diff mbox series

[for_v22,v2,1/8] selftests/x86/sgx: Align enclave binary on 4k boundary

Message ID 20190813011252.4121-2-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series x86/sgx: Remove EADD worker and page copy | expand

Commit Message

Sean Christopherson Aug. 13, 2019, 1:12 a.m. UTC
Align the enclave's binary blob to 4096 bytes so that a pointer to the
blob satisfies hardware's requirements that the source data for EADD be
page aligned.  An upcoming kernel change will extend the alignment
requirement to userspace so that the kernel can avoid copying the source
into an internal buffer, i.e. pass the userspace pointer directly to
EADD.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 tools/testing/selftests/x86/sgx/encl_piggy.S | 1 +
 1 file changed, 1 insertion(+)

Comments

Jarkko Sakkinen Aug. 16, 2019, 1:55 p.m. UTC | #1
On Mon, Aug 12, 2019 at 06:12:45PM -0700, Sean Christopherson wrote:
> Align the enclave's binary blob to 4096 bytes so that a pointer to the
> blob satisfies hardware's requirements that the source data for EADD be
> page aligned.  An upcoming kernel change will extend the alignment
> requirement to userspace so that the kernel can avoid copying the source
> into an internal buffer, i.e. pass the userspace pointer directly to
> EADD.
> 
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

Requirement is too way strong vocabulary here. Whether it should be required
or there should fast and slow paths is debatable.

/Jarkko
Jethro Beekman Aug. 16, 2019, 3:36 p.m. UTC | #2
On 2019-08-16 06:55, Jarkko Sakkinen wrote:
> Requirement is too way strong vocabulary here. Whether it should be required
> or there should fast and slow paths is debatable.

After userspace has gone through all the trouble to map an enclave using 
the new API, aligning the input to this ioctl seems like a minor 
inconvenience.

--
Jethro Beekman | Fortanix
Jarkko Sakkinen Aug. 16, 2019, 11:41 p.m. UTC | #3
On Fri, Aug 16, 2019 at 03:36:11PM +0000, Jethro Beekman wrote:
> On 2019-08-16 06:55, Jarkko Sakkinen wrote:
> > Requirement is too way strong vocabulary here. Whether it should be required
> > or there should fast and slow paths is debatable.
> 
> After userspace has gone through all the trouble to map an enclave using the
> new API, aligning the input to this ioctl seems like a minor inconvenience.

You might in some cases mmap() less than the ELRANGE for legit reasons.
It is not really a question of convenience but rather just taking
advantage of robustness brought by the loose binding to the VMA.

/Jarkko
diff mbox series

Patch

diff --git a/tools/testing/selftests/x86/sgx/encl_piggy.S b/tools/testing/selftests/x86/sgx/encl_piggy.S
index 542001658afb..a7f6447abbba 100644
--- a/tools/testing/selftests/x86/sgx/encl_piggy.S
+++ b/tools/testing/selftests/x86/sgx/encl_piggy.S
@@ -4,6 +4,7 @@ 
  */
 
 	.section ".rodata", "a"
+	.balign 4096
 
 encl_bin:
 	.globl encl_bin