From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5wB-0006nt-Qd for qemu-devel@nongnu.org; Thu, 22 Sep 2016 11:29:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5w7-0003Hk-J6 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 11:29:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52382) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5w7-0003Hg-Cy for qemu-devel@nongnu.org; Thu, 22 Sep 2016 11:29:19 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9F4C1CC80C for ; Thu, 22 Sep 2016 15:29:18 +0000 (UTC) Date: Thu, 22 Sep 2016 16:29:15 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20160922152915.GH2085@work-vm> References: <1474557927-21698-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1474557927-21698-1-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 0/2] kvm: fix incorrect LAPIC reset after reboot in x2apic mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org * 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