Skip to content

Fix some KVM/HYP interactions with kprobes

James Morse kvmarm linux-arm-kernel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 8 repliesIn review
  2. v14 patches 3 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: arm64: Forbid kprobing of the VHE world-switch codearch/arm64/kvm/hyp/switch.c arch/arm64/kvm/hyp/sysreg-sr.c+10 -05 replies
2/4arm64: kprobe: Always blacklist the KVM world-switch codearch/arm64/kernel/probes/kprobes.c+3 -31 reply
3/4arm64: hyp-stub: Forbid kprobing of the hyp-stubarch/arm64/kernel/hyp-stub.S+2 -02 replies
4/4arm64: hibernate: Clean the __hyp_text to PoC after resumearch/arm64/kernel/hibernate.c+3 -10 replies

Reviews trailers per patch

2 of 4 patches have a Reviewed-by or Acked-by.

PatchMasami HiramatsuChristoffer Dall
1/4A-b
2/4A-b R-b
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/4] Fix some KVM/HYP interactions with kprobes

Hi guys,

When looking at Masami Hiramatsu's kprobe cleanup series, it occurred to me the 'no KVM' isn't just about the EL1/EL2 split on non-VHE systems, but whether KVM is prepared to handle stepping on a breakpoint. It's not.

This labels all the VHE-only KVM functions that run during world switch with NOKPROBE_SYMBOL(), and always blacklists __hyp_text for kprobes to cover the common guest entry/exit code.

I anticipate patch 1 going via the KVM tree to avoid conflicts. Patch 2 will conflict with [0].

I'm not sure what the best thing to do with the hyp-stub is. Patch 3 moves it to __hyp_text, and patch 4 covers the hibernate fallout from doing that. We don't have any other mmu-off but not idmap'd text. Probing the hyp-stub has to be done by address as the symbol names alias those in the __entry_text, which is blacklisted. (although this might depend on link order). I think anyone doing this is trying to shoot themselves in the foot.

Know issues:
* Other regions we should blacklist are the kexec and hibernate 'copy everything' code, as the vectors may have been overwritten by the time we step on the probe. cpu-suspend needs investigating...

Thanks,

James

[0] lore.kernel.org/r/154753341900.31541.8135985235882849464.stgit@devbox

James Morse (4):
KVM: arm64: Forbid kprobing of the VHE world-switch code
arm64: kprobe: Always blacklist the KVM world-switch code
arm64: hyp-stub: Forbid kprobing of the hyp-stub
arm64: hibernate: Clean the __hyp_text to PoC after resume

 arch/arm64/kernel/hibernate.c      | 4 +++-
 arch/arm64/kernel/hyp-stub.S       | 2 ++
 arch/arm64/kernel/probes/kprobes.c | 6 +++---
 arch/arm64/kvm/hyp/switch.c        | 5 +++++
 arch/arm64/kvm/hyp/sysreg-sr.c     | 5 +++++
 5 files changed, 18 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1