* [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-14 17:05 ` Thomas Garnier
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Garnier @ 2017-03-14 17:05 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Thomas Garnier, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek, Jiri Kosina, Matt Fleming,
Ard Biesheuvel, Boris Ostrovsky, Rusty Russell, Paolo Bonzini,
Borislav Petkov, Christian Borntraeger, Frederic Weisbecker,
Luis R . Rodriguez, Stanislaw Gruszka, Peter Zijlstra,
Josh Poimboeuf, Vitaly Kuznetsov, Tim Chen, Joerg Roedel,
Radim Krčmář
Cc: x86, linux-kernel, linux-doc, kasan-dev, linux-mm, 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-20170308
---
Documentation/x86/x86_64/mm.txt | 5 ++++-
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 +
mm/vmalloc.c | 1 +
6 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index 5724092db811..ee3f9c30957c 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks
ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
... unused hole ...
ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0
-ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable)
ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
@@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be raised later if needed).
The mappings are not part of any other kernel PGD and are only available
during EFI runtime calls.
+The module mapping space size changes based on the CONFIG requirements for the
+following fixmap section.
+
Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all
physical memory, vmalloc/ioremap space and virtual memory map are randomized.
Their order is preserved but their base will be offset early at boot time.
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..bb05e21cf3c7 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t;
#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)
+/* The module sections ends with the start of the fixmap */
+#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
#define ESPFIX_PGD_ENTRY _AC(-2, UL)
#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
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 58b5bee7ea27..75efeecc85eb 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -20,6 +20,7 @@
#include <asm/kasan.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 8d63d7a104c3..1bde19ef86bd 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -9,6 +9,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];
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 32979d945766..1fc9598ed019 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,6 +35,7 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
+#include <asm/fixmap.h>
#include "internal.h"
--
2.12.0.367.g23dc2f6d3c-goog
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-14 17:05 ` Thomas Garnier
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Garnier @ 2017-03-14 17:05 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Thomas Garnier, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek, Jiri Kosina, Matt Fleming,
Ard Biesheuvel
Cc: x86, linux-kernel, linux-doc, kasan-dev, linux-mm, 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-20170308
---
Documentation/x86/x86_64/mm.txt | 5 ++++-
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 +
mm/vmalloc.c | 1 +
6 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index 5724092db811..ee3f9c30957c 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks
ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
... unused hole ...
ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0
-ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable)
ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
@@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be raised later if needed).
The mappings are not part of any other kernel PGD and are only available
during EFI runtime calls.
+The module mapping space size changes based on the CONFIG requirements for the
+following fixmap section.
+
Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all
physical memory, vmalloc/ioremap space and virtual memory map are randomized.
Their order is preserved but their base will be offset early at boot time.
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..bb05e21cf3c7 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t;
#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)
+/* The module sections ends with the start of the fixmap */
+#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
#define ESPFIX_PGD_ENTRY _AC(-2, UL)
#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
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 58b5bee7ea27..75efeecc85eb 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -20,6 +20,7 @@
#include <asm/kasan.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 8d63d7a104c3..1bde19ef86bd 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -9,6 +9,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];
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 32979d945766..1fc9598ed019 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,6 +35,7 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
+#include <asm/fixmap.h>
#include "internal.h"
--
2.12.0.367.g23dc2f6d3c-goog
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-14 17:05 ` Thomas Garnier
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Garnier @ 2017-03-14 17:05 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Thomas Garnier, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek, Jiri Kosina, Matt Fleming,
Ard Biesheuvel
Cc: x86, linux-kernel, linux-doc, kasan-dev, linux-mm, 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-20170308
---
Documentation/x86/x86_64/mm.txt | 5 ++++-
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 +
mm/vmalloc.c | 1 +
6 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index 5724092db811..ee3f9c30957c 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks
ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
... unused hole ...
ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0
-ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable)
ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
@@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be raised later if needed).
The mappings are not part of any other kernel PGD and are only available
during EFI runtime calls.
+The module mapping space size changes based on the CONFIG requirements for the
+following fixmap section.
+
Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all
physical memory, vmalloc/ioremap space and virtual memory map are randomized.
Their order is preserved but their base will be offset early at boot time.
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..bb05e21cf3c7 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t;
#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)
+/* The module sections ends with the start of the fixmap */
+#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
#define ESPFIX_PGD_ENTRY _AC(-2, UL)
#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
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 58b5bee7ea27..75efeecc85eb 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -20,6 +20,7 @@
#include <asm/kasan.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 8d63d7a104c3..1bde19ef86bd 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -9,6 +9,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];
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 32979d945766..1fc9598ed019 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,6 +35,7 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
+#include <asm/fixmap.h>
#include "internal.h"
--
2.12.0.367.g23dc2f6d3c-goog
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-14 17:05 ` Thomas Garnier
(?)
(?)
@ 2017-03-15 13:52 ` Boris Ostrovsky
-1 siblings, 0 replies; 23+ messages in thread
From: Boris Ostrovsky @ 2017-03-15 13:52 UTC (permalink / raw)
To: Thomas Garnier, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
Jonathan Corbet, Andrey Ryabinin, Alexander Potapenko,
Dmitry Vyukov, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek, Jiri Kosina, Matt Fleming,
Ard Biesheuvel, Rusty Russell, Paolo Bonzini, Borislav Petkov,
Christian Borntraeger, Frederic Weisbecker, Luis R . Rodriguez,
Stanislaw Gruszka, Peter Zijlstra, Josh Poimboeuf,
Vitaly Kuznetsov, Tim Chen, Joerg Roedel,
Radim Krčmář
Cc: x86, linux-kernel, linux-doc, kasan-dev, linux-mm, linux-pm,
linux-efi, xen-devel, lguest, kvm, kernel-hardening
On 03/14/2017 01:05 PM, Thomas Garnier wrote:
> 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>
For Xen bits (and to some extent bare-metal):
Reviewed-and-Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-15 13:52 ` Boris Ostrovsky
0 siblings, 0 replies; 23+ messages in thread
From: Boris Ostrovsky @ 2017-03-15 13:52 UTC (permalink / raw)
To: Thomas Garnier, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
Jonathan Corbet, Andrey Ryabinin, Alexander Potapenko,
Dmitry Vyukov, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek, Jiri Kosina, Matt Fleming,
Ard Biesheuvel, Rusty Russell, Paolo Bonzini, Borislav Petkov,
Christian Borntraeger, Frederic Weisbecker, Luis R . Rodriguez,
Stanislaw Gruszka, Peter Zijlstra, Josh Poimboeuf,
Vitaly Kuznetsov, Tim Chen, Joerg Roedel,
Radim Krčmář
Cc: x86, linux-kernel, linux-doc, kasan-dev, linux-mm, linux-pm,
linux-efi, xen-devel, lguest, kvm, kernel-hardening
On 03/14/2017 01:05 PM, Thomas Garnier wrote:
> 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>
For Xen bits (and to some extent bare-metal):
Reviewed-and-Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-15 13:52 ` Boris Ostrovsky
0 siblings, 0 replies; 23+ messages in thread
From: Boris Ostrovsky @ 2017-03-15 13:52 UTC (permalink / raw)
To: Thomas Garnier, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
Jonathan Corbet, Andrey Ryabinin, Alexander Potapenko,
Dmitry Vyukov, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek
Cc: x86, linux-kernel, linux-doc, kasan-dev, linux-mm, linux-pm,
linux-efi, xen-devel, lguest, kvm, kernel-hardening
On 03/14/2017 01:05 PM, Thomas Garnier wrote:
> 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>
For Xen bits (and to some extent bare-metal):
Reviewed-and-Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-15 13:52 ` Boris Ostrovsky
0 siblings, 0 replies; 23+ messages in thread
From: Boris Ostrovsky @ 2017-03-15 13:52 UTC (permalink / raw)
To: Thomas Garnier, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
Jonathan Corbet, Andrey Ryabinin, Alexander Potapenko,
Dmitry Vyukov, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek
Cc: x86, linux-kernel, linux-doc, kasan-dev, linux-mm, linux-pm,
linux-efi, xen-devel, lguest, kvm, kernel-hardening
On 03/14/2017 01:05 PM, Thomas Garnier wrote:
> 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>
For Xen bits (and to some extent bare-metal):
Reviewed-and-Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-14 17:05 ` Thomas Garnier
` (3 preceding siblings ...)
(?)
@ 2017-03-15 13:52 ` Boris Ostrovsky
-1 siblings, 0 replies; 23+ messages in thread
From: Boris Ostrovsky @ 2017-03-15 13:52 UTC (permalink / raw)
To: Thomas Garnier, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
Jonathan Corbet, Andrey Ryabinin, Alexander Potapenko,
Dmitry Vyukov, Lorenzo Stoakes, Kees Cook, Juergen Gross,
Andy Lutomirski, Paul Gortmaker, Andrew Morton, Michal Hocko,
zijun_hu, Chris Wilson, Andy Lutomirski, Rafael J . Wysocki,
Len Brown, Pavel Machek, Jiri Kosina, Matt Fleming,
Ard Biesheuvel
Cc: linux-efi, kvm, linux-pm, x86, linux-doc, linux-kernel,
kasan-dev, linux-mm, lguest, kernel-hardening, xen-devel
On 03/14/2017 01:05 PM, Thomas Garnier wrote:
> 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>
For Xen bits (and to some extent bare-metal):
Reviewed-and-Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-14 17:05 ` Thomas Garnier
(?)
(?)
@ 2017-03-16 8:10 ` Ingo Molnar
-1 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-16 8:10 UTC (permalink / raw)
To: Thomas Garnier
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky, Rusty Russell, Paolo Bonzini, Borislav Petkov,
Christian Borntraeger, Frederic Weisbecker, Luis R . Rodriguez,
Stanislaw Gruszka, Peter Zijlstra, Josh Poimboeuf,
Vitaly Kuznetsov, Tim Chen, Joerg Roedel,
Radim Krčmář,
x86, linux-kernel, linux-doc, kasan-dev, linux-mm, linux-pm,
linux-efi, xen-devel, lguest, kvm, kernel-hardening
* Thomas Garnier <thgarnie@google.com> wrote:
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> 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 +
> mm/vmalloc.c | 1 +
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -35,6 +35,7 @@
> #include <linux/uaccess.h>
> #include <asm/tlbflush.h>
> #include <asm/shmparam.h>
> +#include <asm/fixmap.h>
>
> #include "internal.h"
Note that asm/fixmap.h is an x86-ism that isn't present in many other
architectures, so this hunk will break the build.
To make progress with these patches I've fixed it up with an ugly #ifdef
CONFIG_X86, but it needs a real solution instead before this can be pushed
upstream.
Thanks,
Ingo
=====================>
mm/vmalloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index dabea6a29fad..b7d2a23349f4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,7 +35,10 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
-#include <asm/fixmap.h>
+
+#ifdef CONFIG_X86
+# include <asm/fixmap.h>
+#endif
#include "internal.h"
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-16 8:10 ` Ingo Molnar
0 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-16 8:10 UTC (permalink / raw)
To: Thomas Garnier
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky, Rusty Russell, Paolo Bonzini, Borislav Petkov,
Christian Borntraeger, Frederic Weisbecker, Luis R . Rodriguez,
Stanislaw Gruszka, Peter Zijlstra, Josh Poimboeuf,
Vitaly Kuznetsov, Tim Chen, Joerg Roedel,
Radim Krčmář,
x86, linux-kernel, linux-doc, kasan-dev, linux-mm, linux-pm,
linux-efi, xen-devel, lguest, kvm, kernel-hardening
* Thomas Garnier <thgarnie@google.com> wrote:
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> 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 +
> mm/vmalloc.c | 1 +
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -35,6 +35,7 @@
> #include <linux/uaccess.h>
> #include <asm/tlbflush.h>
> #include <asm/shmparam.h>
> +#include <asm/fixmap.h>
>
> #include "internal.h"
Note that asm/fixmap.h is an x86-ism that isn't present in many other
architectures, so this hunk will break the build.
To make progress with these patches I've fixed it up with an ugly #ifdef
CONFIG_X86, but it needs a real solution instead before this can be pushed
upstream.
Thanks,
Ingo
=====================>
mm/vmalloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index dabea6a29fad..b7d2a23349f4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,7 +35,10 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
-#include <asm/fixmap.h>
+
+#ifdef CONFIG_X86
+# include <asm/fixmap.h>
+#endif
#include "internal.h"
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-16 8:10 ` Ingo Molnar
0 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-16 8:10 UTC (permalink / raw)
To: Thomas Garnier
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky
* Thomas Garnier <thgarnie@google.com> wrote:
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> 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 +
> mm/vmalloc.c | 1 +
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -35,6 +35,7 @@
> #include <linux/uaccess.h>
> #include <asm/tlbflush.h>
> #include <asm/shmparam.h>
> +#include <asm/fixmap.h>
>
> #include "internal.h"
Note that asm/fixmap.h is an x86-ism that isn't present in many other
architectures, so this hunk will break the build.
To make progress with these patches I've fixed it up with an ugly #ifdef
CONFIG_X86, but it needs a real solution instead before this can be pushed
upstream.
Thanks,
Ingo
=====================>
mm/vmalloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index dabea6a29fad..b7d2a23349f4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,7 +35,10 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
-#include <asm/fixmap.h>
+
+#ifdef CONFIG_X86
+# include <asm/fixmap.h>
+#endif
#include "internal.h"
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-16 8:10 ` Ingo Molnar
0 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-16 8:10 UTC (permalink / raw)
To: Thomas Garnier
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky
* Thomas Garnier <thgarnie@google.com> wrote:
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> 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 +
> mm/vmalloc.c | 1 +
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -35,6 +35,7 @@
> #include <linux/uaccess.h>
> #include <asm/tlbflush.h>
> #include <asm/shmparam.h>
> +#include <asm/fixmap.h>
>
> #include "internal.h"
Note that asm/fixmap.h is an x86-ism that isn't present in many other
architectures, so this hunk will break the build.
To make progress with these patches I've fixed it up with an ugly #ifdef
CONFIG_X86, but it needs a real solution instead before this can be pushed
upstream.
Thanks,
Ingo
=====================>
mm/vmalloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index dabea6a29fad..b7d2a23349f4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,7 +35,10 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
-#include <asm/fixmap.h>
+
+#ifdef CONFIG_X86
+# include <asm/fixmap.h>
+#endif
#include "internal.h"
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-16 8:10 ` Ingo Molnar
(?)
@ 2017-03-16 15:33 ` Thomas Garnier
-1 siblings, 0 replies; 23+ messages in thread
From: Thomas Garnier @ 2017-03-16 15:33 UTC (permalink / raw)
To: Ingo Molnar
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky
On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> Note that asm/fixmap.h is an x86-ism that isn't present in many other
> architectures, so this hunk will break the build.
>
> To make progress with these patches I've fixed it up with an ugly #ifdef
> CONFIG_X86, but it needs a real solution instead before this can be pushed
> upstream.
I also saw an error on x86 tip on special configuration. I found this
new patch below to be a good solution to both.
Let me know what you think.
=====
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-20170308
---
Documentation/x86/x86_64/mm.txt | 5 ++++-
arch/x86/include/asm/pgtable_64.h | 1 +
arch/x86/include/asm/pgtable_64_types.h | 3 ++-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index 5724092db811..ee3f9c30957c 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp
fixup stacks
ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
... unused hole ...
ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0
-ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable)
ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
@@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be
raised later if needed).
The mappings are not part of any other kernel PGD and are only available
during EFI runtime calls.
+The module mapping space size changes based on the CONFIG requirements for the
+following fixmap section.
+
Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all
physical memory, vmalloc/ioremap space and virtual memory map are randomized.
Their order is preserved but their base will be offset early at boot time.
diff --git a/arch/x86/include/asm/pgtable_64.h
b/arch/x86/include/asm/pgtable_64.h
index 73c7ccc38912..67608d4abc2c 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -13,6 +13,7 @@
#include <asm/processor.h>
#include <linux/bitops.h>
#include <linux/threads.h>
+#include <asm/fixmap.h>
extern pud_t level3_kernel_pgt[512];
extern pud_t level3_ident_pgt[512];
diff --git a/arch/x86/include/asm/pgtable_64_types.h
b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..bb05e21cf3c7 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t;
#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)
+/* The module sections ends with the start of the fixmap */
+#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
#define ESPFIX_PGD_ENTRY _AC(-2, UL)
#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
--
2.12.0.367.g23dc2f6d3c-goog
--
Thomas
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-16 15:33 ` Thomas Garnier
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Garnier @ 2017-03-16 15:33 UTC (permalink / raw)
To: Ingo Molnar
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky, Rusty Russell, Paolo Bonzini, Borislav Petkov,
Christian Borntraeger, Frederic Weisbecker, Luis R . Rodriguez,
Stanislaw Gruszka, Peter Zijlstra, Josh Poimboeuf,
Vitaly Kuznetsov, Tim Chen, Joerg Roedel,
Radim Krčmář,
the arch/x86 maintainers, LKML, linux-doc, kasan-dev, Linux-MM,
Linux PM list, linux-efi, xen-devel, lguest, kvm list,
Kernel Hardening
On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> Note that asm/fixmap.h is an x86-ism that isn't present in many other
> architectures, so this hunk will break the build.
>
> To make progress with these patches I've fixed it up with an ugly #ifdef
> CONFIG_X86, but it needs a real solution instead before this can be pushed
> upstream.
I also saw an error on x86 tip on special configuration. I found this
new patch below to be a good solution to both.
Let me know what you think.
=====
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-20170308
---
Documentation/x86/x86_64/mm.txt | 5 ++++-
arch/x86/include/asm/pgtable_64.h | 1 +
arch/x86/include/asm/pgtable_64_types.h | 3 ++-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index 5724092db811..ee3f9c30957c 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp
fixup stacks
ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
... unused hole ...
ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0
-ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable)
ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
@@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be
raised later if needed).
The mappings are not part of any other kernel PGD and are only available
during EFI runtime calls.
+The module mapping space size changes based on the CONFIG requirements for the
+following fixmap section.
+
Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all
physical memory, vmalloc/ioremap space and virtual memory map are randomized.
Their order is preserved but their base will be offset early at boot time.
diff --git a/arch/x86/include/asm/pgtable_64.h
b/arch/x86/include/asm/pgtable_64.h
index 73c7ccc38912..67608d4abc2c 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -13,6 +13,7 @@
#include <asm/processor.h>
#include <linux/bitops.h>
#include <linux/threads.h>
+#include <asm/fixmap.h>
extern pud_t level3_kernel_pgt[512];
extern pud_t level3_ident_pgt[512];
diff --git a/arch/x86/include/asm/pgtable_64_types.h
b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..bb05e21cf3c7 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t;
#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)
+/* The module sections ends with the start of the fixmap */
+#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
#define ESPFIX_PGD_ENTRY _AC(-2, UL)
#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
--
2.12.0.367.g23dc2f6d3c-goog
--
Thomas
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-16 15:33 ` Thomas Garnier
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Garnier @ 2017-03-16 15:33 UTC (permalink / raw)
To: Ingo Molnar
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky
On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> Note that asm/fixmap.h is an x86-ism that isn't present in many other
> architectures, so this hunk will break the build.
>
> To make progress with these patches I've fixed it up with an ugly #ifdef
> CONFIG_X86, but it needs a real solution instead before this can be pushed
> upstream.
I also saw an error on x86 tip on special configuration. I found this
new patch below to be a good solution to both.
Let me know what you think.
=====
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-20170308
---
Documentation/x86/x86_64/mm.txt | 5 ++++-
arch/x86/include/asm/pgtable_64.h | 1 +
arch/x86/include/asm/pgtable_64_types.h | 3 ++-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index 5724092db811..ee3f9c30957c 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp
fixup stacks
ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
... unused hole ...
ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0
-ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable)
ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
@@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be
raised later if needed).
The mappings are not part of any other kernel PGD and are only available
during EFI runtime calls.
+The module mapping space size changes based on the CONFIG requirements for the
+following fixmap section.
+
Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all
physical memory, vmalloc/ioremap space and virtual memory map are randomized.
Their order is preserved but their base will be offset early at boot time.
diff --git a/arch/x86/include/asm/pgtable_64.h
b/arch/x86/include/asm/pgtable_64.h
index 73c7ccc38912..67608d4abc2c 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -13,6 +13,7 @@
#include <asm/processor.h>
#include <linux/bitops.h>
#include <linux/threads.h>
+#include <asm/fixmap.h>
extern pud_t level3_kernel_pgt[512];
extern pud_t level3_ident_pgt[512];
diff --git a/arch/x86/include/asm/pgtable_64_types.h
b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..bb05e21cf3c7 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t;
#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)
+/* The module sections ends with the start of the fixmap */
+#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
#define ESPFIX_PGD_ENTRY _AC(-2, UL)
#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
--
2.12.0.367.g23dc2f6d3c-goog
--
Thomas
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-16 15:33 ` Thomas Garnier
(?)
@ 2017-03-17 7:34 ` Ingo Molnar
-1 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-17 7:34 UTC (permalink / raw)
To: Thomas Garnier
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky
* Thomas Garnier <thgarnie@google.com> wrote:
> On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > Note that asm/fixmap.h is an x86-ism that isn't present in many other
> > architectures, so this hunk will break the build.
> >
> > To make progress with these patches I've fixed it up with an ugly #ifdef
> > CONFIG_X86, but it needs a real solution instead before this can be pushed
> > upstream.
>
> I also saw an error on x86 tip on special configuration. I found this
> new patch below to be a good solution to both.
>
> Let me know what you think.
>
> =====
>
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> arch/x86/include/asm/pgtable_64.h | 1 +
> arch/x86/include/asm/pgtable_64_types.h | 3 ++-
> 3 files changed, 7 insertions(+), 2 deletions(-)
The patch is heavily whitespace and line wrap damaged :-(
Please send a properly titled, changelogged delta patch against tip:master (or
tip:x86/mm) to remove the CONFIG_X86 hack and fix the build bug.
Thanks,
Ingo
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-17 7:34 ` Ingo Molnar
0 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-17 7:34 UTC (permalink / raw)
To: Thomas Garnier
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky, Rusty Russell, Paolo Bonzini, Borislav Petkov,
Christian Borntraeger, Frederic Weisbecker, Luis R . Rodriguez,
Stanislaw Gruszka, Peter Zijlstra, Josh Poimboeuf,
Vitaly Kuznetsov, Tim Chen, Joerg Roedel,
Radim Krčmář,
the arch/x86 maintainers, LKML, linux-doc, kasan-dev, Linux-MM,
Linux PM list, linux-efi, xen-devel, lguest, kvm list,
Kernel Hardening
* Thomas Garnier <thgarnie@google.com> wrote:
> On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > Note that asm/fixmap.h is an x86-ism that isn't present in many other
> > architectures, so this hunk will break the build.
> >
> > To make progress with these patches I've fixed it up with an ugly #ifdef
> > CONFIG_X86, but it needs a real solution instead before this can be pushed
> > upstream.
>
> I also saw an error on x86 tip on special configuration. I found this
> new patch below to be a good solution to both.
>
> Let me know what you think.
>
> =====
>
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> arch/x86/include/asm/pgtable_64.h | 1 +
> arch/x86/include/asm/pgtable_64_types.h | 3 ++-
> 3 files changed, 7 insertions(+), 2 deletions(-)
The patch is heavily whitespace and line wrap damaged :-(
Please send a properly titled, changelogged delta patch against tip:master (or
tip:x86/mm) to remove the CONFIG_X86 hack and fix the build bug.
Thanks,
Ingo
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
@ 2017-03-17 7:34 ` Ingo Molnar
0 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-17 7:34 UTC (permalink / raw)
To: Thomas Garnier
Cc: Thomas Gleixner, Ingo Molnar, H . Peter Anvin, Jonathan Corbet,
Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Lorenzo Stoakes, Kees Cook, Juergen Gross, Andy Lutomirski,
Paul Gortmaker, Andrew Morton, Michal Hocko, zijun_hu,
Chris Wilson, Andy Lutomirski, Rafael J . Wysocki, Len Brown,
Pavel Machek, Jiri Kosina, Matt Fleming, Ard Biesheuvel,
Boris Ostrovsky
* Thomas Garnier <thgarnie@google.com> wrote:
> On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > Note that asm/fixmap.h is an x86-ism that isn't present in many other
> > architectures, so this hunk will break the build.
> >
> > To make progress with these patches I've fixed it up with an ugly #ifdef
> > CONFIG_X86, but it needs a real solution instead before this can be pushed
> > upstream.
>
> I also saw an error on x86 tip on special configuration. I found this
> new patch below to be a good solution to both.
>
> Let me know what you think.
>
> =====
>
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> arch/x86/include/asm/pgtable_64.h | 1 +
> arch/x86/include/asm/pgtable_64_types.h | 3 ++-
> 3 files changed, 7 insertions(+), 2 deletions(-)
The patch is heavily whitespace and line wrap damaged :-(
Please send a properly titled, changelogged delta patch against tip:master (or
tip:x86/mm) to remove the CONFIG_X86 hack and fix the build bug.
Thanks,
Ingo
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-16 15:33 ` Thomas Garnier
` (2 preceding siblings ...)
(?)
@ 2017-03-17 7:34 ` Ingo Molnar
-1 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-17 7:34 UTC (permalink / raw)
To: Thomas Garnier
Cc: Michal Hocko, Stanislaw Gruszka, linux-doc, kvm list,
Radim Krčmář,
Matt Fleming, Frederic Weisbecker, Chris Wilson, Linux-MM,
Paul Gortmaker, linux-efi, Alexander Potapenko, Pavel Machek,
H . Peter Anvin, Kernel Hardening, Boris Ostrovsky, zijun_hu,
lguest, xen-devel, Jonathan Corbet, Joerg Roedel,
the arch/x86 maintainers, kasan-dev
* Thomas Garnier <thgarnie@google.com> wrote:
> On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > Note that asm/fixmap.h is an x86-ism that isn't present in many other
> > architectures, so this hunk will break the build.
> >
> > To make progress with these patches I've fixed it up with an ugly #ifdef
> > CONFIG_X86, but it needs a real solution instead before this can be pushed
> > upstream.
>
> I also saw an error on x86 tip on special configuration. I found this
> new patch below to be a good solution to both.
>
> Let me know what you think.
>
> =====
>
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> arch/x86/include/asm/pgtable_64.h | 1 +
> arch/x86/include/asm/pgtable_64_types.h | 3 ++-
> 3 files changed, 7 insertions(+), 2 deletions(-)
The patch is heavily whitespace and line wrap damaged :-(
Please send a properly titled, changelogged delta patch against tip:master (or
tip:x86/mm) to remove the CONFIG_X86 hack and fix the build bug.
Thanks,
Ingo
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-16 8:10 ` Ingo Molnar
` (3 preceding siblings ...)
(?)
@ 2017-03-16 15:33 ` Thomas Garnier
-1 siblings, 0 replies; 23+ messages in thread
From: Thomas Garnier @ 2017-03-16 15:33 UTC (permalink / raw)
To: Ingo Molnar
Cc: Michal Hocko, Stanislaw Gruszka, linux-doc, kvm list,
Radim Krčmář,
Matt Fleming, Frederic Weisbecker, Chris Wilson, Linux-MM,
Paul Gortmaker, linux-efi, Alexander Potapenko, Pavel Machek,
H . Peter Anvin, Kernel Hardening, Boris Ostrovsky, zijun_hu,
lguest, xen-devel, Jonathan Corbet, Joerg Roedel,
the arch/x86 maintainers, kasan-dev
On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> Note that asm/fixmap.h is an x86-ism that isn't present in many other
> architectures, so this hunk will break the build.
>
> To make progress with these patches I've fixed it up with an ugly #ifdef
> CONFIG_X86, but it needs a real solution instead before this can be pushed
> upstream.
I also saw an error on x86 tip on special configuration. I found this
new patch below to be a good solution to both.
Let me know what you think.
=====
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-20170308
---
Documentation/x86/x86_64/mm.txt | 5 ++++-
arch/x86/include/asm/pgtable_64.h | 1 +
arch/x86/include/asm/pgtable_64_types.h | 3 ++-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt
index 5724092db811..ee3f9c30957c 100644
--- a/Documentation/x86/x86_64/mm.txt
+++ b/Documentation/x86/x86_64/mm.txt
@@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp
fixup stacks
ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
... unused hole ...
ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0
-ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable)
ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
@@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be
raised later if needed).
The mappings are not part of any other kernel PGD and are only available
during EFI runtime calls.
+The module mapping space size changes based on the CONFIG requirements for the
+following fixmap section.
+
Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all
physical memory, vmalloc/ioremap space and virtual memory map are randomized.
Their order is preserved but their base will be offset early at boot time.
diff --git a/arch/x86/include/asm/pgtable_64.h
b/arch/x86/include/asm/pgtable_64.h
index 73c7ccc38912..67608d4abc2c 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -13,6 +13,7 @@
#include <asm/processor.h>
#include <linux/bitops.h>
#include <linux/threads.h>
+#include <asm/fixmap.h>
extern pud_t level3_kernel_pgt[512];
extern pud_t level3_ident_pgt[512];
diff --git a/arch/x86/include/asm/pgtable_64_types.h
b/arch/x86/include/asm/pgtable_64_types.h
index 3a264200c62f..bb05e21cf3c7 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t;
#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)
+/* The module sections ends with the start of the fixmap */
+#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
#define MODULES_LEN (MODULES_END - MODULES_VADDR)
#define ESPFIX_PGD_ENTRY _AC(-2, UL)
#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
--
2.12.0.367.g23dc2f6d3c-goog
--
Thomas
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v7 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size
2017-03-14 17:05 ` Thomas Garnier
` (5 preceding siblings ...)
(?)
@ 2017-03-16 8:10 ` Ingo Molnar
-1 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2017-03-16 8:10 UTC (permalink / raw)
To: Thomas Garnier
Cc: Michal Hocko, Stanislaw Gruszka, linux-doc, kvm,
Radim Krčmář,
Matt Fleming, Frederic Weisbecker, Chris Wilson, linux-mm,
Paul Gortmaker, linux-efi, Alexander Potapenko, Pavel Machek,
H . Peter Anvin, kernel-hardening, Boris Ostrovsky, zijun_hu,
lguest, xen-devel, Jonathan Corbet, Joerg Roedel, x86, kasan-dev,
Christian Borntraeger, Ingo Molnar
* Thomas Garnier <thgarnie@google.com> wrote:
> 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-20170308
> ---
> Documentation/x86/x86_64/mm.txt | 5 ++++-
> 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 +
> mm/vmalloc.c | 1 +
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -35,6 +35,7 @@
> #include <linux/uaccess.h>
> #include <asm/tlbflush.h>
> #include <asm/shmparam.h>
> +#include <asm/fixmap.h>
>
> #include "internal.h"
Note that asm/fixmap.h is an x86-ism that isn't present in many other
architectures, so this hunk will break the build.
To make progress with these patches I've fixed it up with an ugly #ifdef
CONFIG_X86, but it needs a real solution instead before this can be pushed
upstream.
Thanks,
Ingo
=====================>
mm/vmalloc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index dabea6a29fad..b7d2a23349f4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -35,7 +35,10 @@
#include <linux/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
-#include <asm/fixmap.h>
+
+#ifdef CONFIG_X86
+# include <asm/fixmap.h>
+#endif
#include "internal.h"
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 23+ messages in thread