From patchwork Thu Apr 14 03:59:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BrillyWu@viatech.com.cn X-Patchwork-Id: 706161 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3E3xeZW008395 for ; Thu, 14 Apr 2011 03:59:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751519Ab1DND71 (ORCPT ); Wed, 13 Apr 2011 23:59:27 -0400 Received: from exchtp08.via.com.tw ([61.66.243.7]:60681 "EHLO exchtp08.via.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751409Ab1DND70 convert rfc822-to-8bit (ORCPT ); Wed, 13 Apr 2011 23:59:26 -0400 Received: from mailtp.via.com.tw ([10.5.254.18]) by exchtp08.via.com.tw with Microsoft SMTPSVC(6.0.3790.4675); Thu, 14 Apr 2011 11:59:25 +0800 Received: from exchsg04.s3graphics.com ([10.3.254.212]) by mailtp.via.com.tw with Microsoft SMTPSVC(6.0.3790.4675); Thu, 14 Apr 2011 11:59:24 +0800 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: [PATCH v2] KVM: Add CPUID support for VIA CPU X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Thu, 14 Apr 2011 11:59:22 +0800 Message-ID: In-Reply-To: <4DA589DF.8060002@redhat.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v2] KVM: Add CPUID support for VIA CPU Thread-Index: Acv5zohzNxMq+5FOQ2CDYVdDcGoeyQAgwYKw References: <4DA565D8.8050504@redhat.com> <4DA589DF.8060002@redhat.com> From: To: , Cc: X-OriginalArrivalTime: 14 Apr 2011 03:59:24.0958 (UTC) FILETIME=[57EFA3E0:01CBFA58] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 14 Apr 2011 03:59:41 +0000 (UTC) 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 Signed-off-by: KaryJin --- arch/x86/kvm/x86.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/arch/x86/kvm/x86.c 2011-04-12 10:16:07.713785938 +0800 +++ b/arch/x86/kvm/x86.c 2011-04-14 11:23:34.673820989 +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); @@ -2486,6 +2506,26 @@ static int kvm_dev_ioctl_get_supported_c if (nent >= cpuid->nent) goto out_free; + /* Add support for Centaur's CPUID instruction. */ + if (boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR) { + do_cpuid_ent(&cpuid_entries[nent], 0xC0000000, 0, + &nent, cpuid->nent); + + r = -E2BIG; + if (nent >= cpuid->nent) + goto out_free; + + 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, cpuid->nent); -- To unsubscribe from this list: send the line "unsubscribe kvm" in