All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Schmitz <schmitzmic@gmail.com>
To: linux-m68k@vger.kernel.org
Cc: geert@linux-m68k.org, uli@fpond.eu, fthain@linux-m68k.org,
	viro@zeniv.linux.org.uk, Michael Schmitz <schmitzmic@gmail.com>,
	stable@vger.kernel.org, cip-dev@lists.cip-project.org
Subject: [PATCH v3 1/8] m68k/mm: Adjust VM area to be unmapped by gap size for __iounmap()
Date: Wed,  7 Feb 2024 10:10:57 +1300	[thread overview]
Message-ID: <20240206211104.26421-2-schmitzmic@gmail.com> (raw)
In-Reply-To: <20240206211104.26421-1-schmitzmic@gmail.com>

commit 3f90f9ef2dda316d64e420d5d51ba369587ccc55 upstream.

If 020/030 support is enabled, get_io_area() leaves an IO_SIZE gap
between mappings which is added to the vm_struct representing the
mapping.  __ioremap() uses the actual requested size (after alignment),
while __iounmap() is passed the size from the vm_struct.

On 020/030, early termination descriptors are used to set up mappings of
extent 'size', which are validated on unmapping. The unmapped gap of
size IO_SIZE defeats the sanity check of the pmd tables, causing
__iounmap() to loop forever on 030.

On 040/060, unmapping of page table entries does not check for a valid
mapping, so the umapping loop always completes there.

Adjust size to be unmapped by the gap that had been added in the
vm_struct prior.

This fixes the hang in atari_platform_init() reported a long time ago,
and a similar one reported by Finn recently (addressed by removing
ioremap() use from the SWIM driver.

Tested on my Falcon in 030 mode - untested but should work the same on
040/060 (the extra page tables cleared there would never have been set
up anyway).

Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
[geert: Minor commit description improvements]
[geert: This was fixed in 2.4.23, but not in 2.5.x]
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable@vger.kernel.org
Cc: <cip-dev@lists.cip-project.org> # 4.4
---
 arch/m68k/mm/kmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index 6e4955bc542b..fcd52cefee29 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -88,7 +88,8 @@ static inline void free_io_area(void *addr)
 	for (p = &iolist ; (tmp = *p) ; p = &tmp->next) {
 		if (tmp->addr == addr) {
 			*p = tmp->next;
-			__iounmap(tmp->addr, tmp->size);
+			/* remove gap added in get_io_area() */
+			__iounmap(tmp->addr, tmp->size - IO_SIZE);
 			kfree(tmp);
 			return;
 		}
-- 
2.17.1


  reply	other threads:[~2024-02-06 21:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 21:10 [PATCH v3 0/8] m68k v4.4 backport fixes Michael Schmitz
2024-02-06 21:10 ` Michael Schmitz [this message]
2024-02-06 21:10 ` [PATCH v3 2/8] m68k: Only force 030 bus error if PC not in exception table Michael Schmitz
2024-02-06 21:10 ` [PATCH v3 3/8] m68k: include module.h to make use of exception handling in traps.c Michael Schmitz
2024-02-06 21:11 ` [PATCH v3 4/8] m68k: Handle arrivals of multiple signals correctly Michael Schmitz
2024-02-06 21:11 ` [PATCH v3 5/8] m68k: Update ->thread.esp0 before calling syscall_trace() in ret_from_signal Michael Schmitz
2024-02-06 21:11 ` [PATCH v3 6/8] m68k: Leave stack mangling to asm wrapper of sigreturn() Michael Schmitz
2024-02-06 21:11 ` [PATCH v3 7/8] m68k: fix livelock in uaccess Michael Schmitz
2024-02-06 21:11 ` [PATCH v3 8/8] m68k: Move signal frame following exception on 68020/030 Michael Schmitz
2024-02-06 21:15 ` [PATCH v3 0/8] m68k v4.4 backport fixes John Paul Adrian Glaubitz
2024-02-06 21:37   ` Michael Schmitz

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=20240206211104.26421-2-schmitzmic@gmail.com \
    --to=schmitzmic@gmail.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=fthain@linux-m68k.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=uli@fpond.eu \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.