From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752708AbcFIPUE (ORCPT ); Thu, 9 Jun 2016 11:20:04 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35586 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752154AbcFIPUA (ORCPT ); Thu, 9 Jun 2016 11:20:00 -0400 Subject: Re: [PATCH] x86/kvm/svm: Simplify cpu_has_svm() To: Borislav Petkov , LKML References: <1462787586-24151-1-git-send-email-bp@alien8.de> Cc: Joerg Roedel , kvm@vger.kernel.org, x86@kernel.org From: Paolo Bonzini Message-ID: <8c6ff71a-9bd4-73bb-c820-b0c59fc0b02b@redhat.com> Date: Thu, 9 Jun 2016 17:19:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <1462787586-24151-1-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 09/05/2016 11:53, Borislav Petkov wrote: > From: Borislav Petkov > > Use already cached CPUID information instead of querying CPUID again. > > No functionality change. > > Signed-off-by: Borislav Petkov > Cc: Joerg Roedel > Cc: kvm@vger.kernel.org > Cc: x86@kernel.org > --- > arch/x86/include/asm/svm.h | 1 - > arch/x86/include/asm/virtext.h | 8 ++------ > 2 files changed, 2 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h > index 6136d99f537b..41888f51f936 100644 > --- a/arch/x86/include/asm/svm.h > +++ b/arch/x86/include/asm/svm.h > @@ -185,7 +185,6 @@ struct __attribute__ ((__packed__)) vmcb { > struct vmcb_save_area save; > }; > > -#define SVM_CPUID_FEATURE_SHIFT 2 > #define SVM_CPUID_FUNC 0x8000000a > > #define SVM_VM_CR_SVM_DISABLE 4 > diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h > index cce9ee68e335..0116b2ee9e64 100644 > --- a/arch/x86/include/asm/virtext.h > +++ b/arch/x86/include/asm/virtext.h > @@ -83,23 +83,19 @@ static inline void cpu_emergency_vmxoff(void) > */ > static inline int cpu_has_svm(const char **msg) > { > - uint32_t eax, ebx, ecx, edx; > - > if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) { > if (msg) > *msg = "not amd"; > return 0; > } > > - cpuid(0x80000000, &eax, &ebx, &ecx, &edx); > - if (eax < SVM_CPUID_FUNC) { > + if (boot_cpu_data.extended_cpuid_level < SVM_CPUID_FUNC) { > if (msg) > *msg = "can't execute cpuid_8000000a"; > return 0; > } > > - cpuid(0x80000001, &eax, &ebx, &ecx, &edx); > - if (!(ecx & (1 << SVM_CPUID_FEATURE_SHIFT))) { > + if (!boot_cpu_has(X86_FEATURE_SVM)) { > if (msg) > *msg = "svm not available"; > return 0; > Queued, thanks. Paolo