Hi Mathieu,

On 9/4/26 5:35 AM, Mathieu Poirier wrote:
From: Jean-Philippe Brucker <[email protected]>

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 <[email protected]>
Signed-off-by: Mathieu Poirier <[email protected]>
---
  linux-headers/asm-arm64/kvm.h |  9 +++++++++
  linux-headers/linux/kvm.h     | 10 +++++++++-
  2 files changed, 18 insertions(+), 1 deletion(-)

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 29f81c05aca2..8b7627f11447 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -689,14 +689,19 @@ struct kvm_enable_cap {
   * 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.
+ *
+ * Bits[30-31] are reserved for the VM type
   */
  #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)
+#define KVM_VM_TYPE_ARM_NORMAL 0
+#define KVM_VM_TYPE_ARM_REALM          (1UL << 30)
  #define KVM_VM_TYPE_ARM_PROTECTED     (1UL << 31)
  #define KVM_VM_TYPE_ARM_MASK          (KVM_VM_TYPE_ARM_IPA_SIZE_MASK | \
-                                        KVM_VM_TYPE_ARM_PROTECTED)
+                                        KVM_VM_TYPE_ARM_PROTECTED | \
+                                        KVM_VM_TYPE_ARM_REALM)
/*
   * ioctls for /dev/kvm fds:
@@ -719,6 +724,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.
   */
@@ -988,6 +995,7 @@ struct kvm_enable_cap {
  #define KVM_CAP_S390_HPAGE_2G 249
  #define KVM_CAP_PPC_COMPAT_CAPS 250
  #define KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES 251
+#define KVM_CAP_ARM_RMI 252

Both KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES and KVM_CAP_ARM_RMI aren't 
consistent to
the definitions in Steven Price's (v16) host series [1]. They need corrections 
as
below. Otherwise, realm VM can't be started and the following errors are raised 
by
qemu.

[1] https://lore.kernel.org/kvm/[email protected]/

root@host:~# qemu-system-aarch64 -enable-kvm                  \
-object rme-guest,id=rme0,convert-in-place=on                 \
-machine virt,gic-version=3,confidential-guest-support=rme0   \
-m 2G -cpu host                                               \
-smp maxcpus=4,cpus=4,sockets=1,clusters=1,cores=2,threads=2  \
-object memory-backend-guest-memfd,id=mem0,size=2G,share=on   \
-numa node,nodeid=0,cpus=0-3,memdev=mem0                      \
-serial mon:stdio -monitor none -nographic -nodefaults        \
-kernel /mnt/linux/arch/arm64/boot/Image                      \
-initrd /mnt/buildroot/output/images/rootfs.cpio.xz           \
-append earlycon=pl011,mmio,0x10009000000
    :
qemu-system-aarch64: VM doesn't support Realms
qemu-system-aarch64: failed to initialize kvm: No such device


-#define KVM_CAP_PPC_COMPAT_CAPS 250
-#define KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES 251
-#define KVM_CAP_ARM_RMI 252
+#define KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES 250
+#define KVM_CAP_ARM_RMI 251

  struct kvm_irq_routing_irqchip {
        __u32 irqchip;

Thanks,
Gavin


Reply via email to