Cc: David S. Miller <da...@davemloft.net>
Signed-off-by: Jiong Wang <jiong.w...@netronome.com>
---
 arch/sparc/net/bpf_jit_comp_64.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c
index 65428e7..8318d3a 100644
--- a/arch/sparc/net/bpf_jit_comp_64.c
+++ b/arch/sparc/net/bpf_jit_comp_64.c
@@ -905,6 +905,10 @@ static int build_insn(const struct bpf_insn *insn, struct 
jit_ctx *ctx)
                ctx->saw_frame_pointer = true;
 
        switch (code) {
+       /* explicit zero extension */
+       case BPF_ALU | BPF_ZEXT:
+               emit_alu_K(SRL, dst, 0, ctx);
+               break;
        /* dst = src */
        case BPF_ALU | BPF_MOV | BPF_X:
                emit_alu3_K(SRL, src, 0, dst, ctx);
@@ -1144,7 +1148,8 @@ static int build_insn(const struct bpf_insn *insn, struct 
jit_ctx *ctx)
                break;
 
        do_alu32_trunc:
-               if (BPF_CLASS(code) == BPF_ALU)
+               if (BPF_CLASS(code) == BPF_ALU &&
+                   !ctx->prog->aux->verifier_zext)
                        emit_alu_K(SRL, dst, 0, ctx);
                break;
 
@@ -1432,6 +1437,11 @@ static void jit_fill_hole(void *area, unsigned int size)
                *ptr++ = 0x91d02005; /* ta 5 */
 }
 
+bool bpf_jit_hardware_zext(void)
+{
+       return false;
+}
+
 struct sparc64_jit_data {
        struct bpf_binary_header *header;
        u8 *image;
-- 
2.7.4

Reply via email to