Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D410AC4CEC7 for ; Thu, 12 Sep 2019 19:48:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B019F2081B for ; Thu, 12 Sep 2019 19:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbfILTsE (ORCPT ); Thu, 12 Sep 2019 15:48:04 -0400 Received: from mga14.intel.com ([192.55.52.115]:31837 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbfILTsE (ORCPT ); Thu, 12 Sep 2019 15:48:04 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2019 12:48:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,489,1559545200"; d="scan'208";a="336683009" Received: from dscaswel-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.53.44]) by orsmga004.jf.intel.com with ESMTP; 12 Sep 2019 12:47:59 -0700 From: Jarkko Sakkinen To: linux-sgx@vger.kernel.org Cc: sean.j.christopherson@intel.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, Jarkko Sakkinen Subject: [PATCH RESEND 05/11] x86/sgx: Turn encls_failed() as inline function Date: Thu, 12 Sep 2019 20:47:14 +0100 Message-Id: <20190912194720.7107-6-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190912194720.7107-1-jarkko.sakkinen@linux.intel.com> References: <20190912194720.7107-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-sgx-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org Turn encls_failed() as an inline function. As far as the tracing goes we issue warning consistently in the call sites, which is enough to catch the potential issues. Cc: Sean Christopherson Cc: Shay Katz-zamir Cc: Serge Ayoun Signed-off-by: Jarkko Sakkinen --- arch/x86/kernel/cpu/sgx/Makefile | 2 +- arch/x86/kernel/cpu/sgx/encls.c | 24 ------------------------ arch/x86/kernel/cpu/sgx/encls.h | 18 +++++++++++++++++- 3 files changed, 18 insertions(+), 26 deletions(-) delete mode 100644 arch/x86/kernel/cpu/sgx/encls.c diff --git a/arch/x86/kernel/cpu/sgx/Makefile b/arch/x86/kernel/cpu/sgx/Makefile index 379e9c52848e..cfd29c42264b 100644 --- a/arch/x86/kernel/cpu/sgx/Makefile +++ b/arch/x86/kernel/cpu/sgx/Makefile @@ -1,5 +1,5 @@ # core -obj-y += encl.o encls.o main.o reclaim.o +obj-y += encl.o main.o reclaim.o # driver obj-y += driver.o ioctl.o diff --git a/arch/x86/kernel/cpu/sgx/encls.c b/arch/x86/kernel/cpu/sgx/encls.c deleted file mode 100644 index 1b492c15a2b8..000000000000 --- a/arch/x86/kernel/cpu/sgx/encls.c +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) -// Copyright(c) 2016-19 Intel Corporation. - -#include -#include -#include "encls.h" -#include "sgx.h" - -/** - * encls_failed() - Check if an ENCLS leaf function failed - * @ret: the return value of an ENCLS leaf function call - * - * Check if an ENCLS leaf function failed. This is a condition where the leaf - * function causes a fault that is not caused by an EPCM conflict. - * - * Return: true if there was a fault other than an EPCM conflict - */ -bool encls_failed(int ret) -{ - int epcm_trapnr = boot_cpu_has(X86_FEATURE_SGX2) ? - X86_TRAP_PF : X86_TRAP_GP; - - return encls_faulted(ret) && ENCLS_TRAPNR(ret) != epcm_trapnr; -} diff --git a/arch/x86/kernel/cpu/sgx/encls.h b/arch/x86/kernel/cpu/sgx/encls.h index 6631afbf2f64..b7e6462e58b8 100644 --- a/arch/x86/kernel/cpu/sgx/encls.h +++ b/arch/x86/kernel/cpu/sgx/encls.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "sgx.h" /** @@ -66,7 +67,22 @@ static inline bool encls_returned_code(int ret) return !encls_faulted(ret) && ret; } -bool encls_failed(int ret); +/** + * encls_failed() - Check if an ENCLS leaf function failed + * @ret: the return value of an ENCLS leaf function call + * + * Check if an ENCLS leaf function failed. This is a condition where the leaf + * function causes a fault that is not caused by an EPCM conflict. + * + * Return: true if there was a fault other than an EPCM conflict + */ +static inline bool encls_failed(int ret) +{ + int epcm_trapnr = boot_cpu_has(X86_FEATURE_SGX2) ? + X86_TRAP_PF : X86_TRAP_GP; + + return encls_faulted(ret) && ENCLS_TRAPNR(ret) != epcm_trapnr; +} /** * __encls_ret_N - encode an ENCLS leaf that returns an error code in EAX -- 2.20.1