kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: Avi Kivity <avi@redhat.com>,
	Alexey Zaytsev <alexey.zaytsev@gmail.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	jinsong.liu@intel.com, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: Don't automatically expose the TSC deadline timer in cpuid
Date: Mon, 26 Dec 2011 01:44:48 +0100	[thread overview]
Message-ID: <4EF7C380.2090504@web.de> (raw)
In-Reply-To: <1324839608.3261.10.camel@lappy>

[-- Attachment #1: Type: text/plain, Size: 1867 bytes --]

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 returned
>> +as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
>> +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_CPUID2.
> 
> 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.

> 
>> +	if (apic) {
>> +		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
>> +			apic->lapic_timer.timer_mode_mask = 3 << 17;
>> +		else
>> +			apic->lapic_timer.timer_mode_mask = 1 << 17;
>> +	}
> 
> Can we change these to be:
> 
> if(...)
> 	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC | APIC_LVT_TIMER_TSCDEADLINE;
> else
> 	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC;
> 

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  parent reply	other threads:[~2011-12-26  0:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-25 13:03 [PATCH] KVM: Don't automatically expose the TSC deadline timer in cpuid Avi Kivity
2011-12-25 18:39 ` Jan Kiszka
2011-12-26 11:14   ` Avi Kivity
2011-12-25 19:00 ` Sasha Levin
2011-12-25 19:47   ` Sasha Levin
2011-12-26  8:51     ` Liu, Jinsong
2011-12-26  0:44   ` Jan Kiszka [this message]
2011-12-26  8:42 ` Liu, Jinsong
2011-12-26 10:35   ` Avi Kivity
2011-12-26 10:43     ` Alexey Zaytsev
2011-12-26 10:45       ` Avi Kivity
2011-12-26 11:25         ` Alexey Zaytsev
2011-12-26 11:28           ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EF7C380.2090504@web.de \
    --to=jan.kiszka@web.de \
    --cc=alexey.zaytsev@gmail.com \
    --cc=avi@redhat.com \
    --cc=jinsong.liu@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).