[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-next v2 9/9] x86: introduce CONFIG_HYPERV and detection code



On Mon, Oct 21, 2019 at 04:02:33PM +0100, Andrew Cooper wrote:
> On 21/10/2019 11:26, Roger Pau Monné wrote:
> >>> +
> >>> +    cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
> >>> +    if ( (ebx == 0x7263694d) && /* "Micr" */
> >>> +         (ecx == 0x666f736f) && /* "osof" */
> >>> +         (edx == 0x76482074) )  /* "t Hv" */
> >> I guess there are no HyperV headers to import that have those values
> >> defined?
> >>
> >> Alternatively you could do something like the following I think:
> >>
> >> static const char hyperv_sig[] __initconst = "Microsoft Hv";
> >>
> >> bool __init hyperv_probe(void)
> >> {
> >>     uint32_t eax, sig[3];
> >>
> >>     cpuid(0x40000000, &eax, &sig[0], &sig[1], &sig[2]);
> >>     if ( !strncmp(hyperv_sig, sig, strncmp(hyperv_sig) )
> > Urg, I've made a mistake here, the line should be:
> >
> > !strncmp(hyperv_sig, sig, strlen(hyperv_sig))
> 
> Just because the leaves form an ascii string, doesn't mean that using
> string comparisons are the sane way to check.  3x 32bit compares are
> substantially more efficient, and far harder to get wrong.
> 
> Wei: On your detection algorithm, you also need to find HV#1 in
> 0x40000001.eax to detect conformance to the viridian spec.

Sure I can do that.

I'm not sure it matters that much in practice though.

Wei.

> 
> ~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.