diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-05-02 13:27:13 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-05-02 13:27:13 -0400 |
commit | b239fb2501117bf3aeb4dd6926edd855be92333d (patch) | |
tree | 62ac25204632ef0b14e3bd84580c722e69800cf7 /include/asm-i386 | |
parent | 3dc494e86d1c93afd4c66385f270899dbfae483d (diff) |
[PATCH] i386: PARAVIRT: Hooks to set up initial pagetable
This patch introduces paravirt_ops hooks to control how the kernel's
initial pagetable is set up.
In the case of a native boot, the very early bootstrap code creates a
simple non-PAE pagetable to map the kernel and physical memory. When
the VM subsystem is initialized, it creates a proper pagetable which
respects the PAE mode, large pages, etc.
When booting under a hypervisor, there are many possibilities for what
paging environment the hypervisor establishes for the guest kernel, so
the constructon of the kernel's pagetable depends on the hypervisor.
In the case of Xen, the hypervisor boots the kernel with a fully
constructed pagetable, which is already using PAE if necessary. Also,
Xen requires particular care when constructing pagetables to make sure
all pagetables are always mapped read-only.
In order to make this easier, kernel's initial pagetable construction
has been changed to only allocate and initialize a pagetable page if
there's no page already present in the pagetable. This allows the Xen
paravirt backend to make a copy of the hypervisor-provided pagetable,
allowing the kernel to establish any more mappings it needs while
keeping the existing ones.
A slightly subtle point which is worth highlighting here is that Xen
requires all kernel mappings to share the same pte_t pages between all
pagetables, so that updating a kernel page's mapping in one pagetable
is reflected in all other pagetables. This makes it possible to
allocate a page and attach it to a pagetable without having to
explicitly enumerate that page's mapping in all pagetables.
And:
+From: "Eric W. Biederman" <ebiederm@xmission.com>
If we don't set the leaf page table entries it is quite possible that
will inherit and incorrect page table entry from the initial boot
page table setup in head.S. So we need to redo the effort here,
so we pick up PSE, PGE and the like.
Hypervisors like Xen require that their page tables be read-only,
which is slightly incompatible with our low identity mappings, however
I discussed this with Jeremy he has modified the Xen early set_pte
function to avoid problems in this area.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Acked-by: William Irwin <bill.irwin@oracle.com>
Cc: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-i386')
-rw-r--r-- | include/asm-i386/paravirt.h | 17 | ||||
-rw-r--r-- | include/asm-i386/pgtable.h | 16 |
2 files changed, 32 insertions, 1 deletions
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h index 0aacb13bb929..c49b44cdd8ee 100644 --- a/include/asm-i386/paravirt.h +++ b/include/asm-i386/paravirt.h | |||
@@ -2,10 +2,11 @@ | |||
2 | #define __ASM_PARAVIRT_H | 2 | #define __ASM_PARAVIRT_H |
3 | /* Various instructions on x86 need to be replaced for | 3 | /* Various instructions on x86 need to be replaced for |
4 | * para-virtualization: those hooks are defined here. */ | 4 | * para-virtualization: those hooks are defined here. */ |
5 | |||
6 | #ifdef CONFIG_PARAVIRT | ||
5 | #include <linux/stringify.h> | 7 | #include <linux/stringify.h> |
6 | #include <asm/page.h> | 8 | #include <asm/page.h> |
7 | 9 | ||
8 | #ifdef CONFIG_PARAVIRT | ||
9 | /* These are the most performance critical ops, so we want to be able to patch | 10 | /* These are the most performance critical ops, so we want to be able to patch |
10 | * callers */ | 11 | * callers */ |
11 | #define PARAVIRT_IRQ_DISABLE 0 | 12 | #define PARAVIRT_IRQ_DISABLE 0 |
@@ -50,6 +51,9 @@ struct paravirt_ops | |||
50 | char *(*memory_setup)(void); | 51 | char *(*memory_setup)(void); |
51 | void (*init_IRQ)(void); | 52 | void (*init_IRQ)(void); |
52 | 53 | ||
54 | void (*pagetable_setup_start)(pgd_t *pgd_base); | ||
55 | void (*pagetable_setup_done)(pgd_t *pgd_base); | ||
56 | |||
53 | void (*banner)(void); | 57 | void (*banner)(void); |
54 | 58 | ||
55 | unsigned long (*get_wallclock)(void); | 59 | unsigned long (*get_wallclock)(void); |
@@ -370,6 +374,17 @@ static inline void setup_secondary_clock(void) | |||
370 | } | 374 | } |
371 | #endif | 375 | #endif |
372 | 376 | ||
377 | static inline void paravirt_pagetable_setup_start(pgd_t *base) | ||
378 | { | ||
379 | if (paravirt_ops.pagetable_setup_start) | ||
380 | (*paravirt_ops.pagetable_setup_start)(base); | ||
381 | } | ||
382 | |||
383 | static inline void paravirt_pagetable_setup_done(pgd_t *base) | ||
384 | { | ||
385 | if (paravirt_ops.pagetable_setup_done) | ||
386 | (*paravirt_ops.pagetable_setup_done)(base); | ||
387 | } | ||
373 | 388 | ||
374 | #ifdef CONFIG_SMP | 389 | #ifdef CONFIG_SMP |
375 | static inline void startup_ipi_hook(int phys_apicid, unsigned long start_eip, | 390 | static inline void startup_ipi_hook(int phys_apicid, unsigned long start_eip, |
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h index 147f2553784d..0790ad6ed440 100644 --- a/include/asm-i386/pgtable.h +++ b/include/asm-i386/pgtable.h | |||
@@ -514,6 +514,22 @@ do { \ | |||
514 | * tables contain all the necessary information. | 514 | * tables contain all the necessary information. |
515 | */ | 515 | */ |
516 | #define update_mmu_cache(vma,address,pte) do { } while (0) | 516 | #define update_mmu_cache(vma,address,pte) do { } while (0) |
517 | |||
518 | void native_pagetable_setup_start(pgd_t *base); | ||
519 | void native_pagetable_setup_done(pgd_t *base); | ||
520 | |||
521 | #ifndef CONFIG_PARAVIRT | ||
522 | static inline void paravirt_pagetable_setup_start(pgd_t *base) | ||
523 | { | ||
524 | native_pagetable_setup_start(base); | ||
525 | } | ||
526 | |||
527 | static inline void paravirt_pagetable_setup_done(pgd_t *base) | ||
528 | { | ||
529 | native_pagetable_setup_done(base); | ||
530 | } | ||
531 | #endif /* !CONFIG_PARAVIRT */ | ||
532 | |||
517 | #endif /* !__ASSEMBLY__ */ | 533 | #endif /* !__ASSEMBLY__ */ |
518 | 534 | ||
519 | #ifdef CONFIG_FLATMEM | 535 | #ifdef CONFIG_FLATMEM |