Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp207997rdb; Mon, 22 Jan 2024 01:13:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyZ5X+W4vD4dp53P/Tfr98cn7wPJBPPceD3TO/HlENFQPAaby6jBx7yGUOe9ibnXDAH86j X-Received: by 2002:a05:6214:ac5:b0:681:7c2b:d86e with SMTP id g5-20020a0562140ac500b006817c2bd86emr7343873qvi.114.1705914818809; Mon, 22 Jan 2024 01:13:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705914818; cv=pass; d=google.com; s=arc-20160816; b=NSplGE5TOyGZmJZYtdWiZBCXKqrvE9zfQuBe6WxhnjWV2DlT4B7MimiXU2JVHUYR+S 3n1bP3MYOfF+30C3eLCBmDMB5Mpjtf4b7fmKUQ+WXS4oYtJ5JgFKzeizIoLCFGSz+riS cs80OCeYzpIoZnPQ5cDjNmpL7LQ0aphtIW6quaRnjT2CgVLTxuup9DBd7HN39jbkBAtT OMMDwqVEwPimZkO/0fXJ/rU5rGF2VKo1LtfLtp49ZLHPmoJ3n03eoF9BjRPsF5b7vLPm 12zeTwm3PXgm6nvn4tnbd/yteWEYp9+2MFbSb7r5Q+HvG36OF6yEwHDAJJrERLo27IUh U7JQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=anpwjJFJvKmui4DbRVFl+bq/czyO2Fw5IsMP2KX6EWQ=; fh=48HUvOMbKpeHraf1klkRburnyvYvg0IkDo40jTOEaFs=; b=Rn0lltVPKT962ZOj93ZxLFEl84xLaw35L3qpXxjV8UwusaRoi9qGC7ageJF1Ae6bif ySbx1DFqIrm+y15t6Ba5OSSNinh+/yj4sMa3YzTx5pqT4rhUtK5wWjtp5NUZu0WqPEGz /xmfsC26KYLFnzQgan5HOpwDY8XUvCS0y3x7GCT+wPgDElQ5AFx2s9zushvvZTnrpLBX J6suHElxp3j/kbuIqdaQwMpc4icwu1VI/n1uD2a7Hoqs9hlNCr0jNVlrBEKvu/mH9syB V/PuTHsXb/vylg7k2ye+ekKw+t+G7hKyV00HIV89+QVnCjLC7PePcIMo8DgY3aiPL0sG /8Rg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jLmcULa1; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-32601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32601-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x27-20020a0cb21b000000b0067f0aa02082si5262076qvd.268.2024.01.22.01.13.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 01:13:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jLmcULa1; arc=pass (i=1 spf=pass spfdomain=flex--ardb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-32601-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32601-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 902151C24213 for ; Mon, 22 Jan 2024 09:13:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59CC839FED; Mon, 22 Jan 2024 09:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jLmcULa1" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A45239852 for ; Mon, 22 Jan 2024 09:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705914772; cv=none; b=nsBnguFs3XL5Pne+puROHYqiQGJkw5fRnmepV2lhch2a+rVHHzMIDi0O4k7wlcFIZNMxn3WTc3A+XYYSvYDYAg0gIhg2DBsovR7iKvR1Cr8ogW0lG2mXYAX8V3EIdqY7AKKu6DHh1uddfXI9INVojvqBJKMmOmHw/XJPxcqSNDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705914772; c=relaxed/simple; bh=7WqvfI2V9xt/Od2Zwwt1owQ25hJdvvX/uuPnR9lgy1Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AVmzjKWJPlwnOleqBPIKjEG2lD5QBoC0wPKtg21YyaA/yAehLjcunkSTFtjnZZZrBfEwZf+raSaPNy4QYbNVRTYXHXW8XCPlGOwBC0EFMqnVJThLzxO8jky8cqZ4Ppg+wdIHAsCluZ5imlY9Y8QMaOU/HRrYaciZgMPJsNpmrxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jLmcULa1; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbe9dacc912so3473093276.2 for ; Mon, 22 Jan 2024 01:12:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705914770; x=1706519570; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=anpwjJFJvKmui4DbRVFl+bq/czyO2Fw5IsMP2KX6EWQ=; b=jLmcULa1WyQQmLpq+xiWSpwC4o/CGgXinM1ss1d9caPF2VERjWmSGEpW2QB+S9PBBn AdzGNiMS7rOxsekj2iRm+BXlDHvdRxfiwR1P7JR5gBzkC8YUsXuME8svP7Zn/dyg/U/k 0s+X3BNQyQCW6EEoZjd9S9Wsk3Kv2orP3IdXVWJ+RS0N2eCg+OySHK0MbjsjUheKOxfq lf0ULmV8tXBpZ/p/pYGwqk2A+3vp5S50erpiHKQItMYQKksz2/TeTTYzyzeU3bdsJCYC Kf6Nwco7FcKxOBa6DYUZs/n1BxgsM3om31rgI5caY0HbKPkfJvJ+WRFgTIjfiZ3E64WU Jl4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705914770; x=1706519570; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=anpwjJFJvKmui4DbRVFl+bq/czyO2Fw5IsMP2KX6EWQ=; b=hv854aYOMJwXQCAjwq/0/XHRpdtxF77eUi6bXYCi3rb1ePmC7zAKe9w0ZuaD9SlHmh +vEMaplgMlKmdowzEfbQ2nvIiLmmo5XiWQ1f9FfI4ypvAwHivxMey7Z4X/frQvtXltVq EopNxUqSw5wP8ZZ6tw2bSwE3MiBw/rjqzr8iGakLxm4jB1VDF2aQoOS3aaq5+0RBoEj4 tjBl305jE7gSqbUA3+e9rzISuV4Ew3iTBJjU+cIieU9jKvQtYRcFkuri7WY7HO0VtfH7 5ieV4KFzTxVmbK71QCTSL2p3l4JgYWiqvxWZRhKFIsIQ69dNVCBDA60GHSnHGRxA+kCm 5WAA== X-Gm-Message-State: AOJu0YwXpjkI/Ti7LT/kc9LxXtOtHl827pf/H2W+Em+umCEzsSGWq/Tl E7llfI1Aha/dHyJ2NqobWyinjq+a/BQx55A2obLP2IE5vPEctUhKLOaIMn1GdI2J8lECbH5rwnC +Od6VkuEJ36PO68lp+nXrs7MEwd9Yus7Q5UjZUlfShwZr/jQ2m1S4H2xuaPDz4CzMKsI4oTGRfh n7xx23YtcIbyTpgRVzsmrPs3SulSJafQ== X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:6902:1808:b0:dc2:3426:c9ee with SMTP id cf8-20020a056902180800b00dc23426c9eemr240839ybb.11.1705914769920; Mon, 22 Jan 2024 01:12:49 -0800 (PST) Date: Mon, 22 Jan 2024 10:08:55 +0100 In-Reply-To: <20240122090851.851120-7-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240122090851.851120-7-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1581; i=ardb@kernel.org; h=from:subject; bh=thQkn6eFYWU4rIO38nRY5rSfaRiPUJPmqajniqH14XU=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXWdwXL25bMmmm1ZFF9evWDmkTcTIha1sGp3zPaal+6zr 4qB+1xVRykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZjIGztGhtPFZyb/Xb5FN/f7 90CdRWd52mdPLC3t2LdyTaY67xfrJysZ/gpIeM4/a/g0Y3fTyS5Nqasbk9+o34rxme419eRVjen fGRkA X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240122090851.851120-10-ardb+git@google.com> Subject: [RFC PATCH 3/5] btf: Avoid weak external references From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Kevin Loughlin , Tom Lendacky , Dionna Glaze , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Arnd Bergmann , Martin KaFai Lau , Nathan Chancellor , Nick Desaulniers , Justin Stitt , linux-arch@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" From: Ard Biesheuvel If the BTF code is enabled in the build configuration, the start/stop BTF markers are guaranteed to exist in the final link but not during the first linker pass. Avoid GOT based relocations to these markers in the final executable by providing preliminary definitions that will be used by the first linker pass, and superseded by the actual definitions in the subsequent ones. Signed-off-by: Ard Biesheuvel --- include/asm-generic/vmlinux.lds.h | 2 ++ kernel/bpf/btf.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index a39e050416c7..ef45331fb043 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -456,6 +456,8 @@ * independent code. */ #define PRELIMINARY_SYMBOL_DEFINITIONS \ + PROVIDE(__start_BTF = .); \ + PROVIDE(__stop_BTF = .); \ PROVIDE(kallsyms_addresses = .); \ PROVIDE(kallsyms_offsets = .); \ PROVIDE(kallsyms_names = .); \ diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 596471189176..a659fc7045bb 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -5581,8 +5581,8 @@ static struct btf *btf_parse(const union bpf_attr *attr, bpfptr_t uattr, u32 uat return ERR_PTR(err); } -extern char __weak __start_BTF[]; -extern char __weak __stop_BTF[]; +extern char __start_BTF[]; +extern char __stop_BTF[]; extern struct btf *btf_vmlinux; #define BPF_MAP_TYPE(_id, _ops) -- 2.43.0.429.g432eaa2c6b-goog