Skip to content

Commit

Permalink
arm64: RME: Define the user ABI
Browse files Browse the repository at this point in the history
There is one (multiplexed) CAP which can be used to create, populate and
then activate the realm.

Signed-off-by: Steven Price <steven.price@arm.com>
  • Loading branch information
Steven Price authored and intel-lab-lkp committed Jan 28, 2023
1 parent 81bbfc0 commit 8ea2cfe
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/virt/kvm/api.rst
Expand Up @@ -4965,6 +4965,7 @@ Recognised values for feature:

===== ===========================================
arm64 KVM_ARM_VCPU_SVE (requires KVM_CAP_ARM_SVE)
arm64 KVM_ARM_VCPU_REC (requires KVM_CAP_ARM_RME)
===== ===========================================

Finalizes the configuration of the specified vcpu feature.
Expand Down
63 changes: 63 additions & 0 deletions arch/arm64/include/uapi/asm/kvm.h
Expand Up @@ -109,6 +109,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;
Expand Down Expand Up @@ -401,6 +402,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
Expand Down
2 changes: 2 additions & 0 deletions include/uapi/linux/kvm.h
Expand Up @@ -1176,6 +1176,8 @@ struct kvm_ppc_resize_hpt {
#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225

#define KVM_CAP_ARM_RME 300 // FIXME: Large number to prevent conflicts

#ifdef KVM_CAP_IRQ_ROUTING

struct kvm_irq_routing_irqchip {
Expand Down

0 comments on commit 8ea2cfe

Please sign in to comment.