Messages in this thread | ![/](/images/icornerl.gif) | | Date | Thu, 9 Dec 2021 23:21:03 +0100 | Subject | Re: [PATCH v2] selftests: KVM: avoid failures due to reserved HyperTransport region | From | Paolo Bonzini <> |
| |
On 12/9/21 22:47, Sean Christopherson wrote: >> + /* >> + * Otherwise it's at the top of the physical address >> + * space, possibly reduced due to SME by bits 11:6 of >> + * CPUID[0x8000001f].EBX. >> + */ >> + eax = 0x80000008; >> + cpuid(&eax, &ebx, &ecx, &edx); > > Should't this check 0x80000000.eax >= 0x80000008 first? Or do we just accept > failure if family==0x17 and there's no 0x80000008? One paranoid option would be > to use the pre-fam17 value, e.g. > > /* Before family 17h, the HyperTransport area is just below 1T. */ > ht_gfn = (1 << 28) - num_ht_pages; > if (x86_family(eax) < 0x17) > goto out; > > eax = 0x80000000; > cpuid(&eax, &ebx, &ecx, &edx); > max_ext_leaf = eax; > > /* Use the old, conservative value if MAXPHYADDR isn't enumerated. */ > if (max_ext_leaf < 0x80000008) > goto out;
Yes, this works for me too. Though in practice I don't think any 64-bit machine ever existed without 0x80000008 (you need it to decide what's a canonical address and what isn't), so that would have to be a 32-bit fam17h machine.
Paolo
> /* comment */ > eax = 0x80000008; > cpuid(&eax, &ebx, &ecx, &edx); > max_pfn = (1ULL << ((eax & 255) - vm->page_shift)) - 1; > if (max_ext_leaf >= 0x8000001f) { > <adjust> > } > ht_gfn = max_pfn - num_ht_pages; > out: > return min(max_gfn, ht_gfn - 1); > >> + max_pfn = (1ULL << ((eax & 255) - vm->page_shift)) - 1; > LOL, "& 255", you just couldn't resist, huh? My version of Rami Code only goes > up to 15.:-) >
| ![\](/images/icornerr.gif) |