Re: [RFC v2-fix-v1 1/1] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions

From: Sean Christopherson
Date: Wed May 19 2021 - 16:09:59 EST


On Wed, May 19, 2021, Kuppuswamy, Sathyanarayanan wrote:
>
> On 5/19/21 8:31 AM, Dave Hansen wrote:
> > Was this "older compiler" argument really the reason?
>
> It is a speculation. I haven't tried to reproduce it with old compiler. So
> I have removed that point.

It's not "older" compilers. gcc does not support R8-R15 as input/output
constraints, which means inline asm needs to do register shenanigans, and those
are horribly fragile because the compiler does not ensure register variables are
preserved outside of asm blobs. E.g. adding a print like so can corrupt r10,
which makes it an absolute nightmare to debug/trace flows that pass r8-r15 to
asm blobs since looking at the code the wrong way can break things.

register unsigned long r10 asm("r10") = __r10;

pr_info("TDCALL: RAX = %lx, R10 = %lx\n", rax, __r10);

asm volatile("tdcall"
: "=a"(rax) :
: "a"(rax), "r"(r10));