Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 72258
b: refs/heads/master
c: df29f43
h: refs/heads/master
v: v3
  • Loading branch information
Matias Zabaljauregui authored and Rusty Russell committed Oct 23, 2007
1 parent 5aa5c38 commit 21b840a
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 142 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 47aee45ae3c708ab678e09abfba0efaf6ca0e87a
refs/heads/master: df29f43e650df29456804dabdb2611de914e7c0f
2 changes: 1 addition & 1 deletion trunk/drivers/lguest/hypercalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void do_hcall(struct lguest *lg, struct hcall_args *args)
guest_set_stack(lg, args->arg1, args->arg2, args->arg3);
break;
case LHCALL_SET_PTE:
guest_set_pte(lg, args->arg1, args->arg2, mkgpte(args->arg3));
guest_set_pte(lg, args->arg1, args->arg2, __pte(args->arg3));
break;
case LHCALL_SET_PMD:
guest_set_pmd(lg, args->arg1, args->arg2);
Expand Down
45 changes: 8 additions & 37 deletions trunk/drivers/lguest/lg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 21b840a

Please sign in to comment.