From f13905571c09b77febc9638f47be1633b6eeb098 Mon Sep 17 00:00:00 2001
Message-Id: <f13905571c09b77febc9638f47be1633b6eeb098.1351793582.git.minovotn@redhat.com>
In-Reply-To: <e74f21f4030b33aaac45cab138ecabe18aac615b.1351793582.git.minovotn@redhat.com>
References: <e74f21f4030b33aaac45cab138ecabe18aac615b.1351793582.git.minovotn@redhat.com>
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Thu, 25 Oct 2012 19:28:18 +0200
Subject: [PATCH 5/8] i386: kvm: x2apic is not supported without in-kernel
 irqchip

RH-Author: Eduardo Habkost <ehabkost@redhat.com>
Message-id: <1351193301-31675-6-git-send-email-ehabkost@redhat.com>
Patchwork-id: 43651
O-Subject: [RHEL6.4 qemu-kvm PATCH 5/8] i386: kvm: x2apic is not supported without in-kernel irqchip
Bugzilla: 691638
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>

Bugzilla: 691638
Upstream status: equivalent patch submitted
 Message-Id: <1349383747-19383-11-git-send-email-ehabkost@redhat.com>

This is necessary so that x2apic is not improperly enabled when the
in-kernel irqchip is disabled.

This will also make the -cpu check/enforce options more reliable, as the
check_features_against_host() code will detect cases where x2apic can't
be enabled in the host.

[RHEL note: the upstream code is on target-i386/kvm.c, this
 changes the equivalent RHEL-6 code, at qemu-kvm-x86.c]

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu-kvm-x86.c | 7 +++++++
 1 file changed, 7 insertions(+)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qemu-kvm-x86.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index f7f8428..eed3883 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -772,6 +772,13 @@ uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function,
 				kvm_check_extension(kvm_state, KVM_CAP_TSC_DEADLINE_TIMER)) {
 			ret |= CPUID_EXT_TSC_DEADLINE_TIMER;
 		}
+
+		/* x2apic is reported by GET_SUPPORTED_CPUID, but it can't be enabled
+		 * without the in-kernel irqchip
+		 */
+		if (!kvm_irqchip_in_kernel()) {
+			ret &= ~CPUID_EXT_X2APIC;
+		}
 	}
 
 
-- 
1.7.11.7

