Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Add support for ARM #28

Open
3 tasks
alban opened this issue Jan 26, 2020 · 3 comments
Open
3 tasks

Add support for ARM #28

alban opened this issue Jan 26, 2020 · 3 comments

Comments

@alban
Copy link
Member

alban commented Jan 26, 2020

traceloop currently only works on x86_64.

Non-exhaustive list of tasks:

  • The syscall table (syscall_table.go) needs to be per-architecture
  • straceback-guess-bpf.c hard code some syscall numbers
if (exit != 0 && id != 165) { // mount
if (id != 269) { // faccessat()
  • errno computation is x86_64 specific (if errNo >= -4095 && errNo <= -1 in event.go)
@eiffel-fl
Copy link

eiffel-fl commented Dec 17, 2021

Hi.

I thought to several approaches to deal with harcoded syscall numbers:

  1. If we can call any kernel functions from BPF code, we can do something like this:
#include <linux/kallsyms.h>
#include <linux/ftrace.h>

// ...

unsigned long addr;
char str[KSYM_SYMBOL_LEN];

addr = arch_syscall_addr(id);
kallsyms_lookup(addr, NULL, NULL, NULL, str);
if (!strcmp(str + 3, "faccessat"))
	return 0;
  1. If it exists a BPF helper to get CPU architecture, we can do something like this:
char *architecture = bpf_get_cpu_architecture()
if ((!strcmp(architecture, "x86_64") && id == 149) || (!strcmp(architecture, "aarch64) && id == 48 || ...)
        return 0;
  1. Otherwise, we can use __NR_faccessat macro:
#include <linux/unistd.h>

if (id == __NR_faccessat)
        return 0;

First solution seems to be the best one, sadly we cannot call any kernel function from BPF code for the moment.
The second one is less generic but seems OK, sadly it does not exists a bpf helper to get cpu architecture.
The last one would require to compile BPF code against the architecture kernel headers as __NR_faccesstat value would be replaced by corresponding value for the given architecture. This is doable but will not ease our build system.

Let me know what you think about these different solutions.

Best regards.

eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue May 12, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue May 12, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jun 1, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jun 3, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jun 8, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jun 8, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jun 23, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jun 23, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jul 1, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jul 4, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
eiffel-fl added a commit to inspektor-gadget/inspektor-gadget that referenced this issue Jul 5, 2022
At the moment, this gadget cannot work on arm64 for several reasons [1].

Signed-off-by: Francis Laniel <[email protected]>
[1] kinvolk/traceloop#28
@retpolanne
Copy link

I'm currently working on being able to build on aarch64 with make and docker.

@retpolanne
Copy link

So, I tried porting it and saw a bunch of compiling errors due to ASM.

My patches are here
main...retpolanne:traceloop:arm64

I'm seeing the same things as this issue iovisor/bcc#1202 but bcc was fixed by adding bpfasmparser to the Cmake LLVM libraries: iovisor/bcc@7abe63a

I did some research and couldn't find a way to add this bpfasmparser to our Clang flags. However, I do see bpfasmparser on llvm-config --components.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants