From nobody Thu Nov 28 05:33:05 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7AB11CF7AB for ; Thu, 3 Oct 2024 23:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727996896; cv=none; b=JmzP+hcS7fKQtPtt6c9Jrsrk4P3L8o7iwm28yF6OF9g94xnsoxhSUcOsMVQ8caqoODKXG4fxfisdlI94XYup00ImKwnNKrT4X/YcR4rOr/NkyukZd1UWexD9F2c2ZmWRHoe0Tio40iSSUWPkdqJ6+1Dgzxy7nQhv01oaYcmtsdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727996896; c=relaxed/simple; bh=u8T99IzGWykMNel3U/9wzmTaqZv74nJArrn871UJQgA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tL5VZp57rNLwulA0Y76t9t7GjI7Mi8Mme0rsOiy8AqVbMpLDOd2f6TqOAVHOzHgr0JJWsPhHbxy9xXg9xqaVwrXEJQukglcDVcw9TC7EBstUHoqwHAiaISy09qGPCSOTHkEb0MBQcosd8zNIEFcr7M0ZrFV0jkVUO01YaZbql8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=F8S9OuLp; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="F8S9OuLp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727996893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m8knLYr09K7Vnktb8HVIIx+q1DRSVC9E3W+BXuiuKNc=; b=F8S9OuLpiE13OsRh6VvJZiuHN51EU1xdhRjpxUwIB5+ftfcHgehPZDzDxBmx6yEV4gMxL0 zaZK+XrqZRJm01NetpYsvG+RppzSRdm2/HN52+GqVCiX8gpypV6yrFYsfbwHufcNp//m73 HVUI+V+bVGiIOIo2rSKZSMNyBxnoMso= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-BlCEm-jlNSKdwH-kUEbL2A-1; Thu, 03 Oct 2024 19:08:10 -0400 X-MC-Unique: BlCEm-jlNSKdwH-kUEbL2A-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5EEFE1955F44; Thu, 3 Oct 2024 23:08:09 +0000 (UTC) Received: from virtlab1023.lab.eng.rdu2.redhat.com (virtlab1023.lab.eng.rdu2.redhat.com [10.8.1.187]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4DAC819560A3; Thu, 3 Oct 2024 23:08:08 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, torvalds@linux-foundation.org Subject: [PATCH 1/2] KVM: x86: leave kvm.ko out of the build if no vendor module is requested Date: Thu, 3 Oct 2024 19:08:05 -0400 Message-ID: <20241003230806.229001-2-pbonzini@redhat.com> In-Reply-To: <20241003230806.229001-1-pbonzini@redhat.com> References: <20241003230806.229001-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" kvm.ko is nothing but library code shared by kvm-intel.ko and kvm-amd.ko. It provides no functionality on its own and it is unnecessary unless one of the vendor-specific module is compiled. In particular, /dev/kvm is not created until one of kvm-intel.ko or kvm-amd.ko is loaded. Use CONFIG_KVM to decide if it is built-in or a module, but use the vendor-specific modules for the actual decision on whether to build it. This also fixes a build failure when CONFIG_KVM_INTEL and CONFIG_KVM_AMD are both disabled. The cpu_emergency_register_virt_callback() function is called from kvm.ko, but it is only defined if at least one of CONFIG_KVM_INTEL and CONFIG_KVM_AMD is provided. Fixes: 590b09b1d88e ("KVM: x86: Register "emergency disable" callbacks when= virt is enabled") Signed-off-by: Paolo Bonzini --- arch/x86/kvm/Kconfig | 7 +++++-- arch/x86/kvm/Makefile | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 730c2f34d347..81bce9dd9331 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -17,8 +17,8 @@ menuconfig VIRTUALIZATION =20 if VIRTUALIZATION =20 -config KVM - tristate "Kernel-based Virtual Machine (KVM) support" +config KVM_X86_COMMON + def_tristate KVM if KVM_INTEL || KVM_AMD depends on X86_LOCAL_APIC select KVM_COMMON select KVM_GENERIC_MMU_NOTIFIER @@ -45,6 +45,9 @@ config KVM select KVM_GENERIC_HARDWARE_ENABLING select KVM_GENERIC_PRE_FAULT_MEMORY select KVM_WERROR if WERROR + +config KVM + tristate "Kernel-based Virtual Machine (KVM) support" help Support hosting fully virtualized guest machines using hardware virtualization extensions. You will need a fairly recent diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 5494669a055a..0d050cfaffb2 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -32,7 +32,7 @@ kvm-intel-y +=3D vmx/vmx_onhyperv.o vmx/hyperv_evmcs.o kvm-amd-y +=3D svm/svm_onhyperv.o endif =20 -obj-$(CONFIG_KVM) +=3D kvm.o +obj-$(CONFIG_KVM_X86_COMMON) +=3D kvm.o obj-$(CONFIG_KVM_INTEL) +=3D kvm-intel.o obj-$(CONFIG_KVM_AMD) +=3D kvm-amd.o =20 --=20 2.43.5 From nobody Thu Nov 28 05:33:05 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AFF01CF5D1 for ; Thu, 3 Oct 2024 23:08:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727996895; cv=none; b=sgkH+Izi7JacSFzaDgtdJ4gIB7ac2/oIdH/BymU3/dq92pzi9ZVMCetsSwX/i+fL1eubOqqFXELRMDRA+gQeQzDob6gXppmpoBpe1GcST7dK2+xP/EuAuyK5ejEIf3c2/2QcuXD6ElTHRiPS3gHCI+CEG4ztSwyS9opYDuLIj6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727996895; c=relaxed/simple; bh=2IX5e4v312UcCof0zH5Eau+p44cjWF1hGdp1QlTb3g0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QII1BH0ahNrXRuUg4nTB9ld05a9V1n7f1HfNItPHc7Ve3P4RW6AR3v+K03x4SPndiNg84ZgD7KW6fh5WwG2M6wwCso+NNX4h67IM0RNxunaUACo17pcnal0NMyoCwVVJOhEcYtJ3fzA1anFYtBl3xndpNL3IZpt8JmMIZKIM0sE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SGRpKJV4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SGRpKJV4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727996893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OP/fmcCu3JQQY+vXBVp7Ap3zOT1BUDlHez9ToS07+nk=; b=SGRpKJV4XiiOaOQ5yM7PeUyqsD3HYvunnJ3tORCsxri6zDc9UL/W7D4W5tKtMeSMCflEmQ T1Xx4C71BOX3tHG7Lwrd+OsTyseE8HtKpGYkSvV9usgDBz6OWBXaMDknEGMJyiOhsfhyjb a4z8gstwzUH6lwnA6gQOel+VsGo1hE0= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-495-bASMRJJZP2yF9GmNd1aHwA-1; Thu, 03 Oct 2024 19:08:11 -0400 X-MC-Unique: bASMRJJZP2yF9GmNd1aHwA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5E1401955EEA; Thu, 3 Oct 2024 23:08:10 +0000 (UTC) Received: from virtlab1023.lab.eng.rdu2.redhat.com (virtlab1023.lab.eng.rdu2.redhat.com [10.8.1.187]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 468B51955E8C; Thu, 3 Oct 2024 23:08:09 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, torvalds@linux-foundation.org Subject: [PATCH 2/2] x86/reboot: emergency callbacks are now registered by common KVM code Date: Thu, 3 Oct 2024 19:08:06 -0400 Message-ID: <20241003230806.229001-3-pbonzini@redhat.com> In-Reply-To: <20241003230806.229001-1-pbonzini@redhat.com> References: <20241003230806.229001-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" 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 Fixes: 590b09b1d88e ("KVM: x86: Register "emergency disable" callbacks when= virt is enabled") Fixes: 6d55a94222db ("x86/reboot: Unconditionally define cpu_emergency_virt= _cb typedef") Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/reboot.h | 4 ++-- arch/x86/kernel/reboot.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h index d0ef2a678d66..7ec4c4d12277 100644 --- a/arch/x86/include/asm/reboot.h +++ b/arch/x86/include/asm/reboot.h @@ -26,13 +26,13 @@ void __noreturn machine_real_restart(unsigned int type); #define MRR_APM 1 =20 typedef void (cpu_emergency_virt_cb)(void); -#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD) +#if IS_ENABLED(CONFIG_KVM_X86_COMMON) void cpu_emergency_register_virt_callback(cpu_emergency_virt_cb *callback); void cpu_emergency_unregister_virt_callback(cpu_emergency_virt_cb *callbac= k); 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_COMMON */ =20 typedef void (*nmi_shootdown_cb)(int, struct pt_regs*); void nmi_shootdown_cpus(nmi_shootdown_cb callback); diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 0e0a4cf6b5eb..0e3f9479ccc8 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -530,7 +530,7 @@ static inline void kb_wait(void) =20 static inline void nmi_shootdown_cpus_on_restart(void); =20 -#if IS_ENABLED(CONFIG_KVM_INTEL) || IS_ENABLED(CONFIG_KVM_AMD) +#if IS_ENABLED(CONFIG_KVM_X86_COMMON) /* RCU-protected callback to disable virtualization prior to reboot. */ static cpu_emergency_virt_cb __rcu *cpu_emergency_virt_callback; =20 @@ -600,7 +600,7 @@ static void emergency_reboot_disable_virtualization(voi= d) } #else static void emergency_reboot_disable_virtualization(void) { } -#endif /* CONFIG_KVM_INTEL || CONFIG_KVM_AMD */ +#endif /* CONFIG_KVM_X86_COMMON */ =20 void __attribute__((weak)) mach_reboot_fixups(void) { --=20 2.43.5