All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: "Mikołaj Lenczewski" <miko.lenczewski@arm.com>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, ryan.roberts@arm.com,
	catalin.marinas@arm.com, mark.rutland@arm.com,
	james.morse@arm.com, will@kernel.org, oliver.upton@linux.dev,
	joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com
Subject: Re: [PATCH v1] arm64: Add TLB Conflict Abort Exception handler to KVM
Date: Wed, 15 Jan 2025 15:13:54 +0000	[thread overview]
Message-ID: <865xmgw1n1.wl-maz@kernel.org> (raw)
In-Reply-To: <20250110172411.39845-3-miko.lenczewski@arm.com>

On Fri, 10 Jan 2025 17:24:07 +0000,
Mikołaj Lenczewski <miko.lenczewski@arm.com> wrote:
> 
> Currently, KVM does not handle the case of a stage 2 TLB conflict abort
> exception. This can legitimately occurs when the guest is eliding full
> BBM semantics as permitted by BBM level 2. In this case it is possible
> for a confclit abort to be delivered to EL2. We handle that by
> invalidating the full TLB.
> 
> The Arm ARM specifies that the worst-case invalidation is either a
> `tlbi vmalls12e1` or a `tlbi alle1` (as per DDI0487K section D8.16.3).
> We implement `tlbi alle1` by extending the existing
> __kvm_flush_vm_context() helper to allow for differentiating between
> inner-shareable and cpu-local invalidations.
> 
> This commit applies on top of v6.13-rc2 (fac04efc5c79).
> 
> Signed-off-by: Mikołaj Lenczewski <miko.lenczewski@arm.com>
> ---
>  arch/arm64/include/asm/esr.h       |  8 ++++++++
>  arch/arm64/include/asm/kvm_asm.h   |  2 +-
>  arch/arm64/kvm/hyp/nvhe/hyp-main.c |  2 +-
>  arch/arm64/kvm/hyp/nvhe/tlb.c      |  9 +++++++--
>  arch/arm64/kvm/hyp/vhe/tlb.c       |  9 +++++++--
>  arch/arm64/kvm/mmu.c               | 13 +++++++++++++
>  arch/arm64/kvm/vmid.c              |  2 +-
>  7 files changed, 38 insertions(+), 7 deletions(-)
>

[...]

> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index c9d46ad57e52..7c0d97449d23 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -1756,6 +1756,19 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu)
>  	ipa = fault_ipa = kvm_vcpu_get_fault_ipa(vcpu);
>  	is_iabt = kvm_vcpu_trap_is_iabt(vcpu);
>  
> +	if (esr_fsc_is_tlb_conflict_abort(esr)) {
> +
> +		/* Architecturely, at this stage 2 tlb conflict abort, we must
> +		 * either perform a `tlbi vmalls12e1`, or a `tlbi alle1`. Due
> +		 * to nesting of VMs, we would have to iterate all flattened
> +		 * VMIDs to clean out a single guest, so we perform a `tlbi alle1`
> +		 * instead to save time.
> +		 */
> +		__kvm_flush_vm_context(true);
> +
> +		return 1;
> +	}
> +

This is broken. At this stage, you are preemptible, so whatever
invalidation you are performing might be happening on the wrong CPU
(and I really don't want to see a broadcast invalidation).

I really don't see why this can't be handled as a fixup in the inner
run loop, which would save *a lot* of cycles and do the right thing.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

  parent reply	other threads:[~2025-01-15 15:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10 17:24 [PATCH v1] arm64: Add TLB Conflict Abort Exception handler to KVM Mikołaj Lenczewski
2025-01-10 18:49 ` Oliver Upton
2025-01-16 10:41   ` Mikołaj Lenczewski
2025-01-15 15:13 ` Marc Zyngier [this message]
2025-01-16 10:42   ` Mikołaj Lenczewski

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=865xmgw1n1.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=miko.lenczewski@arm.com \
    --cc=oliver.upton@linux.dev \
    --cc=ryan.roberts@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --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.