Received: from eggs.gnu.org ([2001:4830:134:3::10]:40271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7Qas-0001nv-LP for qemu-devel@nongnu.org; Tue, 23 Jun 2015 11:58:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7Qap-00024D-7S for qemu-devel@nongnu.org; Tue, 23 Jun 2015 11:58:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7Qao-000249-TC for qemu-devel@nongnu.org; Tue, 23 Jun 2015 11:58:35 -0400 Date: Tue, 23 Jun 2015 12:58:32 -0300 From: Eduardo Habkost Message-ID: <20150623155832.GE3134@thinpad.lan.raisama.net> References: <1433790460-30679-1-git-send-email-ehabkost@redhat.com> <20150608201835.GM3525@orkuz.home> <558951C0.3050806@suse.de> <20150623150828.GD3134@thinpad.lan.raisama.net> <20150623173048-mutt-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20150623173048-mutt-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 0/2] target-i386: "custom" CPU model + script to dump existing CPU models List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: mimu@linux.vnet.ibm.com, qemu-devel@nongnu.org, Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , Paolo Bonzini , Jiri Denemark , Andreas =?iso-8859-1?Q?F=E4rber?= , rth@twiddle.net On Tue, Jun 23, 2015 at 05:32:42PM +0200, Michael S. Tsirkin wrote: > On Tue, Jun 23, 2015 at 12:08:28PM -0300, Eduardo Habkost wrote: > > On Tue, Jun 23, 2015 at 02:32:00PM +0200, Andreas F=E4rber wrote: > > > Am 08.06.2015 um 22:18 schrieb Jiri Denemark: > > > >> To help libvirt in the transition, a x86-cpu-model-dump script i= s provided, > > > >> that will generate a config file that can be loaded using -readc= onfig, based on > > > >> the -cpu and -machine options provided in the command-line. > > > >=20 > > > > Thanks Eduardo, I never was a big fan of moving (or copying) all = the CPU > > > > configuration data to libvirt, but now I think it actually makes = sense. > > > > We already have a partial copy of CPU model definitions in libvir= t > > > > anyway, but as QEMU changes some CPU models in some machine types= (and > > > > libvirt does not do that) we have no real control over the guest = CPU > > > > configuration. While what we really want is full control to enfor= ce > > > > stable guest ABI. > > >=20 > > > That sounds like FUD to me. Any concrete data points where QEMU doe= s not > > > have a stable ABI for x86 CPUs? That's what we have the pc*-x.y mac= hines > > > for. > >=20 > > What Jiri is saying that the CPUs change depending on -mmachine, not > > that the ABI is broken by a given machine. > >=20 > > The problem here is that libvirt needs to provide CPU models whose > > runnability does not depend on the machine-type. If users have a VM t= hat > > is running in a host and the VM machine-type changes, >=20 > How does it change, and why? Sometimes we add features to a CPU model because they were not emulated b= y KVM and now they are. Sometimes we remove or add features or change other fie= lds because we are fixing previous mistakes. Recently we we were going to rem= ove features from models because of an Intel CPU errata, but then decided to = create a new CPU model name instead. See some examples at the end of this message. >=20 > > the VM should be > > still runnable in that host. QEMU doesn't provide that, our CPU model= s > > may change when we introduce new machine-types, so we are giving them= a > > mechanism that allows libvirt to implement the policy they need. >=20 > I don't mind wrt CPU specifically, but we absolutely do change guest AB= I > in many ways when we change machine types. All the other ABI changes we introduce in QEMU don't affect runnability o= f the VM in a given host, that's the problem we are trying to address here. ABI changes are expected when changing to a new machine, runnability changes aren't. Examples of commits changing CPU models: commit 726a8ff68677d8d5fba17eb0ffb85076bfb598dc Author: Eduardo Habkost Date: Fri Apr 10 14:45:00 2015 -0300 target-i386: Remove AMD feature flag aliases from CPU model table =20 When CPU vendor is AMD, the AMD feature alias bits on CPUID[0x80000001].EDX are already automatically copied from CPUID[1].= EDX on x86_cpu_realizefn(). When CPU vendor is Intel, those bits are reserved and should be zero. On either case, those bits shouldn't be = set in the CPU model table. =20 Reviewed-by: Igor Mammedov Signed-off-by: Eduardo Habkost commit 13704e4c455770d500d6b87b117e32f0d01252c9 Author: Eduardo Habkost Date: Thu Jan 22 17:22:54 2015 -0200 target-i386: Disable HLE and RTM on Haswell & Broadwell =20 All Haswell CPUs and some Broadwell CPUs were updated by Intel to hav= e the HLE and RTM features disabled. This will prevent "-cpu Haswell,enforce" and "-cpu Broadwell,enforce" from running out = of the box on those CPUs. =20 Disable those features by default on Broadwell and Haswell CPU models= , starting on pc-*-2.3. Users who want to use those features can enable them explicitly on the command-line. =20 Signed-off-by: Eduardo Habkost Signed-off-by: Paolo Bonzini commit 78a611f1936b3eac8ed78a2be2146a742a85212c Author: Paolo Bonzini Date: Fri Dec 5 10:52:46 2014 +0100 target-i386: add f16c and rdrand to Haswell and Broadwell =20 Both were added in Ivy Bridge (for which we do not have a CPU model yet!). =20 Reviewed-by: Eduardo Habkost Signed-off-by: Paolo Bonzini commit b3a4f0b1a072a467d003755ca0e55c5be38387cb Author: Paolo Bonzini Date: Wed Dec 10 14:12:41 2014 -0200 target-i386: add VME to all CPUs =20 vm86 mode extensions date back to the 486. All models should have them. =20 Signed-off-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Paolo Bonzini commit 0bb0b2d2fe7f645ddaf1f0ff40ac669c9feb4aa1 Author: Paolo Bonzini Date: Mon Nov 24 15:54:43 2014 +0100 target-i386: add feature flags for CPUID[EAX=3D0xd,ECX=3D1] =20 These represent xsave-related capabilities of the processor, and KVM = may or may not support them. =20 Add feature bits so that they are considered by "-cpu ...,enforce", a= nd use the new feature work instead of calling kvm_arch_get_supported_cpuid. =20 Bit 3 (XSAVES) is not migratables because it requires saving MSR_IA32= _XSS. Neither KVM nor any commonly available hardware supports it anyway. =20 Signed-off-by: Paolo Bonzini commit e93abc147fa628650bdbe7fd57f27462ca40a3c2 Author: Eduardo Habkost Date: Fri Oct 3 16:39:50 2014 -0300 target-i386: Don't enable nested VMX by default =20 TCG doesn't support VMX, and nested VMX is not enabled by default in = the KVM kernel module. =20 So, there's no reason to have VMX enabled by default on the core2duo = and coreduo CPU models, today. Even the newer Intel CPU model definitions don't have it enabled. =20 In this case, we need machine-type compat code, as people may be runn= ing the older machine-types on hosts that had VMX nesting enabled. =20 Signed-off-by: Eduardo Habkost Signed-off-by: Andreas F=E4rber commit f8e6a11aecc96e9d8a84f17d7c07019471714e20 Author: Eduardo Habkost Date: Tue Sep 10 17:48:59 2013 -0300 target-i386: Set model=3D6 on qemu64 & qemu32 CPU models =20 There's no Intel CPU with family=3D6,model=3D2, and Linux and Windows= guests disable SEP when seeing that combination due to Pentium Pro erratum #= 82. =20 In addition to just having SEP ignored by guests, Skype (and maybe ot= her applications) runs sysenter directly without passing through ntdll on Windows, and crashes because Windows ignored the SEP CPUID bit. =20 So, having model > 2 is a better default on qemu64 and qemu32 for two reasons: making SEP really available for guests, and avoiding crashin= g applications that work on bare metal. =20 model=3D3 would fix the problem, but it causes CPU enumeration proble= ms for Windows guests[1]. So let's set model=3D6, that matches "Athlon (PM core)" on AMD and "P2 with on-die L2 cache" on Intel and it allow= s Windows to use all CPUs as well as fixing sysenter. =20 [1] https://bugzilla.redhat.com/show_bug.cgi?id=3D508623 =20 Cc: Andrea Arcangeli Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Signed-off-by: Andreas F=E4rber commit 6b11322e0f724eb0649fdc324a44288b783023ad Author: Eduardo Habkost Date: Mon May 27 17:23:55 2013 -0300 target-i386: Set level=3D4 on Conroe/Penryn/Nehalem =20 The CPUID level value on Conroe, Penryn, and Nehalem are too low. Thi= s causes at least one known problem: the -smp "threads" option doesn't work as expect if level is < 4, because thread count information is provided to the guest on CPUID[EAX=3D4,ECX=3D2].EAX =20 Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Signed-off-by: Andreas F=E4rber commit ffce9ebbb69363dfe7605585cdad58ea3847edf4 Author: Eduardo Habkost Date: Mon May 27 17:23:54 2013 -0300 target-i386: Update model values on Conroe/Penryn/Nehalem CPU models =20 The CPUID model values on Conroe, Penryn, and Nehalem are too conservative and don't reflect the values found on real Conroe, Penry= n, and Nehalem CPUs. =20 This causes at least one known problems: Windows XP disables sysenter when (family =3D=3D 6 && model <=3D 2), but Skype tries to use the sy= senter instruction anyway because it is reported as available on CPUID, maki= ng it crash. =20 This patch sets appropriate model values that correspond to real Conr= oe, Penryn, and Nehalem CPUs. =20 Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Signed-off-by: Andreas F=E4rber commit b2a856d99281f2fee60a4313d204205bcd2c4269 Author: Andreas F=E4rber Date: Wed May 1 17:30:51 2013 +0200 target-i386: Change CPUID model of 486 to 8 =20 This changes the model number of 486 to 8 (DX4) which matches the feature set presented, and actually has the CPUID instruction. =20 This adds a compatibility property, to keep model=3D0 on pc-*-1.4 and= older. =20 Signed-off-by: H. Peter Anvin [AF: Add compat_props entry] Tested-by: Eduardo Habkost Reviewed-by: Eduardo Habkost Signed-off-by: Andreas F=E4rber KVM-specific changes: commit 75d373ef9729bd22fbc46bfd8dcd158cbf6d9777 Author: Eduardo Habkost Date: Fri Oct 3 16:39:51 2014 -0300 target-i386: Disable SVM by default in KVM mode =20 Make SVM be disabled by default on all CPU models when in KVM mode. Nested SVM is enabled by default in the KVM kernel module, but it is probably less stable than nested VMX (which is already disabled by default). =20 Add a new compat function, x86_cpu_compat_kvm_no_autodisable(), to ke= ep compatibility on previous machine-types. =20 Suggested-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Andreas F=E4rber commit 864867b91b48d38e2bfc7b225197901e6f7d8216 Author: Eduardo Habkost Date: Fri Oct 3 16:39:48 2014 -0300 target-i386: Disable CPUID_ACPI by default in KVM mode =20 KVM never supported the CPUID_ACPI flag, so it doesn't make sense to have it enabled by default when KVM is enabled. =20 The motivation here is exactly the same we had for the MONITOR flag (disabled by commit 136a7e9a85d7047461f8153f7d12c514a3d68f69). =20 And like in the MONITOR flag case, we don't need machine-type compat = code because it is currently impossible to run a KVM VM with the ACPI flag= set. =20 Signed-off-by: Eduardo Habkost Signed-off-by: Andreas F=E4rber commit 136a7e9a85d7047461f8153f7d12c514a3d68f69 Author: Eduardo Habkost Date: Wed Apr 30 13:48:28 2014 -0300 target-i386: kvm: Don't enable MONITOR by default on any CPU model =20 KVM never supported the MONITOR flag so it doesn't make sense to have= it enabled by default when KVM is enabled. =20 The rationale here is similar to the cases where it makes sense to ha= ve a feature enabled by default on all CPU models when on KVM mode (e.g. x2apic). In this case we are having a feature disabled by default for the same reasons. =20 In this case we don't need machine-type compat code because it is currently impossible to run a KVM VM with the MONITOR flag set. =20 Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Andreas F=E4rber commit ef02ef5f4536dba090b12360a6c862ef0e57e3bc Author: Eduardo Habkost Date: Wed Feb 19 11:58:12 2014 -0300 target-i386: Enable x2apic by default on KVM =20 When on KVM mode, enable x2apic by default on all CPU models. =20 Normally we try to keep the CPU model definitions as close as the rea= l CPUs as possible, but x2apic can be emulated by KVM without host CPU support for x2apic, and it improves performance by reducing APIC acce= ss overhead. x2apic emulation is available on KVM since 2009 (Linux 2.6.32-rc1), there's no reason for not enabling x2apic by default whe= n running KVM. =20 Signed-off-by: Eduardo Habkost Acked-by: Michael S. Tsirkin Signed-off-by: Andreas F=E4rber commit 6a4784ce6b95b013a13504ead9ab62975faf6eff Author: Eduardo Habkost Date: Mon Jan 7 16:20:44 2013 -0200 target-i386: Disable kvm_mmu by default =20 KVM_CAP_PV_MMU capability reporting was removed from the kernel since v2.6.33 (see commit a68a6a7282373), and was completely removed from t= he kernel since v3.3 (see commit fb92045843). It doesn't make sense to k= eep it enabled by default, as it would cause unnecessary hassle when usin= g the "enforce" flag. =20 This disables kvm_mmu on all machine-types. With this fix, the possib= le scenarios when migrating from QEMU <=3D 1.3 to QEMU 1.4 are: =20 ------------+----------+---------------------------------------------= ------- src kernel | dst kern.| Result ------------+----------+---------------------------------------------= ------- >=3D 2.6.33 | any | kvm_mmu was already disabled and will stay= disabled <=3D 2.6.32 | >=3D 3.3 | correct live migration is impossible <=3D 2.6.32 | <=3D 3.2 | kvm_mmu will be disabled on next guest r= eboot * ------------+----------+---------------------------------------------= ------- =20 * If they are running kernel <=3D 2.6.32 and want kvm_mmu to be kept enabled on guest reboot, they can explicitly add +kvm_mmu to the Q= EMU command-line. Using 2.6.33 and higher, it is not possible to enabl= e kvm_mmu explicitly anymore. =20 Signed-off-by: Eduardo Habkost Reviewed-by: Gleb Natapov Signed-off-by: Andreas F=E4rber commit dc59944bc9a5ad784572eea57610de60e4a2f4e5 Author: Michael S. Tsirkin Date: Thu Oct 18 00:15:48 2012 +0200 qemu: enable PV EOI for qemu 1.3 =20 Enable KVM PV EOI by default. You can still disable it with -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, enable only for qemu 1.3 (or in the future, newer) machine type. =20 Signed-off-by: Michael S. Tsirkin commit ef8621b1a3b199c348606c0a11a77d8e8bf135f1 Author: Anthony Liguori Date: Wed Aug 29 09:32:41 2012 -0500 target-i386: disable pv eoi to fix migration across QEMU versions =20 We have a problem with how we handle migration with KVM paravirt feat= ures. We unconditionally enable paravirt features regardless of whether we = know how to migrate them. =20 We also don't tie paravirt features to specific machine types so an o= ld QEMU on a new kernel would expose features that never existed. =20 The 1.2 cycle is over and as things stand, migration is broken. Mich= ael has another series that adds support for migrating PV EOI and attempts to= make it work correctly for different machine types. =20 After speaking with Michael on IRC, we agreed to take this patch plus= 1 & 4 from his series. This makes sure QEMU can migrate PV EOI if it's ena= bled, but does not enable it by default. =20 This also means that we won't unconditionally enable new features for= guests future proofing us from this happening again in the future. =20 Signed-off-by: Anthony Liguori --=20 Eduardo