From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 14/47] target-i386: add feature flags for CPUID[EAX=0xd, ECX=1]
Date: Mon, 15 Dec 2014 17:37:58 +0100 [thread overview]
Message-ID: <1418661511-22348-15-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1418661511-22348-1-git-send-email-pbonzini@redhat.com>
These represent xsave-related capabilities of the processor, and KVM may
or may not support them.
Add feature bits so that they are considered by "-cpu ...,enforce", and use
the new feature work instead of calling kvm_arch_get_supported_cpuid.
Bit 3 (XSAVES) is not migratables because it requires saving MSR_IA32_XSS.
Neither KVM nor any commonly available hardware supports it anyway.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target-i386/cpu.c | 29 ++++++++++++++++++++++++++++-
target-i386/cpu.h | 6 ++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e9df33e..cf4cf01 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -274,6 +274,17 @@ static const char *cpuid_apm_edx_feature_name[] = {
NULL, NULL, NULL, NULL,
};
+static const char *cpuid_xsave_feature_name[] = {
+ "xsaveopt", "xsavec", "xgetbv1", "xsaves",
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+};
+
#define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
#define PENTIUM_FEATURES (I486_FEATURES | CPUID_DE | CPUID_TSC | \
CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_MMX | CPUID_APIC)
@@ -391,6 +402,14 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
.tcg_features = TCG_APM_FEATURES,
.unmigratable_flags = CPUID_APM_INVTSC,
},
+ [FEAT_XSAVE] = {
+ .feat_names = cpuid_xsave_feature_name,
+ .cpuid_eax = 0xd,
+ .cpuid_needs_ecx = true, .cpuid_ecx = 1,
+ .cpuid_reg = R_EAX,
+ .tcg_features = 0,
+ .unmigratable_flags = FEAT_XSAVES,
+ },
};
typedef struct X86RegisterInfo32 {
@@ -1018,6 +1037,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_EXT2_SYSCALL,
.features[FEAT_8000_0001_ECX] =
CPUID_EXT3_LAHF_LM,
+ .features[FEAT_XSAVE] =
+ CPUID_XSAVE_XSAVEOPT,
.xlevel = 0x8000000A,
.model_id = "Intel Xeon E312xx (Sandy Bridge)",
},
@@ -1051,6 +1072,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP |
CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID |
CPUID_7_0_EBX_RTM,
+ .features[FEAT_XSAVE] =
+ CPUID_XSAVE_XSAVEOPT,
.xlevel = 0x8000000A,
.model_id = "Intel Core Processor (Haswell)",
},
@@ -1085,6 +1108,8 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCID |
CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX |
CPUID_7_0_EBX_SMAP,
+ .features[FEAT_XSAVE] =
+ CPUID_XSAVE_XSAVEOPT,
.xlevel = 0x8000000A,
.model_id = "Intel Core Processor (Broadwell)",
},
@@ -1202,6 +1227,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE |
CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | CPUID_EXT3_SVM |
CPUID_EXT3_LAHF_LM,
+ /* no xsaveopt! */
.xlevel = 0x8000001A,
.model_id = "AMD Opteron 62xx class CPU",
},
@@ -1236,6 +1262,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_MISALIGNSSE |
CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | CPUID_EXT3_SVM |
CPUID_EXT3_LAHF_LM,
+ /* no xsaveopt! */
.xlevel = 0x8000001A,
.model_id = "AMD Opteron 63xx class CPU",
},
@@ -2377,7 +2404,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
*eax |= kvm_mask & (XSTATE_FP | XSTATE_SSE);
*ebx = *ecx;
} else if (count == 1) {
- *eax = kvm_arch_get_supported_cpuid(s, 0xd, 1, R_EAX);
+ *eax = env->features[FEAT_XSAVE];
} else if (count < ARRAY_SIZE(ext_save_areas)) {
const ExtSaveArea *esa = &ext_save_areas[count];
if ((env->features[esa->feature] & esa->bits) == esa->bits &&
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 015f5b5..f9d74c7 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -411,6 +411,7 @@ typedef enum FeatureWord {
FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */
FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */
FEAT_SVM, /* CPUID[8000_000A].EDX */
+ FEAT_XSAVE, /* CPUID[EAX=0xd,ECX=1].EAX */
FEATURE_WORDS,
} FeatureWord;
@@ -571,6 +572,11 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
#define CPUID_7_0_EBX_AVX512ER (1U << 27) /* AVX-512 Exponential and Reciprocal */
#define CPUID_7_0_EBX_AVX512CD (1U << 28) /* AVX-512 Conflict Detection */
+#define CPUID_XSAVE_XSAVEOPT (1U << 0)
+#define CPUID_XSAVE_XSAVEC (1U << 1)
+#define CPUID_XSAVE_XGETBV1 (1U << 2)
+#define CPUID_XSAVE_XSAVES (1U << 3)
+
/* CPUID[0x80000007].EDX flags: */
#define CPUID_APM_INVTSC (1U << 8)
--
1.8.3.1
next prev parent reply other threads:[~2014-12-15 16:39 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-15 16:37 [Qemu-devel] [PULL 00/47] Patches for KVM, x86, SCSI, migration fixes (2014-12-15) Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 01/47] Add bootloader name to multiboot implementation Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 02/47] target-i386: simplify AES emulation Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 03/47] KVM_CAP_IRQFD and KVM_CAP_IRQFD_RESAMPLE checks Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 04/47] vfio: use kvm_resamplefds_enabled() Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 05/47] valgrind: avoid false positives in KVM_GET_DIRTY_LOG ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 06/47] valgrind/i386: avoid false positives on KVM_SET_CLOCK ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 07/47] valgrind/i386: avoid false positives on KVM_SET_PIT ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 08/47] valgrind/i386: avoid false positives on KVM_SET_XCRS ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 09/47] valgrind/i386: avoid false positives on KVM_SET_MSRS ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 10/47] valgrind/i386: avoid false positives on KVM_GET_MSRS ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 11/47] valgrind/i386: avoid false positives on KVM_SET_VCPU_EVENTS ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 12/47] valgrind/s390x: avoid false positives on KVM_SET_FPU ioctl Paolo Bonzini
2014-12-15 16:37 ` [Qemu-devel] [PULL 13/47] coverity/s390x: avoid false positive in kvm_irqchip_add_adapter_route Paolo Bonzini
2014-12-15 16:37 ` Paolo Bonzini [this message]
2014-12-15 16:37 ` [Qemu-devel] [PULL 15/47] target-mips: kvm: do not use get_clock() Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 16/47] target-i386: get/set/migrate XSAVES state Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 17/47] x86: Drop superfluous conditionals around g_free() Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 18/47] x86: Fuse g_malloc(); memset() into g_malloc0() Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 19/47] x86: Use g_new() & friends where that makes obvious sense Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 20/47] x86: Drop some superfluous casts from void * Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 21/47] scsi: Drop superfluous conditionals around g_free() Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 22/47] scsi: Fuse g_malloc(); memset() into g_malloc0() Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 23/47] scsi: Use g_new() & friends where that makes obvious sense Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 24/47] scsi-disk: provide maximum transfer length Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 25/47] cpu-exec: fix cpu_exec_nocache Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 26/47] cpu-exec: reset exception_index correctly Paolo Bonzini
2014-12-19 2:19 ` Eduardo Habkost
2014-12-23 6:55 ` Pavel Dovgaluk
[not found] ` <2162.40673694319$1419317788@news.gmane.org>
2014-12-23 8:54 ` Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 27/47] icount: set can_do_io outside TB execution Paolo Bonzini
2014-12-17 8:53 ` Pavel Dovgaluk
2014-12-17 9:19 ` Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 28/47] icount: introduce cpu_get_icount_raw Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 29/47] cpu-exec: invalidate nocache translation if they are interrupted Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 30/47] timer: introduce new QEMU_CLOCK_VIRTUAL_RT clock Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 31/47] cpus: make icount warp behave well with respect to stop/cont Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 32/47] i386: do not cross the pages boundaries in replay mode Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 33/47] pc: add 2.3 machine types Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 34/47] target-i386: add VME to all CPUs Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 35/47] target-i386: add f16c and rdrand to Haswell and Broadwell Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 36/47] target-i386: add Ivy Bridge CPU model Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 37/47] kvm/apic: fix 2.2->2.1 migration Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 38/47] linuxboot: fix loading old kernels Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 39/47] serial: reset thri_pending on IER writes with THRI=0 Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 40/47] serial: clean up THRE/TEMT handling Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 41/47] serial: update LSR on enabling/disabling FIFOs Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 42/47] serial: only resample THR interrupt on rising edge of IER.THRI Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 43/47] sdhci: Set a default frequency clock Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 44/47] sdhci: Remove class "virtual" methods Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 45/47] sdhci: Add "sysbus" to sdhci QOM types and methods Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 46/47] sdhci: Define SDHCI PCI ids Paolo Bonzini
2014-12-15 16:38 ` [Qemu-devel] [PULL 47/47] sdhci: Support SDHCI devices on PCI Paolo Bonzini
2014-12-16 12:33 ` [Qemu-devel] [PULL 00/47] Patches for KVM, x86, SCSI, migration fixes (2014-12-15) Peter Maydell
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=1418661511-22348-15-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 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).