Skip to contentSkip to conversation

selftests/bpf: trace_helpers.c: do not use poisoned type

PATCH Applied Shung-Hsi Yu 3 participants 3 messages Feb 2, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: trace_helpers.c: do not use poisoned type

After commit c698eaebdf47 ("selftests/bpf: trace_helpers.c: Optimize kallsyms cache") trace_helpers.c now includes libbpf_internal.h, and thus can no longer use the u32 type (among others) since they are poison in libbpf_internal.h. Replace u32 with __u32 to fix the following error when building trace_helpers.c on powerpc:

error: attempt to use poisoned "u32"

Fixes c698eaebdf47 ("selftests/bpf: trace_helpers.c: Optimize kallsyms cache")

---
Somehow this error only shows up when I'm building on ppc64le, but not x86_64 and aarch64. But I didn't investigate further.

---
 tools/testing/selftests/bpf/trace_helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/trace_helpers.c +1 -1
index 4faa898ff7fc..27fd7ed3e4b0 100644
@@ -271,7 +271,7 @@ ssize_t get_uprobe_offset(const void *addr)
 	 * addi  r2,r2,XXXX
 	 */
 	{
-		const u32 *insn = (const u32 *)(uintptr_t)addr;
+		const __u32 *insn = (const __u32 *)(uintptr_t)addr;
 
 		if ((((*insn & OP_RT_RA_MASK) == ADDIS_R2_R12) ||
 		     ((*insn & OP_RT_RA_MASK) == LIS_R2)) &&

base-commit: 943b043aeecce9accb6d367af47791c633e95e4d

Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Shung-Hsi Yu

After commit c698eaebdf47 ("selftests/bpf: trace_helpers.c: Optimize kallsyms cache") trace_helpers.c now includes libbpf_internal.h, and thus can no longer use the u32 type (among others) since they are poison in libbpf_internal.h. Replace u32 with __u32 to fix the following error when building trace_helpers.c on powerpc:

Quoted 7 lines

error: attempt to use poisoned "u32"

Fixes c698eaebdf47 ("selftests/bpf: trace_helpers.c: Optimize kallsyms cache")

---
Somehow this error only shows up when I'm building on ppc64le, but not x86_64 and aarch64. But I didn't investigate further.

it's within powerpc ifdef:

  #if defined(__powerpc64__) && defined(_CALL_ELF) && _CALL_ELF == 2

jirka

Quoted 22 lines
---
 tools/testing/selftests/bpf/trace_helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/trace_helpers.c +1 -1
index 4faa898ff7fc..27fd7ed3e4b0 100644
@@ -271,7 +271,7 @@ ssize_t get_uprobe_offset(const void *addr)
 	 * addi  r2,r2,XXXX
 	 */
 	{
-		const u32 *insn = (const u32 *)(uintptr_t)addr;
+		const __u32 *insn = (const __u32 *)(uintptr_t)addr;
 
 		if ((((*insn & OP_RT_RA_MASK) == ADDIS_R2_R12) ||
 		     ((*insn & OP_RT_RA_MASK) == LIS_R2)) &&

base-commit: 943b043aeecce9accb6d367af47791c633e95e4d

Signature · 1 line
2.43.0
#2 lore raw
In reply to Shung-Hsi Yu
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Quoted 9 lines · On Fri, 2 Feb 2024 17:55:58 +0800 you wrote:

After commit c698eaebdf47 ("selftests/bpf: trace_helpers.c: Optimize kallsyms cache") trace_helpers.c now includes libbpf_internal.h, and thus can no longer use the u32 type (among others) since they are poison in libbpf_internal.h. Replace u32 with __u32 to fix the following error when building trace_helpers.c on powerpc:

error: attempt to use poisoned "u32"

[...]

Here is the summary with links:
- [bpf] selftests/bpf: trace_helpers.c: do not use poisoned type

    https://git.kernel.org/bpf/bpf-next/c/a68b50f47bec

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html