Re: [RFC v1 01/25] linux-headers: Add RME related definitions
On Fri, Jul 10, 2026 at 11:09:43AM +1000, Gavin Shan wrote:
> On 7/8/26 8:42 AM, Mathieu Poirier wrote:
> > From: Jean-Philippe Brucker
> >
> > This is a temporary patch intended for testing purposes only. It provides
> > definitions related to supporting Realms by the QEMU-VMM.
> >
> > Signed-off-by: Jean-Philippe Brucker
> > Signed-off-by: Mathieu Poirier
> > ---
> > linux-headers/asm-arm64/kvm.h | 9 +
> > linux-headers/linux/kvm.h | 21 +
> > 2 files changed, 26 insertions(+), 4 deletions(-)
> >
> > diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
> > index 6aefe7973814..4c08631ec7d2 100644
> > --- a/linux-headers/asm-arm64/kvm.h
> > +++ b/linux-headers/asm-arm64/kvm.h
> > @@ -208,6 +208,15 @@ struct kvm_arm_counter_offset {
> > __u64 reserved;
> > };
> > +#define KVM_ARM_RMI_POPULATE_FLAGS_MEASURE (1 << 0)
> > +struct kvm_arm_rmi_populate {
> > + __u64 base;
> > + __u64 size;
> > + __u64 source_uaddr;
> > + __u32 flags;
> > + __u32 reserved;
> > +};
> > +
> > #define KVM_ARM_TAGS_TO_GUEST 0
> > #define KVM_ARM_TAGS_FROM_GUEST 1
> > diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> > index 50e87ed72c20..dae6e5ba8457 100644
> > --- a/linux-headers/linux/kvm.h
> > +++ b/linux-headers/linux/kvm.h
> > @@ -685,11 +685,21 @@ struct kvm_enable_cap {
> > #define KVM_S390_SIE_PAGE_OFFSET 1
> > /*
> > - * On arm64, machine type can be used to request the physical
> > - * address size for the VM. Bits[7-0] are reserved for the guest
> > - * PA size shift (i.e, log2(PA_Size)). For backward compatibility,
> > - * value 0 implies the default IPA size, 40bits.
> > + * On arm64, machine type can be used to request both the machine type and
> > + * the physical address size for the VM.
> > + *
> > + * Bits[31-30] are reserved for the ARM specific machine type.
> > + *
> > + * Bits[7-0] are reserved for the guest PA size shift (i.e, log2(PA_Size)).
> > + * For backward compatibility, value 0 implies the default IPA size,
> > 40bits.
> >*/
> > +#define KVM_VM_TYPE_ARM_SHIFT 30
> > +#define KVM_VM_TYPE_ARM_MASK (0x3ULL <<
> > KVM_VM_TYPE_ARM_SHIFT)
> > +#define KVM_VM_TYPE_ARM(_type) \
> > + (((_type) << KVM_VM_TYPE_ARM_SHIFT) & KVM_VM_TYPE_ARM_MASK)
> > +#define KVM_VM_TYPE_ARM_NORMAL KVM_VM_TYPE_ARM(0)
> > +#define KVM_VM_TYPE_ARM_REALM KVM_VM_TYPE_ARM(1)
> > +
> > #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL
> > #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \
> > ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
>
> The definitions in this section aren't exactly same to that in (v14) host
> series,
> leading to KVM_VM_TYPE_ARM_REALM = 0 in my environment and the realm guest
> can't
> be started with the following error message. At least, KVM_VM_TYPE_ARM_MASK
> has
> been redefined with different values.
>
> qemu-system-aarch64: KVM does not support guest_memfd
I agree with you. Although outdated the above should work - left shifting
0x3ULL by 30 seems to be causing issues.
>
> > linux-headers/linux/kvm.h
>
> #define KVM_VM_TYPE_ARM_SHIFT 30
> #define KVM_VM_TYPE_ARM_MASK (0x3ULL << KVM_VM_TYPE_ARM_SHIFT)
>
> #define KVM_VM_TYPE_ARM_MASK (KVM_VM_TYPE_ARM_IPA_SIZE_MASK | \
> KVM_VM_TYPE_ARM_PROTECTED)
>
> After syncing the definitions with those in (v14) host series, I'm able to
> boot
> a simple realm guest (no virtio devices) with one warning.
>
> qemu-system-aarch64: Failed to enable KVM_CAP_ARM_NISV_TO_USER cap
Right, that one is useless.
Both issues reported here will be addressed in the next revision.
>
> Thanks,
> Gavin
>
> > @@ -719,6 +729,8 @@ struct kvm_enable_cap {
> > #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
> > #define KVM_GET_MSR_FEATURE_INDEX_LIST_IOWR(KVMIO, 0x0a, struct
> > kvm_msr_list)
> > +#define KVM_ARM_RMI_POPULATE _IOWR(KVMIO, 0xd7, struct
> > kvm_arm_rmi_populate)
> > +
> > /*
> >* Extension capability list.
> >*/
> > @@ -985,6 +997,7 @@ struct kvm_enable_cap {
> > #define KVM_CAP_S390_USER_OPEREXEC 246
> > #define KVM_CAP_S390_KEYOP 247
> > #define KVM_CAP_S390_VSIE_ESAMODE 248
> > +#define KVM_CAP_ARM_RMI 249
> > struct kvm_irq_routing_irqchip {
> > __u32 irqchip;
>
Re: [RFC v1 01/25] linux-headers: Add RME related definitions
On 7/10/26 8:46 PM, Lorenzo Pieralisi wrote:
On Fri, Jul 10, 2026 at 11:09:43AM +1000, Gavin Shan wrote:
[...]
After syncing the definitions with those in (v14) host series, I'm able to boot
a simple realm guest (no virtio devices) with one warning.
qemu-system-aarch64: Failed to enable KVM_CAP_ARM_NISV_TO_USER cap
That's because we need to use the VM instance specific check extension
rather than the global one before trying to enable the cap.
It is harmless.
Yes, the capability KVM_CAP_ARM_NISV_TO_USER has been hidden from realm guest
in the (v14) host series. With the following changes applied on the top, the
warning is avoided, I think the changes need to be integrated to [RFC v1 08/25]
target/arm/kvm: Use kvm_vm_check_extension() where necessary.
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 3d5e16a21c..4c52ee7e1b 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -623,7 +623,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
return -EINVAL;
}
-if (kvm_check_extension(s, KVM_CAP_ARM_NISV_TO_USER)) {
+if (kvm_vm_check_extension(s, KVM_CAP_ARM_NISV_TO_USER)) {
if (kvm_vm_enable_cap(s, KVM_CAP_ARM_NISV_TO_USER, 0)) {
error_report("Failed to enable KVM_CAP_ARM_NISV_TO_USER cap");
} else {
Besides, I think it's known issue that 'reboot' doesn't work.
Welcome to Buildroot
buildroot login: root
root@guest:~# reboot
:
qemu-system-aarch64: cpus are not resettable, terminating
Thanks,
Gavin
Lorenzo
Re: [RFC v1 01/25] linux-headers: Add RME related definitions
On Fri, Jul 10, 2026 at 11:09:43AM +1000, Gavin Shan wrote: [...] > After syncing the definitions with those in (v14) host series, I'm able to > boot > a simple realm guest (no virtio devices) with one warning. > > qemu-system-aarch64: Failed to enable KVM_CAP_ARM_NISV_TO_USER cap That's because we need to use the VM instance specific check extension rather than the global one before trying to enable the cap. It is harmless. Lorenzo
Re: [RFC v1 01/25] linux-headers: Add RME related definitions
On Fri, Jul 10, 2026 at 11:09:43AM +1000, Gavin Shan wrote:
> On 7/8/26 8:42 AM, Mathieu Poirier wrote:
> > From: Jean-Philippe Brucker
> >
> > This is a temporary patch intended for testing purposes only. It provides
> > definitions related to supporting Realms by the QEMU-VMM.
> >
> > Signed-off-by: Jean-Philippe Brucker
> > Signed-off-by: Mathieu Poirier
> > ---
> > linux-headers/asm-arm64/kvm.h | 9 +
> > linux-headers/linux/kvm.h | 21 +
> > 2 files changed, 26 insertions(+), 4 deletions(-)
> >
> > diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
> > index 6aefe7973814..4c08631ec7d2 100644
> > --- a/linux-headers/asm-arm64/kvm.h
> > +++ b/linux-headers/asm-arm64/kvm.h
> > @@ -208,6 +208,15 @@ struct kvm_arm_counter_offset {
> > __u64 reserved;
> > };
> > +#define KVM_ARM_RMI_POPULATE_FLAGS_MEASURE (1 << 0)
> > +struct kvm_arm_rmi_populate {
> > + __u64 base;
> > + __u64 size;
> > + __u64 source_uaddr;
> > + __u32 flags;
> > + __u32 reserved;
> > +};
> > +
> > #define KVM_ARM_TAGS_TO_GUEST 0
> > #define KVM_ARM_TAGS_FROM_GUEST 1
> > diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> > index 50e87ed72c20..dae6e5ba8457 100644
> > --- a/linux-headers/linux/kvm.h
> > +++ b/linux-headers/linux/kvm.h
> > @@ -685,11 +685,21 @@ struct kvm_enable_cap {
> > #define KVM_S390_SIE_PAGE_OFFSET 1
> > /*
> > - * On arm64, machine type can be used to request the physical
> > - * address size for the VM. Bits[7-0] are reserved for the guest
> > - * PA size shift (i.e, log2(PA_Size)). For backward compatibility,
> > - * value 0 implies the default IPA size, 40bits.
> > + * On arm64, machine type can be used to request both the machine type and
> > + * the physical address size for the VM.
> > + *
> > + * Bits[31-30] are reserved for the ARM specific machine type.
> > + *
> > + * Bits[7-0] are reserved for the guest PA size shift (i.e, log2(PA_Size)).
> > + * For backward compatibility, value 0 implies the default IPA size,
> > 40bits.
> >*/
> > +#define KVM_VM_TYPE_ARM_SHIFT 30
> > +#define KVM_VM_TYPE_ARM_MASK (0x3ULL <<
> > KVM_VM_TYPE_ARM_SHIFT)
> > +#define KVM_VM_TYPE_ARM(_type) \
> > + (((_type) << KVM_VM_TYPE_ARM_SHIFT) & KVM_VM_TYPE_ARM_MASK)
> > +#define KVM_VM_TYPE_ARM_NORMAL KVM_VM_TYPE_ARM(0)
> > +#define KVM_VM_TYPE_ARM_REALM KVM_VM_TYPE_ARM(1)
> > +
> > #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL
> > #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \
> > ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
>
> The definitions in this section aren't exactly same to that in (v14) host
> series,
> leading to KVM_VM_TYPE_ARM_REALM = 0 in my environment and the realm guest
> can't
> be started with the following error message. At least, KVM_VM_TYPE_ARM_MASK
> has
> been redefined with different values.
>
> qemu-system-aarch64: KVM does not support guest_memfd
>
> > linux-headers/linux/kvm.h
>
> #define KVM_VM_TYPE_ARM_SHIFT 30
> #define KVM_VM_TYPE_ARM_MASK (0x3ULL << KVM_VM_TYPE_ARM_SHIFT)
>
> #define KVM_VM_TYPE_ARM_MASK (KVM_VM_TYPE_ARM_IPA_SIZE_MASK | \
> KVM_VM_TYPE_ARM_PROTECTED)
>
> After syncing the definitions with those in (v14) host series, I'm able to
> boot
> a simple realm guest (no virtio devices) with one warning.
>
> qemu-system-aarch64: Failed to enable KVM_CAP_ARM_NISV_TO_USER cap
Yep, that's correct the VM type handling has to be updated and I am looking
into the cap failure.
Thanks,
Lorenzo
> Thanks,
> Gavin
>
> > @@ -719,6 +729,8 @@ struct kvm_enable_cap {
> > #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
> > #define KVM_GET_MSR_FEATURE_INDEX_LIST_IOWR(KVMIO, 0x0a, struct
> > kvm_msr_list)
> > +#define KVM_ARM_RMI_POPULATE _IOWR(KVMIO, 0xd7, struct
> > kvm_arm_rmi_populate)
> > +
> > /*
> >* Extension capability list.
> >*/
> > @@ -985,6 +997,7 @@ struct kvm_enable_cap {
> > #define KVM_CAP_S390_USER_OPEREXEC 246
> > #define KVM_CAP_S390_KEYOP 247
> > #define KVM_CAP_S390_VSIE_ESAMODE 248
> > +#define KVM_CAP_ARM_RMI 249
> > struct kvm_irq_routing_irqchip {
> > __u32 irqchip;
>
Re: [RFC v1 01/25] linux-headers: Add RME related definitions
On 7/8/26 8:42 AM, Mathieu Poirier wrote:
From: Jean-Philippe Brucker
This is a temporary patch intended for testing purposes only. It provides
definitions related to supporting Realms by the QEMU-VMM.
Signed-off-by: Jean-Philippe Brucker
Signed-off-by: Mathieu Poirier
---
linux-headers/asm-arm64/kvm.h | 9 +
linux-headers/linux/kvm.h | 21 +
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index 6aefe7973814..4c08631ec7d2 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -208,6 +208,15 @@ struct kvm_arm_counter_offset {
__u64 reserved;
};
+#define KVM_ARM_RMI_POPULATE_FLAGS_MEASURE (1 << 0)
+struct kvm_arm_rmi_populate {
+ __u64 base;
+ __u64 size;
+ __u64 source_uaddr;
+ __u32 flags;
+ __u32 reserved;
+};
+
#define KVM_ARM_TAGS_TO_GUEST 0
#define KVM_ARM_TAGS_FROM_GUEST 1
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 50e87ed72c20..dae6e5ba8457 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -685,11 +685,21 @@ struct kvm_enable_cap {
#define KVM_S390_SIE_PAGE_OFFSET 1
/*
- * On arm64, machine type can be used to request the physical
- * address size for the VM. Bits[7-0] are reserved for the guest
- * PA size shift (i.e, log2(PA_Size)). For backward compatibility,
- * value 0 implies the default IPA size, 40bits.
+ * On arm64, machine type can be used to request both the machine type and
+ * the physical address size for the VM.
+ *
+ * Bits[31-30] are reserved for the ARM specific machine type.
+ *
+ * Bits[7-0] are reserved for the guest PA size shift (i.e, log2(PA_Size)).
+ * For backward compatibility, value 0 implies the default IPA size, 40bits.
*/
+#define KVM_VM_TYPE_ARM_SHIFT 30
+#define KVM_VM_TYPE_ARM_MASK (0x3ULL << KVM_VM_TYPE_ARM_SHIFT)
+#define KVM_VM_TYPE_ARM(_type) \
+ (((_type) << KVM_VM_TYPE_ARM_SHIFT) & KVM_VM_TYPE_ARM_MASK)
+#define KVM_VM_TYPE_ARM_NORMAL KVM_VM_TYPE_ARM(0)
+#define KVM_VM_TYPE_ARM_REALM KVM_VM_TYPE_ARM(1)
+
#define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL
#define KVM_VM_TYPE_ARM_IPA_SIZE(x) \
((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
The definitions in this section aren't exactly same to that in (v14) host
series,
leading to KVM_VM_TYPE_ARM_REALM = 0 in my environment and the realm guest can't
be started with the following error message. At least, KVM_VM_TYPE_ARM_MASK has
been redefined with different values.
qemu-system-aarch64: KVM does not support guest_memfd
> linux-headers/linux/kvm.h
#define KVM_VM_TYPE_ARM_SHIFT 30
#define KVM_VM_TYPE_ARM_MASK (0x3ULL << KVM_VM_TYPE_ARM_SHIFT)
#define KVM_VM_TYPE_ARM_MASK (KVM_VM_TYPE_ARM_IPA_SIZE_MASK | \
KVM_VM_TYPE_ARM_PROTECTED)
After syncing the definitions with those in (v14) host series, I'm able to boot
a simple realm guest (no virtio devices) with one warning.
qemu-system-aarch64: Failed to enable KVM_CAP_ARM_NISV_TO_USER cap
Thanks,
Gavin
@@ -719,6 +729,8 @@ struct kvm_enable_cap {
#define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
#define KVM_GET_MSR_FEATURE_INDEX_LIST_IOWR(KVMIO, 0x0a, struct
kvm_msr_list)
+#define KVM_ARM_RMI_POPULATE _IOWR(KVMIO, 0xd7, struct kvm_arm_rmi_populate)
+
/*
* Extension capability list.
*/
@@ -985,6 +997,7 @@ struct kvm_enable_cap {
#define KVM_CAP_S390_USER_OPEREXEC 246
#define KVM_CAP_S390_KEYOP 247
#define KVM_CAP_S390_VSIE_ESAMODE 248
+#define KVM_CAP_ARM_RMI 249
struct kvm_irq_routing_irqchip {
__u32 irqchip;
