Skip to content

Support writable CPU ID registers from userspace

Jing Zhang kvm kvmarm linux-arm-kernel 11 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v11 Latest5 patches 6 repliesIn review
  2. v105 patches 14 repliesSuperseded
  3. v95 patches 10 repliesSuperseded
Earlier versions · 8
VersionPostedPatchesRepliesStatus
v86 patches27 repliesSuperseded
v76 patches2 repliesSuperseded
v66 patches9 repliesSuperseded
v56 patches6 repliesSuperseded
v46 patches18 repliesSuperseded
v36 patches12 repliesSuperseded
v26 patches9 repliesSuperseded
v16 patches6 repliesSuperseded

Patches in v11 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5KVM: arm64: Save ID registers' sanitized value per guestarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/sys_regs.c +1 more+87 -130 replies
2/5KVM: arm64: Use per guest ID register for ID_AA64PFR0_EL1.[CSV2|CSV3]arch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/sys_regs.c+47 -290 replies
3/5KVM: arm64: Use per guest ID register for ID_AA64DFR0_EL1.PMUVerarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/sys_regs.c +1 more+52 -250 replies
4/5KVM: arm64: Reuse fields of sys_reg_desc for idregarch/arm64/kvm/sys_regs.c arch/arm64/kvm/sys_regs.h+82 -340 replies
5/5KVM: arm64: Refactor writings for PMUVer/CSV2/CSV3arch/arm64/include/asm/cpufeature.h arch/arm64/kernel/cpufeature.c arch/arm64/kvm/sys_regs.c+203 -915 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v11 yet.

Read the v11 thread

Cover letter [PATCH v11 0/5] Support writable CPU ID registers from userspace

This patchset refactors/adds code to support writable per guest CPU ID feature registers. Part of the code/ideas are from
https://lore.kernel.org/all/[email protected] . No functional change is intended in this patchset. With the new CPU ID feature registers infrastructure, only writtings of ID_AA64PFR0_EL1.[CSV2|CSV3], ID_AA64DFR0_EL1.PMUVer and ID_DFR0_ELF.PerfMon are allowed as KVM does before.

Writable (Configurable) per guest CPU ID feature registers are useful for creating/migrating guest on ARM CPUs with different kinds of features.

This patchset uses kvm->arch.config_lock from Oliver's lock inversion fixes at
https://lore.kernel.org/linux-arm-kernel/[email protected]/

---

* v10 - v11
- Rebased to v6.4-rc4.
- Move one time searching of first ID reg from kvm_arm_init_id_regs() to

    kvm_sys_reg_table_init().
  - Move the lock/unlock of arch.config_lock and whether vm has ran to
    kvm_sys_reg_get_user()/kvm_sys_reg_set_user().

- Addressed some other review comments from Marc and Oliver.

* v9 - v10
- Rebased to v6.4-rc3
- Addressed some review comments from v8/v9.

* v8 -> v9
- Rebased to v6.4-rc2.
- Don't create new file id_regs.c and don't move out id regs from sys_reg_descs array to reduce the changes.

* v7 -> v8
- Move idregs table sanity check to kvm_sys_reg_table_init.
- Only allow userspace writing before VM running.
- No lock is hold for guest access to idregs.
- Addressed some other comments from Reiji and Oliver.

* v6 -> v7
- Rebased to v6.3-rc7.
- Add helpers for idregs read/write.
- Guard all idregs reads/writes.
- Add code to fix features' safe value type which is different for KVM than for the host.

* v5 -> v6
- Rebased to v6.3-rc5.
- Reuse struct sys_reg_desc's reset() callback and field val for KVM. sanitisation function and writable mask instead of creating a new data structure for idregs.
- Use get_arm64_ftr_reg() instead of exposing idregs ftr_bits array.

* v4 -> v5
- Rebased to 2fad20ae05cb (kvmarm/next)
Merge branch kvm-arm64/selftest/misc-6,4 into kvmarm-master/next
- Use kvm->arch.config_lock to guard update to multiple VM scope idregs to avoid lock inversion
- Add back IDREG() macro for idregs access
- Refactor struct id_reg_desc by using existing infrastructure.
- Addressed many other comments from Marc.

* v3 -> v4
- Remove IDREG() macro for ID reg access, use simple array access instead
- Rename kvm_arm_read_id_reg_with_encoding() to kvm_arm_read_id_reg()
- Save perfmon value in ID_DFR0_EL1 instead of pmuver
- Update perfmon in ID_DFR0_EL1 and pmuver in ID_AA64DFR0_EL1 atomically
- Remove kvm_vcpu_has_pmu() in macro kvm_pmu_is_3p5()
- Improve ID register sanity checking in kvm_arm_check_idreg_table()

* v2 -> v3
- Rebased to 96a4627dbbd4 (kvmarm/next)
Merge tag ' https://github.com/oupton/linux tags/kvmarm-6.3' from into kvmarm-master/next
- Add id registere emulation entry point function emulate_id_reg
- Fix consistency for ID_AA64DFR0_EL1.PMUVer and ID_DFR0_EL1.PerfMon
- Improve the checking for id register table by ensuring that every entry has the correct id register encoding.
- Addressed other comments from Reiji and Marc.

* v1 -> v2
- Rebase to 7121a2e1d107 (kvmarm/next) Merge branch kvm-arm64/nv-prefix into kvmarm/next
- Address writing issue for PMUVer

[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]
[3] https://lore.kernel.org/all/[email protected]
[4] https://lore.kernel.org/all/[email protected]
[5] https://lore.kernel.org/all/[email protected]
[6] https://lore.kernel.org/all/[email protected]
[7] https://lore.kernel.org/all/[email protected]
[8] https://lore.kernel.org/all/[email protected]
[9] https://lore.kernel.org/all/[email protected]
[10] https://lore.kernel.org/all/[email protected]

---

Jing Zhang (5):
KVM: arm64: Save ID registers' sanitized value per guest
KVM: arm64: Use per guest ID register for ID_AA64PFR0_EL1.[CSV2|CSV3]
KVM: arm64: Use per guest ID register for ID_AA64DFR0_EL1.PMUVer
KVM: arm64: Reuse fields of sys_reg_desc for idreg
KVM: arm64: Refactor writings for PMUVer/CSV2/CSV3

 arch/arm64/include/asm/cpufeature.h |   1 +
 arch/arm64/include/asm/kvm_host.h   |  34 +-
 arch/arm64/kernel/cpufeature.c      |   2 +-
 arch/arm64/kvm/arm.c                |  24 +-
 arch/arm64/kvm/sys_regs.c           | 467 ++++++++++++++++++++++------
 arch/arm64/kvm/sys_regs.h           |  22 +-
 include/kvm/arm_pmu.h               |   9 +-
 7 files changed, 419 insertions(+), 140 deletions(-)

base-commit: 7877cb91f1081754a1487c144d85dc0d2e2e7fc4

Signature · 1 line
2.41.0.rc0.172.g3f132b7071-goog