arch/loongarch/include/asm/fpu.h | 6 ++++++ arch/loongarch/include/asm/lbt.h | 4 ++++ arch/loongarch/kernel/fpu.S | 6 ++++++ arch/loongarch/kernel/lbt.S | 4 ++++ arch/loongarch/kernel/signal.c | 21 --------------------- 5 files changed, 20 insertions(+), 21 deletions(-)
Like the other relevant symbols, export some fp, lsx, lasx and lbt
assembly symbols and put the function declarations in header files
rather than source files.
Cc: stable@vger.kernel.org # 6.6+
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/loongarch/include/asm/fpu.h | 6 ++++++
arch/loongarch/include/asm/lbt.h | 4 ++++
arch/loongarch/kernel/fpu.S | 6 ++++++
arch/loongarch/kernel/lbt.S | 4 ++++
arch/loongarch/kernel/signal.c | 21 ---------------------
5 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h
index 3177674228f8..52efb2f4df1c 100644
--- a/arch/loongarch/include/asm/fpu.h
+++ b/arch/loongarch/include/asm/fpu.h
@@ -28,16 +28,22 @@ extern void kernel_fpu_end(void);
extern void _init_fpu(unsigned int);
extern void _save_fp(struct loongarch_fpu *);
extern void _restore_fp(struct loongarch_fpu *);
+extern int _save_fp_context(void __user *fpregs, void __user *fcc, void __user *csr);
+extern int _restore_fp_context(void __user *fpregs, void __user *fcc, void __user *csr);
extern void _save_lsx(struct loongarch_fpu *fpu);
extern void _restore_lsx(struct loongarch_fpu *fpu);
extern void _init_lsx_upper(void);
extern void _restore_lsx_upper(struct loongarch_fpu *fpu);
+extern int _save_lsx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
+extern int _restore_lsx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
extern void _save_lasx(struct loongarch_fpu *fpu);
extern void _restore_lasx(struct loongarch_fpu *fpu);
extern void _init_lasx_upper(void);
extern void _restore_lasx_upper(struct loongarch_fpu *fpu);
+extern int _save_lasx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
+extern int _restore_lasx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
static inline void enable_lsx(void);
static inline void disable_lsx(void);
diff --git a/arch/loongarch/include/asm/lbt.h b/arch/loongarch/include/asm/lbt.h
index e671978bf552..24a9ee232fee 100644
--- a/arch/loongarch/include/asm/lbt.h
+++ b/arch/loongarch/include/asm/lbt.h
@@ -15,6 +15,10 @@
extern void _init_lbt(void);
extern void _save_lbt(struct loongarch_lbt *);
extern void _restore_lbt(struct loongarch_lbt *);
+extern int _save_lbt_context(void __user *regs, void __user *eflags);
+extern int _restore_lbt_context(void __user *regs, void __user *eflags);
+extern int _save_ftop_context(void __user *ftop);
+extern int _restore_ftop_context(void __user *ftop);
static inline int is_lbt_enabled(void)
{
diff --git a/arch/loongarch/kernel/fpu.S b/arch/loongarch/kernel/fpu.S
index 6ab640101457..28caf416ae36 100644
--- a/arch/loongarch/kernel/fpu.S
+++ b/arch/loongarch/kernel/fpu.S
@@ -458,6 +458,7 @@ SYM_FUNC_START(_save_fp_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_save_fp_context)
+EXPORT_SYMBOL_GPL(_save_fp_context)
/*
* a0: fpregs
@@ -471,6 +472,7 @@ SYM_FUNC_START(_restore_fp_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_restore_fp_context)
+EXPORT_SYMBOL_GPL(_restore_fp_context)
/*
* a0: fpregs
@@ -484,6 +486,7 @@ SYM_FUNC_START(_save_lsx_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_save_lsx_context)
+EXPORT_SYMBOL_GPL(_save_lsx_context)
/*
* a0: fpregs
@@ -497,6 +500,7 @@ SYM_FUNC_START(_restore_lsx_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_restore_lsx_context)
+EXPORT_SYMBOL_GPL(_restore_lsx_context)
/*
* a0: fpregs
@@ -510,6 +514,7 @@ SYM_FUNC_START(_save_lasx_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_save_lasx_context)
+EXPORT_SYMBOL_GPL(_save_lasx_context)
/*
* a0: fpregs
@@ -523,6 +528,7 @@ SYM_FUNC_START(_restore_lasx_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_restore_lasx_context)
+EXPORT_SYMBOL_GPL(_restore_lasx_context)
.L_fpu_fault:
li.w a0, -EFAULT # failure
diff --git a/arch/loongarch/kernel/lbt.S b/arch/loongarch/kernel/lbt.S
index 001f061d226a..71678912d24c 100644
--- a/arch/loongarch/kernel/lbt.S
+++ b/arch/loongarch/kernel/lbt.S
@@ -90,6 +90,7 @@ SYM_FUNC_START(_save_lbt_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_save_lbt_context)
+EXPORT_SYMBOL_GPL(_save_lbt_context)
/*
* a0: scr
@@ -110,6 +111,7 @@ SYM_FUNC_START(_restore_lbt_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_restore_lbt_context)
+EXPORT_SYMBOL_GPL(_restore_lbt_context)
/*
* a0: ftop
@@ -120,6 +122,7 @@ SYM_FUNC_START(_save_ftop_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_save_ftop_context)
+EXPORT_SYMBOL_GPL(_save_ftop_context)
/*
* a0: ftop
@@ -150,6 +153,7 @@ SYM_FUNC_START(_restore_ftop_context)
li.w a0, 0 # success
jr ra
SYM_FUNC_END(_restore_ftop_context)
+EXPORT_SYMBOL_GPL(_restore_ftop_context)
.L_lbt_fault:
li.w a0, -EFAULT # failure
diff --git a/arch/loongarch/kernel/signal.c b/arch/loongarch/kernel/signal.c
index 7a555b600171..4740cb5b2388 100644
--- a/arch/loongarch/kernel/signal.c
+++ b/arch/loongarch/kernel/signal.c
@@ -51,27 +51,6 @@
#define lock_lbt_owner() ({ preempt_disable(); pagefault_disable(); })
#define unlock_lbt_owner() ({ pagefault_enable(); preempt_enable(); })
-/* Assembly functions to move context to/from the FPU */
-extern asmlinkage int
-_save_fp_context(void __user *fpregs, void __user *fcc, void __user *csr);
-extern asmlinkage int
-_restore_fp_context(void __user *fpregs, void __user *fcc, void __user *csr);
-extern asmlinkage int
-_save_lsx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
-extern asmlinkage int
-_restore_lsx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
-extern asmlinkage int
-_save_lasx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
-extern asmlinkage int
-_restore_lasx_context(void __user *fpregs, void __user *fcc, void __user *fcsr);
-
-#ifdef CONFIG_CPU_HAS_LBT
-extern asmlinkage int _save_lbt_context(void __user *regs, void __user *eflags);
-extern asmlinkage int _restore_lbt_context(void __user *regs, void __user *eflags);
-extern asmlinkage int _save_ftop_context(void __user *ftop);
-extern asmlinkage int _restore_ftop_context(void __user *ftop);
-#endif
-
struct rt_sigframe {
struct siginfo rs_info;
struct ucontext rs_uctx;
--
2.42.0
Hello Yang, I don`t know why change it defination remove "asmlinkage", why not explain it in commit message? BRs Wentao Guan
On 04/09/2025 12:12 AM, Wentao Guan wrote: > Hello Yang, > > I don`t know why change it defination remove "asmlinkage", > why not explain it in commit message? $ grep -rnw "define asmlinkage" . ./arch/x86/include/asm/linkage.h:20:#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0))) ./include/linux/linkage.h:22:#define asmlinkage CPP_ASMLINKAGE include/linux/linkage.h #ifdef __cplusplus #define CPP_ASMLINKAGE extern "C" #else #define CPP_ASMLINKAGE #endif #ifndef asmlinkage #define asmlinkage CPP_ASMLINKAGE #endif So for LoongArch, asmlinkage means extern "C" or NULL, there is no need to use asmlinkage for these prototypes because they are not put in uapi headers, that is to say, they will be called and built only by C compiler rather than C++ compiler, so asmlinkage is actually NULL in this case. Furthermore, there are no asmlinkage for the other exist prototypes such as _save_fp, _restore_fp in arch/loongarch/include/asm/fpu.h, so in my opinion, just keep them consistent. But according to Documentation/process/coding-style.rst, it seems asmlinkage should be used. "Large, non-trivial assembly functions should go in .S files, with corresponding C prototypes defined in C header files. The C prototypes for assembly functions should use ``asmlinkage``." There are two ways: (1) no need to use asmlinkage for these new added prototypes for assembly functions in asm/fpu.h and asm/lbt.h to keep consistent. (2) use asmlinkage for these new added prototypes for assembly functions in asm/fpu.h and asm/lbt.h according to Documentation, and then add asmlinkage for the other exist prototypes if necessary. That's up to the arch maintainer Huacai. Thanks, Tiezhu
Hi, Tiezhu, On Fri, Apr 11, 2025 at 10:47 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > On 04/09/2025 12:12 AM, Wentao Guan wrote: > > Hello Yang, > > > > I don`t know why change it defination remove "asmlinkage", > > why not explain it in commit message? > > $ grep -rnw "define asmlinkage" . > ./arch/x86/include/asm/linkage.h:20:#define asmlinkage CPP_ASMLINKAGE > __attribute__((regparm(0))) > ./include/linux/linkage.h:22:#define asmlinkage CPP_ASMLINKAGE > > include/linux/linkage.h > > #ifdef __cplusplus > #define CPP_ASMLINKAGE extern "C" > #else > #define CPP_ASMLINKAGE > #endif > > #ifndef asmlinkage > #define asmlinkage CPP_ASMLINKAGE > #endif > > So for LoongArch, asmlinkage means extern "C" or NULL, there is no > need to use asmlinkage for these prototypes because they are not put > in uapi headers, that is to say, they will be called and built only > by C compiler rather than C++ compiler, so asmlinkage is actually > NULL in this case. > > Furthermore, there are no asmlinkage for the other exist prototypes > such as _save_fp, _restore_fp in arch/loongarch/include/asm/fpu.h, > so in my opinion, just keep them consistent. > > But according to Documentation/process/coding-style.rst, it seems > asmlinkage should be used. > > "Large, non-trivial assembly functions should go in .S files, with > corresponding > C prototypes defined in C header files. The C prototypes for assembly > functions should use ``asmlinkage``." > > There are two ways: > (1) no need to use asmlinkage for these new added prototypes for > assembly functions in asm/fpu.h and asm/lbt.h to keep consistent. > > (2) use asmlinkage for these new added prototypes for assembly functions > in asm/fpu.h and asm/lbt.h according to Documentation, and then add > asmlinkage for the other exist prototypes if necessary. I think this way is better, especially you have CCed stable, it should really fix something. Huacai > > That's up to the arch maintainer Huacai. > > Thanks, > Tiezhu >
© 2016 - 2025 Red Hat, Inc.