From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 3F0F6C43381 for ; Wed, 10 Mar 2021 22:57:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E5A164FD6 for ; Wed, 10 Mar 2021 22:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233478AbhCJW4c (ORCPT ); Wed, 10 Mar 2021 17:56:32 -0500 Received: from mga02.intel.com ([134.134.136.20]:13783 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbhCJW4A (ORCPT ); Wed, 10 Mar 2021 17:56:00 -0500 IronPort-SDR: m0/E1qlyf/nrMRyOqGabwUgq+wv7VAEut8aIFd7kjO2PP7DHms6Qtmlw7t7/++Y2zDz8eOlgqH 4Rmr5gLc3RNQ== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="175683825" X-IronPort-AV: E=Sophos;i="5.81,238,1610438400"; d="scan'208";a="175683825" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 14:55:59 -0800 IronPort-SDR: vgwZzVqErYKUbnwXGaNZd9JIwqSzZBKODEvebckIrrOpn0/GLJKSjxkr67x9aoT/+38x2cDqv0 ape7PH+LypIQ== X-IronPort-AV: E=Sophos;i="5.81,238,1610438400"; d="scan'208";a="403865286" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.23.206]) ([10.209.23.206]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 14:55:56 -0800 Subject: Re: [PATCH v22 8/8] x86/vdso: Add ENDBR64 to __vdso_sgx_enter_enclave To: Jarkko Sakkinen Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang References: <20210310220519.16811-1-yu-cheng.yu@intel.com> <20210310220519.16811-9-yu-cheng.yu@intel.com> From: "Yu, Yu-cheng" Message-ID: <8b8efe44-b79f-ce29-ee28-066f88c93840@intel.com> Date: Wed, 10 Mar 2021 14:55:55 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/10/2021 2:39 PM, Jarkko Sakkinen wrote: > On Wed, Mar 10, 2021 at 02:05:19PM -0800, Yu-cheng Yu wrote: >> When CET is enabled, __vdso_sgx_enter_enclave() needs an endbr64 >> in the beginning of the function. > > OK. > > What you should do is to explain what it does and why it's needed. > The endbr marks a branch target. Without the "no-track" prefix, if an indirect call/jmp reaches a non-endbr opcode, a control-protection fault is raised. Usually endbr's are inserted by the compiler. For assembly, these have to be put in manually. I will add this in the commit log if there is another revision. Thanks! -- Yu-cheng >> >> Signed-off-by: Yu-cheng Yu >> Cc: Andy Lutomirski >> Cc: Dave Hansen >> Cc: Jarkko Sakkinen >> --- >> arch/x86/entry/vdso/vsgx.S | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S >> index 86a0e94f68df..a70d4d09f713 100644 >> --- a/arch/x86/entry/vdso/vsgx.S >> +++ b/arch/x86/entry/vdso/vsgx.S >> @@ -27,6 +27,9 @@ >> SYM_FUNC_START(__vdso_sgx_enter_enclave) >> /* Prolog */ >> .cfi_startproc >> +#ifdef CONFIG_X86_CET >> + endbr64 >> +#endif >> push %rbp >> .cfi_adjust_cfa_offset 8 >> .cfi_rel_offset %rbp, 0 >> -- >> 2.21.0 >> >> > > /Jarkko >