From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Alexey Zaytsev <alexey.zaytsev@gmail.com>,
"Liu, Jinsong" <jinsong.liu@intel.com>,
Kernel development list <linux-kernel@vger.kernel.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
"Garrett D'Amore" <garrett@nexenta.com>,
kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH v2] KVM: x86: Prevent exposing TSC deadline timer feature in the absence of in-kernel APIC
Date: Wed, 21 Dec 2011 12:28:29 +0100 [thread overview]
Message-ID: <4EF1C2DD.8070303@siemens.com> (raw)
In-Reply-To: <4EF1B8A4.2050008@redhat.com>
On 2011-12-21 11:44, Avi Kivity wrote:
> On 12/21/2011 12:41 PM, Jan Kiszka wrote:
>> On 2011-12-21 11:35, Avi Kivity wrote:
>>> On 12/21/2011 12:25 PM, Jan Kiszka wrote:
>>>> We must not report the TSC deadline timer feature on our own when user
>>>> space provides the APIC as we have no clue about its features.
>>>
>>> We must not report the TSC deadline timer feature on our own, period.
>>> We should just update the timer mode mask there. Don't know how this
>>> slipped through review.
>>>
>>> I think your original idea was correct. Add a new KVM_CAP for the tsc
>>> deadline timer. Userspace can add the bit to cpuid if either it
>>> implements the feature in a userspace apic, or if it finds the new
>>> capability and uses the kernel apic.
>>
>> Right, we do need some control for user space to keep the feature
>> disabled when migrating from an older host.
>>
>> However, there is also the timer_mode_mask which requires tuning in
>> addition to the cpuid flag.
>>
>
> timer_mode_mask can just be slaved to the bit (as received by
> KVM_SET_CPUID); that's exactly kvm_update_cpuid()'s role.
Like
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 230f713..89b02bf 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -27,7 +27,6 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
{
struct kvm_cpuid_entry2 *best;
struct kvm_lapic *apic = vcpu->arch.apic;
- u32 timer_mode_mask;
best = kvm_find_cpuid_entry(vcpu, 1, 0);
if (!best)
@@ -40,15 +39,12 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
best->ecx |= bit(X86_FEATURE_OSXSAVE);
}
- if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
- best->function == 0x1) {
- best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER);
- timer_mode_mask = 3 << 17;
- } else
- timer_mode_mask = 1 << 17;
-
- if (apic)
- apic->lapic_timer.timer_mode_mask = timer_mode_mask;
+ 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;
+ }
kvm_pmu_cpuid_update(vcpu);
}
+ the KVM_CAP thing?
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Alexey Zaytsev <alexey.zaytsev@gmail.com>,
"Liu, Jinsong" <jinsong.liu@intel.com>,
Kernel development list <linux-kernel@vger.kernel.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
"Garrett D'Amore" <garrett@nexenta.com>,
kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH v2] KVM: x86: Prevent exposing TSC deadline timer feature in the absence of in-kernel APIC
Date: Wed, 21 Dec 2011 12:28:29 +0100 [thread overview]
Message-ID: <4EF1C2DD.8070303@siemens.com> (raw)
In-Reply-To: <4EF1B8A4.2050008@redhat.com>
On 2011-12-21 11:44, Avi Kivity wrote:
> On 12/21/2011 12:41 PM, Jan Kiszka wrote:
>> On 2011-12-21 11:35, Avi Kivity wrote:
>>> On 12/21/2011 12:25 PM, Jan Kiszka wrote:
>>>> We must not report the TSC deadline timer feature on our own when user
>>>> space provides the APIC as we have no clue about its features.
>>>
>>> We must not report the TSC deadline timer feature on our own, period.
>>> We should just update the timer mode mask there. Don't know how this
>>> slipped through review.
>>>
>>> I think your original idea was correct. Add a new KVM_CAP for the tsc
>>> deadline timer. Userspace can add the bit to cpuid if either it
>>> implements the feature in a userspace apic, or if it finds the new
>>> capability and uses the kernel apic.
>>
>> Right, we do need some control for user space to keep the feature
>> disabled when migrating from an older host.
>>
>> However, there is also the timer_mode_mask which requires tuning in
>> addition to the cpuid flag.
>>
>
> timer_mode_mask can just be slaved to the bit (as received by
> KVM_SET_CPUID); that's exactly kvm_update_cpuid()'s role.
Like
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 230f713..89b02bf 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -27,7 +27,6 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
{
struct kvm_cpuid_entry2 *best;
struct kvm_lapic *apic = vcpu->arch.apic;
- u32 timer_mode_mask;
best = kvm_find_cpuid_entry(vcpu, 1, 0);
if (!best)
@@ -40,15 +39,12 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
best->ecx |= bit(X86_FEATURE_OSXSAVE);
}
- if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
- best->function == 0x1) {
- best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER);
- timer_mode_mask = 3 << 17;
- } else
- timer_mode_mask = 1 << 17;
-
- if (apic)
- apic->lapic_timer.timer_mode_mask = timer_mode_mask;
+ 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;
+ }
kvm_pmu_cpuid_update(vcpu);
}
+ the KVM_CAP thing?
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2011-12-21 11:28 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 0:32 [Regression, bisected] a3e06bbe8445f57eb949e6474c5a9b30f24d2057: KVM: emulate lapic tsc deadline timer for guest" Alexey Zaytsev
2011-12-12 6:13 ` Liu, Jinsong
2011-12-14 9:37 ` Alexey Zaytsev
2011-12-20 8:43 ` Alexey Zaytsev
2011-12-20 8:53 ` Liu, Jinsong
2011-12-20 8:58 ` Alexey Zaytsev
2011-12-20 9:26 ` Liu, Jinsong
2011-12-20 9:48 ` Avi Kivity
2011-12-20 9:51 ` Alexey Zaytsev
2011-12-20 18:58 ` Linus Torvalds
2011-12-20 19:21 ` Liu, Jinsong
2011-12-20 19:47 ` Alexey Zaytsev
2011-12-20 20:19 ` Liu, Jinsong
2011-12-20 20:22 ` Alexey Zaytsev
2011-12-20 20:26 ` Liu, Jinsong
2011-12-20 20:36 ` Alexey Zaytsev
2011-12-20 20:44 ` Liu, Jinsong
2011-12-21 9:18 ` Avi Kivity
2011-12-20 23:04 ` Jan Kiszka
2011-12-21 10:10 ` [PATCH] KVM: x86: Prevent exposing TSC deadline timer feature in the absence of in-kernel APIC Jan Kiszka
2011-12-21 10:25 ` [PATCH v2] " Jan Kiszka
2011-12-21 10:35 ` Avi Kivity
2011-12-21 10:41 ` Jan Kiszka
2011-12-21 10:44 ` Avi Kivity
2011-12-21 11:28 ` Jan Kiszka [this message]
2011-12-21 11:28 ` Jan Kiszka
2011-12-21 11:45 ` Avi Kivity
2011-12-21 11:45 ` Avi Kivity
2011-12-21 11:58 ` Jan Kiszka
2011-12-21 11:58 ` Jan Kiszka
2011-12-21 12:02 ` Avi Kivity
2011-12-21 12:02 ` Avi Kivity
2011-12-22 15:41 ` Liu, Jinsong
2011-12-25 12:37 ` Avi Kivity
2011-12-25 12:37 ` Avi Kivity
2011-12-26 8:11 ` Liu, Jinsong
2011-12-26 11:35 ` Avi Kivity
2011-12-26 11:35 ` Avi Kivity
2011-12-26 14:23 ` Liu, Jinsong
2011-12-21 10:41 ` Alexey Zaytsev
2011-12-20 19:05 ` [Regression, bisected] a3e06bbe8445f57eb949e6474c5a9b30f24d2057: KVM: emulate lapic tsc deadline timer for guest" Liu, Jinsong
2011-12-21 9:20 ` 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=4EF1C2DD.8070303@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=alexey.zaytsev@gmail.com \
--cc=avi@redhat.com \
--cc=garrett@nexenta.com \
--cc=jinsong.liu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=torvalds@linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.