• Youling Tang's avatar
    LoongArch: BPF: Add BPF exception tables · dbcd7f5f
    Youling Tang authored
    Inspired by commit 80083428("bpf, arm64: Add BPF exception tables"),
    do similar to LoongArch to add BPF exception tables.
    
    When a tracing BPF program attempts to read memory without using the
    bpf_probe_read() helper, the verifier marks the load instruction with
    the BPF_PROBE_MEM flag. Since the LoongArch JIT does not currently
    recognize this flag it falls back to the interpreter.
    
    Add support for BPF_PROBE_MEM, by appending an exception table to the
    BPF program. If the load instruction causes a data abort, the fixup
    infrastructure finds the exception table and fixes up the fault, by
    clearing the destination register and jumping over the faulting
    instruction.
    
    To keep the compact exception table entry format, inspect the pc in
    fixup_exception(). A more generic solution would add a "handler" field
    to the table entry, like on x86, s390 and arm64, etc.
    Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
    Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
    dbcd7f5f
bpf_jit.h 7.07 KB