x86/head: Refactor 32-bit pgtable setup
PATCH 1/1 x86/head: Refactor 32-bit pgtable setup
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of head_32.S so that mk_early_pgtbl_32 can be invoked from both the new Xen entry point and the existing startup_32 code.
Convert resulting common code to C.
---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)
arch/x86/include/asm/pgtable_32.h +32 -0
@@ -27,6 +27,7 @@extern pgd_t swapper_pg_dir[1024 ];extern pgd_t initial_page_table[1024 ]; +extern pmd_t initial_pg_pmd[];static inline void pgtable_cache_init (void ) { }static inline void check_pgt_cache (void ) { }
@@ -75,4 +76,35 @@ static inline void check_pgt_cache(void) { }#define kern_addr_valid (kaddr) (0)#endif +/* +* This is how much memory in addition to the memory covered up to +* and including _end we need mapped initially. +* We need: +* (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE) +* (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE) +* +* Modulo rounding, each megabyte assigned here requires a kilobyte of +* memory, which is currently unreclaimed. +* +* This should be a multiple of a page. +* +* KERNEL_IMAGE_SIZE should be greater than pa(_end) +* and small than max_low_pfn, otherwise will waste some page table entries +*/ +#if PTRS_PER_PMD >1 +#define PAGE_TABLE_SIZE (pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD) +#else +#define PAGE_TABLE_SIZE (pages) ((pages) / PTRS_PER_PGD) +#endif + +/* +* Number of possible pages in the lowmem region. +* +* We shift 2 by 31 instead of 1 by 32 to the left in order to avoid a +* gas warning about overflowing shift count when gas has been compiled +* with only a host target support using a 32-bit type for internal +* representation. +*/ +#define LOWMEM_PAGES ((((2<<31) - __PAGE_OFFSET) >> PAGE_SHIFT)) +#endif /* _ASM_X86_PGTABLE_32_H */
arch/x86/kernel/head32.c +62 -0
65 lines not on this page · raw message
arch/x86/kernel/head_32.S +7 -115
150 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)
Whee, I love it! And the code is so much more readable!
Did you have any particular robustness problems (difficult to resolve crashes) while developing it, or was it reasonably straightforward to do?
Thanks,
Ingo
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)
Whee, I love it! And the code is so much more readable!
Did you have any particular robustness problems (difficult to resolve crashes) while developing it, or was it reasonably straightforward to do?
Thanks,
Ingo
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.
Quoted 8 lines
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)Whee, I love it! And the code is so much more readable!
Did you have any particular robustness problems (difficult to resolve crashes) while developing it, or was it reasonably straightforward to do?
There was nothing particularly difficult beyond understanding current code. That, of course, is not to say that there were no crashes but developing this on a guest gives you pretty good insight into why/where you crashed.
This was tested on bare-metal (in case you are wondering), but obviously more testing is always good.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.
Quoted 8 lines
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)Whee, I love it! And the code is so much more readable!
Did you have any particular robustness problems (difficult to resolve crashes) while developing it, or was it reasonably straightforward to do?
There was nothing particularly difficult beyond understanding current code. That, of course, is not to say that there were no crashes but developing this on a guest gives you pretty good insight into why/where you crashed.
This was tested on bare-metal (in case you are wondering), but obviously more testing is always good.
-boris
Ingo Molnar
Acked-byQuoted 27 lines · Boris Ostrovsky
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.Quoted 8 lines
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)Whee, I love it! And the code is so much more readable!
Did you have any particular robustness problems (difficult to resolve crashes) while developing it, or was it reasonably straightforward to do?
Quoted 7 lines
There was nothing particularly difficult beyond understanding current code. That, of course, is not to say that there were no crashes but developing this on a guest gives you pretty good insight into why/where you crashed.
This was tested on bare-metal (in case you are wondering), but obviously more testing is always good.
Ok, cool!
Would you like to carry this with your other Xen dependencies? If yes:
If not then I can pick it up and get it to Linus in v4.10.
Thanks,
Ingo
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 35 lines · Ingo Molnar
Quoted 26 lines · Boris Ostrovsky
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.Quoted 8 lines
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)Whee, I love it! And the code is so much more readable!
Did you have any particular robustness problems (difficult to resolve crashes) while developing it, or was it reasonably straightforward to do?
Quoted 7 lines
There was nothing particularly difficult beyond understanding current code. That, of course, is not to say that there were no crashes but developing this on a guest gives you pretty good insight into why/where you crashed.
This was tested on bare-metal (in case you are wondering), but obviously more testing is always good.
Quoted 7 lines
Ok, cool!
Would you like to carry this with your other Xen dependencies? If yes:
Acked-by Ingo Molnar <[email protected]>If not then I can pick it up and get it to Linus in v4.10.
I don't think my series will get into 4.10 since it is has a dependency on hypervisor code that is still being reviewed.
If you could take it via your tree it would be great. Thanks!
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 35 lines · Ingo Molnar
Quoted 26 lines · Boris Ostrovsky
Quoted 17 lines · Ingo Molnar
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.Quoted 8 lines
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)Whee, I love it! And the code is so much more readable!
Did you have any particular robustness problems (difficult to resolve crashes) while developing it, or was it reasonably straightforward to do?
Quoted 7 lines
There was nothing particularly difficult beyond understanding current code. That, of course, is not to say that there were no crashes but developing this on a guest gives you pretty good insight into why/where you crashed.
This was tested on bare-metal (in case you are wondering), but obviously more testing is always good.
Quoted 7 lines
Ok, cool!
Would you like to carry this with your other Xen dependencies? If yes:
Acked-by Ingo Molnar <[email protected]>If not then I can pick it up and get it to Linus in v4.10.
I don't think my series will get into 4.10 since it is has a dependency on hypervisor code that is still being reviewed.
If you could take it via your tree it would be great. Thanks!
-boris
Quoted 15 lines · Boris Ostrovsky
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of
head_32.Sso thatmk_early_pgtbl_32can be invoked from both the new Xen entry point and the existingstartup_32code.Convert resulting common code to C.
Signed-off-by Boris Ostrovsky <[email protected]>---
This is replacement for https://lkml.org/lkml/2016/10/14/434, with assembly code re-written in C as requested by Ingo.
Quoted 4 lines
arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)
Yeah, so (belatedly) I tried to merge this to latest upstream, via the commit below (note the slight edits to the changelog) - but 32-bit defconfig fails to build:
arch/x86/kernel/head_32.S:615: Error: can't resolve init_thread_union' {*UND* section} - SIZEOF_PTREGS' {*UND* section}
Thanks,
Ingo
=======================>
From 071878c634fda7d9be3f015f05a89f5468e7e2e4 Mon Sep 17 00:00:00 2001
From: Boris Ostrovsky <[email protected]>
Date: Thu, 8 Dec 2016 11:44:31 -0500
Subject: [PATCH] x86/boot/32: Convert the 32-bit pgtable setup code from assembly to C
The new Xen PVH entry point requires page tables to be set up by the kernel since it is entered with paging disabled.
Pull the common code out of head_32.S so that mk_early_pgtbl_32() can be invoked from both the new Xen entry point and the existing startup_32() code.
Convert resulting common code to C.
--- arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 122 +++----------------------------------- 3 files changed, 101 insertions(+), 115 deletions(-)
arch/x86/include/asm/pgtable_32.h +32 -0
@@ -27,6 +27,7 @@ struct vm_area_struct;extern pgd_t swapper_pg_dir[1024 ];extern pgd_t initial_page_table[1024 ]; +extern pmd_t initial_pg_pmd[];static inline void pgtable_cache_init (void ) { }static inline void check_pgt_cache (void ) { }
@@ -75,4 +76,35 @@ do { \#define kern_addr_valid (kaddr) (0)#endif +/* +* This is how much memory in addition to the memory covered up to +* and including _end we need mapped initially. +* We need: +* (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE) +* (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE) +* +* Modulo rounding, each megabyte assigned here requires a kilobyte of +* memory, which is currently unreclaimed. +* +* This should be a multiple of a page. +* +* KERNEL_IMAGE_SIZE should be greater than pa(_end) +* and small than max_low_pfn, otherwise will waste some page table entries +*/ +#if PTRS_PER_PMD >1 +#define PAGE_TABLE_SIZE (pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD) +#else +#define PAGE_TABLE_SIZE (pages) ((pages) / PTRS_PER_PGD) +#endif + +/* +* Number of possible pages in the lowmem region. +* +* We shift 2 by 31 instead of 1 by 32 to the left in order to avoid a +* gas warning about overflowing shift count when gas has been compiled +* with only a host target support using a 32-bit type for internal +* representation. +*/ +#define LOWMEM_PAGES ((((2<<31) - __PAGE_OFFSET) >> PAGE_SHIFT)) +#endif /* _ASM_X86_PGTABLE_32_H */
arch/x86/kernel/head32.c +62 -0
65 lines not on this page · raw message
arch/x86/kernel/head_32.S +7 -115
152 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 6 lines · Ingo Molnar
Yeah, so (belatedly) I tried to merge this to latest upstream, via the commit below (note the slight edits to the changelog) - but 32-bit defconfig fails to build:
arch/x86/kernel/head_32.S:615: Error: can't resolveinit_thread_union' {*UND* section} -SIZEOF_PTREGS' {*UND* section}
When you dropped MAPPING_BEYOND_END (that I indeed should have removed) you left comment opening in the wrong place:
Quoted 13 lines
arch/x86/kernel/head_32.S +1
-0@@ -24,6 +24,7 @@ #include <asm/nops.h> #include <asm/bootparam.h> #include <asm/export.h> +#include <asm/pgtable_32.h> /* Physical address */ #define pa(X) ((X) - __PAGE_OFFSET)
arch/x86/kernel/head_32.S line 43
Quoted 1 line
arch/x86/kernel/head_32.S +0
-0@@ -42,43 +43,8 @@ #define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id
This one:
Quoted 15 lines
arch/x86/kernel/head_32.S +0
-13/* - * This is how much memory in addition to the memory covered up to - * and including _end we need mapped initially. - * We need: - * (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE) - * (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE) - * - * Modulo rounding, each megabyte assigned here requires a kilobyte of - * memory, which is currently unreclaimed. - * - * This should be a multiple of a page. - * - * KERNEL_IMAGE_SIZE should be greater than pa(_end) - * and small than max_low_pfn, otherwise will waste some page table entries
arch/x86/kernel/head_32.S line 46
Quoted 10 lines
arch/x86/kernel/head_32.S +0
-8- */ - -#if PTRS_PER_PMD > 1 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD) -#else -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD) -#endif - #define SIZEOF_PTREGS 17*4
In other words, this version of the patch needs:
arch/x86/kernel/head_32.S +2 -1
@@ -42,9 +42,10 @@ #define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability #define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id -/* + #define SIZEOF_PTREGS 17*4 +/* * Worst-case size of the kernel mapping we need to make: * a relocatable kernel can live anywhere in lowmem, so we need to be able * to map all of lowmem.
-boris
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
kbuild test robot
build botRe: [PATCH] x86/boot/32: Convert the 32-bit pgtable setup code from assembly to C
In reply to Ingo Molnarurl: https://github.com/0day-ci/linux/commits/Ingo-Molnar/x86-boot-32-Convert-the-32-bit-pgtable-setup-code-from-assembly-to-C/20170106-035845 config: i386-tinyconfig (attached as .config) compiler…
Hi Ingo,
[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.10-rc2 next-20170105]
[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/Ingo-Molnar/x86-boot-32-Convert-the-32-bit-pgtable-setup-code-from-assembly-to-C/20170106-035845
config: i386-tinyconfig (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=i386 All errors (new ones prefixed by >>):
arch/x86/kernel/head_32.S: Assembler messages:
>> arch/x86/kernel/head_32.S:612: Error: can't resolve `init_thread_union' {*UND* section} - `SIZEOF_PTREGS' {*UND* section}vim +612 arch/x86/kernel/head_32.S
11d4c3f9 arch/x86/kernel/head_32.S H. Peter Anvin 2011-02-04 606 .balign 4 b32f96c7 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-08-18 607 ENTRY(initial_stack) 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 608 /* 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 609 * The SIZEOF_PTREGS gap is a convention which helps the in-kernel 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 610 * unwinder reliably detect the end of the stack. 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 611 */ 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 @612 .long init_thread_union + THREAD_SIZE - SIZEOF_PTREGS - \ 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 613 TOP_OF_KERNEL_STACK_PADDING;
^1da177e arch/i386/kernel/head.S Linus Torvalds 2005-04-16 6144c5023a3 arch/x86/kernel/head_32.S H. Peter Anvin 2012-04-18 615 __INITRODATA
:::::: The code at line 612 was first introduced by commit
:::::: 22dc391865af29a1332bd1d17152f2ca7188bc4a x86/boot: Fix the end of the stack for idle tasks
:::::: TO: Josh Poimboeuf <[email protected]>
:::::: CC: Ingo Molnar <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
kbuild test robot
build botRe: [PATCH] x86/boot/32: Convert the 32-bit pgtable setup code from assembly to C
In reply to Ingo Molnarurl: https://github.com/0day-ci/linux/commits/Ingo-Molnar/x86-boot-32-Convert-the-32-bit-pgtable-setup-code-from-assembly-to-C/20170106-035845 config: i386-tinyconfig (attached as .config) compiler…
Hi Ingo,
[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.10-rc2 next-20170105]
[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/Ingo-Molnar/x86-boot-32-Convert-the-32-bit-pgtable-setup-code-from-assembly-to-C/20170106-035845
config: i386-tinyconfig (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=i386 All errors (new ones prefixed by >>):
arch/x86/kernel/head_32.S: Assembler messages:
>> arch/x86/kernel/head_32.S:612: Error: can't resolve `init_thread_union' {*UND* section} - `SIZEOF_PTREGS' {*UND* section}vim +612 arch/x86/kernel/head_32.S
11d4c3f9 arch/x86/kernel/head_32.S H. Peter Anvin 2011-02-04 606 .balign 4 b32f96c7 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-08-18 607 ENTRY(initial_stack) 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 608 /* 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 609 * The SIZEOF_PTREGS gap is a convention which helps the in-kernel 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 610 * unwinder reliably detect the end of the stack. 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 611 */ 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 @612 .long init_thread_union + THREAD_SIZE - SIZEOF_PTREGS - \ 22dc3918 arch/x86/kernel/head_32.S Josh Poimboeuf 2016-09-21 613 TOP_OF_KERNEL_STACK_PADDING;
^1da177e arch/i386/kernel/head.S Linus Torvalds 2005-04-16 6144c5023a3 arch/x86/kernel/head_32.S H. Peter Anvin 2012-04-18 615 __INITRODATA
:::::: The code at line 612 was first introduced by commit
:::::: 22dc391865af29a1332bd1d17152f2ca7188bc4a x86/boot: Fix the end of the stack for idle tasks
:::::: TO: Josh Poimboeuf <[email protected]>
:::::: CC: Ingo Molnar <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
tip-bot for Boris Ostrovsky
merge bot[tip:x86/boot] x86/boot/32: Convert the 32-bit pgtable setup code from assembly to C
In reply to Boris Ostrovskyx86/boot/32: Convert the 32-bit pgtable setup code from assembly to C
Commit-ID: 1e620f9b23e598ab936ece12233e98e97930b692 Gitweb: http://git.kernel.org/tip/1e620f9b23e598ab936ece12233e98e97930b692 Author: Boris Ostrovsky <[email protected]> AuthorDate: Thu, 8 Dec 2016 11:44:31 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 6 Jan 2017 08:39:26 +0100
x86/boot/32: Convert the 32-bit pgtable setup code from assembly to C
The new Xen PVH entry point requires page tables to be setup by the kernel since it is entered with paging disabled.
Pull the common code out of head_32.S so that mk_early_pgtbl_32() can be invoked from both the new Xen entry point and the existing startup_32() code.
Convert resulting common code to C.
--- arch/x86/include/asm/pgtable_32.h | 32 ++++++++++ arch/x86/kernel/head32.c | 62 +++++++++++++++++++ arch/x86/kernel/head_32.S | 121 +++----------------------------------- 3 files changed, 101 insertions(+), 114 deletions(-)
arch/x86/include/asm/pgtable_32.h +32 -0
@@ -27,6 +27,7 @@ struct vm_area_struct;extern pgd_t swapper_pg_dir[1024 ];extern pgd_t initial_page_table[1024 ]; +extern pmd_t initial_pg_pmd[];static inline void pgtable_cache_init (void ) { }static inline void check_pgt_cache (void ) { }
@@ -75,4 +76,35 @@ do { \#define kern_addr_valid (kaddr) (0)#endif +/* +* This is how much memory in addition to the memory covered up to +* and including _end we need mapped initially. +* We need: +* (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE) +* (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE) +* +* Modulo rounding, each megabyte assigned here requires a kilobyte of +* memory, which is currently unreclaimed. +* +* This should be a multiple of a page. +* +* KERNEL_IMAGE_SIZE should be greater than pa(_end) +* and small than max_low_pfn, otherwise will waste some page table entries +*/ +#if PTRS_PER_PMD >1 +#define PAGE_TABLE_SIZE (pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD) +#else +#define PAGE_TABLE_SIZE (pages) ((pages) / PTRS_PER_PGD) +#endif + +/* +* Number of possible pages in the lowmem region. +* +* We shift 2 by 31 instead of 1 by 32 to the left in order to avoid a +* gas warning about overflowing shift count when gas has been compiled +* with only a host target support using a 32-bit type for internal +* representation. +*/ +#define LOWMEM_PAGES ((((2<<31) - __PAGE_OFFSET) >> PAGE_SHIFT)) +#endif /* _ASM_X86_PGTABLE_32_H */
arch/x86/kernel/head32.c +62 -0
65 lines not on this page · raw message
arch/x86/kernel/head_32.S +7 -114
153 lines not on this page · raw message