From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [RFC PATCH] Emulate MOVBE Date: Tue, 16 Apr 2013 13:47:46 +0200 Message-ID: <516D3A62.6030708@redhat.com> References: <20130409234602.GI5077@pd.tnic> <20130410112942.07dfc167@slackpad> <20130410100845.GB17919@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Andre Przywara , Borislav Petkov , kvm@vger.kernel.org, =?ISO-8859-1?Q?J=F6rg_R=F6del?= , "H. Peter Anvin" , x86-ml , kvm@vger-kernel.org To: Gleb Natapov Return-path: Received: from mail-qe0-f53.google.com ([209.85.128.53]:42742 "EHLO mail-qe0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753749Ab3DPLsD (ORCPT ); Tue, 16 Apr 2013 07:48:03 -0400 Received: by mail-qe0-f53.google.com with SMTP id q19so185182qeb.12 for ; Tue, 16 Apr 2013 04:48:01 -0700 (PDT) In-Reply-To: <20130410100845.GB17919@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Il 10/04/2013 12:08, Gleb Natapov ha scritto: >> > What is the opinion from the KVM folks on this? Shall we start to >> > emulate instructions the host does not provide? In this particular case >> > a relatively simple patch fixes a problem (starting Atom optimized >> > kernels on non-Atom machines). > We can add the emulation, but we should not start announcing the instruction > availability to a guest if host cpu does not have it by default. This > may trick a guest into thinking that movbe is the fastest way to do > something when it is not. > This does highlight a weakness in CPU_GET_SUPPORTED_CPUID, but I think this is not a problem in practice. With a management layer such as oVirt it's not a problem. For example, oVirt has its own library of processors. It doesn't care if KVM enables movbe. If you tell it your datacenter is a mix of Haswells and Sandy Bridges it will pick the CPUID bits that are common to all. However, even without a suitable management layer it is also not really a problem. The only processors that support MOVBE are Atom and Haswell. Haswell adds a whole lot of extra CPUID features, hence "-cpu Haswell,enforce" will fail with or without movbe emulation. "-cpu Haswell" will disable all Haswell new features except movbe will remain slow; that's fine, I think, anyway it's not what you'ld do except to play with CPU models. Atom is not defined by QEMU; even if it was, it is unlikely to be specified for a KVM guest since Atom doesn't support hardware virtualization itself. The next AMD processor that has MOVBE will probably have at least another feature that is not in Opteron_G5, thus it will be the same as Haswell. Paolo