lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51011C06.9090003@linux.vnet.ibm.com>
Date:	Thu, 24 Jan 2013 19:33:26 +0800
From:	Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>
To:	Gleb Natapov <gleb@...hat.com>
CC:	Marcelo Tosatti <mtosatti@...hat.com>,
	Avi Kivity <avi.kivity@...il.com>,
	LKML <linux-kernel@...r.kernel.org>, KVM <kvm@...r.kernel.org>
Subject: Re: [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@...ux.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!

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