From: Avi Kivity <avi@redhat.com>
To: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH 5/7] KVM: MMU: Add validate_indirect_spte() helper
Date: Mon, 12 Jul 2010 11:50:48 +0300 [thread overview]
Message-ID: <4C3AD768.6010107@redhat.com> (raw)
In-Reply-To: <4C3AA441.2090002@cn.fujitsu.com>
On 07/12/2010 08:12 AM, Xiao Guangrong wrote:
>
> Avi Kivity wrote:
>
>> Move the code to validate an indirect shadow page (by verifying that the gpte
>> has not changed since it was fetched) into a helper.
>>
>> Signed-off-by: Avi Kivity<avi@redhat.com>
>> ---
>> arch/x86/kvm/paging_tmpl.h | 29 ++++++++++++++++++++---------
>> 1 files changed, 20 insertions(+), 9 deletions(-)
>>
>> diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
>> index cacb4f2..72f54fe 100644
>> --- a/arch/x86/kvm/paging_tmpl.h
>> +++ b/arch/x86/kvm/paging_tmpl.h
>> @@ -299,6 +299,23 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
>> gpte_to_gfn(gpte), pfn, true, true);
>> }
>>
>> +static bool FNAME(validate_indirect_spte)(struct kvm_vcpu *vcpu,
>> + u64 *sptep, struct kvm_mmu_page *sp,
>> + struct guest_walker *gw, int level)
>> +{
>> + int r;
>> + pt_element_t curr_pte;
>> +
>> + r = kvm_read_guest_atomic(vcpu->kvm,
>> + gw->pte_gpa[level - 2],
>> + &curr_pte, sizeof(curr_pte));
>> + if (r || curr_pte != gw->ptes[level - 2]) {
>> + kvm_mmu_put_page(sp, sptep);
>> + return false;
>>
> I think it's 'level - 1' here for checking 'level''s mapping
>
Well, I'm just moving code around. If it needs to be fixed, that's
another patch.
I think the logic is, we just write-protected the shadow page for level
L-1, so we need to verify that the gpte we write protected hasn't
changed. That gpte is in level L - 1, and it is stored in
gw->gptes[level - 2].
Of course, that logic is wrong, we need to check all gptes, since
between the guest walk and FNAME(fetch)() the shadow pages and gptes may
have changed several times. I'll fix that later.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2010-07-12 8:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-11 15:42 [PATCH 0/7] Simplify and fix fetch() Avi Kivity
2010-07-11 15:42 ` [PATCH 1/7] KVM: MMU: Add link_shadow_page() helper Avi Kivity
2010-07-12 4:58 ` Xiao Guangrong
2010-07-11 15:42 ` [PATCH 2/7] KVM: MMU: Use __set_spte to link shadow pages Avi Kivity
2010-07-12 4:58 ` Xiao Guangrong
2010-07-11 15:42 ` [PATCH 3/7] KVM: MMU: Add drop_spte_if_large() helper Avi Kivity
2010-07-12 4:59 ` Xiao Guangrong
2010-07-11 15:42 ` [PATCH 4/7] KVM: MMU: Add validate_direct_spte() helper Avi Kivity
2010-07-12 5:00 ` Xiao Guangrong
2010-07-11 15:42 ` [PATCH 5/7] KVM: MMU: Add validate_indirect_spte() helper Avi Kivity
2010-07-12 5:01 ` Xiao Guangrong
2010-07-12 5:12 ` Xiao Guangrong
2010-07-12 8:50 ` Avi Kivity [this message]
2010-07-11 15:42 ` [PATCH 6/7] KVM: MMU: Simplify spte fetch() function Avi Kivity
2010-07-11 16:08 ` Avi Kivity
2010-07-12 5:10 ` Xiao Guangrong
2010-07-12 8:52 ` Avi Kivity
2010-07-12 5:08 ` Xiao Guangrong
2010-07-12 8:53 ` Avi Kivity
2010-07-11 15:42 ` [PATCH 7/7] KVM: MMU: Validate all gptes during fetch, not just those used for new pages Avi Kivity
2010-07-12 5:10 ` Xiao Guangrong
2010-07-12 8:58 ` Avi Kivity
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=4C3AD768.6010107@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong@cn.fujitsu.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