Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45259
b: refs/heads/master
c: 1b0973b
h: refs/heads/master
i:
  45257: f6cdbbf
  45255: d78e45e
v: v3
  • Loading branch information
Avi Kivity authored and Linus Torvalds committed Jan 6, 2007
1 parent d03d336 commit cf6791e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 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: 17ac10ad2bb7d8c4f401668484b2e661a15726c6
refs/heads/master: 1b0973bd8f788178f21d9eebdd879203464f8528
2 changes: 2 additions & 0 deletions trunk/drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,8 @@ static int kvm_dev_ioctl_set_sregs(struct kvm *kvm, struct kvm_sregs *sregs)

mmu_reset_needed |= vcpu->cr4 != sregs->cr4;
kvm_arch_ops->set_cr4(vcpu, sregs->cr4);
if (!is_long_mode(vcpu) && is_pae(vcpu))
load_pdptrs(vcpu, vcpu->cr3);

if (mmu_reset_needed)
kvm_mmu_reset_context(vcpu);
Expand Down
28 changes: 18 additions & 10 deletions trunk/drivers/kvm/paging_tmpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,28 @@ static void FNAME(walk_addr)(struct guest_walker *walker,
hpa_t hpa;
struct kvm_memory_slot *slot;
pt_element_t *ptep;
pt_element_t root;

walker->level = vcpu->mmu.root_level;
walker->table_gfn = (vcpu->cr3 & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
walker->table = NULL;
root = vcpu->cr3;
#if PTTYPE == 64
if (!is_long_mode(vcpu)) {
walker->ptep = &vcpu->pdptrs[(addr >> 30) & 3];
root = *walker->ptep;
if (!(root & PT_PRESENT_MASK))
return;
--walker->level;
}
#endif
walker->table_gfn = (root & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
slot = gfn_to_memslot(vcpu->kvm, walker->table_gfn);
hpa = safe_gpa_to_hpa(vcpu, vcpu->cr3 & PT64_BASE_ADDR_MASK);
hpa = safe_gpa_to_hpa(vcpu, root & PT64_BASE_ADDR_MASK);
walker->table = kmap_atomic(pfn_to_page(hpa >> PAGE_SHIFT), KM_USER0);

ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) ||
(vcpu->cr3 & ~(PAGE_MASK | CR3_FLAGS_MASK)) == 0);

walker->table = (pt_element_t *)( (unsigned long)walker->table |
(unsigned long)(vcpu->cr3 & ~(PAGE_MASK | CR3_FLAGS_MASK)) );
walker->inherited_ar = PT_USER_MASK | PT_WRITABLE_MASK;

for (;;) {
Expand All @@ -89,11 +99,8 @@ static void FNAME(walk_addr)(struct guest_walker *walker,
ASSERT(((unsigned long)walker->table & PAGE_MASK) ==
((unsigned long)ptep & PAGE_MASK));

/* Don't set accessed bit on PAE PDPTRs */
if (vcpu->mmu.root_level != 3 || walker->level != 3)
if ((*ptep & (PT_PRESENT_MASK | PT_ACCESSED_MASK))
== PT_PRESENT_MASK)
*ptep |= PT_ACCESSED_MASK;
if (is_present_pte(*ptep) && !(*ptep & PT_ACCESSED_MASK))
*ptep |= PT_ACCESSED_MASK;

if (!is_present_pte(*ptep) ||
walker->level == PT_PAGE_TABLE_LEVEL ||
Expand All @@ -116,7 +123,8 @@ static void FNAME(walk_addr)(struct guest_walker *walker,

static void FNAME(release_walker)(struct guest_walker *walker)
{
kunmap_atomic(walker->table, KM_USER0);
if (walker->table)
kunmap_atomic(walker->table, KM_USER0);
}

static void FNAME(set_pte)(struct kvm_vcpu *vcpu, u64 guest_pte,
Expand Down

0 comments on commit cf6791e

Please sign in to comment.