From patchwork Thu Jun 20 09:17:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Maguire X-Patchwork-Id: 13705019 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42A6E3D0AD for ; Thu, 20 Jun 2024 09:18:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718875100; cv=none; b=BVxcgZ4l2rzO1vibB4f9niJ6dhH7h9a4yoXCzLwXAxZkziMxAkGgIwcJc39ZUoZ8Kka/24YCnOWqfYBVg9vyRz9PcskZaH0TqOEfeq2iS7CMmGUlRlQtpuRh8doEN0xwQeKKA9Ks6UrEka6eijAzu8Aa0AaoIOtoJx8G9MW+svU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718875100; c=relaxed/simple; bh=GBwRRzABQZMdoZGRAiWcuqYhW7VQiCncKXlfz9WLoFk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gxoex7wgAgco7AcBZknQ+6KmYM9P2RQH9cCw+3mOYiPXZrY3BHgVF6GhOwlXO1U8hMoHy/sSMlq6elQdVfAP7/ltnexD5gBZaInr+fVVQoBvXnfdMPorAUK47qm/8N1t3HjFWr8AuvzOk0QOVgn2gNqSyRaeyjLazA1vCOA9PBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=C9JkmAo/; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="C9JkmAo/" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45K5FFIk005911; Thu, 20 Jun 2024 09:17:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=h hQLG69H4xRs/OD6xZ+c1TlTQunnjWNZRPWtiQoVigY=; b=C9JkmAo/t2J3xSjKs PM8nBgtGshqzex7uLYiIKm21CZ+smOrPmyXRNs2GMcmQJ50O2I2zRCnRkHwgDtNM Dmg9HnNikKdnL5/efS03UhWzMbQA7KPNFmOSQQjRJpo8YDNTTgU1RTNXFawHF2kp i/mxRW+nGKBwfG7EPm78jXbtMMljreOI/3fy9ZbSrHkD+6Q+XfvJKJf5rg2QJFH1 arJc0/G9I4FK0+YBCot9wmaU4I1ov1VwN/eestHP6KwUZEMBKBYFdwb4ATv/Od0Z 28d11QB5NQHZ/rkTHhgaR8z2vv75zzxNqDSz4kJD90ZMPB4fg8dVccGEv3FXBS8K NWGjQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3yuj9jarh1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jun 2024 09:17:52 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45K8CAUB032921; Thu, 20 Jun 2024 09:17:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1da76c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jun 2024 09:17:51 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 45K9HdGH028275; Thu, 20 Jun 2024 09:17:50 GMT Received: from bpf.uk.oracle.com (dhcp-10-175-186-70.vpn.oracle.com [10.175.186.70]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3ys1da764t-3; Thu, 20 Jun 2024 09:17:50 +0000 From: Alan Maguire To: andrii@kernel.org, eddyz87@gmail.com Cc: acme@redhat.com, ast@kernel.org, daniel@iogearbox.net, jolsa@kernel.org, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, mykolal@fb.com, thinker.li@gmail.com, bentiss@kernel.org, tanggeliang@kylinos.cn, bpf@vger.kernel.org, Alan Maguire Subject: [PATCH v2 bpf-next 2/6] module, bpf: store BTF base pointer in struct module Date: Thu, 20 Jun 2024 10:17:29 +0100 Message-ID: <20240620091733.1967885-3-alan.maguire@oracle.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240620091733.1967885-1-alan.maguire@oracle.com> References: <20240620091733.1967885-1-alan.maguire@oracle.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-20_06,2024-06-19_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406200065 X-Proofpoint-GUID: 00Prt4b-xI-jRnGtypUukBNL8XDo3LE0 X-Proofpoint-ORIG-GUID: 00Prt4b-xI-jRnGtypUukBNL8XDo3LE0 X-Patchwork-Delegate: bpf@iogearbox.net ...as this will allow split BTF modules with a base BTF representation (rather than the full vmlinux BTF at time of BTF encoding) to resolve their references to kernel types in a way that is more resilient to small changes in kernel types. This will allow modules that are not built every time the kernel is to provide more resilient BTF, rather than have it invalidated every time BTF ids for core kernel types change. Fields are ordered to avoid holes in struct module. Signed-off-by: Alan Maguire Reviewed-by: Luis Chamberlain Acked-by: Andrii Nakryiko --- include/linux/module.h | 2 ++ kernel/module/main.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/module.h b/include/linux/module.h index ffa1c603163c..b79d926cae8a 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -509,7 +509,9 @@ struct module { #endif #ifdef CONFIG_DEBUG_INFO_BTF_MODULES unsigned int btf_data_size; + unsigned int btf_base_data_size; void *btf_data; + void *btf_base_data; #endif #ifdef CONFIG_JUMP_LABEL struct jump_entry *jump_entries; diff --git a/kernel/module/main.c b/kernel/module/main.c index d18a94b973e1..d9592195c5bb 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -2166,6 +2166,8 @@ static int find_module_sections(struct module *mod, struct load_info *info) #endif #ifdef CONFIG_DEBUG_INFO_BTF_MODULES mod->btf_data = any_section_objs(info, ".BTF", 1, &mod->btf_data_size); + mod->btf_base_data = any_section_objs(info, ".BTF.base", 1, + &mod->btf_base_data_size); #endif #ifdef CONFIG_JUMP_LABEL mod->jump_entries = section_objs(info, "__jump_table", @@ -2590,8 +2592,9 @@ static noinline int do_init_module(struct module *mod) } #ifdef CONFIG_DEBUG_INFO_BTF_MODULES - /* .BTF is not SHF_ALLOC and will get removed, so sanitize pointer */ + /* .BTF is not SHF_ALLOC and will get removed, so sanitize pointers */ mod->btf_data = NULL; + mod->btf_base_data = NULL; #endif /* * We want to free module_init, but be aware that kallsyms may be