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 83092C433E0 for ; Fri, 12 Mar 2021 16:58:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D21D65024 for ; Fri, 12 Mar 2021 16:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D21D65024 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 91AFD6B009C; Fri, 12 Mar 2021 11:58:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F09A6B009E; Fri, 12 Mar 2021 11:58:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BC666B009F; Fri, 12 Mar 2021 11:58:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 608706B009C for ; Fri, 12 Mar 2021 11:58:06 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 194584DDF for ; Fri, 12 Mar 2021 16:58:06 +0000 (UTC) X-FDA: 77911829772.29.7886401 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP id D0F9990009E2 for ; Fri, 12 Mar 2021 16:58:02 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 37F6B6500F; Fri, 12 Mar 2021 16:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615568284; bh=gKkUVElYcaHXJ1ly/d4kbT2/9U4Tw7bw+eiTqrYs7b8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZqPKG5aG0BpfyoiUeBI+egQZFVtE5C+b8/t5mfL9duPO3caEsNO/vNn5sF9SkBQ1+ 1pyIdEMn1uJbl1knOM1Hd+2H8n/a2TgyJfT5P3sdXi8R58yJ4HCyK0MyTYpZukSv3M 9M4r3fSPLLMTlFwXVUsHkGA6ppr6GuR4F6l5cNLeGDhHlSose0r4vYwUxn4HhiHafx s56kQ8fVgyWoOqisATyAYrQgfJQU3caA8o4XbyruZjM43vwurHGkFr36Q1Uj+pPUEx JaoawokOszzZMlPemGoaCFkS7/iKRpbAY4B5VVSCtm9/Je9wazSjgpck8LnetP3Nt4 Y9KG49L+wv39g== Date: Fri, 12 Mar 2021 18:57:40 +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: a8xqnpmijp7fhinnnbn3hw7npsz56df5 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D0F9990009E2 Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615568282-225946 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 Fri, Mar 12, 2021 at 06:55:57PM +0200, Jarkko Sakkinen wrote: > 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 = fault > > > is raised.=A0 Usually endbr's are inserted by the compiler.=A0 For = assembly, > > > these have to be put in manually.=A0 I will add this in the commit = log 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 = for > > 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= one. >=20 > Thank you, this clears the whole thing a lot. >=20 > Doesn't this mean that it could be there just as well unconditionally? Please, ignore the question (got the answer). /Jarkko