Commit 26c44a63 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: x86/mmu: Consolidate "is MMIO SPTE" code

Replace the open-coded "is MMIO SPTE" checks in the MMU warnings
related to software-based access/dirty tracking to make the code
slightly more self-documenting.

No functional change intended.
Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 4af77151
...@@ -310,6 +310,11 @@ void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value, u64 access_mask) ...@@ -310,6 +310,11 @@ void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value, u64 access_mask)
} }
EXPORT_SYMBOL_GPL(kvm_mmu_set_mmio_spte_mask); EXPORT_SYMBOL_GPL(kvm_mmu_set_mmio_spte_mask);
static bool is_mmio_spte(u64 spte)
{
return (spte & shadow_mmio_mask) == shadow_mmio_value;
}
static inline bool sp_ad_disabled(struct kvm_mmu_page *sp) static inline bool sp_ad_disabled(struct kvm_mmu_page *sp)
{ {
return sp->role.ad_disabled; return sp->role.ad_disabled;
...@@ -317,19 +322,19 @@ static inline bool sp_ad_disabled(struct kvm_mmu_page *sp) ...@@ -317,19 +322,19 @@ static inline bool sp_ad_disabled(struct kvm_mmu_page *sp)
static inline bool spte_ad_enabled(u64 spte) static inline bool spte_ad_enabled(u64 spte)
{ {
MMU_WARN_ON((spte & shadow_mmio_mask) == shadow_mmio_value); MMU_WARN_ON(is_mmio_spte(spte));
return !(spte & shadow_acc_track_value); return !(spte & shadow_acc_track_value);
} }
static inline u64 spte_shadow_accessed_mask(u64 spte) static inline u64 spte_shadow_accessed_mask(u64 spte)
{ {
MMU_WARN_ON((spte & shadow_mmio_mask) == shadow_mmio_value); MMU_WARN_ON(is_mmio_spte(spte));
return spte_ad_enabled(spte) ? shadow_accessed_mask : 0; return spte_ad_enabled(spte) ? shadow_accessed_mask : 0;
} }
static inline u64 spte_shadow_dirty_mask(u64 spte) static inline u64 spte_shadow_dirty_mask(u64 spte)
{ {
MMU_WARN_ON((spte & shadow_mmio_mask) == shadow_mmio_value); MMU_WARN_ON(is_mmio_spte(spte));
return spte_ad_enabled(spte) ? shadow_dirty_mask : 0; return spte_ad_enabled(spte) ? shadow_dirty_mask : 0;
} }
...@@ -404,11 +409,6 @@ static void mark_mmio_spte(struct kvm_vcpu *vcpu, u64 *sptep, u64 gfn, ...@@ -404,11 +409,6 @@ static void mark_mmio_spte(struct kvm_vcpu *vcpu, u64 *sptep, u64 gfn,
mmu_spte_set(sptep, mask); mmu_spte_set(sptep, mask);
} }
static bool is_mmio_spte(u64 spte)
{
return (spte & shadow_mmio_mask) == shadow_mmio_value;
}
static gfn_t get_mmio_spte_gfn(u64 spte) static gfn_t get_mmio_spte_gfn(u64 spte)
{ {
u64 gpa = spte & shadow_nonpresent_or_rsvd_lower_gfn_mask; u64 gpa = spte & shadow_nonpresent_or_rsvd_lower_gfn_mask;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment