From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753749AbbKXJdu (ORCPT ); Tue, 24 Nov 2015 04:33:50 -0500 Received: from terminus.zytor.com ([198.137.202.10]:55309 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753712AbbKXJds (ORCPT ); Tue, 24 Nov 2015 04:33:48 -0500 Date: Tue, 24 Nov 2015 01:32:49 -0800 From: tip-bot for Borislav Petkov Message-ID: Cc: pbonzini@redhat.com, dvlasenk@redhat.com, brgerst@gmail.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, bp@alien8.de, peterz@infradead.org, hpa@zytor.com, bp@suse.de, tglx@linutronix.de, mingo@kernel.org, luto@amacapital.net Reply-To: brgerst@gmail.com, linux-kernel@vger.kernel.org, pbonzini@redhat.com, dvlasenk@redhat.com, bp@alien8.de, torvalds@linux-foundation.org, peterz@infradead.org, mingo@kernel.org, luto@amacapital.net, hpa@zytor.com, tglx@linutronix.de, bp@suse.de In-Reply-To: <1448273546-2567-3-git-send-email-bp@alien8.de> References: <1448273546-2567-3-git-send-email-bp@alien8.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] kvm: Add accessors for guest CPU's family, model, stepping Git-Commit-ID: 91713faf386be6d7e6556b656436813f8c4ee552 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 91713faf386be6d7e6556b656436813f8c4ee552 Gitweb: http://git.kernel.org/tip/91713faf386be6d7e6556b656436813f8c4ee552 Author: Borislav Petkov AuthorDate: Mon, 23 Nov 2015 11:12:22 +0100 Committer: Ingo Molnar CommitDate: Tue, 24 Nov 2015 09:15:54 +0100 kvm: Add accessors for guest CPU's family, model, stepping Those give the family, model and stepping of the guest vcpu. Signed-off-by: Borislav Petkov Reviewed-by: Paolo Bonzini Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1448273546-2567-3-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kvm/cpuid.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h index 06332cb..5d47e0d 100644 --- a/arch/x86/kvm/cpuid.h +++ b/arch/x86/kvm/cpuid.h @@ -2,6 +2,7 @@ #define ARCH_X86_KVM_CPUID_H #include "x86.h" +#include int kvm_update_cpuid(struct kvm_vcpu *vcpu); struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu, @@ -170,4 +171,37 @@ static inline bool guest_cpuid_has_nrips(struct kvm_vcpu *vcpu) } #undef BIT_NRIPS +static inline int guest_cpuid_family(struct kvm_vcpu *vcpu) +{ + struct kvm_cpuid_entry2 *best; + + best = kvm_find_cpuid_entry(vcpu, 0x1, 0); + if (!best) + return -1; + + return x86_family(best->eax); +} + +static inline int guest_cpuid_model(struct kvm_vcpu *vcpu) +{ + struct kvm_cpuid_entry2 *best; + + best = kvm_find_cpuid_entry(vcpu, 0x1, 0); + if (!best) + return -1; + + return x86_model(best->eax); +} + +static inline int guest_cpuid_stepping(struct kvm_vcpu *vcpu) +{ + struct kvm_cpuid_entry2 *best; + + best = kvm_find_cpuid_entry(vcpu, 0x1, 0); + if (!best) + return -1; + + return x86_stepping(best->eax); +} + #endif