Move some i386 specific page table related defines from lg.h to include/asm-i386/lguest_pgtable.h Signed-off-by: Jes Sorensen --- drivers/lguest/i386_core.c | 1 drivers/lguest/lg.h | 39 ---------------------------------- drivers/lguest/page_tables.c | 1 drivers/lguest/segments.c | 1 include/asm-i386/lguest.h | 2 + include/asm-i386/lguest_pgtable.h | 43 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 39 deletions(-) Index: linux-2.6.23-rc3/drivers/lguest/i386_core.c =================================================================== --- linux-2.6.23-rc3.orig/drivers/lguest/i386_core.c +++ linux-2.6.23-rc3/drivers/lguest/i386_core.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "lg.h" static int cpu_had_pge; Index: linux-2.6.23-rc3/drivers/lguest/lg.h =================================================================== --- linux-2.6.23-rc3.orig/drivers/lguest/lg.h +++ linux-2.6.23-rc3/drivers/lguest/lg.h @@ -20,10 +20,6 @@ void free_pagetables(void); int init_pagetables(struct page **switcher_page, unsigned int pages); -/* Full 4G segment descriptors, suitable for CS and DS. */ -#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00}) -#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300}) - struct lguest_dma_info { struct list_head list; @@ -35,47 +31,12 @@ struct lguest_dma_info u8 interrupt; /* 0 when not registered */ }; -/*H:310 The page-table code owes a great debt of gratitude to Andi Kleen. He - * reviewed the original code which used "u32" for all page table entries, and - * insisted that it would be far clearer with explicit typing. I thought it - * was overkill, but he was right: it is much clearer than it was before. - * - * We have separate types for the Guest's ptes & pgds and the shadow ptes & - * pgds. There's already a Linux type for these (pte_t and pgd_t) but they - * change depending on kernel config options (PAE). */ - -/* Each entry is identical: lower 12 bits of flags and upper 20 bits for the - * "page frame number" (0 == first physical page, etc). They are different - * types so the compiler will warn us if we mix them improperly. */ -typedef union { - struct { unsigned flags:12, pfn:20; }; - struct { unsigned long val; } raw; -} spgd_t; -typedef union { - struct { unsigned flags:12, pfn:20; }; - struct { unsigned long val; } raw; -} spte_t; -typedef union { - struct { unsigned flags:12, pfn:20; }; - struct { unsigned long val; } raw; -} gpgd_t; -typedef union { - struct { unsigned flags:12, pfn:20; }; - struct { unsigned long val; } raw; -} gpte_t; - /* We have two convenient macros to convert a "raw" value as handed to us by * the Guest into the correct Guest PGD or PTE type. */ #define mkgpte(_val) ((gpte_t){.raw.val = _val}) #define mkgpgd(_val) ((gpgd_t){.raw.val = _val}) /*:*/ -struct pgdir -{ - unsigned long cr3; - spgd_t *pgdir; -}; - /* We have two pages shared with guests, per cpu. */ struct lguest_pages { Index: linux-2.6.23-rc3/drivers/lguest/page_tables.c =================================================================== --- linux-2.6.23-rc3.orig/drivers/lguest/page_tables.c +++ linux-2.6.23-rc3/drivers/lguest/page_tables.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "lg.h" Index: linux-2.6.23-rc3/drivers/lguest/segments.c =================================================================== --- linux-2.6.23-rc3.orig/drivers/lguest/segments.c +++ linux-2.6.23-rc3/drivers/lguest/segments.c @@ -10,6 +10,7 @@ * checks, and the worst you'll experience reading this code is butterfly-rash * from frolicking through its parklike serenity. :*/ #include "lg.h" +#include /*H:600 * We've almost completed the Host; there's just one file to go! Index: linux-2.6.23-rc3/include/asm-i386/lguest.h =================================================================== --- linux-2.6.23-rc3.orig/include/asm-i386/lguest.h +++ linux-2.6.23-rc3/include/asm-i386/lguest.h @@ -9,6 +9,7 @@ #ifndef __ASSEMBLY__ #include #include +#include #define LGUEST_SWITCHER_NEEDS_MAPPING 1 @@ -80,6 +81,7 @@ static inline void lguest_set_ts(void) if (!(cr0 & 8)) write_cr0(cr0|8); } + #endif /* __ASSEMBLY__ */ #endif Index: linux-2.6.23-rc3/include/asm-i386/lguest_pgtable.h =================================================================== --- /dev/null +++ linux-2.6.23-rc3/include/asm-i386/lguest_pgtable.h @@ -0,0 +1,43 @@ +#ifndef _LG_I386_PGTABLE_H +#define _LG_I386_PGTABLE_H + +/* Full 4G segment descriptors, suitable for CS and DS. */ +#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00}) +#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300}) + +/*H:310 The page-table code owes a great debt of gratitude to Andi Kleen. He + * reviewed the original code which used "u32" for all page table entries, and + * insisted that it would be far clearer with explicit typing. I thought it + * was overkill, but he was right: it is much clearer than it was before. + * + * We have separate types for the Guest's ptes & pgds and the shadow ptes & + * pgds. There's already a Linux type for these (pte_t and pgd_t) but they + * change depending on kernel config options (PAE). */ + +/* Each entry is identical: lower 12 bits of flags and upper 20 bits for the + * "page frame number" (0 == first physical page, etc). They are different + * types so the compiler will warn us if we mix them improperly. */ +typedef union { + struct { unsigned flags:12, pfn:20; }; + struct { unsigned long val; } raw; +} spgd_t; +typedef union { + struct { unsigned flags:12, pfn:20; }; + struct { unsigned long val; } raw; +} spte_t; +typedef union { + struct { unsigned flags:12, pfn:20; }; + struct { unsigned long val; } raw; +} gpgd_t; +typedef union { + struct { unsigned flags:12, pfn:20; }; + struct { unsigned long val; } raw; +} gpte_t; + +struct pgdir +{ + unsigned long cr3; + spgd_t *pgdir; +}; + +#endif