From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiU14-0001aj-HU for qemu-devel@nongnu.org; Wed, 04 Jan 2012 11:48:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RiU0z-0001k8-O3 for qemu-devel@nongnu.org; Wed, 04 Jan 2012 11:48:42 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:54312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiU0z-0001jn-C5 for qemu-devel@nongnu.org; Wed, 04 Jan 2012 11:48:37 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate02.web.de (Postfix) with ESMTP id 644831BF344D2 for ; Wed, 4 Jan 2012 17:48:35 +0100 (CET) Message-ID: <4F0482D6.8080705@web.de> Date: Wed, 04 Jan 2012 14:48:22 -0200 From: Jan Kiszka MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig9E87DB657655A8C6443B822F" Subject: Re: [Qemu-devel] [PATCH 2/2] Expose tsc deadline timer cpuid to guest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Liu, Jinsong" Cc: "qemu-devel@nongnu.org" , Marcelo Tosatti , Avi Kivity , kvm , Alexey Zaytsev This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9E87DB657655A8C6443B822F Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-12-28 19:55, Liu, Jinsong wrote: >>>From 3a78adf8006ec6189bfe2f55f7ae213e75bf3815 Mon Sep 17 00:00:00 2001 > From: Liu Jinsong > Date: Thu, 29 Dec 2011 05:28:12 +0800 > Subject: [PATCH 2/2] Expose tsc deadline timer cpuid to guest >=20 > Depend on several factors: > 1. Considering live migration, user enable/disable tsc deadline timer; > 2. If guest use kvm apic and kvm emulate tsc deadline timer, expose it;= > 3. If in the future qemu support tsc deadline timer emulation, > and guest use qemu apic, add cpuid exposing case then. This requires some logic change and then rewording: - enable TSC deadline timer support by default if in-kernel irqchip is used - disable it on user request via a cpu feature flag - disable it for older machine types (see below) by default TSC deadline timer emulation in user space is a different story to be told once we have a patch for it. >=20 > Signed-off-by: Liu, Jinsong > --- > target-i386/cpu.h | 2 ++ > target-i386/cpuid.c | 7 ++++++- > target-i386/kvm.c | 13 +++++++++++++ > 3 files changed, 21 insertions(+), 1 deletions(-) >=20 > diff --git a/target-i386/cpu.h b/target-i386/cpu.h > index 177d8aa..f2d0ad5 100644 > --- a/target-i386/cpu.h > +++ b/target-i386/cpu.h > @@ -399,6 +399,7 @@ > #define CPUID_EXT_X2APIC (1 << 21) > #define CPUID_EXT_MOVBE (1 << 22) > #define CPUID_EXT_POPCNT (1 << 23) > +#define CPUID_EXT_TSC_DEADLINE_TIMER (1 << 24) > #define CPUID_EXT_XSAVE (1 << 26) > #define CPUID_EXT_OSXSAVE (1 << 27) > #define CPUID_EXT_HYPERVISOR (1 << 31) > @@ -693,6 +694,7 @@ typedef struct CPUX86State { > =20 > uint64_t tsc; > uint64_t tsc_deadline; > + bool tsc_deadline_timer_enabled; > =20 > uint64_t mcg_status; > uint64_t msr_ia32_misc_enable; > diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c > index 0b3af90..fe749e0 100644 > --- a/target-i386/cpuid.c > +++ b/target-i386/cpuid.c > @@ -48,7 +48,7 @@ static const char *ext_feature_name[] =3D { > "fma", "cx16", "xtpr", "pdcm", > NULL, NULL, "dca", "sse4.1|sse4_1", > "sse4.2|sse4_2", "x2apic", "movbe", "popcnt", > - NULL, "aes", "xsave", "osxsave", > + "tsc_deadline", "aes", "xsave", "osxsave", > "avx", NULL, NULL, "hypervisor", > }; > static const char *ext2_feature_name[] =3D { > @@ -225,6 +225,7 @@ typedef struct x86_def_t { > int model; > int stepping; > int tsc_khz; > + bool tsc_deadline_timer_enabled; > uint32_t features, ext_features, ext2_features, ext3_features; > uint32_t kvm_features, svm_features; > uint32_t xlevel; > @@ -742,6 +743,9 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_= def, const char *cpu_model) > x86_cpu_def->ext3_features &=3D ~minus_ext3_features; > x86_cpu_def->kvm_features &=3D ~minus_kvm_features; > x86_cpu_def->svm_features &=3D ~minus_svm_features; > + /* Defaultly user don't against tsc_deadline_timer */ > + x86_cpu_def->tsc_deadline_timer_enabled =3D > + !(minus_ext_features & CPUID_EXT_TSC_DEADLINE_TIMER); > if (check_cpuid) { > if (check_features_against_host(x86_cpu_def) && enforce_cpuid)= > goto error; > @@ -885,6 +889,7 @@ int cpu_x86_register (CPUX86State *env, const char = *cpu_model) > env->cpuid_ext4_features =3D def->ext4_features; > env->cpuid_xlevel2 =3D def->xlevel2; > env->tsc_khz =3D def->tsc_khz; > + env->tsc_deadline_timer_enabled =3D def->tsc_deadline_timer_enable= d; > if (!kvm_enabled()) { > env->cpuid_features &=3D TCG_FEATURES; > env->cpuid_ext_features &=3D TCG_EXT_FEATURES; > diff --git a/target-i386/kvm.c b/target-i386/kvm.c > index d50de90..79baf0b 100644 > --- a/target-i386/kvm.c > +++ b/target-i386/kvm.c > @@ -370,6 +370,19 @@ int kvm_arch_init_vcpu(CPUState *env) > i =3D env->cpuid_ext_features & CPUID_EXT_HYPERVISOR; > env->cpuid_ext_features &=3D kvm_arch_get_supported_cpuid(s, 1, 0,= R_ECX); > env->cpuid_ext_features |=3D i; > + /* > + * 1. Considering live migration, user enable/disable tsc deadline= timer; > + * 2. If guest use kvm apic and kvm emulate tsc deadline timer, ex= pose it; > + * 3. If in the future qemu support tsc deadline timer emulation, > + * and guest use qemu apic, add cpuid exposing case then. > + */ See above. Also, I don't think this comment applies very well to this function. > + env->cpuid_ext_features &=3D ~CPUID_EXT_TSC_DEADLINE_TIMER; Can that feature possibly be set in cpuid_ext_features? I thought the kernel now refrains from this. > + if (env->tsc_deadline_timer_enabled) { > + if (kvm_irqchip_in_kernel() && > + kvm_check_extension(s, KVM_CAP_TSC_DEADLINE_TIMER)) { > + env->cpuid_ext_features |=3D CPUID_EXT_TSC_DEADLINE_TIMER;= > + } > + } > =20 > env->cpuid_ext2_features &=3D kvm_arch_get_supported_cpuid(s, 0x80= 000001, > 0, R_EDX)= ; Sorry, it remains bogus to expose the tsc deadline timer feature on machines < pc-1.1. That's just like we introduced kvmclock only to pc-0.14 onward. The reason is that guest OSes so far running on qemu-1.0 or older without deadline timer support must not find that feature when being migrated to a host with qemu-1.1 in pc-1.0 compat mode. Yes, the user can explicitly disable it, but that is not the idea of legacy machine models. They should provide the very same environment that older qemu versions offered. Jan --------------enig9E87DB657655A8C6443B822F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8EgtwACgkQitSsb3rl5xRgzwCfdI+p6dAg6z5pytMj/efk2ICA 4T0An1W2oghkQS63i9bycsoTHe4mM3Uc =xJ8F -----END PGP SIGNATURE----- --------------enig9E87DB657655A8C6443B822F--