Skip to contentSkip to conversation

linux-user/arm: Fix return value of SYS_cacheflush

PATCH In review J. Neuschäfer 2 participants 2 messages Jun 13, 2025 – Jun 16, 2025

lore
Share & tools
lore
#0 lore raw

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

Although the emulated cacheflush syscall does nothing, it still needs to return zero to indicate success.

---
 linux-user/arm/cpu_loop.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/arm/cpu_loop.c +1 -0
index e8417d040691a04a3edc0f5508f047571beac8fa..33f63951a958a5a48ced2d1e187264d691e5c940 100644
@@ -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,

Signature · 1 line
J. Neuschäfer <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · J. Neuschäfer

Although the emulated cacheflush syscall does nothing, it still needs to return zero to indicate success.

---
 linux-user/arm/cpu_loop.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/arm/cpu_loop.c +0 -0
index e8417d040691a04a3edc0f5508f047571beac8fa..33f63951a958a5a48ced2d1e187264d691e5c940 100644

linux-user/arm/cpu_loop.c void cpu_loop(CPUARMState *env) · line 369

Quoted 7 lines
linux-user/arm/cpu_loop.c +1 -0
@@ -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]);

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