On Tue, Nov 01, 2022 at 01:33:16PM +0000, Marc Zyngier wrote:
Mark Brown broonie@kernel.org wrote:
- if (cpus_have_final_cap(ARM64_SME))
- if (cpus_have_final_cap(ARM64_SME)) { write_sysreg(read_sysreg(sctlr_el2) & ~SCTLR_ELx_ENTP2, sctlr_el2);
I still question this. As far as I can tell, it only affects the host context (HCR_EL2.{E2H,TGE}={1,1}).
This is outlined in the description of the HFGWTR_EL2.nTPIDR2_EL0 bit:
Oh, I see what you meant there - I was purely focusing on the new code with the fine grained traps, not the existing code.
So I can only conclude that messing with SCTLR_EL2 is superfluous and doesn't affect the execution in a guest context.
Yes, if you look at the pseudocode for TPIDR2_EL0 that's the case. It's either EnTP2 for HCR_EL2.<E2H,TGE> == '11' or the fine grained trap otherwise.
/*
* Enable access to SMPRI_EL1 - we don't need to
* control nTPIDR2_EL0 in VHE mode.
*/
This comment is factually wrong.
Bah, I fixed one but not the other sorry :/
Date: Tue, 1 Nov 2022 12:19:51 +0000 Subject: [PATCH] KVM: arm64: Fix SMPRI_EL1/TPIDR2_EL0 trapping on VHE
The trapping of SMPRI_EL1 and TPIDR2_EL0 currently only really work on nVHE, as only this mode uses the fine-grained trapping that controls these two registers.
Move the trapping enable/disable code into __{de,}activate_traps_common(), allowing it to be called when it actually matters on VHE, and remove the flipping of EL2 control for TPIDR2_EL0, which only affects the host access of this register.
Fixes: 861262ab8627 ("KVM: arm64: Handle SME host state when running guests") Signed-off-by: Marc Zyngier maz@kernel.org Cc: stable@vger.kernel.org
Reported-by: Mark Brown broonie@kernel.org Reviewed-by: Mark Brown broonie@kernel.org