From: Mark Brown <broonie@kernel.org>
To: Dave Martin <Dave.Martin@arm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
Joey Gouly <joey.gouly@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Will Deacon <will@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org>,
Fuad Tabba <tabba@google.com>,
Mark Rutland <mark.rutland@arm.com>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
Eric Auger <eric.auger@redhat.com>
Subject: Re: [PATCH v8 11/29] KVM: arm64: Document the KVM ABI for SME
Date: Wed, 26 Nov 2025 18:41:39 +0000 [thread overview]
Message-ID: <8d27e309-15d7-47de-b51a-9f0e0bfa4766@sirena.org.uk> (raw)
In-Reply-To: <aScfSMZEKCeUq7Zn@e133380.arm.com>
[-- Attachment #1: Type: text/plain, Size: 5497 bytes --]
On Wed, Nov 26, 2025 at 05:23:47PM +0000, Dave Martin wrote:
> On Mon, Nov 24, 2025 at 08:12:56PM +0000, Mark Brown wrote:
> > On Mon, Nov 24, 2025 at 03:48:06PM +0000, Peter Maydell wrote:
> > > > .. [1] These encodings are not accepted for SVE-enabled vcpus. See
> > > > - :ref:`KVM_ARM_VCPU_INIT`.
> > > > + :ref:`KVM_ARM_VCPU_INIT`. They are also not accepted when SME is
> > > > + enabled without SVE and the vcpu is in streaming mode.
> > > Does this mean that on an SME-no-SVE VM the VMM needs to know
> > > if the vcpu is currently in streaming mode or not to determine
> > > whether to read the FP registers as fp_regs or sve regs? That
> > > seems unpleasant -- I was expecting this to be strictly a
> > > matter of how the VM was configured (as it is with SVE).
> > Yes, it does.
> Is the above condition right re streaming mode? The original reason
> for this restriction was that the SVE Z-regs and FPSIMD V-regs are
> aliases when SVE is present. To avoid having to worry about how to
> order register accesses and/or paste parts of them together, we went
> down the road of banishing encodings that alias a subset of the
> register state accessed by some other encoding.
I queried the issue with requiring that writes to the registers be done
in a specific order - we apparently have some other examples of this
already (I would need to go and check which specifically) so that was
seen as OK.
> In line with this principle, with SME Vn and Zn are aliases when
> *not* in streaming mode, so allowing access through the Vn view feels
> problematic too? (And when in streaming mode, the Vn regs don't exist
> at all.)
The ABI proposed here is that the V registers will only be available
with a VM that lacks SVE, you'll never have them both simultaneously but
rather which is available at any given moment will vary on a SME without
SVE VM. This obviously has complications, but aliasing is not one of
them.
Another option would be to represent the V registers as 128 bit Z
registers, giving you something similar to how they'd appear on a VM
with both SVE and SME for a SME only VM.
> Whether the proposed ABI is considered awkward for VMMs or not is a
> separate matter...)
Indeed.
> > > > + max_vq. This is the maximum vector length currently available to
> > > > + the guest on this vcpu, and determines which register slices are
> > > > + visible through this ioctl interface.
> >
> > > > + If SME is supported then the max_vq used for the Z and P registers
> > > > + while SVCR.SM is 1 this vector length will be the maximum SME
> > > > + vector length available for the guest, otherwise it will be the
> > > > + maximum SVE vector length available.
> The max_vq name here is not ABI; it's just linking concepts together in
> the documentation text.
> So, can we give explicitly different names to these two max_vq values?
We could call them sve_max_vq and sme_max_vq?
> Splitting the affected register descriptions into "SVCR.SM == 0" and
> "SVCR.SM == 1" cases also be helpful to make this special-casing clear.
Possibly I'm looking at the wrong thing here but the overall text for
describing the vector registers is relatively long so I worry that it'd
be harder for readers to play spot the difference if there was
duplication. I figured explicitly calling out the differences would be
clearer and less error prone in terms of any future updates.
> > This is attempting to say that the VL for the Z and P registers (and
> > FFR) will vary depending on if the vCPU is in streaming mode or not if
> > the maximum VL for SVE and SME differs, similarly to how the Z, P and
> > FFR registers disappear when we are not in streaming mode in a SME only
> > system.
> May flipping SVCR.SM through KVM_SET_ONE_REG have the architectural
> effect of zeroing the vector regs? That feels like something that
> should be stated explicitly.
Yes, it should zero them - I'll find some place/way to add that.
> I'd agree that this mutating interface feels odd, and does not follow
> the original spirit of the design here.
> But the SME architecture doesn't fit well with the spirit of the
> original KVM ABI here either, so I guess there won't be a perfect
> solution.
Something's going to be awkward somewhere.
> It seems that when SME is enabled in the vCPU features and the VMM is
> planning to dump or set affected registers, there is a requirement to
> dump / set SVCR.SM first, and then go down one of two code paths. Can
> this be called out explicitly? This is a departure from the the
> previous interaction model, so it probably deserves its own section,
> which can then be cross-referenced from individual reg
> descriptions.
> SVCR.SM exhibits this modality w.r.t a specific set of affected
> register encodings; it would be good to have that captured clearly in
> one place.
As I said above my understanding is that this is not actually a
departure from the current stituation, this not being noticed probably
highlights why it'd be good to improve the documentation here! I think
grouping all behaviours like this together would be good from a
usability point of view. I don't know how much of that that fits
directly in the ABI document or in a separate "here's some gotchas" type
document, things are already getting a bit difficult to manage.
Possibly both.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-11-26 18:41 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 11:36 [PATCH v8 00/29] KVM: arm64: Implement support for SME Mark Brown
2025-09-02 11:36 ` [PATCH v8 01/29] arm64/sysreg: Update SMIDR_EL1 to DDI0601 2025-06 Mark Brown
2025-09-02 11:36 ` [PATCH v8 02/29] arm64/fpsimd: Update FA64 and ZT0 enables when loading SME state Mark Brown
2025-09-02 11:36 ` [PATCH v8 03/29] arm64/fpsimd: Decide to save ZT0 and streaming mode FFR at bind time Mark Brown
2025-09-02 11:36 ` [PATCH v8 04/29] arm64/fpsimd: Check enable bit for FA64 when saving EFI state Mark Brown
2025-09-02 11:36 ` [PATCH v8 05/29] arm64/fpsimd: Determine maximum virtualisable SME vector length Mark Brown
2025-09-02 11:36 ` [PATCH v8 06/29] KVM: arm64: Introduce non-UNDEF FGT control Mark Brown
2025-09-19 15:14 ` Marc Zyngier
2025-09-19 15:53 ` Mark Brown
2025-09-02 11:36 ` [PATCH v8 07/29] KVM: arm64: Pay attention to FFR parameter in SVE save and load Mark Brown
2025-09-02 11:36 ` [PATCH v8 08/29] KVM: arm64: Pull ctxt_has_ helpers to start of sysreg-sr.h Mark Brown
2025-09-02 11:36 ` [PATCH v8 09/29] KVM: arm64: Move SVE state access macros after feature test macros Mark Brown
2025-09-02 11:36 ` [PATCH v8 10/29] KVM: arm64: Rename SVE finalization constants to be more general Mark Brown
2025-09-02 11:36 ` [PATCH v8 11/29] KVM: arm64: Document the KVM ABI for SME Mark Brown
2025-11-24 15:48 ` Peter Maydell
2025-11-24 20:12 ` Mark Brown
2025-11-26 17:23 ` Dave Martin
2025-11-26 18:41 ` Mark Brown [this message]
2025-11-27 15:06 ` Peter Maydell
2025-11-27 15:47 ` Mark Brown
2025-09-02 11:36 ` [PATCH v8 12/29] KVM: arm64: Define internal features " Mark Brown
2025-09-02 11:36 ` [PATCH v8 13/29] KVM: arm64: Rename sve_state_reg_region Mark Brown
2025-09-02 11:36 ` [PATCH v8 14/29] KVM: arm64: Store vector lengths in an array Mark Brown
2025-09-02 11:36 ` [PATCH v8 15/29] KVM: arm64: Implement SME vector length configuration Mark Brown
2025-09-02 11:36 ` [PATCH v8 16/29] KVM: arm64: Support SME control registers Mark Brown
2025-09-02 11:36 ` [PATCH v8 17/29] KVM: arm64: Support TPIDR2_EL0 Mark Brown
2025-09-02 11:36 ` [PATCH v8 18/29] KVM: arm64: Support SME identification registers for guests Mark Brown
2025-09-02 11:36 ` [PATCH v8 19/29] KVM: arm64: Support SME priority registers Mark Brown
2025-09-02 11:36 ` [PATCH v8 20/29] KVM: arm64: Provide assembly for SME register access Mark Brown
2025-09-02 11:36 ` [PATCH v8 21/29] KVM: arm64: Support userspace access to streaming mode Z and P registers Mark Brown
2025-09-02 11:36 ` [PATCH v8 22/29] KVM: arm64: Flush register state on writes to SVCR.SM and SVCR.ZA Mark Brown
2025-09-02 11:36 ` [PATCH v8 23/29] KVM: arm64: Expose SME specific state to userspace Mark Brown
2025-09-02 11:36 ` [PATCH v8 24/29] KVM: arm64: Context switch SME state for guests Mark Brown
2025-09-02 11:36 ` [PATCH v8 25/29] KVM: arm64: Handle SME exceptions Mark Brown
2025-09-02 11:36 ` [PATCH v8 26/29] KVM: arm64: Expose SME to nested guests Mark Brown
2025-09-02 11:36 ` [PATCH v8 27/29] KVM: arm64: Provide interface for configuring and enabling SME for guests Mark Brown
2025-09-02 11:36 ` [PATCH v8 28/29] KVM: arm64: selftests: Add SME system registers to get-reg-list Mark Brown
2025-09-02 11:36 ` [PATCH v8 29/29] KVM: arm64: selftests: Add SME to set_id_regs test Mark Brown
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=8d27e309-15d7-47de-b51a-9f0e0bfa4766@sirena.org.uk \
--to=broonie@kernel.org \
--cc=Dave.Martin@arm.com \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=eric.auger@redhat.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.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).