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: <6cd9c7ba-cb73-bb77-3cfc-e06b204a76d9@huawei.com>
Date:   Thu, 14 Jan 2021 17:28:04 +0800
From:   "wangyanan (Y)" <wangyanan55@...wei.com>
To:     Will Deacon <will@...nel.org>
CC:     <linux-kernel@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        Marc Zyngier <maz@...nel.org>,
        Catalin Marinas <catalin.marinas@....com>,
        James Morse <james.morse@....com>,
        Julien Thierry <julien.thierry.kdev@...il.com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Gavin Shan <gshan@...hat.com>,
        Quentin Perret <qperret@...gle.com>,
        <wanghaibin.wang@...wei.com>, <yezengruan@...wei.com>,
        <zhukeqian1@...wei.com>, <yuzenghui@...wei.com>
Subject: Re: [PATCH v2 3/3] KVM: arm64: Mark the page dirty only if the fault
 is handled successfully


On 2021/1/13 23:51, Will Deacon wrote:
> On Wed, Dec 16, 2020 at 08:28:44PM +0800, Yanan Wang wrote:
>> We now mark the page dirty and set the bitmap before calling fault handlers
>> in user_mem_abort(), and we might end up having spurious dirty pages if
>> update of permissions or mapping has failed.
>> So, mark the page dirty only if the fault is handled successfully.
>>
>> Let the guest directly enter again but not return to userspace if we were
>> trying to recreate the same mapping or only change access permissions
>> with BBM, which is not permitted in the mapping path.
>>
>> Signed-off-by: Yanan Wang <wangyanan55@...wei.com>
>> ---
>>   arch/arm64/kvm/mmu.c | 18 ++++++++++++++----
>>   1 file changed, 14 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
>> index 75814a02d189..72e516a10914 100644
>> --- a/arch/arm64/kvm/mmu.c
>> +++ b/arch/arm64/kvm/mmu.c
>> @@ -879,11 +879,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>   	if (vma_pagesize == PAGE_SIZE && !force_pte)
>>   		vma_pagesize = transparent_hugepage_adjust(memslot, hva,
>>   							   &pfn, &fault_ipa);
>> -	if (writable) {
>> +	if (writable)
>>   		prot |= KVM_PGTABLE_PROT_W;
>> -		kvm_set_pfn_dirty(pfn);
>> -		mark_page_dirty(kvm, gfn);
>> -	}
>>   
>>   	if (fault_status != FSC_PERM && !device)
>>   		clean_dcache_guest_page(pfn, vma_pagesize);
>> @@ -911,6 +908,19 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>   					     memcache);
>>   	}
>>   
>> +	/* Mark the page dirty only if the fault is handled successfully */
>> +	if (writable && !ret) {
>> +		kvm_set_pfn_dirty(pfn);
>> +		mark_page_dirty(kvm, gfn);
>> +	}
>> +
>> +	/* Let the guest directly enter again if we were trying to recreate the
>> +	 * same mapping or only change access permissions with BBM, which is not
>> +	 * permitted in the mapping path.
>> +	 */
>> +	if (ret == -EAGAIN)
>> +		ret = 0;
> Maybe just 'return ret != -EAGAIN ? ret : 0;' at the end of the function?
Yes, it's more concise.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