Message ID | 20241030190039.77971-6-rick.p.edgecombe@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | TDX vCPU/VM creation | expand |
On 10/30/24 12:00, Rick Edgecombe wrote: > From: Isaku Yamahata <isaku.yamahata@intel.com> > > Intel TDX protects guest VMs from malicious host and certain physical > attacks. Pre-TDX Intel hardware has support for a memory encryption > architecture called MK-TME, which repurposes several high bits of > physical address as "KeyID". TDX ends up with reserving a sub-range of > MK-TME KeyIDs as "TDX private KeyIDs". The changelog there was great. It read my mind because I was wondering why some of the operations didn't get combined in helper functions which could be exported. Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
On Tue, 2024-11-12 at 12:09 -0800, Dave Hansen wrote: > On 10/30/24 12:00, Rick Edgecombe wrote: > > From: Isaku Yamahata <isaku.yamahata@intel.com> > > > > Intel TDX protects guest VMs from malicious host and certain physical > > attacks. Pre-TDX Intel hardware has support for a memory encryption > > architecture called MK-TME, which repurposes several high bits of > > physical address as "KeyID". TDX ends up with reserving a sub-range of > > MK-TME KeyIDs as "TDX private KeyIDs". > > The changelog there was great. It read my mind because I was wondering > why some of the operations didn't get combined in helper functions which > could be exported. > > Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Thanks, I'll make the u64 removal changes to this one and leave the ack.
diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index d33e46d53d59..9897335a8e2f 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -121,6 +121,10 @@ const struct tdx_sys_info *tdx_get_sysinfo(void); int tdx_guest_keyid_alloc(void); void tdx_guest_keyid_free(unsigned int keyid); + +/* SEAMCALL wrappers for creating/destroying/running TDX guests */ +u64 tdh_mng_key_config(u64 tdr); +u64 tdh_mng_key_freeid(u64 tdr); #else static inline void tdx_init(void) { } static inline int tdx_cpu_enable(void) { return -ENODEV; } diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index b883c1a4b002..c42eab8cc069 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -1562,3 +1562,23 @@ void tdx_guest_keyid_free(unsigned int keyid) ida_free(&tdx_guest_keyid_pool, keyid); } EXPORT_SYMBOL_GPL(tdx_guest_keyid_free); + +u64 tdh_mng_key_config(u64 tdr) +{ + struct tdx_module_args args = { + .rcx = tdr, + }; + + return seamcall(TDH_MNG_KEY_CONFIG, &args); +} +EXPORT_SYMBOL_GPL(tdh_mng_key_config); + +u64 tdh_mng_key_freeid(u64 tdr) +{ + struct tdx_module_args args = { + .rcx = tdr, + }; + + return seamcall(TDH_MNG_KEY_FREEID, &args); +} +EXPORT_SYMBOL_GPL(tdh_mng_key_freeid); diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h index 9b708a8fb568..95002e7ff4c5 100644 --- a/arch/x86/virt/vmx/tdx/tdx.h +++ b/arch/x86/virt/vmx/tdx/tdx.h @@ -17,13 +17,15 @@ /* * TDX module SEAMCALL leaf functions */ -#define TDH_PHYMEM_PAGE_RDMD 24 -#define TDH_SYS_KEY_CONFIG 31 -#define TDH_SYS_INIT 33 -#define TDH_SYS_RD 34 -#define TDH_SYS_LP_INIT 35 -#define TDH_SYS_TDMR_INIT 36 -#define TDH_SYS_CONFIG 45 +#define TDH_MNG_KEY_CONFIG 8 +#define TDH_MNG_KEY_FREEID 20 +#define TDH_PHYMEM_PAGE_RDMD 24 +#define TDH_SYS_KEY_CONFIG 31 +#define TDH_SYS_INIT 33 +#define TDH_SYS_RD 34 +#define TDH_SYS_LP_INIT 35 +#define TDH_SYS_TDMR_INIT 36 +#define TDH_SYS_CONFIG 45 /* TDX page types */ #define PT_NDA 0x0