Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Fuad Tabba <tabba@google.com>
Cc: sashiko-reviews@lists.linux.dev, Oliver Upton <oupton@kernel.org>,
	kvmarm@lists.linux.dev
Subject: Re: [PATCH 4/7] KVM: arm64: Set IL for injected FPAC exceptions during ERET emulation
Date: Wed, 17 Jun 2026 15:34:48 +0100	[thread overview]
Message-ID: <86v7bhs0af.wl-maz@kernel.org> (raw)
In-Reply-To: <CA+EHjTzWpLBxy=Pi=K0G-9JU0cPTsGSNB4Esy+K+vFYNM0DnNw@mail.gmail.com>

On Wed, 17 Jun 2026 13:39:14 +0100,
Fuad Tabba <tabba@google.com> wrote:
> 
> On Wed, 17 Jun 2026 at 13:36, Marc Zyngier <maz@kernel.org> wrote:
> >
> > On Mon, 15 Jun 2026 13:42:23 +0100,
> > Fuad Tabba <tabba@google.com> wrote:
> > >
> > > On Sun, 14 Jun 2026 at 17:45, <sashiko-bot@kernel.org> wrote:
> > > >
> > > One thing I noticed while looking at this:
> > > kvm_check_illegal_exception_return() preserves {N,Z,C,V,D,A,I,F} from
> > > the current PSTATE, but the Arm ARM says these should come from
> > > SPSR_ELx on an illegal exception return (EL and SP are unchanged, but
> > > the flags and masks are taken from SPSR). PAN and ALLINT should also
> > > come from SPSR_ELx if their respective features are implemented.
> > >
> > > Marc, is the current behavior intentional, or should we be
> > > constructing PSTATE from the original SPSR_EL2 for those fields?
> >
> > This looks like a long standing bug for something we really never
> > tested. I reckon the patch below would do the trick.
> >
> >         M.
> >
> > +++ b/arch/arm64/kvm/emulate-nested.c
> > @@ -2746,17 +2746,29 @@ static u64 kvm_check_illegal_exception_return(struct kvm_vcpu *vcpu, u64 spsr)
> >             (spsr & PSR_MODE32_BIT) ||
> >             (vcpu_el2_tge_is_set(vcpu) && (mode == PSR_MODE_EL1t ||
> >                                            mode == PSR_MODE_EL1h))) {
> > +               u64 mask;
> > +
> >                 /*
> >                  * The guest is playing with our nerves. Preserve EL, SP,
> > -                * masks, flags from the existing PSTATE, and set IL.
> > -                * The HW will then generate an Illegal State Exception
> > -                * immediately after ERET.
> > +                * masks, flags from the existing SPSR, and set IL (see
> > +                * R_VWJHB). The HW will then generate an Illegal State
> > +                * Exception immediately after ERET.
> >                  */
> > -               spsr = *vcpu_cpsr(vcpu);
> > -
> > -               spsr &= (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT |
> > +               mask  = (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT |
> >                          PSR_N_BIT | PSR_Z_BIT | PSR_C_BIT | PSR_V_BIT |
> >                          PSR_MODE_MASK | PSR_MODE32_BIT);
> > +
> > +               if (kvm_has_feat(vcpu->kvm, ID_AA64MMFR1_EL1, PAN, IMP))
> > +                       mask |= PSR_PAN_BIT;
> > +               if (kvm_has_feat(vcpu->kvm, ID_AA64PFR1_EL1, NMI, IMP))
> > +                       mask |= ALLINT_ALLINT;
> > +               /* Account for FEAT_SPE_EXC and FEAT_TRBE_EXC one day... */
> > +               if (kvm_has_feat(vcpu->kvm, ID_AA64DFR1_EL1, EBEP, IMP))
> > +                       mask |= BIT_ULL(32);
> > +               if (kvm_has_feat(vcpu->kvm, ID_AA64PFR1_EL1, GCS, IMP))
> > +                       mask |= BIT_ULL(34);
> > +
> > +               spsr &= mask;
> 
> I'm on it...

Sorry, in what sense?

	M.

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

  reply	other threads:[~2026-06-17 14:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-14 16:33 [PATCH 0/7] KVM: arm64: Fix missing ESR_ELx.IL in syndrome injection Fuad Tabba
2026-06-14 16:33 ` [PATCH 1/7] KVM: arm64: Set ESR_ELx.IL for injected undefined exceptions at EL2 Fuad Tabba
2026-06-14 16:33 ` [PATCH 2/7] KVM: arm64: Unconditionally set IL for injected undefined exceptions Fuad Tabba
2026-06-14 16:33 ` [PATCH 3/7] KVM: arm64: Unconditionally set IL for injected abort exceptions Fuad Tabba
2026-06-14 16:33 ` [PATCH 4/7] KVM: arm64: Set IL for injected FPAC exceptions during ERET emulation Fuad Tabba
2026-06-14 16:45   ` sashiko-bot
2026-06-15 12:42     ` Fuad Tabba
2026-06-17 12:36       ` Marc Zyngier
2026-06-17 12:39         ` Fuad Tabba
2026-06-17 14:34           ` Marc Zyngier [this message]
2026-06-17 14:51             ` Fuad Tabba
2026-06-18  7:59   ` Marc Zyngier
2026-06-18  8:18     ` Fuad Tabba
2026-06-14 16:33 ` [PATCH 5/7] KVM: arm64: Set IL for emulated SError injection Fuad Tabba
2026-06-14 16:46   ` sashiko-bot
2026-06-15 12:48     ` Fuad Tabba
2026-06-14 16:33 ` [PATCH 6/7] KVM: arm64: Set IL for nested " Fuad Tabba
2026-06-14 16:44   ` sashiko-bot
2026-06-15  4:46     ` Oliver Upton
2026-06-15 13:12       ` Fuad Tabba
2026-06-14 16:33 ` [PATCH 7/7] KVM: arm64: Set IL in fake ESR for pKVM memory sharing exit Fuad Tabba

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=86v7bhs0af.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tabba@google.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