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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4C04C028.8050506@redhat.com>
Date:	Tue, 01 Jun 2010 11:09:12 +0300
From:	Avi Kivity <avi@...hat.com>
To:	Xiao Guangrong <xiaoguangrong@...fujitsu.com>
CC:	Marcelo Tosatti <mtosatti@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>,
	KVM list <kvm@...r.kernel.org>
Subject: Re: [PATCH 1/5] KVM: MMU: introduce some macros to cleanup hlist
 traverseing

On 06/01/2010 05:38 AM, Xiao Guangrong wrote:
>
> Avi Kivity wrote:
>    
>> On 05/31/2010 05:00 AM, Xiao Guangrong wrote:
>>      
>>>        
>>>>
>>>>          
>>>>> +
>>>>> +#define for_each_gfn_indirect_sp(kvm, sp, gfn, pos, n)            \
>>>>> +  hlist_for_each_entry_safe(sp, pos, n,                    \
>>>>> +&kvm->arch.mmu_page_hash[kvm_page_table_hashfn(gfn)], hash_link)\
>>>>> +        if (sp->gfn == gfn&&    !sp->role.direct)
>>>>> +
>>>>> +#define for_each_gfn_indirect_valid_sp(kvm, sp, gfn, pos, n)        \
>>>>> +  hlist_for_each_entry_safe(sp, pos, n,                    \
>>>>> +&kvm->arch.mmu_page_hash[kvm_page_table_hashfn(gfn)], hash_link)\
>>>>> +        if (sp->gfn == gfn&&    !sp->role.direct&&          \
>>>>> +            !sp->role.invalid)
>>>>>
>>>>>
>>>>>            
>>>> Shouldn't we always skip invalid gfns?
>>>>
>>>>          
>>> Actually, in kvm_mmu_unprotect_page() function, it need find out
>>> invalid shadow pages:
>>>
>>> |    hlist_for_each_entry_safe(sp, node, n, bucket, hash_link)
>>> |        if (sp->gfn == gfn&&   !sp->role.direct) {
>>> |            pgprintk("%s: gfn %lx role %x\n", __func__, gfn,
>>> |                 sp->role.word);
>>> |            r = 1;
>>> |            if (kvm_mmu_zap_page(kvm, sp))
>>> |                goto restart;
>>> |        }
>>>
>>> I'm not sure whether we can skip invalid sp here, since it can change
>>> this
>>> function's return value. :-(
>>>
>>>        
>> Hm.  Invalid pages don't need to be write protected.  So I think you can
>> patch unprotect_page() to ignore invalid pages, and then you can convert
>> it to the new macros which ignore invalid pages as well.
>>
>> The invariant is: if an sp exists with !role.invalid and !unsync, then
>> the page must be write protected.
>>      
> OK, will fix it in the next version.
>
>    
>>
>>      
>>>> What about providing both gfn and role to the macro?
>>>>
>>>>
>>>>          
>>> In current code, no code simply use role and gfn to find sp,
>>> in kvm_mmu_get_page(), we need do other work for
>>> 'sp->gfn == gfn&&   sp->role != role' sp, and other functions only need
>>> compare
>>> some members in role, but not all members.
>>>
>>>        
>> How about just gfn?  I think everything compares against that!
>>
>>      
> In this patch, it already introduced a macro to only compares 'gfn', that is:
>
> +#define for_each_gfn_sp(kvm, sp, gfn, pos, n)				\
> +  hlist_for_each_entry_safe(sp, pos, n,				\
> +	&kvm->arch.mmu_page_hash[kvm_page_table_hashfn(gfn)], hash_link)\
> +		if (sp->gfn == gfn)
>
> Sorry if i misunderstand your meaning.
>    

No, I got confused.

-- 
error compiling committee.c: too many arguments to function

--
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