* [PULL 01/17] linux-user, bsd-user: Preserve incoming order of environment variables in the target
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 02/17] cocoa: Fix warnings about invalid prototype declarations Philippe Mathieu-Daudé
` (16 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Andreas Schwab, Warner Losh,
Philippe Mathieu-Daudé
From: Andreas Schwab <schwab@suse.de>
Do not reverse the order of environment variables in the target environ
array relative to the incoming environ order. Some testsuites depend on a
specific order, even though it is not defined by any standard.
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <mvmlejfsivd.fsf@suse.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
bsd-user/main.c | 10 +++++++++-
linux-user/main.c | 10 +++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index cd8b2a670f..b597328118 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -295,8 +295,16 @@ int main(int argc, char **argv)
envlist = envlist_create();
- /* add current environment into the list */
+ /*
+ * add current environment into the list
+ * envlist_setenv adds to the front of the list; to preserve environ
+ * order add from back to front
+ */
for (wrk = environ; *wrk != NULL; wrk++) {
+ continue;
+ }
+ while (wrk != environ) {
+ wrk--;
(void) envlist_setenv(envlist, *wrk);
}
diff --git a/linux-user/main.c b/linux-user/main.c
index 5e6b2e1714..dba67ffa36 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -692,8 +692,16 @@ int main(int argc, char **argv, char **envp)
envlist = envlist_create();
- /* add current environment into the list */
+ /*
+ * add current environment into the list
+ * envlist_setenv adds to the front of the list; to preserve environ
+ * order add from back to front
+ */
for (wrk = environ; *wrk != NULL; wrk++) {
+ continue;
+ }
+ while (wrk != environ) {
+ wrk--;
(void) envlist_setenv(envlist, *wrk);
}
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 02/17] cocoa: Fix warnings about invalid prototype declarations
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 01/17] linux-user, bsd-user: Preserve incoming order of environment variables in the target Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 03/17] util/cacheflush: Use declarations from <OSCacheControl.h> on Darwin Philippe Mathieu-Daudé
` (15 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Philippe Mathieu-Daudé, Akihiko Odaki
Fix the following Cocoa trivial warnings:
C compiler for the host machine: cc (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
Objective-C compiler for the host machine: clang (clang 14.0.0)
[100/334] Compiling Objective-C object libcommon.fa.p/net_vmnet-bridged.m.o
net/vmnet-bridged.m:40:31: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
static char* get_valid_ifnames()
^
void
[742/1436] Compiling Objective-C object libcommon.fa.p/ui_cocoa.m.o
ui/cocoa.m:1937:22: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
static int cocoa_main()
^
void
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230425192820.34063-1-philmd@linaro.org>
---
net/vmnet-bridged.m | 2 +-
ui/cocoa.m | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m
index 46d2282863..76a28abe79 100644
--- a/net/vmnet-bridged.m
+++ b/net/vmnet-bridged.m
@@ -37,7 +37,7 @@ static bool validate_ifname(const char *ifname)
}
-static char* get_valid_ifnames()
+static char* get_valid_ifnames(void)
{
xpc_object_t shared_if_list = vmnet_copy_shared_interface_list();
__block char *if_list = NULL;
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 168170a8a6..0c2153d17c 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1934,7 +1934,7 @@ static void cocoa_clipboard_request(QemuClipboardInfo *info,
exit(status);
}
-static int cocoa_main()
+static int cocoa_main(void)
{
QemuThread thread;
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 03/17] util/cacheflush: Use declarations from <OSCacheControl.h> on Darwin
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 01/17] linux-user, bsd-user: Preserve incoming order of environment variables in the target Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 02/17] cocoa: Fix warnings about invalid prototype declarations Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 04/17] util/cacheflush: Avoid possible redundant dcache flush " Philippe Mathieu-Daudé
` (14 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Philippe Mathieu-Daudé, Richard Henderson
Per the cache(3) man page, sys_icache_invalidate() and
sys_dcache_flush() are declared in <libkern/OSCacheControl.h>.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230605175647.88395-2-philmd@linaro.org>
---
util/cacheflush.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/cacheflush.c b/util/cacheflush.c
index 06c2333a60..de35616718 100644
--- a/util/cacheflush.c
+++ b/util/cacheflush.c
@@ -237,8 +237,8 @@ static void __attribute__((constructor)) init_cache_info(void)
#ifdef CONFIG_DARWIN
/* Apple does not expose CTR_EL0, so we must use system interfaces. */
-extern void sys_icache_invalidate(void *start, size_t len);
-extern void sys_dcache_flush(void *start, size_t len);
+#include <libkern/OSCacheControl.h>
+
void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len)
{
sys_dcache_flush((void *)rw, len);
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 04/17] util/cacheflush: Avoid possible redundant dcache flush on Darwin
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-06-13 9:38 ` [PULL 03/17] util/cacheflush: Use declarations from <OSCacheControl.h> on Darwin Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 05/17] accel/hvf: Report HV_DENIED error Philippe Mathieu-Daudé
` (13 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Philippe Mathieu-Daudé, Richard Henderson,
Akihiko Odaki
<libkern/OSCacheControl.h> describes sys_icache_invalidate() as
"equivalent to sys_cache_control(kCacheFunctionPrepareForExecution)",
having kCacheFunctionPrepareForExecution defined as:
/* Prepare memory for execution. This should be called
* after writing machine instructions to memory, before
* executing them. It syncs the dcache and icache. [...]
*/
Since the dcache is also sync'd, we can avoid the sys_dcache_flush()
call when both rx/rw pointers are equal.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230605195911.96033-1-philmd@linaro.org>
---
util/cacheflush.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/util/cacheflush.c b/util/cacheflush.c
index de35616718..a08906155a 100644
--- a/util/cacheflush.c
+++ b/util/cacheflush.c
@@ -241,7 +241,14 @@ static void __attribute__((constructor)) init_cache_info(void)
void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len)
{
- sys_dcache_flush((void *)rw, len);
+ if (rx == rw) {
+ /*
+ * sys_icache_invalidate() syncs the dcache and icache,
+ * so no need to call sys_dcache_flush().
+ */
+ } else {
+ sys_dcache_flush((void *)rw, len);
+ }
sys_icache_invalidate((void *)rx, len);
}
#else
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 05/17] accel/hvf: Report HV_DENIED error
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-06-13 9:38 ` [PULL 04/17] util/cacheflush: Avoid possible redundant dcache flush " Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 06/17] target/hppa/meson: Only build int_helper.o with system emulation Philippe Mathieu-Daudé
` (12 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Antonio Caggiano, Philippe Mathieu-Daudé
From: Antonio Caggiano <quic_acaggian@quicinc.com>
On MacOS 11 and subsequent versions, in case the resulting binary is not
signed with the proper entitlement, handle and report the HV_DENIED
error.
Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
Message-Id: <20230608123014.28715-1-quic_acaggian@quicinc.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/hvf/hvf-all.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index 754707dbfb..4920787af6 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -38,6 +38,12 @@ void assert_hvf_ok(hv_return_t ret)
case HV_UNSUPPORTED:
error_report("Error: HV_UNSUPPORTED");
break;
+#if defined(MAC_OS_VERSION_11_0) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
+ case HV_DENIED:
+ error_report("Error: HV_DENIED");
+ break;
+#endif
default:
error_report("Unknown Error");
}
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 06/17] target/hppa/meson: Only build int_helper.o with system emulation
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2023-06-13 9:38 ` [PULL 05/17] accel/hvf: Report HV_DENIED error Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 07/17] target/i386/helper: Remove do_cpu_sipi() stub for user-mode emulation Philippe Mathieu-Daudé
` (11 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Philippe Mathieu-Daudé, Richard Henderson
int_helper.c only contains system emulation code:
remove the #ifdef'ry and move the file to the meson
softmmu source set.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230602223016.58647-1-philmd@linaro.org>
---
target/hppa/int_helper.c | 3 ---
target/hppa/meson.build | 2 +-
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c
index f599dccfff..d2480b163b 100644
--- a/target/hppa/int_helper.c
+++ b/target/hppa/int_helper.c
@@ -25,7 +25,6 @@
#include "hw/core/cpu.h"
#include "hw/hppa/hppa_hardware.h"
-#ifndef CONFIG_USER_ONLY
static void eval_interrupt(HPPACPU *cpu)
{
CPUState *cs = CPU(cpu);
@@ -273,5 +272,3 @@ bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
}
return false;
}
-
-#endif /* !CONFIG_USER_ONLY */
diff --git a/target/hppa/meson.build b/target/hppa/meson.build
index 81b4b4e617..83b1e0ee7d 100644
--- a/target/hppa/meson.build
+++ b/target/hppa/meson.build
@@ -7,13 +7,13 @@ hppa_ss.add(files(
'fpu_helper.c',
'gdbstub.c',
'helper.c',
- 'int_helper.c',
'op_helper.c',
'translate.c',
))
hppa_softmmu_ss = ss.source_set()
hppa_softmmu_ss.add(files(
+ 'int_helper.c',
'machine.c',
'mem_helper.c',
'sys_helper.c',
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 07/17] target/i386/helper: Remove do_cpu_sipi() stub for user-mode emulation
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2023-06-13 9:38 ` [PULL 06/17] target/hppa/meson: Only build int_helper.o with system emulation Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 08/17] target/i386/helper: Shuffle do_cpu_init() Philippe Mathieu-Daudé
` (10 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Philippe Mathieu-Daudé, Richard Henderson
Since commit 604664726f ("target/i386: Restrict cpu_exec_interrupt()
handler to sysemu"), do_cpu_sipi() isn't called anymore on user
emulation. Remove the now pointless stub.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230602224628.59546-2-philmd@linaro.org>
---
target/i386/cpu.h | 3 ++-
target/i386/helper.c | 3 ---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 7201a71de8..cd047e0410 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2285,7 +2285,6 @@ static inline void cpu_get_tb_cpu_state(CPUX86State *env, target_ulong *pc,
}
void do_cpu_init(X86CPU *cpu);
-void do_cpu_sipi(X86CPU *cpu);
#define MCE_INJECT_BROADCAST 1
#define MCE_INJECT_UNCOND_AO 2
@@ -2419,6 +2418,8 @@ void x86_cpu_set_default_version(X86CPUVersion version);
#ifndef CONFIG_USER_ONLY
+void do_cpu_sipi(X86CPU *cpu);
+
#define APIC_DEFAULT_ADDRESS 0xfee00000
#define APIC_SPACE_SIZE 0x100000
diff --git a/target/i386/helper.c b/target/i386/helper.c
index 36bf2107e7..792c8eb45e 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -611,9 +611,6 @@ void do_cpu_sipi(X86CPU *cpu)
void do_cpu_init(X86CPU *cpu)
{
}
-void do_cpu_sipi(X86CPU *cpu)
-{
-}
#endif
#ifndef CONFIG_USER_ONLY
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 08/17] target/i386/helper: Shuffle do_cpu_init()
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2023-06-13 9:38 ` [PULL 07/17] target/i386/helper: Remove do_cpu_sipi() stub for user-mode emulation Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 09/17] target/i386: Rename helper template headers as '.h.inc' Philippe Mathieu-Daudé
` (9 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Philippe Mathieu-Daudé, Richard Henderson
Move the #ifdef'ry inside do_cpu_init() instead of
declaring an empty stub for user emulation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230602224628.59546-3-philmd@linaro.org>
---
target/i386/helper.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/target/i386/helper.c b/target/i386/helper.c
index 792c8eb45e..89aa696c6d 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -580,9 +580,9 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector,
return 1;
}
-#if !defined(CONFIG_USER_ONLY)
void do_cpu_init(X86CPU *cpu)
{
+#if !defined(CONFIG_USER_ONLY)
CPUState *cs = CPU(cpu);
CPUX86State *env = &cpu->env;
CPUX86State *save = g_new(CPUX86State, 1);
@@ -601,19 +601,15 @@ void do_cpu_init(X86CPU *cpu)
kvm_arch_do_init_vcpu(cpu);
}
apic_init_reset(cpu->apic_state);
+#endif /* CONFIG_USER_ONLY */
}
+#ifndef CONFIG_USER_ONLY
+
void do_cpu_sipi(X86CPU *cpu)
{
apic_sipi(cpu->apic_state);
}
-#else
-void do_cpu_init(X86CPU *cpu)
-{
-}
-#endif
-
-#ifndef CONFIG_USER_ONLY
void cpu_load_efer(CPUX86State *env, uint64_t val)
{
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 09/17] target/i386: Rename helper template headers as '.h.inc'
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2023-06-13 9:38 ` [PULL 08/17] target/i386/helper: Shuffle do_cpu_init() Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 10/17] hw/i2c: Enable an id for the pca954x devices Philippe Mathieu-Daudé
` (8 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-block, Philippe Mathieu-Daudé, Richard Henderson
Since commit 139c1837db ("meson: rename included C source files
to .c.inc"), QEMU standard procedure for included C files is to
use *.c.inc.
Besides, since commit 6a0057aa22 ("docs/devel: make a statement
about includes") this is documented as the Coding Style:
If you do use template header files they should be named with
the ``.c.inc`` or ``.h.inc`` suffix to make it clear they are
being included for expansion.
Therefore move the included templates in the tcg/ directory and
rename as '.h.inc'.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230608133108.72655-5-philmd@linaro.org>
---
target/i386/helper.h | 6 +++---
.../{cc_helper_template.h => cc_helper_template.h.inc} | 0
| 0
.../shift_helper_template.h.inc} | 0
target/i386/tcg/cc_helper.c | 8 ++++----
target/i386/tcg/int_helper.c | 8 ++++----
6 files changed, 11 insertions(+), 11 deletions(-)
rename target/i386/tcg/{cc_helper_template.h => cc_helper_template.h.inc} (100%)
rename target/i386/{ops_sse_header.h => tcg/ops_sse_header.h.inc} (100%)
rename target/i386/{shift_helper_template.h => tcg/shift_helper_template.h.inc} (100%)
diff --git a/target/i386/helper.h b/target/i386/helper.h
index e627a93107..48609c210b 100644
--- a/target/i386/helper.h
+++ b/target/i386/helper.h
@@ -203,11 +203,11 @@ DEF_HELPER_1(enter_mmx, void, env)
DEF_HELPER_1(emms, void, env)
#define SHIFT 0
-#include "ops_sse_header.h"
+#include "tcg/ops_sse_header.h.inc"
#define SHIFT 1
-#include "ops_sse_header.h"
+#include "tcg/ops_sse_header.h.inc"
#define SHIFT 2
-#include "ops_sse_header.h"
+#include "tcg/ops_sse_header.h.inc"
DEF_HELPER_3(rclb, tl, env, tl, tl)
DEF_HELPER_3(rclw, tl, env, tl, tl)
diff --git a/target/i386/tcg/cc_helper_template.h b/target/i386/tcg/cc_helper_template.h.inc
similarity index 100%
rename from target/i386/tcg/cc_helper_template.h
rename to target/i386/tcg/cc_helper_template.h.inc
diff --git a/target/i386/ops_sse_header.h b/target/i386/tcg/ops_sse_header.h.inc
similarity index 100%
rename from target/i386/ops_sse_header.h
rename to target/i386/tcg/ops_sse_header.h.inc
diff --git a/target/i386/shift_helper_template.h b/target/i386/tcg/shift_helper_template.h.inc
similarity index 100%
rename from target/i386/shift_helper_template.h
rename to target/i386/tcg/shift_helper_template.h.inc
diff --git a/target/i386/tcg/cc_helper.c b/target/i386/tcg/cc_helper.c
index 6227dbb30b..c310bd842f 100644
--- a/target/i386/tcg/cc_helper.c
+++ b/target/i386/tcg/cc_helper.c
@@ -58,21 +58,21 @@ const uint8_t parity_table[256] = {
};
#define SHIFT 0
-#include "cc_helper_template.h"
+#include "cc_helper_template.h.inc"
#undef SHIFT
#define SHIFT 1
-#include "cc_helper_template.h"
+#include "cc_helper_template.h.inc"
#undef SHIFT
#define SHIFT 2
-#include "cc_helper_template.h"
+#include "cc_helper_template.h.inc"
#undef SHIFT
#ifdef TARGET_X86_64
#define SHIFT 3
-#include "cc_helper_template.h"
+#include "cc_helper_template.h.inc"
#undef SHIFT
#endif
diff --git a/target/i386/tcg/int_helper.c b/target/i386/tcg/int_helper.c
index 599ac968b0..05418f181f 100644
--- a/target/i386/tcg/int_helper.c
+++ b/target/i386/tcg/int_helper.c
@@ -448,20 +448,20 @@ target_ulong helper_pext(target_ulong src, target_ulong mask)
}
#define SHIFT 0
-#include "shift_helper_template.h"
+#include "shift_helper_template.h.inc"
#undef SHIFT
#define SHIFT 1
-#include "shift_helper_template.h"
+#include "shift_helper_template.h.inc"
#undef SHIFT
#define SHIFT 2
-#include "shift_helper_template.h"
+#include "shift_helper_template.h.inc"
#undef SHIFT
#ifdef TARGET_X86_64
#define SHIFT 3
-#include "shift_helper_template.h"
+#include "shift_helper_template.h.inc"
#undef SHIFT
#endif
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 10/17] hw/i2c: Enable an id for the pca954x devices
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2023-06-13 9:38 ` [PULL 09/17] target/i386: Rename helper template headers as '.h.inc' Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 11/17] hw/ide/ahci: Remove stray backslash Philippe Mathieu-Daudé
` (7 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Patrick Venture, Hao Wu, Philippe Mathieu-Daudé,
Corey Minyard
From: Patrick Venture <venture@google.com>
This allows the devices to be more readily found and specified.
Without setting the name field, they can only be found by device type
name, which doesn't let you specify the second of the same device type
behind a bus.
Tested: Verified that by default the device was findable with the name
'pca954x[77]', for an instance attached at that address.
Signed-off-by: Patrick Venture <venture@google.com>
Reviewed-by: Hao Wu <wuhaotsh@google.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Corey Minyard <cminyard@mvista.com>
Message-Id: <20230322172136.48010-1-venture@google.com>
[PMD: Fix typo in property name]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i2c/i2c_mux_pca954x.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index 3945de795c..db5db956a6 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -20,6 +20,7 @@
#include "hw/i2c/i2c_mux_pca954x.h"
#include "hw/i2c/smbus_slave.h"
#include "hw/qdev-core.h"
+#include "hw/qdev-properties.h"
#include "hw/sysbus.h"
#include "qemu/log.h"
#include "qemu/module.h"
@@ -43,6 +44,8 @@ typedef struct Pca954xState {
bool enabled[PCA9548_CHANNEL_COUNT];
I2CBus *bus[PCA9548_CHANNEL_COUNT];
+
+ char *name;
} Pca954xState;
/*
@@ -181,6 +184,17 @@ static void pca9548_class_init(ObjectClass *klass, void *data)
s->nchans = PCA9548_CHANNEL_COUNT;
}
+static void pca954x_realize(DeviceState *dev, Error **errp)
+{
+ Pca954xState *s = PCA954X(dev);
+ DeviceState *d = DEVICE(s);
+ if (s->name) {
+ d->id = g_strdup(s->name);
+ } else {
+ d->id = g_strdup_printf("pca954x[%x]", s->parent.i2c.address);
+ }
+}
+
static void pca954x_init(Object *obj)
{
Pca954xState *s = PCA954X(obj);
@@ -197,6 +211,11 @@ static void pca954x_init(Object *obj)
}
}
+static Property pca954x_props[] = {
+ DEFINE_PROP_STRING("name", Pca954xState, name),
+ DEFINE_PROP_END_OF_LIST()
+};
+
static void pca954x_class_init(ObjectClass *klass, void *data)
{
I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass);
@@ -209,9 +228,12 @@ static void pca954x_class_init(ObjectClass *klass, void *data)
rc->phases.enter = pca954x_enter_reset;
dc->desc = "Pca954x i2c-mux";
+ dc->realize = pca954x_realize;
k->write_data = pca954x_write_data;
k->receive_byte = pca954x_read_byte;
+
+ device_class_set_props(dc, pca954x_props);
}
static const TypeInfo pca954x_info[] = {
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 11/17] hw/ide/ahci: Remove stray backslash
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2023-06-13 9:38 ` [PULL 10/17] hw/i2c: Enable an id for the pca954x devices Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 12/17] hw/scsi/megasas: Silent GCC duplicated-cond warning Philippe Mathieu-Daudé
` (6 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Niklas Cassel, Philippe Mathieu-Daudé, John Snow
From: Niklas Cassel <niklas.cassel@wdc.com>
This backslash obviously does not belong here, so remove it.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-Id: <20230601134434.519805-2-nks@flawful.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ide/ahci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 4e76d6b191..48d550f633 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -690,7 +690,7 @@ static void ahci_reset_port(AHCIState *s, int port)
s->dev[port].port_state = STATE_RUN;
if (ide_state->drive_kind == IDE_CD) {
- ahci_set_signature(d, SATA_SIGNATURE_CDROM);\
+ ahci_set_signature(d, SATA_SIGNATURE_CDROM);
ide_state->status = SEEK_STAT | WRERR_STAT | READY_STAT;
} else {
ahci_set_signature(d, SATA_SIGNATURE_DISK);
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 12/17] hw/scsi/megasas: Silent GCC duplicated-cond warning
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2023-06-13 9:38 ` [PULL 11/17] hw/ide/ahci: Remove stray backslash Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 13/17] hw/char/parallel: Export struct ParallelState Philippe Mathieu-Daudé
` (5 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Philippe Mathieu-Daudé, Paolo Bonzini,
Philippe Mathieu-Daudé, Hannes Reinecke
From: Philippe Mathieu-Daudé <philmd@redhat.com>
GCC9 is confused when building with CFLAG -O3:
hw/scsi/megasas.c: In function ‘megasas_scsi_realize’:
hw/scsi/megasas.c:2387:26: error: duplicated ‘if’ condition [-Werror=duplicated-cond]
2387 | } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) {
hw/scsi/megasas.c:2385:19: note: previously used here
2385 | if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) {
cc1: all warnings being treated as errors
When this device was introduced in commit e8f943c3bcc, the author
cared about modularity, using a definition for the firmware limit.
However if the firmware limit isn't changed (MEGASAS_MAX_SGE = 128),
the code ends doing the same check twice.
Per the maintainer [*]:
> The original code assumed that one could change MFI_PASS_FRAME_SIZE,
> but it turned out not to be possible as it's being hardcoded in the
> drivers themselves (even though the interface provides mechanisms to
> query it). So we can remove the duplicate lines.
Add the 'MEGASAS_MIN_SGE' definition for the '64' magic value,
slightly rewrite the condition check to simplify a bit the logic
and remove the unnecessary / duplicated check.
[*] https://lore.kernel.org/qemu-devel/e0029fc5-882f-1d63-15e3-1c3dbe9b6a2c@suse.de/
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Message-Id: <20230328210126.16282-1-philmd@linaro.org>
---
hw/scsi/megasas.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 9cbbb16121..32c70c9e99 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -42,6 +42,7 @@
#define MEGASAS_MAX_FRAMES 2048 /* Firmware limit at 65535 */
#define MEGASAS_DEFAULT_FRAMES 1000 /* Windows requires this */
#define MEGASAS_GEN2_DEFAULT_FRAMES 1008 /* Windows requires this */
+#define MEGASAS_MIN_SGE 64
#define MEGASAS_MAX_SGE 128 /* Firmware limit */
#define MEGASAS_DEFAULT_SGE 80
#define MEGASAS_MAX_SECTORS 0xFFFF /* No real limit */
@@ -2356,6 +2357,7 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
MegasasState *s = MEGASAS(dev);
MegasasBaseClass *b = MEGASAS_GET_CLASS(s);
uint8_t *pci_conf;
+ uint32_t sge;
int i, bar_type;
Error *err = NULL;
int ret;
@@ -2424,13 +2426,15 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
if (!s->hba_serial) {
s->hba_serial = g_strdup(MEGASAS_HBA_SERIAL);
}
- if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) {
- s->fw_sge = MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE;
- } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) {
- s->fw_sge = 128 - MFI_PASS_FRAME_SIZE;
- } else {
- s->fw_sge = 64 - MFI_PASS_FRAME_SIZE;
+
+ sge = s->fw_sge + MFI_PASS_FRAME_SIZE;
+ if (sge < MEGASAS_MIN_SGE) {
+ sge = MEGASAS_MIN_SGE;
+ } else if (sge >= MEGASAS_MAX_SGE) {
+ sge = MEGASAS_MAX_SGE;
}
+ s->fw_sge = sge - MFI_PASS_FRAME_SIZE;
+
if (s->fw_cmds > MEGASAS_MAX_FRAMES) {
s->fw_cmds = MEGASAS_MAX_FRAMES;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 13/17] hw/char/parallel: Export struct ParallelState
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2023-06-13 9:38 ` [PULL 12/17] hw/scsi/megasas: Silent GCC duplicated-cond warning Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 14/17] hw/char/parallel-isa: Export struct ISAParallelState Philippe Mathieu-Daudé
` (4 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Bernhard Beschow, Mark Cave-Ayland,
Philippe Mathieu-Daudé
From: Bernhard Beschow <shentey@gmail.com>
Exporting ParallelState is a precondition for exporing TYPE_ISA_PARALLEL to be
performed in the next patch.
Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230612081238.1742-2-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/char/parallel.h | 21 +++++++++++++++++++++
hw/char/parallel.c | 20 --------------------
2 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h
index 29d2876d00..9f76edca81 100644
--- a/include/hw/char/parallel.h
+++ b/include/hw/char/parallel.h
@@ -1,9 +1,30 @@
#ifndef HW_PARALLEL_H
#define HW_PARALLEL_H
+#include "exec/ioport.h"
+#include "exec/memory.h"
#include "hw/isa/isa.h"
+#include "hw/irq.h"
+#include "chardev/char-fe.h"
#include "chardev/char.h"
+typedef struct ParallelState {
+ MemoryRegion iomem;
+ uint8_t dataw;
+ uint8_t datar;
+ uint8_t status;
+ uint8_t control;
+ qemu_irq irq;
+ int irq_pending;
+ CharBackend chr;
+ int hw_driver;
+ int epp_timeout;
+ uint32_t last_read_offset; /* For debugging */
+ /* Memory-mapped interface */
+ int it_shift;
+ PortioList portio_list;
+} ParallelState;
+
#define TYPE_ISA_PARALLEL "isa-parallel"
void parallel_hds_isa_init(ISABus *bus, int n);
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index 3d32589bb3..e75fc5019d 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -27,10 +27,7 @@
#include "qapi/error.h"
#include "qemu/module.h"
#include "chardev/char-parallel.h"
-#include "chardev/char-fe.h"
#include "hw/acpi/acpi_aml_interface.h"
-#include "hw/irq.h"
-#include "hw/isa/isa.h"
#include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h"
#include "migration/vmstate.h"
@@ -76,23 +73,6 @@
#define PARA_CTR_SIGNAL (PARA_CTR_SELECT|PARA_CTR_INIT|PARA_CTR_AUTOLF|PARA_CTR_STROBE)
-typedef struct ParallelState {
- MemoryRegion iomem;
- uint8_t dataw;
- uint8_t datar;
- uint8_t status;
- uint8_t control;
- qemu_irq irq;
- int irq_pending;
- CharBackend chr;
- int hw_driver;
- int epp_timeout;
- uint32_t last_read_offset; /* For debugging */
- /* Memory-mapped interface */
- int it_shift;
- PortioList portio_list;
-} ParallelState;
-
OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
struct ISAParallelState {
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 14/17] hw/char/parallel-isa: Export struct ISAParallelState
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2023-06-13 9:38 ` [PULL 13/17] hw/char/parallel: Export struct ParallelState Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 15/17] exec/ram_addr: Return number of dirty pages in cpu_physical_memory_set_dirty_lebitmap() Philippe Mathieu-Daudé
` (3 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Bernhard Beschow, Mark Cave-Ayland,
Philippe Mathieu-Daudé
From: Bernhard Beschow <shentey@gmail.com>
Allows the struct to be embedded directly into device models without additional
allocation.
Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230612081238.1742-3-shentey@gmail.com>
[PMD: Update MAINTAINERS entry and use SPDX license identifier]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 2 +-
include/hw/char/parallel-isa.h | 30 ++++++++++++++++++++++++++++++
include/hw/char/parallel.h | 2 --
hw/char/parallel-isa.c | 1 +
hw/char/parallel.c | 12 +-----------
hw/i386/pc_piix.c | 2 +-
hw/i386/pc_q35.c | 2 +-
hw/isa/isa-superio.c | 1 +
hw/sparc64/sun4u.c | 2 +-
9 files changed, 37 insertions(+), 17 deletions(-)
create mode 100644 include/hw/char/parallel-isa.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 4a80a38511..88b5a7ee0a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1740,7 +1740,7 @@ F: hw/rtc/mc146818rtc*
F: hw/watchdog/wdt_ib700.c
F: hw/watchdog/wdt_i6300esb.c
F: include/hw/display/vga.h
-F: include/hw/char/parallel.h
+F: include/hw/char/parallel*.h
F: include/hw/dma/i8257.h
F: include/hw/i2c/pm_smbus.h
F: include/hw/input/i8042.h
diff --git a/include/hw/char/parallel-isa.h b/include/hw/char/parallel-isa.h
new file mode 100644
index 0000000000..d24ccecf05
--- /dev/null
+++ b/include/hw/char/parallel-isa.h
@@ -0,0 +1,30 @@
+/*
+ * QEMU ISA Parallel PORT emulation
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ * Copyright (c) 2007 Marko Kohtala
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef HW_PARALLEL_ISA_H
+#define HW_PARALLEL_ISA_H
+
+#include "parallel.h"
+
+#include "hw/isa/isa.h"
+#include "qom/object.h"
+
+#define TYPE_ISA_PARALLEL "isa-parallel"
+OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
+
+struct ISAParallelState {
+ ISADevice parent_obj;
+
+ uint32_t index;
+ uint32_t iobase;
+ uint32_t isairq;
+ ParallelState state;
+};
+
+#endif /* HW_PARALLEL_ISA_H */
diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h
index 9f76edca81..7b5a309a03 100644
--- a/include/hw/char/parallel.h
+++ b/include/hw/char/parallel.h
@@ -25,8 +25,6 @@ typedef struct ParallelState {
PortioList portio_list;
} ParallelState;
-#define TYPE_ISA_PARALLEL "isa-parallel"
-
void parallel_hds_isa_init(ISABus *bus, int n);
bool parallel_mm_init(MemoryRegion *address_space,
diff --git a/hw/char/parallel-isa.c b/hw/char/parallel-isa.c
index 547ae69304..ab0f879998 100644
--- a/hw/char/parallel-isa.c
+++ b/hw/char/parallel-isa.c
@@ -13,6 +13,7 @@
#include "sysemu/sysemu.h"
#include "hw/isa/isa.h"
#include "hw/qdev-properties.h"
+#include "hw/char/parallel-isa.h"
#include "hw/char/parallel.h"
#include "qapi/error.h"
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index e75fc5019d..147c900f0d 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -31,6 +31,7 @@
#include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h"
#include "migration/vmstate.h"
+#include "hw/char/parallel-isa.h"
#include "hw/char/parallel.h"
#include "sysemu/reset.h"
#include "sysemu/sysemu.h"
@@ -73,17 +74,6 @@
#define PARA_CTR_SIGNAL (PARA_CTR_SELECT|PARA_CTR_INIT|PARA_CTR_AUTOLF|PARA_CTR_STROBE)
-OBJECT_DECLARE_SIMPLE_TYPE(ISAParallelState, ISA_PARALLEL)
-
-struct ISAParallelState {
- ISADevice parent_obj;
-
- uint32_t index;
- uint32_t iobase;
- uint32_t isairq;
- ParallelState state;
-};
-
static void parallel_update_irq(ParallelState *s)
{
if (s->irq_pending)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 42af03dbb4..44146e6ff5 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -26,7 +26,7 @@
#include CONFIG_DEVICES
#include "qemu/units.h"
-#include "hw/char/parallel.h"
+#include "hw/char/parallel-isa.h"
#include "hw/dma/i8257.h"
#include "hw/loader.h"
#include "hw/i386/x86.h"
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 6155427e48..a9a59ed42b 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -30,7 +30,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
-#include "hw/char/parallel.h"
+#include "hw/char/parallel-isa.h"
#include "hw/loader.h"
#include "hw/i2c/smbus_eeprom.h"
#include "hw/rtc/mc146818rtc.h"
diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c
index 9292ec3bcf..7dbfc374da 100644
--- a/hw/isa/isa-superio.c
+++ b/hw/isa/isa-superio.c
@@ -21,6 +21,7 @@
#include "hw/isa/superio.h"
#include "hw/qdev-properties.h"
#include "hw/input/i8042.h"
+#include "hw/char/parallel-isa.h"
#include "hw/char/serial.h"
#include "trace.h"
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index e2858a0331..29e9b6cc26 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -35,7 +35,7 @@
#include "hw/qdev-properties.h"
#include "hw/pci-host/sabre.h"
#include "hw/char/serial.h"
-#include "hw/char/parallel.h"
+#include "hw/char/parallel-isa.h"
#include "hw/rtc/m48t59.h"
#include "migration/vmstate.h"
#include "hw/input/i8042.h"
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 15/17] exec/ram_addr: Return number of dirty pages in cpu_physical_memory_set_dirty_lebitmap()
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2023-06-13 9:38 ` [PULL 14/17] hw/char/parallel-isa: Export struct ISAParallelState Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 16/17] hw/vfio: Add number of dirty pages to vfio_get_dirty_bitmap tracepoint Philippe Mathieu-Daudé
` (2 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Joao Martins, Peter Xu, Philippe Mathieu-Daudé
From: Joao Martins <joao.m.martins@oracle.com>
In preparation for including the number of dirty pages in the
vfio_get_dirty_bitmap() tracepoint, return the number of dirty pages in
cpu_physical_memory_set_dirty_lebitmap() similar to
cpu_physical_memory_sync_dirty_bitmap().
To avoid counting twice when GLOBAL_DIRTY_RATE is enabled, stash the
number of bits set per bitmap quad in a variable (@nbits) and reuse it
there.
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230530180556.24441-2-joao.m.martins@oracle.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/ram_addr.h | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 90a8269290..9f2e3893f5 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -334,14 +334,23 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
}
#if !defined(_WIN32)
-static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
- ram_addr_t start,
- ram_addr_t pages)
+
+/*
+ * Contrary to cpu_physical_memory_sync_dirty_bitmap() this function returns
+ * the number of dirty pages in @bitmap passed as argument. On the other hand,
+ * cpu_physical_memory_sync_dirty_bitmap() returns newly dirtied pages that
+ * weren't set in the global migration bitmap.
+ */
+static inline
+uint64_t cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
+ ram_addr_t start,
+ ram_addr_t pages)
{
unsigned long i, j;
- unsigned long page_number, c;
+ unsigned long page_number, c, nbits;
hwaddr addr;
ram_addr_t ram_addr;
+ uint64_t num_dirty = 0;
unsigned long len = (pages + HOST_LONG_BITS - 1) / HOST_LONG_BITS;
unsigned long hpratio = qemu_real_host_page_size() / TARGET_PAGE_SIZE;
unsigned long page = BIT_WORD(start >> TARGET_PAGE_BITS);
@@ -369,6 +378,7 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
if (bitmap[k]) {
unsigned long temp = leul_to_cpu(bitmap[k]);
+ nbits = ctpopl(temp);
qatomic_or(&blocks[DIRTY_MEMORY_VGA][idx][offset], temp);
if (global_dirty_tracking) {
@@ -377,10 +387,12 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
temp);
if (unlikely(
global_dirty_tracking & GLOBAL_DIRTY_DIRTY_RATE)) {
- total_dirty_pages += ctpopl(temp);
+ total_dirty_pages += nbits;
}
}
+ num_dirty += nbits;
+
if (tcg_enabled()) {
qatomic_or(&blocks[DIRTY_MEMORY_CODE][idx][offset],
temp);
@@ -409,9 +421,11 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
for (i = 0; i < len; i++) {
if (bitmap[i] != 0) {
c = leul_to_cpu(bitmap[i]);
+ nbits = ctpopl(c);
if (unlikely(global_dirty_tracking & GLOBAL_DIRTY_DIRTY_RATE)) {
- total_dirty_pages += ctpopl(c);
+ total_dirty_pages += nbits;
}
+ num_dirty += nbits;
do {
j = ctzl(c);
c &= ~(1ul << j);
@@ -424,6 +438,8 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
}
}
}
+
+ return num_dirty;
}
#endif /* not _WIN32 */
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 16/17] hw/vfio: Add number of dirty pages to vfio_get_dirty_bitmap tracepoint
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2023-06-13 9:38 ` [PULL 15/17] exec/ram_addr: Return number of dirty pages in cpu_physical_memory_set_dirty_lebitmap() Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-13 9:38 ` [PULL 17/17] exec/memory: Introduce RAM_NAMED_FILE flag Philippe Mathieu-Daudé
2023-06-14 4:39 ` [PULL 00/17] Misc patches for 2023-06-13 Richard Henderson
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Joao Martins, Cédric Le Goater,
Philippe Mathieu-Daudé, Alex Williamson
From: Joao Martins <joao.m.martins@oracle.com>
Include the number of dirty pages on the vfio_get_dirty_bitmap tracepoint.
These are fetched from the newly added return value in
cpu_physical_memory_set_dirty_lebitmap().
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <20230530180556.24441-3-joao.m.martins@oracle.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/common.c | 7 ++++---
hw/vfio/trace-events | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 78358ede27..fa8fd949b1 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1747,6 +1747,7 @@ static int vfio_get_dirty_bitmap(VFIOContainer *container, uint64_t iova,
{
bool all_device_dirty_tracking =
vfio_devices_all_device_dirty_tracking(container);
+ uint64_t dirty_pages;
VFIOBitmap vbmap;
int ret;
@@ -1772,11 +1773,11 @@ static int vfio_get_dirty_bitmap(VFIOContainer *container, uint64_t iova,
goto out;
}
- cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, ram_addr,
- vbmap.pages);
+ dirty_pages = cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, ram_addr,
+ vbmap.pages);
trace_vfio_get_dirty_bitmap(container->fd, iova, size, vbmap.size,
- ram_addr);
+ ram_addr, dirty_pages);
out:
g_free(vbmap.bitmap);
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
index 646e42fd27..cfb60c354d 100644
--- a/hw/vfio/trace-events
+++ b/hw/vfio/trace-events
@@ -120,7 +120,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic
vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]"
vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%08x"
vfio_dma_unmap_overflow_workaround(void) ""
-vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start) "container fd=%d, iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64
+vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size, uint64_t bitmap_size, uint64_t start, uint64_t dirty_pages) "container fd=%d, iova=0x%"PRIx64" size= 0x%"PRIx64" bitmap_size=0x%"PRIx64" start=0x%"PRIx64" dirty_pages=%"PRIu64
vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu dirty @ 0x%"PRIx64" - 0x%"PRIx64
# platform.c
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PULL 17/17] exec/memory: Introduce RAM_NAMED_FILE flag
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2023-06-13 9:38 ` [PULL 16/17] hw/vfio: Add number of dirty pages to vfio_get_dirty_bitmap tracepoint Philippe Mathieu-Daudé
@ 2023-06-13 9:38 ` Philippe Mathieu-Daudé
2023-06-14 4:39 ` [PULL 00/17] Misc patches for 2023-06-13 Richard Henderson
17 siblings, 0 replies; 19+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-13 9:38 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Steve Sistare, Peter Xu, Philippe Mathieu-Daudé
From: Steve Sistare <steven.sistare@oracle.com>
migrate_ignore_shared() is an optimization that avoids copying memory
that is visible and can be mapped on the target. However, a
memory-backend-ram or a memory-backend-memfd block with the RAM_SHARED
flag set is not migrated when migrate_ignore_shared() is true. This is
wrong, because the block has no named backing store, and its contents will
be lost. To fix, ignore shared memory iff it is a named file. Define a
new flag RAM_NAMED_FILE to distinguish this case.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <1686151116-253260-1-git-send-email-steven.sistare@oracle.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
qapi/migration.json | 4 ++--
include/exec/cpu-common.h | 1 +
include/exec/memory.h | 3 +++
backends/hostmem-file.c | 1 +
migration/ram.c | 3 ++-
softmmu/physmem.c | 7 ++++++-
6 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/qapi/migration.json b/qapi/migration.json
index 179af0c4d8..5bb5ab82a0 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -465,8 +465,8 @@
# block devices (and thus take locks) immediately at the end of
# migration. (since 3.0)
#
-# @x-ignore-shared: If enabled, QEMU will not migrate shared memory
-# (since 4.0)
+# @x-ignore-shared: If enabled, QEMU will not migrate shared memory that is
+# accessible on the destination machine. (since 4.0)
#
# @validate-uuid: Send the UUID of the source to allow the destination
# to ensure it is the same. (since 4.2)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index e5a55ede5f..87dc9a752c 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -93,6 +93,7 @@ void qemu_ram_set_uf_zeroable(RAMBlock *rb);
bool qemu_ram_is_migratable(RAMBlock *rb);
void qemu_ram_set_migratable(RAMBlock *rb);
void qemu_ram_unset_migratable(RAMBlock *rb);
+bool qemu_ram_is_named_file(RAMBlock *rb);
int qemu_ram_get_fd(RAMBlock *rb);
size_t qemu_ram_pagesize(RAMBlock *block);
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c3661b2276..47c2e0221c 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -232,6 +232,9 @@ typedef struct IOMMUTLBEvent {
/* RAM that isn't accessible through normal means. */
#define RAM_PROTECTED (1 << 8)
+/* RAM is an mmap-ed named file */
+#define RAM_NAMED_FILE (1 << 9)
+
static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn,
IOMMUNotifierFlag flags,
hwaddr start, hwaddr end,
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 38ea65bec5..b4335a80e6 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -57,6 +57,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
ram_flags = backend->share ? RAM_SHARED : 0;
ram_flags |= backend->reserve ? 0 : RAM_NORESERVE;
ram_flags |= fb->is_pmem ? RAM_PMEM : 0;
+ ram_flags |= RAM_NAMED_FILE;
memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), name,
backend->size, fb->align, ram_flags,
fb->mem_path, fb->offset, fb->readonly,
diff --git a/migration/ram.c b/migration/ram.c
index 88a6c82e63..5283a75f02 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -197,7 +197,8 @@ static bool postcopy_preempt_active(void)
bool ramblock_is_ignored(RAMBlock *block)
{
return !qemu_ram_is_migratable(block) ||
- (migrate_ignore_shared() && qemu_ram_is_shared(block));
+ (migrate_ignore_shared() && qemu_ram_is_shared(block)
+ && qemu_ram_is_named_file(block));
}
#undef RAMBLOCK_FOREACH
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 588d0d166b..6bdd944fe8 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -1570,6 +1570,11 @@ void qemu_ram_unset_migratable(RAMBlock *rb)
rb->flags &= ~RAM_MIGRATABLE;
}
+bool qemu_ram_is_named_file(RAMBlock *rb)
+{
+ return rb->flags & RAM_NAMED_FILE;
+}
+
int qemu_ram_get_fd(RAMBlock *rb)
{
return rb->fd;
@@ -1880,7 +1885,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
/* Just support these ram flags by now. */
assert((ram_flags & ~(RAM_SHARED | RAM_PMEM | RAM_NORESERVE |
- RAM_PROTECTED)) == 0);
+ RAM_PROTECTED | RAM_NAMED_FILE)) == 0);
if (xen_enabled()) {
error_setg(errp, "-mem-path not supported with Xen");
--
2.38.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PULL 00/17] Misc patches for 2023-06-13
2023-06-13 9:38 [PULL 00/17] Misc patches for 2023-06-13 Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2023-06-13 9:38 ` [PULL 17/17] exec/memory: Introduce RAM_NAMED_FILE flag Philippe Mathieu-Daudé
@ 2023-06-14 4:39 ` Richard Henderson
17 siblings, 0 replies; 19+ messages in thread
From: Richard Henderson @ 2023-06-14 4:39 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: qemu-block
On 6/13/23 11:38, Philippe Mathieu-Daudé wrote:
> Misc patches, some accumulated since too long.
>
> The following changes since commit fdd0df5340a8ebc8de88078387ebc85c5af7b40f:
>
> Merge tag 'pull-ppc-20230610' ofhttps://gitlab.com/danielhb/qemu into staging (2023-06-10 07:25:00 -0700)
>
> are available in the Git repository at:
>
> https://github.com/philmd/qemu.git tags/misc-20230613
>
> for you to fetch changes up to b0182e537e5aba38031a5009cb16d5e924342458:
>
> exec/memory: Introduce RAM_NAMED_FILE flag (2023-06-13 11:28:58 +0200)
>
> ----------------------------------------------------------------
> Misc patches queue
>
> - user emulation: Preserve environment variable order
> - macos/darwin/hvf: Fix build warnings, slighly optimize DCache flush
> - target/i386: Minor cleanups, rename template headers with '.inc' suffix
> - target/hppa: Avoid building int_helper.o on user emulation
> - hw: Add 'name' property to pca954x, export ISAParallelState, silent warnings
> - hw/vfio: Trace number of bitmap dirty pages
> - exec/memory: Introduce RAM_NAMED_FILE to distinct block without named backing store
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 19+ messages in thread