ANDROID: KVM: arm64: speacialize and move __activate_traps_hcrx out of __activate_traps_common

In future patches, this function isn't going to be used for
protected VMs. Therefore, move it out of the common function so
that in can be selectively called in future patches.

Moreover, it's behavior betwen VHE and nVHE is going to diverge.

No functional change intended.

Bug: 278749606
Change-Id: I583f5af74edf93a52c2d0328421ed68c7072d507
Signed-off-by: Fuad Tabba <tabba@google.com>
This commit is contained in:
Fuad Tabba 2023-12-12 14:03:45 +00:00
parent 289f66c4ee
commit 991bca2981
3 changed files with 16 additions and 9 deletions

View File

@ -221,20 +221,25 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu)
vcpu->arch.mdcr_el2_host = read_sysreg(mdcr_el2); vcpu->arch.mdcr_el2_host = read_sysreg(mdcr_el2);
write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
}
if (cpus_have_final_cap(ARM64_HAS_HCX)) { static inline void __activate_traps_hcrx(struct kvm_vcpu *vcpu)
u64 hcrx = HCRX_GUEST_FLAGS; {
if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu)) { u64 hcrx = HCRX_GUEST_FLAGS;
u64 clr = 0, set = 0;
compute_clr_set(vcpu, HCRX_EL2, clr, set); if (!cpus_have_final_cap(ARM64_HAS_HCX))
return;
hcrx |= set; if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu)) {
hcrx &= ~clr; u64 clr = 0, set = 0;
}
write_sysreg_s(hcrx, SYS_HCRX_EL2); compute_clr_set(vcpu, HCRX_EL2, clr, set);
hcrx |= set;
hcrx &= ~clr;
} }
write_sysreg_s(hcrx, SYS_HCRX_EL2);
} }
static inline void __deactivate_traps_common(struct kvm_vcpu *vcpu) static inline void __deactivate_traps_common(struct kvm_vcpu *vcpu)

View File

@ -43,6 +43,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
___activate_traps(vcpu); ___activate_traps(vcpu);
__activate_traps_common(vcpu); __activate_traps_common(vcpu);
__activate_traps_hcrx(vcpu);
__activate_traps_hfgxtr(vcpu); __activate_traps_hfgxtr(vcpu);
val = vcpu->arch.cptr_el2; val = vcpu->arch.cptr_el2;

View File

@ -148,6 +148,7 @@ void activate_traps_vhe_load(struct kvm_vcpu *vcpu)
local_irq_save(flags); local_irq_save(flags);
__activate_traps_common(vcpu); __activate_traps_common(vcpu);
__activate_traps_hcrx(vcpu);
__activate_traps_hfgxtr(vcpu); __activate_traps_hfgxtr(vcpu);
local_irq_restore(flags); local_irq_restore(flags);
} }