Re: [PATCH v38 21/24] x86/vdso: Implement a vDSO for Intel SGX enclave call
From: Jarkko Sakkinen
Date: Mon Sep 28 2020 - 21:18:35 EST
On Mon, Sep 28, 2020 at 11:17:42AM -0700, Dave Hansen wrote:
> On 9/28/20 11:12 AM, Andy Lutomirski wrote:
> >> endbr64
> >> /* Check if shadow stack is in use. NB: R11 is the only usable
> >> scratch register for function calls. */
> >> xorl %r11d, %r11d
> >> rdsspq %r11
> >> testq %r11, %r11
> >> jnz 3f
> >> call 2f
> >> 1:
> >> pause
> >> lfence
> >> jmp 1b
> >> 2:
> >> mov %rax, (%rsp)
> >> ret
> >> 3:
> >> /* Shadow stack is in use. Make the indirect call. */
> >> call *%rax
> >> ret
> > What do we expect user programs to do on CET systems? It would be
> > nice if we could instead ALTERNATIVE this out if X86_FEATURE_SHSTK.
>
> Shouldn't we just be able to use X86_FEATURE_RETPOLINE?
>
> We probably need a mechanism to force X86_FEATURE_SHSTK and
> X86_FEATURE_RETPOLINE to be mutually exclusive if we don't have one already.
First of all: lets go with boot time patching instead of dynamic
detection. It's both easier to implement and by all other merits makes a
lot more sense. It was just a thing that I've not used before.
That sorted out, does it matter which direction I look it at? I could
use either feature flag as basis (and I do not have a personal
preference here).
/Jarkko