x86/irq/32: Use named operands in inline asm
PATCH 1/5 x86/irq/32: Use named operands in inline asm
Also use inout "+" constraint modifier where appropriate.
--- arch/x86/kernel/irq_32.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
arch/x86/kernel/irq_32.c +9 -11
@@ -54,12 +54,11 @@ static inline void print_stack_overflow(void) { }static void call_on_stack (void *func,void *stack) { - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=b" (stack) - :"0" (stack), - [thunk_target]"D" (func) +"movl %[sp], %%esp" + : [sp]"+b" (stack) + : [thunk_target]"D" (func) :"memory" ,"cc" ,"edx" ,"ecx" ,"eax" ); }
@@ -71,7 +70,7 @@ static inline void *current_stack(void)static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk; -u32 *isp, *prev_esp, arg1; +u32 *isp, *prev_esp; curstk = (struct irq_stack *)current_stack (); irqstk =__this_cpu_read (pcpu_hot.hardirq_stack_ptr);
@@ -94,12 +93,11 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)if (unlikely (overflow))call_on_stack (print_stack_overflow, isp); - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=a" (arg1),"=b" (isp) - :"0" (desc),"1" (isp), - [thunk_target]"D" (desc->handle_irq) +"movl %[sp], %%esp" + :"+a" (desc), [sp]"+b" (isp) + : [thunk_target]"D" (desc->handle_irq) :"memory" ,"cc" ,"ecx" );return 1 ; }
Signature · 1 line
2.42.0
PATCH 2/5 x86/irq/32: Add missing clobber to inline asm
i386 ABI declares %edx as a call-clobbered register.
--- arch/x86/kernel/irq_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/irq_32.c +1 -1
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) "movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) - : "memory", "cc", "ecx"); + : "memory", "cc", "edx", "ecx");return 1 ; }
Signature · 1 line
2.42.0
[tip: x86/asm] x86/irq/32: Add missing clobber to inline asm
The following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 553d9797b9a161ae98072250bbe7ba4cec03cb87 Gitweb: https://git.kernel.org/tip/553d9797b9a161ae98072250bbe7ba4cec03cb87 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:22 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 10:53:51 +01:00
x86/irq/32: Add missing clobber to inline asm
i386 ABI declares %edx as a call-clobbered register.
--- arch/x86/kernel/irq_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/irq_32.c +1 -1
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) "movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) - : "memory", "cc", "ecx"); + : "memory", "cc", "edx", "ecx");return 1 ; }
[tip: x86/asm] x86/irq/32: Add missing clobber to inline asm
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 40d9cd9bb08cbe36900efd1600e2228698d52b4a Gitweb: https://git.kernel.org/tip/40d9cd9bb08cbe36900efd1600e2228698d52b4a Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:22 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 11:21:40 +01:00
x86/irq/32: Add missing clobber to inline asm
i386 ABI declares %edx as a call-clobbered register.
--- arch/x86/kernel/irq_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/irq_32.c +1 -1
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) "movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) - : "memory", "cc", "ecx"); + : "memory", "cc", "edx", "ecx");return 1 ; }
[tip: x86/asm] x86/irq/32: Add missing clobber to inline asm
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 76f71137811a6dfa52b3e22a86a772e5753021d3 Gitweb: https://git.kernel.org/tip/76f71137811a6dfa52b3e22a86a772e5753021d3 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:22 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 20:12:40 +01:00
x86/irq/32: Add missing clobber to inline asm
i386 ABI declares %edx as a call-clobbered register.
--- arch/x86/kernel/irq_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/irq_32.c +1 -1
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) "movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) - : "memory", "cc", "ecx"); + : "memory", "cc", "edx", "ecx");return 1 ; }
PATCH 3/5 x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
In reply to Uros BizjakThis constraint should be used for any inline asm which has a CALL instruction, otherwise the compiler may schedule the asm before the frame pointer gets set up by the containing function, causing objtool to print a "call without frame pointer save/setup" warning.
--- arch/x86/kernel/irq_32.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/irq_32.c +2 -0
@@ -59,6 +59,7 @@ static void call_on_stack(void *func, void *stack)"movl %[sp], %%esp" : [sp] "+b" (stack) : [thunk_target] "D" (func) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx", "eax"); }
@@ -98,6 +99,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)"movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx");return 1 ; }
Signature · 1 line
2.42.0
[tip: x86/asm] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
The following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 94770fe8648b80ee7ec4484e43b2381a25b62746 Gitweb: https://git.kernel.org/tip/94770fe8648b80ee7ec4484e43b2381a25b62746 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:23 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 10:53:51 +01:00
x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
This constraint should be used for any inline asm which has a CALL instruction, otherwise the compiler may schedule the asm before the frame pointer gets set up by the containing function, causing objtool to print a "call without frame pointer save/setup" warning.
--- arch/x86/kernel/irq_32.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/irq_32.c +2 -0
@@ -59,6 +59,7 @@ static void call_on_stack(void *func, void *stack)"movl %[sp], %%esp" : [sp] "+b" (stack) : [thunk_target] "D" (func) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx", "eax"); }
@@ -98,6 +99,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)"movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx");return 1 ; }
[tip: x86/asm] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 4d93ca6d7e92584c559d8687ac9eef15251bb97b Gitweb: https://git.kernel.org/tip/4d93ca6d7e92584c559d8687ac9eef15251bb97b Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:23 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 11:21:40 +01:00
x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
This constraint should be used for any inline asm which has a CALL instruction, otherwise the compiler may schedule the asm before the frame pointer gets set up by the containing function, causing objtool to print a "call without frame pointer save/setup" warning.
--- arch/x86/kernel/irq_32.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/irq_32.c +2 -0
@@ -59,6 +59,7 @@ static void call_on_stack(void *func, void *stack)"movl %[sp], %%esp" : [sp] "+b" (stack) : [thunk_target] "D" (func) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx", "eax"); }
@@ -98,6 +99,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)"movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx");return 1 ; }
kernel test robot
build botRe: [PATCH -tip 3/5] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
In reply to Uros Bizjakkernel test robot noticed the following build errors:
Hi Uros,
kernel test robot noticed the following build errors:
[auto build test ERROR on tip/x86/core]
[also build test ERROR on tip/auto-latest linus/master v6.14-rc5 next-20250304] [cannot apply to tip/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-irq-32-Add-missing-clobber-to-inline-asm/20250303-235755 base: tip/x86/core patch link: https://lore.kernel.org/r/20250303155446.112769-3-ubizjak%40gmail.com patch subject: [PATCH -tip 3/5] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC config: i386-buildonly-randconfig-003-20250304 (https://download.01.org/0day-ci/archive/20250305/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250305/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
arch/x86/kernel/irq_32.c: In function 'call_on_stack':
>> arch/x86/kernel/irq_32.c:62:24: error: expected ':' or ')' before 'COMMA'
62 | COMMA(ASM_CALL_CONSTRAINT)
| ^~~~~
arch/x86/kernel/irq_32.c: In function 'execute_on_irq_stack':
arch/x86/kernel/irq_32.c:102:24: error: expected ':' or ')' before 'COMMA'
102 | COMMA(ASM_CALL_CONSTRAINT)
| ^~~~~vim +62 arch/x86/kernel/irq_32.c
54
55 static void call_on_stack(void *func, void *stack)
56 {
57 asm volatile("xchgl %[sp], %%esp\n"
58 CALL_NOSPEC
59 "movl %[sp], %%esp"
60 : [sp] "+b" (stack)
61 : [thunk_target] "D" (func)
> 62 COMMA(ASM_CALL_CONSTRAINT)
63 : "memory", "cc", "edx", "ecx", "eax");
64 }
65 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Uros Bizjak
AppliedRe: [PATCH -tip 3/5] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
Quoted 12 lines · kernel test robot
Hi Uros,
kernel test robot noticed the following build errors:
[auto build test ERROR on tip/x86/core]
[also build test ERROR on tip/auto-latest linus/master v6.14-rc5 next-20250304] [cannot apply to tip/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
Quoted 2 lines
url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-irq-32-Add-missing-clobber-to-inline-asm/20250303-235755 base: tip/x86/core
This patch was applied to the wrong tree, where COMMA was not yet defined. It works OK in the current -tip tree.
Uros.
kernel test robot
build botRe: [PATCH -tip 3/5] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
In reply to Uros Bizjakkernel test robot noticed the following build errors:
Hi Uros,
kernel test robot noticed the following build errors:
[auto build test ERROR on tip/x86/core]
[also build test ERROR on tip/auto-latest linus/master v6.14-rc5 next-20250304] [cannot apply to tip/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/x86-irq-32-Add-missing-clobber-to-inline-asm/20250303-235755 base: tip/x86/core patch link: https://lore.kernel.org/r/20250303155446.112769-3-ubizjak%40gmail.com patch subject: [PATCH -tip 3/5] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC config: i386-buildonly-randconfig-001-20250304 (https://download.01.org/0day-ci/archive/20250305/[email protected]/config) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250305/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> arch/x86/kernel/irq_32.c:62:10: error: expected ')'
62 | COMMA(ASM_CALL_CONSTRAINT)
| ^
arch/x86/kernel/irq_32.c:102:10: error: expected ')'
102 | COMMA(ASM_CALL_CONSTRAINT)
| ^2 errors generated.
vim +62 arch/x86/kernel/irq_32.c
54
55 static void call_on_stack(void *func, void *stack)
56 {
57 asm volatile("xchgl %[sp], %%esp\n"
58 CALL_NOSPEC
59 "movl %[sp], %%esp"
60 : [sp] "+b" (stack)
61 : [thunk_target] "D" (func)
> 62 COMMA(ASM_CALL_CONSTRAINT)
63 : "memory", "cc", "edx", "ecx", "eax");
64 }
65 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
[tip: x86/asm] x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 784af8f453fddec902639f42e2456f7fb5199450 Gitweb: https://git.kernel.org/tip/784af8f453fddec902639f42e2456f7fb5199450 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:23 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 20:12:40 +01:00
x86/irq/32: Add ASM_CALL_CONSTRAINT to inline asm using CALL_NOSPEC
This constraint should be used for any inline asm which has a CALL instruction, otherwise the compiler may schedule the asm before the frame pointer gets set up by the containing function, causing objtool to print a "call without frame pointer save/setup" warning.
--- arch/x86/kernel/irq_32.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/irq_32.c +2 -0
@@ -59,6 +59,7 @@ static void call_on_stack(void *func, void *stack)"movl %[sp], %%esp" : [sp] "+b" (stack) : [thunk_target] "D" (func) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx", "eax"); }
@@ -98,6 +99,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)"movl %[sp], %%esp" : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) +COMMA (ASM_CALL_CONSTRAINT ) : "memory", "cc", "edx", "ecx");return 1 ; }
PATCH 4/5 x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
In reply to Uros BizjakMake code more readable by using current_stack_pointer global variable.
--- arch/x86/kernel/irq_32.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/irq_32.c +1 -4
@@ -31,10 +31,7 @@ int sysctl_panic_on_stackoverflow __read_mostly;/* Debugging check for stack overflow: is there less than 1KB free? */ static int check_stack_overflow (void ) { -long sp; - - __asm__ __volatile__("andl %%esp,%0" : -"=r" (sp) :"0" (THREAD_SIZE -1 )); +unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );return sp < (sizeof (struct thread_info ) +STACK_WARN ); }
Signature · 1 line
2.42.0
[tip: x86/asm] x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
The following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 70e8a96f5408e409dc71b08a366d6d705e9d9fb8 Gitweb: https://git.kernel.org/tip/70e8a96f5408e409dc71b08a366d6d705e9d9fb8 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:24 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 10:53:51 +01:00
x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
Make code more readable by using the 'current_stack_pointer' global variable.
--- arch/x86/kernel/irq_32.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/irq_32.c +1 -4
@@ -31,10 +31,7 @@ int sysctl_panic_on_stackoverflow __read_mostly;/* Debugging check for stack overflow: is there less than 1KB free? */ static int check_stack_overflow (void ) { -long sp; - - __asm__ __volatile__("andl %%esp,%0" : -"=r" (sp) :"0" (THREAD_SIZE -1 )); +unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );return sp < (sizeof (struct thread_info ) +STACK_WARN ); }
[tip: x86/asm] x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 9266be1052e0586ea932011ad671beefbaff1a64 Gitweb: https://git.kernel.org/tip/9266be1052e0586ea932011ad671beefbaff1a64 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:24 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 11:21:40 +01:00
x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
Make code more readable by using the 'current_stack_pointer' global variable.
--- arch/x86/kernel/irq_32.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/irq_32.c +1 -4
@@ -31,10 +31,7 @@ int sysctl_panic_on_stackoverflow __read_mostly;/* Debugging check for stack overflow: is there less than 1KB free? */ static int check_stack_overflow (void ) { -long sp; - - __asm__ __volatile__("andl %%esp,%0" : -"=r" (sp) :"0" (THREAD_SIZE -1 )); +unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );return sp < (sizeof (struct thread_info ) +STACK_WARN ); }
[tip: x86/asm] x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 1aee47babaa440b92314199963c5ed3395dc4edb Gitweb: https://git.kernel.org/tip/1aee47babaa440b92314199963c5ed3395dc4edb Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:24 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 20:12:40 +01:00
x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
Make code more readable by using the 'current_stack_pointer' global variable.
--- arch/x86/kernel/irq_32.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/irq_32.c +1 -4
@@ -31,10 +31,7 @@ int sysctl_panic_on_stackoverflow __read_mostly;/* Debugging check for stack overflow: is there less than 1KB free? */ static int check_stack_overflow (void ) { -long sp; - - __asm__ __volatile__("andl %%esp,%0" : -"=r" (sp) :"0" (THREAD_SIZE -1 )); +unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );return sp < (sizeof (struct thread_info ) +STACK_WARN ); }
[tip: x86/asm] x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: d4432fb5b8798a7663974bed277a8a6e330a50d8 Gitweb: https://git.kernel.org/tip/d4432fb5b8798a7663974bed277a8a6e330a50d8 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:24 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 20:28:58 +01:00
x86/irq/32: Use current_stack_pointer to avoid asm() in check_stack_overflow()
Make code more readable by using the 'current_stack_pointer' global variable.
--- arch/x86/kernel/irq_32.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/irq_32.c +1 -4
@@ -31,10 +31,7 @@ int sysctl_panic_on_stackoverflow __read_mostly;/* Debugging check for stack overflow: is there less than 1KB free? */ static int check_stack_overflow (void ) { -long sp; - - __asm__ __volatile__("andl %%esp,%0" : -"=r" (sp) :"0" (THREAD_SIZE -1 )); +unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );return sp < (sizeof (struct thread_info ) +STACK_WARN ); }
PATCH 5/5 x86/irq/32: Change some static functions to bool
In reply to Uros BizjakThe return values of some functions are of boolean type. Change the type of these function to bool and adjust their return values.
--- arch/x86/kernel/irq_32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/irq_32.c +6 -6
@@ -29,7 +29,7 @@int sysctl_panic_on_stackoverflow__read_mostly ;/* Debugging check for stack overflow: is there less than 1KB free? */ -static int check_stack_overflow (void ) +static bool check_stack_overflow (void ) {unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );
@@ -45,7 +45,7 @@ static void print_stack_overflow(void) }#else -static inline int check_stack_overflow (void ) {return 0 ; } +static inline bool check_stack_overflow (void ) {return false; }static inline void print_stack_overflow (void ) { }#endif
@@ -65,7 +65,7 @@ static inline void *current_stack(void)return (void *)(current_stack_pointer & ~(THREAD_SIZE -1 )); } -static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) +static inline bool execute_on_irq_stack (bool overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk;u32 *isp, *prev_esp;
@@ -80,7 +80,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)* current stack (which is the irq stack already after all) */ if (unlikely (curstk == irqstk)) -return 0 ; +return false; isp = (u32 *) ((char *)irqstk +sizeof (*irqstk));
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) : [thunk_target] "D" (desc->handle_irq) COMMA(ASM_CALL_CONSTRAINT) : "memory", "cc", "edx", "ecx"); -return 1 ; +return true; }/*
@@ -147,7 +147,7 @@ void do_softirq_own_stack(void)void __handle_irq (struct irq_desc *desc,struct pt_regs *regs) { -int overflow =check_stack_overflow (); +bool overflow =check_stack_overflow ();if (user_mode (regs) || !execute_on_irq_stack (overflow, desc)) {if (unlikely (overflow))
Signature · 1 line
2.42.0
[tip: x86/asm] x86/irq/32: Change some static functions to bool
The following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 45f6469225e8da92ff1e5ec1027431053ba397c0 Gitweb: https://git.kernel.org/tip/45f6469225e8da92ff1e5ec1027431053ba397c0 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:25 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 10:53:52 +01:00
x86/irq/32: Change some static functions to bool
The return values of these functions is 0/1, but they use an int type instead of bool:
check_stack_overflow()
execute_on_irq_stack()
Change the type of these function to bool and adjust their return values and affected helper variables.
[ mingo: Rewrote the changelog ]
--- arch/x86/kernel/irq_32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/irq_32.c +6 -6
@@ -29,7 +29,7 @@int sysctl_panic_on_stackoverflow__read_mostly ;/* Debugging check for stack overflow: is there less than 1KB free? */ -static int check_stack_overflow (void ) +static bool check_stack_overflow (void ) {unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );
@@ -45,7 +45,7 @@ static void print_stack_overflow(void) }#else -static inline int check_stack_overflow (void ) {return 0 ; } +static inline bool check_stack_overflow (void ) {return false; }static inline void print_stack_overflow (void ) { }#endif
@@ -65,7 +65,7 @@ static inline void *current_stack(void)return (void *)(current_stack_pointer & ~(THREAD_SIZE -1 )); } -static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) +static inline bool execute_on_irq_stack (bool overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk;u32 *isp, *prev_esp;
@@ -80,7 +80,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)* current stack (which is the irq stack already after all) */ if (unlikely (curstk == irqstk)) -return 0 ; +return false; isp = (u32 *) ((char *)irqstk +sizeof (*irqstk));
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) : [thunk_target] "D" (desc->handle_irq) COMMA(ASM_CALL_CONSTRAINT) : "memory", "cc", "edx", "ecx"); -return 1 ; +return true; }/*
@@ -147,7 +147,7 @@ void do_softirq_own_stack(void)void __handle_irq (struct irq_desc *desc,struct pt_regs *regs) { -int overflow =check_stack_overflow (); +bool overflow =check_stack_overflow ();if (user_mode (regs) || !execute_on_irq_stack (overflow, desc)) {if (unlikely (overflow))
[tip: x86/asm] x86/irq/32: Change some static functions to bool
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 7b52de3a2811bf16f52b895478920113e1b39878 Gitweb: https://git.kernel.org/tip/7b52de3a2811bf16f52b895478920113e1b39878 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:25 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 11:21:40 +01:00
x86/irq/32: Change some static functions to bool
The return values of these functions is 0/1, but they use an int type instead of bool:
check_stack_overflow()
execute_on_irq_stack()
Change the type of these function to bool and adjust their return values and affected helper variables.
[ mingo: Rewrote the changelog ]
--- arch/x86/kernel/irq_32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/irq_32.c +6 -6
@@ -29,7 +29,7 @@int sysctl_panic_on_stackoverflow__read_mostly ;/* Debugging check for stack overflow: is there less than 1KB free? */ -static int check_stack_overflow (void ) +static bool check_stack_overflow (void ) {unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );
@@ -45,7 +45,7 @@ static void print_stack_overflow(void) }#else -static inline int check_stack_overflow (void ) {return 0 ; } +static inline bool check_stack_overflow (void ) {return false; }static inline void print_stack_overflow (void ) { }#endif
@@ -65,7 +65,7 @@ static inline void *current_stack(void)return (void *)(current_stack_pointer & ~(THREAD_SIZE -1 )); } -static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) +static inline bool execute_on_irq_stack (bool overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk;u32 *isp, *prev_esp;
@@ -80,7 +80,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)* current stack (which is the irq stack already after all) */ if (unlikely (curstk == irqstk)) -return 0 ; +return false; isp = (u32 *) ((char *)irqstk +sizeof (*irqstk));
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) : [thunk_target] "D" (desc->handle_irq) COMMA(ASM_CALL_CONSTRAINT) : "memory", "cc", "edx", "ecx"); -return 1 ; +return true; }/*
@@ -147,7 +147,7 @@ void do_softirq_own_stack(void)void __handle_irq (struct irq_desc *desc,struct pt_regs *regs) { -int overflow =check_stack_overflow (); +bool overflow =check_stack_overflow ();if (user_mode (regs) || !execute_on_irq_stack (overflow, desc)) {if (unlikely (overflow))
[tip: x86/asm] x86/irq/32: Change some static functions to bool
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 9c5f9473dfa0b13af72b8f856e2c87d36acaed90 Gitweb: https://git.kernel.org/tip/9c5f9473dfa0b13af72b8f856e2c87d36acaed90 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:25 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 20:12:40 +01:00
x86/irq/32: Change some static functions to bool
The return values of these functions is 0/1, but they use an int type instead of bool:
check_stack_overflow()
execute_on_irq_stack()
Change the type of these function to bool and adjust their return values and affected helper variables.
[ mingo: Rewrote the changelog ]
--- arch/x86/kernel/irq_32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/irq_32.c +6 -6
@@ -29,7 +29,7 @@int sysctl_panic_on_stackoverflow__read_mostly ;/* Debugging check for stack overflow: is there less than 1KB free? */ -static int check_stack_overflow (void ) +static bool check_stack_overflow (void ) {unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );
@@ -45,7 +45,7 @@ static void print_stack_overflow(void) }#else -static inline int check_stack_overflow (void ) {return 0 ; } +static inline bool check_stack_overflow (void ) {return false; }static inline void print_stack_overflow (void ) { }#endif
@@ -65,7 +65,7 @@ static inline void *current_stack(void)return (void *)(current_stack_pointer & ~(THREAD_SIZE -1 )); } -static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) +static inline bool execute_on_irq_stack (bool overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk;u32 *isp, *prev_esp;
@@ -80,7 +80,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)* current stack (which is the irq stack already after all) */ if (unlikely (curstk == irqstk)) -return 0 ; +return false; isp = (u32 *) ((char *)irqstk +sizeof (*irqstk));
@@ -98,7 +98,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) : [thunk_target] "D" (desc->handle_irq) COMMA(ASM_CALL_CONSTRAINT) : "memory", "cc", "edx", "ecx"); -return 1 ; +return true; }/*
@@ -147,7 +147,7 @@ void do_softirq_own_stack(void)void __handle_irq (struct irq_desc *desc,struct pt_regs *regs) { -int overflow =check_stack_overflow (); +bool overflow =check_stack_overflow ();if (user_mode (regs) || !execute_on_irq_stack (overflow, desc)) {if (unlikely (overflow))
[tip: x86/asm] x86/irq/32: Change some static functions to bool
In reply to Uros BizjakThe following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: c8b584fe82d0f1e478a598f954943b095a4a8f5c Gitweb: https://git.kernel.org/tip/c8b584fe82d0f1e478a598f954943b095a4a8f5c Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:25 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 20:28:58 +01:00
x86/irq/32: Change some static functions to bool
The return values of these functions is 0/1, but they use an int type instead of bool:
check_stack_overflow()
execute_on_irq_stack()
Change the type of these function to bool and adjust their return values and affected helper variables.
[ mingo: Rewrote the changelog ]
--- arch/x86/kernel/irq_32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/irq_32.c +6 -6
@@ -29,7 +29,7 @@int sysctl_panic_on_stackoverflow__read_mostly ;/* Debugging check for stack overflow: is there less than 1KB free? */ -static int check_stack_overflow (void ) +static bool check_stack_overflow (void ) {unsigned long sp = current_stack_pointer & (THREAD_SIZE -1 );
@@ -45,7 +45,7 @@ static void print_stack_overflow(void) }#else -static inline int check_stack_overflow (void ) {return 0 ; } +static inline bool check_stack_overflow (void ) {return false; }static inline void print_stack_overflow (void ) { }#endif
@@ -64,7 +64,7 @@ static inline void *current_stack(void)return (void *)(current_stack_pointer & ~(THREAD_SIZE -1 )); } -static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) +static inline bool execute_on_irq_stack (bool overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk;u32 *isp, *prev_esp;
@@ -79,7 +79,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)* current stack (which is the irq stack already after all) */ if (unlikely (curstk == irqstk)) -return 0 ; +return false; isp = (u32 *) ((char *)irqstk +sizeof (*irqstk));
@@ -96,7 +96,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc) : "+a" (desc), [sp] "+b" (isp) : [thunk_target] "D" (desc->handle_irq) : "memory", "cc", "edx", "ecx"); -return 1 ; +return true; }/*
@@ -145,7 +145,7 @@ void do_softirq_own_stack(void)void __handle_irq (struct irq_desc *desc,struct pt_regs *regs) { -int overflow =check_stack_overflow (); +bool overflow =check_stack_overflow ();if (user_mode (regs) || !execute_on_irq_stack (overflow, desc)) {if (unlikely (overflow))
The following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 3fc50ac7607a18a60207901ad1604dae9b52701b Gitweb: https://git.kernel.org/tip/3fc50ac7607a18a60207901ad1604dae9b52701b Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:21 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 10:53:51 +01:00
x86/irq/32: Use named operands in inline asm
Also use inout "+" constraint modifier where appropriate.
--- arch/x86/kernel/irq_32.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
arch/x86/kernel/irq_32.c +9 -11
@@ -54,12 +54,11 @@ static inline void print_stack_overflow(void) { }static void call_on_stack (void *func,void *stack) { - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=b" (stack) - :"0" (stack), - [thunk_target]"D" (func) +"movl %[sp], %%esp" + : [sp]"+b" (stack) + : [thunk_target]"D" (func) :"memory" ,"cc" ,"edx" ,"ecx" ,"eax" ); }
@@ -71,7 +70,7 @@ static inline void *current_stack(void)static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk; -u32 *isp, *prev_esp, arg1; +u32 *isp, *prev_esp; curstk = (struct irq_stack *)current_stack (); irqstk =__this_cpu_read (pcpu_hot.hardirq_stack_ptr);
@@ -94,12 +93,11 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)if (unlikely (overflow))call_on_stack (print_stack_overflow, isp); - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=a" (arg1),"=b" (isp) - :"0" (desc),"1" (isp), - [thunk_target]"D" (desc->handle_irq) +"movl %[sp], %%esp" + :"+a" (desc), [sp]"+b" (isp) + : [thunk_target]"D" (desc->handle_irq) :"memory" ,"cc" ,"ecx" );return 1 ; }
The following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: df682f7b763e8d983ef70c4908f8980a2ffc81cd Gitweb: https://git.kernel.org/tip/df682f7b763e8d983ef70c4908f8980a2ffc81cd Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:21 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 11:21:40 +01:00
x86/irq/32: Use named operands in inline asm
Also use inout "+" constraint modifier where appropriate.
--- arch/x86/kernel/irq_32.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
arch/x86/kernel/irq_32.c +9 -11
@@ -54,12 +54,11 @@ static inline void print_stack_overflow(void) { }static void call_on_stack (void *func,void *stack) { - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=b" (stack) - :"0" (stack), - [thunk_target]"D" (func) +"movl %[sp], %%esp" + : [sp]"+b" (stack) + : [thunk_target]"D" (func) :"memory" ,"cc" ,"edx" ,"ecx" ,"eax" ); }
@@ -71,7 +70,7 @@ static inline void *current_stack(void)static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk; -u32 *isp, *prev_esp, arg1; +u32 *isp, *prev_esp; curstk = (struct irq_stack *)current_stack (); irqstk =__this_cpu_read (pcpu_hot.hardirq_stack_ptr);
@@ -94,12 +93,11 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)if (unlikely (overflow))call_on_stack (print_stack_overflow, isp); - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=a" (arg1),"=b" (isp) - :"0" (desc),"1" (isp), - [thunk_target]"D" (desc->handle_irq) +"movl %[sp], %%esp" + :"+a" (desc), [sp]"+b" (isp) + : [thunk_target]"D" (desc->handle_irq) :"memory" ,"cc" ,"ecx" );return 1 ; }
The following commit has been merged into the x86/asm branch of tip:
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: 0ec914707c3ed052ed26eb88f9300109030a7fb2 Gitweb: https://git.kernel.org/tip/0ec914707c3ed052ed26eb88f9300109030a7fb2 Author: Uros Bizjak <[email protected]> AuthorDate: Mon, 03 Mar 2025 16:54:21 +01:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Tue, 04 Mar 2025 20:12:40 +01:00
x86/irq/32: Use named operands in inline asm
Also use inout "+" constraint modifier where appropriate.
--- arch/x86/kernel/irq_32.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
arch/x86/kernel/irq_32.c +9 -11
@@ -54,12 +54,11 @@ static inline void print_stack_overflow(void) { }static void call_on_stack (void *func,void *stack) { - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=b" (stack) - :"0" (stack), - [thunk_target]"D" (func) +"movl %[sp], %%esp" + : [sp]"+b" (stack) + : [thunk_target]"D" (func) :"memory" ,"cc" ,"edx" ,"ecx" ,"eax" ); }
@@ -71,7 +70,7 @@ static inline void *current_stack(void)static inline int execute_on_irq_stack (int overflow,struct irq_desc *desc) {struct irq_stack *curstk, *irqstk; -u32 *isp, *prev_esp, arg1; +u32 *isp, *prev_esp; curstk = (struct irq_stack *)current_stack (); irqstk =__this_cpu_read (pcpu_hot.hardirq_stack_ptr);
@@ -94,12 +93,11 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)if (unlikely (overflow))call_on_stack (print_stack_overflow, isp); - asmvolatile ("xchgl %%ebx,%%esp \n" + asmvolatile ("xchgl %[sp], %%esp\n" CALL_NOSPEC -"movl %%ebx,%%esp \n" - :"=a" (arg1),"=b" (isp) - :"0" (desc),"1" (isp), - [thunk_target]"D" (desc->handle_irq) +"movl %[sp], %%esp" + :"+a" (desc), [sp]"+b" (isp) + : [thunk_target]"D" (desc->handle_irq) :"memory" ,"cc" ,"ecx" );return 1 ; }