[PATCH] x86/32: skip early initialisation of swapper_pg_dir if it is already current

From: Ian Campbell
Date: Thu Oct 28 2010 - 05:16:52 EST


In particular in the Xen PV case the Xen early startup code has
already initialised swapper_pg_dir and switched to it. In this case
initial_page_table is uninitialised since Xen has no use for it so
copying it over swapper_pg_dir is not correct.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxxxxxxxx>
Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
---
arch/x86/kernel/setup.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 95a3274..2d89d5a 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -705,12 +705,14 @@ void __init setup_arch(char **cmdline_p)
* copy kernel address range established so far and switch
* to the proper swapper page table
*/
- clone_pgd_range(swapper_pg_dir + KERNEL_PGD_BOUNDARY,
- initial_page_table + KERNEL_PGD_BOUNDARY,
- KERNEL_PGD_PTRS);
+ if (read_cr3() != __pa(swapper_pg_dir)) {
+ clone_pgd_range(swapper_pg_dir + KERNEL_PGD_BOUNDARY,
+ initial_page_table + KERNEL_PGD_BOUNDARY,
+ KERNEL_PGD_PTRS);

- load_cr3(swapper_pg_dir);
- __flush_tlb_all();
+ load_cr3(swapper_pg_dir);
+ __flush_tlb_all();
+ }
#else
printk(KERN_INFO "Command line: %s\n", boot_command_line);
#endif
--
1.5.6.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/