From: Miao Wang <shankerwangmiao@gmail.com>
Hard coding PAGE_SIZE to 4K will prevent user-only emulation from
working on hosts with 16K page size.
Fixes: 1d832c19db1e ("target/loongarch: Support 4K page size")
Fixes: qemu-project/qemu#3651
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
---
target/loongarch/cpu-param.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/target/loongarch/cpu-param.h b/target/loongarch/cpu-param.h
index 3bcf77b3755abdc302699c22c7aa99e2e8c3bbf3..6abe72ff5cab46e246fde4fa76bce05ba7c1cd20 100644
--- a/target/loongarch/cpu-param.h
+++ b/target/loongarch/cpu-param.h
@@ -10,6 +10,11 @@
#define TARGET_VIRT_ADDR_SPACE_BITS 48
-#define TARGET_PAGE_BITS 12
+#ifdef CONFIG_USER_ONLY
+/* Allow user-only to vary page size from 4k */
+# define TARGET_PAGE_BITS_VARY
+#else
+# define TARGET_PAGE_BITS 12
+#endif
#endif
---
base-commit: 30e8a06b64aa58a3990ba39cb5d09531e7d265e0
change-id: 20260630-loong64-vary-page-sz-253ded0be884
Best regards,
--
Miao Wang <shankerwangmiao@gmail.com>
On 30.06.2026 10:56, Miao Wang via B4 Relay wrote:
> From: Miao Wang <shankerwangmiao@gmail.com>
>
> Hard coding PAGE_SIZE to 4K will prevent user-only emulation from
> working on hosts with 16K page size.
Doesn't the same apply to all other targets - hard-coding PAGE_SIZE to
4k for any linux-user target will prevent this target from working on
hosts with 16k page size?
Meanwhile, I'm picking this up for qemu-stable (11.0.x only, since
TARGET_PAGE_BITS_VARY is not handled in earlier releases).
Thanks,
/mjt
> Fixes: 1d832c19db1e ("target/loongarch: Support 4K page size")
> Fixes: qemu-project/qemu#3651
>
> Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
> ---
> target/loongarch/cpu-param.h | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/target/loongarch/cpu-param.h b/target/loongarch/cpu-param.h
> index 3bcf77b3755abdc302699c22c7aa99e2e8c3bbf3..6abe72ff5cab46e246fde4fa76bce05ba7c1cd20 100644
> --- a/target/loongarch/cpu-param.h
> +++ b/target/loongarch/cpu-param.h
> @@ -10,6 +10,11 @@
>
> #define TARGET_VIRT_ADDR_SPACE_BITS 48
>
> -#define TARGET_PAGE_BITS 12
> +#ifdef CONFIG_USER_ONLY
> +/* Allow user-only to vary page size from 4k */
> +# define TARGET_PAGE_BITS_VARY
> +#else
> +# define TARGET_PAGE_BITS 12
> +#endif
>
> #endif
>
> ---
> base-commit: 30e8a06b64aa58a3990ba39cb5d09531e7d265e0
> change-id: 20260630-loong64-vary-page-sz-253ded0be884
>
> Best regards,
On 7/8/26 04:38, Michael Tokarev wrote: > On 30.06.2026 10:56, Miao Wang via B4 Relay wrote: >> From: Miao Wang <shankerwangmiao@gmail.com> >> >> Hard coding PAGE_SIZE to 4K will prevent user-only emulation from >> working on hosts with 16K page size. > > Doesn't the same apply to all other targets - hard-coding PAGE_SIZE to > 4k for any linux-user target will prevent this target from working on > hosts with 16k page size? But some targets really have a fixed page size and aren't prepared for any changes. E.g. x86 and m68k. Thus it's up to the target to decide if variable page size is ok. r~
Hi, > 2026年7月8日 19:38,Michael Tokarev <mjt@tls.msk.ru> 写道: > > On 30.06.2026 10:56, Miao Wang via B4 Relay wrote: >> From: Miao Wang <shankerwangmiao@gmail.com> >> Hard coding PAGE_SIZE to 4K will prevent user-only emulation from >> working on hosts with 16K page size. > > Doesn't the same apply to all other targets - hard-coding PAGE_SIZE to > 4k for any linux-user target will prevent this target from working on > hosts with 16k page size? I believe so. It seem that qemu-user might have trouble handling guest with smaller page size than the host, IIUC. If a certain target requires 4K page size while the host has a larger page size, then there will be no way to handle this. Using this patch just allows to use the same page size as the host when possible. BTW, in Debian, there are currently two "special" architectures, which are s390x and loong64. S390x is the only one with big-endianness while loong64 is the only one with 16K page size by default. As a result, testing results on these two architectures can catch more cross-architecture related bugs. Cheers, Miao Wang
On 7/8/26 14:09, Miao Wang wrote: > Hi, > >> 2026年7月8日 19:38,Michael Tokarev <mjt@tls.msk.ru> 写道: >> >> On 30.06.2026 10:56, Miao Wang via B4 Relay wrote: >>> From: Miao Wang <shankerwangmiao@gmail.com> >>> Hard coding PAGE_SIZE to 4K will prevent user-only emulation from >>> working on hosts with 16K page size. >> >> Doesn't the same apply to all other targets - hard-coding PAGE_SIZE to >> 4k for any linux-user target will prevent this target from working on >> hosts with 16k page size? > > I believe so. It seem that qemu-user might have trouble handling guest > with smaller page size than the host, IIUC. If a certain target requires > 4K page size while the host has a larger page size, then there will > be no way to handle this. Using this patch just allows to use the > same page size as the host when possible. > > BTW, in Debian, there are currently two "special" architectures, > which are s390x and loong64. S390x is the only one with big-endianness Just for the record: hppa is big-endian as well, and in addition it's a 32-bit arch (for linux-user). > while loong64 is the only one with 16K page size by default. As a > result, testing results on these two architectures can catch more > cross-architecture related bugs. > > Cheers, > > Miao Wang
在 2026/6/30 下午3:56, Miao Wang via B4 Relay 写道:
> From: Miao Wang <shankerwangmiao@gmail.com>
>
> Hard coding PAGE_SIZE to 4K will prevent user-only emulation from
> working on hosts with 16K page size.
>
> Fixes: 1d832c19db1e ("target/loongarch: Support 4K page size")
> Fixes: qemu-project/qemu#3651
>
> Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
> ---
> target/loongarch/cpu-param.h | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Reviewed-by: Song Gao <gaosong@loongson.cn>
Thanks.
Song Gao
> diff --git a/target/loongarch/cpu-param.h b/target/loongarch/cpu-param.h
> index 3bcf77b3755abdc302699c22c7aa99e2e8c3bbf3..6abe72ff5cab46e246fde4fa76bce05ba7c1cd20 100644
> --- a/target/loongarch/cpu-param.h
> +++ b/target/loongarch/cpu-param.h
> @@ -10,6 +10,11 @@
>
> #define TARGET_VIRT_ADDR_SPACE_BITS 48
>
> -#define TARGET_PAGE_BITS 12
> +#ifdef CONFIG_USER_ONLY
> +/* Allow user-only to vary page size from 4k */
> +# define TARGET_PAGE_BITS_VARY
> +#else
> +# define TARGET_PAGE_BITS 12
> +#endif
>
> #endif
>
> ---
> base-commit: 30e8a06b64aa58a3990ba39cb5d09531e7d265e0
> change-id: 20260630-loong64-vary-page-sz-253ded0be884
>
> Best regards,
© 2016 - 2026 Red Hat, Inc.