From: Paolo Bonzini <pbonzini@redhat.com>
To: Junaid Shahid <junaids@google.com>, kvm@vger.kernel.org
Cc: andreslc@google.com, pfeiner@google.com, guangrong.xiao@linux.intel.com
Subject: Re: [PATCH 5/5] kvm: x86: mmu: Verify that restored PTE has needed perms in fast page fault
Date: Wed, 25 Jan 2017 12:49:06 +0100 [thread overview]
Message-ID: <2cf4d0ad-e022-c0b7-a07a-e9b6e82fa5ba@redhat.com> (raw)
In-Reply-To: <1482380972-25573-6-git-send-email-junaids@google.com>
> - remove_acc_track = is_access_track_spte(spte);
> -
> - /* Verify that the fault can be handled in the fast path */
> - if (!remove_acc_track && !remove_write_prot)
> - break;
> + new_spte = is_access_track_spte(spte)
> + ? restore_acc_track_spte(spte)
> + : spte;
Just a tiny stylistic change to match the "new_spte |= PT_WRITABLE_MASK"
in the block below:
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index aa3b0d14c019..2fd7586aad4d 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3135,9 +3135,10 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level,
break;
}
- new_spte = is_access_track_spte(spte)
- ? restore_acc_track_spte(spte)
- : spte;
+ new_spte = spte;
+
+ if (is_access_track_spte(spte))
+ new_spte = restore_acc_track_spte(new_spte);
/*
* Currently, to simplify the code, write-protection can
Paolo
> /*
> - * Do not fix write-permission on the large spte since we only
> - * dirty the first page into the dirty-bitmap in
> - * fast_pf_fix_direct_spte() that means other pages are missed
> - * if its slot is dirty-logged.
> - *
> - * Instead, we let the slow page fault path create a normal spte
> - * to fix the access.
> - *
> - * See the comments in kvm_arch_commit_memory_region().
> + * Currently, to simplify the code, write-protection can
> + * be removed in the fast path only if the SPTE was
> + * write-protected for dirty-logging or access tracking.
> */
> - if (sp->role.level > PT_PAGE_TABLE_LEVEL && remove_write_prot)
> + if ((error_code & PFERR_WRITE_MASK) &&
> + spte_can_locklessly_be_made_writable(spte))
> + {
> + new_spte |= PT_WRITABLE_MASK;
> +
> + /*
> + * Do not fix write-permission on the large spte since
> + * we only dirty the first page into the dirty-bitmap in
> + * fast_pf_fix_direct_spte() that means other pages are
> + * missed if its slot is dirty-logged.
> + *
> + * Instead, we let the slow page fault path create a
> + * normal spte to fix the access.
> + *
> + * See the comments in kvm_arch_commit_memory_region().
> + */
> + if (sp->role.level > PT_PAGE_TABLE_LEVEL)
> + break;
> + }
> +
> + /* Verify that the fault can be handled in the fast path */
> + if (new_spte == spte ||
> + !is_access_allowed(error_code, new_spte))
> break;
>
> /*
> @@ -3166,8 +3175,7 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level,
> */
> fault_handled = fast_pf_fix_direct_spte(vcpu, sp,
> iterator.sptep, spte,
> - remove_write_prot,
> - remove_acc_track);
> + new_spte);
> if (fault_handled)
> break;
>
>
next prev parent reply other threads:[~2017-01-25 11:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-22 4:29 [PATCH 0/5] Followup patches for lockless access tracking Junaid Shahid
2016-12-22 4:29 ` [PATCH 1/5] kvm: x86: mmu: Rename EPT_VIOLATION_READ/WRITE/INSTR constants Junaid Shahid
2016-12-22 4:29 ` [PATCH 2/5] kvm: x86: mmu: Set SPTE_SPECIAL_MASK within mmu.c Junaid Shahid
2016-12-22 4:29 ` [PATCH 3/5] kvm: x86: mmu: Move pgtbl walk inside retry loop in fast_page_fault Junaid Shahid
2016-12-22 4:29 ` [PATCH 4/5] kvm: x86: mmu: Update comment in mark_spte_for_access_track Junaid Shahid
2016-12-22 4:29 ` [PATCH 5/5] kvm: x86: mmu: Verify that restored PTE has needed perms in fast page fault Junaid Shahid
2017-01-25 11:49 ` Paolo Bonzini [this message]
2017-01-25 20:05 ` Junaid Shahid
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2cf4d0ad-e022-c0b7-a07a-e9b6e82fa5ba@redhat.com \
--to=pbonzini@redhat.com \
--cc=andreslc@google.com \
--cc=guangrong.xiao@linux.intel.com \
--cc=junaids@google.com \
--cc=kvm@vger.kernel.org \
--cc=pfeiner@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox