Merge tag 'hyperv-fixes-signed' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 19 May 2020 18:48:21 +0000 (11:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 19 May 2020 18:48:21 +0000 (11:48 -0700)
Pull hyperv fix from Wei Liu:
 "One patch from Vitaly to fix reenlightenment notifications"

* tag 'hyperv-fixes-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
  x86/hyperv: Properly suspend/resume reenlightenment notifications

arch/x86/hyperv/hv_init.c

index fd51bac..acf76b4 100644 (file)
@@ -226,10 +226,18 @@ static int hv_cpu_die(unsigned int cpu)
 
        rdmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
        if (re_ctrl.target_vp == hv_vp_index[cpu]) {
-               /* Reassign to some other online CPU */
+               /*
+                * Reassign reenlightenment notifications to some other online
+                * CPU or just disable the feature if there are no online CPUs
+                * left (happens on hibernation).
+                */
                new_cpu = cpumask_any_but(cpu_online_mask, cpu);
 
-               re_ctrl.target_vp = hv_vp_index[new_cpu];
+               if (new_cpu < nr_cpu_ids)
+                       re_ctrl.target_vp = hv_vp_index[new_cpu];
+               else
+                       re_ctrl.enabled = 0;
+
                wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl));
        }
 
@@ -293,6 +301,13 @@ static void hv_resume(void)
 
        hv_hypercall_pg = hv_hypercall_pg_saved;
        hv_hypercall_pg_saved = NULL;
+
+       /*
+        * Reenlightenment notifications are disabled by hv_cpu_die(0),
+        * reenable them here if hv_reenlightenment_cb was previously set.
+        */
+       if (hv_reenlightenment_cb)
+               set_hv_tscchange_cb(hv_reenlightenment_cb);
 }
 
 /* Note: when the ops are called, only CPU0 is online and IRQs are disabled. */