Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80769
b: refs/heads/master
c: d835dfe
h: refs/heads/master
i:
  80767: e8ec969
v: v3
  • Loading branch information
Avi Kivity committed Jan 30, 2008
1 parent 69a82f3 commit 6659624
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 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: 79539cec0c3c38d35a1e3e5310d2c562ae6e82b8
refs/heads/master: d835dfecd00fd770288dcd9a46c0e0966d526fdf
2 changes: 1 addition & 1 deletion trunk/drivers/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ static int nonpaging_init_context(struct kvm_vcpu *vcpu)
return 0;
}

static void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu)
void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu)
{
++vcpu->stat.tlb_flush;
kvm_x86_ops->tlb_flush(vcpu);
Expand Down
25 changes: 25 additions & 0 deletions trunk/drivers/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3)
return ret;
}

static bool pdptrs_changed(struct kvm_vcpu *vcpu)
{
u64 pdpte[ARRAY_SIZE(vcpu->pdptrs)];
bool changed = true;
int r;

if (is_long_mode(vcpu) || !is_pae(vcpu))
return false;

mutex_lock(&vcpu->kvm->lock);
r = kvm_read_guest(vcpu->kvm, vcpu->cr3 & ~31u, pdpte, sizeof(pdpte));
if (r < 0)
goto out;
changed = memcmp(pdpte, vcpu->pdptrs, sizeof(pdpte)) != 0;
out:
mutex_unlock(&vcpu->kvm->lock);

return changed;
}

void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
{
if (cr0 & CR0_RESERVED_BITS) {
Expand Down Expand Up @@ -271,6 +291,11 @@ EXPORT_SYMBOL_GPL(set_cr4);

void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
{
if (cr3 == vcpu->cr3 && !pdptrs_changed(vcpu)) {
kvm_mmu_flush_tlb(vcpu);
return;
}

if (is_long_mode(vcpu)) {
if (cr3 & CR3_L_MODE_RESERVED_BITS) {
printk(KERN_DEBUG "set_cr3: #GP, reserved bits\n");
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/kvm/x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ int emulator_write_emulated(unsigned long addr,

unsigned long segment_base(u16 selector);

void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu);
void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
const u8 *new, int bytes);
int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
Expand Down

0 comments on commit 6659624

Please sign in to comment.