nfp: bpf: fix immed relocation for larger offsets
authorJakub Kicinski <jakub.kicinski@netronome.com>
Thu, 8 Feb 2018 04:27:12 +0000 (20:27 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 8 Feb 2018 10:59:50 +0000 (11:59 +0100)
Immed relocation is missing a shift which means for larger
offsets the lower and higher part of the address would be
ORed together.

Fixes: ce4ebfd859c3 ("nfp: bpf: add helpers for updating immediate instructions")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
drivers/net/ethernet/netronome/nfp/nfp_asm.c

index 3f6952b66a4979cc9bcc9d1333367a61c315f1b3..1e597600c693812d38d080fd355c82e2c8a350d8 100644 (file)
@@ -107,7 +107,7 @@ u16 immed_get_value(u64 instr)
        if (!unreg_is_imm(reg))
                reg = FIELD_GET(OP_IMMED_B_SRC, instr);
 
-       return (reg & 0xff) | FIELD_GET(OP_IMMED_IMM, instr);
+       return (reg & 0xff) | FIELD_GET(OP_IMMED_IMM, instr) << 8;
 }
 
 void immed_set_value(u64 *instr, u16 immed)