From patchwork Tue Sep 12 11:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 138202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp433614vqx; Tue, 12 Sep 2023 07:09:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWn+0OeZSvepiuPF5qUwQZdTnxlli85XylwqfKQs7JNipdK27Xf/eXl+El8bQuUYA597g4 X-Received: by 2002:a05:6a00:2191:b0:68e:3eb6:d45 with SMTP id h17-20020a056a00219100b0068e3eb60d45mr11830816pfi.30.1694527777576; Tue, 12 Sep 2023 07:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694527777; cv=none; d=google.com; s=arc-20160816; b=dDbQzdifDxO+ASwSUfvm2iFlEo2QSImfoDeuWEJZpISN79VMwaYLLimVeKaD7AREjV D+g/D3ENG+gWjnbkLk1REMgI5feoWLmz9akTjSYolVq+9ixZFET9pMyhwwHKysZOk+Tr FRA6q7+DuIQqWP6dfusOeD8OgZGCh+5Z4OuXxmS1qisZME1G+p70YTONMcZAGN9oOi1h 3vpUbe+PWABI96TcixggD4uaGFaKoV0kIq3sFiECbPMsnPLGg1xxv13uwZomfspreaiP tqm3IdHF2W+H8TwcHhj1B0kpPH7NozQj1yML/4nv4WAuhKpImRTza4JHFyDqNofxUO8D cnGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=LbBprMwnbPPLEsY2vhOkPL097RyL9EsvHkcx1RT2pw4=; fh=xQdFc4MTDkfl621nQN3lEwvyoudKrxtP0/vIUE6HyjU=; b=TkVqfrv90ksNaXkEiI/qnYBC4GVZWCClmMRfMNkDCpwBVUxp/NZaUDjx7zTMyTUwxc h9DUnzjVQRZLk51Q6J66tmA0V6tnHOIWgx2sp6AIV67T33mXnyEGfsJH9Fc5BIdkP4Sa uQDY3tmtA0+cGjj69tEIoULnAV1M3Cq4pF1CM8vMCc3wkBETlSQeothrcNZE3Lndr+ey NDu99MSJsjgdAMwthDGLsL09I43CJXIdzWUzP/H1iD6xy7pxjJuT3Alx+Kc48L0XEh/s HZdvpNaiU9jajeYbVD43MeB606IWrYelkcFsVG0aq4drIBtRCxWaOg2/yi0v2P6wiSWM IVFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UXmXsl5f; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x26-20020a63171a000000b00577960a815csi1700205pgl.188.2023.09.12.07.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 07:09:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UXmXsl5f; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 03F728024079; Tue, 12 Sep 2023 04:09:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234639AbjILLJP (ORCPT + 37 others); Tue, 12 Sep 2023 07:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234254AbjILLIn (ORCPT ); Tue, 12 Sep 2023 07:08:43 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E371735; Tue, 12 Sep 2023 04:08:34 -0700 (PDT) Date: Tue, 12 Sep 2023 11:08:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694516913; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LbBprMwnbPPLEsY2vhOkPL097RyL9EsvHkcx1RT2pw4=; b=UXmXsl5f1f1WItwXW0rTTAr/bVbnDs93VWND9UG9ktZEPL6QxJ3fQeY6lC8LqVivesT6u6 uhQtub1Okm7/pmstWO4l5aB+V8WwqVHBFD0qraxFXGLxZdVB20nyKHTgzvS/oyhugNJgXT 8419RU19e+JKUGprt4MWP+i3MJ+6zoRRHewx067nR+gOd9uB+wSpZZyuCVAuLnA97vtL2R YbFICEFmWimb8mKyJddRy6HfP8YoV7FTwTNM20mskxeGppoauHSdQFGxhCn3dp8L17aK8v H56F9EEOevpUT4oIM+zsnOOc22HM0Odm1k4r4JlPYcFqWgRBJ/vo1Nq+pt2+Jg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694516913; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LbBprMwnbPPLEsY2vhOkPL097RyL9EsvHkcx1RT2pw4=; b=d0zORbHSTTua6HBsA/I1aQNGUd7sr6j6/WUvmtW+Avjh6Q1QEJjngBR6dmDsduWldqjpOD X0qNIJp9dRsVSfBQ== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/ibt: Suppress spurious ENDBR Cc: David Kaplan , "Peter Zijlstra (Intel)" , Andrew Cooper , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230802110323.016197440@infradead.org> References: <20230802110323.016197440@infradead.org> MIME-Version: 1.0 Message-ID: <169451691250.27769.12189082412488879527.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 04:09:29 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773124681535054044 X-GMAIL-MSGID: 1776841158653421810 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 70524a25365bab3dfe968691aa436fff765a8dde Gitweb: https://git.kernel.org/tip/70524a25365bab3dfe968691aa436fff765a8dde Author: Peter Zijlstra AuthorDate: Wed, 02 Aug 2023 12:55:46 +02:00 Committer: root CommitterDate: Tue, 12 Sep 2023 12:40:28 +02:00 x86/ibt: Suppress spurious ENDBR It was reported that under certain circumstances GCC emits ENDBR instructions for _THIS_IP_ usage. Specifically, when it appears at the start of a basic block -- but not elsewhere. Since _THIS_IP_ is never used for control flow, these ENDBR instructions are completely superfluous. Override the _THIS_IP_ definition for x86_64 to avoid this. Less ENDBR instructions is better. Fixes: 156ff4a544ae ("x86/ibt: Base IBT bits") Reported-by: David Kaplan Signed-off-by: "Peter Zijlstra (Intel)" Reviewed-by: Andrew Cooper Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20230802110323.016197440@infradead.org --- arch/x86/include/asm/linkage.h | 8 ++++++++ include/linux/instruction_pointer.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h index 97a3de7..5ff49fd 100644 --- a/arch/x86/include/asm/linkage.h +++ b/arch/x86/include/asm/linkage.h @@ -8,6 +8,14 @@ #undef notrace #define notrace __attribute__((no_instrument_function)) +#ifdef CONFIG_64BIT +/* + * The generic version tends to create spurious ENDBR instructions under + * certain conditions. + */ +#define _THIS_IP_ ({ unsigned long __here; asm ("lea 0(%%rip), %0" : "=r" (__here)); __here; }) +#endif + #ifdef CONFIG_X86_32 #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0))) #endif /* CONFIG_X86_32 */ diff --git a/include/linux/instruction_pointer.h b/include/linux/instruction_pointer.h index cda1f70..aa0b3ff 100644 --- a/include/linux/instruction_pointer.h +++ b/include/linux/instruction_pointer.h @@ -2,7 +2,12 @@ #ifndef _LINUX_INSTRUCTION_POINTER_H #define _LINUX_INSTRUCTION_POINTER_H +#include + #define _RET_IP_ (unsigned long)__builtin_return_address(0) + +#ifndef _THIS_IP_ #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) +#endif #endif /* _LINUX_INSTRUCTION_POINTER_H */