netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
To: "Björn Töpel" <bjorn.topel@gmail.com>
Cc: Netdev <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Tom Herbert <tom@herbertland.com>,
	Anders Roxell <anders.roxell@gmail.com>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: csum_partial() on different archs (selftest/bpf)
Date: Fri, 13 Nov 2020 13:24:40 +0100	[thread overview]
Message-ID: <20201113122440.GA2164@myrica> (raw)
In-Reply-To: <CAJ+HfNiQbOcqCLxFUP2FMm5QrLXUUaj852Fxe3hn_2JNiucn6g@mail.gmail.com>

Hi,

On Fri, Nov 13, 2020 at 11:36:08AM +0100, Björn Töpel wrote:
> I was running the selftest/bpf on riscv, and had a closer look at one
> of the failing cases:
> 
>   #14/p valid read map access into a read-only array 2 FAIL retval
> 65507 != -29 (run 1/1)
> 
> The test does a csum_partial() call via a BPF helper. riscv uses the
> generic implementation. arm64 uses the generic csum_partial() and fail
> in the same way [1].

It's worse than that, because arm64, parisc, alpha and others implement
do_csum(), called by the generic csum_partial(), and those all return a
16-bit value.

It would be good to firstly formalize the size of the value returned by
the bpf_csum_diff() helper, because it's not clear from the doc (and the
helper returns a s64).

Then homogenizing the csum_partial() implementations is difficult. One way
forward, without having to immediately rewrite all arch-specific
implementations, would be to replace csum_partial() and do_csum() with
csum_partial_32(), csum_partial_16(), do_csum_32() and do_csum_16(). That
way we can use a generic implementation of the 32-bit variant if the
arch-specific implementation is 16-bit.

Thanks,
Jean

> arm (32-bit) has a arch specfic implementation,
> and fail in another way (FAIL retval 131042 != -29) [2].
> 
> I mimicked the test case in a userland program, comparing the generic
> csum_partial() to the x86 implementation [3], and the generic and x86
> implementation does yield a different result.
> 
> x86     :    -29 : 0xffffffe3
> generic :  65507 : 0x0000ffe3
> arm     : 131042 : 0x0001ffe2
> 
> Who is correct? :-) It would be nice to get rid of this failed case...
> 
> 
> Thanks,
> Björn
> 
> 
> [1] https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20201112/testrun/3430401/suite/kselftest/test/bpf.test_verifier/log
> [2] https://qa-reports.linaro.org/lkft/linux-mainline-master/build/v5.10-rc3-207-g585e5b17b92d/testrun/3432361/suite/kselftest/test/bpf.test_verifier/log
> [3] https://gist.github.com/bjoto/dc22d593aa3ac63c2c90632de5ed82e0

  parent reply	other threads:[~2020-11-13 12:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 10:36 csum_partial() on different archs (selftest/bpf) Björn Töpel
2020-11-13 11:34 ` Eric Dumazet
2020-11-13 13:17   ` Björn Töpel
2020-11-13 12:24 ` Jean-Philippe Brucker [this message]
2020-11-13 13:22   ` Björn Töpel
2020-11-13 14:15     ` Al Viro
2020-11-13 14:32       ` Daniel Borkmann
2020-11-13 17:28         ` Al Viro
2020-11-13 12:42 ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201113122440.GA2164@myrica \
    --to=jean-philippe@linaro.org \
    --cc=anders.roxell@gmail.com \
    --cc=bjorn.topel@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=tom@herbertland.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).