Re: [PATCH] x86: detect running on a HyperV system

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: H. Peter Anvin
Date: Thursday, May 6, 2010 - 6:49 pm

On 05/06/2010 12:18 PM, Greg KH wrote:

Okay... we write something called x86_hyper_features, but it isn't
actually used for anything.  I'm assuming based on what I can see in
<asm/hyperv.h> that it is almost certainly not anything CPU-based.  I
really don't like a random field that can be stuffed with information
from random locations, and it doesn't look like it's even a flag field
in any meaningful way.  Worse, the field is just used to mix bits from
two different CPUID levels at what appears to be a completely arbitrary
boundary:

        /*
         * Extract the features, recommendations etc.
         * The first 9 bits will be used to track hypervisor features.
         * The next 6 bits will be used to track the hypervisor
         * recommendations.
         */
        cpuid(HYPERV_CPUID_FEATURES, &eax, &ebx, &ecx, &edx);
        c->x86_hyper_features |= (eax & 0x1ff);

        cpuid(HYPERV_CPUID_ENLIGHTMENT_INFO, &eax, &ebx, &ecx, &edx);
        c->x86_hyper_features |= ((eax & 0x3f) << 9);

Why 9?  Why 6?  The only thing that I can think of that justifies those
particular numbers is what the *current* version of Hyper-V does.

It would be better to just have a global variable where these two levels
are separately stuffed away instead of arbitrarily commingled (again,
I'm assuming none of the bits are actually per CPU.)

What does this driver of yours do with them?

	-hpa
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] x86: detect running on a HyperV system, Greg KH, (Thu May 6, 12:08 pm)
Re: [PATCH] x86: detect running on a HyperV system, H. Peter Anvin, (Thu May 6, 12:13 pm)
Re: [PATCH] x86: detect running on a HyperV system, H. Peter Anvin, (Thu May 6, 2:23 pm)
Re: [PATCH] x86: detect running on a HyperV system, H. Peter Anvin, (Thu May 6, 6:49 pm)
RE: [PATCH] x86: detect running on a HyperV system, Hank Janssen, (Fri May 7, 9:20 am)
[tip:x86/cpu] x86: Detect running on a Microsoft HyperV system, tip-bot for Ky Srini ..., (Fri May 7, 6:57 pm)