All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: Support PPC in arch_specific_syscall_pfx
@ 2022-07-28 22:23 Daniel Müller
  2022-07-28 23:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Müller @ 2022-07-28 22:23 UTC (permalink / raw)
  To: bpf, ast, andrii, daniel, kernel-team

Commit 708ac5bea0ce ("libbpf: add ksyscall/kretsyscall sections support
for syscall kprobes") added the arch_specific_syscall_pfx() function,
which returns a string representing the architecture in use. As it turns
out this function is currently not aware of Power PC, where NULL is
returned. That's being flagged by the libbpf CI system, which builds for
ppc64le and the compiler sees a NULL pointer being passed in to a %s
format string.
With this change we add representations for two more architectures, for
Power PC and Power PC 64, and also adjust the string format logic to
handle NULL pointers gracefully, in an attempt to prevent similar issues
with other architectures in the future.

Fixes: 708ac5bea0ce ("libbpf: add ksyscall/kretsyscall sections support for syscall kprobes")
Signed-off-by: Daniel Müller <deso@posteo.net>
---
 tools/lib/bpf/libbpf.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b01fe01..50d4181 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9995,6 +9995,10 @@ static const char *arch_specific_syscall_pfx(void)
 	return "mips";
 #elif defined(__riscv)
 	return "riscv";
+#elif defined(__powerpc__)
+	return "powerpc";
+#elif defined(__powerpc64__)
+	return "powerpc64";
 #else
 	return NULL;
 #endif
@@ -10127,8 +10131,13 @@ struct bpf_link *bpf_program__attach_ksyscall(const struct bpf_program *prog,
 		return libbpf_err_ptr(-EINVAL);
 
 	if (kernel_supports(prog->obj, FEAT_SYSCALL_WRAPPER)) {
+		/* arch_specific_syscall_pfx() should never return NULL here
+		 * because it is guarded by kernel_supports(). However, since
+		 * compiler does not know that we have an explicit conditional
+		 * as well.
+		 */
 		snprintf(func_name, sizeof(func_name), "__%s_sys_%s",
-			 arch_specific_syscall_pfx(), syscall_name);
+			 arch_specific_syscall_pfx() ? : "", syscall_name);
 	} else {
 		snprintf(func_name, sizeof(func_name), "__se_sys_%s", syscall_name);
 	}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] libbpf: Support PPC in arch_specific_syscall_pfx
  2022-07-28 22:23 [PATCH bpf-next] libbpf: Support PPC in arch_specific_syscall_pfx Daniel Müller
@ 2022-07-28 23:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-28 23:20 UTC (permalink / raw)
  To: =?utf-8?q?Daniel_M=C3=BCller_=3Cdeso=40posteo=2Enet=3E?=
  Cc: bpf, ast, andrii, daniel, kernel-team

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Thu, 28 Jul 2022 22:23:45 +0000 you wrote:
> Commit 708ac5bea0ce ("libbpf: add ksyscall/kretsyscall sections support
> for syscall kprobes") added the arch_specific_syscall_pfx() function,
> which returns a string representing the architecture in use. As it turns
> out this function is currently not aware of Power PC, where NULL is
> returned. That's being flagged by the libbpf CI system, which builds for
> ppc64le and the compiler sees a NULL pointer being passed in to a %s
> format string.
> With this change we add representations for two more architectures, for
> Power PC and Power PC 64, and also adjust the string format logic to
> handle NULL pointers gracefully, in an attempt to prevent similar issues
> with other architectures in the future.
> 
> [...]

Here is the summary with links:
  - [bpf-next] libbpf: Support PPC in arch_specific_syscall_pfx
    https://git.kernel.org/bpf/bpf-next/c/64893e83f916

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-28 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 22:23 [PATCH bpf-next] libbpf: Support PPC in arch_specific_syscall_pfx Daniel Müller
2022-07-28 23:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.