Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp469326ybm; Mon, 20 May 2019 20:38:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqypaCYRGrIlnbc2RdwDG2WVxGCGrKTdA4gtGUO2QgvQnofEQckbhoXDdfSP688VMxcvTLU9 X-Received: by 2002:a63:2260:: with SMTP id t32mr41549837pgm.222.1558409925324; Mon, 20 May 2019 20:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558409925; cv=none; d=google.com; s=arc-20160816; b=eaj2tUKVpDaF3Bq/YkfIIV/kUHc6csaEoorW9SHoBaqCI7YZ9+Gdj4dJhbrlY8Iiie 7UpX/VkxFmOzHreqlhX8uBRY/nTLgQwfoPe+loDE3bQs1Y3qr14YgKfZnbZfgLzTqbVT Y9hIPjIMq+3EbWriDUHjc36MHTybSTja5rdGztMZ41qa+6qE0j3oN4S2tIFp4baPnzn5 s0bkBHKCkt8LSRuQ/M5XYSyYbk4Wczj24MwI8yA69b3yMpuKCNiVWqok0QDd0TQ0bvDq FyFhtfQ+4Ap26LU+v2kd0AtXEZdeHWCFlwr891zl9h1yvDjqj9Qwz68uifWZUhup0tWf UdXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ZUGMuj/Q0LcrzjGzFgw97KeT+sFqZryhdZX7du4Ws2c=; b=e7DjU628ILBPvFAHhgUTH4hMEnGVD7W80r/iJEdEAmiFaUQfV/eCdkymaL+bziSlNI G7db+PUp0GjBxHLJCiNdZUo0w3Ug+T8qdXwD6y3rK2GUJ6L0rS8rEXinujGJYCDmr9G3 vL1ZdqVNL3E2np5W4mkvkk50v2eGLg0cVv8BK67rAkATfYQB6rK8jCnfrqZF5QrdPGRi zgH04jZIsSyZ1m0IhLLby4SIodChQ0ddpkuXUWZJs8XEBkDAiFk6Y2Tc4rKsKTIUWiAI vf4udkZT3eM61T9UDHgR0a4iVMBqDhWhWijKJKshALZEGLq1mX1aarJuR88z71YbUhRP Bp8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si20920629plm.427.2019.05.20.20.38.30; Mon, 20 May 2019 20:38:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727559AbfEUDhV (ORCPT + 99 others); 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) > { >