* [PATCH v2] m68k: Fix task info flags handling for 68000
@ 2026-04-04 2:31 Daniel Palmer
2026-04-04 11:57 ` Greg Ungerer
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Palmer @ 2026-04-04 2:31 UTC (permalink / raw)
To: gerg, christoph.plattner
Cc: geert, linux-m68k, linux-kernel, sashal, Daniel Palmer
The logic for deciding what to do after a syscall should be checking
if any of the lower byte bits are set and then checking if the reschedule
bit is set.
Currently we are loading the top word, checking if any bits are set
(which never seems to be true) and thus jumping over loading the
whole long and checking if the reschedule bit is set.
We get the thread info in two places so split that logic out in
a macro and then fix the code so that it loads the byte of the flags
we need to check, checks if anything is set and then checks if
the reschedule bit in particular is set.
Reported-by: Christoph Plattner <christoph.plattner@gmx.at>
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
v2: Only load the lower byte of the flags as that's all we need.
This change was suggested by Greg and I tested it still works.
arch/m68k/68000/entry.S | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/arch/m68k/68000/entry.S b/arch/m68k/68000/entry.S
index 72e95663b62f..c257cc415c47 100644
--- a/arch/m68k/68000/entry.S
+++ b/arch/m68k/68000/entry.S
@@ -18,6 +18,13 @@
.text
+/* get thread_info pointer into a2 */
+ .macro getthreadinfo
+ movel %sp,%d1
+ andl #-THREAD_SIZE,%d1
+ movel %d1,%a2
+ .endm
+
.globl system_call
.globl resume
.globl ret_from_exception
@@ -70,9 +77,8 @@ ENTRY(system_call)
movel %sp@(PT_OFF_ORIG_D0),%d0
- movel %sp,%d1 /* get thread_info pointer */
- andl #-THREAD_SIZE,%d1
- movel %d1,%a2
+ /* Doing a trace ? */
+ getthreadinfo
btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
jne do_trace
cmpl #NR_syscalls,%d0
@@ -96,16 +102,15 @@ Luser_return:
/* heavy interrupt load*/
andw #ALLOWINT,%sr
- movel %sp,%d1 /* get thread_info pointer */
- andl #-THREAD_SIZE,%d1
- movel %d1,%a2
+ getthreadinfo
1:
- move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
+ /* check if any of the flags are set */
+ moveb %a2@(TINFO_FLAGS + 3),%d1 /* thread_info->flags (low 8 bits) */
jne Lwork_to_do
RESTORE_ALL
Lwork_to_do:
- movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
+ /* check if reschedule needs to be called */
btst #TIF_NEED_RESCHED,%d1
jne reschedule
--
2.51.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] m68k: Fix task info flags handling for 68000
2026-04-04 2:31 [PATCH v2] m68k: Fix task info flags handling for 68000 Daniel Palmer
@ 2026-04-04 11:57 ` Greg Ungerer
0 siblings, 0 replies; 2+ messages in thread
From: Greg Ungerer @ 2026-04-04 11:57 UTC (permalink / raw)
To: Daniel Palmer, christoph.plattner; +Cc: geert, linux-m68k, linux-kernel, sashal
Hi Daniel,
On 4/4/26 12:31, Daniel Palmer wrote:
> The logic for deciding what to do after a syscall should be checking
> if any of the lower byte bits are set and then checking if the reschedule
> bit is set.
>
> Currently we are loading the top word, checking if any bits are set
> (which never seems to be true) and thus jumping over loading the
> whole long and checking if the reschedule bit is set.
>
> We get the thread info in two places so split that logic out in
> a macro and then fix the code so that it loads the byte of the flags
> we need to check, checks if anything is set and then checks if
> the reschedule bit in particular is set.
>
> Reported-by: Christoph Plattner <christoph.plattner@gmx.at>
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
> ---
> v2: Only load the lower byte of the flags as that's all we need.
> This change was suggested by Greg and I tested it still works.
Thanks for taking care of this.
I have pushed into the m68knommu git tree for-next branch.
Regards
Greg
> arch/m68k/68000/entry.S | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/arch/m68k/68000/entry.S b/arch/m68k/68000/entry.S
> index 72e95663b62f..c257cc415c47 100644
> --- a/arch/m68k/68000/entry.S
> +++ b/arch/m68k/68000/entry.S
> @@ -18,6 +18,13 @@
>
> .text
>
> +/* get thread_info pointer into a2 */
> + .macro getthreadinfo
> + movel %sp,%d1
> + andl #-THREAD_SIZE,%d1
> + movel %d1,%a2
> + .endm
> +
> .globl system_call
> .globl resume
> .globl ret_from_exception
> @@ -70,9 +77,8 @@ ENTRY(system_call)
>
> movel %sp@(PT_OFF_ORIG_D0),%d0
>
> - movel %sp,%d1 /* get thread_info pointer */
> - andl #-THREAD_SIZE,%d1
> - movel %d1,%a2
> + /* Doing a trace ? */
> + getthreadinfo
> btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
> jne do_trace
> cmpl #NR_syscalls,%d0
> @@ -96,16 +102,15 @@ Luser_return:
> /* heavy interrupt load*/
> andw #ALLOWINT,%sr
>
> - movel %sp,%d1 /* get thread_info pointer */
> - andl #-THREAD_SIZE,%d1
> - movel %d1,%a2
> + getthreadinfo
> 1:
> - move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
> + /* check if any of the flags are set */
> + moveb %a2@(TINFO_FLAGS + 3),%d1 /* thread_info->flags (low 8 bits) */
> jne Lwork_to_do
> RESTORE_ALL
>
> Lwork_to_do:
> - movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
> + /* check if reschedule needs to be called */
> btst #TIF_NEED_RESCHED,%d1
> jne reschedule
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-04 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-04 2:31 [PATCH v2] m68k: Fix task info flags handling for 68000 Daniel Palmer
2026-04-04 11:57 ` Greg Ungerer
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®