All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message
@ 2017-09-05 17:06 Borislav Petkov
  2017-09-06 12:54 ` David Hildenbrand
  2017-09-13 14:06 ` Radim Krčmář
  0 siblings, 2 replies; 7+ messages in thread
From: Borislav Petkov @ 2017-09-05 17:06 UTC (permalink / raw)
  To: KVM
  Cc: LKML, Janakarajan Natarajan, Paolo Bonzini, Radim Krčmář

From: Borislav Petkov <bp@suse.de>

There's no need to issue that everytime during boot - we have the
/proc/cpuinfo flag for people and software to query.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/svm.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 8dbd8dbc83eb..f25e5b930932 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1101,11 +1101,8 @@ static __init int svm_hardware_setup(void)
 	if (vls) {
 		if (!npt_enabled ||
 		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
-		    !IS_ENABLED(CONFIG_X86_64)) {
+		    !IS_ENABLED(CONFIG_X86_64))
 			vls = false;
-		} else {
-			pr_info("Virtual VMLOAD VMSAVE supported\n");
-		}
 	}
 
 	return 0;
-- 
2.13.0

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

* Re: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message
  2017-09-05 17:06 [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message Borislav Petkov
@ 2017-09-06 12:54 ` David Hildenbrand
  2017-09-06 13:17   ` Borislav Petkov
  2017-09-13 14:06 ` Radim Krčmář
  1 sibling, 1 reply; 7+ messages in thread
From: David Hildenbrand @ 2017-09-06 12:54 UTC (permalink / raw)
  To: Borislav Petkov, KVM
  Cc: LKML, Janakarajan Natarajan, Paolo Bonzini, Radim Krčmář

On 05.09.2017 19:06, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> There's no need to issue that everytime during boot - we have the
> /proc/cpuinfo flag for people and software to query.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/svm.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 8dbd8dbc83eb..f25e5b930932 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1101,11 +1101,8 @@ static __init int svm_hardware_setup(void)
>  	if (vls) {
>  		if (!npt_enabled ||
>  		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
> -		    !IS_ENABLED(CONFIG_X86_64)) {
> +		    !IS_ENABLED(CONFIG_X86_64))
>  			vls = false;
> -		} else {
> -			pr_info("Virtual VMLOAD VMSAVE supported\n");
> -		}
>  	}
>  
>  	return 0;
> 

Maybe go one step further and incorporate everything (+vls) into a
single if statement?

-- 

Thanks,

David

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

* Re: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message
  2017-09-06 12:54 ` David Hildenbrand
@ 2017-09-06 13:17   ` Borislav Petkov
  2017-09-06 14:00     ` David Hildenbrand
  0 siblings, 1 reply; 7+ messages in thread
From: Borislav Petkov @ 2017-09-06 13:17 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: KVM, LKML, Janakarajan Natarajan, Paolo Bonzini,
	Radim Krčmář

On Wed, Sep 06, 2017 at 02:54:05PM +0200, David Hildenbrand wrote:
> Maybe go one step further and incorporate everything (+vls) into a
> single if statement?

Or maybe simplify it even more by not even looking at vls. If the user
disables it, fine, if she enables it but the hw doesn't support it, it
will be set to false automatically.

Or am I missing a case?

---
From: Borislav Petkov <bp@suse.de>
Date: Tue, 5 Sep 2017 18:59:55 +0200
Subject: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE
 supported-message
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There's no need to issue that everytime during boot - we have the
/proc/cpuinfo flag for people and software to query.

Also, simplify logic which verifies the vls chicken bit setting.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/svm.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 8dbd8dbc83eb..d3c481778d9c 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1098,15 +1098,10 @@ static __init int svm_hardware_setup(void)
 		}
 	}
 
-	if (vls) {
-		if (!npt_enabled ||
-		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
-		    !IS_ENABLED(CONFIG_X86_64)) {
-			vls = false;
-		} else {
-			pr_info("Virtual VMLOAD VMSAVE supported\n");
-		}
-	}
+	if (!npt_enabled ||
+	    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
+	    !IS_ENABLED(CONFIG_X86_64))
+		vls = false;
 
 	return 0;
 
