From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: linux-sgx@vger.kernel.org
Subject: [PATCH for_v23 5/7] x86/sgx: Add a flag to ADD_PAGES to allow replicating the source page
Date: Tue, 8 Oct 2019 21:42:39 -0700 [thread overview]
Message-ID: <20191009044241.3591-6-sean.j.christopherson@intel.com> (raw)
In-Reply-To: <20191009044241.3591-1-sean.j.christopherson@intel.com>
Add a flag to allow userspace to replicate a single source page to
multiple target pages in the enclave, e.g. to zero the .bss, initialize
the heap, etc...
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
arch/x86/include/uapi/asm/sgx.h | 7 ++++++-
arch/x86/kernel/cpu/sgx/ioctl.c | 3 ++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h
index 84734229d8dd..42634e99945e 100644
--- a/arch/x86/include/uapi/asm/sgx.h
+++ b/arch/x86/include/uapi/asm/sgx.h
@@ -28,6 +28,9 @@ struct sgx_enclave_create {
__u64 src;
};
+/* Replicate a single source data page to all target pages. */
+#define SGX_ADD_PAGES_REPLICATE_SRC BIT(0)
+
/**
* struct sgx_enclave_add_pages - parameter structure for the
* %SGX_IOC_ENCLAVE_ADD_PAGE ioctl
@@ -35,6 +38,7 @@ struct sgx_enclave_create {
* @src: start address for the page data
* @nr_pages: number of pages to add to enclave
* @secinfo: address for the SECINFO data
+ * @flags: misc control flags
* @mrmask: bitmask for the measured 256 byte chunks
* @reserved: reserved for future use
*/
@@ -43,8 +47,9 @@ struct sgx_enclave_add_pages {
__u64 src;
__u64 nr_pages;
__u64 secinfo;
+ __u32 flags;
__u16 mrmask;
- __u8 reserved[6];
+ __u8 reserved[2];
};
/**
diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
index 4597dd8f5c91..9c6d582612cb 100644
--- a/arch/x86/kernel/cpu/sgx/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/ioctl.c
@@ -529,7 +529,8 @@ static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg)
break;
addp.offset += PAGE_SIZE;
- addp.src += PAGE_SIZE;
+ if (!(addp.flags & SGX_ADD_PAGES_REPLICATE_SRC))
+ addp.src += PAGE_SIZE;
}
if (copy_to_user(arg, &addp, sizeof(addp)))
--
2.22.0
next prev parent reply other threads:[~2019-10-09 4:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 4:42 [PATCH for_v23 0/7] x86/sgx: Improve add pages ioctl Sean Christopherson
2019-10-09 4:42 ` [PATCH for_v23 1/7] x86/sgx: Modify ADD_PAGE ioctl to take offset instead of full address Sean Christopherson
2019-10-09 4:42 ` [PATCH for_v23 2/7] selftests/x86/sgx: Update test to account for ADD_PAGE change Sean Christopherson
2019-10-09 4:42 ` [PATCH for_v23 3/7] x86/sgx: Tweak ADD_PAGE ioctl to allow adding multiple pages Sean Christopherson
2019-10-14 21:32 ` Jarkko Sakkinen
2019-10-14 21:35 ` Jarkko Sakkinen
2019-10-14 23:31 ` Sean Christopherson
2019-10-16 10:17 ` Jarkko Sakkinen
2019-10-16 10:19 ` Jarkko Sakkinen
2019-10-16 10:29 ` Jarkko Sakkinen
2019-10-21 11:24 ` Jarkko Sakkinen
2019-10-09 4:42 ` [PATCH for_v23 4/7] selftests/x86/sgx: Update enclave build flow to do multi-page add Sean Christopherson
2019-10-09 4:42 ` Sean Christopherson [this message]
2019-10-09 4:42 ` [PATCH for_v23 6/7] selftests/x86/sgx: Update selftest to account for ADD_PAGES flag Sean Christopherson
2019-10-09 4:42 ` [PATCH for_v23 7/7] selftests/x86/sgx: Add test coverage for reclaim and replicate Sean Christopherson
2019-10-10 3:28 ` [PATCH for_v23 0/7] x86/sgx: Improve add pages ioctl Haitao Huang
2019-10-11 14:37 ` Sean Christopherson
2019-10-13 15:15 ` Dr. Greg
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=20191009044241.3591-6-sean.j.christopherson@intel.com \
--to=sean.j.christopherson@intel.com \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=linux-sgx@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).