From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: Don't automatically expose the TSC deadline timer in cpuid Date: Mon, 26 Dec 2011 01:44:48 +0100 Message-ID: <4EF7C380.2090504@web.de> References: <1324818200-15660-1-git-send-email-avi@redhat.com> <1324839608.3261.10.camel@lappy> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA71ABDD502EE327262A35391" Cc: Avi Kivity , Alexey Zaytsev , Marcelo Tosatti , jinsong.liu@intel.com, kvm@vger.kernel.org To: Sasha Levin Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:57594 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751515Ab1LZAow (ORCPT ); Sun, 25 Dec 2011 19:44:52 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate01.web.de (Postfix) with ESMTP id E91591A77738E for ; Mon, 26 Dec 2011 01:44:50 +0100 (CET) In-Reply-To: <1324839608.3261.10.camel@lappy> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA71ABDD502EE327262A35391 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-12-25 20:00, Sasha Levin wrote: > On Sun, 2011-12-25 at 15:03 +0200, Avi Kivity wrote: >> +The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always retu= rned >> +as false, since the feature depends on KVM_CREATE_IRQCHIP for local A= PIC >> +support. Instead it is reported via >> + >> + ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER) >> + >> +if that returns true you use KVM_CREATE_IRQCHIP, or if emulate the >> +feature in userspace, then you can enable the feature for KVM_SET_CPU= ID2. >=20 > Thats a bit strange, it's going to be a somewhat ugly special case in > userspace code. Just add something like if (kvm_has_cap_tscdeadline()) set_cpuid_feature_bit(vcpu, tcs_deadline) to the in-kernel apic setup code in userland. > It also means we can't simply proxy through CPUID from > kernel to the guest and only disable things we don't support, we now > have to enable them as well. That's unavoidable as you can't tell for sure if TSC_DEADLINE can be supported at all times the user may invoke KVM_GET_SUPPORTED_CPUID - that depends on the dynamic VM configuration. Just proxying the bits through like kvmtool may do right now is a very special case KVM can't support due to existing user space code and the needs of migration. >=20 >> + if (apic) { >> + if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER)) >> + apic->lapic_timer.timer_mode_mask =3D 3 << 17; >> + else >> + apic->lapic_timer.timer_mode_mask =3D 1 << 17; >> + } >=20 > Can we change these to be: >=20 > if(...) > apic->lapic_timer.timer_mode_mask =3D APIC_LVT_TIMER_PERIODIC | APIC_L= VT_TIMER_TSCDEADLINE; > else > apic->lapic_timer.timer_mode_mask =3D APIC_LVT_TIMER_PERIODIC; >=20 Yep, using symbols is better. As the patch needs some polishing regarding the doc wording, I think this could be cleaned up as well. Jan --------------enigA71ABDD502EE327262A35391 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.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk73w4AACgkQitSsb3rl5xRn2wCg2mutzZzFTJVxUk7t+fctxXw3 P2oAnA1iWtZ7+EKdim6xwkg244qXZnU+ =bg8p -----END PGP SIGNATURE----- --------------enigA71ABDD502EE327262A35391--