diff mbox

[v1,1/3] x86/mm: Adapt MODULES_END based on Fixmap section size

Message ID 20170120164126.27624-1-thgarnie@google.com
State New, archived
Headers show

Commit Message

Thomas Garnier Jan. 20, 2017, 4:41 p.m. UTC
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-20170119
---
 arch/x86/include/asm/fixmap.h           | 8 ++++++++
 arch/x86/include/asm/pgtable_64_types.h | 3 ---
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

Andy Lutomirski Jan. 20, 2017, 10:24 p.m. UTC | #1
On Fri, Jan 20, 2017 at 8:41 AM, 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>

Looks good to me.
kernel test robot Jan. 21, 2017, 2:43 a.m. UTC | #2
Hi Thomas,

[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.10-rc4 next-20170120]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Thomas-Garnier/x86-mm-Adapt-MODULES_END-based-on-Fixmap-section-size/20170121-094756
config: x86_64-randconfig-x002-201703 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   arch/x86/mm/kasan_init_64.c: In function 'kasan_init':
>> arch/x86/mm/kasan_init_64.c:120:57: error: 'MODULES_END' undeclared (first use in this function)
     kasan_populate_zero_shadow(kasan_mem_to_shadow((void *)MODULES_END),
                                                            ^~~~~~~~~~~
   arch/x86/mm/kasan_init_64.c:120:57: note: each undeclared identifier is reported only once for each function it appears in

vim +/MODULES_END +120 arch/x86/mm/kasan_init_64.c

c420f167d Andrey Ryabinin 2015-02-13  114  		kasan_mem_to_shadow((void *)__START_KERNEL_map));
c420f167d Andrey Ryabinin 2015-02-13  115  
c420f167d Andrey Ryabinin 2015-02-13  116  	vmemmap_populate((unsigned long)kasan_mem_to_shadow(_stext),
c420f167d Andrey Ryabinin 2015-02-13  117  			(unsigned long)kasan_mem_to_shadow(_end),
c420f167d Andrey Ryabinin 2015-02-13  118  			NUMA_NO_NODE);
c420f167d Andrey Ryabinin 2015-02-13  119  
69786cdb3 Andrey Ryabinin 2015-08-13 @120  	kasan_populate_zero_shadow(kasan_mem_to_shadow((void *)MODULES_END),
ef7f0d6a6 Andrey Ryabinin 2015-02-13  121  			(void *)KASAN_SHADOW_END);
ef7f0d6a6 Andrey Ryabinin 2015-02-13  122  
ef7f0d6a6 Andrey Ryabinin 2015-02-13  123  	load_cr3(init_level4_pgt);

:::::: The code at line 120 was first introduced by commit
:::::: 69786cdb379bbc6eab14cf2393c1abd879316e85 x86/kasan, mm: Introduce generic kasan_populate_zero_shadow()

:::::: TO: Andrey Ryabinin <ryabinin.a.a@gmail.com>
:::::: CC: Ingo Molnar <mingo@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Jan. 21, 2017, 3:21 a.m. UTC | #3
Hi Thomas,

[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.10-rc4 next-20170120]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Thomas-Garnier/x86-mm-Adapt-MODULES_END-based-on-Fixmap-section-size/20170121-094756
config: x86_64-randconfig-x008-201703 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> arch/x86/mm/dump_pagetables.c:85:4: error: 'MODULES_VADDR' undeclared here (not in a function)
     { MODULES_VADDR,        "Modules" },
       ^~~~~~~~~~~~~
>> arch/x86/mm/dump_pagetables.c:86:4: error: 'MODULES_END' undeclared here (not in a function)
     { MODULES_END,          "End Modules" },
       ^~~~~~~~~~~

vim +/MODULES_VADDR +85 arch/x86/mm/dump_pagetables.c

3891a04aa H. Peter Anvin 2014-04-29  79  	{ ESPFIX_BASE_ADDR,	"ESPfix Area", 16 },
8a5a5d153 Mathias Krause 2014-09-07  80  # endif
8266e31ed Mathias Krause 2014-09-21  81  # ifdef CONFIG_EFI
8266e31ed Mathias Krause 2014-09-21  82  	{ EFI_VA_END,		"EFI Runtime Services" },
8266e31ed Mathias Krause 2014-09-21  83  # endif
fe770bf03 H. Peter Anvin 2008-04-17  84  	{ __START_KERNEL_map,   "High Kernel Mapping" },
9a79cf9c1 Yinghai Lu     2008-03-07 @85  	{ MODULES_VADDR,        "Modules" },
9a79cf9c1 Yinghai Lu     2008-03-07 @86  	{ MODULES_END,          "End Modules" },
fe770bf03 H. Peter Anvin 2008-04-17  87  #else
fe770bf03 H. Peter Anvin 2008-04-17  88  	{ PAGE_OFFSET,          "Kernel Mapping" },
fe770bf03 H. Peter Anvin 2008-04-17  89  	{ 0/* VMALLOC_START */, "vmalloc() Area" },

:::::: The code at line 85 was first introduced by commit
:::::: 9a79cf9c1aa671325fa5ba37576c2cee23823d04 x86: sort address_markers for dump_pagetables

:::::: TO: Yinghai Lu <yhlu.kernel@gmail.com>
:::::: CC: Ingo Molnar <mingo@elte.hu>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

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))