@samitouri / QOSamiQemu / commits / 731525c276

plugins: use int64_t for the syscall filter return value

The syscall return value passed back through the syscall filter callback is semantically signed: negative values encode errno codes. Declaring the sysret pointer as uint64_t * is therefore misleading and forces callers to launder the value through an unsigned temporary. Change the sysret pointer to int64_t * across the public plugin API typedef (qemu_plugin_vcpu_syscall_filter_cb_t), the internal qemu_plugin_vcpu_syscall_filter() prototypes and stub, its implementation in plugins/core.c, the linux-user caller, and the in-tree example plugins. Signed-off-by: Ziyang Zhang <functioner@sjtu.edu.cn> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/20260618082426.790315-2-functioner@sjtu.edu.cn Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>

Ziyang Zhang committed Jun 18, 2026 at 16:24 UTC 731525c27607bbe392abe3b8be2bce3ab65ae4f5
6 files changed +7 -7
include/plugins/qemu-plugin.h
+1 -1
@@ -871,7 +871,7 @@ typedef bool
871 int64_t num, uint64_t a1, uint64_t a2,
872 uint64_t a3, uint64_t a4, uint64_t a5,
873 uint64_t a6, uint64_t a7, uint64_t a8,
874 - uint64_t *sysret,
874 + int64_t *sysret,
875 void *userdata);
876
877 /**
include/qemu/plugin.h
+2 -2
@@ -172,7 +172,7 @@ bool
172 qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1,
173 uint64_t a2, uint64_t a3, uint64_t a4,
174 uint64_t a5, uint64_t a6, uint64_t a7,
175 - uint64_t a8, uint64_t *sysret);
175 + uint64_t a8, int64_t *sysret);
176
177 void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr,
178 uint64_t value_low,
@@ -288,7 +288,7 @@ static inline bool
288 qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1,
289 uint64_t a2, uint64_t a3, uint64_t a4,
290 uint64_t a5, uint64_t a6, uint64_t a7,
291 - uint64_t a8, uint64_t *sysret)
291 + uint64_t a8, int64_t *sysret)
292 {
293 return false;
294 }
linux-user/syscall.c
+1 -1
@@ -14619,7 +14619,7 @@ static bool send_through_syscall_filters(CPUState *cpu, int num,
14619 abi_long arg7, abi_long arg8,
14620 abi_long *sysret)
14621 {
14622 - uint64_t sysret64 = 0;
14622 + int64_t sysret64 = 0;
14623 bool filtered = qemu_plugin_vcpu_syscall_filter(cpu, num, arg1, arg2,
14624 arg3, arg4, arg5, arg6,
14625 arg7, arg8, &sysret64);
plugins/core.c
+1 -1
@@ -573,7 +573,7 @@ bool
573 qemu_plugin_vcpu_syscall_filter(CPUState *cpu, int64_t num, uint64_t a1,
574 uint64_t a2, uint64_t a3, uint64_t a4,
575 uint64_t a5, uint64_t a6, uint64_t a7,
576 - uint64_t a8, uint64_t *sysret)
576 + uint64_t a8, int64_t *sysret)
577 {
578 struct qemu_plugin_cb *cb, *next;
579 enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_SYSCALL_FILTER;
tests/tcg/plugins/setpc.c
+1 -1
@@ -27,7 +27,7 @@ static bool vcpu_syscall_filter(unsigned int vcpu_index,
27 int64_t num, uint64_t a1, uint64_t a2,
28 uint64_t a3, uint64_t a4, uint64_t a5,
29 uint64_t a6, uint64_t a7, uint64_t a8,
30 - uint64_t *sysret, void *userdata)
30 + int64_t *sysret, void *userdata)
31 {
32 if (num == MAGIC_SYSCALL) {
33 if (a1 == SETPC) {
tests/tcg/plugins/syscall.c
+1 -1
@@ -176,7 +176,7 @@ static bool vcpu_syscall_filter(unsigned int vcpu_index,
176 int64_t num, uint64_t a1, uint64_t a2,
177 uint64_t a3, uint64_t a4, uint64_t a5,
178 uint64_t a6, uint64_t a7, uint64_t a8,
179 - uint64_t *sysret, void *userdata)
179 + int64_t *sysret, void *userdata)
180 {
181 /* Special syscall to test the filter functionality. */
182 if (num == 4096 && a1 == 0x66CCFF) {