From mboxrd@z Thu Jan 1 00:00:00 1970 From: Prarit Bhargava Subject: Re: [PATCH 1/2] kvm, Add x86_hyper_kvm to complete detect_hypervisor_platform check [v2] Date: Fri, 06 Jul 2012 13:47:39 -0400 Message-ID: <4FF724BB.5040008@redhat.com> References: <1341493877-16622-1-git-send-email-prarit@redhat.com> <1341493877-16622-2-git-send-email-prarit@redhat.com> <4FF59606.4060504@redhat.com> <4FF5987C.6080905@redhat.com> <20120706112719.GA18059@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , linux-kernel@vger.kernel.org, Gleb Natapov , Alex Williamson , Konrad Rzeszutek Wilk , kvm@vger.kernel.org To: Marcelo Tosatti Return-path: In-Reply-To: <20120706112719.GA18059@amt.cnet> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 07/06/2012 07:27 AM, Marcelo Tosatti wrote: > On Thu, Jul 05, 2012 at 09:37:00AM -0400, Prarit Bhargava wrote: >> >> >> On 07/05/2012 09:26 AM, Avi Kivity wrote: >>> Please copy at least kvm@vger.kernel.org, and preferably Marcelo as well >>> (the other kvm co-maintainer). >>> >>> >> >> While debugging I noticed that unlike all the other hypervisor code in the >> kernel, kvm does not have an entry for x86_hyper which is used in >> detect_hypervisor_platform() which results in a nice printk in the >> syslog. This is only really a stub function but it >> does make kvm more consistent with the other hypervisors. >> >> [v2]: add detect and _GPL export >> >> Signed-off-by: Prarit Bhargava >> Cc: Avi Kivity >> Cc: Gleb Natapov >> Cc: Alex Williamson >> Cc: Konrad Rzeszutek Wilk > > Looks good, please regenerate: > > Hunk #1 FAILED at 39. > Hunk #2 succeeded at 484 (offset 51 lines). > 1 out of 2 hunks FAILED -- saving rejects to file > arch/x86/kernel/kvm.c.rej Oops. Sorry about that Marcelo. I didn't know about kvm next :( My bad. ----8<----- [PATCH 1/2] kvm, Add x86_hyper_kvm to complete detect_hypervisor_platform check [v3] While debugging I noticed that unlike all the other hypervisor code in the kernel, kvm does not have an entry for x86_hyper which is used in detect_hypervisor_platform() which results in a nice printk in the syslog. This is only really a stub function but it does make kvm more consistent with the other hypervisors. [v2]: add detect and _GPL export [v3]: patch against kvm next Signed-off-by: Prarit Bhargava Cc: Avi Kivity Cc: Gleb Natapov Cc: Alex Williamson Cc: Konrad Rzeszutek Wilk Cc: Marcelo Tostatti Cc: kvm@vger.kernel.org --- arch/x86/include/asm/hypervisor.h | 1 + arch/x86/kernel/cpu/hypervisor.c | 1 + arch/x86/kernel/kvm.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h index 7a15153..b518c75 100644 --- a/arch/x86/include/asm/hypervisor.h +++ b/arch/x86/include/asm/hypervisor.h @@ -49,6 +49,7 @@ extern const struct hypervisor_x86 *x86_hyper; extern const struct hypervisor_x86 x86_hyper_vmware; extern const struct hypervisor_x86 x86_hyper_ms_hyperv; extern const struct hypervisor_x86 x86_hyper_xen_hvm; +extern const struct hypervisor_x86 x86_hyper_kvm; static inline bool hypervisor_x2apic_available(void) { diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c index 755f64f..6d6dd7a 100644 --- a/arch/x86/kernel/cpu/hypervisor.c +++ b/arch/x86/kernel/cpu/hypervisor.c @@ -37,6 +37,7 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] = #endif &x86_hyper_vmware, &x86_hyper_ms_hyperv, + &x86_hyper_kvm, }; const struct hypervisor_x86 *x86_hyper; diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 75ab94c..299cf14 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -41,6 +41,7 @@ #include #include #include +#include static int kvmapf = 1; @@ -483,6 +484,19 @@ void __init kvm_guest_init(void) #endif } +static bool __init kvm_detect(void) +{ + if (!kvm_para_available()) + return false; + return true; +} + +const struct hypervisor_x86 x86_hyper_kvm __refconst = { + .name = "KVM", + .detect = kvm_detect, +}; +EXPORT_SYMBOL_GPL(x86_hyper_kvm); + static __init int activate_jump_labels(void) { if (has_steal_clock) { -- 1.7.10.2