All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 0/2] kvm: fix incorrect LAPIC reset after reboot in x2apic mode
Date: Thu, 22 Sep 2016 16:29:15 +0100	[thread overview]
Message-ID: <20160922152915.GH2085@work-vm> (raw)
In-Reply-To: <1474557927-21698-1-git-send-email-pbonzini@redhat.com>

* Paolo Bonzini (pbonzini@redhat.com) wrote:
> Linux 4.8 introduces changes that really really require you to set
> the APIC base (via either KVM_SET_SREGS or KVM_SET_MSRS) before the
> KVM_SET_LAPIC ioctl, unless KVM_SET_LAPIC is immediately preceded by
> KVM_GET_LAPIC.  This is because in x2apic mode KVM now moves the APIC id
> from bits 31-24 of the KVM_SET_LAPIC argument to bits 7-0 of the APIC_ID
> register (0x20).  If QEMU does not nudge the APIC out of x2apic at reset
> time, the subsequent KVM_SET_LAPIC incorrectly shifts the APIC id right
> and Linux sees (in bits 31-24) a zero id.
> 
> While QEMU has always done the right thing, the recent commit 78d6a05
> ("x86/lapic: Load LAPIC state at post_load", 2016-09-13) changed
> that, causing a bug on newer kernels.  Fix this by setting the APIC
> base in kvm_apic_put.  Another workaround could be to enable
> KVM_X2APIC_API_USE_32BIT_IDS, which lets KVM not mangle the APIC ID.
> 
> Despite the "don't break userspace" mantra, I believe that this can be
> considered a QEMU bug.
> 
> I checked kvmtool and it only calls KVM_SET_LAPIC after a KVM_GET_LAPIC,
> which avoids the issue in the first place.
> 
> Dr. David Alan Gilbert (1):
>   kvm: apic: set APIC base as part of kvm_apic_put
> 
> Paolo Bonzini (1):
>   target-i386: introduce kvm_put_one_msr
> 
> v1->v2: send the right patches

Yep, that's better - that corresponds to the version you pastebin'd
earlier and it seems to work nicely.

Dave

> 
>  hw/i386/kvm/apic.c     |  2 ++
>  target-i386/kvm.c      | 31 ++++++++++++++++++++++---------
>  target-i386/kvm_i386.h |  2 ++
>  3 files changed, 26 insertions(+), 9 deletions(-)
> 
> -- 
> 2.7.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

      parent reply	other threads:[~2016-09-22 15:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22 15:25 [Qemu-devel] [PATCH v2 0/2] kvm: fix incorrect LAPIC reset after reboot in x2apic mode Paolo Bonzini
2016-09-22 15:25 ` [Qemu-devel] [PATCH 1/2] target-i386: introduce kvm_put_one_msr Paolo Bonzini
2016-09-22 15:25 ` [Qemu-devel] [PATCH 2/2] kvm: apic: set APIC base as part of kvm_apic_put Paolo Bonzini
2016-09-22 15:29 ` Dr. David Alan Gilbert [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=20160922152915.GH2085@work-vm \
    --to=dgilbert@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.