QEMU-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@kernel.org>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@gmail.com>
Cc: "Yoshinori Sato" <yoshinori.sato@nifty.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Helge Deller" <deller@gmx.de>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Matt Turner" <mattst88@gmail.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"John Paul Adrian Glaubitz" <glaubitz@physik.fu-berlin.de>
Subject: [PULL 3/3] linux-user/sh4: allow full 32-bit address space
Date: Tue, 28 Jul 2026 11:16:33 +0200	[thread overview]
Message-ID: <20260728091633.29765-4-deller@kernel.org> (raw)
In-Reply-To: <20260728091633.29765-1-deller@kernel.org>

From: Laurent Vivier <laurent@vivier.eu>

On real SH4 hardware, the address space is split between user mode
(U0, 0x00000000-0x7fffffff) and kernel mode (P1-P4, 0x80000000-0xffffffff),
so TARGET_VIRT_ADDR_SPACE_BITS was set to 31 for CONFIG_USER_ONLY.

However, qemu-user does not emulate the MMU, so this limit is not needed.
The only effect is to restrict reserved_va to 2 GB, causing OOM failures
for memory-intensive builds (e.g. webkit2gtk on Debian sh4 buildds).

Set TARGET_VIRT_ADDR_SPACE_BITS to 32 unconditionally, like most other
32-bit targets. Also fix the TASK_UNMAPPED_BASE macro to use 1ull instead
of 1u to avoid undefined behavior when shifting by 32.

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/sh4/target_mman.h | 2 +-
 target/sh4/cpu-param.h       | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/linux-user/sh4/target_mman.h b/linux-user/sh4/target_mman.h
index dd9016081e..2d05837c2f 100644
--- a/linux-user/sh4/target_mman.h
+++ b/linux-user/sh4/target_mman.h
@@ -1,6 +1,6 @@
 /* arch/sh/include/asm/processor_32.h */
 #define TASK_UNMAPPED_BASE \
-    TARGET_PAGE_ALIGN((1u << TARGET_VIRT_ADDR_SPACE_BITS) / 3)
+    TARGET_PAGE_ALIGN((1ull << TARGET_VIRT_ADDR_SPACE_BITS) / 3)
 
 /* arch/sh/include/asm/elf.h */
 #define ELF_ET_DYN_BASE       (TASK_UNMAPPED_BASE * 2)
diff --git a/target/sh4/cpu-param.h b/target/sh4/cpu-param.h
index c3b8114e53..9d72e35e31 100644
--- a/target/sh4/cpu-param.h
+++ b/target/sh4/cpu-param.h
@@ -9,10 +9,8 @@
 #define SH4_CPU_PARAM_H
 
 #define TARGET_PAGE_BITS 12  /* 4k */
-#ifdef CONFIG_USER_ONLY
-# define TARGET_VIRT_ADDR_SPACE_BITS 31
-#else
-# define TARGET_VIRT_ADDR_SPACE_BITS 32
-#endif
+
+/* qemu-user does not emulate the MMU, so no need to limit to 31 bits. */
+#define TARGET_VIRT_ADDR_SPACE_BITS 32
 
 #endif
-- 
2.54.0



  parent reply	other threads:[~2026-07-28  9:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  9:16 [PULL 0/3] Linux user patches Helge Deller
2026-07-28  9:16 ` [PULL 1/3] linux-user: Guard local FUTEX_CMD_MASK definition Helge Deller
2026-07-28  9:16 ` [PULL 2/3] linux-user: fix guards for the fsmount(2) syscall series Helge Deller
2026-07-28  9:16 ` Helge Deller [this message]
2026-07-28 15:31 ` [PULL 0/3] Linux user patches Stefan Hajnoczi

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=20260728091633.29765-4-deller@kernel.org \
    --to=deller@kernel.org \
    --cc=clg@redhat.com \
    --cc=deller@gmx.de \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=laurent@vivier.eu \
    --cc=mattst88@gmail.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=yoshinori.sato@nifty.com \
    /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