All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-01-26 16:59 ` Thomas Garnier
  0 siblings, 0 replies; 38+ messages in thread
From: Thomas Garnier @ 2017-01-26 16:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Andrey Ryabinin,
	Alexander Potapenko, Dmitry Vyukov, Thomas Garnier, Kees Cook,
	Andy Lutomirski, Arjan van de Ven, Paul Gortmaker,
	Borislav Petkov, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
	Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
	Boris Ostrovsky, Juergen Gross, Rusty Russell,
	Christian Borntraeger, Fenghua Yu, He Chen, Brian Gerst,
	Luis R . Rodriguez, Adam Buchbinder, Stanislaw Gruszka,
	Arnd Bergmann, Dave Hansen, Chen Yucong, Vitaly Kuznetsov,
	David Vrabel, Josh Poimboeuf, Tim Chen, Rik van Riel, Andi Kleen,
	Jiri Olsa, Prarit Bhargava, Michael Ellerman, Joerg Roedel,
	Paolo Bonzini, Radim Krčmář
  Cc: x86, linux-kernel, kasan-dev, linux-pm, linux-efi, xen-devel,
	lguest, kvm, kernel-hardening

This patch aligns MODULES_END to the beginning of the Fixmap section.
It optimizes the space available for both sections. The address is
pre-computed based on the number of pages required by the Fixmap
section.

It will allow GDT remapping in the Fixmap section. The current
MODULES_END static address does not provide enough space for the kernel
to support a large number of processors.

Signed-off-by: Thomas Garnier <thgarnie@google.com>
---
Based on next-20170125
---
 arch/x86/include/asm/fixmap.h           | 8 ++++++++
 arch/x86/include/asm/pgtable_64_types.h | 3 ---
 arch/x86/kernel/module.c                | 1 +
 arch/x86/mm/dump_pagetables.c           | 1 +
 arch/x86/mm/kasan_init_64.c             | 1 +
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 8554f960e21b..c46289799b02 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -132,6 +132,14 @@ enum fixed_addresses {
 
 extern void reserve_top_address(unsigned long reserve);
 
+/* On 64bit, the module sections ends with the start of the fixmap */
+#ifdef CONFIG_X86_64
+#define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
+#define MODULES_END   __fix_to_virt(__end_of_fixed_addresses + 1)
+#define MODULES_LEN   (MODULES_END - MODULES_VADDR)
+#endif /* CONFIG_X86_64 */
+
+
 #define FIXADDR_SIZE	(__end_of_permanent_fixed_addresses << PAGE_SHIFT)
 #define FIXADDR_START		(FIXADDR_TOP - FIXADDR_SIZE)
 
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..de8bace10200 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -66,9 +66,6 @@ typedef struct { pteval_t pte; } pte_t;
 #define VMEMMAP_START	__VMEMMAP_BASE
 #endif /* CONFIG_RANDOMIZE_MEMORY */
 #define VMALLOC_END	(VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
-#define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
-#define MODULES_END      _AC(0xffffffffff000000, UL)
-#define MODULES_LEN   (MODULES_END - MODULES_VADDR)
 #define ESPFIX_PGD_ENTRY _AC(-2, UL)
 #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
 #define EFI_VA_START	 ( -4 * (_AC(1, UL) << 30))
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index 477ae806c2fa..fad61caac75e 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -35,6 +35,7 @@
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/setup.h>
+#include <asm/fixmap.h>
 
 #if 0
 #define DEBUGP(fmt, ...)				\
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index ea9c49adaa1f..eefd6d015d02 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -18,6 +18,7 @@
 #include <linux/seq_file.h>
 
 #include <asm/pgtable.h>
+#include <asm/fixmap.h>
 
 /*
  * The dumper groups pagetable entries of the same type into one, and for
diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c
index 0493c17b8a51..34f167cf3316 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -8,6 +8,7 @@
 
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
+#include <asm/fixmap.h>
 
 extern pgd_t early_level4_pgt[PTRS_PER_PGD];
 extern struct range pfn_mapped[E820_X_MAX];
-- 
2.11.0.483.g087da7b7c-goog

^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2017-02-06 22:10 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 16:59 [PATCH v2 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size Thomas Garnier
2017-01-26 16:59 ` [kernel-hardening] " Thomas Garnier
2017-01-26 16:59 ` Thomas Garnier
2017-01-26 16:59 ` Thomas Garnier
2017-01-26 16:59 ` [PATCH v2 2/3] x86: Remap GDT tables in the Fixmap section Thomas Garnier
2017-01-26 16:59 ` Thomas Garnier
2017-01-26 16:59   ` [kernel-hardening] " Thomas Garnier
2017-01-26 16:59   ` Thomas Garnier
2017-01-26 16:59   ` Thomas Garnier
2017-01-26 18:52   ` Andy Lutomirski
2017-01-26 18:52     ` [kernel-hardening] " Andy Lutomirski
2017-01-26 19:10     ` Thomas Garnier
2017-01-26 19:10       ` [kernel-hardening] " Thomas Garnier
2017-01-26 19:10     ` Thomas Garnier
2017-01-26 18:52   ` Andy Lutomirski
2017-01-26 16:59 ` [PATCH v2 3/3] x86: Make the GDT remapping read-only on 64 bit Thomas Garnier
2017-01-26 16:59 ` Thomas Garnier
2017-01-26 16:59   ` [kernel-hardening] " Thomas Garnier
2017-01-26 16:59   ` Thomas Garnier
2017-01-26 16:59   ` Thomas Garnier
2017-02-01  9:15   ` Ingo Molnar
2017-02-01  9:15     ` [kernel-hardening] " Ingo Molnar
2017-02-01  9:15     ` Ingo Molnar
2017-02-02  5:13     ` Andy Lutomirski
2017-02-02  5:13     ` Andy Lutomirski
2017-02-02  5:13       ` [kernel-hardening] " Andy Lutomirski
2017-02-02  5:13       ` Andy Lutomirski
2017-02-02  7:12       ` Ingo Molnar
2017-02-02  7:12         ` [kernel-hardening] " Ingo Molnar
2017-02-02  7:12         ` Ingo Molnar
2017-02-02  7:12       ` Ingo Molnar
2017-02-01  9:15   ` Ingo Molnar
2017-02-02  5:14   ` Andy Lutomirski
2017-02-02  5:14   ` Andy Lutomirski
2017-02-02  5:14     ` [kernel-hardening] " Andy Lutomirski
2017-02-06 22:10     ` Thomas Garnier
2017-02-06 22:10     ` Thomas Garnier
2017-02-06 22:10       ` [kernel-hardening] " Thomas Garnier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.