Skip to content

Commit 306b4c9

Browse files
kristina-martsenkoctmarinas
authored andcommitted
KVM: arm64: switch HCRX_EL2 between host and guest
Switch the HCRX_EL2 register between host and guest configurations, in order to enable different features in the host and guest. Now that there are separate guest flags, we can also remove SMPME from the host flags, as SMPME is used for virtualizing SME priorities and has no use in the host. Signed-off-by: Kristina Martsenko <[email protected]> Acked-by: Marc Zyngier <[email protected]> Acked-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent b0c756f commit 306b4c9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

arch/arm64/include/asm/kvm_arm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
#define HCR_HOST_NVHE_PROTECTED_FLAGS (HCR_HOST_NVHE_FLAGS | HCR_TSC)
9494
#define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H)
9595

96-
#define HCRX_HOST_FLAGS (HCRX_EL2_SMPME)
96+
#define HCRX_GUEST_FLAGS (HCRX_EL2_SMPME)
97+
#define HCRX_HOST_FLAGS 0
9798

9899
/* TCR_EL2 Registers bits */
99100
#define TCR_EL2_RES1 ((1U << 31) | (1 << 23))

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ static inline void ___activate_traps(struct kvm_vcpu *vcpu)
130130

131131
if (cpus_have_final_cap(ARM64_HAS_RAS_EXTN) && (hcr & HCR_VSE))
132132
write_sysreg_s(vcpu->arch.vsesr_el2, SYS_VSESR_EL2);
133+
134+
if (cpus_have_final_cap(ARM64_HAS_HCX))
135+
write_sysreg_s(HCRX_GUEST_FLAGS, SYS_HCRX_EL2);
133136
}
134137

135138
static inline void ___deactivate_traps(struct kvm_vcpu *vcpu)
@@ -144,6 +147,9 @@ static inline void ___deactivate_traps(struct kvm_vcpu *vcpu)
144147
vcpu->arch.hcr_el2 &= ~HCR_VSE;
145148
vcpu->arch.hcr_el2 |= read_sysreg(hcr_el2) & HCR_VSE;
146149
}
150+
151+
if (cpus_have_final_cap(ARM64_HAS_HCX))
152+
write_sysreg_s(HCRX_HOST_FLAGS, SYS_HCRX_EL2);
147153
}
148154

149155
static inline bool __populate_fault_info(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)