diff mbox series

[2/3] KVM: PPC: Book3S HV: Delay setting of kvm ops

Message ID 20211223211931.3560887-3-farosas@linux.ibm.com
State New
Headers show
Series KVM: PPC: KVM module exit fixes | expand

Commit Message

Fabiano Rosas Dec. 23, 2021, 9:19 p.m. UTC
Delay the setting of kvm_hv_ops until after all init code has
completed. This avoids leaving the ops still accessible if the init
fails.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
---
 arch/powerpc/kvm/book3s_hv.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Nicholas Piggin Dec. 25, 2021, 10:19 a.m. UTC | #1
Excerpts from Fabiano Rosas's message of December 24, 2021 7:19 am:
> Delay the setting of kvm_hv_ops until after all init code has
> completed. This avoids leaving the ops still accessible if the init
> fails.
> 
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>

Also looks okay to me but KVM init has lots of details. IIRC Alexey may 
have run into a related issue with ops being set too early (or was it 
cleared too late?)

Thanks,
Nick

> ---
>  arch/powerpc/kvm/book3s_hv.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 9f4765951733..53400932f5d8 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -6087,9 +6087,6 @@ static int kvmppc_book3s_init_hv(void)
>  	}
>  #endif
>  
> -	kvm_ops_hv.owner = THIS_MODULE;
> -	kvmppc_hv_ops = &kvm_ops_hv;
> -
>  	init_default_hcalls();
>  
>  	init_vcore_lists();
> @@ -6105,10 +6102,15 @@ static int kvmppc_book3s_init_hv(void)
>  	}
>  
>  	r = kvmppc_uvmem_init();
> -	if (r < 0)
> +	if (r < 0) {
>  		pr_err("KVM-HV: kvmppc_uvmem_init failed %d\n", r);
> +		return r;
> +	}
>  
> -	return r;
> +	kvm_ops_hv.owner = THIS_MODULE;
> +	kvmppc_hv_ops = &kvm_ops_hv;
> +
> +	return 0;
>  }
>  
>  static void kvmppc_book3s_exit_hv(void)
> -- 
> 2.33.1
> 
>
Fabiano Rosas Jan. 11, 2022, 2:43 p.m. UTC | #2
Nicholas Piggin <npiggin@gmail.com> writes:

> Excerpts from Fabiano Rosas's message of December 24, 2021 7:19 am:
>> Delay the setting of kvm_hv_ops until after all init code has
>> completed. This avoids leaving the ops still accessible if the init
>> fails.
>> 
>> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
>> ---
>>  arch/powerpc/kvm/book3s_hv.c | 12 +++++++-----
>>  1 file changed, 7 insertions(+), 5 deletions(-)
>> 
>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>> index 9f4765951733..53400932f5d8 100644
>> --- a/arch/powerpc/kvm/book3s_hv.c
>> +++ b/arch/powerpc/kvm/book3s_hv.c
>> @@ -6087,9 +6087,6 @@ static int kvmppc_book3s_init_hv(void)
>>  	}
>>  #endif
>>  
>> -	kvm_ops_hv.owner = THIS_MODULE;
>> -	kvmppc_hv_ops = &kvm_ops_hv;
>> -
>>  	init_default_hcalls();
>>  
>>  	init_vcore_lists();
>> @@ -6105,10 +6102,15 @@ static int kvmppc_book3s_init_hv(void)
>>  	}
>>  
>>  	r = kvmppc_uvmem_init();
>> -	if (r < 0)
>> +	if (r < 0) {
>>  		pr_err("KVM-HV: kvmppc_uvmem_init failed %d\n", r);
>> +		return r;
>> +	}
>>  
>> -	return r;
>> +	kvm_ops_hv.owner = THIS_MODULE;
>> +	kvmppc_hv_ops = &kvm_ops_hv;
>> +
>> +	return 0;
>>  }
>>  
>>  static void kvmppc_book3s_exit_hv(void)
>> -- 
>> 2.33.1
>> 
>> 
>
> Also looks okay to me but KVM init has lots of details. IIRC Alexey may 
> have run into a related issue with ops being set too early (or was it 
> cleared too late?)
>
> Thanks,
> Nick
>

CC Alexey
diff mbox series

Patch

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 9f4765951733..53400932f5d8 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -6087,9 +6087,6 @@  static int kvmppc_book3s_init_hv(void)
 	}
 #endif
 
-	kvm_ops_hv.owner = THIS_MODULE;
-	kvmppc_hv_ops = &kvm_ops_hv;
-
 	init_default_hcalls();
 
 	init_vcore_lists();
@@ -6105,10 +6102,15 @@  static int kvmppc_book3s_init_hv(void)
 	}
 
 	r = kvmppc_uvmem_init();
-	if (r < 0)
+	if (r < 0) {
 		pr_err("KVM-HV: kvmppc_uvmem_init failed %d\n", r);
+		return r;
+	}
 
-	return r;
+	kvm_ops_hv.owner = THIS_MODULE;
+	kvmppc_hv_ops = &kvm_ops_hv;
+
+	return 0;
 }
 
 static void kvmppc_book3s_exit_hv(void)