Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45819
b: refs/heads/master
c: 73b1087
h: refs/heads/master
i:
  45817: 99abca6
  45815: 2a60495
v: v3
  • Loading branch information
Avi Kivity authored and Linus Torvalds committed Jan 26, 2007
1 parent 649c7ee commit cab41fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 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: 7993ba43db1c07245ada067791f91dbf018095ac
refs/heads/master: 73b1087e6176a34c01eea3db269848f72fad72c1
6 changes: 6 additions & 0 deletions trunk/drivers/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static int dbg = 1;
#define PFERR_PRESENT_MASK (1U << 0)
#define PFERR_WRITE_MASK (1U << 1)
#define PFERR_USER_MASK (1U << 2)
#define PFERR_FETCH_MASK (1U << 4)

#define PT64_ROOT_LEVEL 4
#define PT32_ROOT_LEVEL 2
Expand All @@ -168,6 +169,11 @@ static int is_cpuid_PSE36(void)
return 1;
}

static int is_nx(struct kvm_vcpu *vcpu)
{
return vcpu->shadow_efer & EFER_NX;
}

static int is_present_pte(unsigned long pte)
{
return pte & PT_PRESENT_MASK;
Expand Down
15 changes: 12 additions & 3 deletions trunk/drivers/kvm/paging_tmpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct guest_walker {
*/
static int FNAME(walk_addr)(struct guest_walker *walker,
struct kvm_vcpu *vcpu, gva_t addr,
int write_fault, int user_fault)
int write_fault, int user_fault, int fetch_fault)
{
hpa_t hpa;
struct kvm_memory_slot *slot;
Expand Down Expand Up @@ -123,6 +123,11 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
if (user_fault && !(*ptep & PT_USER_MASK))
goto access_error;

#if PTTYPE == 64
if (fetch_fault && is_nx(vcpu) && (*ptep & PT64_NX_MASK))
goto access_error;
#endif

if (!(*ptep & PT_ACCESSED_MASK))
*ptep |= PT_ACCESSED_MASK; /* avoid rmw */

Expand Down Expand Up @@ -169,6 +174,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
walker->error_code |= PFERR_WRITE_MASK;
if (user_fault)
walker->error_code |= PFERR_USER_MASK;
if (fetch_fault)
walker->error_code |= PFERR_FETCH_MASK;
return 0;
}

Expand Down Expand Up @@ -372,6 +379,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
{
int write_fault = error_code & PFERR_WRITE_MASK;
int user_fault = error_code & PFERR_USER_MASK;
int fetch_fault = error_code & PFERR_FETCH_MASK;
struct guest_walker walker;
u64 *shadow_pte;
int fixed;
Expand All @@ -388,7 +396,8 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
/*
* Look up the shadow pte for the faulting address.
*/
r = FNAME(walk_addr)(&walker, vcpu, addr, write_fault, user_fault);
r = FNAME(walk_addr)(&walker, vcpu, addr, write_fault, user_fault,
fetch_fault);

/*
* The page is not mapped by the guest. Let the guest handle it.
Expand Down Expand Up @@ -437,7 +446,7 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr)
pt_element_t guest_pte;
gpa_t gpa;

FNAME(walk_addr)(&walker, vcpu, vaddr, 0, 0);
FNAME(walk_addr)(&walker, vcpu, vaddr, 0, 0, 0);
guest_pte = *walker.ptep;
FNAME(release_walker)(&walker);

Expand Down

0 comments on commit cab41fa

Please sign in to comment.