Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5610298ybi; Tue, 4 Jun 2019 09:11:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjCf2Ey/AyScECzK+PpSxEVoddoIpIQ7M2ve5nPHK7O8rn80aXrnfw/NLJ2imhYCv4Yt/e X-Received: by 2002:a17:902:3341:: with SMTP id a59mr9279123plc.186.1559664667096; Tue, 04 Jun 2019 09:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559664667; cv=none; d=google.com; s=arc-20160816; b=Hc9VrbEaRYYM9yNYQo6Mj2vnQ3jp5BJqjTgA1813Kubgz+9GLAtIRcWwcXuLQL7tEH GiEULkmJoXv7XGOAUpBapCVGWkmEozjAXnHgKnHA5FhUWNpvdy9aw9AQBvjWIHzXu1De 8NCcKATCvK/7+CcsI2rSbpyYCTLe1OOcyKnZODdvUVzdi+FpJCvDebTFpeQHE1YyVT9g nBKeOUTzhIGiyBcGu3mxmomHXNgcqlok3A/I2NK7fle1xrUp//IUmyfdIQq3GDxZAqXq HtXqRjlMOUC44rG01BbW2Kd3aaJmofnHAozfbF3QE45M6igAF3/gDvxB9dvGjPsvsm3P x1ww== 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=i2GOZSsboUyjyadR02A1xcM2g/DGUFQmrqakyY+cAKw=; b=Se/Ow8jHbFkIo2VznS4SmROcFIILpSzFnu5zZ9C93DVogMNTmhpTrWtwwX8GS282OE betPcAlcMhB9y6sOPbRdvsBVri8eXhGx+gLMpxCkaAWzGX9CytKqPjEt1tTWx6m4jYCl i8ay6C/pbw8J9BCNpuJPDfRMGOy5DOnxkJGQUf6sqjc3jbRXQ4GBLUyjTGiBOVhjpgky 93TuDlqqJeDmGiPGHIHewyM9ETSYpZnXYYiKAGvSlQxwtniRRKo1ypHTN3PDdiTsSX7p K69NFse9tcUzLLm7vcCOd+FcpJ9bcJ78euit3TvoFkDURFKIZzAydT0Xo8jgrm46sQ7i bvpQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k65si3611536pje.15.2019.06.04.09.10.49; Tue, 04 Jun 2019 09:11:07 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728308AbfFDQJW (ORCPT + 99 others); Tue, 4 Jun 2019 12:09:22 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40146 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728207AbfFDQJU (ORCPT ); Tue, 4 Jun 2019 12:09:20 -0400 Received: by mail-wm1-f66.google.com with SMTP id u16so642763wmc.5 for ; Tue, 04 Jun 2019 09:09:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=i2GOZSsboUyjyadR02A1xcM2g/DGUFQmrqakyY+cAKw=; b=tp9qQ2YD85/5RLpyg/UALjiayXnapVG2UTFWsG9VS2CK7urxW9Runoluu7Ka0cg6S5 +AzVb9FEMjrPaP8SvTBg3ihauQj4tvLCP0S4f28n8G13wqdibtTlHttJaSIHW3WoU1ba bqEfYLOL9Ur1IipmugIahOfftmR7sdXUqyOtmsRpgP7YmvPlJfcPo5trhgwLSLtagasy 0ERYodU9dFwBSSGcT+jlLddZH6sxWLCk1iMsoNXx6fHxnmIWK1OU0YTqV5njpPpfum9v jBf1aC2wwM+AWP7LYOhmnNIcKUNXq30y546dWT5mVat0fsgkD1KqdTuafWnHjB6QUQFH yIfQ== X-Gm-Message-State: APjAAAUoPmjdCp6OxiV1kijkxKSWqmiSrKwcvJhhYfOxd+hOLnp911Ro fP67NxW3TEEGdlwAitYcDFm0v3z8W+TCAg== X-Received: by 2002:a1c:98d6:: with SMTP id a205mr6467195wme.145.1559664558756; Tue, 04 Jun 2019 09:09:18 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:657f:501:149f:5617? ([2001:b07:6468:f312:657f:501:149f:5617]) by smtp.gmail.com with ESMTPSA id d17sm20007242wrx.9.2019.06.04.09.09.17 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 09:09:17 -0700 (PDT) Subject: Re: [PATCH] kvm: x86: refine kvm_get_arch_capabilities() To: Xiaoyao Li , =?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: Paolo Bonzini Message-ID: <1c653e8d-29d5-3f55-a0a0-c3ee37560650@redhat.com> Date: Tue, 4 Jun 2019 18:09:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; 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 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 On 19/04/19 04:16, 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) > { > Queued, thanks. Paolo