All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Exposing arm64 ID-register safe_rules semantics to userspace?
@ 2026-06-08  9:43 Khushit Shah
  2026-06-08 11:10 ` Marc Zyngier
  0 siblings, 1 reply; 4+ messages in thread
From: Khushit Shah @ 2026-06-08  9:43 UTC (permalink / raw)
  To: kvmarm@lists.linux.dev
  Cc: maz@kernel.org, oupton@kernel.org, eric.auger@redhat.com,
	cohuck@redhat.com, peter.maydell@linaro.org, qemu-arm@nongnu.org,
	Mark Cave-Ayland, Shaju Abraham

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,
- report blockers in QMP query-cpu-definitions for a given named
model,
- 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?

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?

Happy to prototype whichever direction maintainers prefer.

[1] https://lore.kernel.org/qemu-arm/20260605083358.1320563-1-khushit.shah@nutanix.com/T/#m71ce71d5a652edd205e2b5c200cb75292f57c0fc

Warm Regards,
Khushit

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-08 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08  9:43 [RFC] Exposing arm64 ID-register safe_rules semantics to userspace? Khushit Shah
2026-06-08 11:10 ` Marc Zyngier
2026-06-08 13:28   ` Khushit Shah
2026-06-08 14:08     ` Marc Zyngier

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.