From nobody Fri May 3 09:08:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487856977981495.0259384810397; Thu, 23 Feb 2017 05:36:17 -0800 (PST) Received: from localhost ([::1]:58781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgtZ7-0001fs-I4 for importer@patchew.org; Thu, 23 Feb 2017 08:36:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgtXj-00012x-TP for qemu-devel@nongnu.org; Thu, 23 Feb 2017 08:34:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgtXg-0000az-Ph for qemu-devel@nongnu.org; Thu, 23 Feb 2017 08:34:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgtXg-0000ac-HE for qemu-devel@nongnu.org; Thu, 23 Feb 2017 08:34:44 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86253C04BD41 for ; Thu, 23 Feb 2017 13:34:44 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-170.ams2.redhat.com [10.36.117.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FCD5BAFE0; Thu, 23 Feb 2017 13:34:43 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, pbonzini@redhat.com, lersek@redhat.com Date: Thu, 23 Feb 2017 13:34:41 +0000 Message-Id: <20170223133441.16010-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 23 Feb 2017 13:34:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] x86: Work around SMI migration breakages X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Migration from a 2.3.0 qemu results in a reboot on the receiving QEMU due to a disagreement about SM (System management) interrupts. 2.3.0 didn't have much SMI support, but it did set CPU_INTERRUPT_SMI and this gets into the migration stream, but on 2.3.0 it never got delivered. ~2.4.0 SMI interrupt support was added but was broken - so that when a 2.3.0 stream was received it cleared the CPU_INTERRUPT_SMI but never actually caused an interrupt. The SMI delivery was recently fixed by 68c6efe07a, but the effect now is that an incoming 2.3.0 stream takes the interrupt it had flagged but it's bios can't actually handle it(I think partly due to the original interrupt not being taken during boot?). The consequence is a triple(?) fault and a reboot. Tested from: 2.3.1 -M 2.3.0 2.7.0 -M 2.3.0 2.8.0 -M 2.3.0 2.8.0 -M 2.8.0 This corresponds to RH bugzilla entry 1420679. Signed-off-by: Dr. David Alan Gilbert --- include/hw/i386/pc.h | 4 ++++ target/i386/cpu.c | 2 ++ target/i386/cpu.h | 3 +++ target/i386/kvm.c | 7 ++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 079e8d9..cb49826 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -624,6 +624,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_= t *); .driver =3D "Broadwell-noTSX" "-" TYPE_X86_CPU,\ .property =3D "xlevel",\ .value =3D stringify(0x8000000a),\ + },{\ + .driver =3D TYPE_X86_CPU,\ + .property =3D "kvm-no-smi-migration",\ + .value =3D "on",\ }, =20 #define PC_COMPAT_2_2 \ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fd7add2..b2058cd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3708,6 +3708,8 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("cpuid-0xb", X86CPU, enable_cpuid_0xb, true), DEFINE_PROP_BOOL("lmce", X86CPU, enable_lmce, false), DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true), + DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration, + false), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), DEFINE_PROP_END_OF_LIST() }; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 8df124f..c5dfef8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1255,6 +1255,9 @@ struct X86CPU { /* if true override the phys_bits value with a value read from the hos= t */ bool host_phys_bits; =20 + /* Stop SMI delivery for migration compatibility with old machines */ + bool kvm_no_smi_migration; + /* Number of physical address bits supported */ uint32_t phys_bits; =20 diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 27fd050..5bfe633 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2531,7 +2531,12 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int leve= l) events.smi.pending =3D 0; events.smi.latched_init =3D 0; } - events.flags |=3D KVM_VCPUEVENT_VALID_SMM; + /* Stop SMI delivery on old machine types to avoid a reboot + * on an inward migration of an old VM. + */ + if (!cpu->kvm_no_smi_migration) { + events.flags |=3D KVM_VCPUEVENT_VALID_SMM; + } } =20 if (level >=3D KVM_PUT_RESET_STATE) { --=20 2.9.3