Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5180849imm; Tue, 19 Jun 2018 06:27:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKcz1LcWnAScUQgzKwQWzSSUdJE4BHUoo31SwyH8MHdKCZZxu2rGkNYzRmAiHDWvr9Ar0fA X-Received: by 2002:a62:918:: with SMTP id e24-v6mr17771197pfd.30.1529414845916; Tue, 19 Jun 2018 06:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529414845; cv=none; d=google.com; s=arc-20160816; b=02nloMsASbrVSm0NakZ3E1VNDMMtVlUgor/FGMrzVGFK9YPV8jnszXLgILzyjtNq5p Y0P2z6mb/5Q4SugmbKnrYrWMu47/XrMVMskIpXWnU6nqKGXehIQ+gdmMxh1EbE+0LyD2 0EJCHTl5T0fkkfppJ0WguRmDrSu4F+oBZ1YU51Bl1c0tATAXcpkbl29qHo0yY0JqZYk1 hBkTLASaZtJ3uI9F0nM6J63Of838H1pO3zRCV4wdprZvndOHuOpFoWhxa9J/vlSoHUdf rTdbL2rZdDfvP1IGv4x+FNF1nPeQRztMsRyGSYs2HyB4rhggRzMdJdNrn8260c4R/QBG 27fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=oXEjJ6RF4un0Mt3b2Fvt8dT5h21lTn7NxyKsn+0PXPg=; b=g0ie+hYDIqq1NQgeZIOg64OMo1MGI3JNYLZrPP7P+GXNVZMCE2XVm9bFcfMLCQVf+Q OsZpG+AbapNUeFfBvRzX+aYpQOMs6XcJg+HwX1JHkKfLZZuugu28ymiKv2z2smV6U85q pto39UySODke3GE9WfkSSv0TM81Ewmsg3WSGdBhr8NFmBYHw/mCjxM4SVhPOvIgNP5Ck f8kzO77METB75+2p5k21kak3nM0f7tWV8ZqlDcnV983yC5mD4u6gNJj6D+YceMeMCP/B BvVynw99jowPfzKhgUJyXtcWCwfui8eo9gWMybN9he0zJbWgNMmn6jZ7HHhU1QQBP8Rh L0Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10-v6si19141310pln.349.2018.06.19.06.27.12; Tue, 19 Jun 2018 06:27:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966168AbeFSNZ5 (ORCPT + 99 others); Tue, 19 Jun 2018 09:25:57 -0400 Received: from mga04.intel.com ([192.55.52.120]:55231 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937149AbeFSNZ4 (ORCPT ); Tue, 19 Jun 2018 09:25:56 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jun 2018 06:25:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,243,1526367600"; d="scan'208";a="51105786" Received: from aluisell-mobl2.ger.corp.intel.com (HELO localhost) ([10.249.254.128]) by orsmga006.jf.intel.com with ESMTP; 19 Jun 2018 06:25:35 -0700 Date: Tue, 19 Jun 2018 16:25:34 +0300 From: Jarkko Sakkinen To: Dave Hansen Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:INTEL SGX" Subject: Re: [PATCH v11 08/13] x86, sgx: added ENCLS wrappers Message-ID: <20180619132534.GE5609@linux.intel.com> References: <20180608171216.26521-1-jarkko.sakkinen@linux.intel.com> <20180608171216.26521-9-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 08, 2018 at 10:43:50AM -0700, Dave Hansen wrote: > On 06/08/2018 10:09 AM, Jarkko Sakkinen wrote: > > This commit adds wrappers for Intel(R) SGX ENCLS opcode functionality. > > What's ENCLS? I know what an opcode is, but I don't know what "opcode > functionality" is. Could you give us more than a single, cryptic > sentence, please? Sure. > > +enum sgx_commands { > > + ECREATE = 0x0, > > + EADD = 0x1, > > + EINIT = 0x2, > > + EREMOVE = 0x3, > > + EDGBRD = 0x4, > > + EDGBWR = 0x5, > > + EEXTEND = 0x6, > > + ELDU = 0x8, > > + EBLOCK = 0x9, > > + EPA = 0xA, > > + EWB = 0xB, > > + ETRACK = 0xC, > > + EAUG = 0xD, > > + EMODPR = 0xE, > > + EMODT = 0xF, > > +}; > > Again, please differentiate hardware-defined values from > software-defines ones. Also, would it hurt to expand the acronyms a > bit, like: > > + ELDU = 0x8, /* LoaD Underpants */ Not a bad idea at all. > > +#define SGX_FN(name, params...) \ > > +{ \ > > + void *epc; \ > > + int ret; \ > > + epc = sgx_get_page(epc_page); \ > > + ret = __##name(params); \ > > + sgx_put_page(epc); \ > > + return ret; \ > > +} > > Have I seen sgx_*_page() yet in this series? This seems out of order. Oops, thanks for spotting this out. > > +#define BUILD_SGX_FN(fn, name) \ > > +static inline int fn(struct sgx_epc_page *epc_page) \ > > + SGX_FN(name, epc) > > +BUILD_SGX_FN(sgx_eremove, eremove) > > +BUILD_SGX_FN(sgx_eblock, eblock) > > +BUILD_SGX_FN(sgx_etrack, etrack) > > +BUILD_SGX_FN(sgx_epa, epa) > > + > > +static inline int sgx_emodpr(struct sgx_secinfo *secinfo, > > + struct sgx_epc_page *epc_page) > > + SGX_FN(emodpr, secinfo, epc) > > +static inline int sgx_emodt(struct sgx_secinfo *secinfo, > > + struct sgx_epc_page *epc_page) > > + SGX_FN(emodt, secinfo, epc) > > Wow, that's hideous. > > Can't you just do: > > BUILD_SGX_FN(__sgx_emopt, foo) > > static inline int sgx_emodt(struct sgx_secinfo *secinfo, > struct sgx_epc_page *epc_page) > { > return __sgx_emopt(secinfo, page); > } > > Also, this entire patch seems rather comment-free. Was that intentional? Something that I've ignored (big series) but I'll add comments to the next version. /Jarkko