Macro PAGE_OFFSET(0xffff880000000000) in sampleip_user.c is inaccurate,
for example, in aarch64 architecture, this value depends on the
CONFIG_ARM64_VA_BITS compilation configuration, this value defaults to 48,
the corresponding PAGE_OFFSET is 0xffff800000000000, if we use the value
defined in sampleip_user.c, then all KSYMs obtained by sampleip are (user)
Symbol error due to PAGE_OFFSET error:
$ sudo ./sampleip 1
Sampling at 99 Hertz for 1 seconds. Ctrl-C also ends.
ADDR KSYM COUNT
0xffff80000810ceb8 (user) 1
0xffffb28ec880 (user) 1
0xffff8000080c82b8 (user) 1
0xffffb23fed24 (user) 1
0xffffb28944fc (user) 1
0xffff8000084628bc (user) 1
0xffffb2a935c0 (user) 1
0xffff80000844677c (user) 1
0xffff80000857a3a4 (user) 1
...
A few examples of addresses in the CONFIG_ARM64_VA_BITS=48 environment in
the aarch64 environment:
$ sudo head /proc/kallsyms
ffff8000080a0000 T _text
ffff8000080b0000 t gic_handle_irq
ffff8000080b0000 T _stext
ffff8000080b0000 T __irqentry_text_start
ffff8000080b00b0 t gic_handle_irq
ffff8000080b0230 t gic_handle_irq
ffff8000080b03b4 T __irqentry_text_end
ffff8000080b03b8 T __softirqentry_text_start
ffff8000080b03c0 T __do_softirq
ffff8000080b0718 T __entry_text_start
We just need to replace the PAGE_OFFSET with the address _text in
/proc/kallsyms to solve this problem:
$ sudo ./sampleip 1
Sampling at 99 Hertz for 1 seconds. Ctrl-C also ends.
ADDR KSYM COUNT
0xffffb2892ab0 (user) 1
0xffffb2b1edfc (user) 1
0xffff800008462834 __arm64_sys_ppoll 1
0xffff8000084b87f4 eventfd_read 1
0xffffb28e6788 (user) 1
0xffff8000081e96d8 rcu_all_qs 1
0xffffb2ada878 (user) 1
...
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Link: https://lore.kernel.org/r/tencent_A0E82E0BEE925285F8156D540731DF805F05@qq.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>