qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 01/16] NOMERGE: Add KVM Arm RME definitions to Linux headers


From: Jean-Philippe Brucker
Subject: [RFC PATCH 01/16] NOMERGE: Add KVM Arm RME definitions to Linux headers
Date: Fri, 27 Jan 2023 15:07:14 +0000

Copy the KVM definitions for Arm RME from the development branch.
Don't merge, they will be added from the periodic Linux header sync.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 linux-headers/asm-arm64/kvm.h | 63 +++++++++++++++++++++++++++++++++++
 linux-headers/linux/kvm.h     | 21 +++++++++---
 2 files changed, 80 insertions(+), 4 deletions(-)

diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index 4bf2d7246e..8e04d6f7ff 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -108,6 +108,7 @@ struct kvm_regs {
 #define KVM_ARM_VCPU_SVE               4 /* enable SVE for this CPU */
 #define KVM_ARM_VCPU_PTRAUTH_ADDRESS   5 /* VCPU uses address authentication */
 #define KVM_ARM_VCPU_PTRAUTH_GENERIC   6 /* VCPU uses generic authentication */
+#define KVM_ARM_VCPU_REC               7 /* VCPU REC state as part of Realm */
 
 struct kvm_vcpu_init {
        __u32 target;
@@ -391,6 +392,68 @@ enum {
 #define   KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3
 #define   KVM_DEV_ARM_ITS_CTRL_RESET           4
 
+/* KVM_CAP_ARM_RME on VM fd */
+#define KVM_CAP_ARM_RME_CONFIG_REALM           0
+#define KVM_CAP_ARM_RME_CREATE_RD              1
+#define KVM_CAP_ARM_RME_INIT_IPA_REALM         2
+#define KVM_CAP_ARM_RME_POPULATE_REALM         3
+#define KVM_CAP_ARM_RME_ACTIVATE_REALM         4
+
+#define KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA256                0
+#define KVM_CAP_ARM_RME_MEASUREMENT_ALGO_SHA512                1
+
+#define KVM_CAP_ARM_RME_RPV_SIZE 64
+
+/* List of configuration items accepted for KVM_CAP_ARM_RME_CONFIG_REALM */
+#define KVM_CAP_ARM_RME_CFG_RPV                        0
+#define KVM_CAP_ARM_RME_CFG_HASH_ALGO          1
+#define KVM_CAP_ARM_RME_CFG_SVE                        2
+#define KVM_CAP_ARM_RME_CFG_DBG                        3
+#define KVM_CAP_ARM_RME_CFG_PMU                        4
+
+struct kvm_cap_arm_rme_config_item {
+       __u32 cfg;
+       union {
+               /* cfg == KVM_CAP_ARM_RME_CFG_RPV */
+               struct {
+                       __u8    rpv[KVM_CAP_ARM_RME_RPV_SIZE];
+               };
+
+               /* cfg == KVM_CAP_ARM_RME_CFG_HASH_ALGO */
+               struct {
+                       __u32   hash_algo;
+               };
+
+               /* cfg == KVM_CAP_ARM_RME_CFG_SVE */
+               struct {
+                       __u32   sve_vq;
+               };
+
+               /* cfg == KVM_CAP_ARM_RME_CFG_DBG */
+               struct {
+                       __u32   num_brps;
+                       __u32   num_wrps;
+               };
+
+               /* cfg == KVM_CAP_ARM_RME_CFG_PMU */
+               struct {
+                       __u32   num_pmu_cntrs;
+               };
+               /* Fix the size of the union */
+               __u8    reserved[256];
+       };
+};
+
+struct kvm_cap_arm_rme_populate_realm_args {
+       __u64 populate_ipa_base;
+       __u64 populate_ipa_size;
+};
+
+struct kvm_cap_arm_rme_init_ipa_args {
+       __u64 init_ipa_base;
+       __u64 init_ipa_size;
+};
+
 /* Device Control API on vcpu fd */
 #define KVM_ARM_VCPU_PMU_V3_CTRL       0
 #define   KVM_ARM_VCPU_PMU_V3_IRQ      0
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index ebdafa576d..9d5affc98a 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -901,14 +901,25 @@ struct kvm_ppc_resize_hpt {
 #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[11-8] 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          8
+#define KVM_VM_TYPE_ARM_MASK           (0xfULL << 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)
+
 /*
  * ioctls for /dev/kvm fds:
  */
@@ -1176,6 +1187,8 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_S390_ZPCI_OP 221
 #define KVM_CAP_S390_CPU_TOPOLOGY 222
 
+#define KVM_CAP_ARM_RME 300 // FIXME: Large number to prevent conflicts
+
 #ifdef KVM_CAP_IRQ_ROUTING
 
 struct kvm_irq_routing_irqchip {
-- 
2.39.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]