Rename tdx_parse_tdinfo() to tdx_setup() and move setting NOTIFY_ENABLES there.
The function will be extended to adjust TD configuration.
Signed-off-by: Kirill A. Shutemov kirill.shutemov@linux.intel.com Reviewed-by: Kuppuswamy Sathyanarayanan sathyanarayanan.kuppuswamy@linux.intel.com Reviewed-by: Kai Huang kai.huang@intel.com Cc: stable@vger.kernel.org --- arch/x86/coco/tdx/tdx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 64717a96a936..08ce488b54d0 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -193,7 +193,7 @@ static void __noreturn tdx_panic(const char *msg) __tdx_hypercall(&args); }
-static void tdx_parse_tdinfo(u64 *cc_mask) +static void tdx_setup(u64 *cc_mask) { struct tdx_module_args args = {}; unsigned int gpa_width; @@ -218,6 +218,9 @@ static void tdx_parse_tdinfo(u64 *cc_mask) gpa_width = args.rcx & GENMASK(5, 0); *cc_mask = BIT_ULL(gpa_width - 1);
+ /* Kernel does not use NOTIFY_ENABLES and does not need random #VEs */ + tdg_vm_wr(TDCS_NOTIFY_ENABLES, 0, -1ULL); + /* * The kernel can not handle #VE's when accessing normal kernel * memory. Ensure that no #VE will be delivered for accesses to @@ -964,11 +967,11 @@ void __init tdx_early_init(void) setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
cc_vendor = CC_VENDOR_INTEL; - tdx_parse_tdinfo(&cc_mask); - cc_set_mask(cc_mask);
- /* Kernel does not use NOTIFY_ENABLES and does not need random #VEs */ - tdg_vm_wr(TDCS_NOTIFY_ENABLES, 0, -1ULL); + /* Configure the TD */ + tdx_setup(&cc_mask); + + cc_set_mask(cc_mask);
/* * All bits above GPA width are reserved and kernel treats shared bit
On 28.08.24 г. 12:35 ч., Kirill A. Shutemov wrote:
Rename tdx_parse_tdinfo() to tdx_setup() and move setting NOTIFY_ENABLES there.
The function will be extended to adjust TD configuration.
<offtopic> Since this deals with renaming, I think it will make sense to rename tdx_early_init() to tdx_guest_init/tdx_guest_early_init as it becomes confusing as to which parts of the TDX pertain to the host and which to the guest. Right now we only have the guest portions under arch/x86/coco/tdx but when the kvm/vmx stuff land things will become somewhat messy.. </offtopic>
<snip>
On Wed, Aug 28, 2024 at 04:53:57PM +0300, Nikolay Borisov wrote:
On 28.08.24 г. 12:35 ч., Kirill A. Shutemov wrote:
Rename tdx_parse_tdinfo() to tdx_setup() and move setting NOTIFY_ENABLES there.
The function will be extended to adjust TD configuration.
<offtopic> Since this deals with renaming, I think it will make sense to rename tdx_early_init() to tdx_guest_init/tdx_guest_early_init as it becomes confusing as to which parts of the TDX pertain to the host and which to the guest. Right now we only have the guest portions under arch/x86/coco/tdx but when the kvm/vmx stuff land things will become somewhat messy.. </offtopic>
I don't see a problem with the current state. KVM side will land under arch/x86/virt/vmx/tdx, so the path will give it away.
linux-stable-mirror@lists.linaro.org