From fe8ca3ebee8612dfb5e4dc9055cbf1d597844759 Mon Sep 17 00:00:00 2001 From: liuhao365 Date: Mon, 8 Dec 2025 15:37:47 +0800 Subject: [PATCH] virtcca secure cvm supports live migration test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit virtcca inclusion category: feature bugzilla: https://gitee.com/openeuler/release-management/issues/IDBB6P -------------------------------- this patch adds support for live migration in the secure CVM feature of virtcca. It ensures that the security context is maintained during the migration process. Signed-off-by: hjx_gitff Signed-off-by: zhuyifan1 Signed-off-by: 限行带树 Signed-off-by: liuhao365 --- arch/arm64/include/asm/kvm_tmm.h | 20 ++++++++++++++++++++ include/uapi/linux/kvm.h | 5 +++++ tools/include/uapi/linux/kvm.h | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/arch/arm64/include/asm/kvm_tmm.h b/arch/arm64/include/asm/kvm_tmm.h index 484940589c7c..2cbb2b1cf926 100644 --- a/arch/arm64/include/asm/kvm_tmm.h +++ b/arch/arm64/include/asm/kvm_tmm.h @@ -157,6 +157,26 @@ static inline unsigned long cvm_ttt_level_mapsize(int level) return (1UL << CVM_TTT_LEVEL_SHIFT(level)); } + +struct kvm_virtcca_mig_cmd { + /* enum kvm_tdx_cmd_id */ + __u32 id; + /* flags for sub-commend. If sub-command doesn't use this, set zero. */ + __u32 flags; + /* + * data for each sub-command. An immediate or a pointer to the actual + * data in process virtual address. If sub-command doesn't use it, + * set zero. + */ + __u64 data; + /* + * Auxiliary error code. The sub-command may return TDX SEAMCALL + * status code in addition to -Exxx. + * Defined for consistency with struct kvm_sev_cmd. + */ + __u64 error; +}; + #endif #endif diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 0036cfaf5d69..f3e8bd5c4249 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1499,6 +1499,8 @@ enum kvm_device_type { #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_RISCV_AIA, #define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA + KVM_DEV_TYPE_VIRTCCA_MIG_STREAM = 0x00C, +#define KVM_DEV_TYPE_VIRTCCA_MIG_STREAM KVM_DEV_TYPE_VIRTCCA_MIG_STREAM KVM_DEV_TYPE_LOONGARCH_IPI, #define KVM_DEV_TYPE_LOONGARCH_IPI KVM_DEV_TYPE_LOONGARCH_IPI KVM_DEV_TYPE_LOONGARCH_EIOINTC, @@ -1773,6 +1775,9 @@ struct kvm_enc_region { __u64 size; }; +/*virtcca migration*/ +#define KVM_CVM_MIG_IOCTL _IOWR(KVMIO, 0xf2, struct kvm_virtcca_mig_cmd) + #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index bd1a496b5448..34f3243767c1 100644 --- a/tools/include/uapi/linux/kvm.h +++ b/tools/include/uapi/linux/kvm.h @@ -1448,6 +1448,8 @@ enum kvm_device_type { #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_RISCV_AIA, #define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA + KVM_DEV_TYPE_VIRTCCA_MIG_STREAM = 0x00C, +#define KVM_DEV_TYPE_VIRTCCA_MIG_STREAM KVM_DEV_TYPE_VIRTCCA_MIG_STREAM KVM_DEV_TYPE_LA_IOAPIC = 0x100, #define KVM_DEV_TYPE_LA_IOAPIC KVM_DEV_TYPE_LA_IOAPIC KVM_DEV_TYPE_LA_IPI, @@ -1668,6 +1670,9 @@ struct kvm_enc_region { __u64 size; }; +/*virtcca migration*/ +#define KVM_CVM_MIG_IOCTL _IOWR(KVMIO, 0xf2, struct kvm_virtcca_mig_cmd) + #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) -- Gitee