Commit 01c168ac authored by Gui Jianfeng's avatar Gui Jianfeng Committed by Avi Kivity

KVM: MMU: don't check PT_WRITABLE_MASK directly

Since we have is_writable_pte(), make use of it.
Signed-off-by: default avatarGui Jianfeng <guijianfeng@cn.fujitsu.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 3af1817a
...@@ -2990,7 +2990,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot) ...@@ -2990,7 +2990,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
pt = sp->spt; pt = sp->spt;
for (i = 0; i < PT64_ENT_PER_PAGE; ++i) for (i = 0; i < PT64_ENT_PER_PAGE; ++i)
/* avoid RMW */ /* avoid RMW */
if (pt[i] & PT_WRITABLE_MASK) if (is_writable_pte(pt[i]))
pt[i] &= ~PT_WRITABLE_MASK; pt[i] &= ~PT_WRITABLE_MASK;
} }
kvm_flush_remote_tlbs(kvm); kvm_flush_remote_tlbs(kvm);
...@@ -3425,7 +3425,7 @@ void inspect_spte_has_rmap(struct kvm *kvm, u64 *sptep) ...@@ -3425,7 +3425,7 @@ void inspect_spte_has_rmap(struct kvm *kvm, u64 *sptep)
struct kvm_mmu_page *rev_sp; struct kvm_mmu_page *rev_sp;
gfn_t gfn; gfn_t gfn;
if (*sptep & PT_WRITABLE_MASK) { if (is_writable_pte(*sptep)) {
rev_sp = page_header(__pa(sptep)); rev_sp = page_header(__pa(sptep));
gfn = kvm_mmu_page_get_gfn(rev_sp, sptep - rev_sp->spt); gfn = kvm_mmu_page_get_gfn(rev_sp, sptep - rev_sp->spt);
...@@ -3474,7 +3474,7 @@ static void check_writable_mappings_rmap(struct kvm_vcpu *vcpu) ...@@ -3474,7 +3474,7 @@ static void check_writable_mappings_rmap(struct kvm_vcpu *vcpu)
if (!(ent & PT_PRESENT_MASK)) if (!(ent & PT_PRESENT_MASK))
continue; continue;
if (!(ent & PT_WRITABLE_MASK)) if (!is_writable_pte(ent))
continue; continue;
inspect_spte_has_rmap(vcpu->kvm, &pt[i]); inspect_spte_has_rmap(vcpu->kvm, &pt[i]);
} }
...@@ -3508,7 +3508,7 @@ static void audit_write_protection(struct kvm_vcpu *vcpu) ...@@ -3508,7 +3508,7 @@ static void audit_write_protection(struct kvm_vcpu *vcpu)
spte = rmap_next(vcpu->kvm, rmapp, NULL); spte = rmap_next(vcpu->kvm, rmapp, NULL);
while (spte) { while (spte) {
if (*spte & PT_WRITABLE_MASK) if (is_writable_pte(*spte))
printk(KERN_ERR "%s: (%s) shadow page has " printk(KERN_ERR "%s: (%s) shadow page has "
"writable mappings: gfn %lx role %x\n", "writable mappings: gfn %lx role %x\n",
__func__, audit_msg, sp->gfn, __func__, audit_msg, sp->gfn,
......
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