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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A1A9CC433DB for ; Fri, 12 Mar 2021 16:56:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 11FFB6500F for ; Fri, 12 Mar 2021 16:56:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11FFB6500F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2663C6B0099; Fri, 12 Mar 2021 11:56:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 216936B009A; Fri, 12 Mar 2021 11:56:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DEBB6B009B; Fri, 12 Mar 2021 11:56:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id E5D956B0099 for ; Fri, 12 Mar 2021 11:56:20 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A171C363D for ; Fri, 12 Mar 2021 16:56:20 +0000 (UTC) X-FDA: 77911825320.13.B0A4F23 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf12.hostedemail.com (Postfix) with ESMTP id ED017FA for ; Fri, 12 Mar 2021 16:56:15 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BAC46501D; Fri, 12 Mar 2021 16:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615568179; bh=sUw5X72tXoX09gxNNea9KLqurXYlY189vCRL3W4qdik=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G0oi+GyBCIDqsQHVnRhKDpq2WFc+tn4nKcydUWwiiUMAAd5j4YURLpF/QO1JgLRir SvUrEfEL2d9giqM6IwvBQ7/dDcdnZEC4LC/CPwz/RJuIWTSOsYOTXKXVq88RKlVXH5 Gb3gTDMG2Xq3eIbJz2XbKgM8DB/tG3QN5V6WORRVTDIBHFeS9UMCL7DZyzXLvnWQcM QcU2tGem2rA38vh7k2HQVrAjr0Ds2MUPbHGdMDDmPKn0d6AwGLsJiAJFrtZRsjBek/ AURbVhmz3efN/JgVM0lcUWNvS9uuqv6JFgSP+GptQtJvxMuU+dnVSKLISHD/R2GJW7 088JTb7Yx3ZwA== Date: Fri, 12 Mar 2021 18:55:54 +0200 From: Jarkko Sakkinen To: Dave Hansen Cc: "Yu, Yu-cheng" , 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 Subject: Re: [PATCH v22 8/8] x86/vdso: Add ENDBR64 to __vdso_sgx_enter_enclave Message-ID: References: <20210310220519.16811-1-yu-cheng.yu@intel.com> <20210310220519.16811-9-yu-cheng.yu@intel.com> <8b8efe44-b79f-ce29-ee28-066f88c93840@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: X-Stat-Signature: yhfe4pugmdcc4nxq3k5tm46qt88ppa88 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: ED017FA Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615568175-786959 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Mar 10, 2021 at 03:20:20PM -0800, 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. > >> > >=20 > > The endbr marks a branch target.=A0 Without the "no-track" prefix, if= an > > indirect call/jmp reaches a non-endbr opcode, a control-protection fa= ult > > is raised.=A0 Usually endbr's are inserted by the compiler.=A0 For as= sembly, > > these have to be put in manually.=A0 I will add this in the commit lo= g if > > there is another revision.=A0 Thanks! >=20 > 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 fo= r > his subsystem or driver. >=20 > I'd probably say: >=20 > 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. >=20 > 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 o= ne. Thank you, this clears the whole thing a lot. Doesn't this mean that it could be there just as well unconditionally? /Jarkko