netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Jiong Wang <jiong.wang@netronome.com>
Cc: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org,
	oss-drivers@netronome.com
Subject: Re: [PATH bpf-next 11/13] bpf: verifier support JMP32
Date: Wed, 19 Dec 2018 15:54:06 -0800	[thread overview]
Message-ID: <20181219155406.36d1bcb5@cakuba.netronome.com> (raw)
In-Reply-To: <1545259460-13376-12-git-send-email-jiong.wang@netronome.com>

On Wed, 19 Dec 2018 17:44:18 -0500, Jiong Wang wrote:
> Verifier is doing some runtime optimizations based on the extra info
> conditional jump instruction could offer, especially when the comparison
> is between constant and register for which case the value range of the
> register could be improved.
> 
>   is_branch_taken/reg_set_min_max/reg_set_min_max_inv
> 
> are the three functions that needs updating.
> 
> There are some other conditional jump related optimizations but they
> are with pointer types comparison which JMP32 won't be generated for.
> 
> Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
> ---
>  kernel/bpf/verifier.c | 178 ++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 137 insertions(+), 41 deletions(-)
> 
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index e0e77ff..3123c91 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -3919,7 +3919,7 @@ static int is_branch_taken(struct bpf_reg_state *reg, u64 val, u8 opcode)
>   */
>  static void reg_set_min_max(struct bpf_reg_state *true_reg,
>  			    struct bpf_reg_state *false_reg, u64 val,
> -			    u8 opcode)
> +			    u8 opcode, bool is_jmp32)
>  {
>  	/* If the dst_reg is a pointer, we can't learn anything about its
>  	 * variable offset from the compare (unless src_reg were a pointer into
> @@ -3935,45 +3935,69 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg,
>  		/* If this is false then we know nothing Jon Snow, but if it is
>  		 * true then we know for sure.
>  		 */
> -		__mark_reg_known(true_reg, val);
> +		if (is_jmp32)
> +			true_reg->var_off = tnum_or(true_reg->var_off,
> +						    tnum_const(val));

These tnum updates look strange, if the jump is 32bit we know the
bottom bits.  So:

	tnum.m &= GENMASK(63, 32);
	tnum.v = upper_32_bits(tnum.v) | lower_32_bits(val);

> +		else
> +			__mark_reg_known(true_reg, val);
>  		break;

  reply	other threads:[~2018-12-19 23:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 22:44 [PATH bpf-next 00/13] bpf: propose new jmp32 instructions Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 01/13] bpf: encoding description and macros for JMP32 Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 02/13] bpf: interpreter support " Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 03/13] bpf: JIT blinds support JMP32 Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 04/13] x86_64: bpf: implement jitting of JMP32 Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 05/13] x32: " Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 06/13] arm64: " Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 07/13] arm: " Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 08/13] ppc: " Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 09/13] s390: " Jiong Wang
2018-12-20  6:47   ` Martin Schwidefsky
2018-12-19 22:44 ` [PATH bpf-next 10/13] nfp: " Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 11/13] bpf: verifier support JMP32 Jiong Wang
2018-12-19 23:54   ` Jakub Kicinski [this message]
2019-01-08 15:23     ` Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 12/13] bpf: unit tests for JMP32 Jiong Wang
2018-12-19 22:44 ` [PATH bpf-next 13/13] selftests: bpf: makefile support sub-register code-gen test mode Jiong Wang
2018-12-20  3:08 ` [PATH bpf-next 00/13] bpf: propose new jmp32 instructions Alexei Starovoitov

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=20181219155406.36d1bcb5@cakuba.netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jiong.wang@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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).