From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6jnm-0005yZ-Jv for qemu-devel@nongnu.org; Wed, 29 Aug 2012 11:03:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6jnl-0002Lj-Eh for qemu-devel@nongnu.org; Wed, 29 Aug 2012 11:03:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6jnl-0002LU-6P for qemu-devel@nongnu.org; Wed, 29 Aug 2012 11:03:29 -0400 From: Eduardo Habkost Date: Wed, 29 Aug 2012 12:04:25 -0300 Message-Id: <1346252665-9373-1-git-send-email-ehabkost@redhat.com> In-Reply-To: <20120829144157.GH6223@otherpad.lan.raisama.net> References: <20120829144157.GH6223@otherpad.lan.raisama.net> Subject: [Qemu-devel] [QEMU 1.2 PATCH] i386: kvm: have a predefined set of default KVM feature bits List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Gleb Natapov , "Michael S. Tsirkin" , mtosatti@redhat.com, Blue Swirl , Jan Kiszka , avi@redhat.com, Anthony Liguori We can't simply expose the GET_SUPPORTED_CPUID results directly to the guest, or the resulting guest-visible CPUID bits may change under the guest's feet when we live-migrate. We still have to implement proper per-machine-type migration compatibility bits, but this at least is a workaround for cases where PV EOI would be silently enabled after a host kernel upgrade. We also have to implement proper check/warnings about unsupported bits when using "-cpu check" or "-cpu enforce", because the default bits may be silently disabled if the host kernel doesn't support them. Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 18 +++++++++++++++++- target-i386/cpu.h | 10 ++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 120a2e3..52042f0 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -283,6 +283,21 @@ typedef struct x86_def_t { CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A) #define TCG_SVM_FEATURES 0 + +/* List of KVM features we (try to) enable by default + * + * CPUID_KVM_PV_EOI is not enabled until we have proper per-machine-type + * migration compatibility support + * + * CPUID_KVM_MMU is not enabled because it is deprecated. + */ +#define DEFAULT_KVM_FEATURES (CPUID_KVM_CLOCKSOURCE | \ + CPUID_KVM_KVM_NOP_IO_DELAY | \ + CPUID_KVM_CLOCKSOURCE2 | \ + CPUID_KVM_KVM_ASYNC_PF | \ + CPUID_KVM_STEAL_TIME | \ + CPUID_KVM_CLOCKSOURCE_STABLE_BIT) + /* maintains list of cpu model definitions */ static x86_def_t *x86_defs = {NULL}; @@ -887,7 +902,8 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) memcpy(x86_cpu_def, def, sizeof(*def)); } - plus_kvm_features = ~0; /* not supported bits will be filtered out later */ + /* not supported bits will be filtered out later */ + plus_kvm_features = DEFAULT_KVM_FEATURES; add_flagname_to_bitmaps("hypervisor", &plus_features, &plus_ext_features, &plus_ext2_features, &plus_ext3_features, diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 60f9e97..5ce4baf 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -440,6 +440,16 @@ #define CPUID_SVM_PAUSEFILTER (1 << 10) #define CPUID_SVM_PFTHRESHOLD (1 << 12) +/* CPUID[4000_0001h].EAX bits: */ +#define CPUID_KVM_CLOCKSOURCE (1 << 0) +#define CPUID_KVM_KVM_NOP_IO_DELAY (1 << 1) +#define CPUID_KVM_MMU (1 << 2) +#define CPUID_KVM_CLOCKSOURCE2 (1 << 3) +#define CPUID_KVM_KVM_ASYNC_PF (1 << 4) +#define CPUID_KVM_STEAL_TIME (1 << 5) +#define CPUID_KVM_KVM_PV_EOI (1 << 6) +#define CPUID_KVM_CLOCKSOURCE_STABLE_BIT (1 << 24) + #define CPUID_VENDOR_INTEL_1 0x756e6547 /* "Genu" */ #define CPUID_VENDOR_INTEL_2 0x49656e69 /* "ineI" */ #define CPUID_VENDOR_INTEL_3 0x6c65746e /* "ntel" */ -- 1.7.11.4