diff mbox series

[v1,4/6] riscv: vector: do not pass task_struct into riscv_v_vstate_{save,restore}()

Message ID 20230715150032.6917-5-andy.chiu@sifive.com (mailing list archive)
State Superseded
Headers show
Series riscv: support kernel-mode Vector | expand

Checks

Context Check Description
conchuod/cover_letter success Series has a cover letter
conchuod/tree_selection success Guessed tree name to be for-next at HEAD 471aba2e4760
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 4 and now 4
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 14 this patch: 14
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig fail Failed to build the tree with this patch.
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 3 this patch: 3
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 75 lines checked
conchuod/build_rv64_nommu_k210_defconfig fail Build failed
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig fail Build failed

Commit Message

Andy Chiu July 15, 2023, 3 p.m. UTC
riscv_v_vstate_{save,restore}() can operate only on the knowlege of
struct __riscv_v_ext_state, and struct pt_regs. Let the caller decides
which should be passed into the function. Meanwhile, the kernel-mode
Vector is going to introduce another vstate, so this also makes functions
potentially able to be reused.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
---
 arch/riscv/include/asm/entry-common.h  |  2 +-
 arch/riscv/include/asm/vector.h        | 14 +++++---------
 arch/riscv/kernel/kernel_mode_vector.c |  2 +-
 arch/riscv/kernel/ptrace.c             |  2 +-
 arch/riscv/kernel/signal.c             |  2 +-
 5 files changed, 9 insertions(+), 13 deletions(-)

Comments

Conor Dooley July 17, 2023, 10:32 a.m. UTC | #1
On Sat, Jul 15, 2023 at 03:00:30PM +0000, Andy Chiu wrote:
> riscv_v_vstate_{save,restore}() can operate only on the knowlege of
> struct __riscv_v_ext_state, and struct pt_regs. Let the caller decides
> which should be passed into the function. Meanwhile, the kernel-mode
> Vector is going to introduce another vstate, so this also makes functions
> potentially able to be reused.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>

Breaks the build chief:
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'

rv64 allmodconfig w/ gcc.

Thanks,
Conor.

