All of lore.kernel.org
 help / color / mirror / Atom feed
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 1/7] x86/sgx: Modify ADD_PAGE ioctl to take offset instead of full address
Date: Tue,  8 Oct 2019 21:42:35 -0700	[thread overview]
Message-ID: <20191009044241.3591-2-sean.j.christopherson@intel.com> (raw)
In-Reply-To: <20191009044241.3591-1-sean.j.christopherson@intel.com>

Change SGX_IOC_ENCLAVE_ADD_PAGE to take the target page as an offset
instead of a full address now that the API no longer uses the address to
find the target enclave.

Suggested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/include/uapi/asm/sgx.h |  4 ++--
 arch/x86/kernel/cpu/sgx/ioctl.c | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h
index 8f4660e07f6b..67583b046af1 100644
--- a/arch/x86/include/uapi/asm/sgx.h
+++ b/arch/x86/include/uapi/asm/sgx.h
@@ -31,14 +31,14 @@ struct sgx_enclave_create  {
 /**
  * struct sgx_enclave_add_page - parameter structure for the
  *                               %SGX_IOC_ENCLAVE_ADD_PAGE ioctl
- * @addr:	address within the ELRANGE
+ * @offset:	page offset within the enclave
  * @src:	address for the page data
  * @secinfo:	address for the SECINFO data
  * @mrmask:	bitmask for the measured 256 byte chunks
  * @reserved:	reserved for future use
  */
 struct sgx_enclave_add_page {
-	__u64	addr;
+	__u64	offset;
 	__u64	src;
 	__u64	secinfo;
 	__u16	mrmask;
diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
index 75f868bad3ea..f407dd35f9e3 100644
--- a/arch/x86/kernel/cpu/sgx/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/ioctl.c
@@ -113,7 +113,7 @@ static int sgx_validate_secs(const struct sgx_secs *secs,
 }
 
 static struct sgx_encl_page *sgx_encl_page_alloc(struct sgx_encl *encl,
-						 unsigned long addr,
+						 unsigned long offset,
 						 u64 secinfo_flags)
 {
 	struct sgx_encl_page *encl_page;
@@ -123,7 +123,7 @@ static struct sgx_encl_page *sgx_encl_page_alloc(struct sgx_encl *encl,
 	if (!encl_page)
 		return ERR_PTR(-ENOMEM);
 
-	encl_page->desc = addr;
+	encl_page->desc = encl->base + offset;
 	encl_page->encl = encl;
 
 	prot = _calc_vm_trans(secinfo_flags, SGX_SECINFO_R, PROT_READ)  |
@@ -368,7 +368,7 @@ static int sgx_encl_add_page(struct sgx_encl *encl,
 	struct sgx_va_page *va_page;
 	int ret;
 
-	encl_page = sgx_encl_page_alloc(encl, addp->addr, secinfo->flags);
+	encl_page = sgx_encl_page_alloc(encl, addp->offset, secinfo->flags);
 	if (IS_ERR(encl_page))
 		return PTR_ERR(encl_page);
 
@@ -485,11 +485,11 @@ static long sgx_ioc_enclave_add_page(struct sgx_encl *encl, void __user *arg)
 	if (copy_from_user(&addp, arg, sizeof(addp)))
 		return -EFAULT;
 
-	if (!IS_ALIGNED(addp.addr, PAGE_SIZE) ||
+	if (!IS_ALIGNED(addp.offset, PAGE_SIZE) ||
 	    !IS_ALIGNED(addp.src, PAGE_SIZE))
 		return -EINVAL;
 
-	if (addp.addr < encl->base || addp.addr - encl->base >= encl->size)
+	if (addp.offset >= encl->size)
 		return -EINVAL;
 
 	if (copy_from_user(&secinfo, (void __user *)addp.secinfo,
-- 
2.22.0


  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 ` Sean Christopherson [this message]
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 ` [PATCH for_v23 5/7] x86/sgx: Add a flag to ADD_PAGES to allow replicating the source page Sean Christopherson
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-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.