[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9a3bd48c4e69946bc4ade274ce2cc318@kernel.org>
Date: Tue, 15 Dec 2020 13:18:35 +0000
From: Marc Zyngier <maz@...nel.org>
To: "wangyanan (Y)" <wangyanan55@...wei.com>
Cc: Will Deacon <will@...nel.org>, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.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,
jiangkunkun@...wei.com, wangjingyi11@...wei.com,
lushenming@...wei.com
Subject: Re: [RFC PATCH] KVM: arm64: Add prejudgement for relaxing permissions
only case in stage2 translation fault handler
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...
Powered by blists - more mailing lists