Skip to content

Commit 261cd5e

Browse files
committed
x86/reboot: Expose VMCS crash hooks if and only if KVM_{INTEL,AMD} is enabled
Expose the crash/reboot hooks used by KVM to disable virtualization in hardware and unblock INIT only if there's a potential in-tree user, i.e. either KVM_INTEL or KVM_AMD is enabled. Reviewed-by: Kai Huang <kai.huang@intel.com> Link: https://lore.kernel.org/r/20230721201859.2307736-9-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 59765db commit 261cd5e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

arch/x86/include/asm/reboot.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ void __noreturn machine_real_restart(unsigned int type);
2525
#define MRR_BIOS 0
2626
#define MRR_APM 1
2727

28+
#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD)
2829
typedef void (cpu_emergency_virt_cb)(void);
2930
void cpu_emergency_register_virt_callback(cpu_emergency_virt_cb *callback);
3031
void cpu_emergency_unregister_virt_callback(cpu_emergency_virt_cb *callback);
3132
void cpu_emergency_disable_virtualization(void);
33+
#else
34+
static inline void cpu_emergency_disable_virtualization(void) {}
35+
#endif /* CONFIG_KVM_INTEL || CONFIG_KVM_AMD */
3236

3337
typedef void (*nmi_shootdown_cb)(int, struct pt_regs*);
3438
void nmi_shootdown_cpus(nmi_shootdown_cb callback);

arch/x86/kernel/reboot.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ static inline void kb_wait(void)
529529

530530
static inline void nmi_shootdown_cpus_on_restart(void);
531531

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

@@ -596,7 +597,9 @@ static void emergency_reboot_disable_virtualization(void)
596597
nmi_shootdown_cpus_on_restart();
597598
}
598599
}
599-
600+
#else
601+
static void emergency_reboot_disable_virtualization(void) { }
602+
#endif /* CONFIG_KVM_INTEL || CONFIG_KVM_AMD */
600603

601604
void __attribute__((weak)) mach_reboot_fixups(void)
602605
{

0 commit comments

Comments
 (0)