LoongArch: KVM: Remove unnecessary CSR register saving during enter guest

Message ID 20240112035039.833974-1-maobibo@loongson.cn
State New
Headers
Series LoongArch: KVM: Remove unnecessary CSR register saving during enter guest |

Commit Message

maobibo Jan. 12, 2024, 3:50 a.m. UTC
  Some CSR registers like CRMD/PRMD are saved during enter VM mode. However
they are not restored for actual use, saving for these CSR registers
can be removed.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 arch/loongarch/kvm/switch.S | 6 ------
 1 file changed, 6 deletions(-)


base-commit: de927f6c0b07d9e698416c5b287c521b07694cac
  

Comments

maobibo Jan. 31, 2024, 3:48 a.m. UTC | #1
slightly ping :)

On 2024/1/12 上午11:50, Bibo Mao wrote:
> Some CSR registers like CRMD/PRMD are saved during enter VM mode. However
> they are not restored for actual use, saving for these CSR registers
> can be removed.
> 
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   arch/loongarch/kvm/switch.S | 6 ------
>   1 file changed, 6 deletions(-)
> 
> diff --git a/arch/loongarch/kvm/switch.S b/arch/loongarch/kvm/switch.S
> index 0ed9040307b7..905b90de50e8 100644
> --- a/arch/loongarch/kvm/switch.S
> +++ b/arch/loongarch/kvm/switch.S
> @@ -213,12 +213,6 @@ SYM_FUNC_START(kvm_enter_guest)
>   	/* Save host GPRs */
>   	kvm_save_host_gpr a2
>   
> -	/* Save host CRMD, PRMD to stack */
> -	csrrd	a3, LOONGARCH_CSR_CRMD
> -	st.d	a3, a2, PT_CRMD
> -	csrrd	a3, LOONGARCH_CSR_PRMD
> -	st.d	a3, a2, PT_PRMD
> -
>   	addi.d	a2, a1, KVM_VCPU_ARCH
>   	st.d	sp, a2, KVM_ARCH_HSP
>   	st.d	tp, a2, KVM_ARCH_HTP
> 
> base-commit: de927f6c0b07d9e698416c5b287c521b07694cac
>
  
zhaotianrui Feb. 1, 2024, 3:29 a.m. UTC | #2
Reviewed-by: Tianrui Zhao <zhaotianrui@loongson.cn>

在 2024/1/31 上午11:48, maobibo 写道:
> slightly ping :)
> 
> On 2024/1/12 上午11:50, Bibo Mao wrote:
>> Some CSR registers like CRMD/PRMD are saved during enter VM mode. However
>> they are not restored for actual use, saving for these CSR registers
>> can be removed.
>>
>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>> ---
>>   arch/loongarch/kvm/switch.S | 6 ------
>>   1 file changed, 6 deletions(-)
>>
>> diff --git a/arch/loongarch/kvm/switch.S b/arch/loongarch/kvm/switch.S
>> index 0ed9040307b7..905b90de50e8 100644
>> --- a/arch/loongarch/kvm/switch.S
>> +++ b/arch/loongarch/kvm/switch.S
>> @@ -213,12 +213,6 @@ SYM_FUNC_START(kvm_enter_guest)
>>       /* Save host GPRs */
>>       kvm_save_host_gpr a2
>> -    /* Save host CRMD, PRMD to stack */
>> -    csrrd    a3, LOONGARCH_CSR_CRMD
>> -    st.d    a3, a2, PT_CRMD
>> -    csrrd    a3, LOONGARCH_CSR_PRMD
>> -    st.d    a3, a2, PT_PRMD
>> -
>>       addi.d    a2, a1, KVM_VCPU_ARCH
>>       st.d    sp, a2, KVM_ARCH_HSP
>>       st.d    tp, a2, KVM_ARCH_HTP
>>
>> base-commit: de927f6c0b07d9e698416c5b287c521b07694cac
>>
  
Huacai Chen Feb. 26, 2024, 12:58 p.m. UTC | #3
LGTM, queued for loongarch-kvm.

Huacai

On Thu, Feb 1, 2024 at 11:30 AM zhaotianrui <zhaotianrui@loongson.cn> wrote:
>
> Reviewed-by: Tianrui Zhao <zhaotianrui@loongson.cn>
>
> 在 2024/1/31 上午11:48, maobibo 写道:
> > slightly ping :)
> >
> > On 2024/1/12 上午11:50, Bibo Mao wrote:
> >> Some CSR registers like CRMD/PRMD are saved during enter VM mode. However
> >> they are not restored for actual use, saving for these CSR registers
> >> can be removed.
> >>
> >> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> >> ---
> >>   arch/loongarch/kvm/switch.S | 6 ------
> >>   1 file changed, 6 deletions(-)
> >>
> >> diff --git a/arch/loongarch/kvm/switch.S b/arch/loongarch/kvm/switch.S
> >> index 0ed9040307b7..905b90de50e8 100644
> >> --- a/arch/loongarch/kvm/switch.S
> >> +++ b/arch/loongarch/kvm/switch.S
> >> @@ -213,12 +213,6 @@ SYM_FUNC_START(kvm_enter_guest)
> >>       /* Save host GPRs */
> >>       kvm_save_host_gpr a2
> >> -    /* Save host CRMD, PRMD to stack */
> >> -    csrrd    a3, LOONGARCH_CSR_CRMD
> >> -    st.d    a3, a2, PT_CRMD
> >> -    csrrd    a3, LOONGARCH_CSR_PRMD
> >> -    st.d    a3, a2, PT_PRMD
> >> -
> >>       addi.d    a2, a1, KVM_VCPU_ARCH
> >>       st.d    sp, a2, KVM_ARCH_HSP
> >>       st.d    tp, a2, KVM_ARCH_HTP
> >>
> >> base-commit: de927f6c0b07d9e698416c5b287c521b07694cac
> >>
>
>
  

Patch

diff --git a/arch/loongarch/kvm/switch.S b/arch/loongarch/kvm/switch.S
index 0ed9040307b7..905b90de50e8 100644
--- a/arch/loongarch/kvm/switch.S
+++ b/arch/loongarch/kvm/switch.S
@@ -213,12 +213,6 @@  SYM_FUNC_START(kvm_enter_guest)
 	/* Save host GPRs */
 	kvm_save_host_gpr a2
 
-	/* Save host CRMD, PRMD to stack */
-	csrrd	a3, LOONGARCH_CSR_CRMD
-	st.d	a3, a2, PT_CRMD
-	csrrd	a3, LOONGARCH_CSR_PRMD
-	st.d	a3, a2, PT_PRMD
-
 	addi.d	a2, a1, KVM_VCPU_ARCH
 	st.d	sp, a2, KVM_ARCH_HSP
 	st.d	tp, a2, KVM_ARCH_HTP