From: Oliver Upton <oliver.upton@linux.dev>
To: Marc Zyngier <maz@kernel.org>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Joey Gouly <joey.gouly@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Christoffer Dall <christoffer.dall@arm.com>,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Subject: Re: [PATCH v2 12/16] KVM: arm64: nv: Tag shadow S2 entries with guest's leaf S2 level
Date: Mon, 3 Jun 2024 18:05:23 +0000 [thread overview]
Message-ID: <Zl4F45W_FoVr89zl@linux.dev> (raw)
In-Reply-To: <20240529145628.3272630-13-maz@kernel.org>
On Wed, May 29, 2024 at 03:56:24PM +0100, Marc Zyngier wrote:
> Populate bits [56:55] of the leaf entry with the level provided
> by the guest's S2 translation. This will allow us to better scope
> the invalidation by remembering the mapping size.
>
> Of course, this assume that the guest will issue an invalidation
> with an address that falls into the same leaf. If the guest doesn't,
> we'll over-invalidate.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
> arch/arm64/include/asm/kvm_nested.h | 8 ++++++++
> arch/arm64/kvm/mmu.c | 17 +++++++++++++++--
> 2 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_nested.h b/arch/arm64/include/asm/kvm_nested.h
> index fcb0de3a93fe..971dbe533730 100644
> --- a/arch/arm64/include/asm/kvm_nested.h
> +++ b/arch/arm64/include/asm/kvm_nested.h
> @@ -5,6 +5,7 @@
> #include <linux/bitfield.h>
> #include <linux/kvm_host.h>
> #include <asm/kvm_emulate.h>
> +#include <asm/kvm_pgtable.h>
>
> static inline bool vcpu_has_nv(const struct kvm_vcpu *vcpu)
> {
> @@ -195,4 +196,11 @@ static inline bool kvm_auth_eretax(struct kvm_vcpu *vcpu, u64 *elr)
> }
> #endif
>
> +#define KVM_NV_GUEST_MAP_SZ (KVM_PGTABLE_PROT_SW1 | KVM_PGTABLE_PROT_SW0)
> +
> +static inline u64 kvm_encode_nested_level(struct kvm_s2_trans *trans)
> +{
> + return FIELD_PREP(KVM_NV_GUEST_MAP_SZ, trans->level);
> +}
> +
It might be nice to keep all of the software fields for (in)valid in
a central place so we can add some documentation. I fear this is going
to get rather complicated as more pieces of pKVM land upstream and we
find new and fun ways to cram data into stage-2.
> #endif /* __ARM64_KVM_NESTED_H */
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 4ed93a384255..f3a8ec70bd29 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -1598,11 +1598,17 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
> * Potentially reduce shadow S2 permissions to match the guest's own
> * S2. For exec faults, we'd only reach this point if the guest
> * actually allowed it (see kvm_s2_handle_perm_fault).
> + *
> + * Also encode the level of the nested translation in the SW bits of
> + * the PTE/PMD/PUD. This will be retrived on TLB invalidation from
> + * the guest.
typo: retrieved
Also, it might be helpful to add some color here to indicate the encoded
TTL is used to represent the span of a single virtual TLB entry,
providing scope to the TLBI by address.
Before I actually read what was going on, I thought the TTL in the PTE
was used for matching invalidation scopes that have a valid TTL.
--
Thanks,
Oliver
WARNING: multiple messages have this Message-ID (diff)
From: Oliver Upton <oliver.upton@linux.dev>
To: Marc Zyngier <maz@kernel.org>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Joey Gouly <joey.gouly@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Christoffer Dall <christoffer.dall@arm.com>,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Subject: Re: [PATCH v2 12/16] KVM: arm64: nv: Tag shadow S2 entries with guest's leaf S2 level
Date: Mon, 3 Jun 2024 18:05:23 +0000 [thread overview]
Message-ID: <Zl4F45W_FoVr89zl@linux.dev> (raw)
In-Reply-To: <20240529145628.3272630-13-maz@kernel.org>
On Wed, May 29, 2024 at 03:56:24PM +0100, Marc Zyngier wrote:
> Populate bits [56:55] of the leaf entry with the level provided
> by the guest's S2 translation. This will allow us to better scope
> the invalidation by remembering the mapping size.
>
> Of course, this assume that the guest will issue an invalidation
> with an address that falls into the same leaf. If the guest doesn't,
> we'll over-invalidate.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
> arch/arm64/include/asm/kvm_nested.h | 8 ++++++++
> arch/arm64/kvm/mmu.c | 17 +++++++++++++++--
> 2 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_nested.h b/arch/arm64/include/asm/kvm_nested.h
> index fcb0de3a93fe..971dbe533730 100644
> --- a/arch/arm64/include/asm/kvm_nested.h
> +++ b/arch/arm64/include/asm/kvm_nested.h
> @@ -5,6 +5,7 @@
> #include <linux/bitfield.h>
> #include <linux/kvm_host.h>
> #include <asm/kvm_emulate.h>
> +#include <asm/kvm_pgtable.h>
>
> static inline bool vcpu_has_nv(const struct kvm_vcpu *vcpu)
> {
> @@ -195,4 +196,11 @@ static inline bool kvm_auth_eretax(struct kvm_vcpu *vcpu, u64 *elr)
> }
> #endif
>
> +#define KVM_NV_GUEST_MAP_SZ (KVM_PGTABLE_PROT_SW1 | KVM_PGTABLE_PROT_SW0)
> +
> +static inline u64 kvm_encode_nested_level(struct kvm_s2_trans *trans)
> +{
> + return FIELD_PREP(KVM_NV_GUEST_MAP_SZ, trans->level);
> +}
> +
It might be nice to keep all of the software fields for (in)valid in
a central place so we can add some documentation. I fear this is going
to get rather complicated as more pieces of pKVM land upstream and we
find new and fun ways to cram data into stage-2.
> #endif /* __ARM64_KVM_NESTED_H */
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 4ed93a384255..f3a8ec70bd29 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -1598,11 +1598,17 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
> * Potentially reduce shadow S2 permissions to match the guest's own
> * S2. For exec faults, we'd only reach this point if the guest
> * actually allowed it (see kvm_s2_handle_perm_fault).
> + *
> + * Also encode the level of the nested translation in the SW bits of
> + * the PTE/PMD/PUD. This will be retrived on TLB invalidation from
> + * the guest.
typo: retrieved
Also, it might be helpful to add some color here to indicate the encoded
TTL is used to represent the span of a single virtual TLB entry,
providing scope to the TLBI by address.
Before I actually read what was going on, I thought the TTL in the PTE
was used for matching invalidation scopes that have a valid TTL.
--
Thanks,
Oliver
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-06-03 18:05 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 14:56 [PATCH v2 00/16] KVM: arm64: nv: Shadow stage-2 page table handling Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 01/16] KVM: arm64: nv: Support multiple nested Stage-2 mmu structures Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 02/16] KVM: arm64: nv: Implement nested Stage-2 page table walk logic Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 03/16] KVM: arm64: nv: Handle shadow stage 2 page faults Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 04/16] KVM: arm64: nv: Unmap/flush shadow stage 2 page tables Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 05/16] KVM: arm64: nv: Add Stage-1 EL2 invalidation primitives Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 06/16] KVM: arm64: nv: Handle EL2 Stage-1 TLB invalidation Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 07/16] KVM: arm64: nv: Handle TLB invalidation targeting L2 stage-1 Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 08/16] KVM: arm64: nv: Handle TLBI VMALLS12E1{,IS} operations Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 09/16] KVM: arm64: nv: Handle TLBI ALLE1{,IS} operations Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 10/16] KVM: arm64: nv: Handle TLBI IPAS2E1{,IS} operations Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 11/16] KVM: arm64: nv: Handle FEAT_TTL hinted TLB operations Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 12/16] KVM: arm64: nv: Tag shadow S2 entries with guest's leaf S2 level Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-06-03 18:05 ` Oliver Upton [this message]
2024-06-03 18:05 ` Oliver Upton
2024-06-05 7:56 ` Marc Zyngier
2024-06-05 7:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 13/16] KVM: arm64: nv: Invalidate TLBs based on shadow S2 TTL-like information Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-06-03 18:36 ` Oliver Upton
2024-06-03 18:36 ` Oliver Upton
2024-06-04 7:59 ` Marc Zyngier
2024-06-04 7:59 ` Marc Zyngier
2024-06-04 17:49 ` Oliver Upton
2024-06-04 17:49 ` Oliver Upton
2024-05-29 14:56 ` [PATCH v2 14/16] KVM: arm64: nv: Add handling of outer-shareable TLBI operations Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 15/16] KVM: arm64: nv: Add handling of range-based " Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
2024-05-29 14:56 ` [PATCH v2 16/16] KVM: arm64: nv: Add handling of NXS-flavoured " Marc Zyngier
2024-05-29 14:56 ` Marc Zyngier
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=Zl4F45W_FoVr89zl@linux.dev \
--to=oliver.upton@linux.dev \
--cc=alexandru.elisei@arm.com \
--cc=christoffer.dall@arm.com \
--cc=gankulkarni@os.amperecomputing.com \
--cc=james.morse@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@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.