public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Daniel Palmer <daniel@0x0f.com>
To: gerg@linux-m68k.org, geert@linux-m68k.org,
	christoph.plattner@gmx.at, linux-m68k@lists.linux-m68k.org
Cc: sashal@kernel.org, Daniel Palmer <daniel@0x0f.com>
Subject: [PATCH] m68k: Fix task info flags handling for 68000
Date: Thu, 12 Mar 2026 20:58:32 +0900	[thread overview]
Message-ID: <20260312115832.835968-1-daniel@0x0f.com> (raw)

The logic for deciding what to do after a syscall should be checking
if any of the lower word 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 just loads the whole
of the flags, 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>
---

I have had a variation of this patch for ages and haven't
gotten around to sending it. Christoph e-mailed us (Greg, Sasha and me)
to report this issue with a similar patch. Apparently this is an
issue all the way back to 5.15.

Christoph, can you check this works for you? I took this out of my
personal branch and made sure it built but I have a bunch of other
junk I need to actually boot it on the things I have.

 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..cd193fd34c19 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 */
+	movel	%a2@(TINFO_FLAGS),%d1	/* thread_info->flags */
 	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


             reply	other threads:[~2026-03-12 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 11:58 Daniel Palmer [this message]
2026-03-12 18:25 ` [PATCH] m68k: Fix task info flags handling for 68000 christoph.plattner
2026-03-16 14:08 ` Greg Ungerer
2026-03-16 22:05   ` Daniel Palmer
2026-03-25 11:25     ` Greg Ungerer
2026-03-30 22:09       ` Daniel Palmer
2026-03-31 12:09         ` Greg Ungerer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260312115832.835968-1-daniel@0x0f.com \
    --to=daniel@0x0f.com \
    --cc=christoph.plattner@gmx.at \
    --cc=geert@linux-m68k.org \
    --cc=gerg@linux-m68k.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=sashal@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox