[PATCH v6 09/33] arm64: Prepare sharing arm64 headers with s390
Marc Zyngier
maz at kernel.org
Thu Aug 13 03:14:09 PDT 2026
On Wed, 12 Aug 2026 16:36:05 +0100,
Steffen Eiden <seiden at linux.ibm.com> wrote:
[...]
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 46c8d7928b3f..22770c1132cb 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -56,6 +56,36 @@
> #define KVM_REQ_MAP_L1_VNCR_EL2 KVM_ARCH_REQ(10)
> #define KVM_REQ_VGIC_PROCESS_UPDATE KVM_ARCH_REQ(11)
>
> +/*
> + * If we encounter a data abort without valid instruction syndrome
> + * information, report this to user space. User space can (and
> + * should) opt in to this feature if KVM_CAP_ARM_NISV_TO_USER is
> + * supported.
> + */
> +#define KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER 0
> +/* Memory Tagging Extension enabled for the guest */
> +#define KVM_ARCH_FLAG_MTE_ENABLED 1
> +/* At least one vCPU has ran in the VM */
> +#define KVM_ARCH_FLAG_HAS_RAN_ONCE 2
> +/* The vCPU feature set for the VM is configured */
> +#define KVM_ARCH_FLAG_VCPU_FEATURES_CONFIGURED 3
> +/* PSCI SYSTEM_SUSPEND enabled for the guest */
> +#define KVM_ARCH_FLAG_SYSTEM_SUSPEND_ENABLED 4
> +/* VM counter offset */
> +#define KVM_ARCH_FLAG_VM_COUNTER_OFFSET 5
> +/* Timer PPIs made immutable */
> +#define KVM_ARCH_FLAG_TIMER_PPIS_IMMUTABLE 6
> +/* Initial ID reg values loaded */
> +#define KVM_ARCH_FLAG_ID_REGS_INITIALIZED 7
> +/* Fine-Grained UNDEF initialised */
> +#define KVM_ARCH_FLAG_FGU_INITIALIZED 8
> +/* SVE exposed to guest */
> +#define KVM_ARCH_FLAG_GUEST_HAS_SVE 9
> +/* MIDR_EL1, REVIDR_EL1, and AIDR_EL1 are writable from userspace */
> +#define KVM_ARCH_FLAG_WRITABLE_IMP_ID_REGS 10
> +/* Unhandled SEAs are taken to userspace */
> +#define KVM_ARCH_FLAG_EXIT_SEA 11
> +
I don't mind the move, but please add a comment indicating that these
are bit indices for for kvm_arch::flags, as we have now lost locality.
And whilst we're at it, there is not reason why this has to be a set
of #define, it can perfectly be an enum, as the numbers themselves
have no particular meaning. Something like the untested hack below.
M.
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 08b2f24dc3c79..402bbb5eb0d91 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -306,6 +306,39 @@ enum fgt_group_id {
__NR_FGT_GROUP_IDS__
};
+/* Bit indices for kvm_arch::flags */
+enum kvm_arch_flag_bits {
+ /*
+ * If we encounter a data abort without valid instruction syndrome
+ * information, report this to user space. User space can (and
+ * should) opt in to this feature if KVM_CAP_ARM_NISV_TO_USER is
+ * supported.
+ */
+ KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER,
+ /* Memory Tagging Extension enabled for the guest */
+ KVM_ARCH_FLAG_MTE_ENABLED,
+ /* At least one vCPU has ran in the VM */
+ KVM_ARCH_FLAG_HAS_RAN_ONCE,
+ /* The vCPU feature set for the VM is configured */
+ KVM_ARCH_FLAG_VCPU_FEATURES_CONFIGURED,
+ /* PSCI SYSTEM_SUSPEND enabled for the guest */
+ KVM_ARCH_FLAG_SYSTEM_SUSPEND_ENABLED,
+ /* VM counter offset */
+ KVM_ARCH_FLAG_VM_COUNTER_OFFSET,
+ /* Timer PPIs made immutable */
+ KVM_ARCH_FLAG_TIMER_PPIS_IMMUTABLE,
+ /* Initial ID reg values loaded */
+ KVM_ARCH_FLAG_ID_REGS_INITIALIZED,
+ /* Fine-Grained UNDEF initialised */
+ KVM_ARCH_FLAG_FGU_INITIALIZED,
+ /* SVE exposed to guest */
+ KVM_ARCH_FLAG_GUEST_HAS_SVE,
+ /* MIDR_EL1, REVIDR_EL1, and AIDR_EL1 are writable from userspace */
+ KVM_ARCH_FLAG_WRITABLE_IMP_ID_REGS,
+ /* Unhandled SEAs are taken to userspace */
+ KVM_ARCH_FLAG_EXIT_SEA,
+};
+
struct kvm_arch {
struct kvm_s2_mmu mmu;
@@ -338,35 +371,7 @@ struct kvm_arch {
/* Protects VM-scoped configuration data */
struct mutex config_lock;
- /*
- * If we encounter a data abort without valid instruction syndrome
- * information, report this to user space. User space can (and
- * should) opt in to this feature if KVM_CAP_ARM_NISV_TO_USER is
- * supported.
- */
-#define KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER 0
- /* Memory Tagging Extension enabled for the guest */
-#define KVM_ARCH_FLAG_MTE_ENABLED 1
- /* At least one vCPU has ran in the VM */
-#define KVM_ARCH_FLAG_HAS_RAN_ONCE 2
- /* The vCPU feature set for the VM is configured */
-#define KVM_ARCH_FLAG_VCPU_FEATURES_CONFIGURED 3
- /* PSCI SYSTEM_SUSPEND enabled for the guest */
-#define KVM_ARCH_FLAG_SYSTEM_SUSPEND_ENABLED 4
- /* VM counter offset */
-#define KVM_ARCH_FLAG_VM_COUNTER_OFFSET 5
- /* Timer PPIs made immutable */
-#define KVM_ARCH_FLAG_TIMER_PPIS_IMMUTABLE 6
- /* Initial ID reg values loaded */
-#define KVM_ARCH_FLAG_ID_REGS_INITIALIZED 7
- /* Fine-Grained UNDEF initialised */
-#define KVM_ARCH_FLAG_FGU_INITIALIZED 8
- /* SVE exposed to guest */
-#define KVM_ARCH_FLAG_GUEST_HAS_SVE 9
- /* MIDR_EL1, REVIDR_EL1, and AIDR_EL1 are writable from userspace */
-#define KVM_ARCH_FLAG_WRITABLE_IMP_ID_REGS 10
- /* Unhandled SEAs are taken to userspace */
-#define KVM_ARCH_FLAG_EXIT_SEA 11
+ /* VM-wide flags, described in kvm_arch_flag_bits */
unsigned long flags;
/* VM-wide vCPU feature set */
--
Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list