Pagetables to use normal kernel types

This is my first step in the migration of page_tables.c to the kernel
types and functions/macros (2.6.23-rc3).  Seems to be working OK.

Signed-off-by: Matias Zabaljauregui <matias.zabaljauregui@cern.ch>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Matias Zabaljauregui
2007-10-22 11:03:33 +10:00
committed by Rusty Russell
parent 47aee45ae3
commit df29f43e65
3 changed files with 98 additions and 141 deletions

View File

@@ -28,45 +28,10 @@ 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;
pgd_t *pgdir;
};
/* We have two pages shared with guests, per cpu. */
@@ -157,6 +122,12 @@ int lguest_address_ok(const struct lguest *lg,
unsigned long addr, unsigned long len);
int run_guest(struct lguest *lg, unsigned long __user *user);
/* Helper macros to obtain the first 12 or the last 20 bits, this is only the
* first step in the migration to the kernel types. pte_pfn is already defined
* in the kernel. */
#define pgd_flags(x) (pgd_val(x) & ~PAGE_MASK)
#define pte_flags(x) (pte_val(x) & ~PAGE_MASK)
#define pgd_pfn(x) (pgd_val(x) >> PAGE_SHIFT)
/* interrupts_and_traps.c: */
void maybe_do_interrupt(struct lguest *lg);
@@ -187,7 +158,7 @@ void guest_set_pmd(struct lguest *lg, unsigned long cr3, u32 i);
void guest_pagetable_clear_all(struct lguest *lg);
void guest_pagetable_flush_user(struct lguest *lg);
void guest_set_pte(struct lguest *lg, unsigned long cr3,
unsigned long vaddr, gpte_t val);
unsigned long vaddr, pte_t val);
void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages);
int demand_page(struct lguest *info, unsigned long cr2, int errcode);
void pin_page(struct lguest *lg, unsigned long vaddr);