From patchwork Tue Sep 12 15:54:48 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: 138411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp646373vqx; Tue, 12 Sep 2023 12:57:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH9W4uAnKK5s0BAa637J0YEjAUDCCtO+7wi+ymlaMPVPhxb+xvc3c95SzEAhFPBelXrVaW X-Received: by 2002:a17:90b:4b52:b0:26b:9e2:1298 with SMTP id mi18-20020a17090b4b5200b0026b09e21298mr320298pjb.11.1694548638522; Tue, 12 Sep 2023 12:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694548638; cv=none; d=google.com; s=arc-20160816; b=WAm958W4aJPLkQeqC+5XtckGL9JfEpEW8KuqMx4DQX4wiBw5wGmtYAvZYhReAGIPrP 0c7HUn0l2VTQBc7IOweCVhjqLjsH6qHIRwxn5FOz8lHG7IdXBoZnrxdLuM3Aba0Rc3IG 2sxWXhu9wqht9BjzJ+hRQlrsrfMihMpzRDrYiNaE5/TeUJxkK5AIHcPVtIvwIF+DrGMZ OCFDohPqjTtlp2crrOQ+8S0FCoC6CwCE+ZproFBvnLkyY2uH3g0egpJdmITzKo47Y4Su i2qWp3OZ3y29g0pMKiVNZ7Ryl7D63RtfcCIwCP06oZ5vh5XZn49oo48qYi7qKz2KAlIX SuZA== 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=p1oFME0Jidi+UhsgoJHi2a1vbMzwZWMIBlYUJ39K9aE=; fh=L56StNRzXuSzVo2KhCwSajCxRRiMkXPwmoXp7xQJOm8=; b=TIdNX03hda1Yp2VE6hYHczduokT2jxerYH4jwojbMxC5NAe5gSy/uOJ8ZSxMWEm5Up e1yx1rGPC2kM9itleqeNiC/UvF7VYFO/5Ks5lt+5Urmg8KBcn+bE3ubET/Bs6TGUZmAS zlpUD9dVbdZBivswss2QSW/CbpsN1l+fkuo+UPrX9YzzFv5DGvkkYfQRFDKiI7jFeyGe sxX5AGELfXFKxfGgbtUx9kBRgAByIYFk7HJJI9AjJkbzuM/m1E0L/vQlgFzfc1/H/Qmd AYc09G+sVaj34o2P48GCZhvJCXwn3UliBLLodRoxbSC858hmdhdwIY+LzbT6zGI4KRrk wNqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eNXCYq99; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fIlPD4oX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z21-20020a17090ab11500b0026cf0b7e813si10490397pjq.94.2023.09.12.12.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 12:57:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eNXCYq99; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fIlPD4oX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 3D9338249F4E; Tue, 12 Sep 2023 08:55:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236523AbjILPy6 (ORCPT + 37 others); Tue, 12 Sep 2023 11:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236472AbjILPyy (ORCPT ); Tue, 12 Sep 2023 11:54:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986D610E5; Tue, 12 Sep 2023 08:54:50 -0700 (PDT) Date: Tue, 12 Sep 2023 15:54:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694534089; 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=p1oFME0Jidi+UhsgoJHi2a1vbMzwZWMIBlYUJ39K9aE=; b=eNXCYq99ULs6Y60luIxFjl8OvocUbXFYup8bSXjvS4HP/Bse4UCtkBJ4s/Qlb7BfoeP2Ri lrQq211O+HKbkxR61+vkY75J7iB17+XXi3JhOMYZCLVnK6BkCiUdBBBoexaduDWJQiVdlw PfTifjCSvLA8EY7Ttno/ZGOK4GmF/HR3KlpDn+l3odwsHEFzUKLHh9OdbmbJyQXPXfQJHI nO5Mk5hOjtloQxtX7IYq9jpz9IoNKjqer4Q5iT7tW4VzrJtPYfsmHX3wk8sdydERzf8xkE IMf3otlldRZZkUUzW8CFZ06l1vi05J0+kpeITtq41e6Z+0Q97la3ESsPsrTQsg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694534089; 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=p1oFME0Jidi+UhsgoJHi2a1vbMzwZWMIBlYUJ39K9aE=; b=fIlPD4oX0BS2szKgNnVsgHJ0aUfJAvnsvGa/TchcpVEBLbXG2aSQ6KHFZ/WS9tRmwDDBRa 34sQuKX43Jr4KkCw== 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 , Andrew Cooper , "Peter Zijlstra (Intel)" , Ingo Molnar , 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: <169453408866.27769.11485253343334355054.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 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 08:55:18 -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 fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773124681535054044 X-GMAIL-MSGID: 1776863033383639255 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 25e73b7e3f72a25aa30cbb2eecb49036e0acf066 Gitweb: https://git.kernel.org/tip/25e73b7e3f72a25aa30cbb2eecb49036e0acf066 Author: Peter Zijlstra AuthorDate: Wed, 02 Aug 2023 12:55:46 +02:00 Committer: Ingo Molnar CommitterDate: Tue, 12 Sep 2023 17:50:53 +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 Reviewed-by: Andrew Cooper Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar 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 */