All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM
@ 2020-04-13  7:50 Paolo Bonzini
  2020-04-13 23:30 ` Sean Christopherson
  2020-04-16 13:57 ` Tom Lendacky
  0 siblings, 2 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-04-13  7:50 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: ubizjak

Use svm_sev_enabled() in order to cull all calls to PSP code.  Otherwise,
compilation fails with undefined symbols if the PSP device driver is compiled
as a module and KVM is not.

Reported-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/svm/sev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 0e3fc311d7da..364ffe32139c 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -1117,7 +1117,7 @@ int __init sev_hardware_setup(void)
 	/* Maximum number of encrypted guests supported simultaneously */
 	max_sev_asid = cpuid_ecx(0x8000001F);
 
-	if (!max_sev_asid)
+        if (!svm_sev_enabled())
 		return 1;
 
 	/* Minimum ASID value that should be used for SEV guest */
@@ -1156,6 +1156,9 @@ int __init sev_hardware_setup(void)
 
 void sev_hardware_teardown(void)
 {
+        if (!svm_sev_enabled())
+                return;
+
 	bitmap_free(sev_asid_bitmap);
 	bitmap_free(sev_reclaim_asid_bitmap);
 
-- 
2.18.2


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

* Re: [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM
  2020-04-13  7:50 [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM Paolo Bonzini
@ 2020-04-13 23:30 ` Sean Christopherson
  2020-04-16 13:57 ` Tom Lendacky
  1 sibling, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2020-04-13 23:30 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm, ubizjak

On Mon, Apr 13, 2020 at 03:50:31AM -0400, Paolo Bonzini wrote:
> Use svm_sev_enabled() in order to cull all calls to PSP code.  Otherwise,
> compilation fails with undefined symbols if the PSP device driver is compiled
> as a module and KVM is not.
> 
> Reported-by: Uros Bizjak <ubizjak@gmail.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/svm/sev.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 0e3fc311d7da..364ffe32139c 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1117,7 +1117,7 @@ int __init sev_hardware_setup(void)
>  	/* Maximum number of encrypted guests supported simultaneously */
>  	max_sev_asid = cpuid_ecx(0x8000001F);
>  
> -	if (!max_sev_asid)
> +        if (!svm_sev_enabled())
>  		return 1;
>  
>  	/* Minimum ASID value that should be used for SEV guest */
> @@ -1156,6 +1156,9 @@ int __init sev_hardware_setup(void)
>  
>  void sev_hardware_teardown(void)
>  {
> +        if (!svm_sev_enabled())
> +                return;
> +

Tabs instead of spaces.  Checkpatch also whinges about going past 75 chars
in the changelog.

>  	bitmap_free(sev_asid_bitmap);
>  	bitmap_free(sev_reclaim_asid_bitmap);
>  
> -- 
> 2.18.2
> 

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

* Re: [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM
  2020-04-13  7:50 [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM Paolo Bonzini
  2020-04-13 23:30 ` Sean Christopherson
@ 2020-04-16 13:57 ` Tom Lendacky
  2020-04-16 14:14   ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Lendacky @ 2020-04-16 13:57 UTC (permalink / raw)
  To: Paolo Bonzini, linux-kernel, kvm; +Cc: ubizjak

On 4/13/20 2:50 AM, Paolo Bonzini wrote:
> Use svm_sev_enabled() in order to cull all calls to PSP code.  Otherwise,
> compilation fails with undefined symbols if the PSP device driver is compiled
> as a module and KVM is not.

The Kconfig support will set CONFIG_KVM_AMD_SEV to "n" in this situation, 
so it might be worth seeing if sev.o could be removed from the build at 
that point. I'll try and look at that when I get a chance, but I'm 
currently buried with a ton of other work.

> 
> Reported-by: Uros Bizjak <ubizjak@gmail.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   arch/x86/kvm/svm/sev.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 0e3fc311d7da..364ffe32139c 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1117,7 +1117,7 @@ int __init sev_hardware_setup(void)
>   	/* Maximum number of encrypted guests supported simultaneously */
>   	max_sev_asid = cpuid_ecx(0x8000001F);
>   
> -	if (!max_sev_asid)
> +        if (!svm_sev_enabled())

It looks like these are spaces instead of tabs, could just be my email 
veiwer, though.

>   		return 1;
>   
>   	/* Minimum ASID value that should be used for SEV guest */
> @@ -1156,6 +1156,9 @@ int __init sev_hardware_setup(void)
>   
>   void sev_hardware_teardown(void)
>   {
> +        if (!svm_sev_enabled())
> +                return;
> +

Ditto on the spaces/tabs thing, here.

Thanks,
Tom

>   	bitmap_free(sev_asid_bitmap);
>   	bitmap_free(sev_reclaim_asid_bitmap);
>   
> 

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

* Re: [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM
  2020-04-16 13:57 ` Tom Lendacky
@ 2020-04-16 14:14   ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-04-16 14:14 UTC (permalink / raw)
  To: Tom Lendacky, linux-kernel, kvm; +Cc: ubizjak

On 16/04/20 15:57, Tom Lendacky wrote:
> On 4/13/20 2:50 AM, Paolo Bonzini wrote:
>> Use svm_sev_enabled() in order to cull all calls to PSP code.  Otherwise,
>> compilation fails with undefined symbols if the PSP device driver is
>> compiled
>> as a module and KVM is not.
> 
> The Kconfig support will set CONFIG_KVM_AMD_SEV to "n" in this
> situation, so it might be worth seeing if sev.o could be removed from
> the build at that point. I'll try and look at that when I get a chance,
> but I'm currently buried with a ton of other work.

It could be made to work, but you would have to add stubs to sev.h.

Paolo


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

end of thread, other threads:[~2020-04-16 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13  7:50 [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM Paolo Bonzini
2020-04-13 23:30 ` Sean Christopherson
2020-04-16 13:57 ` Tom Lendacky
2020-04-16 14:14   ` 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.