@@ -530,6 +530,51 @@ static inline void kb_wait(void)
530
530
531
531
static inline void nmi_shootdown_cpus_on_restart (void );
532
532
533
+ /* RCU-protected callback to disable virtualization prior to reboot. */
534
+ static cpu_emergency_virt_cb __rcu * cpu_emergency_virt_callback ;
535
+
536
+ void cpu_emergency_register_virt_callback (cpu_emergency_virt_cb * callback )
537
+ {
538
+ if (WARN_ON_ONCE (rcu_access_pointer (cpu_emergency_virt_callback )))
539
+ return ;
540
+
541
+ rcu_assign_pointer (cpu_emergency_virt_callback , callback );
542
+ }
543
+ EXPORT_SYMBOL_GPL (cpu_emergency_register_virt_callback );
544
+
545
+ void cpu_emergency_unregister_virt_callback (cpu_emergency_virt_cb * callback )
546
+ {
547
+ if (WARN_ON_ONCE (rcu_access_pointer (cpu_emergency_virt_callback ) != callback ))
548
+ return ;
549
+
550
+ rcu_assign_pointer (cpu_emergency_virt_callback , NULL );
551
+ synchronize_rcu ();
552
+ }
553
+ EXPORT_SYMBOL_GPL (cpu_emergency_unregister_virt_callback );
554
+
555
+ /*
556
+ * Disable virtualization, i.e. VMX or SVM, to ensure INIT is recognized during
557
+ * reboot. VMX blocks INIT if the CPU is post-VMXON, and SVM blocks INIT if
558
+ * GIF=0, i.e. if the crash occurred between CLGI and STGI.
559
+ */
560
+ void cpu_emergency_disable_virtualization (void )
561
+ {
562
+ cpu_emergency_virt_cb * callback ;
563
+
564
+ /*
565
+ * IRQs must be disabled as KVM enables virtualization in hardware via
566
+ * function call IPIs, i.e. IRQs need to be disabled to guarantee
567
+ * virtualization stays disabled.
568
+ */
569
+ lockdep_assert_irqs_disabled ();
570
+
571
+ rcu_read_lock ();
572
+ callback = rcu_dereference (cpu_emergency_virt_callback );
573
+ if (callback )
574
+ callback ();
575
+ rcu_read_unlock ();
576
+ }
577
+
533
578
static void emergency_reboot_disable_virtualization (void )
534
579
{
535
580
local_irq_disable ();
@@ -786,54 +831,9 @@ void machine_crash_shutdown(struct pt_regs *regs)
786
831
}
787
832
#endif
788
833
789
- /* RCU-protected callback to disable virtualization prior to reboot. */
790
- static cpu_emergency_virt_cb __rcu * cpu_emergency_virt_callback ;
791
-
792
- void cpu_emergency_register_virt_callback (cpu_emergency_virt_cb * callback )
793
- {
794
- if (WARN_ON_ONCE (rcu_access_pointer (cpu_emergency_virt_callback )))
795
- return ;
796
-
797
- rcu_assign_pointer (cpu_emergency_virt_callback , callback );
798
- }
799
- EXPORT_SYMBOL_GPL (cpu_emergency_register_virt_callback );
800
-
801
- void cpu_emergency_unregister_virt_callback (cpu_emergency_virt_cb * callback )
802
- {
803
- if (WARN_ON_ONCE (rcu_access_pointer (cpu_emergency_virt_callback ) != callback ))
804
- return ;
805
-
806
- rcu_assign_pointer (cpu_emergency_virt_callback , NULL );
807
- synchronize_rcu ();
808
- }
809
- EXPORT_SYMBOL_GPL (cpu_emergency_unregister_virt_callback );
810
-
811
834
/* This is the CPU performing the emergency shutdown work. */
812
835
int crashing_cpu = -1 ;
813
836
814
- /*
815
- * Disable virtualization, i.e. VMX or SVM, to ensure INIT is recognized during
816
- * reboot. VMX blocks INIT if the CPU is post-VMXON, and SVM blocks INIT if
817
- * GIF=0, i.e. if the crash occurred between CLGI and STGI.
818
- */
819
- void cpu_emergency_disable_virtualization (void )
820
- {
821
- cpu_emergency_virt_cb * callback ;
822
-
823
- /*
824
- * IRQs must be disabled as KVM enables virtualization in hardware via
825
- * function call IPIs, i.e. IRQs need to be disabled to guarantee
826
- * virtualization stays disabled.
827
- */
828
- lockdep_assert_irqs_disabled ();
829
-
830
- rcu_read_lock ();
831
- callback = rcu_dereference (cpu_emergency_virt_callback );
832
- if (callback )
833
- callback ();
834
- rcu_read_unlock ();
835
- }
836
-
837
837
#if defined(CONFIG_SMP )
838
838
839
839
static nmi_shootdown_cb shootdown_callback ;
0 commit comments