[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4EF1B423.8050707@siemens.com>
Date: Wed, 21 Dec 2011 11:25:39 +0100
From: Jan Kiszka <jan.kiszka@...mens.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Alexey Zaytsev <alexey.zaytsev@...il.com>,
"Liu, Jinsong" <jinsong.liu@...el.com>, Avi Kivity <avi@...hat.com>
CC: Kernel development list <linux-kernel@...r.kernel.org>,
Marcelo Tosatti <mtosatti@...hat.com>,
"Garrett D'Amore" <garrett@...enta.com>, kvm <kvm@...r.kernel.org>
Subject: [PATCH v2] KVM: x86: Prevent exposing TSC deadline timer feature
in the absence of in-kernel APIC
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.
Signed-off-by: Jan Kiszka <jan.kiszka@...mens.com>
---
Changes in v2:
- reorganized code to make the flow clearer
arch/x86/kvm/cpuid.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 230f713..b7cdd3b 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,14 @@ 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 (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
+ best->function == 0x1) {
+ 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);
}
--
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists