mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-01 11:54:10 +00:00
s390/bpf: Only clear A and X for converted BPF programs
Only classic BPF programs that have been converted to eBPF need to clear the A and X registers. We can check for converted programs with: bpf_prog->type == BPF_PROG_TYPE_UNSPEC So add the check and skip initialization for real eBPF programs. Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ce2b6ad9c1
commit
cde66c2d88
1 changed files with 11 additions and 9 deletions
|
@ -387,7 +387,7 @@ static void save_restore_regs(struct bpf_jit *jit, int op)
|
||||||
* Save registers and create stack frame if necessary.
|
* Save registers and create stack frame if necessary.
|
||||||
* See stack frame layout desription in "bpf_jit.h"!
|
* See stack frame layout desription in "bpf_jit.h"!
|
||||||
*/
|
*/
|
||||||
static void bpf_jit_prologue(struct bpf_jit *jit)
|
static void bpf_jit_prologue(struct bpf_jit *jit, bool is_classic)
|
||||||
{
|
{
|
||||||
if (jit->seen & SEEN_TAIL_CALL) {
|
if (jit->seen & SEEN_TAIL_CALL) {
|
||||||
/* xc STK_OFF_TCCNT(4,%r15),STK_OFF_TCCNT(%r15) */
|
/* xc STK_OFF_TCCNT(4,%r15),STK_OFF_TCCNT(%r15) */
|
||||||
|
@ -440,13 +440,15 @@ static void bpf_jit_prologue(struct bpf_jit *jit)
|
||||||
EMIT6_DISP_LH(0xe3000000, 0x0004, REG_SKB_DATA, REG_0,
|
EMIT6_DISP_LH(0xe3000000, 0x0004, REG_SKB_DATA, REG_0,
|
||||||
BPF_REG_1, offsetof(struct sk_buff, data));
|
BPF_REG_1, offsetof(struct sk_buff, data));
|
||||||
}
|
}
|
||||||
/* BPF compatibility: clear A (%b0) and X (%b7) registers */
|
/* Clear A (%b0) and X (%b7) registers for converted BPF programs */
|
||||||
if (REG_SEEN(BPF_REG_A))
|
if (is_classic) {
|
||||||
/* lghi %ba,0 */
|
if (REG_SEEN(BPF_REG_A))
|
||||||
EMIT4_IMM(0xa7090000, BPF_REG_A, 0);
|
/* lghi %ba,0 */
|
||||||
if (REG_SEEN(BPF_REG_X))
|
EMIT4_IMM(0xa7090000, BPF_REG_A, 0);
|
||||||
/* lghi %bx,0 */
|
if (REG_SEEN(BPF_REG_X))
|
||||||
EMIT4_IMM(0xa7090000, BPF_REG_X, 0);
|
/* lghi %bx,0 */
|
||||||
|
EMIT4_IMM(0xa7090000, BPF_REG_X, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1232,7 +1234,7 @@ static int bpf_jit_prog(struct bpf_jit *jit, struct bpf_prog *fp)
|
||||||
jit->lit = jit->lit_start;
|
jit->lit = jit->lit_start;
|
||||||
jit->prg = 0;
|
jit->prg = 0;
|
||||||
|
|
||||||
bpf_jit_prologue(jit);
|
bpf_jit_prologue(jit, fp->type == BPF_PROG_TYPE_UNSPEC);
|
||||||
for (i = 0; i < fp->len; i += insn_count) {
|
for (i = 0; i < fp->len; i += insn_count) {
|
||||||
insn_count = bpf_jit_insn(jit, fp, i);
|
insn_count = bpf_jit_insn(jit, fp, i);
|
||||||
if (insn_count < 0)
|
if (insn_count < 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue