Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>, Fuad Tabba <fuad.tabba@linux.dev>
Cc: Will Deacon <will@kernel.org>,
	Ard Biesheuvel <ardb+git@google.com>,
	kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	Oliver Upton <oupton@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH] KVM: arm64: Don't livelock when AT can't resolve a fault IPA
Date: Mon, 02 Nov 2026 16:52:48 +0000	[thread overview]
Message-ID: <86bj872n1b.wl-maz@kernel.org> (raw)
In-Reply-To: <CA+EHjTxVPyY70Dm+BiwgQQNwx1cJpEKvJBJGZWPCKLx2M8X2FA@mail.gmail.com>

On Mon, 02 Nov 2026 15:57:51 +0000,
Fuad Tabba <fuad.tabba@linux.dev> wrote:
> 
> Hi Will,
> 
> On Mon, 02 Nov 2026 14:17:10 +0000, Will Deacon <will@kernel.org> wrote:
> > On Mon, Nov 02, 2026 at 02:09:25PM +0000, Marc Zyngier wrote:
> > > On Mon, 02 Nov 2026 13:59:12 +0000,
> > > Will Deacon <will@kernel.org> wrote:
> [...]
> > > > > diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h
> [...]
> > > > >  static inline bool kvm_hyp_handle_memory_fault(struct kvm_vcpu *vcpu,
> > > > >                                                 u64 *exit_code)
> > > > >  {
> > > > > -        if (!__populate_fault_info(vcpu))
> > > > > +        if (!__populate_fault_info(vcpu)) {
> > > >
> > > > Presumably we need a barrier (DSB?) here, to ensure that the TLBI happens
> > > > after the AT instruction?
> 
> I don't think the TLBI requires a barrier before it, because it
> doesn't matter if the AT's walk allocates entries after the TLBI.
> Anything it allocates matches memory, and the stage-2 descriptor the
> AT faulted on has AF clear, so that descriptor can't be cached:
> 
> R_XCLRD: Translation table entries that generate a Translation
> fault, an Address size fault, or an Access flag fault are never cached
> in a TLB.
> 
> The stale entries the guest keeps hitting were already there before
> the TLBI, and the dsb(nsh) and isb after it are what complete it
> against them.
> 
> [... your other reply ... ]
> > > Alternatively, VMALLE1 or even VAE1 should be enough to get rid of the
> > > S1 TLB.
> >
> > Ah, sorry, VMALLE1 is what I meant to ask about. I basically haven't
> > understood the need to invalidate the stage-2.
> 
> The guest's walk can also go through a stage-2 entry for its
> page-table page, cached before the aging cleared that page's AF, and
> nothing requires the AT to use that entry:
> 
> R_NPZWX: When an address translation instruction is executed, it is
> IMPLEMENTATION DEFINED whether the result can be returned from a TLB,
> or a translation table walk occurs.
> 
> So if my reading is correct, on a CPU whose AT walks memory instead,
> the AT keeps failing while the guest's walk goes through the stale
> entry, and the guest takes the same permission fault again. VMALLE1
> and VAE1 only cover stage 1, so they'd leave that loop in place.

If we assume that the TLB covers VA->PA (which is a very likely case),
TLBI VAE1 should nuke the permission fault that brought the vcpu to
EL2, and instead walk the page tables, getting the access fault.

The only case I can imagine where invalidating S2 would matter is if
you are running under NV, because there is an independent S2 TLB (the
shadow S2), and then VMALLS12E1 makes total sense.

Ard, was this solely observed under NV? Or did you see it on a non NV
guest as well?

Thanks,

	M.

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


  parent reply	other threads:[~2026-11-02 16:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  9:47 [PATCH] KVM: arm64: Don't livelock when AT can't resolve a fault IPA Ard Biesheuvel
2026-11-02 12:19 ` Fuad Tabba
2026-11-02 13:59 ` Will Deacon
2026-11-02 14:09   ` Marc Zyngier
2026-11-02 14:17     ` Will Deacon
2026-11-02 15:57   ` Fuad Tabba
2026-11-02 16:12     ` Ard Biesheuvel
2026-11-02 16:52     ` Marc Zyngier [this message]
2026-11-02 18:23       ` Ard Biesheuvel
2026-11-02 18:41         ` Marc Zyngier
2026-11-02 19:49           ` Will Deacon
2026-11-02 19:27     ` Will Deacon
2026-11-02 14:16 ` 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=86bj872n1b.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=oupton@kernel.org \
    --cc=seiden@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox