Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4196410imm; Tue, 25 Sep 2018 13:04:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV60BtdBnB94AVPCz1P4MlQT8sB0kWX9r0DKLVR3dDv947bRI/QmymQil40YIkrS1frBo1OWl X-Received: by 2002:a63:1d3:: with SMTP id 202-v6mr2479368pgb.136.1537905850749; Tue, 25 Sep 2018 13:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537905850; cv=none; d=google.com; s=arc-20160816; b=uiWyTLpYBVzIj0596Rz20H61rb6YlCaJneeIOm8DHQxXkEgcF135F3PY1UlmphwOmD 0VoXxSK8DGUyvPJXE8wFCZxzKvfipWeYm4kiEzejzYEe3TG3siyzlBH50lOr4I8b+z1L 07p28LgTqgKAZoy4HTd+7wKtU9GP0D7rSKp77lNfKcc8WzwKcoavc+a9gjmdEVybmctt sAG738SP+lzyCrLxq2RFKeUhbxNrpATOUFTa/fIBiZ88/QQoWD4ZbXAOJcBRopgGk+6q dA5kZlctEOCuGras0oWphc0bpuEtR1mXz2DrdK/u12WeomtjFUZpK95G2aAc2Lum6Dwb WjrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from:dkim-signature; bh=wJ3ghOv44Ze7hWxabIvIqFmvpibAuwCLhoXsjP9Zu7g=; b=IVJjq02EgS2tIu55b+ADFjMUe5f+336eD1/mBqEh3jHdeQEJV7k2IbwCI/LAkuEuHC dZa2rVDunlH69XlXWA19wzQhBGsAzlWAtMpg7mwGL35qxiVQ6Z/GBcS+QnSDqUrSCczG mJWC6QEkQGwFdMzldRoWhZJWmhbBKZh7tobySzaR5Zv4uFQIKaOaNX7+xZFczh5rWA0+ pBwYyinCeRgqGLZmwMklnnQCxM4Xtm0Xt0jqRwQIMBQE7iSKKrrsNATjvQBStwV+Qd/A S7WA83ayGx0U4Z6d+mjlkiX2eOjxXPnp5u9wZKGV1d8NQZr19ALdVjS7CGQ4wWQeNIBx vwww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Tyt90W4V; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si3150254plm.205.2018.09.25.13.03.54; Tue, 25 Sep 2018 13:04:10 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Tyt90W4V; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727233AbeIZCLS (ORCPT + 99 others); Tue, 25 Sep 2018 22:11:18 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36702 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbeIZCLS (ORCPT ); Tue, 25 Sep 2018 22:11:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:References:Cc:To: Subject:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wJ3ghOv44Ze7hWxabIvIqFmvpibAuwCLhoXsjP9Zu7g=; b=Tyt90W4VNzdLqwlKFODC4Zxr8 MkgSAtZd6AduVB3GZ/rZNytIBk5GCfKsHBdd/rs8hq8fBOxINsToIATiwOh3mwe9FzVEzSDigvpjJ kyIiqXOBYCYAe35edxb+Dzu67EYMpgsdg8KB3oPxGJuJOX5tCZdscNGi8lei1Lszkpke6MuVBpAxV kzmpSQhy53m8oWQTuhRiiBD1Jh8gEyM/S0WUOFzF2RfIctPH5QWe7Fa0PAUTtJq+MCXcxM02YTiiH ILVim/qCNwH74jqRGOIZW0n1VkjKwEhvCxaxZSrS4+ayL3t7UJBHFxKPBchPnpjLTL3vfVy0yB/NK l088uIKHQ==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g4tWo-0000iv-M1; Tue, 25 Sep 2018 20:02:07 +0000 From: Randy Dunlap Subject: [PATCH v14 11/19] x86/sgx: Add wrappers for ENCLS leaf functions To: Jarkko Sakkinen , x86@kernel.org, platform-driver-x86@vger.kernel.org Cc: dave.hansen@intel.com, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, andriy.shevchenko@linux.intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Suresh Siddha , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" References: <20180925130845.9962-1-jarkko.sakkinen@linux.intel.com> <20180925130845.9962-12-jarkko.sakkinen@linux.intel.com> Message-ID: Date: Tue, 25 Sep 2018 13:01:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180925130845.9962-12-jarkko.sakkinen@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/25/18 6:06 AM, Jarkko Sakkinen wrote: > Add wrappers for Intel(R) SGX ENCLS opcode leaf functions except > ENCLS(EINIT). ENCLS invokes privileged functions for managing (creation, > initialization and swapping) and debugging enclaves. > > Signed-off-by: Jarkko Sakkinen > Co-developed-by: Sean Christopherson > Signed-off-by: Sean Christopherson > --- > arch/x86/include/asm/sgx.h | 244 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 244 insertions(+) > > diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h > index f4f82f0453a9..e66e2572011e 100644 > --- a/arch/x86/include/asm/sgx.h > +++ b/arch/x86/include/asm/sgx.h > @@ -10,4 +10,248 @@ > extern bool sgx_enabled; > extern bool sgx_lc_enabled; > Hi, Please don't use "/**" to begin comment blocks that are not kernel-doc notation, like the 3 below. Note: I might have seen one (or some) of these "fixed" in other patches in this series (not sure). > +/** > + * ENCLS_FAULT_FLAG - flag signifying an ENCLS return code is a trapnr > + * > + * ENCLS has its own (positive value) error codes and also generates > + * ENCLS specific #GP and #PF faults. And the ENCLS values get munged > + * with system error codes as everything percolates back up the stack. > + * Unfortunately (for us), we need to precisely identify each unique > + * error code, e.g. the action taken if EWB fails varies based on the > + * type of fault and on the exact SGX error code, i.e. we can't simply > + * convert all faults to -EFAULT. > + * > + * To make all three error types coexist, we set bit 30 to identify an > + * ENCLS fault. Bit 31 (technically bits N:31) is used to differentiate > + * between positive (faults and SGX error codes) and negative (system > + * error codes) values. > + */ > +#define ENCLS_FAULT_FLAG 0x40000000 > + > +/** > + * Check for a fault by looking for a postive value with the fault > + * flag set. The postive value check is needed to filter out system > + * error codes since negative values will have all higher order bits > + * set, including ENCLS_FAULT_FLAG. > + */ > +#define IS_ENCLS_FAULT(r) ((int)(r) > 0 && ((r) & ENCLS_FAULT_FLAG)) > + > +/** > + * Retrieve the encoded trapnr from the specified return code. > + */ > +#define ENCLS_TRAPNR(r) ((r) & ~ENCLS_FAULT_FLAG) thanks, -- ~Randy