bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Ilya Leoshkevich <iii@linux.ibm.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Cc: <bpf@vger.kernel.org>, Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH bpf-next] selftests/bpf: Use _REGION1_SIZE in test_snprintf_btf on s390
Date: Fri, 26 Feb 2021 09:19:21 -0800	[thread overview]
Message-ID: <9715c71f-f258-5a3b-af4c-a9c56b2b53ad@fb.com> (raw)
In-Reply-To: <20210226135923.114211-1-iii@linux.ibm.com>



On 2/26/21 5:59 AM, Ilya Leoshkevich wrote:
> test_snprintf_btf fails on s390, because NULL points to a readable
> struct lowcore there. Fix by using _REGION1_SIZE instead.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>

Ack with a minor nit below.

Acked-by: Yonghong Song <yhs@fb.com>

> ---
>   tools/testing/selftests/bpf/progs/netif_receive_skb.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/progs/netif_receive_skb.c b/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> index 6b670039ea67..fa54d2abc41e 100644
> --- a/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> +++ b/tools/testing/selftests/bpf/progs/netif_receive_skb.c
> @@ -16,6 +16,13 @@ bool skip = false;
>   #define STRSIZE			2048
>   #define EXPECTED_STRSIZE	256
>   
> +#if defined(bpf_target_s390)
> +/* NULL points to a readable struct lowcore on s390, so take _REGION1_SIZE */
> +#define BADPTR			((void *)(1ULL << 53))
> +#else
> +#define BADPTR			0
> +#endif
> +
>   #ifndef ARRAY_SIZE
>   #define ARRAY_SIZE(x)	(sizeof(x) / sizeof((x)[0]))
>   #endif
> @@ -114,9 +121,9 @@ int BPF_PROG(trace_netif_receive_skb, struct sk_buff *skb)
>   
>   	/* Check invalid ptr value */
>   	p.ptr = 0;
> -	__ret = bpf_snprintf_btf(str, STRSIZE, &p, sizeof(p), 0);
> +	__ret = bpf_snprintf_btf(str, STRSIZE, &p, sizeof(p), BADPTR);
>   	if (__ret >= 0) {
> -		bpf_printk("printing NULL should generate error, got (%d)",
> +		bpf_printk("printing BADPTR should generate error, got (%d)",
>   			   __ret);

The previous error message NULL implies address 0. The new error message
did not print out the badptr address. Do you want to print them out so
in case of errors, you don't need to search source code?

>   		ret = -ERANGE;
>   	}
> 

      reply	other threads:[~2021-02-26 17:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26 13:59 [PATCH bpf-next] selftests/bpf: Use _REGION1_SIZE in test_snprintf_btf on s390 Ilya Leoshkevich
2021-02-26 17:19 ` Yonghong Song [this message]

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=9715c71f-f258-5a3b-af4c-a9c56b2b53ad@fb.com \
    --to=yhs@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=iii@linux.ibm.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).