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. ~Andrew _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel