All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	vkuznets@redhat.com, mlevitsk@redhat.com,
	joao.m.martins@oracle.com, stable@vger.kernel.org,
	David Matlack <dmatlack@google.com>
Subject: Re: [PATCH v2] selftests: KVM: avoid failures due to reserved HyperTransport region
Date: Thu, 9 Dec 2021 23:21:03 +0100	[thread overview]
Message-ID: <a9be23ee-d485-c334-4524-2daa1758cafd@redhat.com> (raw)
In-Reply-To: <YbJ5jyCyqZwZU3uH@google.com>

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.:-)
> 


      reply	other threads:[~2021-12-09 22:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 20:52 [PATCH v2] selftests: KVM: avoid failures due to reserved HyperTransport region Paolo Bonzini
2021-12-09 21:47 ` Sean Christopherson
2021-12-09 22:21   ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9be23ee-d485-c334-4524-2daa1758cafd@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dmatlack@google.com \
    --cc=joao.m.martins@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=seanjc@google.com \
    --cc=stable@vger.kernel.org \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.