From: Marc Zyngier <maz@kernel.org>
To: "wangyanan (Y)" <wangyanan55@huawei.com>
Cc: jiangkunkun@huawei.com, Gavin Shan <gshan@redhat.com>,
lushenming@huawei.com, Suzuki K Poulose <suzuki.poulose@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
zhukeqian1@huawei.com, Quentin Perret <qperret@google.com>,
wangjingyi11@huawei.com, linux-kernel@vger.kernel.org,
yezengruan@huawei.com, James Morse <james.morse@arm.com>,
linux-arm-kernel@lists.infradead.org, yuzenghui@huawei.com,
wanghaibin.wang@huawei.com, Will Deacon <will@kernel.org>,
Julien Thierry <julien.thierry.kdev@gmail.com>
Subject: Re: [RFC PATCH] KVM: arm64: Add prejudgement for relaxing permissions only case in stage2 translation fault handler
Date: Tue, 15 Dec 2020 13:18:35 +0000 [thread overview]
Message-ID: <9a3bd48c4e69946bc4ade274ce2cc318@kernel.org> (raw)
In-Reply-To: <2ab9323a-40a1-d223-f692-0a19207e16a9@huawei.com>
Hi Yanan,
On 2020-12-14 07:20, wangyanan (Y) wrote:
> diff --git a/arch/arm64/kvm/hyp/pgtable.c
> b/arch/arm64/kvm/hyp/pgtable.c
> index a74a62283012..e3c6133567c4 100644
> --- a/arch/arm64/kvm/hyp/pgtable.c
> +++ b/arch/arm64/kvm/hyp/pgtable.c
> @@ -45,6 +45,10 @@
>
> #define KVM_PTE_LEAF_ATTR_HI_S2_XN BIT(54)
>
> +#define KVM_PTE_LEAF_ATTR_S2_PERMS (KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | \
> + KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \
> + KVM_PTE_LEAF_ATTR_HI_S2_XN)
> +
> struct kvm_pgtable_walk_data {
> struct kvm_pgtable *pgt;
> struct kvm_pgtable_walker *walker;
> @@ -473,8 +477,13 @@ static bool stage2_map_walker_try_leaf(u64 addr,
> u64 end, u32 level,
>
> new = kvm_init_valid_leaf_pte(phys, data->attr, level);
> if (kvm_pte_valid(old)) {
> - /* Tolerate KVM recreating the exact same mapping. */
> - if (old == new)
> + /*
> + * Skip updating the PTE with break-before-make if we
> are trying
> + * to recreate the exact same mapping or only change
> the access
> + * permissions. Actually, change of permissions will be
> handled
> + * through the relax_perms path next time if necessary.
> + */
> + if (!((old ^ new) & (~KVM_PTE_LEAF_ATTR_S2_PERMS)))
> goto out;
>
> /* There's an existing different valid leaf entry, so
> perform
I think there is a bit more work to do on this.
One obvious issue is that we currently flag a page as dirty before
handling
the fault. With an early exit, we end-up having spurious dirty pages.
It's not a big deal, but I'd rather mark the page dirty after the
mapping
or the permission update having been successful (at the moment, it
cannot
fails).
Thanks,
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: "wangyanan (Y)" <wangyanan55@huawei.com>
Cc: Will Deacon <will@kernel.org>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Catalin Marinas <catalin.marinas@arm.com>,
James Morse <james.morse@arm.com>,
Julien Thierry <julien.thierry.kdev@gmail.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Gavin Shan <gshan@redhat.com>,
Quentin Perret <qperret@google.com>,
wanghaibin.wang@huawei.com, yezengruan@huawei.com,
zhukeqian1@huawei.com, yuzenghui@huawei.com,
jiangkunkun@huawei.com, wangjingyi11@huawei.com,
lushenming@huawei.com
Subject: Re: [RFC PATCH] KVM: arm64: Add prejudgement for relaxing permissions only case in stage2 translation fault handler
Date: Tue, 15 Dec 2020 13:18:35 +0000 [thread overview]
Message-ID: <9a3bd48c4e69946bc4ade274ce2cc318@kernel.org> (raw)
In-Reply-To: <2ab9323a-40a1-d223-f692-0a19207e16a9@huawei.com>
Hi Yanan,
On 2020-12-14 07:20, wangyanan (Y) wrote:
> diff --git a/arch/arm64/kvm/hyp/pgtable.c
> b/arch/arm64/kvm/hyp/pgtable.c
> index a74a62283012..e3c6133567c4 100644
> --- a/arch/arm64/kvm/hyp/pgtable.c
> +++ b/arch/arm64/kvm/hyp/pgtable.c
> @@ -45,6 +45,10 @@
>
> #define KVM_PTE_LEAF_ATTR_HI_S2_XN BIT(54)
>
> +#define KVM_PTE_LEAF_ATTR_S2_PERMS (KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | \
> + KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \
> + KVM_PTE_LEAF_ATTR_HI_S2_XN)
> +
> struct kvm_pgtable_walk_data {
> struct kvm_pgtable *pgt;
> struct kvm_pgtable_walker *walker;
> @@ -473,8 +477,13 @@ static bool stage2_map_walker_try_leaf(u64 addr,
> u64 end, u32 level,
>
> new = kvm_init_valid_leaf_pte(phys, data->attr, level);
> if (kvm_pte_valid(old)) {
> - /* Tolerate KVM recreating the exact same mapping. */
> - if (old == new)
> + /*
> + * Skip updating the PTE with break-before-make if we
> are trying
> + * to recreate the exact same mapping or only change
> the access
> + * permissions. Actually, change of permissions will be
> handled
> + * through the relax_perms path next time if necessary.
> + */
> + if (!((old ^ new) & (~KVM_PTE_LEAF_ATTR_S2_PERMS)))
> goto out;
>
> /* There's an existing different valid leaf entry, so
> perform
I think there is a bit more work to do on this.
One obvious issue is that we currently flag a page as dirty before
handling
the fault. With an early exit, we end-up having spurious dirty pages.
It's not a big deal, but I'd rather mark the page dirty after the
mapping
or the permission update having been successful (at the moment, it
cannot
fails).
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2020-12-15 13:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 8:01 [RFC PATCH 0/1] Add prejudgement for relaxing permissions only case Yanan Wang
2020-12-11 8:01 ` Yanan Wang
2020-12-11 8:01 ` [RFC PATCH] KVM: arm64: Add prejudgement for relaxing permissions only case in stage2 translation fault handler Yanan Wang
2020-12-11 8:01 ` Yanan Wang
2020-12-11 9:49 ` Marc Zyngier
2020-12-11 9:49 ` Marc Zyngier
2020-12-11 10:00 ` Will Deacon
2020-12-11 10:00 ` Will Deacon
2020-12-14 7:20 ` wangyanan (Y)
2020-12-14 7:20 ` wangyanan (Y)
2020-12-15 13:18 ` Marc Zyngier [this message]
2020-12-15 13:18 ` Marc Zyngier
2020-12-14 7:20 ` wangyanan (Y)
2020-12-14 7:20 ` wangyanan (Y)
2020-12-11 9:53 ` Will Deacon
2020-12-11 9:53 ` Will Deacon
2020-12-14 7:20 ` wangyanan (Y)
2020-12-14 7:20 ` 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=9a3bd48c4e69946bc4ade274ce2cc318@kernel.org \
--to=maz@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=gshan@redhat.com \
--cc=james.morse@arm.com \
--cc=jiangkunkun@huawei.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lushenming@huawei.com \
--cc=qperret@google.com \
--cc=suzuki.poulose@arm.com \
--cc=wanghaibin.wang@huawei.com \
--cc=wangjingyi11@huawei.com \
--cc=wangyanan55@huawei.com \
--cc=will@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.