[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190603191818.GF13384@linux.intel.com>
Date: Mon, 3 Jun 2019 12:18:18 -0700
From: Sean Christopherson <sean.j.christopherson@...el.com>
To: Radim Krčmář <rkrcmar@...hat.com>
Cc: Like Xu <like.xu@...ux.intel.com>,
Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org,
Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH v3] KVM: x86: Add Intel CPUID.1F cpuid emulation
support
On Mon, Jun 03, 2019 at 06:56:17PM +0200, Radim Krčmář wrote:
> > + break;
> > + }
> > entry->eax = min(entry->eax, (u32)(f_intel_pt ? 0x14 : 0xd));
>
> Similarly in the existing code. If we don't have f_intel_pt, then we
> should make sure that leaf 0x14 is not being filled, but we don't really
> have to limit the maximal index.
>
> Adding a single clamping like
>
> /* Limited to the highest leaf implemented in KVM. */
> entry->eax = min(entry->eax, 0x1f);
>
> seems sufficient.
>
> (Passing the hardware value is ok in theory, but it is a cheap way to
> avoid future leaves that cannot be simply zeroed for some weird reason.)
I don't have a strong opinion regarding the code itself, but whatever ends
up getting committed should have a big beefy changelog explaining why the
clamping exists, or at least extolling its virtues. I had a hell of a
time understanding the intent of this one line of code because as your
response shows, there is no one right answer.
Powered by blists - more mailing lists