From patchwork Tue Nov 19 18:41:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 11252573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB5F2138C for ; Tue, 19 Nov 2019 18:41:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96AED22409 for ; Tue, 19 Nov 2019 18:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbfKSSlu (ORCPT ); Tue, 19 Nov 2019 13:41:50 -0500 Received: from mga11.intel.com ([192.55.52.93]:54713 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbfKSSlu (ORCPT ); Tue, 19 Nov 2019 13:41:50 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 10:41:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,219,1571727600"; d="scan'208";a="357191671" Received: from mthoma4-mobl.ger.corp.intel.com (HELO localhost) ([10.251.82.166]) by orsmga004.jf.intel.com with ESMTP; 19 Nov 2019 10:41:48 -0800 From: Jarkko Sakkinen To: linux-sgx@vger.kernel.org Cc: Jarkko Sakkinen , Sean Christopherson Subject: [PATCH for v24 v3 3/4] x86/sgx: Detach sgx_encl_add_page() from struct sgx_enclave_add_pages Date: Tue, 19 Nov 2019 20:41:36 +0200 Message-Id: <20191119184137.16004-3-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191119184137.16004-1-jarkko.sakkinen@linux.intel.com> References: <20191119184137.16004-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Sender: linux-sgx-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org Internals should not have direct bindings to the ioctl API. Therefore, unpack &sgx_enclave_add_pages and pass its fields as separate parameters to sgx_enclave_add_page(). This will also remove an inconsistency: secinfo is already passed as a separate parameter whereas other fields are read from the struct. Cc: Sean Christopherson Signed-off-by: Jarkko Sakkinen --- arch/x86/kernel/cpu/sgx/ioctl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c index a2b411a8236d..f08008bef943 100644 --- a/arch/x86/kernel/cpu/sgx/ioctl.c +++ b/arch/x86/kernel/cpu/sgx/ioctl.c @@ -360,16 +360,16 @@ static int __sgx_encl_extend(struct sgx_encl *encl, return 0; } -static int sgx_encl_add_page(struct sgx_encl *encl, - struct sgx_enclave_add_pages *addp, - struct sgx_secinfo *secinfo) +static int sgx_encl_add_page(struct sgx_encl *encl, unsigned long src, + unsigned long offset, unsigned long length, + struct sgx_secinfo *secinfo, unsigned long flags) { struct sgx_encl_page *encl_page; struct sgx_epc_page *epc_page; struct sgx_va_page *va_page; int ret; - encl_page = sgx_encl_page_alloc(encl, addp->offset, secinfo->flags); + encl_page = sgx_encl_page_alloc(encl, offset, secinfo->flags); if (IS_ERR(encl_page)) return PTR_ERR(encl_page); @@ -412,7 +412,7 @@ static int sgx_encl_add_page(struct sgx_encl *encl, goto err_out_unlock; ret = __sgx_encl_add_page(encl, encl_page, epc_page, secinfo, - addp->src); + src); if (ret) { /* ENCLS failure. */ if (ret == -EIO) @@ -430,7 +430,7 @@ static int sgx_encl_add_page(struct sgx_encl *encl, encl_page->epc_page = epc_page; encl->secs_child_cnt++; - if (addp->flags & SGX_PAGE_MEASURE) { + if (flags & SGX_PAGE_MEASURE) { ret = __sgx_encl_extend(encl, epc_page); /* ENCLS failure. */ @@ -547,7 +547,8 @@ static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg) if (need_resched()) cond_resched(); - ret = sgx_encl_add_page(encl, &addp, &secinfo); + ret = sgx_encl_add_page(encl, addp.src, addp.offset, + addp.length, &secinfo, addp.flags); if (ret) break;