public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: Add CPUID support for VIA CPU
@ 2011-04-13  3:26 BrillyWu
  2011-04-13  8:59 ` Avi Kivity
  0 siblings, 1 reply; 14+ messages in thread
From: BrillyWu @ 2011-04-13  3:26 UTC (permalink / raw)
  To: avi, mtosatti; +Cc: kvm

The CPUIDs for Centaur are added, and then  the features of PadLock
hardware
engine on VIA CPU, such as "ace", "ace_en" and so on, can be passed into
the 
kvm guest.

Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
---
 arch/x86/kvm/x86.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

--- a/arch/x86/kvm/x86.c	2011-04-12 10:16:07.713785938 +0800
+++ b/arch/x86/kvm/x86.c	2011-04-12 10:16:49.903786870 +0800
@@ -2331,6 +2331,12 @@ static void do_cpuid_ent(struct kvm_cpui
 		F(3DNOWPREFETCH) | 0 /* OSVW */ | 0 /* IBS */ | F(XOP) |
 		0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
 
+	/* cpuid 0xC0000001.edx */
+	const u32 kvm_supported_word5_x86_features =
+		F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) |
+		F(ACE2) | F(ACE2_EN) | F(PHE) | F(PHE_EN) |
+		F(PMM) | F(PMM_EN);
+
 	/* all calls to cpuid_count() should be made on the same cpu */
 	get_cpu();
 	do_cpuid_1_ent(entry, function, index);
@@ -2440,6 +2446,20 @@ static void do_cpuid_ent(struct kvm_cpui
 		entry->ecx &= kvm_supported_word6_x86_features;
 		cpuid_mask(&entry->ecx, 6);
 		break;
+	/*Add support for Centaur's CPUID instruction*/
+	case 0xC0000000:
+		/*Just support up to 0xC0000004 now*/
+		entry->eax = min(entry->eax, 0xC0000004);
+		break;
+	case 0xC0000001:
+		entry->edx &= kvm_supported_word5_x86_features;
+		cpuid_mask(&entry->edx, 5);
+		break;
+	case 0xC0000002:
+	case 0xC0000003:
+	case 0xC0000004:
+		/*Now nothing to do, reserved for the future*/
+		break;
 	}
 
 	kvm_x86_ops->set_supported_cpuid(function, entry);
@@ -2484,6 +2504,17 @@ static int kvm_dev_ioctl_get_supported_c
 
 	r = -E2BIG;
 	if (nent >= cpuid->nent)
+		goto out_free;
+
+	/* Add support for Centaur's CPUID instruction. */
+	do_cpuid_ent(&cpuid_entries[nent], 0xC0000000, 0, &nent,
cpuid->nent);
+	limit = cpuid_entries[nent - 1].eax;
+	for (func = 0xC0000001; func <= limit && nent < cpuid->nent;
++func)
+		do_cpuid_ent(&cpuid_entries[nent], func, 0,
+			     &nent, cpuid->nent);
+
+	r = -E2BIG;
+	if (nent >= cpuid->nent)
 		goto out_free;
 
 	do_cpuid_ent(&cpuid_entries[nent], KVM_CPUID_SIGNATURE, 0,
&nent,

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-04-28  1:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13  3:26 [PATCH] KVM: Add CPUID support for VIA CPU BrillyWu
2011-04-13  8:59 ` Avi Kivity
2011-04-13 11:05   ` BrillyWu
2011-04-13 11:32     ` Avi Kivity
2011-04-14  3:14       ` BrillyWu
2011-04-14  7:48         ` Avi Kivity
2011-04-14  9:54           ` BrillyWu
2011-04-14 10:07             ` Avi Kivity
2011-04-21 10:06               ` BrillyWu
2011-04-24  7:18                 ` Avi Kivity
2011-04-25  5:55                   ` BrillyWu
2011-04-27  8:48                     ` Avi Kivity
2011-04-28  1:27                       ` [PATCH] qemu-kvm: " BrillyWu
2011-04-14  3:59       ` [PATCH v2] KVM: " BrillyWu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox