Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1238064 > unrolled thread

[PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V

Started byPaolo Bonzini <pbonzini@redhat.com>
First post2015-10-02 11:30 +0200
Last post2015-10-03 00:00 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V Paolo Bonzini <pbonzini@redhat.com> - 2015-10-02 11:30 +0200
    Re: [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V Vitaly Kuznetsov <vkuznets@redhat.com> - 2015-10-02 13:30 +0200
    RE: [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V KY Srinivasan <kys@microsoft.com> - 2015-10-02 16:40 +0200
      RE: [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V Thomas Gleixner <tglx@linutronix.de> - 2015-10-02 22:10 +0200
        RE: [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V KY Srinivasan <kys@microsoft.com> - 2015-10-03 00:00 +0200

#1238064 — [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V

FromPaolo Bonzini <pbonzini@redhat.com>
Date2015-10-02 11:30 +0200
Subject[PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V
Message-ID<qf4P8-7Gp-25@gated-at.bofh.it>
The specification says that "Microsoft Hv" is actually a vendor ID field
that is only used for reporting and diagnostic purposes.  The actual
field that you need to check is the interface ID that you get in eax
when querying the HYPERV_CPUID_INTERFACE.

Change ms_hyperv_platform to actually do what the specification suggests.
This roughy matches what Windows looks for, though Windows actually
ignores HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS completely.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kernel/cpu/mshyperv.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 381c8b9b3a33..7910e7fd705b 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -116,18 +116,16 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)
 static uint32_t  __init ms_hyperv_platform(void)
 {
 	u32 eax;
-	u32 hyp_signature[3];
 
 	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return 0;
 
-	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
-	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
-
-	if (eax >= HYPERV_CPUID_MIN &&
-	    eax <= HYPERV_CPUID_MAX &&
-	    !memcmp("Microsoft Hv", hyp_signature, 12))
-		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
+	eax = cpuid_eax(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS);
+	if (eax >= HYPERV_CPUID_MIN && eax <= HYPERV_CPUID_MAX) {
+		eax = cpuid_eax(HYPERV_CPUID_INTERFACE);
+		if (!memcmp(&eax, "Hv#1", sizeof(eax)))
+			return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
+	}
 
 	return 0;
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1238129

FromVitaly Kuznetsov <vkuznets@redhat.com>
Date2015-10-02 13:30 +0200
Message-ID<qf6Hg-1V1-13@gated-at.bofh.it>
In reply to#1238064
Paolo Bonzini <pbonzini@redhat.com> writes:

> The specification says that "Microsoft Hv" is actually a vendor ID field
> that is only used for reporting and diagnostic purposes.  The actual
> field that you need to check is the interface ID that you get in eax
> when querying the HYPERV_CPUID_INTERFACE.
>
> Change ms_hyperv_platform to actually do what the specification suggests.
> This roughy matches what Windows looks for, though Windows actually
> ignores HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS completely.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

(and it seems K. Y. is missing on the CC: list, fixed).

> ---
>  arch/x86/kernel/cpu/mshyperv.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 381c8b9b3a33..7910e7fd705b 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -116,18 +116,16 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)
>  static uint32_t  __init ms_hyperv_platform(void)
>  {
>  	u32 eax;
> -	u32 hyp_signature[3];
>
>  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
>  		return 0;
>
> -	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
> -	      &eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);
> -
> -	if (eax >= HYPERV_CPUID_MIN &&
> -	    eax <= HYPERV_CPUID_MAX &&
> -	    !memcmp("Microsoft Hv", hyp_signature, 12))
> -		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +	eax = cpuid_eax(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS);
> +	if (eax >= HYPERV_CPUID_MIN && eax <= HYPERV_CPUID_MAX) {
> +		eax = cpuid_eax(HYPERV_CPUID_INTERFACE);
> +		if (!memcmp(&eax, "Hv#1", sizeof(eax)))
> +			return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +	}
>
>  	return 0;
>  }

-- 
  Vitaly
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1238327

FromKY Srinivasan <kys@microsoft.com>
Date2015-10-02 16:40 +0200
Message-ID<qf9F7-690-11@gated-at.bofh.it>
In reply to#1238064

> -----Original Message-----
> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo
> Bonzini
> Sent: Friday, October 2, 2015 2:27 AM
> To: linux-kernel@vger.kernel.org
> Cc: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; x86@kernel.org; devel@linuxdriverproject.org;
> alex.williamson@redhat.com
> Subject: [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V
> 
> The specification says that "Microsoft Hv" is actually a vendor ID field
> that is only used for reporting and diagnostic purposes.  The actual
> field that you need to check is the interface ID that you get in eax
> when querying the HYPERV_CPUID_INTERFACE.
> 
> Change ms_hyperv_platform to actually do what the specification suggests.
> This roughy matches what Windows looks for, though Windows actually
> ignores HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS completely.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks Paolo.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
>  arch/x86/kernel/cpu/mshyperv.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/mshyperv.c
> b/arch/x86/kernel/cpu/mshyperv.c
> index 381c8b9b3a33..7910e7fd705b 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -116,18 +116,16 @@ static void hv_machine_crash_shutdown(struct
> pt_regs *regs)
>  static uint32_t  __init ms_hyperv_platform(void)
>  {
>  	u32 eax;
> -	u32 hyp_signature[3];
> 
>  	if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
>  		return 0;
> 
> -	cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
> -	      &eax, &hyp_signature[0], &hyp_signature[1],
> &hyp_signature[2]);
> -
> -	if (eax >= HYPERV_CPUID_MIN &&
> -	    eax <= HYPERV_CPUID_MAX &&
> -	    !memcmp("Microsoft Hv", hyp_signature, 12))
> -		return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +	eax =
> cpuid_eax(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS);
> +	if (eax >= HYPERV_CPUID_MIN && eax <= HYPERV_CPUID_MAX) {
> +		eax = cpuid_eax(HYPERV_CPUID_INTERFACE);
> +		if (!memcmp(&eax, "Hv#1", sizeof(eax)))
> +			return
> HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS;
> +	}
> 
>  	return 0;
>  }
> --
> 2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1238567

FromThomas Gleixner <tglx@linutronix.de>
Date2015-10-02 22:10 +0200
Message-ID<qfeOu-5fB-3@gated-at.bofh.it>
In reply to#1238327
On Fri, 2 Oct 2015, KY Srinivasan wrote:
> > Change ms_hyperv_platform to actually do what the specification suggests.
> > This roughy matches what Windows looks for, though Windows actually
> > ignores HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS completely.
> > 
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> 
> Thanks Paolo.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

Does that mean Acked-by or Reviewed-by? SOB certainly does not apply
here.

Thanks,

	tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1238639

FromKY Srinivasan <kys@microsoft.com>
Date2015-10-03 00:00 +0200
Message-ID<qfgwX-7vm-19@gated-at.bofh.it>
In reply to#1238567

> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Friday, October 2, 2015 1:07 PM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>; linux-kernel@vger.kernel.org;
> Haiyang Zhang <haiyangz@microsoft.com>; x86@kernel.org;
> devel@linuxdriverproject.org; alex.williamson@redhat.com
> Subject: RE: [PATCH] x86: guest: rely on leaf 0x40000001 to detect Hyper-V
> 
> On Fri, 2 Oct 2015, KY Srinivasan wrote:
> > > Change ms_hyperv_platform to actually do what the specification
> suggests.
> > > This roughy matches what Windows looks for, though Windows actually
> > > ignores HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS completely.
> > >
> > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >
> > Thanks Paolo.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> 
> Does that mean Acked-by or Reviewed-by? SOB certainly does not apply
> here.
Thomas,

I have reviewed the patch and am acking this change.

Regards,

K. Y
> 
> Thanks,
> 
> 	tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web