* [PATCH] m68k: Wire up bpf
@ 2014-10-21 17:30 Geert Uytterhoeven
0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2014-10-21 17:30 UTC (permalink / raw)
To: linux-m68k; +Cc: linux-kernel, Geert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
arch/m68k/include/asm/unistd.h | 2 +-
arch/m68k/include/uapi/asm/unistd.h | 1 +
arch/m68k/kernel/syscalltable.S | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 4ef7a54813e6b72d..75e75d7b1702fb64 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,7 +4,7 @@
#include <uapi/asm/unistd.h>
-#define NR_syscalls 354
+#define NR_syscalls 355
#define __ARCH_WANT_OLD_READDIR
#define __ARCH_WANT_OLD_STAT
diff --git a/arch/m68k/include/uapi/asm/unistd.h b/arch/m68k/include/uapi/asm/unistd.h
index b419c6b7ac3739b1..2c1bec9a14b67da4 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -359,5 +359,6 @@
#define __NR_renameat2 351
#define __NR_getrandom 352
#define __NR_memfd_create 353
+#define __NR_bpf 354
#endif /* _UAPI_ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S
index 05b46c2b08b8d8d4..2ca219e184cd16e6 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscalltable.S
@@ -374,4 +374,5 @@ ENTRY(sys_call_table)
.long sys_renameat2
.long sys_getrandom
.long sys_memfd_create
+ .long sys_bpf
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] m68k: Wire up bpf
[not found] <1413912653-3269-1-git-send-email-geert@linux-m68k.org>
@ 2014-10-21 21:12 ` Alexei Starovoitov
[not found] ` <CAADnVQ+5J+BM3onCUxzX+eL-gDqiJ04vDG4iD+3zbqngcmoqzQ@mail.gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2014-10-21 21:12 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-m68k, linux-kernel@vger.kernel.org
On Tue, Oct 21, 2014 at 10:30 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> arch/m68k/include/asm/unistd.h | 2 +-
> arch/m68k/include/uapi/asm/unistd.h | 1 +
> arch/m68k/kernel/syscalltable.S | 1 +
> 3 files changed, 3 insertions(+), 1 deletion(-)
did the tests pass in samples/bpf/test_verifier ?
Thank you for taking care of it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] m68k: Wire up bpf
[not found] ` <CAADnVQ+5J+BM3onCUxzX+eL-gDqiJ04vDG4iD+3zbqngcmoqzQ@mail.gmail.com>
@ 2014-10-22 7:48 ` Geert Uytterhoeven
2014-10-22 16:34 ` Alexei Starovoitov
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2014-10-22 7:48 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: linux-m68k, linux-kernel@vger.kernel.org
Hi Alexei,
On Tue, 21 Oct 2014, Alexei Starovoitov wrote:
> On Tue, Oct 21, 2014 at 10:30 AM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> > arch/m68k/include/asm/unistd.h | 2 +-
> > arch/m68k/include/uapi/asm/unistd.h | 1 +
> > arch/m68k/kernel/syscalltable.S | 1 +
> > 3 files changed, 3 insertions(+), 1 deletion(-)
>
> did the tests pass in samples/bpf/test_verifier ?
Thanks for reminding me about the existence of the tests ;-)
Yes, they passed.
Note that gcc 4.1.2 doesn't like C99-initialization of anonymous
struct and union members, so I had to use the patch below:
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index d18316f9e9c488b0..6ec5060a6ece8f23 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -123,7 +123,7 @@ union bpf_attr {
__u32 key_size; /* size of key in bytes */
__u32 value_size; /* size of value in bytes */
__u32 max_entries; /* max number of entries in a map */
- };
+ } create;
struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
__u32 map_fd;
@@ -132,7 +132,7 @@ union bpf_attr {
__aligned_u64 value;
__aligned_u64 next_key;
};
- };
+ } elem;
struct { /* anonymous struct used by BPF_PROG_LOAD command */
__u32 prog_type; /* one of enum bpf_prog_type */
@@ -142,7 +142,7 @@ union bpf_attr {
__u32 log_level; /* verbosity level of verifier */
__u32 log_size; /* size of user buffer */
__aligned_u64 log_buf; /* user supplied buffer */
- };
+ } load;
} __attribute__((aligned(8)));
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
diff --git a/samples/bpf/libbpf.c b/samples/bpf/libbpf.c
index ff65044207384b90..bf1d0bae42c7c6aa 100644
--- a/samples/bpf/libbpf.c
+++ b/samples/bpf/libbpf.c
@@ -18,10 +18,10 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
int max_entries)
{
union bpf_attr attr = {
- .map_type = map_type,
- .key_size = key_size,
- .value_size = value_size,
- .max_entries = max_entries
+ .create.map_type = map_type,
+ .create.key_size = key_size,
+ .create.value_size = value_size,
+ .create.max_entries = max_entries
};
return syscall(__NR_bpf, BPF_MAP_CREATE, &attr, sizeof(attr));
@@ -30,10 +30,10 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
int bpf_update_elem(int fd, void *key, void *value)
{
union bpf_attr attr = {
- .map_fd = fd,
- .key = ptr_to_u64(key),
- .value = ptr_to_u64(value),
+ .elem.map_fd = fd,
+ .elem.key = ptr_to_u64(key),
};
+ attr.elem.value = ptr_to_u64(value);
return syscall(__NR_bpf, BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));
}
@@ -41,10 +41,10 @@ int bpf_update_elem(int fd, void *key, void *value)
int bpf_lookup_elem(int fd, void *key, void *value)
{
union bpf_attr attr = {
- .map_fd = fd,
- .key = ptr_to_u64(key),
- .value = ptr_to_u64(value),
+ .elem.map_fd = fd,
+ .elem.key = ptr_to_u64(key),
};
+ attr.elem.value = ptr_to_u64(value);
return syscall(__NR_bpf, BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));
}
@@ -52,8 +52,8 @@ int bpf_lookup_elem(int fd, void *key, void *value)
int bpf_delete_elem(int fd, void *key)
{
union bpf_attr attr = {
- .map_fd = fd,
- .key = ptr_to_u64(key),
+ .elem.map_fd = fd,
+ .elem.key = ptr_to_u64(key),
};
return syscall(__NR_bpf, BPF_MAP_DELETE_ELEM, &attr, sizeof(attr));
@@ -62,10 +62,10 @@ int bpf_delete_elem(int fd, void *key)
int bpf_get_next_key(int fd, void *key, void *next_key)
{
union bpf_attr attr = {
- .map_fd = fd,
- .key = ptr_to_u64(key),
- .next_key = ptr_to_u64(next_key),
+ .elem.map_fd = fd,
+ .elem.key = ptr_to_u64(key),
};
+ attr.elem.next_key = ptr_to_u64(next_key);
return syscall(__NR_bpf, BPF_MAP_GET_NEXT_KEY, &attr, sizeof(attr));
}
@@ -79,13 +79,13 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
const char *license)
{
union bpf_attr attr = {
- .prog_type = prog_type,
- .insns = ptr_to_u64((void *) insns),
- .insn_cnt = prog_len / sizeof(struct bpf_insn),
- .license = ptr_to_u64((void *) license),
- .log_buf = ptr_to_u64(bpf_log_buf),
- .log_size = LOG_BUF_SIZE,
- .log_level = 1,
+ .load.prog_type = prog_type,
+ .load.insns = ptr_to_u64((void *) insns),
+ .load.insn_cnt = prog_len / sizeof(struct bpf_insn),
+ .load.license = ptr_to_u64((void *) license),
+ .load.log_buf = ptr_to_u64(bpf_log_buf),
+ .load.log_size = LOG_BUF_SIZE,
+ .load.log_level = 1,
};
bpf_log_buf[0] = 0;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] m68k: Wire up bpf
2014-10-22 7:48 ` Geert Uytterhoeven
@ 2014-10-22 16:34 ` Alexei Starovoitov
0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2014-10-22 16:34 UTC (permalink / raw)
To: Geert Uytterhoeven, Andrew Morton
Cc: linux-m68k, linux-kernel@vger.kernel.org
On Wed, Oct 22, 2014 at 12:48 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Hi Alexei,
>
> On Tue, 21 Oct 2014, Alexei Starovoitov wrote:
>> On Tue, Oct 21, 2014 at 10:30 AM, Geert Uytterhoeven
>> <geert@linux-m68k.org> wrote:
>> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> > ---
>> > arch/m68k/include/asm/unistd.h | 2 +-
>> > arch/m68k/include/uapi/asm/unistd.h | 1 +
>> > arch/m68k/kernel/syscalltable.S | 1 +
>> > 3 files changed, 3 insertions(+), 1 deletion(-)
>>
>> did the tests pass in samples/bpf/test_verifier ?
>
> Thanks for reminding me about the existence of the tests ;-)
>
> Yes, they passed.
Great, then:
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
> Note that gcc 4.1.2 doesn't like C99-initialization of anonymous
> struct and union members, so I had to use the patch below:
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index d18316f9e9c488b0..6ec5060a6ece8f23 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -123,7 +123,7 @@ union bpf_attr {
> __u32 key_size; /* size of key in bytes */
> __u32 value_size; /* size of value in bytes */
> __u32 max_entries; /* max number of entries in a map */
> - };
> + } create;
I've tested this stuff with 4.2 and up, since that's the oldest we
have in kernel.org cross-compilers repo.
4.1 was a first release with brand new C front-end which had
all sorts of gotchas and just like 4.0 was a massive release too.
Nowadays I wouldn't touch anything below 4.4
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-22 16:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1413912653-3269-1-git-send-email-geert@linux-m68k.org>
2014-10-21 21:12 ` [PATCH] m68k: Wire up bpf Alexei Starovoitov
[not found] ` <CAADnVQ+5J+BM3onCUxzX+eL-gDqiJ04vDG4iD+3zbqngcmoqzQ@mail.gmail.com>
2014-10-22 7:48 ` Geert Uytterhoeven
2014-10-22 16:34 ` Alexei Starovoitov
2014-10-21 17:30 Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox