From: Cedric Xing <cedric.xing@intel.com>
To: linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org,
jarkko.sakkinen@linux.intel.com
Cc: cedric.xing@intel.com, akpm@linux-foundation.org,
dave.hansen@intel.com, sean.j.christopherson@intel.com,
serge.ayoun@intel.com, shay.katz-zamir@intel.com,
haitao.huang@intel.com, kai.svahn@intel.com, kai.huang@intel.com
Subject: [RFC PATCH v4 0/3] x86/sgx: Amend vDSO API to allow enclave/host parameter passing on untrusted stack
Date: Fri, 12 Jul 2019 23:51:24 -0700 [thread overview]
Message-ID: <cover.1563000446.git.cedric.xing@intel.com> (raw)
In-Reply-To: <cover.1562813643.git.cedric.xing@intel.com>
This patchset is based upon, and can be applied cleanly on SGX1 patch v20
(https://lkml.org/lkml/2019/4/17/344) by Jarkko Sakkinen.
The current proposed __vdso_sgx_enter_enclave() requires enclaves to preserve
%rsp, which prohibits enclaves from allocating space on the untrusted stack.
However, there are existing enclaves (e.g. those built with current Intel SGX
SDK libraries) relying on the untrusted stack for passing parameters to
untrusted functions (aka. o-calls), which requires allocating space on the
untrusted stack by enclaves. After all, passing data via untrusted stack is
very easy to implement (by enclaves), with essentially no overhead, therefore
is very suitable for exchanging data in small amounts, so could be desirable by
future SGX applications as well.
This patchset introduces a new ABI for __vdso_sgx_enter_enclave() to anchor its
stack frame on %rbp (instead of %rsp), so as to allow enclaves to "push" onto
the untrusted stack by decrementing the untrusted %rsp. And in order to service
o-calls and to preserve the untrusted stack upon exceptions, the new vDSO API
takes one more optional parameter - "callback", which if supplied, will be
invoked on all enclave exits (including normal and asynchronous exits). Ample
details regarding the new ABI have been documented as comments inside the
source code located in arch/x86/entry/vsgx_enter_enclave.S
Please note that there was a lengthy discussion on what is the "best" approach
for passing parameters for trusted/untrusted calls. Unfortunately there's no
single "best" approach that fits all use cases, hence this new ABI has been
designed intentionally to accommodate varieties. Therefore, to those not
interested in using the untrusted stack, whatever worked with the old ABI
proposed by Sean will continue to work with this new ABI.
The SGX selftest has been augmented by two new tests. One exercises the new
callback interface, and serves as a simple example to showcase how to use it;
while the other validates the hand-crafted CFI directives in
__vdso_sgx_enter_enclave() by single-stepping through it and unwinding call
stack at every instruction.
Changelog:
· This is version 4 of this patch series with the following changes.
- Removed unrelated cosmetic changes.
- Rewrote and reformatted comments in
arch/x86/entry/vdso/vsgx_enter_enclave.S to follow kernel-doc
conventions. New comments now can be converted to nice looking man pages.
- Fixed minor issues in the unwinding selftest and now it can run to
completion successfully with Sean's fix in vDSO fixup code
(https://patchwork.kernel.org/patch/11040801/). Comments have also been
added to describe the tests done.
· v3 - https://patchwork.kernel.org/cover/11039263/
· v2 - https://patchwork.kernel.org/cover/10914161/
· v1 - https://patchwork.kernel.org/cover/10911615/
Cedric Xing (3):
selftests/x86/sgx: Fix Makefile for SGX selftest
x86/vdso: Modify __vdso_sgx_enter_enclave() to allow parameter passing
on untrusted stack
selftests/x86/sgx: Augment SGX selftest to test vDSO API
arch/x86/entry/vdso/vsgx_enter_enclave.S | 310 ++++++++++++++-----
arch/x86/include/uapi/asm/sgx.h | 14 +-
tools/testing/selftests/x86/sgx/Makefile | 49 ++-
tools/testing/selftests/x86/sgx/main.c | 344 ++++++++++++++++++---
tools/testing/selftests/x86/sgx/sgx_call.S | 40 ++-
5 files changed, 600 insertions(+), 157 deletions(-)
--
2.17.1
next parent reply other threads:[~2019-07-13 6:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1562813643.git.cedric.xing@intel.com>
2019-07-13 6:51 ` Cedric Xing [this message]
2019-07-13 6:51 ` [RFC PATCH v4 1/3] selftests/x86/sgx: Fix Makefile for SGX selftest Cedric Xing
2019-07-13 15:10 ` Jarkko Sakkinen
2019-07-13 15:15 ` Jarkko Sakkinen
2019-07-13 17:29 ` Xing, Cedric
2019-07-14 14:53 ` Jarkko Sakkinen
2019-07-13 6:51 ` [RFC PATCH v4 2/3] x86/vdso: Modify __vdso_sgx_enter_enclave() to allow parameter passing on untrusted stack Cedric Xing
2019-07-13 15:04 ` Jarkko Sakkinen
2019-07-13 15:06 ` Jarkko Sakkinen
2019-07-13 6:51 ` [RFC PATCH v4 3/3] selftests/x86/sgx: Augment SGX selftest to test vDSO API Cedric Xing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1563000446.git.cedric.xing@intel.com \
--to=cedric.xing@intel.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@intel.com \
--cc=haitao.huang@intel.com \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=kai.huang@intel.com \
--cc=kai.svahn@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=sean.j.christopherson@intel.com \
--cc=serge.ayoun@intel.com \
--cc=shay.katz-zamir@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox