From patchwork Fri Sep 22 09:51:51 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: 143322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5449317vqi; Fri, 22 Sep 2023 03:07:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNPHkZHa1BRbXrnDJ8PCy/6UPNSaz23uHnl9q6zRCQnFYuF2Db2llxy75Sa8jw4b8bqiuD X-Received: by 2002:a05:6a00:2d16:b0:68f:b7f6:f1df with SMTP id fa22-20020a056a002d1600b0068fb7f6f1dfmr9350887pfb.5.1695377232742; Fri, 22 Sep 2023 03:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695377232; cv=none; d=google.com; s=arc-20160816; b=rHd0RJwkPmjagO4LwaMhraUJaKgCUDPGSTwhaoqSvJJEdmaPeuveUG7OV/1XSVRXlO gmdhzR0jlkCV6K8/Ef8/iFEWbm7phGMq+Nzr/gpYZnoHguHRiWiub0aPTaJLoQniVzAc XAiOfxTPxAI9+vnTbJP+k9jnOMCl51anWZSPJqPkU2M0riIHhtIXvaRPSSHQrKDMz58X jsjRCQl1ZrfXhWh0bXVzYQCGlxBRNfGf6IEBLrZxBKnUmSr8gCX3Vb3HxcVCsztfmouv VoKZsKCcBrgjRN0ceAYwdvh4dhxoZYtGzYUuVPx+xPD5S1xGiUor3JIZfo9INhYYMDn8 PUlg== 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=ZpjFuO3kpiiRuhS3uCerH9ELrQfzhc9H6B9pLwV5SGs=; fh=VYTEYV7Cgw+e+BVQTRR4fwUZXDAWCPRpZ2wKmgGjK08=; b=d1Kh3jSyAY+7BrwvALD4hWztcoY3pEOT3HKFyR8KIDJk6TcrhnLc2DPIdW+h6UkzLg E8yn/rqV6A/ZeX3HsAyVRknGc7B4pubM3PoENY238qUDx8ooYRzXhOywGzAQrDd+KVV4 Ghvf6phWnvzo2vSiosVNNwM+Nf+79nYiDv1xa1OROhjSZSBmgOcQrZZyQQ3rX2kWjY26 CqE4u3pj8NuM9crTyl1Djaz3yPO5uH15EDJgU6a6LifKGXbWcQ/rYZgER19X6wxJz5iY RfpTC9v9+Te251pRkaq3CTvDoQmPrSBfBEHhwiHWHFxK0Abk5Go+dW7W/xTrnRRkKNW0 Kg2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2Hqy11VP; 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:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id bs70-20020a632849000000b00578af607626si3373348pgb.668.2023.09.22.03.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 03:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2Hqy11VP; 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:1 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 morse.vger.email (Postfix) with ESMTP id 1C96A83AEE1F; Fri, 22 Sep 2023 02:52:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229539AbjIVJwB (ORCPT + 30 others); Fri, 22 Sep 2023 05:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbjIVJwA (ORCPT ); Fri, 22 Sep 2023 05:52:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17556192; Fri, 22 Sep 2023 02:51:54 -0700 (PDT) Date: Fri, 22 Sep 2023 09:51:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695376312; 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=ZpjFuO3kpiiRuhS3uCerH9ELrQfzhc9H6B9pLwV5SGs=; b=2Hqy11VPsKyGPCH5XHyDoo7oM2X0pwaFlmSU4vCYL7GMZ8E52TxkhhkaRTWXTrqJlhUDoB 4iHLOhwvirobikr+j9hcf7Py/4SkHM9Pv8q7PbewqQbQX2xY80fRXcJFfkKLsqnKy4ghzv Qxn7X7UTF79p75tfBqtsy5SksasgmxmPeI/bwJx+7rQbYL/v4L4wupU/QMiPdlfyy7EXCe ZYfm8SmAYhoBhdY30ycFeBA1CB4IjlYkXQ01kC0Zvr8wfaMlfEpyJsBduWIsqg06zcOZh7 WHRjzoJ8kRdz/E00dZDNyIFNCOz49F9duYYo3Kbt3QfIkMg8jQFEeohjpG21uQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695376312; 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=ZpjFuO3kpiiRuhS3uCerH9ELrQfzhc9H6B9pLwV5SGs=; b=DrJyloPynzJbN7llHszpoQESUQkxcT5a5g6Qs9J4JRjGoHUpt7Ic6CWGSKRxtPxFBqf4qC AsEXkxZaHW1p1LCg== From: "tip-bot2 for Fangrui Song" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] x86/speculation, objtool: Use absolute relocations for annotations Cc: Fangrui Song , Ingo Molnar , "Peter Zijlstra (Intel)" , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230920001728.1439947-1-maskray@google.com> References: <20230920001728.1439947-1-maskray@google.com> MIME-Version: 1.0 Message-ID: <169537631186.27769.11892799557376863263.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Fri, 22 Sep 2023 02:52:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777513634464936459 X-GMAIL-MSGID: 1777731876971406374 The following commit has been merged into the objtool/core branch of tip: Commit-ID: b8ec60e1186cdcfce41e7db4c827cb107e459002 Gitweb: https://git.kernel.org/tip/b8ec60e1186cdcfce41e7db4c827cb107e459002 Author: Fangrui Song AuthorDate: Tue, 19 Sep 2023 17:17:28 -07:00 Committer: Ingo Molnar CommitterDate: Fri, 22 Sep 2023 11:41:24 +02:00 x86/speculation, objtool: Use absolute relocations for annotations .discard.retpoline_safe sections do not have the SHF_ALLOC flag. These sections referencing text sections' STT_SECTION symbols with PC-relative relocations like R_386_PC32 [0] is conceptually not suitable. Newer LLD will report warnings for REL relocations even for relocatable links [1]: ld.lld: warning: vmlinux.a(drivers/i2c/busses/i2c-i801.o):(.discard.retpoline_safe+0x120): has non-ABS relocation R_386_PC32 against symbol '' Switch to absolute relocations instead, which indicate link-time addresses. In a relocatable link, these addresses are also output section offsets, used by checks in tools/objtool/check.c. When linking vmlinux, these .discard.* sections will be discarded, therefore it is not a problem that R_X86_64_32 cannot represent a kernel address. Alternatively, we could set the SHF_ALLOC flag for .discard.* sections, but I think non-SHF_ALLOC for sections to be discarded makes more sense. Note: if we decide to never support REL architectures (e.g. arm, i386), we can utilize R_*_NONE relocations (.reloc ., BFD_RELOC_NONE, sym), making .discard.* sections zero-sized. That said, the section content waste is 4 bytes per entry, much smaller than sizeof(Elf{32,64}_Rel). [0] commit 1c0c1faf5692 ("objtool: Use relative pointers for annotations") [1] https://github.com/ClangBuiltLinux/linux/issues/1937 Signed-off-by: Fangrui Song Signed-off-by: Ingo Molnar Acked-by: Peter Zijlstra (Intel) Cc: Josh Poimboeuf Link: https://lore.kernel.org/r/20230920001728.1439947-1-maskray@google.com --- arch/x86/include/asm/alternative.h | 4 ++-- arch/x86/include/asm/nospec-branch.h | 4 ++-- include/linux/objtool.h | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 9c4da69..65f7909 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -58,7 +58,7 @@ #define ANNOTATE_IGNORE_ALTERNATIVE \ "999:\n\t" \ ".pushsection .discard.ignore_alts\n\t" \ - ".long 999b - .\n\t" \ + ".long 999b\n\t" \ ".popsection\n\t" /* @@ -352,7 +352,7 @@ static inline int alternatives_text_reserved(void *start, void *end) .macro ANNOTATE_IGNORE_ALTERNATIVE .Lannotate_\@: .pushsection .discard.ignore_alts - .long .Lannotate_\@ - . + .long .Lannotate_\@ .popsection .endm diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index c55cc24..4952b73 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -196,7 +196,7 @@ .macro ANNOTATE_RETPOLINE_SAFE .Lhere_\@: .pushsection .discard.retpoline_safe - .long .Lhere_\@ - . + .long .Lhere_\@ .popsection .endm @@ -334,7 +334,7 @@ #define ANNOTATE_RETPOLINE_SAFE \ "999:\n\t" \ ".pushsection .discard.retpoline_safe\n\t" \ - ".long 999b - .\n\t" \ + ".long 999b\n\t" \ ".popsection\n\t" typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE]; diff --git a/include/linux/objtool.h b/include/linux/objtool.h index 03f82c2..6f6da95 100644 --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -48,13 +48,13 @@ #define ANNOTATE_NOENDBR \ "986: \n\t" \ ".pushsection .discard.noendbr\n\t" \ - ".long 986b - .\n\t" \ + ".long 986b\n\t" \ ".popsection\n\t" #define ASM_REACHABLE \ "998:\n\t" \ ".pushsection .discard.reachable\n\t" \ - ".long 998b - .\n\t" \ + ".long 998b\n\t" \ ".popsection\n\t" #else /* __ASSEMBLY__ */ @@ -66,7 +66,7 @@ #define ANNOTATE_INTRA_FUNCTION_CALL \ 999: \ .pushsection .discard.intra_function_calls; \ - .long 999b - .; \ + .long 999b; \ .popsection; /* @@ -118,7 +118,7 @@ .macro ANNOTATE_NOENDBR .Lhere_\@: .pushsection .discard.noendbr - .long .Lhere_\@ - . + .long .Lhere_\@ .popsection .endm @@ -141,7 +141,7 @@ .macro REACHABLE .Lhere_\@: .pushsection .discard.reachable - .long .Lhere_\@ - . + .long .Lhere_\@ .popsection .endm