Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Yanan Wang <wangyanan55@huawei.com>
Cc: Gavin Shan <gshan@redhat.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Marc Zyngier <maz@kernel.org>,
	Quentin Perret <qperret@google.com>,
	linux-kernel@vger.kernel.org, yezengruan@huawei.com,
	James Morse <james.morse@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	yuzenghui@huawei.com, wanghaibin.wang@huawei.com,
	zhukeqian1@huawei.com,
	Julien Thierry <julien.thierry.kdev@gmail.com>
Subject: Re: [PATCH v2 3/3] KVM: arm64: Mark the page dirty only if the fault is handled successfully
Date: Wed, 13 Jan 2021 15:51:01 +0000	[thread overview]
Message-ID: <20210113155101.GB11892@willie-the-truck> (raw)
In-Reply-To: <20201216122844.25092-4-wangyanan55@huawei.com>

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@huawei.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?

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-01-13 15:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 12:28 [PATCH v2 0/3] RFC: Solve several problems in stage 2 translation Yanan Wang
2020-12-16 12:28 ` [PATCH v2 1/3] KVM: arm64: Decouple partial code of hyp stage 1 mapping and guest stage 2 mapping Yanan Wang
2020-12-16 12:28 ` [PATCH v2 2/3] KVM: arm64: Add prejudgement for relaxing permissions only case in stage2 translation fault handler Yanan Wang
2021-01-13 15:44   ` Will Deacon
2021-01-14  9:28     ` wangyanan (Y)
2020-12-16 12:28 ` [PATCH v2 3/3] KVM: arm64: Mark the page dirty only if the fault is handled successfully Yanan Wang
2021-01-13 15:51   ` Will Deacon [this message]
2021-01-14  9:28     ` wangyanan (Y)
2020-12-28  2:46 ` [PATCH v2 0/3] RFC: Solve several problems in stage 2 translation wangyanan (Y)

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=20210113155101.GB11892@willie-the-truck \
    --to=will@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=qperret@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=wangyanan55@huawei.com \
    --cc=yezengruan@huawei.com \
    --cc=yuzenghui@huawei.com \
    --cc=zhukeqian1@huawei.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