[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/24] target-i386: warns users when CPU threads>1 fo
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 15/24] target-i386: warns users when CPU threads>1 for non-Intel CPUs |
Date: |
Thu, 23 Oct 2014 15:34:03 +0200 |
From: Wei Huang <address@hidden>
Only Intel CPUs support hyperthreading. When users select threads>1 in
-smp option, QEMU fixes it by adjusting CPUID_0000_0001_EBX and
CPUID_8000_0008_ECX based on inputs (sockets, cores, threads);
so guest VM can boot correctly. However it is still better to gives
users a warning when such case happens.
Signed-off-by: Wei Huang <address@hidden>
[As suggested by Eduardo, check for !IS_INTEL instead of AMD. - Paolo]
Signed-off-by: Paolo Bonzini <address@hidden>
---
target-i386/cpu.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e7bf9de..69a2bd3 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2696,6 +2696,13 @@ static void x86_cpu_apic_realize(X86CPU *cpu, Error
**errp)
}
#endif
+
+#define IS_INTEL_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 && \
+ (env)->cpuid_vendor2 == CPUID_VENDOR_INTEL_2 && \
+ (env)->cpuid_vendor3 == CPUID_VENDOR_INTEL_3)
+#define IS_AMD_CPU(env) ((env)->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && \
+ (env)->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && \
+ (env)->cpuid_vendor3 == CPUID_VENDOR_AMD_3)
static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cs = CPU(dev);
@@ -2703,6 +2710,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error
**errp)
X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
CPUX86State *env = &cpu->env;
Error *local_err = NULL;
+ static bool ht_warned;
if (env->features[FEAT_7_0_EBX] && env->cpuid_level < 7) {
env->cpuid_level = 7;
@@ -2711,9 +2719,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error
**errp)
/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on
* CPUID[1].EDX.
*/
- if (env->cpuid_vendor1 == CPUID_VENDOR_AMD_1 &&
- env->cpuid_vendor2 == CPUID_VENDOR_AMD_2 &&
- env->cpuid_vendor3 == CPUID_VENDOR_AMD_3) {
+ if (IS_AMD_CPU(env)) {
env->features[FEAT_8000_0001_EDX] &= ~CPUID_EXT2_AMD_ALIASES;
env->features[FEAT_8000_0001_EDX] |= (env->features[FEAT_1_EDX]
& CPUID_EXT2_AMD_ALIASES);
@@ -2742,6 +2748,20 @@ static void x86_cpu_realizefn(DeviceState *dev, Error
**errp)
mce_init(cpu);
qemu_init_vcpu(cs);
+ /* Only Intel CPUs support hyperthreading. Even though QEMU fixes this
+ * issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX
+ * based on inputs (sockets,cores,threads), it is still better to gives
+ * users a warning.
+ *
+ * NOTE: the following code has to follow qemu_init_vcpu(). Otherwise
+ * cs->nr_threads hasn't be populated yet and the checking is incorrect.
+ */
+ if (!IS_INTEL_CPU(env) && cs->nr_threads > 1 && !ht_warned) {
+ error_report("AMD CPU doesn't support hyperthreading. Please configure"
+ " -smp options properly.");
+ ht_warned = true;
+ }
+
x86_cpu_apic_realize(cpu, &local_err);
if (local_err != NULL) {
goto out;
--
1.8.3.1
- [Qemu-devel] [PULL 04/24] virtio-scsi: dataplane: stop trying on notifier error, (continued)
- [Qemu-devel] [PULL 04/24] virtio-scsi: dataplane: stop trying on notifier error, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 11/24] qdev: gpio: delete NamedGPIOList::out, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 12/24] qdev: gpio: Remove qdev_init_gpio_out x1 restriction, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 13/24] qdev: gpio: Define qdev_pass_gpios(), Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 14/24] sysbus: Use TYPE_DEVICE GPIO functionality, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 16/24] MAINTAINERS: grab more files from Anthony's pile, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 17/24] MAINTAINERS: add Samuel Thibault as usb-serial.c and baum.c maintainer, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 18/24] MAINTAINERS: add myself for X86, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 19/24] MAINTAINERS: Add more TCG files, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 20/24] MAINTAINERS: add some tests directories, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 15/24] target-i386: warns users when CPU threads>1 for non-Intel CPUs,
Paolo Bonzini <=
- [Qemu-devel] [PULL 22/24] qtest: fix qtest log fd should be initialized before qtest chardev, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 21/24] MAINTAINERS: avoid M entries that point to mailing lists, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 24/24] get_maintainer.pl: restrict cases where it falls back to --git, Paolo Bonzini, 2014/10/23
- [Qemu-devel] [PULL 23/24] get_maintainer.pl: move git loop under "if ($email) {", Paolo Bonzini, 2014/10/23
- Re: [Qemu-devel] [PULL 00/24] SCSI, maintainers and more - 2014-10-17, Peter Maydell, 2014/10/23