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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 54E62C433DB for ; Wed, 10 Mar 2021 23:23:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24AC264FC1 for ; Wed, 10 Mar 2021 23:23:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233170AbhCJXWx (ORCPT ); Wed, 10 Mar 2021 18:22:53 -0500 Received: from mga09.intel.com ([134.134.136.24]:65011 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233271AbhCJXWr (ORCPT ); Wed, 10 Mar 2021 18:22:47 -0500 IronPort-SDR: V/Xx3Laz1EeK68MgBufPlwnSrDu7IaaXsJjbEO7DjSjBmuuPLnOtjpi8xKOn3ohdPhluCq7Cvn YrJV5pAlws3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="188680184" X-IronPort-AV: E=Sophos;i="5.81,238,1610438400"; d="scan'208";a="188680184" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 15:22:45 -0800 IronPort-SDR: 0IDkoEO2HQZNiV1iZJn7oQUIDlBiMFDNIBXwwNfIe/p83TkZr4G7JQyi9y+5tOLg+e/KoeoVJ7 SITLPWfab66A== X-IronPort-AV: E=Sophos;i="5.81,238,1610438400"; d="scan'208";a="509838912" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.23.206]) ([10.209.23.206]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 15:22:42 -0800 Subject: Re: [PATCH v22 8/8] x86/vdso: Add ENDBR64 to __vdso_sgx_enter_enclave To: Dave Hansen , 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> <8b8efe44-b79f-ce29-ee28-066f88c93840@intel.com> From: "Yu, Yu-cheng" Message-ID: <727fed3a-f7da-a947-4221-56ab39deefe4@intel.com> Date: Wed, 10 Mar 2021 15:22:41 -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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On 3/10/2021 3:20 PM, Dave Hansen wrote: > On 3/10/21 2:55 PM, Yu, Yu-cheng wrote: >> 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! > > This is close, but it's missing a detail or two that I think is > important for someone like Jarkko trying to figure out what it means for > his subsystem or driver. > > I'd probably say: > > ENDBR is a special new instruction for the Indirect Branch Tracking > (IBR) component of CET. IBT prevents attacks by ensuring that (most) > indirect branches and function calls may only land at ENDBR > instructions. Branches that don't follow the rules will result in > control flow (#CF) exceptions. > > ENDBR is a noop when IBT is unsupported or disabled. Most ENDBR > instructions are inserted automatically by the compiler, but branch > targets written in assembly must have ENDBR added manually, like this one. > Ok, I will update. Thanks! -- Yu-cheng