Message ID | 20210728170502.351010-12-johan.almbladh@anyfinetworks.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf/tests: Extend the eBPF test suite | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 7/28/21 10:04 AM, Johan Almbladh wrote: > On a 32-bit architecture, the context pointer should occupy the low > half of R0, and the other half should be zero. I think this is probably true. The word choice "should" indicates this doesn't need to be the case if people choose a different implementation, right? > > Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com> > --- > lib/test_bpf.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/lib/test_bpf.c b/lib/test_bpf.c > index 55914b6236aa..314af6eaeb92 100644 > --- a/lib/test_bpf.c > +++ b/lib/test_bpf.c > @@ -2084,6 +2084,22 @@ static struct bpf_test tests[] = { > #undef NUMER > #undef DENOM > }, > +#ifdef CONFIG_32BIT > + { > + "INT: 32-bit context pointer word order and zero-extension", > + .u.insns_int = { > + BPF_ALU32_IMM(BPF_MOV, R0, 0), > + BPF_JMP32_IMM(BPF_JEQ, R1, 0, 3), > + BPF_ALU64_IMM(BPF_RSH, R1, 32), > + BPF_JMP32_IMM(BPF_JNE, R1, 0, 1), > + BPF_ALU32_IMM(BPF_MOV, R0, 1), > + BPF_EXIT_INSN(), > + }, > + INTERNAL, > + { }, > + { { 0, 1 } } > + }, > +#endif > { > "check: missing ret", > .u.insns = { >
On Thu, Jul 29, 2021 at 2:09 AM Yonghong Song <yhs@fb.com> wrote: > On 7/28/21 10:04 AM, Johan Almbladh wrote: > > On a 32-bit architecture, the context pointer should occupy the low > > half of R0, and the other half should be zero. > > I think this is probably true. The word choice "should" indicates > this doesn't need to be the case if people choose a different > implementation, right? > Right. To the best of my knowledge this is true. I can change the wording to "will" to remove the ambiguity.
On 7/29/21 6:29 AM, Johan Almbladh wrote: > On Thu, Jul 29, 2021 at 2:09 AM Yonghong Song <yhs@fb.com> wrote: >> On 7/28/21 10:04 AM, Johan Almbladh wrote: >>> On a 32-bit architecture, the context pointer should occupy the low >>> half of R0, and the other half should be zero. >> >> I think this is probably true. The word choice "should" indicates >> this doesn't need to be the case if people choose a different >> implementation, right? >> > > Right. To the best of my knowledge this is true. I can change the > wording to "will" to remove the ambiguity. Sounds good. thanks!
diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 55914b6236aa..314af6eaeb92 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -2084,6 +2084,22 @@ static struct bpf_test tests[] = { #undef NUMER #undef DENOM }, +#ifdef CONFIG_32BIT + { + "INT: 32-bit context pointer word order and zero-extension", + .u.insns_int = { + BPF_ALU32_IMM(BPF_MOV, R0, 0), + BPF_JMP32_IMM(BPF_JEQ, R1, 0, 3), + BPF_ALU64_IMM(BPF_RSH, R1, 32), + BPF_JMP32_IMM(BPF_JNE, R1, 0, 1), + BPF_ALU32_IMM(BPF_MOV, R0, 1), + BPF_EXIT_INSN(), + }, + INTERNAL, + { }, + { { 0, 1 } } + }, +#endif { "check: missing ret", .u.insns = {
On a 32-bit architecture, the context pointer should occupy the low half of R0, and the other half should be zero. Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com> --- lib/test_bpf.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)