Skip to content

KVM: arm64: Move PC/ELR/SPSR/PSTATE updatess to EL2

Marc Zyngier kvm 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 Latest11 patches 12 repliesIn review
  2. v111 patches 22 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11KVM: arm64: Don't adjust PC on SError during SMC traparch/arm64/kvm/handle_exit.c+8 -80 replies
2/11KVM: arm64: Move kvm_vcpu_trap_il_is32bit into kvm_skip_instr32()arch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/handle_exit.c arch/arm64/kvm/hyp/aarch32.c +3 more+12 -120 replies
3/11KVM: arm64: Make kvm_skip_instr() and co private to HYParch/arm64/include/asm/kvm_emulate.h arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/handle_exit.c +9 more+77 -318 replies
4/11KVM: arm64: Move PC rollback on SError to HYParch/arm64/kvm/handle_exit.c arch/arm64/kvm/hyp/include/hyp/switch.h+15 -170 replies
5/11KVM: arm64: Move VHE direct sysreg accessors into kvm_host.harch/arm64/include/asm/kvm_host.h arch/arm64/kvm/sys_regs.c+91 -810 replies
6/11KVM: arm64: Add basic hooks for injecting exceptions from EL2arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/hyp/exception.c arch/arm64/kvm/hyp/include/hyp/adjust_pc.h +2 more+53 -60 replies
7/11KVM: arm64: Inject AArch64 exceptions from HYParch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/hyp/exception.c arch/arm64/kvm/inject_fault.c+154 -1080 replies
8/11KVM: arm64: Inject AArch32 exceptions from HYParch/arm64/kvm/aarch32.c arch/arm64/kvm/hyp/exception.c+195 -1540 replies
9/11KVM: arm64: Remove SPSR manipulation primitivesarch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/regmap.c+0 -1220 replies
10/11KVM: arm64: Consolidate exception injectionarch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/Makefile arch/arm64/kvm/aarch32.c +1 more+73 -1020 replies
11/11KVM: arm64: Get rid of the AArch32 register mapping codearch/arm64/include/asm/kvm_emulate.h arch/arm64/kvm/Makefile arch/arm64/kvm/guest.c +1 more+26 -1344 replies

Reviews trailers per patch

5 of 11 patches have a Reviewed-by or Acked-by.

PatchMark Rutland
1/11A-b
2/11A-b
3/11
4/11
5/11A-b
6/11
7/11
8/11A-b
9/11A-b
10/11
11/11

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 00/11] KVM: arm64: Move PC/ELR/SPSR/PSTATE updatess to EL2

As we progress towards being able to keep the guest state private to the nVHE hypervisor, this series aims at moving anything that touches the registers involved into an exception to EL2.

The general idea is that any update to these registers is driven by a set of flags passed from EL1 to EL2, and EL2 will deal with the register update itself, removing the need for EL1 to see the guest state. It also results in a bunch of cleanup, mostly in the 32bit department (negative diffstat, yay!).

Of course, none of that has any real effect on security yet. It is only once we start having a private VCPU structure at EL2 that we can enforce the isolation. Similarly, there is no policy enforcement, and a malicious EL1 can still inject exceptions at random points. It can also give bogus ESR values to the guest. Baby steps.

        M.

* From v1 [1]
- Fix __kvm_skip_instr() unexpected recursion
- Fix HVC fixup updating the in-memory state instead of the guest's
- Dropped facilities for IRQ/FIQ/SError exception injection
- Simplified VHE/nVHE differences in exception injection
- Moved AArch32 exception injection over to AArch64 sysregs
- Use compat_lr_* instead of hardcoded registers
- Schpelling fyxes

[1] https://lore.kernel.org/r/[email protected]

Marc Zyngier (11):
KVM: arm64: Don't adjust PC on SError during SMC trap
KVM: arm64: Move kvm_vcpu_trap_il_is32bit into kvm_skip_instr32()
KVM: arm64: Make kvm_skip_instr() and co private to HYP
KVM: arm64: Move PC rollback on SError to HYP
KVM: arm64: Move VHE direct sysreg accessors into kvm_host.h
KVM: arm64: Add basic hooks for injecting exceptions from EL2
KVM: arm64: Inject AArch64 exceptions from HYP
KVM: arm64: Inject AArch32 exceptions from HYP
KVM: arm64: Remove SPSR manipulation primitives
KVM: arm64: Consolidate exception injection
KVM: arm64: Get rid of the AArch32 register mapping code

 arch/arm64/include/asm/kvm_emulate.h       |  70 +----
 arch/arm64/include/asm/kvm_host.h          | 118 +++++++-
 arch/arm64/kvm/Makefile                    |   4 +-
 arch/arm64/kvm/aarch32.c                   | 232 ---------------
 arch/arm64/kvm/guest.c                     |  28 +-
 arch/arm64/kvm/handle_exit.c               |  23 +-
 arch/arm64/kvm/hyp/aarch32.c               |   4 +-
 arch/arm64/kvm/hyp/exception.c             | 331 +++++++++++++++++++++
 arch/arm64/kvm/hyp/include/hyp/adjust_pc.h |  62 ++++
 arch/arm64/kvm/hyp/include/hyp/switch.h    |  17 ++
 arch/arm64/kvm/hyp/nvhe/Makefile           |   2 +-
 arch/arm64/kvm/hyp/nvhe/switch.c           |   3 +
 arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c   |   2 +
 arch/arm64/kvm/hyp/vgic-v3-sr.c            |   2 +
 arch/arm64/kvm/hyp/vhe/Makefile            |   2 +-
 arch/arm64/kvm/hyp/vhe/switch.c            |   3 +
 arch/arm64/kvm/inject_fault.c              | 189 +++++-------
 arch/arm64/kvm/mmio.c                      |   2 +-
 arch/arm64/kvm/mmu.c                       |   2 +-
 arch/arm64/kvm/regmap.c                    | 224 --------------
 arch/arm64/kvm/sys_regs.c                  |  83 +-----
 21 files changed, 666 insertions(+), 737 deletions(-)
 delete mode 100644 arch/arm64/kvm/aarch32.c
 create mode 100644 arch/arm64/kvm/hyp/exception.c
 create mode 100644 arch/arm64/kvm/hyp/include/hyp/adjust_pc.h
 delete mode 100644 arch/arm64/kvm/regmap.c
Signature · 1 line
2.28.0