Skip to content

Commit f2b3d85

Browse files
James Morsewildea01
authored andcommitted
arm64: kprobe: Always blacklist the KVM world-switch code
On systems with VHE the kernel and KVM's world-switch code run at the same exception level. Code that is only used on a VHE system does not need to be annotated as __hyp_text as it can reside anywhere in the kernel text. __hyp_text was also used to prevent kprobes from patching breakpoint instructions into this region, as this code runs at a different exception level. While this is no longer true with VHE, KVM still switches VBAR_EL1, meaning a kprobe's breakpoint executed in the world-switch code will cause a hyp-panic. Move the __hyp_text check in the kprobes blacklist so it applies on VHE systems too, to cover the common code and guest enter/exit assembly. Fixes: 888b3c8 ("arm64: Treat all entry code as non-kprobe-able") Reviewed-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: James Morse <james.morse@arm.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 8ea2359 commit f2b3d85

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/arm64/kernel/probes/kprobes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,13 @@ bool arch_within_kprobe_blacklist(unsigned long addr)
478478
addr < (unsigned long)__entry_text_end) ||
479479
(addr >= (unsigned long)__idmap_text_start &&
480480
addr < (unsigned long)__idmap_text_end) ||
481+
(addr >= (unsigned long)__hyp_text_start &&
482+
addr < (unsigned long)__hyp_text_end) ||
481483
!!search_exception_tables(addr))
482484
return true;
483485

484486
if (!is_kernel_in_hyp_mode()) {
485-
if ((addr >= (unsigned long)__hyp_text_start &&
486-
addr < (unsigned long)__hyp_text_end) ||
487-
(addr >= (unsigned long)__hyp_idmap_text_start &&
487+
if ((addr >= (unsigned long)__hyp_idmap_text_start &&
488488
addr < (unsigned long)__hyp_idmap_text_end))
489489
return true;
490490
}

0 commit comments

Comments
 (0)