Commit a1450a81 authored by Sean Christopherson's avatar Sean Christopherson
Browse files

KVM: x86: Move "kvm_rebooting" to kernel as "virt_rebooting"



Move "kvm_rebooting" to the kernel, exported for KVM, as one of many steps
towards extracting the innermost VMXON and EFER.SVME management logic out
of KVM and into to core x86.

For lack of a better name, call the new file "hw.c", to yield "virt
hardware" when combined with its parent directory.

No functional change intended.

Tested-by: default avatarChao Gao <chao.gao@intel.com>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Tested-by: default avatarSagi Shahar <sagis@google.com>
Link: https://patch.msgid.link/20260214012702.2368778-4-seanjc@google.com


Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent 3c75e6a5
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _ASM_X86_VIRT_H
#define _ASM_X86_VIRT_H

#include <linux/types.h>

#if IS_ENABLED(CONFIG_KVM_X86)
extern bool virt_rebooting;
#endif

#endif /* _ASM_X86_VIRT_H */
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include <asm/traps.h>
#include <asm/reboot.h>
#include <asm/fpu/api.h>
#include <asm/virt.h>

#include <trace/events/ipi.h>

@@ -495,7 +496,7 @@ static inline void kvm_cpu_svm_disable(void)

static void svm_emergency_disable_virtualization_cpu(void)
{
	kvm_rebooting = true;
	virt_rebooting = true;

	kvm_cpu_svm_disable();
}
+5 −5
Original line number Diff line number Diff line
@@ -298,16 +298,16 @@ SYM_FUNC_START(__svm_vcpu_run)
	RESTORE_GUEST_SPEC_CTRL_BODY
	RESTORE_HOST_SPEC_CTRL_BODY (%_ASM_SP)

10:	cmpb $0, _ASM_RIP(kvm_rebooting)
10:	cmpb $0, _ASM_RIP(virt_rebooting)
	jne 2b
	ud2
30:	cmpb $0, _ASM_RIP(kvm_rebooting)
30:	cmpb $0, _ASM_RIP(virt_rebooting)
	jne 4b
	ud2
50:	cmpb $0, _ASM_RIP(kvm_rebooting)
50:	cmpb $0, _ASM_RIP(virt_rebooting)
	jne 6b
	ud2
70:	cmpb $0, _ASM_RIP(kvm_rebooting)
70:	cmpb $0, _ASM_RIP(virt_rebooting)
	jne 8b
	ud2

@@ -394,7 +394,7 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run)
	RESTORE_GUEST_SPEC_CTRL_BODY
	RESTORE_HOST_SPEC_CTRL_BODY %sil

3:	cmpb $0, kvm_rebooting(%rip)
3:	cmpb $0, virt_rebooting(%rip)
	jne 2b
	ud2

+2 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#include <linux/misc_cgroup.h>
#include <linux/mmu_context.h>
#include <asm/tdx.h>
#include <asm/virt.h>
#include "capabilities.h"
#include "mmu.h"
#include "x86_ops.h"
@@ -1994,7 +1995,7 @@ int tdx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t fastpath)
	 * TDX_SEAMCALL_VMFAILINVALID.
	 */
	if (unlikely((vp_enter_ret & TDX_SW_ERROR) == TDX_SW_ERROR)) {
		KVM_BUG_ON(!kvm_rebooting, vcpu->kvm);
		KVM_BUG_ON(!virt_rebooting, vcpu->kvm);
		goto unhandled_exit;
	}

+1 −1
Original line number Diff line number Diff line
@@ -310,7 +310,7 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
	RET

.Lfixup:
	cmpb $0, _ASM_RIP(kvm_rebooting)
	cmpb $0, _ASM_RIP(virt_rebooting)
	jne .Lvmfail
	ud2
.Lvmfail:
Loading