All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Khushit Shah <khushit.shah@nutanix.com>
Cc: "kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
	"oupton@kernel.org" <oupton@kernel.org>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	Mark Cave-Ayland <mark.caveayland@nutanix.com>,
	Shaju Abraham <shaju.abraham@nutanix.com>
Subject: Re: [RFC] Exposing arm64 ID-register safe_rules semantics to userspace?
Date: Mon, 08 Jun 2026 12:10:14 +0100	[thread overview]
Message-ID: <86se6xthih.wl-maz@kernel.org> (raw)
In-Reply-To: <B5C9AE36-8181-4A76-905F-3E89B7200215@nutanix.com>

On Mon, 08 Jun 2026 10:43:11 +0100,
Khushit Shah <khushit.shah@nutanix.com> wrote:
> 
> Hi all,
> 
> On KVM_SET_ONE_REG for ID registers, KVM validates the requested
> field values against the host's values using the per-field rules
> in arm64_ftr_bits[](arch/arm64/kernel/cpufeature.c) (and, some
> KVM specific overrides on top);
>
> In our QEMU RFC for named ARM CPU models [1], we use the safe_rules to:
> - pre-validate a guest ID register configuration before KVM write back,

Pre-validate *how*?

> - report blockers in QMP query-cpu-definitions for a given named
> model,

Sorry, but I have no idea what this is.

> - enumerate supported values per field for QMP/libvirt/upper layers.
>
> RFC has a hand-maintained copy of safe_rules in QEMU that mirrors
> the kernel.
> 
> Any advice for VMMs on how to track the safe_rules used by KVM to
> validate ID-register field values written by userspace?

Why should the VMM care? Either a field is exposed as writable, and in
general it is safe to expose something "lower" than the host value to
the guest, or it isn't, and only that particular value is possible.

There is a few exceptions to this rule, but I expect this to be the
minority.

> 
> There is no API that exposes those rules to VMMs. Until a VMM issues
> KVM_SET_ONE_REG, it cannot know whether the requested set of values
> will be accepted. On failure, VMM still cannot know the faulting field.
>
> We'd like to know what the right approach is:
> - Should there be a KVM ioctl that exposes the safe_rules to
> userspace?
> Maybe Something like KVM_GET_SAFE_RULE (that takes reg_idx and
> start_bit_pos)
> or a bulk ioctl like KVM_GET_REG_SAFE_RULES (that returns (reg_idx,
> start_bit, width, safe_rule, safe_vals) for all the ID registers?
> - Is it acceptable to keep mirroring ftr_bits[] in userspace?
> - Or is this simply not meant to be exposed to userspace VMMs?

My question above still stands: why isn't knowing that a field is
writable or not, together with the max value of that field, enough to
decide what is possible to be set for that field?

Thanks,

	M.

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

  reply	other threads:[~2026-06-08 11:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08  9:43 [RFC] Exposing arm64 ID-register safe_rules semantics to userspace? Khushit Shah
2026-06-08 11:10 ` Marc Zyngier [this message]
2026-06-08 13:28   ` Khushit Shah
2026-06-08 14:08     ` 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=86se6xthih.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=cohuck@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=khushit.shah@nutanix.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=mark.caveayland@nutanix.com \
    --cc=oupton@kernel.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=shaju.abraham@nutanix.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.