From patchwork Tue Aug 18 04:24:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 11719887 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 A71D0739 for ; Tue, 18 Aug 2020 04:24:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B6602078D for ; Tue, 18 Aug 2020 04:24:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726519AbgHREYJ (ORCPT ); Tue, 18 Aug 2020 00:24:09 -0400 Received: from mga07.intel.com ([134.134.136.100]:16710 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbgHREYI (ORCPT ); Tue, 18 Aug 2020 00:24:08 -0400 IronPort-SDR: xrglv+LES4D5DrNFQ1io5QDgchMQoLfJLu2fISgEV98dgoeLaaEkdxr5dvRmT0E+CMuhqf1O4U kbYGv+GCAlsg== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="219156477" X-IronPort-AV: E=Sophos;i="5.76,326,1592895600"; d="scan'208";a="219156477" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 21:24:06 -0700 IronPort-SDR: sDVSplS0zf5RnQ5XgoLlvK07JwD4FBVI04JoYKw7Xmdy5bw8JMB8XWj/LTjlsLckZd4SjsnjtH H71e4mIPVtgg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,326,1592895600"; d="scan'208";a="334270270" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.160]) by FMSMGA003.fm.intel.com with ESMTP; 17 Aug 2020 21:24:06 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: Nathaniel McCallum , Cedric Xing , Jethro Beekman , Andy Lutomirski , linux-sgx@vger.kernel.org Subject: [RFC PATCH 3/4] x86/vdso: x86/sgx: Introduce dedicated SGX exit reasons for vDSO Date: Mon, 17 Aug 2020 21:24:04 -0700 Message-Id: <20200818042405.12871-4-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200818042405.12871-1-sean.j.christopherson@intel.com> References: <20200818042405.12871-1-sean.j.christopherson@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 Use dedicated exit reasons, e.g. SYNCHRONOUS and EXCEPTION, instead of '0' and '-EFAULT' respectively. Using -EFAULT is less than desirable as it usually means "bad address", which may or may not be true for a fault in the enclave or on ENCLU. Signed-off-by: Sean Christopherson Acked-by: Jethro Beekman --- arch/x86/entry/vdso/vsgx_enter_enclave.S | 7 +++++-- arch/x86/include/uapi/asm/sgx.h | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/entry/vdso/vsgx_enter_enclave.S b/arch/x86/entry/vdso/vsgx_enter_enclave.S index aaae6d6e28ac3..b09e87dbe9334 100644 --- a/arch/x86/entry/vdso/vsgx_enter_enclave.S +++ b/arch/x86/entry/vdso/vsgx_enter_enclave.S @@ -19,6 +19,9 @@ /* #define USER_DATA_OFFSET 4*8 */ #define EXCEPTION_OFFSET 5*8 +#define SGX_SYNCHRONOUS_EXIT 0 +#define SGX_EXCEPTION_EXIT 1 + /* Offsets into sgx_enter_enclave.exception. */ #define EX_TRAPNR 0*8 #define EX_ERROR_CODE 0*8+2 @@ -65,7 +68,7 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) mov RUN_OFFSET(%rbp), %rbx /* Set exit_reason. */ - movl $0, EXIT_REASON_OFFSET(%rbx) + movl $SGX_SYNCHRONOUS_EXIT, EXIT_REASON_OFFSET(%rbx) /* Invoke userspace's exit handler if one was provided. */ .Lhandle_exit: @@ -94,7 +97,7 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) mov RUN_OFFSET(%rbp), %rbx /* Set the exit_reason and exception info. */ - movl $(-EFAULT), EXIT_REASON_OFFSET(%rbx) + movl $SGX_EXCEPTION_EXIT, EXIT_REASON_OFFSET(%rbx) mov %di, (EXCEPTION_OFFSET + EX_TRAPNR)(%rbx) mov %si, (EXCEPTION_OFFSET + EX_ERROR_CODE)(%rbx) diff --git a/arch/x86/include/uapi/asm/sgx.h b/arch/x86/include/uapi/asm/sgx.h index d3b107aac279d..80a8b7a949a23 100644 --- a/arch/x86/include/uapi/asm/sgx.h +++ b/arch/x86/include/uapi/asm/sgx.h @@ -74,6 +74,9 @@ struct sgx_enclave_set_attribute { __u64 attribute_fd; }; +#define SGX_SYNCHRONOUS_EXIT 0 +#define SGX_EXCEPTION_EXIT 1 + struct sgx_enclave_run; /**