From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755634AbbKRLKy (ORCPT ); Wed, 18 Nov 2015 06:10:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53031 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755612AbbKRLKw (ORCPT ); Wed, 18 Nov 2015 06:10:52 -0500 Subject: Re: [RFC PATCH 2/3] kvm: Add accessors for guest CPU's family, model, stepping To: Borislav Petkov , LKML References: <1447497436-26424-1-git-send-email-bp@alien8.de> <1447497436-26424-3-git-send-email-bp@alien8.de> Cc: X86 ML , KVM From: Paolo Bonzini Message-ID: <564C5CAF.4040007@redhat.com> Date: Wed, 18 Nov 2015 12:10:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1447497436-26424-3-git-send-email-bp@alien8.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/11/2015 11:37, Borislav Petkov wrote: > From: Borislav Petkov > > Those give the family, model and stepping of the guest vcpu. > > Signed-off-by: Borislav Petkov > Cc: Paolo Bonzini > --- > 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 06332cb7e7d1..5d47e0d95ef1 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 > Reviewed-by: Paolo Bonzini