arm64: kprobes: Restore local irqflag if kprobes is cancelled
authorJisheng Zhang <Jisheng.Zhang@synaptics.com>
Mon, 12 Apr 2021 09:41:01 +0000 (17:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Apr 2021 11:40:02 +0000 (13:40 +0200)
commit509ae27a1874389182b3709de0940a8f8d4dfb8b
treea034c96f33681a2031edd1189ad0a6d5a9a7187a
parentda99331fc6ce2d25f88d47249f04714633d3f0ec
arm64: kprobes: Restore local irqflag if kprobes is cancelled

[ Upstream commit 738fa58ee1328481d1d7889e7c430b3401c571b9 ]

If instruction being single stepped caused a page fault, the kprobes
is cancelled to let the page fault handler continue as a normal page
fault. But the local irqflags are disabled so cpu will restore pstate
with DAIF masked. After pagefault is serviced, the kprobes is
triggerred again, we overwrite the saved_irqflag by calling
kprobes_save_local_irqflag(). NOTE, DAIF is masked in this new saved
irqflag. After kprobes is serviced, the cpu pstate is retored with
DAIF masked.

This patch is inspired by one patch for riscv from Liao Chang.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20210412174101.6bfb0594@xhacker.debian
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm64/kernel/probes/kprobes.c