diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index b8998cf0508a..a4bf2b67d3d7 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -13,7 +13,7 @@ #include /* TDX module Call Leaf IDs */ -#define TDX_GET_INFO 1 +#define TDX_GET_INFO 1 /* TDG.VP.INFO */ #define TDX_GET_VEINFO 3 #define TDX_ACCEPT_PAGE 6 @@ -100,19 +100,10 @@ static inline void tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, panic("TDCALL %lld failed (Buggy TDX module!)\n", fn); } -static void tdx_parse_tdinfo(u64 *cc_mask) +static u64 get_cc_mask(void) { struct tdx_module_output out; - unsigned int gpa_width; - u64 td_attr; - /* - * TDINFO TDX module call is used to get the TD execution environment - * information like GPA width, number of available vcpus, debug mode - * information, etc. More details about the ABI can be found in TDX - * Guest-Host-Communication Interface (GHCI), section 2.4.2 TDCALL - * [TDG.VP.INFO]. - */ tdx_module_call(TDX_GET_INFO, 0, 0, 0, 0, &out); /* @@ -123,7 +114,15 @@ static void tdx_parse_tdinfo(u64 *cc_mask) * can not meaningfully run without it. */ gpa_width = out.rcx & GENMASK(5, 0); - *cc_mask = BIT_ULL(gpa_width - 1); + return BIT_ULL(gpa_width - 1); +} + +static void tdx_check_tdinfo(void) +{ + struct tdx_module_output out; + u64 td_attr; + + tdx_module_call(TDX_GET_INFO, 0, 0, 0, 0, &out); /* * The kernel can not handle #VE's when accessing normal kernel @@ -769,7 +768,8 @@ void __init tdx_early_init(void) setup_force_cpu_cap(X86_FEATURE_TDX_GUEST); cc_set_vendor(CC_VENDOR_INTEL); - tdx_parse_tdinfo(&cc_mask); + tdx_check_tdinfo(); + cc_mask = get_cc_mask(); cc_set_mask(cc_mask); /*