kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Joe Perches <joe@perches.com>, Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	Igor Mammedov <imammedo@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 2/2] KVM: x86: Use memcmp in kvm_cpuid_check_equal()
Date: Wed, 26 Jan 2022 17:25:59 +0100	[thread overview]
Message-ID: <87mtjih3ag.fsf@redhat.com> (raw)
In-Reply-To: <YfFwnm3Vp0eOPElp@google.com>

Sean Christopherson <seanjc@google.com> writes:

> On Wed, Jan 26, 2022, Vitaly Kuznetsov wrote:
>> Joe Perches <joe@perches.com> writes:
>> 
>> > On Mon, 2022-01-24 at 11:36 +0100, Vitaly Kuznetsov wrote:
>> >> kvm_cpuid_check_equal() should also check .flags equality but instead
>> >> of adding it to the existing check, just switch to using memcmp() for
>> >> the whole 'struct kvm_cpuid_entry2'.
>> >
>> > Is the struct padding guaranteed to be identical ?
>> >
>> 
>> Well, yes (or we're all doomeed):
>> - 'struct kvm_cpuid_entry2' is part of KVM userspace ABI, it is supposed
>> to be stable.
>> - Here we compare structs which come from the same userspace during one
>> session (vCPU fd stays open), I can't imagine how structure layout can
>> change on-the-fly.
>
> I'm pretty sure Joe was asking if the contents of the padding field would be
> identical, i.e. if KVM can guarnatee there won't be false positives on
> mismatches,

Ah, sorry, I thought about structure layout. Generally, there's no
guarantee the content of the padding will be the same in the
KVM_SET_CPUID2 case as we vmemdup_user() what userspace VMM gives us.

> which is the same reason Paolo passed on this patch.  Though I still think we
> should roll the dice :-)

Well, so far we've only identified CPU (re-)hotplug by reusing an
existing vCPU fd as a broken use-case and it may happen that QEMU is the
only VMM which does that (and memcmp() approach works for it) ... but
who know what's out there)

-- 
Vitaly


      reply	other threads:[~2022-01-26 16:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 10:36 [PATCH 0/2] KVM: x86: Partially allow KVM_SET_CPUID{,2} follow-up Vitaly Kuznetsov
2022-01-24 10:36 ` [PATCH 1/2] KVM: x86: Move CPUID.(EAX=0x12,ECX=1) mangling to __kvm_update_cpuid_runtime() Vitaly Kuznetsov
2022-01-24 10:36 ` [PATCH 2/2] KVM: x86: Use memcmp in kvm_cpuid_check_equal() Vitaly Kuznetsov
2022-01-24 14:02   ` Paolo Bonzini
2022-01-24 15:10     ` Vitaly Kuznetsov
2022-01-24 16:52       ` Sean Christopherson
2022-01-24 17:07         ` Paolo Bonzini
2022-01-24 19:08           ` Sean Christopherson
2022-01-24 21:03   ` Joe Perches
2022-01-26 10:03     ` Vitaly Kuznetsov
2022-01-26 16:02       ` Sean Christopherson
2022-01-26 16:25         ` Vitaly Kuznetsov [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=87mtjih3ag.fsf@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jmattson@google.com \
    --cc=joe@perches.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=wanpengli@tencent.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).