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@xxxxxxxxxxxxxxx> Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> --- 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