Message ID | 20241030160317.2528209-1-joey.gouly@arm.com (mailing list archive) |
---|---|
Headers | show |
Series | KVM: arm64: Hide unsupported MPAM from the guest | expand |
Hi, Thanks for respinning this Joey. On Wed, Oct 30, 2024 at 04:03:10PM +0000, Joey Gouly wrote: > Hi, > > changes since v5 [1]: > - Removed Kconfig option, the KVM traps shouldn't rely on host kernel support > - Renamed cpus_support_* to system_supports_* since that matches other functions > - Replace static branch arm64_mpam_has_hcr with a normal cpufeature capability > - Add MPAM*_EL2 regs to KVM (undef_access) > - Use constants in the test, instead of hardcoded values > - Added R-b and T-b tags > - Rebased on v6.12-rc5 > > James wrote: > This series fixes up a long standing bug where MPAM was accidentally exposed > to a guest, but the feature was not otherwise trapped or context switched. > This could result in KVM warning about unexpected traps, and injecting an > undef into the guest contradicting the ID registers. > This would prevent an MPAM aware kernel from booting - fortunately, there > aren't any of those. > > Ideally, we'd take the MPAM feature away from the ID registers, but that > would leave existing guests unable to migrate to a newer kernel. Instead, > just ignore that field when it matches the hardware. KVM wasn't going to > expose MPAM anyway. The guest will not see MPAM in the id registers. > > This series includes the head.S and KVM changes to enable/disable traps. If > MPAM is neither enabled nor emulated by EL3 firmware, these system register > accesses will trap to EL3. > If your kernel doesn't boot, and the problem bisects here - please update > your firmware. MPAM has been supported by trusted firmware since v1.6 in > 2018. (also noted on patch 3). This is looking pretty good to me, and I'd really like to have it in for 6.13. Will/Catalin, first 3 patches look OK to you?
On Wed, 30 Oct 2024 16:03:10 +0000, Joey Gouly <joey.gouly@arm.com> wrote: > > Hi, > > changes since v5 [1]: > - Removed Kconfig option, the KVM traps shouldn't rely on host kernel support > - Renamed cpus_support_* to system_supports_* since that matches other functions > - Replace static branch arm64_mpam_has_hcr with a normal cpufeature capability > - Add MPAM*_EL2 regs to KVM (undef_access) > - Use constants in the test, instead of hardcoded values > - Added R-b and T-b tags > - Rebased on v6.12-rc5 > > James wrote: > This series fixes up a long standing bug where MPAM was accidentally exposed > to a guest, but the feature was not otherwise trapped or context switched. > This could result in KVM warning about unexpected traps, and injecting an > undef into the guest contradicting the ID registers. > This would prevent an MPAM aware kernel from booting - fortunately, there > aren't any of those. > > Ideally, we'd take the MPAM feature away from the ID registers, but that > would leave existing guests unable to migrate to a newer kernel. Instead, > just ignore that field when it matches the hardware. KVM wasn't going to > expose MPAM anyway. The guest will not see MPAM in the id registers. > > This series includes the head.S and KVM changes to enable/disable traps. If > MPAM is neither enabled nor emulated by EL3 firmware, these system register > accesses will trap to EL3. > If your kernel doesn't boot, and the problem bisects here - please update > your firmware. MPAM has been supported by trusted firmware since v1.6 in > 2018. (also noted on patch 3). > > Thanks, > Joey > > [1] https://lore.kernel.org/kvmarm/20241015133923.3910916-1-joey.gouly@arm.com/ > > James Morse (7): > arm64/sysreg: Convert existing MPAM sysregs and add the remaining > entries > arm64: head.S: Initialise MPAM EL2 registers and disable traps > arm64: cpufeature: discover CPU support for MPAM > KVM: arm64: Fix missing traps of guest accesses to the MPAM registers > KVM: arm64: Add a macro for creating filtered sys_reg_descs entries > KVM: arm64: Disable MPAM visibility by default and ignore VMM writes > KVM: arm64: selftests: Test ID_AA64PFR0.MPAM isn't completely ignored > > .../arch/arm64/cpu-feature-registers.rst | 2 + > arch/arm64/include/asm/cpu.h | 1 + > arch/arm64/include/asm/cpucaps.h | 5 + > arch/arm64/include/asm/cpufeature.h | 17 ++ > arch/arm64/include/asm/el2_setup.h | 14 ++ > arch/arm64/include/asm/kvm_arm.h | 1 + > arch/arm64/include/asm/sysreg.h | 12 -- > arch/arm64/kernel/cpufeature.c | 96 +++++++++++ > arch/arm64/kernel/cpuinfo.c | 3 + > arch/arm64/kvm/hyp/include/hyp/switch.h | 31 ++++ > arch/arm64/kvm/sys_regs.c | 121 +++++++++---- > arch/arm64/tools/cpucaps | 2 + > arch/arm64/tools/sysreg | 161 ++++++++++++++++++ > .../selftests/kvm/aarch64/set_id_regs.c | 99 ++++++++++- > 14 files changed, 523 insertions(+), 42 deletions(-) For the series: Reviewed-by: Marc Zyngier <maz@kernel.org> M.
On Wed, 30 Oct 2024 16:03:10 +0000, Joey Gouly wrote: > changes since v5 [1]: > - Removed Kconfig option, the KVM traps shouldn't rely on host kernel support > - Renamed cpus_support_* to system_supports_* since that matches other functions > - Replace static branch arm64_mpam_has_hcr with a normal cpufeature capability > - Add MPAM*_EL2 regs to KVM (undef_access) > - Use constants in the test, instead of hardcoded values > - Added R-b and T-b tags > - Rebased on v6.12-rc5 > > [...] Applied to kvmarm/next, thanks! [1/7] arm64/sysreg: Convert existing MPAM sysregs and add the remaining entries https://git.kernel.org/kvmarm/kvmarm/c/83732ce6a056 [2/7] arm64: head.S: Initialise MPAM EL2 registers and disable traps https://git.kernel.org/kvmarm/kvmarm/c/23b33d1e168c [3/7] arm64: cpufeature: discover CPU support for MPAM https://git.kernel.org/kvmarm/kvmarm/c/09e6b306f3ba [4/7] KVM: arm64: Fix missing traps of guest accesses to the MPAM registers https://git.kernel.org/kvmarm/kvmarm/c/31ff96c38ea3 [5/7] KVM: arm64: Add a macro for creating filtered sys_reg_descs entries https://git.kernel.org/kvmarm/kvmarm/c/7da540e29dea [6/7] KVM: arm64: Disable MPAM visibility by default and ignore VMM writes https://git.kernel.org/kvmarm/kvmarm/c/6685f5d572c2 [7/7] KVM: arm64: selftests: Test ID_AA64PFR0.MPAM isn't completely ignored https://git.kernel.org/kvmarm/kvmarm/c/75cd027cbcb1 -- Best, Oliver