From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
"Alexander Graf" <agraf@suse.de>,
"Gabriel L. Somlo" <gsomlo@gmail.com>
Subject: Re: [PATCH 3/4] KVM: x86: drop bogus MWAIT check
Date: Thu, 4 May 2017 21:26:32 +0300 [thread overview]
Message-ID: <20170504212458-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <638dd02c-102a-21d8-7a10-30a3ef3c357d@redhat.com>
On Thu, May 04, 2017 at 12:58:05PM +0200, Paolo Bonzini wrote:
>
>
> On 03/05/2017 21:37, Radim Krčmář wrote:
> > The guest can call MWAIT with ECX = 0 even if we enforce
> > CPUID5_ECX_INTERRUPT_BREAK; the call would have the exactly the same
> > effect as if the host didn't have CPUID5_ECX_INTERRUPT_BREAK.
> >
> > The check was added in some iteration while trying to fix a reported
> > OS X on Core 2 bug, but the CPU had CPUID5_ECX_INTERRUPT_BREAK and the
> > bug is elsewhere.
>
> The reason for this, as I understood it, is that we have historically
> not published leaf 5 information via KVM_GET_SUPPORTED_CPUID. For this
> reason, QEMU is publishing CPUID5_ECX_INTERRUPT_BREAK. Then if:
>
> - the host doesn't have ECX[0]=1 support
>
> - the guest sets ECX[0]
>
> you get a #GP in the guest. So wrong comment but right thing to do.
>
> Paolo
Exactly. And I agree the comment isn't a good one.
> > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> > ---
> > arch/x86/kvm/x86.h | 23 +----------------------
> > 1 file changed, 1 insertion(+), 22 deletions(-)
> >
> > diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> > index 63d5fb65ea30..8ea4e80c24d1 100644
> > --- a/arch/x86/kvm/x86.h
> > +++ b/arch/x86/kvm/x86.h
> > @@ -216,8 +216,6 @@ static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec)
> >
> > static inline bool kvm_mwait_in_guest(void)
> > {
> > - unsigned int eax, ebx, ecx, edx;
> > -
> > if (!cpu_has(&boot_cpu_data, X86_FEATURE_MWAIT))
> > return false;
> >
> > @@ -225,29 +223,10 @@ static inline bool kvm_mwait_in_guest(void)
> > case X86_VENDOR_AMD:
> > return !boot_cpu_has_bug(X86_BUG_AMD_E400);
> > case X86_VENDOR_INTEL:
> > - /* Handle Intel below */
> > - break;
> > + return !boot_cpu_has_bug(X86_BUG_MONITOR);
> > default:
> > return false;
> > }
> > -
> > - if (boot_cpu_has_bug(X86_BUG_MONITOR))
> > - return false;
> > -
> > - /*
> > - * Intel CPUs without CPUID5_ECX_INTERRUPT_BREAK are problematic as
> > - * they would allow guest to stop the CPU completely by disabling
> > - * interrupts then invoking MWAIT.
> > - */
> > - if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
> > - return false;
> > -
> > - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
> > -
> > - if (!(ecx & CPUID5_ECX_INTERRUPT_BREAK))
> > - return false;
> > -
> > - return true;
> > }
> >
> > #endif
> >
next prev parent reply other threads:[~2017-05-04 18:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 19:37 [PATCH 0/4] KVM: x86: kvm_mwait_in_guest() cleanup and fixes Radim Krčmář
2017-05-03 19:37 ` [PATCH 1/4] KVM: svm: prevent MWAIT in guest with erratum 400 Radim Krčmář
2017-05-03 20:11 ` Borislav Petkov
2017-05-04 14:02 ` Radim Krčmář
2017-05-04 16:45 ` Borislav Petkov
2017-05-03 19:37 ` [PATCH 2/4] KVM: x86: prevent MWAIT in guest with buggy MONITOR Radim Krčmář
2017-05-03 19:37 ` [PATCH 3/4] KVM: x86: drop bogus MWAIT check Radim Krčmář
2017-05-04 10:58 ` Paolo Bonzini
2017-05-04 14:33 ` Radim Krčmář
2017-05-04 18:29 ` Michael S. Tsirkin
2017-05-04 20:03 ` Radim Krčmář
2017-05-04 18:26 ` Michael S. Tsirkin [this message]
2017-05-03 19:37 ` [PATCH 4/4] KVM: x86: simplify kvm_mwait_in_guest() Radim Krčmář
2017-05-03 19:45 ` [PATCH 0/4] KVM: x86: kvm_mwait_in_guest() cleanup and fixes Alexander Graf
2017-05-04 17:56 ` Gabriel L. Somlo
2017-05-04 18:07 ` Radim Krčmář
2017-05-05 13:02 ` Gabriel L. Somlo
2017-05-06 16:48 ` Gabriel L. Somlo
2017-05-08 7:23 ` Paolo Bonzini
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=20170504212458-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=agraf@suse.de \
--cc=gsomlo@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox