[linux 6.18.y] [deepin] LoongArch: Export some signal functions#1637
[linux 6.18.y] [deepin] LoongArch: Export some signal functions#1637Kingwkl wants to merge 3 commits intodeepin-community:linux-6.18.yfrom
Conversation
Like the other relevant symbols, export them and put the function declarations in header files rather than source files. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Kanglong Wang <wangkanglong@loongson.cn>
So that they can be probed in the kernel modules to do something. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn> Signed-off-by: Kanglong Wang <wangkanglong@loongson.cn>
So that they can be called in the kernel modules to do something. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Kanglong Wang <wangkanglong@loongson.cn>
Reviewer's GuideExports several LoongArch signal and register helper routines for external use by making previously static functions globally visible, adjusting FPU/LBT context helper declarations, and adding a new wrapper module that exports selected core signal helpers via GPL symbols. Sequence diagram for external use of exported LoongArch signal helperssequenceDiagram
participant ExternalModule
participant LoongArchExtern as loongarch_extern_o
participant CoreSignal as Core_signal_helpers
ExternalModule->>LoongArchExtern: loongarch_copy_siginfo_to_user(to, from)
LoongArchExtern->>CoreSignal: copy_siginfo_to_user(to, from)
CoreSignal-->>LoongArchExtern: result
LoongArchExtern-->>ExternalModule: result
ExternalModule->>LoongArchExtern: loongarch___save_altstack(uss, sp)
LoongArchExtern->>CoreSignal: __save_altstack(uss, sp)
CoreSignal-->>LoongArchExtern: result
LoongArchExtern-->>ExternalModule: result
ExternalModule->>LoongArchExtern: loongarch_restore_altstack(uss)
LoongArchExtern->>CoreSignal: restore_altstack(uss)
CoreSignal-->>LoongArchExtern: result
LoongArchExtern-->>ExternalModule: result
ExternalModule->>LoongArchExtern: loongarch_set_current_blocked(newset)
LoongArchExtern->>CoreSignal: set_current_blocked(newset)
CoreSignal-->>LoongArchExtern: void
LoongArchExtern-->>ExternalModule: void
Class diagram for exported LoongArch signal and register helpersclassDiagram
class LoongArchExternModule {
+void loongarch_set_current_blocked(sigset_t* newset)
+int loongarch_copy_siginfo_to_user(siginfo_t* to, kernel_siginfo_t* from)
+int loongarch___save_altstack(stack_t* uss, unsigned long sp)
+int loongarch_restore_altstack(const stack_t* uss)
}
class CoreSignalHelpers {
+void set_current_blocked(sigset_t* newset)
+int copy_siginfo_to_user(siginfo_t* to, const kernel_siginfo_t* from)
+int __save_altstack(stack_t* uss, unsigned long sp)
+int restore_altstack(const stack_t* uss)
}
class LoongArchPtraceHelpers {
+int gpr_get(struct task_struct* target, const struct user_regset* regset, struct membuf to)
+int gpr_set(struct task_struct* target, const struct user_regset* regset, unsigned int pos, unsigned int count, const void* kbuf, const void* ubuf)
+int read_user(struct task_struct* target, unsigned long addr, unsigned long* data)
+int write_user(struct task_struct* target, unsigned long addr, unsigned long data)
}
class LoongArchSignalHelpers {
+int setup_rt_frame(void* sig_return, struct ksignal* ksig, struct pt_regs* regs, sigset_t* set)
}
class LoongArchFpuContextHelpers {
+int _save_fp_context(void* fpregs, void* fcc, void* csr)
+int _restore_fp_context(void* fpregs, void* fcc, void* csr)
+int _save_lsx_context(void* fpregs, void* fcc, void* fcsr)
+int _restore_lsx_context(void* fpregs, void* fcc, void* fcsr)
+int _save_lasx_context(void* fpregs, void* fcc, void* fcsr)
+int _restore_lasx_context(void* fpregs, void* fcc, void* fcsr)
}
class LoongArchLbtContextHelpers {
+int _save_lbt_context(void* regs, void* eflags)
+int _restore_lbt_context(void* regs, void* eflags)
+int _save_ftop_context(void* ftop)
+int _restore_ftop_context(void* ftop)
}
LoongArchExternModule --> CoreSignalHelpers : calls
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new non-static functions like gpr_get/gpr_set/read_user/write_user/setup_rt_frame are declared directly above their definitions rather than in a common header, which makes external use brittle; consider moving their prototypes into an appropriate exported header instead of duplicating them in the C file.
- In arch/loongarch/include/asm/{fpu.h,lbt.h} the save_context/restore_context functions have been changed from asmlinkage to extern, which alters calling convention annotations; if these are still implemented in assembly you likely want to keep the asmlinkage attribute on the prototypes and add extern only if necessary.
- The new extern.c wrappers (loongarch_set_current_blocked, loongarch_copy_siginfo_to_user, etc.) are thin pass-throughs to existing helpers; where possible it may be cleaner to export the underlying symbols directly or document why wrapper symbols are required instead of using EXPORT_SYMBOL on the originals.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new non-static functions like gpr_get/gpr_set/read_user/write_user/setup_rt_frame are declared directly above their definitions rather than in a common header, which makes external use brittle; consider moving their prototypes into an appropriate exported header instead of duplicating them in the C file.
- In arch/loongarch/include/asm/{fpu.h,lbt.h} the _save_*_context/_restore_*_context functions have been changed from asmlinkage to extern, which alters calling convention annotations; if these are still implemented in assembly you likely want to keep the asmlinkage attribute on the prototypes and add extern only if necessary.
- The new extern.c wrappers (loongarch_set_current_blocked, loongarch_copy_siginfo_to_user, etc.) are thin pass-throughs to existing helpers; where possible it may be cleaner to export the underlying symbols directly or document why wrapper symbols are required instead of using EXPORT_SYMBOL on the originals.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Exports LoongArch signal-related helpers intended for use by external code/modules by adding an arch-local wrapper/export unit and widening visibility of several LoongArch signal/ptrace/FPU/LBT helpers.
Changes:
- Add
arch/loongarch/kernel/extern.cexporting wrapper symbols around core signal and altstack helpers. - Make selected LoongArch signal (
setup_rt_frame) and ptrace helpers (gpr_get/gpr_set/read_user/write_user) non-static (globally visible). - Adjust LoongArch FPU/LBT context helper declarations and wire
extern.ointo the LoongArch kernel build.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| arch/loongarch/kernel/signal.c | Makes setup_rt_frame globally visible. |
| arch/loongarch/kernel/ptrace.c | Makes regset helpers and user read/write helpers globally visible. |
| arch/loongarch/kernel/extern.c | New wrapper/export layer for signal + altstack helpers. |
| arch/loongarch/kernel/Makefile | Adds extern.o to built-in objects. |
| arch/loongarch/include/asm/lbt.h | Adjusts LBT context helper declarations. |
| arch/loongarch/include/asm/fpu.h | Adjusts FPU context helper declarations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,31 @@ | |||
| // SPDX-License-Identifier: GPL-2.0 | |||
There was a problem hiding this comment.
EXPORT_SYMBOL_GPL is used in this file but no header is included that defines it. Add the appropriate include (e.g., <linux/export.h> or <linux/module.h>) so this compiles in all configurations.
| // SPDX-License-Identifier: GPL-2.0 | |
| // SPDX-License-Identifier: GPL-2.0 | |
| #include <linux/export.h> |
|
|
||
| void loongarch_set_current_blocked(sigset_t *newset) | ||
| { | ||
| return set_current_blocked(newset); |
There was a problem hiding this comment.
This function returns void but uses return set_current_blocked(newset);, which triggers a compiler diagnostic ('return with a value, in function returning void'). Call set_current_blocked(newset) and use a plain return; (or omit the return statement).
| return set_current_blocked(newset); | |
| set_current_blocked(newset); |
|
1、3补丁有问题,Auther和signoff-by对不上 |
Export some signal functions
Summary by Sourcery
Export LoongArch signal and register helper functions for use by external code and modules.
New Features:
Enhancements: