Skip to contentSkip to conversation

KVM: arm64: Synchronize SMEN on vcpu schedule out

PATCH Applied Dong Bo 4 participants 4 messages Dec 20, 2022 – Jan 23, 2023

Subsystems (2)
lore
Share & tools
lore

Dong Bo

author
#0 lore raw

PATCH 1/1 KVM: arm64: Synchronize SMEN on vcpu schedule out

From: Nianyao Tang <[email protected]>

If we have VHE and need to reenable SME for host in kvm_arch_vcpu_put_fp, CPACR.SMEN is modified from 0 to 1. Trap control for reading SVCR is modified from enable to disable. Synchronization is needed before reading SVCR later in fpsimd_save, or it may cause sync exception which can not be handled by host.

Cc Marc Zyngier <[email protected]>
Cc James Morse <[email protected]>
Cc Alexandru Elisei <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc Oliver Upton <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
---
 arch/arm64/kvm/fpsimd.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kvm/fpsimd.c +1 -0
index 02dd7e9ebd39..f5799f571317 100644
@@ -184,6 +184,7 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
 			sysreg_clear_set(CPACR_EL1,
 					 CPACR_EL1_SMEN_EL0EN,
 					 CPACR_EL1_SMEN_EL1EN);
+		isb();
 	}
 
 	if (vcpu->arch.fp_state == FP_STATE_GUEST_OWNED) {
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw

+ Mark

Quoted 38 lines · Dong Bo

From: Nianyao Tang <[email protected]>

If we have VHE and need to reenable SME for host in kvm_arch_vcpu_put_fp, CPACR.SMEN is modified from 0 to 1. Trap control for reading SVCR is modified from enable to disable. Synchronization is needed before reading SVCR later in fpsimd_save, or it may cause sync exception which can not be handled by host.

Cc Marc Zyngier <[email protected]>
Cc James Morse <[email protected]>
Cc Alexandru Elisei <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc Oliver Upton <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
---
 arch/arm64/kvm/fpsimd.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kvm/fpsimd.c +1 -0
index 02dd7e9ebd39..f5799f571317 100644
@@ -184,6 +184,7 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
 			sysreg_clear_set(CPACR_EL1,
 					 CPACR_EL1_SMEN_EL0EN,
 					 CPACR_EL1_SMEN_EL1EN);
+		isb();
 	}
 
 	if (vcpu->arch.fp_state == FP_STATE_GUEST_OWNED) {
Signature · 1 line
1.8.3.1
Signature · 1 line
Without deviation from the norm, progress is not possible.
Reviewed-by
#2 lore raw
Quoted 8 lines · Marc Zyngier
Quoted 6 lines · Dong Bo

If we have VHE and need to reenable SME for host in kvm_arch_vcpu_put_fp, CPACR.SMEN is modified from 0 to 1. Trap control for reading SVCR is modified from enable to disable. Synchronization is needed before reading SVCR later in fpsimd_save, or it may cause sync exception which can not be handled by host.

Applied
#3 lore raw
In reply to Dong Bo
Quoted 10 lines · Dong Bo

From: Nianyao Tang <[email protected]>

If we have VHE and need to reenable SME for host in kvm_arch_vcpu_put_fp, CPACR.SMEN is modified from 0 to 1. Trap control for reading SVCR is modified from enable to disable. Synchronization is needed before reading SVCR later in fpsimd_save, or it may cause sync exception which can not be handled by host.

[...]

Applied to kvmarm/next, thanks!

[1/1] KVM: arm64: Synchronize SMEN on vcpu schedule out

      https://git.kernel.org/kvmarm/kvmarm/c/59d78a2ec0e9

--
Best,
Oliver