-- 
2.13.0

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message
  2017-09-06 13:17   ` Borislav Petkov
@ 2017-09-06 14:00     ` David Hildenbrand
  2017-09-06 15:28       ` Borislav Petkov
  0 siblings, 1 reply; 7+ messages in thread
From: David Hildenbrand @ 2017-09-06 14:00 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: KVM, LKML, Janakarajan Natarajan, Paolo Bonzini,
	Radim Krčmář

On 06.09.2017 15:17, Borislav Petkov wrote:
> On Wed, Sep 06, 2017 at 02:54:05PM +0200, David Hildenbrand wrote:
>> Maybe go one step further and incorporate everything (+vls) into a
>> single if statement?
> 
> Or maybe simplify it even more by not even looking at vls. If the user
> disables it, fine, if she enables it but the hw doesn't support it, it
> will be set to false automatically.
> 
> Or am I missing a case?
> 
> ---
> From: Borislav Petkov <bp@suse.de>
> Date: Tue, 5 Sep 2017 18:59:55 +0200
> Subject: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE
>  supported-message
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> There's no need to issue that everytime during boot - we have the
> /proc/cpuinfo flag for people and software to query.
> 
> Also, simplify logic which verifies the vls chicken bit setting.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/svm.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 8dbd8dbc83eb..d3c481778d9c 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1098,15 +1098,10 @@ static __init int svm_hardware_setup(void)
>  		}
>  	}
>  
> -	if (vls) {
> -		if (!npt_enabled ||
> -		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
> -		    !IS_ENABLED(CONFIG_X86_64)) {
> -			vls = false;
> -		} else {
> -			pr_info("Virtual VMLOAD VMSAVE supported\n");
> -		}
> -	}
> +	if (!npt_enabled ||
> +	    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
> +	    !IS_ENABLED(CONFIG_X86_64))
> +		vls = false;
>  
>  	return 0;
>  
> 

had the same idea but was worried about runtime. but  this is really
only executed once, so

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David

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

* Re: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message
  2017-09-06 14:00     ` David Hildenbrand
@ 2017-09-06 15:28       ` Borislav Petkov
  0 siblings, 0 replies; 7+ messages in thread
From: Borislav Petkov @ 2017-09-06 15:28 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: KVM, LKML, Janakarajan Natarajan, Paolo Bonzini,
	Radim Krčmář

On Wed, Sep 06, 2017 at 04:00:04PM +0200, David Hildenbrand wrote:
> had the same idea but was worried about runtime. but this is really
> only executed once, so

Yap, exactly. Forgot to say ... but I was thinking of saying it. :)

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message
  2017-09-05 17:06 [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message Borislav Petkov
  2017-09-06 12:54 ` David Hildenbrand
@ 2017-09-13 14:06 ` Radim Krčmář
  2017-09-13 21:31   ` Paolo Bonzini
  1 sibling, 1 reply; 7+ messages in thread
From: Radim Krčmář @ 2017-09-13 14:06 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: KVM, LKML, Janakarajan Natarajan, Paolo Bonzini

2017-09-05 19:06+0200, Borislav Petkov:
> From: Borislav Petkov <bp@suse.de>
> 
> There's no need to issue that everytime during boot - we have the
> /proc/cpuinfo flag for people and software to query.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/svm.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 8dbd8dbc83eb..f25e5b930932 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1101,11 +1101,8 @@ static __init int svm_hardware_setup(void)
>  	if (vls) {
>  		if (!npt_enabled ||
>  		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
> -		    !IS_ENABLED(CONFIG_X86_64)) {
> +		    !IS_ENABLED(CONFIG_X86_64))
>  			vls = false;
> -		} else {
> -			pr_info("Virtual VMLOAD VMSAVE supported\n");

SVM prints more offending messages on boot, so I'd do all one go.
I am thinking of collocating the info instead as the information might
prevent one round of asking for SVM features.
---8<---
Subject: [PATCH] KVM: SVM: print enabled features on one line

The information might be useful for debugging, but having each feature
present itself is needlessly verbose.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/svm.c | 56 ++++++++++++++++++------------------------------------
 1 file changed, 19 insertions(+), 37 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index af54327b9017..1901815777d0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1078,10 +1078,8 @@ static __init int svm_hardware_setup(void)
 		kvm_tsc_scaling_ratio_frac_bits = 32;
 	}
 
