[PATCH] linux-user/arm: Fix return value of SYS_cacheflush

J. Neuschäfer posted 1 patch 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250613-cache-v1-1-ee9f4a9ba81b@gmx.net
Maintainers: Laurent Vivier <laurent@vivier.eu>
linux-user/arm/cpu_loop.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] linux-user/arm: Fix return value of SYS_cacheflush
Posted by J. Neuschäfer 5 months ago
Although the emulated cacheflush syscall does nothing, it still needs to
return zero to indicate success.

Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
---
 linux-user/arm/cpu_loop.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index e8417d040691a04a3edc0f5508f047571beac8fa..33f63951a958a5a48ced2d1e187264d691e5c940 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -363,6 +363,7 @@ void cpu_loop(CPUARMState *env)
                     switch (n) {
                     case ARM_NR_cacheflush:
                         /* nop */
+                        env->regs[0] = 0;
                         break;
                     case ARM_NR_set_tls:
                         cpu_set_tls(env, env->regs[0]);

---
base-commit: d9ce74873a6a5a7c504379857461e4ae64fcf0cd
change-id: 20250613-cache-723a77168c8e

Best regards,
-- 
J. Neuschäfer <j.neuschaefer@gmx.net>
Re: [PATCH] linux-user/arm: Fix return value of SYS_cacheflush
Posted by Peter Maydell 5 months ago
On Fri, 13 Jun 2025 at 17:02, J. Neuschäfer <j.neuschaefer@gmx.net> wrote:
>
> Although the emulated cacheflush syscall does nothing, it still needs to
> return zero to indicate success.
>
> Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
> ---
>  linux-user/arm/cpu_loop.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
> index e8417d040691a04a3edc0f5508f047571beac8fa..33f63951a958a5a48ced2d1e187264d691e5c940 100644
> --- a/linux-user/arm/cpu_loop.c
> +++ b/linux-user/arm/cpu_loop.c
> @@ -363,6 +363,7 @@ void cpu_loop(CPUARMState *env)
>                      switch (n) {
>                      case ARM_NR_cacheflush:
>                          /* nop */
> +                        env->regs[0] = 0;
>                          break;
>                      case ARM_NR_set_tls:
>                          cpu_set_tls(env, env->regs[0]);

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
and queued to target-arm.next. Interesting that nobody's
noticed this in all these years...

(If we were really enthusiastic we could make it fail for
the "end < start || flags" condition the kernel tests, but
that seems unnecessary. The kernel also checks for access
permissions, which would be harder.)

thanks
-- PMM