]> Git Repo - linux.git/commitdiff
Merge tag 'kvmarm-fixes-6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorPaolo Bonzini <[email protected]>
Fri, 14 Feb 2025 23:32:47 +0000 (18:32 -0500)
committerPaolo Bonzini <[email protected]>
Fri, 14 Feb 2025 23:32:47 +0000 (18:32 -0500)
KVM/arm64 fixes for 6.14, take #2

- Large set of fixes for vector handling, specially in the interactions
  between host and guest state. This fixes a number of bugs affecting
  actual deployments, and greatly simplifies the FP/SIMD/SVE handling.
  Thanks to Mark Rutland for dealing with this thankless task.

- Fix an ugly race between vcpu and vgic creation/init, resulting in
  unexpected behaviours.

- Fix use of kernel VAs at EL2 when emulating timers with nVHE.

- Small set of pKVM improvements and cleanups.

1  2 
arch/arm64/kernel/fpsimd.c
arch/arm64/kvm/arm.c

index 2b601d88762d41f546b618a3c448118a18317136,ec68d520b7ca70e7395bab4bc78fc9a7405d6b92..8370d55f035334edf9d4f01fb33e1054bddadf71
@@@ -562,7 -562,7 +562,7 @@@ static int vec_proc_do_default_vl(cons
        return 0;
  }
  
 -static struct ctl_table sve_default_vl_table[] = {
 +static const struct ctl_table sve_default_vl_table[] = {
        {
                .procname       = "sve_default_vector_length",
                .mode           = 0644,
@@@ -585,7 -585,7 +585,7 @@@ static int __init sve_sysctl_init(void
  #endif /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */
  
  #if defined(CONFIG_ARM64_SME) && defined(CONFIG_SYSCTL)
 -static struct ctl_table sme_default_vl_table[] = {
 +static const struct ctl_table sme_default_vl_table[] = {
        {
                .procname       = "sme_default_vector_length",
                .mode           = 0644,
@@@ -1694,31 -1694,6 +1694,6 @@@ void fpsimd_signal_preserve_current_sta
                sve_to_fpsimd(current);
  }
  
- /*
-  * Called by KVM when entering the guest.
-  */
- void fpsimd_kvm_prepare(void)
- {
-       if (!system_supports_sve())
-               return;
-       /*
-        * KVM does not save host SVE state since we can only enter
-        * the guest from a syscall so the ABI means that only the
-        * non-saved SVE state needs to be saved.  If we have left
-        * SVE enabled for performance reasons then update the task
-        * state to be FPSIMD only.
-        */
-       get_cpu_fpsimd_context();
-       if (test_and_clear_thread_flag(TIF_SVE)) {
-               sve_to_fpsimd(current);
-               current->thread.fp_type = FP_STATE_FPSIMD;
-       }
-       put_cpu_fpsimd_context();
- }
  /*
   * Associate current's FPSIMD context with this cpu
   * The caller must have ownership of the cpu FPSIMD context before calling
diff --combined arch/arm64/kvm/arm.c
index 071a7d75be6891ad591dd58136f60a1d9bc8d4cd,4b7389ad94f55a30cbe6208e8d09ff827d07287a..b8e55a441282f57cb2d4bc55a43b41d5b774dfdd
@@@ -1980,7 -1980,8 +1980,7 @@@ static int kvm_init_vector_slots(void
  static void __init cpu_prepare_hyp_mode(int cpu, u32 hyp_va_bits)
  {
        struct kvm_nvhe_init_params *params = per_cpu_ptr_nvhe_sym(kvm_init_params, cpu);
 -      u64 mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1);
 -      unsigned long tcr;
 +      unsigned long tcr, ips;
  
        /*
         * Calculate the raw per-cpu offset without a translation from the
        params->mair_el2 = read_sysreg(mair_el1);
  
        tcr = read_sysreg(tcr_el1);
 +      ips = FIELD_GET(TCR_IPS_MASK, tcr);
        if (cpus_have_final_cap(ARM64_KVM_HVHE)) {
                tcr |= TCR_EPD1_MASK;
        } else {
        tcr &= ~TCR_T0SZ_MASK;
        tcr |= TCR_T0SZ(hyp_va_bits);
        tcr &= ~TCR_EL2_PS_MASK;
 -      tcr |= FIELD_PREP(TCR_EL2_PS_MASK, kvm_get_parange(mmfr0));
 -      if (kvm_lpa2_is_enabled())
 +      tcr |= FIELD_PREP(TCR_EL2_PS_MASK, ips);
 +      if (lpa2_is_enabled())
                tcr |= TCR_EL2_DS;
        params->tcr_el2 = tcr;
  
@@@ -2481,14 -2481,6 +2481,6 @@@ static void finalize_init_hyp_mode(void
                        per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state =
                                kern_hyp_va(sve_state);
                }
-       } else {
-               for_each_possible_cpu(cpu) {
-                       struct user_fpsimd_state *fpsimd_state;
-                       fpsimd_state = &per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->host_ctxt.fp_regs;
-                       per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->fpsimd_state =
-                               kern_hyp_va(fpsimd_state);
-               }
        }
  }
  
This page took 0.081726 seconds and 4 git commands to generate.