Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[sfrench/cifs-2.6.git] / arch / arm64 / kvm / hyp / switch.c
index 4994f4bdaca5d49f7bc31f6a229b46ce7f0257d6..525c01f48867808b6efa257063daaa4c8207252e 100644 (file)
@@ -48,7 +48,7 @@ static void __hyp_text __activate_traps_vhe(void)
 
        val = read_sysreg(cpacr_el1);
        val |= CPACR_EL1_TTA;
-       val &= ~CPACR_EL1_FPEN;
+       val &= ~(CPACR_EL1_FPEN | CPACR_EL1_ZEN);
        write_sysreg(val, cpacr_el1);
 
        write_sysreg(__kvm_hyp_vector, vbar_el1);
@@ -59,7 +59,7 @@ static void __hyp_text __activate_traps_nvhe(void)
        u64 val;
 
        val = CPTR_EL2_DEFAULT;
-       val |= CPTR_EL2_TTA | CPTR_EL2_TFP;
+       val |= CPTR_EL2_TTA | CPTR_EL2_TFP | CPTR_EL2_TZ;
        write_sysreg(val, cptr_el2);
 }
 
@@ -81,11 +81,17 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
         * it will cause an exception.
         */
        val = vcpu->arch.hcr_el2;
+
        if (!(val & HCR_RW) && system_supports_fpsimd()) {
                write_sysreg(1 << 30, fpexc32_el2);
                isb();
        }
+
+       if (val & HCR_RW) /* for AArch64 only: */
+               val |= HCR_TID3; /* TID3: trap feature register accesses */
+
        write_sysreg(val, hcr_el2);
+
        /* Trap on AArch32 cp15 c15 accesses (EL1 or EL0) */
        write_sysreg(1 << 15, hstr_el2);
        /*
@@ -111,7 +117,7 @@ static void __hyp_text __deactivate_traps_vhe(void)
 
        write_sysreg(mdcr_el2, mdcr_el2);
        write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
-       write_sysreg(CPACR_EL1_FPEN, cpacr_el1);
+       write_sysreg(CPACR_EL1_DEFAULT, cpacr_el1);
        write_sysreg(vectors, vbar_el1);
 }