mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 22:25:03 +00:00
nfp: bpf: pad code with valid nops
We need to append up to 8 nops after last instruction to make sure the CPU will not fetch garbage instructions with invalid ECC if the code store was not initialized. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
fd068ddc88
commit
1c03e03f9b
2 changed files with 13 additions and 1 deletions
|
@ -426,6 +426,11 @@ emit_ld_field(struct nfp_prog *nfp_prog, swreg dst, u8 bmask, swreg src,
|
||||||
emit_ld_field_any(nfp_prog, sc, shift, dst, bmask, src, false);
|
emit_ld_field_any(nfp_prog, sc, shift, dst, bmask, src, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void emit_nop(struct nfp_prog *nfp_prog)
|
||||||
|
{
|
||||||
|
__emit_immed(nfp_prog, UR_REG_IMM, UR_REG_IMM, 0, 0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Wrappers --- */
|
/* --- Wrappers --- */
|
||||||
static bool pack_immed(u32 imm, u16 *val, enum immed_shift *shift)
|
static bool pack_immed(u32 imm, u16 *val, enum immed_shift *shift)
|
||||||
{
|
{
|
||||||
|
@ -1550,7 +1555,7 @@ static void nfp_outro(struct nfp_prog *nfp_prog)
|
||||||
static int nfp_translate(struct nfp_prog *nfp_prog)
|
static int nfp_translate(struct nfp_prog *nfp_prog)
|
||||||
{
|
{
|
||||||
struct nfp_insn_meta *meta;
|
struct nfp_insn_meta *meta;
|
||||||
int err;
|
int i, err;
|
||||||
|
|
||||||
nfp_intro(nfp_prog);
|
nfp_intro(nfp_prog);
|
||||||
if (nfp_prog->error)
|
if (nfp_prog->error)
|
||||||
|
@ -1582,6 +1587,11 @@ static int nfp_translate(struct nfp_prog *nfp_prog)
|
||||||
if (nfp_prog->error)
|
if (nfp_prog->error)
|
||||||
return nfp_prog->error;
|
return nfp_prog->error;
|
||||||
|
|
||||||
|
for (i = 0; i < NFP_USTORE_PREFETCH_WINDOW; i++)
|
||||||
|
emit_nop(nfp_prog);
|
||||||
|
if (nfp_prog->error)
|
||||||
|
return nfp_prog->error;
|
||||||
|
|
||||||
return nfp_fixup_branches(nfp_prog);
|
return nfp_fixup_branches(nfp_prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,6 +362,8 @@ int swreg_to_unrestricted(swreg dst, swreg lreg, swreg rreg,
|
||||||
int swreg_to_restricted(swreg dst, swreg lreg, swreg rreg,
|
int swreg_to_restricted(swreg dst, swreg lreg, swreg rreg,
|
||||||
struct nfp_insn_re_regs *reg, bool has_imm8);
|
struct nfp_insn_re_regs *reg, bool has_imm8);
|
||||||
|
|
||||||
|
#define NFP_USTORE_PREFETCH_WINDOW 8
|
||||||
|
|
||||||
int nfp_ustore_check_valid_no_ecc(u64 insn);
|
int nfp_ustore_check_valid_no_ecc(u64 insn);
|
||||||
u64 nfp_ustore_calc_ecc_insn(u64 insn);
|
u64 nfp_ustore_calc_ecc_insn(u64 insn);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue