[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a9be23ee-d485-c334-4524-2daa1758cafd@redhat.com>
Date: Thu, 9 Dec 2021 23:21:03 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
vkuznets@...hat.com, mlevitsk@...hat.com,
joao.m.martins@...cle.com, stable@...r.kernel.org,
David Matlack <dmatlack@...gle.com>
Subject: Re: [PATCH v2] selftests: KVM: avoid failures due to reserved
HyperTransport region
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.:-)
>
Powered by blists - more mailing lists