lkml.org 
[lkml]   [2013]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 05/12] KVM: MMU: introduce vcpu_adjust_access
On 01/24/2013 06:36 PM, Gleb Natapov wrote:
> On Wed, Jan 23, 2013 at 06:06:36PM +0800, Xiao Guangrong wrote:
>> Introduce it to split the code of adjusting pte_access from the large
>> function of set_spte
>>
>> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>> ---
>> arch/x86/kvm/mmu.c | 63 +++++++++++++++++++++++++++++++++-------------------
>> 1 files changed, 40 insertions(+), 23 deletions(-)
>>
>> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
>> index af8bcb2..43b7e0c 100644
>> --- a/arch/x86/kvm/mmu.c
>> +++ b/arch/x86/kvm/mmu.c
>> @@ -2324,25 +2324,18 @@ static int mmu_need_write_protect(struct kvm_vcpu *vcpu, gfn_t gfn,
>> return 0;
>> }
>>
>> -static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
>> - unsigned pte_access, int level,
>> - gfn_t gfn, pfn_t pfn, bool speculative,
>> - bool can_unsync, bool host_writable)
>> +/*
>> + * Return -1 if a race condition is detected, 1 if @gfn need to be
>> + * write-protected, otherwise 0 is returned.
>> + */
> That's a little bit crafty.
>
> Isn't it better to handle race condition in set_spte() explicitly?
> Something like do:
>
> if (host_writable && (pte_access & ACC_WRITE_MASK) &&
> level > PT_PAGE_TABLE_LEVEL && has_wrprotected_page(vcpu->kvm, gfn, level))
> return 0;
>
> before calling vcpu_adjust_access() in set_spte()?
>
> Or even do:
>
> if ((pte_access & ACC_WRITE_MASK) && level > PT_PAGE_TABLE_LEVEL &&
> has_wrprotected_page(vcpu->kvm, gfn, level))
> return 0;
>
> After calling vcpu_adjust_access().
>
> The later will create read only large page mapping where now it is not
> created, but it shouldn't be a problem as far as I see.

Yes. I like the later way. Will update it. Thanks for your suggestion, Gleb!



\
 
 \ /
  Last update: 2013-01-24 13:01    [W:0.157 / U:1.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site