mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] csky: add arch support current_stack_pointer
@ 2022-10-21 11:56 Tong Tiangen
  2022-10-21 14:48 ` Guo Ren
  0 siblings, 1 reply; 3+ messages in thread
From: Tong Tiangen @ 2022-10-21 11:56 UTC (permalink / raw)
  To: Guo Ren
  Cc: linux-csky, linux-kernel, Tong Tiangen, wangkefeng.wang, Guohanjun

To follow the existing per-arch conventions, using "current_stack_pointer"
to set sp.

This will let it be used in non-arch places(like HARDENED_USERCOPY).

Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
---
 arch/csky/Kconfig                 | 1 +
 arch/csky/include/asm/processor.h | 2 ++
 arch/csky/kernel/stacktrace.c     | 6 ++----
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index adee6ab36862..2236b5c0c213 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -9,6 +9,7 @@ config CSKY
 	select ARCH_USE_BUILTIN_BSWAP
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
+	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_INLINE_READ_LOCK if !PREEMPTION
 	select ARCH_INLINE_READ_LOCK_BH if !PREEMPTION
 	select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPTION
diff --git a/arch/csky/include/asm/processor.h b/arch/csky/include/asm/processor.h
index 63ad71fab30d..ea75d72dea86 100644
--- a/arch/csky/include/asm/processor.h
+++ b/arch/csky/include/asm/processor.h
@@ -84,4 +84,6 @@ unsigned long __get_wchan(struct task_struct *p);
 
 #define cpu_relax() barrier()
 
+register unsigned long current_stack_pointer __asm__("sp");
+
 #endif /* __ASM_CSKY_PROCESSOR_H */
diff --git a/arch/csky/kernel/stacktrace.c b/arch/csky/kernel/stacktrace.c
index 9f78f5d21511..27ecd63e321b 100644
--- a/arch/csky/kernel/stacktrace.c
+++ b/arch/csky/kernel/stacktrace.c
@@ -23,10 +23,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 		sp = user_stack_pointer(regs);
 		pc = instruction_pointer(regs);
 	} else if (task == NULL || task == current) {
-		const register unsigned long current_sp __asm__ ("sp");
 		const register unsigned long current_fp __asm__ ("r8");
 		fp = current_fp;
-		sp = current_sp;
+		sp = current_stack_pointer;
 		pc = (unsigned long)walk_stackframe;
 	} else {
 		/* task blocked in __switch_to */
@@ -68,8 +67,7 @@ static void notrace walk_stackframe(struct task_struct *task,
 		sp = user_stack_pointer(regs);
 		pc = instruction_pointer(regs);
 	} else if (task == NULL || task == current) {
-		const register unsigned long current_sp __asm__ ("sp");
-		sp = current_sp;
+		sp = current_stack_pointer;
 		pc = (unsigned long)walk_stackframe;
 	} else {
 		/* task blocked in __switch_to */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] csky: add arch support current_stack_pointer
  2022-10-21 11:56 [PATCH -next] csky: add arch support current_stack_pointer Tong Tiangen
@ 2022-10-21 14:48 ` Guo Ren
  2022-10-21 15:19   ` Tong Tiangen
  0 siblings, 1 reply; 3+ messages in thread
From: Guo Ren @ 2022-10-21 14:48 UTC (permalink / raw)
  To: Tong Tiangen; +Cc: linux-csky, linux-kernel, wangkefeng.wang, Guohanjun

On Fri, Oct 21, 2022 at 7:31 PM Tong Tiangen <tongtiangen@huawei.com> wrote:
>
> To follow the existing per-arch conventions, using "current_stack_pointer"
> to set sp.
>
> This will let it be used in non-arch places(like HARDENED_USERCOPY).
>

Add a Link tag here. The original patch series lore.kernel.org link.
One tip: commit fdecfea09328b33fd08a4d418237cce9fd176d69 riscv: Rename
"sp_in_global" to "current_stack_pointer"

    To follow the existing per-arch conventions, rename "sp_in_global" to
    "current_stack_pointer". This will let it be used in non-arch places
    (like HARDENED_USERCOPY).
> Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
> ---
>  arch/csky/Kconfig                 | 1 +
>  arch/csky/include/asm/processor.h | 2 ++
>  arch/csky/kernel/stacktrace.c     | 6 ++----
>  3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
> index adee6ab36862..2236b5c0c213 100644
> --- a/arch/csky/Kconfig
> +++ b/arch/csky/Kconfig
> @@ -9,6 +9,7 @@ config CSKY
>         select ARCH_USE_BUILTIN_BSWAP
>         select ARCH_USE_QUEUED_RWLOCKS
>         select ARCH_USE_QUEUED_SPINLOCKS
> +       select ARCH_HAS_CURRENT_STACK_POINTER
>         select ARCH_INLINE_READ_LOCK if !PREEMPTION
>         select ARCH_INLINE_READ_LOCK_BH if !PREEMPTION
>         select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPTION
> diff --git a/arch/csky/include/asm/processor.h b/arch/csky/include/asm/processor.h
> index 63ad71fab30d..ea75d72dea86 100644
> --- a/arch/csky/include/asm/processor.h
> +++ b/arch/csky/include/asm/processor.h
> @@ -84,4 +84,6 @@ unsigned long __get_wchan(struct task_struct *p);
>
>  #define cpu_relax() barrier()
>
> +register unsigned long current_stack_pointer __asm__("sp");
> +
>  #endif /* __ASM_CSKY_PROCESSOR_H */
> diff --git a/arch/csky/kernel/stacktrace.c b/arch/csky/kernel/stacktrace.c
> index 9f78f5d21511..27ecd63e321b 100644
> --- a/arch/csky/kernel/stacktrace.c
> +++ b/arch/csky/kernel/stacktrace.c
> @@ -23,10 +23,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
>                 sp = user_stack_pointer(regs);
>                 pc = instruction_pointer(regs);
>         } else if (task == NULL || task == current) {
> -               const register unsigned long current_sp __asm__ ("sp");
>                 const register unsigned long current_fp __asm__ ("r8");
>                 fp = current_fp;
> -               sp = current_sp;
> +               sp = current_stack_pointer;
>                 pc = (unsigned long)walk_stackframe;
>         } else {
>                 /* task blocked in __switch_to */
> @@ -68,8 +67,7 @@ static void notrace walk_stackframe(struct task_struct *task,
>                 sp = user_stack_pointer(regs);
>                 pc = instruction_pointer(regs);
>         } else if (task == NULL || task == current) {
> -               const register unsigned long current_sp __asm__ ("sp");
> -               sp = current_sp;
> +               sp = current_stack_pointer;
>                 pc = (unsigned long)walk_stackframe;
>         } else {
>                 /* task blocked in __switch_to */
> --
> 2.25.1
>


-- 
Best Regards
 Guo Ren

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] csky: add arch support current_stack_pointer
  2022-10-21 14:48 ` Guo Ren
