mbox series

[v5,00/17] KVM: arm64: Rework guest VM fixed feature handling and trapping in pKVM

Message ID 20241216105057.579031-1-tabba@google.com (mailing list archive)
Headers show
Series KVM: arm64: Rework guest VM fixed feature handling and trapping in pKVM | expand

Message

Fuad Tabba Dec. 16, 2024, 10:50 a.m. UTC
Changes from v4:
- (Oliver) Add assertion in kvm_init_pvm_id_regs() that vm_table
  lock is held.
- (Quentin) Carve out patches that fix RAS and that remove the
  feature KVM_ARM_VCPU_POWER_OFF from original patches, for clarity.
- (Quentin) Add a patch that refactors existing code to use
  kvm_vcpu_has_feature() instead of __vcpu_has_feature().
- (Quentin) Fixes to commit messages.

Other than added assertion, no functional changes between v4 and v5.

This patch series redoes how fixed features for protected guests
are specified in pKVM, as well as how trapping is handled based
on the features available for the VM. It also fixes a couple of
existing bugs in the process. Please refer to v4 for context [1].

This series is based on kvmarm/next (60ad25e14ab5), since it
requires the patches from the series that fixes initialization of
trap register values in pKVM [2].

Cheers,
/fuad

[1] https://lore.kernel.org/all/20241202154742.3611749-1-tabba@google.com/
[2] https://lore.kernel.org/all/20241018074833.2563674-1-tabba@google.com/

Fuad Tabba (17):
  KVM: arm64: Consolidate allowed and restricted VM feature checks
  KVM: arm64: Group setting traps for protected VMs by control register
  KVM: arm64: Move checking protected vcpu features to a separate
    function
  KVM: arm64: Remove KVM_ARM_VCPU_POWER_OFF from protected VMs allowed
    features in pKVM
  KVM: arm64: Use KVM extension checks for allowed protected VM
    capabilities
  KVM: arm64: Initialize feature id registers for protected VMs
  KVM: arm64: Fix RAS trapping in pKVM for protected VMs
  KVM: arm64: Set protected VM traps based on its view of feature
    registers
  KVM: arm64: Rework specifying restricted features for protected VMs
  KVM: arm64: Remove fixed_config.h header
  KVM: arm64: Remove redundant setting of HCR_EL2 trap bit
  KVM: arm64: Calculate cptr_el2 traps on activating traps
  KVM: arm64: Refactor kvm_reset_cptr_el2()
  KVM: arm64: Fix the value of the CPTR_EL2 RES1 bitmask for nVHE
  KVM: arm64: Remove PtrAuth guest vcpu flag
  KVM: arm64: Convert the SVE guest vcpu flag to a vm flag
  KVM: arm64: Use kvm_vcpu_has_feature() directly for struct kvm

 arch/arm64/include/asm/kvm_arm.h              |   2 +-
 arch/arm64/include/asm/kvm_emulate.h          |  29 +-
 arch/arm64/include/asm/kvm_host.h             |  25 +-
 arch/arm64/include/asm/kvm_pkvm.h             |  25 ++
 arch/arm64/kvm/arm.c                          |  30 +-
 .../arm64/kvm/hyp/include/nvhe/fixed_config.h | 223 ----------
 arch/arm64/kvm/hyp/include/nvhe/pkvm.h        |   7 +
 arch/arm64/kvm/hyp/nvhe/pkvm.c                | 341 ++++++---------
 arch/arm64/kvm/hyp/nvhe/setup.c               |   1 -
 arch/arm64/kvm/hyp/nvhe/switch.c              |  52 ++-
 arch/arm64/kvm/hyp/nvhe/sys_regs.c            | 404 ++++++++++--------
 arch/arm64/kvm/nested.c                       |   8 +-
 arch/arm64/kvm/reset.c                        |   6 +-
 13 files changed, 446 insertions(+), 707 deletions(-)
 delete mode 100644 arch/arm64/kvm/hyp/include/nvhe/fixed_config.h


