Skip to content

Commit

Permalink
x86/reboot: emergency callbacks are now registered by common KVM code
Browse files Browse the repository at this point in the history
Guard them with CONFIG_KVM_X86_COMMON rather than the two vendor modules.
In practice this has no functional change, because CONFIG_KVM_X86_COMMON
is set if and only if at least one vendor-specific module is being built.
However, it is cleaner to specify CONFIG_KVM_X86_COMMON for functions that
are used in kvm.ko.

Reported-by: Linus Torvalds <[email protected]>
Fixes: 590b09b ("KVM: x86: Register "emergency disable" callbacks when virt is enabled")
Fixes: 6d55a94 ("x86/reboot: Unconditionally define cpu_emergency_virt_cb typedef")
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Oct 6, 2024
1 parent ea4290d commit 2a5fe5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arch/x86/include/asm/reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ void __noreturn machine_real_restart(unsigned int type);
#define MRR_APM 1

typedef void (cpu_emergency_virt_cb)(void);
#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD)
#if IS_ENABLED(CONFIG_KVM_X86)
void cpu_emergency_register_virt_callback(cpu_emergency_virt_cb *callback);
void cpu_emergency_unregister_virt_callback(cpu_emergency_virt_cb *callback);
void cpu_emergency_disable_virtualization(void);
#else
static inline void cpu_emergency_disable_virtualization(void) {}
#endif /* CONFIG_KVM_INTEL || CONFIG_KVM_AMD */
#endif /* CONFIG_KVM_X86 */

typedef void (*nmi_shootdown_cb)(int, struct pt_regs*);
void nmi_shootdown_cpus(nmi_shootdown_cb callback);
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/kernel/reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ static inline void kb_wait(void)

static inline void nmi_shootdown_cpus_on_restart(void);

#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD)
#if IS_ENABLED(CONFIG_KVM_X86)
/* RCU-protected callback to disable virtualization prior to reboot. */
static cpu_emergency_virt_cb __rcu *cpu_emergency_virt_callback;

Expand Down Expand Up @@ -600,7 +600,7 @@ static void emergency_reboot_disable_virtualization(void)
}
#else
static void emergency_reboot_disable_virtualization(void) { }
#endif /* CONFIG_KVM_INTEL || CONFIG_KVM_AMD */
#endif /* CONFIG_KVM_X86 */

void __attribute__((weak)) mach_reboot_fixups(void)
{
Expand Down

0 comments on commit 2a5fe5a

Please sign in to comment.