• Naveen N. Rao's avatar
    powerpc: Reject probes on instructions that can't be single stepped · 54cdacd7
    Naveen N. Rao authored
    Per the ISA, a Trace interrupt is not generated for:
    - [h|u]rfi[d]
    - rfscv
    - sc, scv, and Trap instructions that trap
    - Power-Saving Mode instructions
    - other instructions that cause interrupts (other than Trace interrupts)
    - the first instructions of any interrupt handler (applies to Branch and Single Step tracing;
    CIABR matches may still occur)
    - instructions that are emulated by software
    
    Add a helper to check for instructions belonging to the first four
    categories above and to reject kprobes, uprobes and xmon breakpoints on
    such instructions. We reject probing on instructions belonging to these
    categories across all ISA versions and across both BookS and BookE.
    
    For trap instructions, we can't know in advance if they can cause a
    trap, and there is no good reason to allow probing on those. Also,
    uprobes already refuses to probe trap instructions and kprobes does not
    allow probes on trap instructions used for kernel warnings and bugs. As
    such, stop allowing any type of probes/breakpoints on trap instruction
    across uprobes, kprobes and xmon.
    
    For some of the fp/altivec instructions that can generate an interrupt
    and which we emulate in the kernel (altivec assist, for example), we
    check and turn off single stepping in emulate_single_step().
    
    Instructions generating a DSI are restarted and single stepping normally
    completes once the instruction is completed.
    
    In uprobes, if a single stepped instruction results in a non-fatal
    signal to be delivered to the task, such signals are "delayed" until
    after the instruction completes. For fatal signals, single stepping is
    cancelled and the instruction restarted in-place so that core dump
    captures proper addresses.
    
    In kprobes, we do not allow probes on instructions having an extable
    entry and we also do not allow probing interrupt vectors.
    Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/f56ee979d50b8711fae350fc97870f3ca34acd75.1648648712.git.naveen.n.rao@linux.vnet.ibm.com
    54cdacd7
xmon.c 92.3 KB