diff options
author | Matias Zabaljauregui <matias.zabaljauregui@cern.ch> | 2007-10-21 21:03:33 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-23 01:49:53 -0400 |
commit | df29f43e650df29456804dabdb2611de914e7c0f (patch) | |
tree | 2f8de4a2f1b7c4141e710123fc86db266f507d83 /drivers/lguest/lg.h | |
parent | 47aee45ae3c708ab678e09abfba0efaf6ca0e87a (diff) |
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>
Diffstat (limited to 'drivers/lguest/lg.h')
-rw-r--r-- | drivers/lguest/lg.h | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h index c2557cfd86c7..dc15b88208ff 100644 --- a/drivers/lguest/lg.h +++ b/drivers/lguest/lg.h | |||
@@ -28,45 +28,10 @@ struct lguest_dma_info | |||
28 | u8 interrupt; /* 0 when not registered */ | 28 | u8 interrupt; /* 0 when not registered */ |
29 | }; | 29 | }; |
30 | 30 | ||
31 | /*H:310 The page-table code owes a great debt of gratitude to Andi Kleen. He | ||
32 | * reviewed the original code which used "u32" for all page table entries, and | ||
33 | * insisted that it would be far clearer with explicit typing. I thought it | ||
34 | * was overkill, but he was right: it is much clearer than it was before. | ||
35 | * | ||
36 | * We have separate types for the Guest's ptes & pgds and the shadow ptes & | ||
37 | * pgds. There's already a Linux type for these (pte_t and pgd_t) but they | ||
38 | * change depending on kernel config options (PAE). */ | ||
39 | |||
40 | /* Each entry is identical: lower 12 bits of flags and upper 20 bits for the | ||
41 | * "page frame number" (0 == first physical page, etc). They are different | ||
42 | * types so the compiler will warn us if we mix them improperly. */ | ||
43 | typedef union { | ||
44 | struct { unsigned flags:12, pfn:20; }; | ||
45 | struct { unsigned long val; } raw; | ||
46 | } spgd_t; | ||
47 | typedef union { | ||
48 | struct { unsigned flags:12, pfn:20; }; | ||
49 | struct { unsigned long val; } raw; | ||
50 | } spte_t; | ||
51 | typedef union { | ||
52 | struct { unsigned flags:12, pfn:20; }; | ||
53 | struct { unsigned long val; } raw; | ||
54 | } gpgd_t; | ||
55 | typedef union { | ||
56 | struct { unsigned flags:12, pfn:20; }; | ||
57 | struct { unsigned long val; } raw; | ||
58 | } gpte_t; | ||
59 | |||
60 | /* We have two convenient macros to convert a "raw" value as handed to us by | ||
61 | * the Guest into the correct Guest PGD or PTE type. */ | ||
62 | #define mkgpte(_val) ((gpte_t){.raw.val = _val}) | ||
63 | #define mkgpgd(_val) ((gpgd_t){.raw.val = _val}) | ||
64 | /*:*/ | ||
65 | |||
66 | struct pgdir | 31 | struct pgdir |
67 | { | 32 | { |
68 | unsigned long cr3; | 33 | unsigned long cr3; |
69 | spgd_t *pgdir; | 34 | pgd_t *pgdir; |
70 | }; | 35 | }; |
71 | 36 | ||
72 | /* We have two pages shared with guests, per cpu. */ | 37 | /* We have two pages shared with guests, per cpu. */ |
@@ -157,6 +122,12 @@ int lguest_address_ok(const struct lguest *lg, | |||
157 | unsigned long addr, unsigned long len); | 122 | unsigned long addr, unsigned long len); |
158 | int run_guest(struct lguest *lg, unsigned long __user *user); | 123 | int run_guest(struct lguest *lg, unsigned long __user *user); |
159 | 124 | ||
125 | /* Helper macros to obtain the first 12 or the last 20 bits, this is only the | ||
126 | * first step in the migration to the kernel types. pte_pfn is already defined | ||
127 | * in the kernel. */ | ||
128 | #define pgd_flags(x) (pgd_val(x) & ~PAGE_MASK) | ||
129 | #define pte_flags(x) (pte_val(x) & ~PAGE_MASK) | ||
130 | #define pgd_pfn(x) (pgd_val(x) >> PAGE_SHIFT) | ||
160 | 131 | ||
161 | /* interrupts_and_traps.c: */ | 132 | /* interrupts_and_traps.c: */ |
162 | void maybe_do_interrupt(struct lguest *lg); | 133 | void maybe_do_interrupt(struct lguest *lg); |
@@ -187,7 +158,7 @@ void guest_set_pmd(struct lguest *lg, unsigned long cr3, u32 i); | |||
187 | void guest_pagetable_clear_all(struct lguest *lg); | 158 | void guest_pagetable_clear_all(struct lguest *lg); |
188 | void guest_pagetable_flush_user(struct lguest *lg); | 159 | void guest_pagetable_flush_user(struct lguest *lg); |
189 | void guest_set_pte(struct lguest *lg, unsigned long cr3, | 160 | void guest_set_pte(struct lguest *lg, unsigned long cr3, |
190 | unsigned long vaddr, gpte_t val); | 161 | unsigned long vaddr, pte_t val); |
191 | void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages); | 162 | void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages); |
192 | int demand_page(struct lguest *info, unsigned long cr2, int errcode); | 163 | int demand_page(struct lguest *info, unsigned long cr2, int errcode); |
193 | void pin_page(struct lguest *lg, unsigned long vaddr); | 164 | void pin_page(struct lguest *lg, unsigned long vaddr); |