[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrWcJw7+tSni3zp4kO=r6gVGkVDnc2477fPg0ErUzvJAKg@mail.gmail.com>
Date: Tue, 23 Apr 2019 12:07:26 -0700
From: Andy Lutomirski <luto@...nel.org>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: Andy Lutomirski <luto@...nel.org>,
Cedric Xing <cedric.xing@...el.com>,
LKML <linux-kernel@...r.kernel.org>, X86 ML <x86@...nel.org>,
linux-sgx@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Dave <dave.hansen@...el.com>, nhorman@...hat.com,
npmccallum@...hat.com, Serge <serge.ayoun@...el.com>,
Shay <shay.katz-zamir@...el.com>,
Haitao <haitao.huang@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Kai <kai.svahn@...el.com>, Borislav Petkov <bp@...en8.de>,
Josh Triplett <josh@...htriplett.org>,
Kai <kai.huang@...el.com>, David Rientjes <rientjes@...gle.com>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Subject: Re: [RFC PATCH v1 3/3] selftests/x86: Augment SGX selftest to test
new __vdso_sgx_enter_enclave() and its callback interface
On Tue, Apr 23, 2019 at 11:59 AM Sean Christopherson
<sean.j.christopherson@...el.com> wrote:
>
> On Mon, Apr 22, 2019 at 06:29:06PM -0700, Andy Lutomirski wrote:
> > What's not tested here is running this code with EFLAGS.TF set and
> > making sure that it unwinds correctly. Also, Jarkko, unless I missed
> > something, the vDSO extable code likely has a bug. If you run the
> > instruction right before ENCLU with EFLAGS.TF set, then do_debug()
> > will eat the SIGTRAP and skip to the exception handler. Similarly, if
> > you put an instruction breakpoint on ENCLU, it'll get skipped. Or is
> > the code actually correct and am I just remembering wrong?
>
> The code is indeed broken, and I don't see a sane way to make it not
> broken other than to never do vDSO fixup on #DB or #BP. But that's
> probably the right thing to do anyways since an attached debugger is
> likely the intended recipient the 99.9999999% of the time.
>
> The crux of the matter is that it's impossible to identify whether or
> not a #DB/#BP originated from within an enclave, e.g. an INT3 in an
> enclave will look identical to an INT3 at the AEP. Even if hardware
> provided a magic flag, #DB still has scenarios where the intended
> recipient is ambiguous, e.g. data breakpoint encountered in the enclave
> but on an address outside of the enclave, breakpoint encountered in the
> enclave and a code breakpoint on the AEP, etc...
Ugh. It sounds like ignoring the fixup for #DB is the right call.
But what happens if the enclave contains an INT3 or ICEBP instruction?
Are they magically promoted to #GP, perhaps?
As a maybe possible alternative, if we made it so that the AEX address
was not the same as the ENCLU, could we usefully distinguish these
exceptions based on RIP? I suppose it's also worth considering
whether page faults from *inside* the enclave should result in SIGSEGV
or result in a fixup. We certainly want page faults from the ENCLU
instruction itself to get fixed up, but maybe we want most exceptions
inside the enclave to work a bit differently. Of course, if we do
this, we need to make sure that the semantics of returning from the
signal handler are reasonable.
Powered by blists - more mailing lists