From: Mark Rutland <mark.rutland@arm.com>
To: Marc Zyngier <maz@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, broonie@kernel.org,
catalin.marinas@arm.com, eauger@redhat.com, fweimer@redhat.com,
jeremy.linton@arm.com, oliver.upton@linux.dev,
pbonzini@redhat.com, stable@vger.kernel.org, tabba@google.com,
wilco.dijkstra@arm.com, will@kernel.org
Subject: Re: [PATCH 8/8] KVM: arm64: Eagerly switch ZCR_EL{1,2}
Date: Thu, 6 Feb 2025 10:28:35 +0000 [thread overview]
Message-ID: <Z6SO0x-T4QRT31Y_@J2N7QTR9R3> (raw)
In-Reply-To: <861pwdvbd3.wl-maz@kernel.org>
On Tue, Feb 04, 2025 at 06:00:24PM +0000, Marc Zyngier wrote:
> On Tue, 04 Feb 2025 15:21:00 +0000,
> Mark Rutland <mark.rutland@arm.com> wrote:
> > +static inline void fpsimd_lazy_switch_to_guest(struct kvm_vcpu *vcpu)
> > +{
> > + u64 zcr_el1, zcr_el2;
> > +
> > + if (!guest_owns_fp_regs())
> > + return;
> > +
> > + if (vcpu_has_sve(vcpu)) {
> > + /* A guest hypervisor may restrict the effective max VL. */
> > + if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu))
> > + zcr_el2 = __vcpu_sys_reg(vcpu, ZCR_EL2);
> > + else
> > + zcr_el2 = vcpu_sve_max_vq(vcpu) - 1;
> > +
> > + sve_cond_update_zcr_vq(zcr_el2, SYS_ZCR_EL2);
>
> Not a big deal, but I though I'd mention it here: Using ZCR_EL2 (or
> any other register using the _EL2 suffix) is a source of expensive
> traps with NV. We're much better off using the _EL1 accessor if we are
> running VHE, as this will involve no trap at all.
>
> nVHE will of course trap, but using nVHE with SVE under NV is not
> something I'm prepared to give a damn about.
Ah, sorry. I had forgotten that wrinkle.
Given the compiler warnings reported by Mark Brown [1] and the kernel
test robot [2], I'll go spin a v2 with that cleaned up.
I'll use write_sysreg_el2() here, i.e.
if (vcpu_has_sve(vcpu)) {
/* A guest hypervisor may restrict the effective max VL. */
if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu))
zcr_el2 = __vcpu_sys_reg(vcpu, ZCR_EL2);
else
zcr_el2 = vcpu_sve_max_vq(vcpu) - 1;
write_sysreg_el2(scr_el2, SYS_ZCR);
}
That'll use the preferred alias automatically, and it matches the style
used to write to ZCR_EL{1,12} immediately after.
Likewise for the other instances.
Mark.
[1] https://lore.kernel.org/linux-arm-kernel/b76803b7-c1b3-426b-a375-0c01b98142c9@sirena.org.uk/
[2] https://lore.kernel.org/oe-kbuild-all/202502061341.FvsCMKEH-lkp@intel.com/
prev parent reply other threads:[~2025-02-06 10:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-04 15:20 [PATCH 0/8] KVM: arm64: FPSIMD/SVE/SME fixes Mark Rutland
2025-02-04 15:20 ` [PATCH 1/8] KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state Mark Rutland
2025-02-04 15:56 ` Mark Brown
2025-02-05 12:31 ` Eric Auger
2025-02-04 15:20 ` [PATCH 2/8] KVM: arm64: Remove host FPSIMD saving for non-protected KVM Mark Rutland
2025-02-04 16:55 ` Mark Brown
2025-02-04 15:20 ` [PATCH 3/8] KVM: arm64: Remove VHE host restore of CPACR_EL1.ZEN Mark Rutland
2025-02-04 17:20 ` Mark Brown
2025-02-04 15:20 ` [PATCH 4/8] KVM: arm64: Remove VHE host restore of CPACR_EL1.SMEN Mark Rutland
2025-02-04 17:23 ` Mark Brown
2025-02-04 15:20 ` [PATCH 5/8] KVM: arm64: Refactor CPTR trap deactivation Mark Rutland
2025-02-04 15:20 ` [PATCH 6/8] KVM: arm64: Refactor exit handlers Mark Rutland
2025-02-04 15:20 ` [PATCH 7/8] KVM: arm64: Mark some header functions as inline Mark Rutland
2025-02-04 18:17 ` Mark Brown
2025-02-05 21:50 ` Mark Brown
2025-02-06 10:01 ` Mark Rutland
2025-02-06 10:03 ` Mark Rutland
2025-02-06 10:42 ` Marc Zyngier
2025-02-06 10:55 ` Mark Rutland
2025-02-06 12:28 ` Marc Zyngier
2025-02-06 13:32 ` Mark Rutland
2025-02-04 15:21 ` [PATCH 8/8] KVM: arm64: Eagerly switch ZCR_EL{1,2} Mark Rutland
2025-02-04 18:00 ` Marc Zyngier
2025-02-06 10:28 ` Mark Rutland [this message]
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=Z6SO0x-T4QRT31Y_@J2N7QTR9R3 \
--to=mark.rutland@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=eauger@redhat.com \
--cc=fweimer@redhat.com \
--cc=jeremy.linton@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tabba@google.com \
--cc=wilco.dijkstra@arm.com \
--cc=will@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).