|
@@ -5074,9 +5074,9 @@ static bool need_remote_flush(u64 old, u64 new)
|
|
}
|
|
}
|
|
|
|
|
|
static u64 mmu_pte_write_fetch_gpte(struct kvm_vcpu *vcpu, gpa_t *gpa,
|
|
static u64 mmu_pte_write_fetch_gpte(struct kvm_vcpu *vcpu, gpa_t *gpa,
|
|
- const u8 *new, int *bytes)
|
|
|
|
|
|
+ int *bytes)
|
|
{
|
|
{
|
|
- u64 gentry;
|
|
|
|
|
|
+ u64 gentry = 0;
|
|
int r;
|
|
int r;
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -5088,22 +5088,12 @@ static u64 mmu_pte_write_fetch_gpte(struct kvm_vcpu *vcpu, gpa_t *gpa,
|
|
/* Handle a 32-bit guest writing two halves of a 64-bit gpte */
|
|
/* Handle a 32-bit guest writing two halves of a 64-bit gpte */
|
|
*gpa &= ~(gpa_t)7;
|
|
*gpa &= ~(gpa_t)7;
|
|
*bytes = 8;
|
|
*bytes = 8;
|
|
- r = kvm_vcpu_read_guest(vcpu, *gpa, &gentry, 8);
|
|
|
|
- if (r)
|
|
|
|
- gentry = 0;
|
|
|
|
- new = (const u8 *)&gentry;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- switch (*bytes) {
|
|
|
|
- case 4:
|
|
|
|
- gentry = *(const u32 *)new;
|
|
|
|
- break;
|
|
|
|
- case 8:
|
|
|
|
- gentry = *(const u64 *)new;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- gentry = 0;
|
|
|
|
- break;
|
|
|
|
|
|
+ if (*bytes == 4 || *bytes == 8) {
|
|
|
|
+ r = kvm_vcpu_read_guest_atomic(vcpu, *gpa, &gentry, *bytes);
|
|
|
|
+ if (r)
|
|
|
|
+ gentry = 0;
|
|
}
|
|
}
|
|
|
|
|
|
return gentry;
|
|
return gentry;
|
|
@@ -5207,8 +5197,6 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
|
|
|
|
|
|
pgprintk("%s: gpa %llx bytes %d\n", __func__, gpa, bytes);
|
|
pgprintk("%s: gpa %llx bytes %d\n", __func__, gpa, bytes);
|
|
|
|
|
|
- gentry = mmu_pte_write_fetch_gpte(vcpu, &gpa, new, &bytes);
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* No need to care whether allocation memory is successful
|
|
* No need to care whether allocation memory is successful
|
|
* or not since pte prefetch is skiped if it does not have
|
|
* or not since pte prefetch is skiped if it does not have
|
|
@@ -5217,6 +5205,9 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
|
|
mmu_topup_memory_caches(vcpu);
|
|
mmu_topup_memory_caches(vcpu);
|
|
|
|
|
|
spin_lock(&vcpu->kvm->mmu_lock);
|
|
spin_lock(&vcpu->kvm->mmu_lock);
|
|
|
|
+
|
|
|
|
+ gentry = mmu_pte_write_fetch_gpte(vcpu, &gpa, &bytes);
|
|
|
|
+
|
|
++vcpu->kvm->stat.mmu_pte_write;
|
|
++vcpu->kvm->stat.mmu_pte_write;
|
|
kvm_mmu_audit(vcpu, AUDIT_PRE_PTE_WRITE);
|
|
kvm_mmu_audit(vcpu, AUDIT_PRE_PTE_WRITE);
|
|
|
|
|