* [PATCH bpf] sparc: Correct ctx->saw_frame_pointer logic.
@ 2018-11-26 22:52 David Miller
2018-11-27 1:54 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2018-11-26 22:52 UTC (permalink / raw)
To: daniel; +Cc: ast, netdev
We need to initialize the frame pointer register not just if it is
seen as a source operand, but also if it is seen as the destination
operand of a store or an atomic instruction (which effectively is a
source operand).
This is exercised by test_verifier's "non-invalid fp arithmetic"
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c
index 222785a..ec4da4d 100644
--- a/arch/sparc/net/bpf_jit_comp_64.c
+++ b/arch/sparc/net/bpf_jit_comp_64.c
@@ -1270,6 +1270,9 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
const u8 tmp2 = bpf2sparc[TMP_REG_2];
u32 opcode = 0, rs2;
+ if (insn->dst_reg == BPF_REG_FP)
+ ctx->saw_frame_pointer = true;
+
ctx->tmp_2_used = true;
emit_loadimm(imm, tmp2, ctx);
@@ -1308,6 +1311,9 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
const u8 tmp = bpf2sparc[TMP_REG_1];
u32 opcode = 0, rs2;
+ if (insn->dst_reg == BPF_REG_FP)
+ ctx->saw_frame_pointer = true;
+
switch (BPF_SIZE(code)) {
case BPF_W:
opcode = ST32;
@@ -1340,6 +1346,9 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
const u8 tmp2 = bpf2sparc[TMP_REG_2];
const u8 tmp3 = bpf2sparc[TMP_REG_3];
+ if (insn->dst_reg == BPF_REG_FP)
+ ctx->saw_frame_pointer = true;
+
ctx->tmp_1_used = true;
ctx->tmp_2_used = true;
ctx->tmp_3_used = true;
@@ -1360,6 +1369,9 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
const u8 tmp2 = bpf2sparc[TMP_REG_2];
const u8 tmp3 = bpf2sparc[TMP_REG_3];
+ if (insn->dst_reg == BPF_REG_FP)
+ ctx->saw_frame_pointer = true;
+
ctx->tmp_1_used = true;
ctx->tmp_2_used = true;
ctx->tmp_3_used = true;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf] sparc: Correct ctx->saw_frame_pointer logic.
2018-11-26 22:52 [PATCH bpf] sparc: Correct ctx->saw_frame_pointer logic David Miller
@ 2018-11-27 1:54 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2018-11-27 1:54 UTC (permalink / raw)
To: David Miller; +Cc: daniel, ast, netdev
On Mon, Nov 26, 2018 at 02:52:18PM -0800, David Miller wrote:
>
> We need to initialize the frame pointer register not just if it is
> seen as a source operand, but also if it is seen as the destination
> operand of a store or an atomic instruction (which effectively is a
> source operand).
>
> This is exercised by test_verifier's "non-invalid fp arithmetic"
>
> Signed-off-by: David S. Miller <davem@davemloft.net>
Applied to bpf tree. Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-27 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26 22:52 [PATCH bpf] sparc: Correct ctx->saw_frame_pointer logic David Miller
2018-11-27 1:54 ` Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.