Re: [RFC v2-fix-v2 1/1] x86/tdx: Wire up KVM hypercalls
From: Dave Hansen
Date: Tue May 18 2021 - 19:29:36 EST
On 5/18/21 2:19 PM, Kuppuswamy Sathyanarayanan wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx>
> KVM hypercalls use the "vmcall" or "vmmcall" instructions.
> Although the ABI is similar, those instructions no longer
> function for TDX guests. Make vendor-specific TDVMCALLs
> instead of VMCALL. This enables TDX guests to run with KVM
> acting as the hypervisor. TDX guests running under other
> hypervisors will continue to use those hypervisor's
Well, I screwed this up when I typed it too, but it is:
TDX guests running under other hypervisors will continue
to use those hypervisors' hypercalls.
I hate how that reads, but oh well.
> Since KVM hypercall functions can be included and called
> from kernel modules, export tdx_kvm_hypercall*() functions
> to avoid symbol errors
No, you're not avoiding errors, you're exporting the symbol so it can be
*USED*. The error comes from it not being exported.
It also helps to be specific here: Export tdx_kvm_hypercall*() to make
the symbols visible to kvm.ko.
> [Isaku Yamahata: proposed KVM VENDOR string]
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> Reviewed-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
Reviewed-by: Dave Hansen <dave.hansen@xxxxxxxxx>
Also, FWIW, if you did this in the header:
+static inline long tdx_kvm_hypercall0(unsigned int nr)
+ return tdx_kvm_hypercall(nr, 0, 0, 0, 0);
You could get away with just exporting tdx_kvm_hypercall() instead of 4
symbols. The rest of the code would look the same.