@ 2022-10-21 15:19   ` Tong Tiangen
  0 siblings, 0 replies; 3+ messages in thread
From: Tong Tiangen @ 2022-10-21 15:19 UTC (permalink / raw)
  To: Guo Ren; +Cc: linux-csky, linux-kernel, wangkefeng.wang, Guohanjun



在 2022/10/21 22:48, Guo Ren 写道:
> On Fri, Oct 21, 2022 at 7:31 PM Tong Tiangen <tongtiangen@huawei.com> wrote:
>>
>> To follow the existing per-arch conventions, using "current_stack_pointer"
>> to set sp.
>>
>> This will let it be used in non-arch places(like HARDENED_USERCOPY).
>>
> 
> Add a Link tag here. The original patch series lore.kernel.org link.
> One tip: commit fdecfea09328b33fd08a4d418237cce9fd176d69 riscv: Rename
> "sp_in_global" to "current_stack_pointer"
> 
>      To follow the existing per-arch conventions, rename "sp_in_global" to
>      "current_stack_pointer". This will let it be used in non-arch places
>      (like HARDENED_USERCOPY).

Hi guo:

Ok, Will be added in v2.

Thanks.
Tong.

>> Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
>> ---
>>   arch/csky/Kconfig                 | 1 +
>>   arch/csky/include/asm/processor.h | 2 ++
>>   arch/csky/kernel/stacktrace.c     | 6 ++----
>>   3 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
>> index adee6ab36862..2236b5c0c213 100644
>> --- a/arch/csky/Kconfig
>> +++ b/arch/csky/Kconfig
>> @@ -9,6 +9,7 @@ config CSKY
>>          select ARCH_USE_BUILTIN_BSWAP
>>          select ARCH_USE_QUEUED_RWLOCKS
>>          select ARCH_USE_QUEUED_SPINLOCKS
>> +       select ARCH_HAS_CURRENT_STACK_POINTER
>>          select ARCH_INLINE_READ_LOCK if !PREEMPTION
>>          select ARCH_INLINE_READ_LOCK_BH if !PREEMPTION
>>          select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPTION
>> diff --git a/arch/csky/include/asm/processor.h b/arch/csky/include/asm/processor.h
>> index 63ad71fab30d..ea75d72dea86 100644
>> --- a/arch/csky/include/asm/processor.h
>> +++ b/arch/csky/include/asm/processor.h
>> @@ -84,4 +84,6 @@ unsigned long __get_wchan(struct task_struct *p);
>>
>>   #define cpu_relax() barrier()
>>
>> +register unsigned long current_stack_pointer __asm__("sp");
>> +
>>   #endif /* __ASM_CSKY_PROCESSOR_H */
>> diff --git a/arch/csky/kernel/stacktrace.c b/arch/csky/kernel/stacktrace.c
>> index 9f78f5d21511..27ecd63e321b 100644
>> --- a/arch/csky/kernel/stacktrace.c
>> +++ b/arch/csky/kernel/stacktrace.c
>> @@ -23,10 +23,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
>>                  sp = user_stack_pointer(regs);
>>                  pc = instruction_pointer(regs);
>>          } else if (task == NULL || task == current) {
>> -               const register unsigned long current_sp __asm__ ("sp");
>>                  const register unsigned long current_fp __asm__ ("r8");
>>                  fp = current_fp;
>> -               sp = current_sp;
>> +               sp = current_stack_pointer;
>>                  pc = (unsigned long)walk_stackframe;
>>          } else {
>>                  /* task blocked in __switch_to */
>> @@ -68,8 +67,7 @@ static void notrace walk_stackframe(struct task_struct *task,
>>                  sp = user_stack_pointer(regs);
>>                  pc = instruction_pointer(regs);
>>          } else if (task == NULL || task == current) {
>> -               const register unsigned long current_sp __asm__ ("sp");
>> -               sp = current_sp;
>> +               sp = current_stack_pointer;
>>                  pc = (unsigned long)walk_stackframe;
>>          } else {
>>                  /* task blocked in __switch_to */
>> --
>> 2.25.1
>>
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-21 15:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 11:56 [PATCH -next] csky: add arch support current_stack_pointer Tong Tiangen
2022-10-21 14:48 ` Guo Ren
2022-10-21 15:19   ` Tong Tiangen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®