Lorenz Bauer
2e2713ae1a
btf: Fix virt_to_phys() on arm64 when mmapping BTF
Breno Leitao reports that arm64 emits the following warning
with CONFIG_DEBUG_VIRTUAL:
[ 58.896157] virt_to_phys used for non-linear address: 000000009fea9737
(__start_BTF+0x0/0x685530)
[ 23.988669] WARNING: CPU: 25 PID: 1442 at arch/arm64/mm/physaddr.c:15
__virt_to_phys (arch/arm64/mm/physaddr.c:?)
...
[ 24.075371] Tainted: [E]=UNSIGNED_MODULE, [N]=TEST
[ 24.080276] Hardware name: Quanta S7GM 20S7GCU0010/S7G MB (CG1), BIOS 3D22
07/03/2024
[ 24.088295] pstate: 63400009 (nZCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
[ 24.098440] pc : __virt_to_phys (arch/arm64/mm/physaddr.c:?)
[ 24.105398] lr : __virt_to_phys (arch/arm64/mm/physaddr.c:?)
...
[ 24.197257] Call trace:
[ 24.199761] __virt_to_phys (arch/arm64/mm/physaddr.c:?) (P)
[ 24.206883] btf_sysfs_vmlinux_mmap (kernel/bpf/sysfs_btf.c:27)
[ 24.214264] sysfs_kf_bin_mmap (fs/sysfs/file.c:179)
[ 24.218536] kernfs_fop_mmap (fs/kernfs/file.c:462)
[ 24.222461] mmap_region (./include/linux/fs.h:? mm/internal.h:167
mm/vma.c:2405 mm/vma.c:2467 mm/vma.c:2622 mm/vma.c:2692)
It seems that the memory layout on arm64 maps the kernel image in vmalloc space
which is different than x86. This makes virt_to_phys emit the warning.
Fix this by translating the address using __pa_symbol as suggested by
Breno instead.
Reported-by: Breno Leitao <leitao@debian.org>
Closes: https://lore.kernel.org/bpf/g2gqhkunbu43awrofzqb4cs4sxkxg2i4eud6p4qziwrdh67q4g@mtw3d3aqfgmb/
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Tested-by: Breno Leitao <leitao@debian>
Fixes: a539e2a6d5 ("btf: Allow mmap of vmlinux btf")
Link: https://lore.kernel.org/r/20250717-vmlinux-mmap-pa-symbol-v1-1-970be6681158@isovalent.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2025-07-17 11:33:52 -07:00
..
2025-07-17 11:33:52 -07:00
2025-06-18 14:25:50 -07:00
2025-06-07 10:05:35 -07:00
2025-04-02 18:17:33 -07:00
2025-05-27 20:09:06 -07:00
2025-04-29 08:27:10 +02:00
2025-06-26 10:50:37 +02:00
2025-06-11 17:24:09 +02:00
2025-04-30 21:53:35 +02:00
2025-06-13 15:36:35 +02:00
2025-05-08 19:49:33 +02:00
2025-05-14 13:16:24 +02:00
2025-06-02 12:24:58 -07:00
2025-06-07 10:05:35 -07:00
2025-05-31 15:44:16 -07:00
2025-03-27 19:22:24 -07:00
2025-06-20 15:31:48 -04:00
2025-06-17 08:19:55 -10:00
2025-06-13 10:55:49 -07:00
2025-06-27 15:51:36 -04:00
2025-02-12 12:24:16 +01:00
2024-02-09 11:13:59 -10:00
2025-06-23 14:01:49 -04:00
2025-04-15 11:32:34 +02:00
2025-04-11 14:14:41 -04:00
2024-10-11 14:34:16 -04:00
2024-12-05 19:22:38 -05:00
2025-03-18 15:34:27 +01:00
2024-06-24 22:24:55 -07:00
2024-04-29 08:29:29 -07:00
2025-03-07 22:03:09 -06:00
2025-03-30 15:44:36 -07:00
2025-03-04 18:44:29 -08:00
2025-05-08 21:50:19 +02:00
2025-02-10 16:56:58 -08:00
2025-05-21 10:48:21 -07:00
2025-05-11 17:54:10 -07:00
2024-12-02 11:25:09 +01:00
2025-05-27 19:40:33 -07:00
2024-02-23 17:48:22 -08:00
2025-06-22 10:11:45 -07:00
2025-05-31 15:44:16 -07:00
2024-10-14 09:14:35 +02:00
2025-03-15 21:22:52 +09:00
2025-05-11 17:54:08 -07:00
2025-02-21 15:05:38 +01:00
2025-01-13 22:40:36 -08:00
2025-03-10 11:54:46 +01:00
2024-07-20 16:33:21 +09:00
2025-01-02 22:12:12 +01:00
2025-02-18 10:16:04 +01:00
2025-02-21 10:25:33 +01:00
2025-02-21 09:20:30 +01:00
2025-06-25 15:55:04 -07:00
2024-11-07 15:25:05 +01:00
2024-12-30 17:59:08 -08:00
2025-04-29 15:54:53 -04:00
2025-03-16 22:30:47 -07:00
2025-05-31 19:12:53 -07:00
2025-06-19 20:48:02 -07:00
2025-05-12 23:50:40 -07:00
2024-04-23 14:59:01 +10:00
2024-12-24 09:46:49 +01:00
2025-03-10 11:54:46 +01:00
2025-01-07 16:59:15 +01:00
2025-06-08 09:07:37 +02:00
2025-01-28 13:48:37 +01:00
2025-05-31 19:12:53 -07:00
2024-11-05 17:12:31 -08:00
2025-05-09 13:13:54 +02:00
2025-05-19 13:44:16 +08:00
2025-05-31 19:12:53 -07:00
2025-05-07 20:24:59 +02:00
2025-03-06 10:18:36 +01:00
2025-01-28 13:48:37 +01:00
2025-05-06 13:59:00 +02:00
2024-08-04 13:36:28 -07:00
2025-05-11 17:48:15 -07:00
2025-04-01 10:06:52 -07:00
2024-04-25 21:07:03 -07:00
2025-05-11 17:54:09 -07:00
2024-10-09 12:47:19 -07:00
2025-03-21 22:10:05 -07:00
2025-03-06 22:26:49 +01:00
2024-11-14 16:09:51 -08:00
2025-02-24 11:17:10 -08:00
2025-04-09 13:32:16 +02:00
2025-01-28 11:34:03 -08:00
2025-03-25 10:46:44 +01:00
2025-01-28 13:48:37 +01:00
2025-03-30 15:44:36 -07:00
2025-03-11 10:15:52 -07:00
2024-07-18 12:19:20 -07:00
2025-05-03 12:02:07 +02:00
2025-04-14 14:13:41 +02:00
2025-04-09 13:32:16 +02:00
2025-01-13 22:40:36 -08:00
2024-11-03 01:28:06 -05:00
2025-02-05 07:14:24 -08:00
2025-03-21 15:30:10 -04:00
2024-07-12 16:39:53 -07:00
2025-03-16 22:30:50 -07:00
2025-01-28 13:48:37 +01:00
2025-02-12 12:12:27 +01:00
2024-09-12 12:16:09 +02:00
2025-01-28 13:48:37 +01:00
2025-04-18 10:08:11 -04:00
2025-05-11 17:54:04 -07:00
2025-03-24 09:52:37 -07:00
2025-04-01 10:06:52 -07:00
2025-05-21 10:48:22 -07:00
2025-06-17 08:58:29 -10:00