mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
s390/bpf: Support internal-only MOV instruction to resolve per-CPU addrs
The verifier emits BPF_MOV64_PERCPU_REG to turn the address of a per-cpu variable into the address of the copy of this cpu. s390 keeps the per-cpu offset of the cpu in the lowcore. Add it to the register with one insn, the way the JIT reads cpu_nr and current_task for the helpers that it inlines. With bpf_jit_supports_percpu_insn() the verifier inlines the lookup in per-cpu array and per-cpu hash maps, and resolves the address of a value in a per-cpu array. Patch 7 needs the insn for may_goto. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261031215543.682284-6-alexei.starovoitov@gmail.com
This commit is contained in:
parent
5eced83779
commit
85b6a11252
|
|
@ -1005,6 +1005,17 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
|
|||
(jit->prg - patch_brc) >> 1;
|
||||
break;
|
||||
}
|
||||
if (insn_is_mov_percpu_addr(insn)) {
|
||||
const u64 *percpu_offset = &get_lowcore()->percpu_offset;
|
||||
|
||||
if (dst_reg != src_reg)
|
||||
/* lgr %dst,%src */
|
||||
EMIT4(0xb9040000, dst_reg, src_reg);
|
||||
/* ag %dst,percpu_offset */
|
||||
EMIT6_DISP_LH(0xe3000000, 0x0008, dst_reg, REG_0, REG_0,
|
||||
(unsigned long)percpu_offset);
|
||||
break;
|
||||
}
|
||||
switch (insn->off) {
|
||||
case 0: /* DST = SRC */
|
||||
/* lgr %dst,%src */
|
||||
|
|
@ -3114,6 +3125,11 @@ bool bpf_jit_supports_timed_may_goto(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool bpf_jit_supports_percpu_insn(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bpf_jit_inlines_helper_call(s32 imm)
|
||||
{
|
||||
switch (imm) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user