From patchwork Mon Jun 3 12:16:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 13683730 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 92A17129E8E for ; Mon, 3 Jun 2024 12:16:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717417013; cv=none; b=p1oYKd29ub6EfUZDCgiEydg0hPWWkYIexlv+eRxhFyJ7bAYHX+P4rUQlLtmIbni0+y+w/gUU9Og8qR1ryK3dK+DnzWZ41kTz4diBx7JoBdW6CJO/7lQKKwqyquW4bLXb06fMs5P02c0upAzbaVgT9nexbu8AfUY6js7JZflM5/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717417013; c=relaxed/simple; bh=LNoei3GA72yWTn14T/waYC4yTMKAPFmkf5G5r+ZC/y8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O/rMsrPSR7hC9wlN5e/P4w74kr/MfCtqE/wu2El7VVrMAeo1pN0o6zMGxdsqxOKm81QW7H7+DUYr7+KcgM/5hxtx65x6WAcGvQTVdDIzXqub/gVpPlXD0aqMSZOxnmEXM4pAqrnXrBt44amOJ2VQtdJPT3YpIdn53kc5Mrf+ghw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ApD1On5A; arc=none smtp.client-ip=209.85.215.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ApD1On5A" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-6c5bcb8e8edso2168582a12.2 for ; Mon, 03 Jun 2024 05:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717417012; x=1718021812; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bc+5KmXQdR0YlvxYXrkRiQKWN0U+4M+4EeM39qU+Hik=; b=ApD1On5Ax3/2fhWa95FtmoEEy98z9KJpsjXhtbioHEbQceHFzgY958RpplYJXkmJYe +EksZ+nPEPuBVL0wBN9Lj2rIL61Pcg471Jp+kJ7cRozKOWp4Lub0tvUmbZIJudTSor0v rea7Nqp1DcIEU+1c6hnavj04KxCBPZRWDjK4wzXpvRy3ej/mEts/i0xQJkKCG0WcOnJq jFZMxzgdsbqMgXK/7JKCIqEB3+YOKzs3t089kFAbQVn/LS9R2JF57GYcccsfRH2QY+Np AYp6EpjnTVQERn4kJ01miQNXCbFmLhHOK+vKADQ1u0my+OODeAK9v4DEb8vqSj7Mj4y+ tskg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717417012; x=1718021812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bc+5KmXQdR0YlvxYXrkRiQKWN0U+4M+4EeM39qU+Hik=; b=w8AEp3LAkAR/CqZjF6Tb3y7mlbrujegSANSEkFygINz/G3c4OwCNwiGqzOt1mEVLrg 7WHfIXUPEL4B6Q+j61Rk9Os7Hy7NeyQMbXrICixfhOEuOzozdps4Zq7jmd8xpXek774F OCNXkp+AVd3weXQA0Ecz2lJzJp8yswW2te0A9gImCExIvh8GdNnoJrcNMJGq2Z9Osl8H Fdf0c7iN9lUvJiSVFuLZwhW0+0dGxXSQ3qaqwc0glK603v5IgYl1axnFvWUlVVxbECo6 aQfQqYtyq8rYmivvwpmJ/G1oIu31iN2+r2avskVcTEN8tDL5BQj3ijzSOyJgVfCfx7ju AeTw== X-Gm-Message-State: AOJu0Yy7fi5DQtxiOj1q+88Fju5dYjEY2TUOqcBNBMoBSv1jIDIx+TYK USHVZfxbmjS5TBND5l62Fh/7WO0GuvFMJz2lRMckeSVfXqRQVfx3ce7wPnNI X-Google-Smtp-Source: AGHT+IEX6nH+nI/tT/+hqygCT8QWW2tEToeh28Qjj6OFPlxyn7Hta7o0eiSAp9SiO44jQYZWbGWngQ== X-Received: by 2002:a17:90b:5350:b0:2bf:e6f1:59e9 with SMTP id 98e67ed59e1d1-2c1dc5921b1mr7871408a91.20.1717417011604; Mon, 03 Jun 2024 05:16:51 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a776f526sm8340820a91.13.2024.06.03.05.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 05:16:51 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Miguel Ojeda Subject: [PATCH bpf v1 0/2] bpf: Fix linker optimization removing kfuncs Date: Mon, 3 Jun 2024 05:16:42 -0700 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net This patch series fixes unwanted stripping of kernel kfuncs during linker optimization, as indicated by build warnings from resolve_btfids e.g. "WARN: resolve_btfids: unresolved symbol ...". This can happen because the __bpf_kfunc macro annotating kfunc declarations is ignored during linking. Patch 1 adds support for the compiler attribute "__retain__", used to avoid linker garbage cleanup. Patch 2 then updates __bpf_kfunc to use this attribute when LTO builds are enabled. Tony Ambardar (2): Compiler Attributes: Add __retain macro bpf: Harden __bpf_kfunc tag against linker kfunc removal include/linux/btf.h | 2 +- include/linux/compiler_attributes.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)