Skip to content

RFC x86: Add vDSO exception fixup for SGX

Sean Christopherson linux-sgx lkml 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 RFC Latest5 patches 58 repliesIn review
  2. v4 RFC5 patches 8 repliesSuperseded
  3. v3 RFC4 patches 11 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC4 patches22 repliesSuperseded
v1 RFC4 patches8 repliesSuperseded

Changes in v5 from the cover letter

- Strip down __vdso_sgx_enter_enclave() so it only touches RSP and GPRs that are already collateral damage of ENCLU[EENTER/ERESUME].
- Add a 16-byte reserved field to 'struct sgx_enclave_exception' so the struct can grow in a backwards compatible fashion.
- Add a blurb at the end of the changelog for patch 1/5 explaining why the vDSO fixup macros look different than the equivalent kernel macros.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5x86/vdso: Add support for exception fixup in vDSO functionsarch/x86/entry/vdso/Makefile arch/x86/entry/vdso/extable.c arch/x86/entry/vdso/extable.h +3 more+131 -110 replies
2/5x86/fault: Add helper function to sanitize error codearch/x86/mm/fault.c+14 -120 replies
3/5x86/fault: Attempt to fixup unhandled #PF on ENCLU before signalingarch/x86/mm/fault.c+7 -00 replies
4/5x86/traps: Attempt to fixup exceptions in vDSO before signalingarch/x86/kernel/traps.c+14 -00 replies
5/5x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave transitionsarch/x86/entry/vdso/Makefile arch/x86/entry/vdso/vdso.lds.S arch/x86/entry/vdso/vsgx_enter_enclave.S +1 more+118 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [RFC PATCH v5 0/5] x86: Add vDSO exception fixup for SGX

__vdso_sgx_enter_enclave() gets another rewrite, this time to strip it down to the bare minimum and explicitly break compliance with the x86-64 ABI. Feedback from v4 revealed that __vdso_sgx_enter_enclave() would need to save (a lot) more than just the non-volatile GPRs to be compliant with the x86-64 ABI, at which point breaking from the ABI completely became much more palatable.

The non-standard ABI also solves the question of "which GPRs should be marshalled to/from the enclave" by getting out of the way entirely and letting userspace have free reign (except for RSP, which has a big ol' DO NOT TOUCH sign on it).

[1] https://lkml.kernel.org/r/[email protected]

v1: https://lkml.kernel.org/r/[email protected]
v2: https://lkml.kernel.org/r/[email protected]
v3: https://lkml.kernel.org/r/[email protected]
v4: https://lkml.kernel.org/r/[email protected]
v5:
- Strip down __vdso_sgx_enter_enclave() so it only touches RSP and GPRs that are already collateral damage of ENCLU[EENTER/ERESUME].
- Add a 16-byte reserved field to 'struct sgx_enclave_exception' so the struct can grow in a backwards compatible fashion.
- Add a blurb at the end of the changelog for patch 1/5 explaining why the vDSO fixup macros look different than the equivalent kernel macros.

Sean Christopherson (5):
x86/vdso: Add support for exception fixup in vDSO functions x86/fault: Add helper function to sanitize error code x86/fault: Attempt to fixup unhandled #PF on ENCLU before signaling x86/traps: Attempt to fixup exceptions in vDSO before signaling x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave
transitions

 arch/x86/entry/vdso/Makefile             |  6 +-
 arch/x86/entry/vdso/extable.c            | 37 +++++++++
 arch/x86/entry/vdso/extable.h            | 29 +++++++
 arch/x86/entry/vdso/vdso-layout.lds.S    |  9 ++-
 arch/x86/entry/vdso/vdso.lds.S           |  1 +
 arch/x86/entry/vdso/vdso2c.h             | 58 ++++++++++++--
 arch/x86/entry/vdso/vsgx_enter_enclave.S | 97 ++++++++++++++++++++++++
 arch/x86/include/asm/vdso.h              |  5 ++
 arch/x86/include/uapi/asm/sgx.h          | 18 +++++
 arch/x86/kernel/traps.c                  | 14 ++++
 arch/x86/mm/fault.c                      | 33 +++++---
 11 files changed, 284 insertions(+), 23 deletions(-)
 create mode 100644 arch/x86/entry/vdso/extable.c
 create mode 100644 arch/x86/entry/vdso/extable.h
 create mode 100644 arch/x86/entry/vdso/vsgx_enter_enclave.S
Signature · 1 line
2.19.2