|
@@ -88,15 +88,23 @@ static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
|
|
|
vcpu->arch.mmio_gva = gva & PAGE_MASK;
|
|
vcpu->arch.mmio_gva = gva & PAGE_MASK;
|
|
|
vcpu->arch.access = access;
|
|
vcpu->arch.access = access;
|
|
|
vcpu->arch.mmio_gfn = gfn;
|
|
vcpu->arch.mmio_gfn = gfn;
|
|
|
|
|
+ vcpu->arch.mmio_gen = kvm_memslots(vcpu->kvm)->generation;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static inline bool vcpu_match_mmio_gen(struct kvm_vcpu *vcpu)
|
|
|
|
|
+{
|
|
|
|
|
+ return vcpu->arch.mmio_gen == kvm_memslots(vcpu->kvm)->generation;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
- * Clear the mmio cache info for the given gva,
|
|
|
|
|
- * specially, if gva is ~0ul, we clear all mmio cache info.
|
|
|
|
|
|
|
+ * Clear the mmio cache info for the given gva. If gva is MMIO_GVA_ANY, we
|
|
|
|
|
+ * clear all mmio cache info.
|
|
|
*/
|
|
*/
|
|
|
|
|
+#define MMIO_GVA_ANY (~(gva_t)0)
|
|
|
|
|
+
|
|
|
static inline void vcpu_clear_mmio_info(struct kvm_vcpu *vcpu, gva_t gva)
|
|
static inline void vcpu_clear_mmio_info(struct kvm_vcpu *vcpu, gva_t gva)
|
|
|
{
|
|
{
|
|
|
- if (gva != (~0ul) && vcpu->arch.mmio_gva != (gva & PAGE_MASK))
|
|
|
|
|
|
|
+ if (gva != MMIO_GVA_ANY && vcpu->arch.mmio_gva != (gva & PAGE_MASK))
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
vcpu->arch.mmio_gva = 0;
|
|
vcpu->arch.mmio_gva = 0;
|
|
@@ -104,7 +112,8 @@ static inline void vcpu_clear_mmio_info(struct kvm_vcpu *vcpu, gva_t gva)
|
|
|
|
|
|
|
|
static inline bool vcpu_match_mmio_gva(struct kvm_vcpu *vcpu, unsigned long gva)
|
|
static inline bool vcpu_match_mmio_gva(struct kvm_vcpu *vcpu, unsigned long gva)
|
|
|
{
|
|
{
|
|
|
- if (vcpu->arch.mmio_gva && vcpu->arch.mmio_gva == (gva & PAGE_MASK))
|
|
|
|
|
|
|
+ if (vcpu_match_mmio_gen(vcpu) && vcpu->arch.mmio_gva &&
|
|
|
|
|
+ vcpu->arch.mmio_gva == (gva & PAGE_MASK))
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
return false;
|
|
@@ -112,7 +121,8 @@ static inline bool vcpu_match_mmio_gva(struct kvm_vcpu *vcpu, unsigned long gva)
|
|
|
|
|
|
|
|
static inline bool vcpu_match_mmio_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
|
|
static inline bool vcpu_match_mmio_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
|
|
|
{
|
|
{
|
|
|
- if (vcpu->arch.mmio_gfn && vcpu->arch.mmio_gfn == gpa >> PAGE_SHIFT)
|
|
|
|
|
|
|
+ if (vcpu_match_mmio_gen(vcpu) && vcpu->arch.mmio_gfn &&
|
|
|
|
|
+ vcpu->arch.mmio_gfn == gpa >> PAGE_SHIFT)
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
return false;
|