From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC683C04AAC for ; Tue, 21 May 2019 03:37:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9D9621479 for ; Tue, 21 May 2019 03:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727579AbfEUDhV (ORCPT ); Mon, 20 May 2019 23:37:21 -0400 Received: from mga14.intel.com ([192.55.52.115]:26339 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfEUDhV (ORCPT ); Mon, 20 May 2019 23:37:21 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 May 2019 20:37:20 -0700 X-ExtLoop1: 1 Received: from xiaoyaol-mobl.ccr.corp.intel.com (HELO [10.239.13.123]) ([10.239.13.123]) by orsmga006.jf.intel.com with ESMTP; 20 May 2019 20:37:18 -0700 Subject: Re: [PATCH] kvm: x86: refine kvm_get_arch_capabilities() To: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org References: <20190419021624.186106-1-xiaoyao.li@linux.intel.com> From: Xiaoyao Li Message-ID: Date: Tue, 21 May 2019 11:37:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190419021624.186106-1-xiaoyao.li@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ping. On 4/19/2019 10:16 AM, Xiaoyao Li wrote: > 1. Using X86_FEATURE_ARCH_CAPABILITIES to enumerate the existence of > MSR_IA32_ARCH_CAPABILITIES to avoid using rdmsrl_safe(). > > 2. Since kvm_get_arch_capabilities() is only used in this file, making > it static. > > Signed-off-by: Xiaoyao Li > --- > arch/x86/include/asm/kvm_host.h | 1 - > arch/x86/kvm/x86.c | 8 ++++---- > 2 files changed, 4 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index a9d03af34030..d4ae67870764 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1526,7 +1526,6 @@ int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low, > unsigned long ipi_bitmap_high, u32 min, > unsigned long icr, int op_64_bit); > > -u64 kvm_get_arch_capabilities(void); > void kvm_define_shared_msr(unsigned index, u32 msr); > int kvm_set_shared_msr(unsigned index, u64 val, u64 mask); > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index a0d1fc80ac5a..ba8e269a8cd2 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -1205,11 +1205,12 @@ static u32 msr_based_features[] = { > > static unsigned int num_msr_based_features; > > -u64 kvm_get_arch_capabilities(void) > +static u64 kvm_get_arch_capabilities(void) > { > - u64 data; > + u64 data = 0; > > - rdmsrl_safe(MSR_IA32_ARCH_CAPABILITIES, &data); > + if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES)) > + rdmsrl(MSR_IA32_ARCH_CAPABILITIES, data); > > /* > * If we're doing cache flushes (either "always" or "cond") > @@ -1225,7 +1226,6 @@ u64 kvm_get_arch_capabilities(void) > > return data; > } > -EXPORT_SYMBOL_GPL(kvm_get_arch_capabilities); > > static int kvm_get_msr_feature(struct kvm_msr_entry *msr) > { >