base-commit: 60ad25e14ab5a4e56c8bf7f7d6846eacb9cd53df

Comments

Marc Zyngier Dec. 20, 2024, 3:22 p.m. UTC | #1
On Mon, 16 Dec 2024 10:50:40 +0000, Fuad Tabba wrote:
> Changes from v4:
> - (Oliver) Add assertion in kvm_init_pvm_id_regs() that vm_table
>   lock is held.
> - (Quentin) Carve out patches that fix RAS and that remove the
>   feature KVM_ARM_VCPU_POWER_OFF from original patches, for clarity.
> - (Quentin) Add a patch that refactors existing code to use
>   kvm_vcpu_has_feature() instead of __vcpu_has_feature().
> - (Quentin) Fixes to commit messages.
> 
> [...]

Applied to next, thanks!

There was a number of conflicts applying this to -rc3, and then
some more with Quentin's series. Please check kvmarm/next to make
sure that I did the right thing.

[01/17] KVM: arm64: Consolidate allowed and restricted VM feature checks
        commit: 2589dbd72797a4163dd998b05c4663ff98bd0771
[02/17] KVM: arm64: Group setting traps for protected VMs by control register
        commit: f50758260bfff393f2a800469b37c45a7ef50376
[03/17] KVM: arm64: Move checking protected vcpu features to a separate function
        commit: 1fea164ccf19750c5bea688afd9122eb84eb3a72
[04/17] KVM: arm64: Remove KVM_ARM_VCPU_POWER_OFF from protected VMs allowed features in pKVM
        commit: 27f5cf8ad5224033a711aef3fde90b60c9a8d7d5
[05/17] KVM: arm64: Use KVM extension checks for allowed protected VM capabilities
        commit: a3163dca4817e9a30b154a14c793641e39a00592
[06/17] KVM: arm64: Initialize feature id registers for protected VMs
        commit: 7ba5b8f80475e48b486f095ee9fb67dc9f9d02df
[07/17] KVM: arm64: Fix RAS trapping in pKVM for protected VMs
        commit: 9df9186f8df513dc9bf9f95f68525c7ebc941bcd
[08/17] KVM: arm64: Set protected VM traps based on its view of feature registers
        commit: 0401f7e76d707741d2562f4988743cc5daf445e4
[09/17] KVM: arm64: Rework specifying restricted features for protected VMs
        commit: 3d7ff00700d1a4d0c8f092f2c1bf67553a8c7c4c
[10/17] KVM: arm64: Remove fixed_config.h header
        commit: 81403c8d04e1d85209cdb0e0ce32aa0019620c65
[11/17] KVM: arm64: Remove redundant setting of HCR_EL2 trap bit
        commit: 092e7b2c3b1a5591bbabc358f3b709dfa2289b91
[12/17] KVM: arm64: Calculate cptr_el2 traps on activating traps
        commit: 2fd5b4b0e7b440602455b79977bfa64dea101e6c
[13/17] KVM: arm64: Refactor kvm_reset_cptr_el2()
        commit: 8f7df795b2da0564b22a03c4aceec90bfc5e1b1b
[14/17] KVM: arm64: Fix the value of the CPTR_EL2 RES1 bitmask for nVHE
        commit: 1eccad35c9268f1ad4be3d72d37167a58c0ac2db
[15/17] KVM: arm64: Remove PtrAuth guest vcpu flag
        commit: c5c1763596660fcd77a1190b3bd78bbe24bcfd6a
[16/17] KVM: arm64: Convert the SVE guest vcpu flag to a vm flag
        commit: 41d6028e28bd474298ff10409c292ec46cf43a90
[17/17] KVM: arm64: Use kvm_vcpu_has_feature() directly for struct kvm
        commit: aac64ad36955268d65375c32415d5bcf1bd1dd47

Cheers,

	M.