-	if (nested) {
-		printk(KERN_INFO "kvm: Nested Virtualization enabled\n");
+	if (nested)
 		kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE);
-	}
 
 	for_each_possible_cpu(cpu) {
 		r = svm_cpu_init(cpu);
@@ -1089,48 +1087,32 @@ static __init int svm_hardware_setup(void)
 			goto err;
 	}
 
-	if (!boot_cpu_has(X86_FEATURE_NPT))
-		npt_enabled = false;
-
-	if (npt_enabled && !npt) {
-		printk(KERN_INFO "kvm: Nested Paging disabled\n");
+	if (!boot_cpu_has(X86_FEATURE_NPT) || !npt)
 		npt_enabled = false;
-	}
 
-	if (npt_enabled) {
-		printk(KERN_INFO "kvm: Nested Paging enabled\n");
+	if (npt_enabled)
 		kvm_enable_tdp();
-	} else
+	else
 		kvm_disable_tdp();
 
-	if (avic) {
-		if (!npt_enabled ||
-		    !boot_cpu_has(X86_FEATURE_AVIC) ||
-		    !IS_ENABLED(CONFIG_X86_LOCAL_APIC)) {
-			avic = false;
-		} else {
-			pr_info("AVIC enabled\n");
+	if (!npt_enabled ||
+	    !boot_cpu_has(X86_FEATURE_AVIC) ||
+	    !IS_ENABLED(CONFIG_X86_LOCAL_APIC))
+		avic = false;
 
-			amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier);
-		}
-	}
+	if (avic)
+		amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier);
 
-	if (vls) {
-		if (!npt_enabled ||
-		    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
-		    !IS_ENABLED(CONFIG_X86_64)) {
-			vls = false;
-		} else {
-			pr_info("Virtual VMLOAD VMSAVE supported\n");
-		}
-	}
+	if (!npt_enabled ||
+	    !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
+	    !IS_ENABLED(CONFIG_X86_64))
+		vls = false;
 
-	if (vgif) {
-		if (!boot_cpu_has(X86_FEATURE_VGIF))
-			vgif = false;
-		else
-			pr_info("Virtual GIF supported\n");
-	}
+	if (!boot_cpu_has(X86_FEATURE_VGIF))
+		vgif = false;
+
+	pr_info("SVM nested=%d npt=%d avic=%d vls=%d vgif=%d\n",
+			nested, npt_enabled, avic, vls, vgif);
 
 	return 0;
 
-- 
2.14.1

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

* Re: [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message
  2017-09-13 14:06 ` Radim Krčmář
@ 2017-09-13 21:31   ` Paolo Bonzini
  0 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2017-09-13 21:31 UTC (permalink / raw)
  To: Radim Krčmář, Borislav Petkov
  Cc: KVM, LKML, Janakarajan Natarajan

On 13/09/2017 16:06, Radim Krčmář wrote:
> -	}
> +	if (!boot_cpu_has(X86_FEATURE_VGIF))
> +		vgif = false;
> +
> +	pr_info("SVM nested=%d npt=%d avic=%d vls=%d vgif=%d\n",
> +			nested, npt_enabled, avic, vls, vgif);

 I doubt we'd get the above info message more than sporadically, and all
these are available with a simple

grep -r . /sys/module/kvm_amd/parameters

which we already do routinely ask bug reporters for the equivalent
kvm_intel.  So I'd say, zap it.

Paolo

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

end of thread, other threads:[~2017-09-13 21:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 17:06 [PATCH] KVM: SVM: Do not issue virtual VMLOAD/VMSAVE supported-message Borislav Petkov
2017-09-06 12:54 ` David Hildenbrand
2017-09-06 13:17   ` Borislav Petkov
2017-09-06 14:00     ` David Hildenbrand
2017-09-06 15:28       ` Borislav Petkov
2017-09-13 14:06 ` Radim Krčmář
2017-09-13 21:31   ` 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.