lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 22 Apr 2021 18:35:46 -0700
From:   Andi Kleen <ak@...ux.intel.com>
To:     Dave Hansen <dave.hansen@...el.com>
Cc:     "Kuppuswamy, Sathyanarayanan" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Andy Lutomirski <luto@...nel.org>,
        Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
        Kuppuswamy Sathyanarayanan <knsathya@...nel.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Raj Ashok <ashok.raj@...el.com>,
        Sean Christopherson <seanjc@...gle.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/1] x86/tdx: Add __tdcall() and __tdvmcall() helper
 functions

On Thu, Apr 22, 2021 at 06:21:07PM -0700, Dave Hansen wrote:
> 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

It's possible, but you would need to mark a lot more registers clobbered
(the x86-64 ABI allows to clobber many registers)

I don't think the stack would be messed up, but there might be problems
with writing the correct unwind information (which tends to be tricky)

Usually it's better to avoid it.

-Andi


> 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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