lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180117222312.14763-12-fancer.lancer@gmail.com>
Date:   Thu, 18 Jan 2018 01:23:09 +0300
From:   Serge Semin <fancer.lancer@...il.com>
To:     ralf@...ux-mips.org, miodrag.dinic@...s.com, jhogan@...nel.org,
        goran.ferenc@...s.com, david.daney@...ium.com,
        paul.gortmaker@...driver.com, paul.burton@...s.com,
        alex.belits@...ium.com, Steven.Hill@...ium.com
Cc:     alexander.sverdlin@...ia.com, matt.redfearn@...s.com,
        kumba@...too.org, marcin.nowakowski@...s.com, James.hogan@...s.com,
        Peter.Wotton@...s.com, Sergey.Semin@...latforms.ru,
        linux-mips@...ux-mips.org, linux-kernel@...r.kernel.org,
        Serge Semin <fancer.lancer@...il.com>
Subject: [PATCH 11/14] MIPS: memblock: Print out kernel virtual mem layout

It is useful to have the kernel virtual memory layout printed
at boot time so to have the full information about the booted
kernel. In some cases it might be unsafe to have virtual
addresses freely visible in logs, so the %pK format is used if
one want to hide them.

Signed-off-by: Serge Semin <fancer.lancer@...il.com>
---
 arch/mips/mm/init.c | 47 +++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 15040266b..d3e6bb531 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -32,6 +32,7 @@
 #include <linux/kcore.h>
 #include <linux/export.h>
 #include <linux/initrd.h>
+#include <linux/sizes.h>
 
 #include <asm/asm-offsets.h>
 #include <asm/bootinfo.h>
@@ -60,6 +61,51 @@ EXPORT_SYMBOL_GPL(empty_zero_page);
 EXPORT_SYMBOL(zero_page_mask);
 
 /*
+ * Print out the kernel virtual memory layout
+ */
+#define MLK(b, t) (void *)b, (void *)t, ((t) - (b)) >> 10
+#define MLM(b, t) (void *)b, (void *)t, ((t) - (b)) >> 20
+#define MLK_ROUNDUP(b, t) (void *)b, (void *)t, DIV_ROUND_UP(((t) - (b)), SZ_1K)
+static void __init __maybe_unused mem_print_kmap_info(void)
+{
+	pr_notice("Kernel virtual memory layout:\n"
+		  "    lowmem  : 0x%pK - 0x%pK  (%4ld MB)\n"
+		  "      .text : 0x%pK - 0x%pK  (%4td kB)\n"
+		  "      .data : 0x%pK - 0x%pK  (%4td kB)\n"
+		  "      .init : 0x%pK - 0x%pK  (%4td kB)\n"
+		  "      .bss  : 0x%pK - 0x%pK  (%4td kB)\n"
+		  "    vmalloc : 0x%pK - 0x%pK  (%4ld MB)\n"
+#ifdef CONFIG_HIGHMEM
+		  "    pkmap   : 0x%pK - 0x%pK  (%4ld MB)\n"
+#endif
+		  "    fixmap  : 0x%pK - 0x%pK  (%4ld kB)\n",
+		  MLM(PAGE_OFFSET, (unsigned long)high_memory),
+		  MLK_ROUNDUP(_text, _etext),
+		  MLK_ROUNDUP(_sdata, _edata),
+		  MLK_ROUNDUP(__init_begin, __init_end),
+		  MLK_ROUNDUP(__bss_start, __bss_stop),
+		  MLM(VMALLOC_START, VMALLOC_END),
+#ifdef CONFIG_HIGHMEM
+		  MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE)),
+#endif
+		  MLK(FIXADDR_START, FIXADDR_TOP));
+
+	/* Check some fundamental inconsistencies. May add something else? */
+#ifdef CONFIG_HIGHMEM
+	BUILD_BUG_ON(VMALLOC_END < PAGE_OFFSET);
+	BUG_ON(VMALLOC_END < (unsigned long)high_memory);
+	BUILD_BUG_ON((PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE) < PAGE_OFFSET);
+	BUG_ON((PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE) <
+		(unsigned long)high_memory);
+#endif
+	BUILD_BUG_ON(FIXADDR_TOP < PAGE_OFFSET);
+	BUG_ON(FIXADDR_TOP < (unsigned long)high_memory);
+}
+#undef MLK
+#undef MLM
+#undef MLK_ROUNDUP
+
+/*
  * Not static inline because used by IP27 special magic initialization code
  */
 void setup_zero_pages(void)
@@ -468,6 +514,7 @@ void __init mem_init(void)
 	free_all_bootmem();
 	setup_zero_pages();	/* Setup zeroed pages.  */
 	mem_init_free_highmem();
+	mem_print_kmap_info();
 	mem_init_print_info(NULL);
 
 #ifdef CONFIG_64BIT
-- 
2.12.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