All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm: x86: refine kvm_get_arch_capabilities()
@ 2019-04-19  2:16 Xiaoyao Li
  2019-05-21  3:37 ` Xiaoyao Li
  2019-06-04 16:09 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Xiaoyao Li @ 2019-04-19  2:16 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář, kvm
  Cc: Xiaoyao Li, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, x86, linux-kernel

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 <xiaoyao.li@linux.intel.com>
---
 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)
 {
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvm: x86: refine kvm_get_arch_capabilities()
  2019-04-19  2:16 [PATCH] kvm: x86: refine kvm_get_arch_capabilities() Xiaoyao Li
@ 2019-05-21  3:37 ` Xiaoyao Li
  2019-06-04 16:09 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Xiaoyao Li @ 2019-05-21  3:37 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář, kvm
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, linux-kernel

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 <xiaoyao.li@linux.intel.com>
> ---
>   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)
>   {
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvm: x86: refine kvm_get_arch_capabilities()
  2019-04-19  2:16 [PATCH] kvm: x86: refine kvm_get_arch_capabilities() Xiaoyao Li
  2019-05-21  3:37 ` Xiaoyao Li
@ 2019-06-04 16:09 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2019-06-04 16:09 UTC (permalink / raw)
  To: Xiaoyao Li, Radim Krčmář, kvm
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, linux-kernel

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 <xiaoyao.li@linux.intel.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-04 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19  2:16 [PATCH] kvm: x86: refine kvm_get_arch_capabilities() Xiaoyao Li
2019-05-21  3:37 ` Xiaoyao Li
2019-06-04 16:09 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.