> ---
>  arch/riscv/include/asm/entry-common.h  |  2 +-
>  arch/riscv/include/asm/vector.h        | 14 +++++---------
>  arch/riscv/kernel/kernel_mode_vector.c |  2 +-
>  arch/riscv/kernel/ptrace.c             |  2 +-
>  arch/riscv/kernel/signal.c             |  2 +-
>  5 files changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/riscv/include/asm/entry-common.h b/arch/riscv/include/asm/entry-common.h
> index 52926f4d8d7c..aa1b9e50d6c8 100644
> --- a/arch/riscv/include/asm/entry-common.h
> +++ b/arch/riscv/include/asm/entry-common.h
> @@ -12,7 +12,7 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
>  {
>  	if (ti_work & _TIF_RISCV_V_DEFER_RESTORE) {
>  		clear_thread_flag(TIF_RISCV_V_DEFER_RESTORE);
> -		riscv_v_vstate_restore(current, regs);
> +		riscv_v_vstate_restore(&current->thread.vstate, regs);
>  	}
>  }
>  
> diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
> index 9831b19153ae..50c556afd95a 100644
> --- a/arch/riscv/include/asm/vector.h
> +++ b/arch/riscv/include/asm/vector.h
> @@ -163,23 +163,19 @@ static inline void riscv_v_vstate_discard(struct pt_regs *regs)
>  	__riscv_v_vstate_dirty(regs);
>  }
>  
> -static inline void riscv_v_vstate_save(struct task_struct *task,
> +static inline void riscv_v_vstate_save(struct __riscv_v_ext_state *vstate,
>  				       struct pt_regs *regs)
>  {
>  	if ((regs->status & SR_VS) == SR_VS_DIRTY) {
> -		struct __riscv_v_ext_state *vstate = &task->thread.vstate;
> -
>  		__riscv_v_vstate_save(vstate, vstate->datap);
>  		__riscv_v_vstate_clean(regs);
>  	}
>  }
>  
> -static inline void riscv_v_vstate_restore(struct task_struct *task,
> +static inline void riscv_v_vstate_restore(struct __riscv_v_ext_state *vstate,
>  					  struct pt_regs *regs)
>  {
>  	if ((regs->status & SR_VS) != SR_VS_OFF) {
> -		struct __riscv_v_ext_state *vstate = &task->thread.vstate;
> -
>  		__riscv_v_vstate_restore(vstate, vstate->datap);
>  		__riscv_v_vstate_clean(regs);
>  	}
> @@ -200,7 +196,7 @@ static inline void __switch_to_vector(struct task_struct *prev,
>  	struct pt_regs *regs;
>  
>  	regs = task_pt_regs(prev);
> -	riscv_v_vstate_save(prev, regs);
> +	riscv_v_vstate_save(prev->thread.vstate, regs);
>  	riscv_v_vstate_set_restore(next, task_pt_regs(next));
>  }
>  
> @@ -218,8 +214,8 @@ static inline bool riscv_v_vstate_query(struct pt_regs *regs) { return false; }
>  static inline bool riscv_v_vstate_ctrl_user_allowed(void) { return false; }
>  #define riscv_v_vsize (0)
>  #define riscv_v_vstate_discard(regs)		do {} while (0)
> -#define riscv_v_vstate_save(task, regs)		do {} while (0)
> -#define riscv_v_vstate_restore(task, regs)	do {} while (0)
> +#define riscv_v_vstate_save(vstate, regs)	do {} while (0)
> +#define riscv_v_vstate_restore(vstate, regs)	do {} while (0)
>  #define __switch_to_vector(__prev, __next)	do {} while (0)
>  #define riscv_v_vstate_off(regs)		do {} while (0)
>  #define riscv_v_vstate_on(regs)			do {} while (0)
> diff --git a/arch/riscv/kernel/kernel_mode_vector.c b/arch/riscv/kernel/kernel_mode_vector.c
> index c0c152c501a5..30f1b861cac0 100644
> --- a/arch/riscv/kernel/kernel_mode_vector.c
> +++ b/arch/riscv/kernel/kernel_mode_vector.c
> @@ -91,7 +91,7 @@ int kernel_rvv_begin(void)
>  		return -EPERM;
>  
>  	/* Save vector state, if any */
> -	riscv_v_vstate_save(current, task_pt_regs(current));
> +	riscv_v_vstate_save(&current->thread.vstate, task_pt_regs(current));
>  
>  	/* Acquire kernel mode vector */
>  	get_cpu_vector_context();
> diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
> index 1d572cf3140f..85e7167245cc 100644
> --- a/arch/riscv/kernel/ptrace.c
> +++ b/arch/riscv/kernel/ptrace.c
> @@ -99,7 +99,7 @@ static int riscv_vr_get(struct task_struct *target,
>  	 * copying them to membuf.
>  	 */
>  	if (target == current)
> -		riscv_v_vstate_save(current, task_pt_regs(current));
> +		riscv_v_vstate_save(&current->thread.vstate, task_pt_regs(current));
>  
>  	/* Copy vector header from vstate. */
>  	membuf_write(&to, vstate, offsetof(struct __riscv_v_ext_state, datap));
> diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
> index 0fca2c128b5f..75fd8cc05e10 100644
> --- a/arch/riscv/kernel/signal.c
> +++ b/arch/riscv/kernel/signal.c
> @@ -86,7 +86,7 @@ static long save_v_state(struct pt_regs *regs, void __user **sc_vec)
>  	/* datap is designed to be 16 byte aligned for better performance */
>  	WARN_ON(unlikely(!IS_ALIGNED((unsigned long)datap, 16)));
>  
> -	riscv_v_vstate_save(current, regs);
> +	riscv_v_vstate_save(&current->thread.vstate, regs);
>  	/* Copy everything of vstate but datap. */
>  	err = __copy_to_user(&state->v_state, &current->thread.vstate,
>  			     offsetof(struct __riscv_v_ext_state, datap));
> -- 
> 2.17.1
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Andy Chiu July 20, 2023, 2:59 p.m. UTC | #2
On Mon, Jul 17, 2023 at 6:33 PM Conor Dooley <conor.dooley@microchip.com> wrote:
>
> On Sat, Jul 15, 2023 at 03:00:30PM +0000, Andy Chiu wrote:
> > riscv_v_vstate_{save,restore}() can operate only on the knowlege of
> > struct __riscv_v_ext_state, and struct pt_regs. Let the caller decides
> > which should be passed into the function. Meanwhile, the kernel-mode
> > Vector is going to introduce another vstate, so this also makes functions
> > potentially able to be reused.
> >
> > Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
>
> Breaks the build chief:
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
> ../arch/riscv/include/asm/vector.h:199:41: error: incompatible type for argument 1 of 'riscv_v_vstate_save'
>
> rv64 allmodconfig w/ gcc.

Thanks for catching this. This bug was buried at the next patch and I
was not careful enough to carry the fix back to this patch.

>
> Thanks,
> Conor.
>
> > ---
> >  arch/riscv/include/asm/entry-common.h  |  2 +-
> >  arch/riscv/include/asm/vector.h        | 14 +++++---------
> >  arch/riscv/kernel/kernel_mode_vector.c |  2 +-
> >  arch/riscv/kernel/ptrace.c             |  2 +-
> >  arch/riscv/kernel/signal.c             |  2 +-
> >  5 files changed, 9 insertions(+), 13 deletions(-)
> >
> > diff --git a/arch/riscv/include/asm/entry-common.h b/arch/riscv/include/asm/entry-common.h
> > index 52926f4d8d7c..aa1b9e50d6c8 100644
> > --- a/arch/riscv/include/asm/entry-common.h
> > +++ b/arch/riscv/include/asm/entry-common.h
> > @@ -12,7 +12,7 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
> >  {
> >       if (ti_work & _TIF_RISCV_V_DEFER_RESTORE) {
> >               clear_thread_flag(TIF_RISCV_V_DEFER_RESTORE);
> > -             riscv_v_vstate_restore(current, regs);
> > +             riscv_v_vstate_restore(&current->thread.vstate, regs);
> >       }
> >  }
> >
> > diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
> > index 9831b19153ae..50c556afd95a 100644
> > --- a/arch/riscv/include/asm/vector.h
> > +++ b/arch/riscv/include/asm/vector.h
> > @@ -163,23 +163,19 @@ static inline void riscv_v_vstate_discard(struct pt_regs *regs)
> >       __riscv_v_vstate_dirty(regs);
> >  }
> >
> > -static inline void riscv_v_vstate_save(struct task_struct *task,
> > +static inline void riscv_v_vstate_save(struct __riscv_v_ext_state *vstate,
> >                                      struct pt_regs *regs)
> >  {
> >       if ((regs->status & SR_VS) == SR_VS_DIRTY) {
> > -             struct __riscv_v_ext_state *vstate = &task->thread.vstate;
> > -
> >               __riscv_v_vstate_save(vstate, vstate->datap);
> >               __riscv_v_vstate_clean(regs);
> >       }
> >  }
> >
> > -static inline void riscv_v_vstate_restore(struct task_struct *task,
> > +static inline void riscv_v_vstate_restore(struct __riscv_v_ext_state *vstate,
> >                                         struct pt_regs *regs)
> >  {
> >       if ((regs->status & SR_VS) != SR_VS_OFF) {
> > -             struct __riscv_v_ext_state *vstate = &task->thread.vstate;
> > -
> >               __riscv_v_vstate_restore(vstate, vstate->datap);
> >               __riscv_v_vstate_clean(regs);
> >       }
> > @@ -200,7 +196,7 @@ static inline void __switch_to_vector(struct task_struct *prev,
> >       struct pt_regs *regs;
> >
> >       regs = task_pt_regs(prev);
> > -     riscv_v_vstate_save(prev, regs);
> > +     riscv_v_vstate_save(prev->thread.vstate, regs);
> >       riscv_v_vstate_set_restore(next, task_pt_regs(next));
> >  }
> >
> > @@ -218,8 +214,8 @@ static inline bool riscv_v_vstate_query(struct pt_regs *regs) { return false; }
> >  static inline bool riscv_v_vstate_ctrl_user_allowed(void) { return false; }
> >  #define riscv_v_vsize (0)
> >  #define riscv_v_vstate_discard(regs)         do {} while (0)
> > -#define riscv_v_vstate_save(task, regs)              do {} while (0)
> > -#define riscv_v_vstate_restore(task, regs)   do {} while (0)
> > +#define riscv_v_vstate_save(vstate, regs)    do {} while (0)
> > +#define riscv_v_vstate_restore(vstate, regs) do {} while (0)
> >  #define __switch_to_vector(__prev, __next)   do {} while (0)
> >  #define riscv_v_vstate_off(regs)             do {} while (0)
> >  #define riscv_v_vstate_on(regs)                      do {} while (0)
> > diff --git a/arch/riscv/kernel/kernel_mode_vector.c b/arch/riscv/kernel/kernel_mode_vector.c
> > index c0c152c501a5..30f1b861cac0 100644
> > --- a/arch/riscv/kernel/kernel_mode_vector.c
> > +++ b/arch/riscv/kernel/kernel_mode_vector.c
> > @@ -91,7 +91,7 @@ int kernel_rvv_begin(void)
> >               return -EPERM;
> >
> >       /* Save vector state, if any */
> > -     riscv_v_vstate_save(current, task_pt_regs(current));
> > +     riscv_v_vstate_save(&current->thread.vstate, task_pt_regs(current));
> >
> >       /* Acquire kernel mode vector */
> >       get_cpu_vector_context();
> > diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
> > index 1d572cf3140f..85e7167245cc 100644
> > --- a/arch/riscv/kernel/ptrace.c
> > +++ b/arch/riscv/kernel/ptrace.c
> > @@ -99,7 +99,7 @@ static int riscv_vr_get(struct task_struct *target,
> >        * copying them to membuf.
> >        */
> >       if (target == current)
> > -             riscv_v_vstate_save(current, task_pt_regs(current));
> > +             riscv_v_vstate_save(&current->thread.vstate, task_pt_regs(current));
> >
> >       /* Copy vector header from vstate. */
> >       membuf_write(&to, vstate, offsetof(struct __riscv_v_ext_state, datap));
> > diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
> > index 0fca2c128b5f..75fd8cc05e10 100644
> > --- a/arch/riscv/kernel/signal.c
> > +++ b/arch/riscv/kernel/signal.c
> > @@ -86,7 +86,7 @@ static long save_v_state(struct pt_regs *regs, void __user **sc_vec)
> >       /* datap is designed to be 16 byte aligned for better performance */
> >       WARN_ON(unlikely(!IS_ALIGNED((unsigned long)datap, 16)));
> >
> > -     riscv_v_vstate_save(current, regs);
> > +     riscv_v_vstate_save(&current->thread.vstate, regs);
> >       /* Copy everything of vstate but datap. */
> >       err = __copy_to_user(&state->v_state, &current->thread.vstate,
> >                            offsetof(struct __riscv_v_ext_state, datap));
> > --
> > 2.17.1
> >
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv

Thanks,
Andy
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/entry-common.h b/arch/riscv/include/asm/entry-common.h
index 52926f4d8d7c..aa1b9e50d6c8 100644
--- a/arch/riscv/include/asm/entry-common.h
+++ b/arch/riscv/include/asm/entry-common.h
@@ -12,7 +12,7 @@  static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
 {
 	if (ti_work & _TIF_RISCV_V_DEFER_RESTORE) {
 		clear_thread_flag(TIF_RISCV_V_DEFER_RESTORE);
-		riscv_v_vstate_restore(current, regs);
+		riscv_v_vstate_restore(&current->thread.vstate, regs);
 	}
 }
 
diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
index 9831b19153ae..50c556afd95a 100644
--- a/arch/riscv/include/asm/vector.h
+++ b/arch/riscv/include/asm/vector.h
@@ -163,23 +163,19 @@  static inline void riscv_v_vstate_discard(struct pt_regs *regs)
 	__riscv_v_vstate_dirty(regs);
 }
 
-static inline void riscv_v_vstate_save(struct task_struct *task,
+static inline void riscv_v_vstate_save(struct __riscv_v_ext_state *vstate,
 				       struct pt_regs *regs)
 {
 	if ((regs->status & SR_VS) == SR_VS_DIRTY) {
-		struct __riscv_v_ext_state *vstate = &task->thread.vstate;
-
 		__riscv_v_vstate_save(vstate, vstate->datap);
 		__riscv_v_vstate_clean(regs);
 	}
 }
 
-static inline void riscv_v_vstate_restore(struct task_struct *task,
+static inline void riscv_v_vstate_restore(struct __riscv_v_ext_state *vstate,
 					  struct pt_regs *regs)
 {
 	if ((regs->status & SR_VS) != SR_VS_OFF) {
-		struct __riscv_v_ext_state *vstate = &task->thread.vstate;
-
 		__riscv_v_vstate_restore(vstate, vstate->datap);
 		__riscv_v_vstate_clean(regs);
 	}
@@ -200,7 +196,7 @@  static inline void __switch_to_vector(struct task_struct *prev,
 	struct pt_regs *regs;
 
 	regs = task_pt_regs(prev);
-	riscv_v_vstate_save(prev, regs);
+	riscv_v_vstate_save(prev->thread.vstate, regs);
 	riscv_v_vstate_set_restore(next, task_pt_regs(next));
 }
 
@@ -218,8 +214,8 @@  static inline bool riscv_v_vstate_query(struct pt_regs *regs) { return false; }
 static inline bool riscv_v_vstate_ctrl_user_allowed(void) { return false; }
 #define riscv_v_vsize (0)
 #define riscv_v_vstate_discard(regs)		do {} while (0)
-#define riscv_v_vstate_save(task, regs)		do {} while (0)
-#define riscv_v_vstate_restore(task, regs)	do {} while (0)
+#define riscv_v_vstate_save(vstate, regs)	do {} while (0)
+#define riscv_v_vstate_restore(vstate, regs)	do {} while (0)
 #define __switch_to_vector(__prev, __next)	do {} while (0)
 #define riscv_v_vstate_off(regs)		do {} while (0)
 #define riscv_v_vstate_on(regs)			do {} while (0)
diff --git a/arch/riscv/kernel/kernel_mode_vector.c b/arch/riscv/kernel/kernel_mode_vector.c
index c0c152c501a5..30f1b861cac0 100644
--- a/arch/riscv/kernel/kernel_mode_vector.c
+++ b/arch/riscv/kernel/kernel_mode_vector.c
@@ -91,7 +91,7 @@  int kernel_rvv_begin(void)
 		return -EPERM;
 
 	/* Save vector state, if any */
-	riscv_v_vstate_save(current, task_pt_regs(current));
+	riscv_v_vstate_save(&current->thread.vstate, task_pt_regs(current));
 
 	/* Acquire kernel mode vector */
 	get_cpu_vector_context();
diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
index 1d572cf3140f..85e7167245cc 100644
--- a/arch/riscv/kernel/ptrace.c
+++ b/arch/riscv/kernel/ptrace.c
@@ -99,7 +99,7 @@  static int riscv_vr_get(struct task_struct *target,
 	 * copying them to membuf.
 	 */
 	if (target == current)
-		riscv_v_vstate_save(current, task_pt_regs(current));
+		riscv_v_vstate_save(&current->thread.vstate, task_pt_regs(current));
 
 	/* Copy vector header from vstate. */
 	membuf_write(&to, vstate, offsetof(struct __riscv_v_ext_state, datap));
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 0fca2c128b5f..75fd8cc05e10 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -86,7 +86,7 @@  static long save_v_state(struct pt_regs *regs, void __user **sc_vec)
 	/* datap is designed to be 16 byte aligned for better performance */
 	WARN_ON(unlikely(!IS_ALIGNED((unsigned long)datap, 16)));
 
-	riscv_v_vstate_save(current, regs);
+	riscv_v_vstate_save(&current->thread.vstate, regs);
 	/* Copy everything of vstate but datap. */
 	err = __copy_to_user(&state->v_state, &current->thread.vstate,
 			     offsetof(struct __riscv_v_ext_state, datap));