aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-05-10 06:55:35 -0400
committerAvi Kivity <avi@redhat.com>2009-06-10 04:48:52 -0400
commit7faa4ee1c777a5f8e8373430cfd9cb6172aa3503 (patch)
tree80c65a6319941d280cdafbcbfb67d41713d97d03 /arch/x86/kvm/x86.c
parent8d753f369bd28fff1706ffe9fb9fea4fd88cf85b (diff)
KVM: Add AMD cpuid bit: cr8_legacy, abm, misaligned sse, sse4, 3dnow prefetch
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c71
1 files changed, 38 insertions, 33 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index da3e65bfc6ee..95de3d34b115 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1247,44 +1247,47 @@ static void do_cpuid_1_ent(struct kvm_cpuid_entry2 *entry, u32 function,
1247 entry->flags = 0; 1247 entry->flags = 0;
1248} 1248}
1249 1249
1250#define F(x) bit(X86_FEATURE_##x)
1251
1250static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, 1252static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
1251 u32 index, int *nent, int maxnent) 1253 u32 index, int *nent, int maxnent)
1252{ 1254{
1253 const u32 kvm_supported_word0_x86_features = bit(X86_FEATURE_FPU) | 1255 unsigned f_nx = is_efer_nx() ? F(NX) : 0;
1254 bit(X86_FEATURE_VME) | bit(X86_FEATURE_DE) |
1255 bit(X86_FEATURE_PSE) | bit(X86_FEATURE_TSC) |
1256 bit(X86_FEATURE_MSR) | bit(X86_FEATURE_PAE) |
1257 bit(X86_FEATURE_MCE) |
1258 bit(X86_FEATURE_CX8) | bit(X86_FEATURE_APIC) |
1259 bit(X86_FEATURE_SEP) | bit(X86_FEATURE_MTRR) |
1260 bit(X86_FEATURE_PGE) | bit(X86_FEATURE_MCA) |
1261 bit(X86_FEATURE_CMOV) | bit(X86_FEATURE_PAT) |
1262 bit(X86_FEATURE_PSE36) |
1263 bit(X86_FEATURE_CLFLSH) | bit(X86_FEATURE_MMX) |
1264 bit(X86_FEATURE_FXSR) | bit(X86_FEATURE_XMM) |
1265 bit(X86_FEATURE_XMM2) | bit(X86_FEATURE_SELFSNOOP);
1266 const u32 kvm_supported_word1_x86_features = bit(X86_FEATURE_FPU) |
1267 bit(X86_FEATURE_VME) | bit(X86_FEATURE_DE) |
1268 bit(X86_FEATURE_PSE) | bit(X86_FEATURE_TSC) |
1269 bit(X86_FEATURE_MSR) | bit(X86_FEATURE_PAE) |
1270 bit(X86_FEATURE_CX8) | bit(X86_FEATURE_APIC) |
1271 bit(X86_FEATURE_PGE) |
1272 bit(X86_FEATURE_CMOV) | bit(X86_FEATURE_PSE36) |
1273 bit(X86_FEATURE_MMX) | bit(X86_FEATURE_FXSR) |
1274 bit(X86_FEATURE_SYSCALL) |
1275 (is_efer_nx() ? bit(X86_FEATURE_NX) : 0) |
1276#ifdef CONFIG_X86_64 1256#ifdef CONFIG_X86_64
1277 bit(X86_FEATURE_LM) | 1257 unsigned f_lm = F(LM);
1258#else
1259 unsigned f_lm = 0;
1278#endif 1260#endif
1279 bit(X86_FEATURE_FXSR_OPT) | 1261
1280 bit(X86_FEATURE_MMXEXT) | 1262 /* cpuid 1.edx */
1281 bit(X86_FEATURE_3DNOWEXT) | 1263 const u32 kvm_supported_word0_x86_features =
1282 bit(X86_FEATURE_3DNOW); 1264 F(FPU) | F(VME) | F(DE) | F(PSE) |
1283 const u32 kvm_supported_word3_x86_features = 1265 F(TSC) | F(MSR) | F(PAE) | F(MCE) |
1284 bit(X86_FEATURE_XMM3) | bit(X86_FEATURE_CX16); 1266 F(CX8) | F(APIC) | 0 /* Reserved */ | F(SEP) |
1267 F(MTRR) | F(PGE) | F(MCA) | F(CMOV) |
1268 F(PAT) | F(PSE36) | 0 /* PSN */ | F(CLFLSH) |
1269 0 /* Reserved, DS, ACPI */ | F(MMX) |
1270 F(FXSR) | F(XMM) | F(XMM2) | F(SELFSNOOP) |
1271 0 /* HTT, TM, Reserved, PBE */;
1272 /* cpuid 0x80000001.edx */
1273 const u32 kvm_supported_word1_x86_features =
1274 F(FPU) | F(VME) | F(DE) | F(PSE) |
1275 F(TSC) | F(MSR) | F(PAE) | F(MCE) |
1276 F(CX8) | F(APIC) | 0 /* Reserved */ | F(SYSCALL) |
1277 F(MTRR) | F(PGE) | F(MCA) | F(CMOV) |
1278 F(PAT) | F(PSE36) | 0 /* Reserved */ |
1279 f_nx | 0 /* Reserved */ | F(MMXEXT) | F(MMX) |
1280 F(FXSR) | F(FXSR_OPT) | 0 /* GBPAGES */ | 0 /* RDTSCP */ |
1281 0 /* Reserved */ | f_lm | F(3DNOWEXT) | F(3DNOW);
1282 /* cpuid 1.ecx */
1283 const u32 kvm_supported_word4_x86_features =
1284 F(XMM3) | F(CX16);
1285 /* cpuid 0x80000001.ecx */
1285 const u32 kvm_supported_word6_x86_features = 1286 const u32 kvm_supported_word6_x86_features =
1286 bit(X86_FEATURE_LAHF_LM) | bit(X86_FEATURE_CMP_LEGACY) | 1287 F(LAHF_LM) | F(CMP_LEGACY) | F(SVM) | 0 /* ExtApicSpace */ |
1287 bit(X86_FEATURE_SVM); 1288 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
1289 F(3DNOWPREFETCH) | 0 /* OSVW */ | 0 /* IBS */ | F(SSE5) |
1290 0 /* SKINIT */ | 0 /* WDT */;
1288 1291
1289 /* all calls to cpuid_count() should be made on the same cpu */ 1292 /* all calls to cpuid_count() should be made on the same cpu */
1290 get_cpu(); 1293 get_cpu();
@@ -1297,7 +1300,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
1297 break; 1300 break;
1298 case 1: 1301 case 1:
1299 entry->edx &= kvm_supported_word0_x86_features; 1302 entry->edx &= kvm_supported_word0_x86_features;
1300 entry->ecx &= kvm_supported_word3_x86_features; 1303 entry->ecx &= kvm_supported_word4_x86_features;
1301 break; 1304 break;
1302 /* function 2 entries are STATEFUL. That is, repeated cpuid commands 1305 /* function 2 entries are STATEFUL. That is, repeated cpuid commands
1303 * may return different values. This forces us to get_cpu() before 1306 * may return different values. This forces us to get_cpu() before
@@ -1359,6 +1362,8 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
1359 put_cpu(); 1362 put_cpu();
1360} 1363}
1361 1364
1365#undef F
1366
1362static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, 1367static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
1363 struct kvm_cpuid_entry2 __user *entries) 1368 struct kvm_cpuid_entry2 __user *entries)
1364{ 1369{