Skip to content

Commit

Permalink
x86/reboot: Assert that IRQs are disabled when turning off virtualiza…
Browse files Browse the repository at this point in the history
…tion

Assert that IRQs are disabled when turning off virtualization in an
emergency.  KVM enables hardware via on_each_cpu(), i.e. could re-enable
hardware if a pending IPI were delivered after disabling virtualization.

Remove a misleading comment from emergency_reboot_disable_virtualization()
about "just" needing to guarantee the CPU is stable (see above).

Reviewed-by: Kai Huang <kai.huang@intel.com>
Link: https://lore.kernel.org/r/20230721201859.2307736-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
  • Loading branch information
sean-jc committed Aug 3, 2023
1 parent baeb4de commit ad93c1a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion arch/x86/kernel/reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ static inline void nmi_shootdown_cpus_on_restart(void);

static void emergency_reboot_disable_virtualization(void)
{
/* Just make sure we won't change CPUs while doing this */
local_irq_disable();

/*
Expand Down Expand Up @@ -821,6 +820,13 @@ void cpu_emergency_disable_virtualization(void)
{
cpu_emergency_virt_cb *callback;

/*
* IRQs must be disabled as KVM enables virtualization in hardware via
* function call IPIs, i.e. IRQs need to be disabled to guarantee
* virtualization stays disabled.
*/
lockdep_assert_irqs_disabled();

rcu_read_lock();
callback = rcu_dereference(cpu_emergency_virt_callback);
if (callback)
Expand Down

0 comments on commit ad93c1a

Please sign in to comment.