* [PULL 01/14] accel/nvmm: Fix NULL dereference in nvmm_init_vcpu()
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 02/14] accel/whpx: Fix NULL dereference in whpx_init_vcpu() Philippe Mathieu-Daudé
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Volker Rümelin,
Richard Henderson
When mechanically moving the @dirty field to AccelCPUState
in commit 79f1926b2d, we neglected cpu->accel is still NULL
when we want to dereference it.
Reported-by: Volker Rümelin <vr_qemu@t-online.de>
Suggested-by: Volker Rümelin <vr_qemu@t-online.de>
Fixes: 79f1926b2d ("accel/nvmm: Use accel-specific per-vcpu @dirty field")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240429091918.27429-3-philmd@linaro.org>
---
target/i386/nvmm/nvmm-all.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index f9cced53b3..65768aca03 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -982,7 +982,7 @@ nvmm_init_vcpu(CPUState *cpu)
}
}
- cpu->accel->dirty = true;
+ qcpu->dirty = true;
cpu->accel = qcpu;
return 0;
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 02/14] accel/whpx: Fix NULL dereference in whpx_init_vcpu()
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 01/14] accel/nvmm: Fix NULL dereference in nvmm_init_vcpu() Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 03/14] exec: Include missing license in 'exec/cpu-common.h' Philippe Mathieu-Daudé
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Volker Rümelin,
Richard Henderson
When mechanically moving the @dirty field to AccelCPUState
in commit 9ad49538c7, we neglected cpu->accel is still NULL
when we want to dereference it.
Fixes: 9ad49538c7 ("accel/whpx: Use accel-specific per-vcpu @dirty field")
Reported-by: Volker Rümelin <vr_qemu@t-online.de>
Suggested-by: Volker Rümelin <vr_qemu@t-online.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240429091918.27429-2-philmd@linaro.org>
---
target/i386/whpx/whpx-all.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index b08e644517..a6674a826d 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2236,7 +2236,7 @@ int whpx_init_vcpu(CPUState *cpu)
}
vcpu->interruptable = true;
- cpu->accel->dirty = true;
+ vcpu->dirty = true;
cpu->accel = vcpu;
max_vcpu_index = max(max_vcpu_index, cpu->cpu_index);
qemu_add_vm_change_state_handler(whpx_cpu_update_state, env);
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 03/14] exec: Include missing license in 'exec/cpu-common.h'
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 01/14] accel/nvmm: Fix NULL dereference in nvmm_init_vcpu() Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 02/14] accel/whpx: Fix NULL dereference in whpx_init_vcpu() Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 04/14] user: Move 'abitypes.h' from 'exec/user' to 'user' Philippe Mathieu-Daudé
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
Commit 1ad2134f91 ("Hardware convenience library") extracted
"cpu-common.h" from "cpu-all.h", which uses the LGPL-2.1+ license.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240427155714.53669-5-philmd@linaro.org>
---
include/exec/cpu-common.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 6d5318895a..8812ba744d 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -1,8 +1,13 @@
+/*
+ * CPU interfaces that are target independent.
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
#ifndef CPU_COMMON_H
#define CPU_COMMON_H
-/* CPU interfaces that are target independent. */
-
#include "exec/vaddr.h"
#ifndef CONFIG_USER_ONLY
#include "exec/hwaddr.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 04/14] user: Move 'abitypes.h' from 'exec/user' to 'user'
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2024-05-03 15:36 ` [PULL 03/14] exec: Include missing license in 'exec/cpu-common.h' Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 05/14] user: Move 'thunk.h' " Philippe Mathieu-Daudé
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
Keep all user emulation headers under the same user/ directory.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240503125202.35667-1-philmd@linaro.org>
---
bsd-user/qemu.h | 2 +-
include/exec/cpu-all.h | 2 +-
include/exec/user/thunk.h | 2 +-
include/{exec => }/user/abitypes.h | 4 ++--
include/user/syscall-trace.h | 2 +-
linux-user/qemu.h | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
rename include/{exec => }/user/abitypes.h (97%)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 8629f0dcde..a0c1ad7efa 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -22,7 +22,7 @@
#include "exec/cpu_ldst.h"
#include "exec/exec-all.h"
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
extern char **environ;
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index e75ec13cd0..032c6d990e 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -64,7 +64,7 @@
/* MMU memory access macros */
#if defined(CONFIG_USER_ONLY)
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
/*
* If non-zero, the guest virtual address space is a contiguous subset
diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h
index 2ebfecf58e..9f35c888f9 100644
--- a/include/exec/user/thunk.h
+++ b/include/exec/user/thunk.h
@@ -21,7 +21,7 @@
#define THUNK_H
#include "cpu.h"
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
/* types enums definitions */
diff --git a/include/exec/user/abitypes.h b/include/user/abitypes.h
similarity index 97%
rename from include/exec/user/abitypes.h
rename to include/user/abitypes.h
index 3ec1969368..5c9a955631 100644
--- a/include/exec/user/abitypes.h
+++ b/include/user/abitypes.h
@@ -1,5 +1,5 @@
-#ifndef EXEC_USER_ABITYPES_H
-#define EXEC_USER_ABITYPES_H
+#ifndef USER_ABITYPES_H
+#define USER_ABITYPES_H
#ifndef CONFIG_USER_ONLY
#error Cannot include this header from system emulation
diff --git a/include/user/syscall-trace.h b/include/user/syscall-trace.h
index b48b2b2d0a..9bd7ca19c8 100644
--- a/include/user/syscall-trace.h
+++ b/include/user/syscall-trace.h
@@ -10,7 +10,7 @@
#ifndef SYSCALL_TRACE_H
#define SYSCALL_TRACE_H
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
#include "gdbstub/user.h"
#include "qemu/plugin.h"
#include "trace/trace-root.h"
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 4777856b52..263f445ff1 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -4,7 +4,7 @@
#include "cpu.h"
#include "exec/cpu_ldst.h"
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
#include "syscall_defs.h"
#include "target_syscall.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 05/14] user: Move 'thunk.h' from 'exec/user' to 'user'
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2024-05-03 15:36 ` [PULL 04/14] user: Move 'abitypes.h' from 'exec/user' to 'user' Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 06/14] coverity: Update user emulation regexp Philippe Mathieu-Daudé
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
Keep all user emulation headers under the same user/ directory.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240428221450.26460-2-philmd@linaro.org>
---
MAINTAINERS | 1 -
bsd-user/qemu.h | 2 +-
include/{exec => }/user/thunk.h | 8 ++++++--
linux-user/user-internals.h | 2 +-
linux-user/thunk.c | 2 +-
5 files changed, 9 insertions(+), 6 deletions(-)
rename include/{exec => }/user/thunk.h (97%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 302b6fd00c..96411e6adf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3692,7 +3692,6 @@ Overall usermode emulation
M: Riku Voipio <riku.voipio@iki.fi>
S: Maintained
F: accel/tcg/user-exec*.c
-F: include/exec/user/
F: include/user/
F: common-user/
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index a0c1ad7efa..a916724de9 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -26,7 +26,7 @@
extern char **environ;
-#include "exec/user/thunk.h"
+#include "user/thunk.h"
#include "target_arch.h"
#include "syscall_defs.h"
#include "target_syscall.h"
diff --git a/include/exec/user/thunk.h b/include/user/thunk.h
similarity index 97%
rename from include/exec/user/thunk.h
rename to include/user/thunk.h
index 9f35c888f9..2a2104b568 100644
--- a/include/exec/user/thunk.h
+++ b/include/user/thunk.h
@@ -17,8 +17,12 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef THUNK_H
-#define THUNK_H
+#ifndef USER_THUNK_H
+#define USER_THUNK_H
+
+#ifndef CONFIG_USER_ONLY
+#error Cannot include this header from system emulation
+#endif
#include "cpu.h"
#include "user/abitypes.h"
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
index ce11d9e21c..5c7f173ceb 100644
--- a/linux-user/user-internals.h
+++ b/linux-user/user-internals.h
@@ -18,7 +18,7 @@
#ifndef LINUX_USER_USER_INTERNALS_H
#define LINUX_USER_USER_INTERNALS_H
-#include "exec/user/thunk.h"
+#include "user/thunk.h"
#include "exec/exec-all.h"
#include "exec/tb-flush.h"
#include "qemu/log.h"
diff --git a/linux-user/thunk.c b/linux-user/thunk.c
index 071aad4b5f..3cd19e79c6 100644
--- a/linux-user/thunk.c
+++ b/linux-user/thunk.c
@@ -20,7 +20,7 @@
#include "qemu/log.h"
#include "qemu.h"
-#include "exec/user/thunk.h"
+#include "user/thunk.h"
//#define DEBUG
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 06/14] coverity: Update user emulation regexp
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2024-05-03 15:36 ` [PULL 05/14] user: Move 'thunk.h' " Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 07/14] plugins/api: Only include 'exec/ram_addr.h' with system emulation Philippe Mathieu-Daudé
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
All user emulation headers are now under include/user/.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240428221450.26460-3-philmd@linaro.org>
---
scripts/coverity-scan/COMPONENTS.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/coverity-scan/COMPONENTS.md b/scripts/coverity-scan/COMPONENTS.md
index 91be8d1c36..1537e49cd5 100644
--- a/scripts/coverity-scan/COMPONENTS.md
+++ b/scripts/coverity-scan/COMPONENTS.md
@@ -121,7 +121,7 @@ usb
~ (/qemu)?(/hw/usb/.*|/include/hw/usb/.*)
user
- ~ (/qemu)?(/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
+ ~ (/qemu)?(/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/user/.*)
util
~ (/qemu)?(/util/.*|/include/qemu/.*)
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 07/14] plugins/api: Only include 'exec/ram_addr.h' with system emulation
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2024-05-03 15:36 ` [PULL 06/14] coverity: Update user emulation regexp Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 08/14] plugins: Update stale comment Philippe Mathieu-Daudé
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
"exec/ram_addr.h" shouldn't be used with user emulation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240427155714.53669-4-philmd@linaro.org>
---
plugins/api.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/api.c b/plugins/api.c
index 8fa5a600ac..eaee344d8e 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -42,10 +42,10 @@
#include "tcg/tcg.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"
-#include "exec/ram_addr.h"
#include "disas/disas.h"
#include "plugin.h"
#ifndef CONFIG_USER_ONLY
+#include "exec/ram_addr.h"
#include "qemu/plugin-memory.h"
#include "hw/boards.h"
#else
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 08/14] plugins: Update stale comment
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2024-05-03 15:36 ` [PULL 07/14] plugins/api: Only include 'exec/ram_addr.h' with system emulation Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 09/14] MAINTAINERS: Update my email address Philippe Mathieu-Daudé
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
"plugin_mask" was renamed as "event_mask" in commit c006147122
("plugins: create CPUPluginState and migrate plugin_mask").
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240427155714.53669-3-philmd@linaro.org>
---
plugins/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/core.c b/plugins/core.c
index 11ca20e626..09c98382f5 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -373,7 +373,7 @@ void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb)
struct qemu_plugin_cb *cb, *next;
enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_TB_TRANS;
- /* no plugin_mask check here; caller should have checked */
+ /* no plugin_state->event_mask check here; caller should have checked */
QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) {
qemu_plugin_vcpu_tb_trans_cb_t func = cb->f.vcpu_tb_trans;
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 09/14] MAINTAINERS: Update my email address
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2024-05-03 15:36 ` [PULL 08/14] plugins: Update stale comment Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 10/14] target/sh4: Fix ADDV opcode Philippe Mathieu-Daudé
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Anthony PERARD, Paul Durrant, Stefano Stabellini,
Philippe Mathieu-Daudé
From: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Paul Durrant <paul@xen.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Message-ID: <20240429154938.19340-1-anthony.perard@citrix.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 96411e6adf..2f08cc528e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -532,7 +532,7 @@ Guest CPU Cores (Xen)
---------------------
X86 Xen CPUs
M: Stefano Stabellini <sstabellini@kernel.org>
-M: Anthony Perard <anthony.perard@citrix.com>
+M: Anthony PERARD <anthony@xenproject.org>
M: Paul Durrant <paul@xen.org>
L: xen-devel@lists.xenproject.org
S: Supported
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 10/14] target/sh4: Fix ADDV opcode
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2024-05-03 15:36 ` [PULL 09/14] MAINTAINERS: Update my email address Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 11/14] target/sh4: Fix SUBV opcode Philippe Mathieu-Daudé
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-stable, Paul Cercueil,
Richard Henderson, Yoshinori Sato
The documentation says:
ADDV Rm, Rn Rn + Rm -> Rn, overflow -> T
But QEMU implementation was:
ADDV Rm, Rn Rn + Rm -> Rm, overflow -> T
Fix by filling the correct Rm register.
Add tests provided by Paul Cercueil.
Cc: qemu-stable@nongnu.org
Fixes: ad8d25a11f ("target-sh4: implement addv and subv using TCG")
Reported-by: Paul Cercueil <paul@crapouillou.net>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2317
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20240430163125.77430-2-philmd@linaro.org>
---
target/sh4/translate.c | 2 +-
tests/tcg/sh4/test-addv.c | 27 +++++++++++++++++++++++++++
tests/tcg/sh4/Makefile.target | 3 +++
3 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 tests/tcg/sh4/test-addv.c
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index ebb6c901bf..4a1dd0d1f4 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -714,7 +714,7 @@ static void _decode_opc(DisasContext * ctx)
tcg_gen_xor_i32(t2, REG(B7_4), REG(B11_8));
tcg_gen_andc_i32(cpu_sr_t, t1, t2);
tcg_gen_shri_i32(cpu_sr_t, cpu_sr_t, 31);
- tcg_gen_mov_i32(REG(B7_4), t0);
+ tcg_gen_mov_i32(REG(B11_8), t0);
}
return;
case 0x2009: /* and Rm,Rn */
diff --git a/tests/tcg/sh4/test-addv.c b/tests/tcg/sh4/test-addv.c
new file mode 100644
index 0000000000..ca87fe746a
--- /dev/null
+++ b/tests/tcg/sh4/test-addv.c
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void addv(const int a, const int b, const int res, const int carry)
+{
+ int o = a, c;
+
+ asm volatile("addv %2,%0\n"
+ "movt %1\n"
+ : "+r"(o), "=r"(c) : "r"(b) : );
+
+ if (c != carry || o != res) {
+ printf("ADDV %d, %d = %d/%d [T = %d/%d]\n", a, b, o, res, c, carry);
+ abort();
+ }
+}
+
+int main(void)
+{
+ addv(INT_MAX, 1, INT_MIN, 1);
+ addv(INT_MAX - 1, 1, INT_MAX, 0);
+
+ return 0;
+}
diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target
index 4d09291c0c..521b8b0a76 100644
--- a/tests/tcg/sh4/Makefile.target
+++ b/tests/tcg/sh4/Makefile.target
@@ -17,3 +17,6 @@ TESTS += test-macl
test-macw: CFLAGS += -O -g
TESTS += test-macw
+
+test-addv: CFLAGS += -O -g
+TESTS += test-addv
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 11/14] target/sh4: Fix SUBV opcode
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2024-05-03 15:36 ` [PULL 10/14] target/sh4: Fix ADDV opcode Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 12/14] target/sh4: Rename TCGv variables as manual for ADDV opcode Philippe Mathieu-Daudé
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, qemu-stable, Paul Cercueil,
Richard Henderson, Yoshinori Sato
The documentation says:
SUBV Rm, Rn Rn - Rm -> Rn, underflow -> T
The overflow / underflow can be calculated as:
T = ((Rn ^ Rm) & (Result ^ Rn)) >> 31
However we were using the incorrect:
T = ((Rn ^ Rm) & (Result ^ Rm)) >> 31
Fix by using the Rn register instead of Rm.
Add tests provided by Paul Cercueil.
Cc: qemu-stable@nongnu.org
Fixes: ad8d25a11f ("target-sh4: implement addv and subv using TCG")
Reported-by: Paul Cercueil <paul@crapouillou.net>
Suggested-by: Paul Cercueil <paul@crapouillou.net>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2318
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20240430163125.77430-3-philmd@linaro.org>
---
target/sh4/translate.c | 2 +-
tests/tcg/sh4/test-subv.c | 30 ++++++++++++++++++++++++++++++
tests/tcg/sh4/Makefile.target | 3 +++
3 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 tests/tcg/sh4/test-subv.c
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 4a1dd0d1f4..3e013b7c7c 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -933,7 +933,7 @@ static void _decode_opc(DisasContext * ctx)
t0 = tcg_temp_new();
tcg_gen_sub_i32(t0, REG(B11_8), REG(B7_4));
t1 = tcg_temp_new();
- tcg_gen_xor_i32(t1, t0, REG(B7_4));
+ tcg_gen_xor_i32(t1, t0, REG(B11_8));
t2 = tcg_temp_new();
tcg_gen_xor_i32(t2, REG(B11_8), REG(B7_4));
tcg_gen_and_i32(t1, t1, t2);
diff --git a/tests/tcg/sh4/test-subv.c b/tests/tcg/sh4/test-subv.c
new file mode 100644
index 0000000000..a3c2db96e4
--- /dev/null
+++ b/tests/tcg/sh4/test-subv.c
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void subv(const int a, const int b, const int res, const int carry)
+{
+ int o = a, c;
+
+ asm volatile("subv %2,%0\n"
+ "movt %1\n"
+ : "+r"(o), "=r"(c) : "r"(b) : );
+
+ if (c != carry || o != res) {
+ printf("SUBV %d, %d = %d/%d [T = %d/%d]\n", a, b, o, res, c, carry);
+ abort();
+ }
+}
+
+int main(void)
+{
+ subv(INT_MIN, 1, INT_MAX, 1);
+ subv(INT_MAX, -1, INT_MIN, 1);
+ subv(INT_MAX, 1, INT_MAX - 1, 0);
+ subv(0, 1, -1, 0);
+ subv(-1, -1, 0, 0);
+
+ return 0;
+}
diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target
index 521b8b0a76..7852fa62d8 100644
--- a/tests/tcg/sh4/Makefile.target
+++ b/tests/tcg/sh4/Makefile.target
@@ -20,3 +20,6 @@ TESTS += test-macw
test-addv: CFLAGS += -O -g
TESTS += test-addv
+
+test-subv: CFLAGS += -O -g
+TESTS += test-subv
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 12/14] target/sh4: Rename TCGv variables as manual for ADDV opcode
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2024-05-03 15:36 ` [PULL 11/14] target/sh4: Fix SUBV opcode Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 13/14] target/sh4: Rename TCGv variables as manual for SUBV opcode Philippe Mathieu-Daudé
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson, Yoshinori Sato
To easily compare with the SH4 manual, rename:
REG(B11_8) -> Rn
REG(B7_4) -> Rm
t0 -> result
Mention how overflow is calculated.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20240430163125.77430-4-philmd@linaro.org>
---
target/sh4/translate.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 3e013b7c7c..47c0f3404e 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -705,16 +705,20 @@ static void _decode_opc(DisasContext * ctx)
return;
case 0x300f: /* addv Rm,Rn */
{
- TCGv t0, t1, t2;
- t0 = tcg_temp_new();
- tcg_gen_add_i32(t0, REG(B7_4), REG(B11_8));
+ TCGv Rn = REG(B11_8);
+ TCGv Rm = REG(B7_4);
+ TCGv result, t1, t2;
+
+ result = tcg_temp_new();
t1 = tcg_temp_new();
- tcg_gen_xor_i32(t1, t0, REG(B11_8));
t2 = tcg_temp_new();
- tcg_gen_xor_i32(t2, REG(B7_4), REG(B11_8));
+ tcg_gen_add_i32(result, Rm, Rn);
+ /* T = ((Rn ^ Rm) & (Result ^ Rn)) >> 31 */
+ tcg_gen_xor_i32(t1, result, Rn);
+ tcg_gen_xor_i32(t2, Rm, Rn);
tcg_gen_andc_i32(cpu_sr_t, t1, t2);
tcg_gen_shri_i32(cpu_sr_t, cpu_sr_t, 31);
- tcg_gen_mov_i32(REG(B11_8), t0);
+ tcg_gen_mov_i32(Rn, result);
}
return;
case 0x2009: /* and Rm,Rn */
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 13/14] target/sh4: Rename TCGv variables as manual for SUBV opcode
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2024-05-03 15:36 ` [PULL 12/14] target/sh4: Rename TCGv variables as manual for ADDV opcode Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-03 15:36 ` [PULL 14/14] ui/cocoa.m: Drop old macOS-10.12-and-earlier compat ifdefs Philippe Mathieu-Daudé
2024-05-04 2:01 ` [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Richard Henderson
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
To easily compare with the SH4 manual, rename:
REG(B11_8) -> Rn
REG(B7_4) -> Rm
t0 -> result
Mention how underflow is calculated.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240430163125.77430-5-philmd@linaro.org>
---
target/sh4/translate.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 47c0f3404e..e599ab9d1a 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -933,16 +933,20 @@ static void _decode_opc(DisasContext * ctx)
return;
case 0x300b: /* subv Rm,Rn */
{
- TCGv t0, t1, t2;
- t0 = tcg_temp_new();
- tcg_gen_sub_i32(t0, REG(B11_8), REG(B7_4));
+ TCGv Rn = REG(B11_8);
+ TCGv Rm = REG(B7_4);
+ TCGv result, t1, t2;
+
+ result = tcg_temp_new();
t1 = tcg_temp_new();
- tcg_gen_xor_i32(t1, t0, REG(B11_8));
t2 = tcg_temp_new();
- tcg_gen_xor_i32(t2, REG(B11_8), REG(B7_4));
+ tcg_gen_sub_i32(result, Rn, Rm);
+ /* T = ((Rn ^ Rm) & (Result ^ Rn)) >> 31 */
+ tcg_gen_xor_i32(t1, result, Rn);
+ tcg_gen_xor_i32(t2, Rn, Rm);
tcg_gen_and_i32(t1, t1, t2);
tcg_gen_shri_i32(cpu_sr_t, t1, 31);
- tcg_gen_mov_i32(REG(B11_8), t0);
+ tcg_gen_mov_i32(Rn, result);
}
return;
case 0x2008: /* tst Rm,Rn */
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL 14/14] ui/cocoa.m: Drop old macOS-10.12-and-earlier compat ifdefs
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2024-05-03 15:36 ` [PULL 13/14] target/sh4: Rename TCGv variables as manual for SUBV opcode Philippe Mathieu-Daudé
@ 2024-05-03 15:36 ` Philippe Mathieu-Daudé
2024-05-04 2:01 ` [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Richard Henderson
14 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-03 15:36 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Daniel P . Berrangé,
Philippe Mathieu-Daudé
From: Peter Maydell <peter.maydell@linaro.org>
We only support the most recent two versions of macOS (currently
macOS 13 Ventura and macOS 14 Sonoma), and our ui/cocoa.m code
already assumes at least macOS 12 Monterey or better, because it uses
NSScreen safeAreaInsets, which is 12.0-or-newer.
Remove the ifdefs that were providing backwards compatibility for
building on 10.12 and earlier versions.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20240502142904.62644-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
ui/cocoa.m | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 25e0db9dd0..981615a8b9 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -50,23 +50,10 @@
#include <Carbon/Carbon.h>
#include "hw/core/cpu.h"
-#ifndef MAC_OS_X_VERSION_10_13
-#define MAC_OS_X_VERSION_10_13 101300
-#endif
-
#ifndef MAC_OS_VERSION_14_0
#define MAC_OS_VERSION_14_0 140000
#endif
-/* 10.14 deprecates NSOnState and NSOffState in favor of
- * NSControlStateValueOn/Off, which were introduced in 10.13.
- * Define for older versions
- */
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
-#define NSControlStateValueOn NSOnState
-#define NSControlStateValueOff NSOffState
-#endif
-
//#define DEBUG
#ifdef DEBUG
--
2.41.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03
2024-05-03 15:35 [PULL 00/14] Accel / SH4 / UI patches for 2024-05-03 Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2024-05-03 15:36 ` [PULL 14/14] ui/cocoa.m: Drop old macOS-10.12-and-earlier compat ifdefs Philippe Mathieu-Daudé
@ 2024-05-04 2:01 ` Richard Henderson
14 siblings, 0 replies; 16+ messages in thread
From: Richard Henderson @ 2024-05-04 2:01 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 5/3/24 08:35, Philippe Mathieu-Daudé wrote:
> The following changes since commit fd87be1dada5672f877e03c2ca8504458292c479:
>
> Merge tag 'accel-20240426' ofhttps://github.com/philmd/qemu into staging (2024-04-26 15:28:13 -0700)
>
> are available in the Git repository at:
>
> https://github.com/philmd/qemu.git tags/accel-sh4-ui-20240503
>
> for you to fetch changes up to 2d27c91e2b72ac7a65504ac207c89262d92464eb:
>
> ui/cocoa.m: Drop old macOS-10.12-and-earlier compat ifdefs (2024-05-03 17:33:26 +0200)
>
> ----------------------------------------------------------------
> - Fix NULL dereference in NVMM & WHPX init_vcpu()
> - Move user emulation headers "exec/user" to "user"
> - Fix SH-4 ADDV / SUBV opcodes
> - Drop Cocoa compatility on macOS <= 10.12
> - Update Anthony PERARD email
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 16+ messages in thread