Re: [PATCH] x86/vmware: Add TDX hypercall support

From: Alexey Makhalov
Date: Thu Dec 07 2023 - 21:28:30 EST




On 12/7/23 9:12 AM, Dave Hansen wrote:
On 12/5/23 23:15, Alexey Makhalov wrote:
+#ifdef CONFIG_INTEL_TDX_GUEST
+/* Export tdx hypercall and allow it only for VMware guests. */
+void vmware_tdx_hypercall_args(struct tdx_module_args *args)
+{
+ if (hypervisor_is_type(X86_HYPER_VMWARE))
+ __tdx_hypercall(args);
+}
+EXPORT_SYMBOL_GPL(vmware_tdx_hypercall_args);
+#endif

I think this is still too generic. This still allows anything setting
X86_HYPER_VMWARE to make any TDX hypercall.

I'd *much* rather you export something like vmware_tdx_hypercall() or
even the high-level calls like hypervisor_ppn_reset_all(). The higher
level and more specialized the interface, the less likely it is to be
abused.

Dave, I understood your point. Please take a look on the next version of the patch.

I export vmware_tdx_hypercall(), while vmware_tdx_hypercall_args() is a
static inline wrapper on top.
Most of the vmware hypercall logic plus sanity checks are now in exported function. While only input and output argument handling remains in the wrapper to allow compiler optimization for hypercalls with few argument. Exporting vmware_tdx_hypercall1, vmware_tdx_hypercall3, and so on is not an option either.

Regards,
--Alexey