Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2656506rdb; Fri, 22 Sep 2023 05:15:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEO0mwKsNZXstyPBb/Nkn0BAle6OQxj5bh19GHdYW1iTmLKD7mRvWXQJhb/sKroZsR7somi X-Received: by 2002:a05:6358:284:b0:143:1063:d1ed with SMTP id w4-20020a056358028400b001431063d1edmr9378505rwj.26.1695384951749; Fri, 22 Sep 2023 05:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695384951; cv=none; d=google.com; s=arc-20160816; b=FEXmSiebMrZdFxEqzR3punGOJZ2COWRuAJiozvEWjxXT1CtTDW7QjlqHhnC2EIiNwD 4mtjDxeT0PsZ1qZ8/0FCDjzVS13JTBVjJGcb3JnNO7HHdTxIrWaIIfsv2XTe4Ej0zfjs YVtEOsdb+OwYG8eCcaELPvp32/TaOTub1LdKq05R13D/zWsBGWIIQ5Yt3Ist8UT3RIDP XsQn+auohBzFg7KNIcn4+jKqlYaLUPttuS0h3L65cRxQUbiJXGBsNVJCA044s3joazf+ aSZZHoE6aivuCInUIbuhWPB/VpQFeN37C8Wnzor6/ou9a9Ci4Ryo2Smb98pBxr6k/T+a n9RA== 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; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 144-20020a630096000000b005780b4905f1si3688073pga.460.2023.09.22.05.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 05:15:51 -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=2Hqy11VP; dkim=neutral (no key) header.i=@linutronix.de; 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 3476D82D87BF; Fri, 22 Sep 2023 02:52:01 -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 S231384AbjIVJwB (ORCPT + 99 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 22 Sep 2023 02:52:01 -0700 (PDT) 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