lkml.org 
[lkml]   [2021]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 1/1] x86/tdx: Add __tdcall() and __tdvmcall() helper functions
From
Date
On 4/22/21 6:09 PM, Kuppuswamy, Sathyanarayanan wrote:
> But let me try to explain it here. What I meant by complication is,
> for in/out instruction, we use alternative_io() to substitute in/out
> instructions with tdg_in()/tdg_out() assembly calls. So we have to ensure
> that we don't corrupt registers or stack from the substituted instructions
>
> If you check the implementation of tdg_in()/tdg_out(), you will notice
> that we have added code to preserve the caller registers. So, if we use
> C wrapper for this use case, there is a chance that it might mess
> the caller registers or stack.
>
>     alternative_io("in" #bwl " %w2, %" #bw "0",            \
>             "call tdg_in" #bwl, X86_FEATURE_TDX_GUEST,    \
>             "=a"(value), "d"(port))

Are you saying that calling C functions from inline assembly might
corrupt the stack or registers? Are you suggesting that you simply
can't call C functions from inline assembly? Or, that you can't express
the register clobbers of a function call in inline assembly?

You might want to check around the kernel to see how other folks do it.

\
 
 \ /
  Last update: 2021-04-23 03:23    [W:0.303 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site