[PATCH v4 10/14] KVM: arm64: Calculate cptr_el2 traps on activating traps
Quentin Perret
qperret at google.com
Wed Dec 11 04:46:12 PST 2024
On Monday 02 Dec 2024 at 15:47:37 (+0000), Fuad Tabba wrote:
> -static void pvm_init_traps_cptr(struct kvm_vcpu *vcpu)
> -{
> - struct kvm *kvm = vcpu->kvm;
> - u64 val = vcpu->arch.cptr_el2;
> -
> - if (!has_hvhe()) {
> - val |= CPTR_NVHE_EL2_RES1;
> - val &= ~(CPTR_NVHE_EL2_RES0);
> - }
> -
> - if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, AMU, IMP))
> - val |= CPTR_EL2_TAM;
> -
> - /* SVE can be disabled by userspace even if supported. */
> - if (!vcpu_has_sve(vcpu)) {
> - if (has_hvhe())
> - val &= ~(CPACR_ELx_ZEN);
> - else
> - val |= CPTR_EL2_TZ;
> - }
> -
> - /* No SME support in KVM. */
> - BUG_ON(kvm_has_feat(kvm, ID_AA64PFR1_EL1, SME, IMP));
> - if (has_hvhe())
> - val &= ~(CPACR_ELx_SMEN);
> - else
> - val |= CPTR_EL2_TSM;
> -
> - if (!kvm_has_feat(kvm, ID_AA64DFR0_EL1, TraceVer, IMP)) {
> - if (has_hvhe())
> - val |= CPACR_EL1_TTA;
> - else
> - val |= CPTR_EL2_TTA;
> - }
> -
> - vcpu->arch.cptr_el2 = val;
> -}
Mooh, wasn't this function added in this very series? Not a huge deal,
but is there any way we could consolidate things a bit?
More information about the linux-arm-kernel
mailing list