BPF List
 help / color / mirror / Atom feed
From: Shenghao Yuan <shenghao.yuan@inria.fr>
To: bpf@vger.kernel.org
Subject: Questions: JIT ARM32
Date: Thu, 12 May 2022 09:22:48 +0200 (CEST)	[thread overview]
Message-ID: <271219135.7057261.1652340168554.JavaMail.zimbra@inria.fr> (raw)

Hello all, 

I am a beginner to learn the eBPF jit compiler (and also a Linux beginner), I have two questions when I read the eBPF-JIT ARM32 source code (I am using bootlin [1] and this eBPF document [2]), could you please give me some suggestions? 

1. mov instructions: I don't understand why it has a condition `imm == 1` [2] 
```c 
case BPF_ALU | BPF_MOV | BPF_K: 
case BPF_ALU | BPF_MOV | BPF_X: 
case BPF_ALU64 | BPF_MOV | BPF_K: 
case BPF_ALU64 | BPF_MOV | BPF_X: 
switch (BPF_SRC(code)) { 
case BPF_X: 
if (imm == 1) { // I don't understand here 
/* Special mov32 for zext */ 
emit_a32_mov_i(dst_hi, 0, ctx); 
break; 
} 
emit_a32_mov_r64(is64, dst, src, ctx); 
``` 
2. alu32 instructions, why jit arm32 doesn't call/trigger alu32 operations [4] 
```c 
if (is64) { 
const s8 *rs; 

rs = arm_bpf_get_reg64(src, tmp2, ctx); 

/* ALU operation */ 
emit_alu_r(rd[1], rs[1], true, false, op, ctx); 
emit_alu_r(rd[0], rs[0], true, true, op, ctx); 
} else { 
s8 rs; 

rs = arm_bpf_get_reg32(src_lo, tmp2[1], ctx); 

/* ALU operation */ 
emit_alu_r(rd[1], rs, true, false, op, ctx); //here it also set is64 as true? 
if (!ctx->prog->aux->verifier_zext) 
emit_a32_mov_i(rd[0], 0, ctx); 
} 
``` 

[1] https://elixir.bootlin.com/linux/v5.18-rc6/source
[2] https://github.com/iovisor/bpf-docs/blob/master/eBPF.md
[3] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm/net/bpf_jit_32.c#L1399 
[4] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm/net/bpf_jit_32.c#L754

Best wishes, 
----------------------- ----------------------- ------------ 
Shenghao YUAN 

TEA (Time, Events and Architectures) team 

Inria Rennes 

Tel: (+33) 0749504117

                 reply	other threads:[~2022-05-12  7:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=271219135.7057261.1652340168554.JavaMail.zimbra@inria.fr \
    --to=shenghao.yuan@inria.fr \
    --cc=bpf@vger.kernel.org \
    /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