Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Force guest EL1 to use user-space's partid configuration

While we trap the guest's attempts to read/write the MPAM control
registers, the hardware continues to use them. Guest-EL0 uses KVM's
user-space's configuration, as the value is left in the register, and
guest-EL1 uses either the host kernel's configuration, or in the case of
VHE, the UNKNOWN reset value of MPAM1_EL1.

We want to force the guest-EL1 to use KVM's user-space's MPAM
configuration. On nVHE rely on MPAM0_EL1 and MPAM1_EL1 always being
programmed the same and on VHE copy MPAM0_EL1 into the guest's
MPAM1_EL1. There is no need to restore as this is out of context once TGE
is set.

Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.com>
Tested-by: Jesse Chick <jessechick@os.amperecomputing.com>
Reviewed-by: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Co-developed-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>

+16
+16
arch/arm64/kvm/hyp/vhe/sysreg-sr.c
··· 183 183 } 184 184 NOKPROBE_SYMBOL(sysreg_restore_guest_state_vhe); 185 185 186 + /* 187 + * The _EL0 value was written by the host's context switch and belongs to the 188 + * VMM. Copy this into the guest's _EL1 register. 189 + */ 190 + static inline void __mpam_guest_load(void) 191 + { 192 + u64 mask = MPAM0_EL1_PARTID_D | MPAM0_EL1_PARTID_I | MPAM0_EL1_PMG_D | MPAM0_EL1_PMG_I; 193 + 194 + if (system_supports_mpam()) { 195 + u64 val = (read_sysreg_s(SYS_MPAM0_EL1) & mask) | MPAM1_EL1_MPAMEN; 196 + 197 + write_sysreg_el1(val, SYS_MPAM1); 198 + } 199 + } 200 + 186 201 /** 187 202 * __vcpu_load_switch_sysregs - Load guest system registers to the physical CPU 188 203 * ··· 237 222 */ 238 223 __sysreg32_restore_state(vcpu); 239 224 __sysreg_restore_user_state(guest_ctxt); 225 + __mpam_guest_load(); 240 226 241 227 if (unlikely(is_hyp_ctxt(vcpu))) { 242 228 __sysreg_restore_vel2_state(vcpu);