Skip to content

Commit 2c1a568

Browse files
Merge commit '9a4750143ce' into merge
Signed-off-by: Francisco Iglesias <[email protected]>
2 parents 83b7871 + 9a47501 commit 2c1a568

28 files changed

+639
-60
lines changed

Diff for: .gitlab-ci.d/crossbuilds.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ cross-win32-system:
165165
job: win32-fedora-cross-container
166166
variables:
167167
IMAGE: fedora-win32-cross
168-
EXTRA_CONFIGURE_OPTS: --enable-fdt=internal
168+
EXTRA_CONFIGURE_OPTS: --enable-fdt=internal --disable-plugins
169169
CROSS_SKIP_TARGETS: alpha-softmmu avr-softmmu hppa-softmmu m68k-softmmu
170170
microblazeel-softmmu mips64el-softmmu nios2-softmmu
171171
artifacts:
@@ -179,7 +179,7 @@ cross-win64-system:
179179
job: win64-fedora-cross-container
180180
variables:
181181
IMAGE: fedora-win64-cross
182-
EXTRA_CONFIGURE_OPTS: --enable-fdt=internal
182+
EXTRA_CONFIGURE_OPTS: --enable-fdt=internal --disable-plugins
183183
CROSS_SKIP_TARGETS: alpha-softmmu avr-softmmu hppa-softmmu
184184
m68k-softmmu microblazeel-softmmu nios2-softmmu
185185
or1k-softmmu rx-softmmu sh4eb-softmmu sparc64-softmmu

Diff for: .gitlab-ci.d/windows.yml

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
- .\msys64\usr\bin\bash -lc "pacman -Sy --noconfirm --needed
7373
bison diffutils flex
7474
git grep make sed
75+
$MINGW_TARGET-binutils
7576
$MINGW_TARGET-capstone
7677
$MINGW_TARGET-ccache
7778
$MINGW_TARGET-curl

Diff for: .mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ malc <[email protected]> malc <malc@c046a42c-6fe2-441c-8c8c-71466251a162>
3030
# Corrupted Author fields
3131
3232
Andreas Färber <[email protected]> Andreas Färber <andreas.faerber>
33+
3334
Jason Wang <[email protected]> Jason Wang <jasowang>
3435
3536
3637
38+
3739

3840
# There is also a:
3941
# (no author) <(no author)@c046a42c-6fe2-441c-8c8c-71466251a162>

Diff for: MAINTAINERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -2941,7 +2941,7 @@ F: gdbstub/*
29412941
F: include/exec/gdbstub.h
29422942
F: include/gdbstub/*
29432943
F: gdb-xml/
2944-
F: tests/tcg/multiarch/gdbstub/
2944+
F: tests/tcg/multiarch/gdbstub/*
29452945
F: scripts/feature_to_c.py
29462946
F: scripts/probe-gdb-support.py
29472947

Diff for: configs/targets/loongarch64-linux-user.mak

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Default configuration for loongarch64-linux-user
22
TARGET_ARCH=loongarch64
33
TARGET_BASE_ARCH=loongarch
4+
TARGET_XML_FILES=gdb-xml/loongarch-base64.xml gdb-xml/loongarch-fpu.xml

Diff for: configure

+11-2
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ fi
309309
ar="${AR-${cross_prefix}ar}"
310310
as="${AS-${cross_prefix}as}"
311311
ccas="${CCAS-$cc}"
312+
dlltool="${DLLTOOL-${cross_prefix}dlltool}"
312313
objcopy="${OBJCOPY-${cross_prefix}objcopy}"
313314
ld="${LD-${cross_prefix}ld}"
314315
ranlib="${RANLIB-${cross_prefix}ranlib}"
@@ -1010,9 +1011,9 @@ if test "$targetos" = "bogus"; then
10101011
fi
10111012

10121013
# test for any invalid configuration combinations
1013-
if test "$targetos" = "windows"; then
1014+
if test "$targetos" = "windows" && ! has "$dlltool"; then
10141015
if test "$plugins" = "yes"; then
1015-
error_exit "TCG plugins not currently supported on Windows platforms"
1016+
error_exit "TCG plugins requires dlltool to build on Windows platforms"
10161017
fi
10171018
plugins="no"
10181019
fi
@@ -1659,9 +1660,15 @@ echo "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak
16591660
echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak
16601661
echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak
16611662
echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak
1663+
if test "$targetos" = windows; then
1664+
echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak
1665+
fi
16621666
if test "$targetos" = darwin; then
16631667
echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak
16641668
fi
1669+
if test "$targetos" = windows; then
1670+
echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak
1671+
fi
16651672

16661673
# tests/tcg configuration
16671674
(config_host_mak=tests/tcg/config-host.mak
@@ -1764,6 +1771,7 @@ if test "$skip_meson" = no; then
17641771
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
17651772
test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
17661773
echo "ar = [$(meson_quote $ar)]" >> $cross
1774+
echo "dlltool = [$(meson_quote $dlltool)]" >> $cross
17671775
echo "nm = [$(meson_quote $nm)]" >> $cross
17681776
echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
17691777
echo "pkg-config = [$(meson_quote $pkg_config)]" >> $cross
@@ -1869,6 +1877,7 @@ preserve_env CC
18691877
preserve_env CFLAGS
18701878
preserve_env CXX
18711879
preserve_env CXXFLAGS
1880+
preserve_env DLLTOOL
18721881
preserve_env LD
18731882
preserve_env LDFLAGS
18741883
preserve_env LD_LIBRARY_PATH

Diff for: contrib/gitdm/domain-map

+4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ amd.com AMD
1212
aspeedtech.com ASPEED Technology Inc.
1313
baidu.com Baidu
1414
bytedance.com ByteDance
15+
cestc.cn Cestc
1516
cmss.chinamobile.com China Mobile
1617
citrix.com Citrix
1718
crudebyte.com Crudebyte
1819
chinatelecom.cn China Telecom
20+
daynix.com Daynix
1921
eldorado.org.br Instituto de Pesquisas Eldorado
2022
fb.com Facebook
2123
fujitsu.com Fujitsu
2224
google.com Google
2325
greensocs.com GreenSocs
26+
hisilicon.com Huawei
2427
huawei.com Huawei
2528
ibm.com IBM
2629
igalia.com Igalia
@@ -38,6 +41,7 @@ proxmox.com Proxmox
3841
quicinc.com Qualcomm Innovation Center
3942
redhat.com Red Hat
4043
rev.ng rev.ng Labs
44+
rivosinc.com Rivos Inc
4145
rt-rk.com RT-RK
4246
samsung.com Samsung
4347
siemens.com Siemens

Diff for: contrib/plugins/Makefile

+22-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,25 @@ NAMES += execlog
1717
NAMES += hotblocks
1818
NAMES += hotpages
1919
NAMES += howvec
20+
21+
# The lockstep example communicates using unix sockets,
22+
# and can't be easily made to work on windows.
23+
ifneq ($(CONFIG_WIN32),y)
2024
NAMES += lockstep
25+
endif
26+
2127
NAMES += hwprofile
2228
NAMES += cache
2329
NAMES += drcov
2430

25-
SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
31+
ifeq ($(CONFIG_WIN32),y)
32+
SO_SUFFIX := .dll
33+
LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0)
34+
else
35+
SO_SUFFIX := .so
36+
endif
37+
38+
SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES)))
2639

2740
# The main QEMU uses Glib extensively so it's perfectly fine to use it
2841
# in plugins (which many example do).
@@ -35,15 +48,20 @@ all: $(SONAMES)
3548
%.o: %.c
3649
$(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $<
3750

38-
lib%.so: %.o
39-
ifeq ($(CONFIG_DARWIN),y)
51+
ifeq ($(CONFIG_WIN32),y)
52+
lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/qemu_plugin_api.lib
53+
$(CC) -shared -o $@ $^ $(LDLIBS)
54+
else ifeq ($(CONFIG_DARWIN),y)
55+
lib%$(SO_SUFFIX): %.o
4056
$(CC) -bundle -Wl,-undefined,dynamic_lookup -o $@ $^ $(LDLIBS)
4157
else
58+
lib%$(SO_SUFFIX): %.o
4259
$(CC) -shared -o $@ $^ $(LDLIBS)
4360
endif
4461

62+
4563
clean:
46-
rm -f *.o *.so *.d
64+
rm -f *.o *$(SO_SUFFIX) *.d
4765
rm -Rf .libs
4866

4967
.PHONY: all clean

Diff for: contrib/plugins/win32_linker.c

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2023, Greg Manning <[email protected]>
3+
*
4+
* This hook, __pfnDliFailureHook2, is documented in the microsoft documentation here:
5+
* https://learn.microsoft.com/en-us/cpp/build/reference/error-handling-and-notification
6+
* It gets called when a delay-loaded DLL encounters various errors.
7+
* We handle the specific case of a DLL looking for a "qemu.exe",
8+
* and give it the running executable (regardless of what it is named).
9+
*
10+
* This work is licensed under the terms of the GNU LGPL, version 2 or later.
11+
* See the COPYING.LIB file in the top-level directory.
12+
*/
13+
14+
#include <windows.h>
15+
#include <delayimp.h>
16+
17+
FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli);
18+
19+
20+
PfnDliHook __pfnDliFailureHook2 = dll_failure_hook;
21+
22+
FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli) {
23+
if (dliNotify == dliFailLoadLib) {
24+
/* If the failing request was for qemu.exe, ... */
25+
if (strcmp(pdli->szDll, "qemu.exe") == 0) {
26+
/* Then pass back a pointer to the top level module. */
27+
HMODULE top = GetModuleHandle(NULL);
28+
return (FARPROC) top;
29+
}
30+
}
31+
/* Otherwise we can't do anything special. */
32+
return 0;
33+
}
34+

Diff for: cpu-target.c

-11
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "hw/core/accel-cpu.h"
4444
#include "trace/trace-root.h"
4545
#include "qemu/accel.h"
46-
#include "qemu/plugin.h"
4746

4847
uintptr_t qemu_host_page_size;
4948
intptr_t qemu_host_page_mask;
@@ -154,11 +153,6 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
154153
/* Wait until cpu initialization complete before exposing cpu. */
155154
cpu_list_add(cpu);
156155

157-
/* Plugin initialization must wait until cpu_index assigned. */
158-
if (tcg_enabled()) {
159-
qemu_plugin_vcpu_init_hook(cpu);
160-
}
161-
162156
#ifdef CONFIG_USER_ONLY
163157
assert(qdev_get_vmsd(DEVICE(cpu)) == NULL ||
164158
qdev_get_vmsd(DEVICE(cpu))->unmigratable);
@@ -187,11 +181,6 @@ void cpu_exec_unrealizefn(CPUState *cpu)
187181
}
188182
#endif
189183

190-
/* Call the plugin hook before clearing cpu->cpu_index in cpu_list_remove */
191-
if (tcg_enabled()) {
192-
qemu_plugin_vcpu_exit_hook(cpu);
193-
}
194-
195184
cpu_list_remove(cpu);
196185
/*
197186
* Now that the vCPU has been removed from the RCU list, we can call

Diff for: gdb-xml/arm-neon.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<reg name="q8" bitsize="128" type="neon_q"/>
7777
<reg name="q9" bitsize="128" type="neon_q"/>
7878
<reg name="q10" bitsize="128" type="neon_q"/>
79-
<reg name="q10" bitsize="128" type="neon_q"/>
79+
<reg name="q11" bitsize="128" type="neon_q"/>
8080
<reg name="q12" bitsize="128" type="neon_q"/>
8181
<reg name="q13" bitsize="128" type="neon_q"/>
8282
<reg name="q14" bitsize="128" type="neon_q"/>

Diff for: gdbstub/gdbstub.c

+78
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,84 @@ static const char *get_feature_xml(const char *p, const char **newp,
415415
return NULL;
416416
}
417417

418+
void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature,
419+
const char *name, const char *xmlname,
420+
int base_reg)
421+
{
422+
char *header = g_markup_printf_escaped(
423+
"<?xml version=\"1.0\"?>"
424+
"<!DOCTYPE feature SYSTEM \"gdb-target.dtd\">"
425+
"<feature name=\"%s\">",
426+
name);
427+
428+
builder->feature = feature;
429+
builder->xml = g_ptr_array_new();
430+
g_ptr_array_add(builder->xml, header);
431+
builder->base_reg = base_reg;
432+
feature->xmlname = xmlname;
433+
feature->num_regs = 0;
434+
}
435+
436+
void gdb_feature_builder_append_tag(const GDBFeatureBuilder *builder,
437+
const char *format, ...)
438+
{
439+
va_list ap;
440+
va_start(ap, format);
441+
g_ptr_array_add(builder->xml, g_markup_vprintf_escaped(format, ap));
442+
va_end(ap);
443+
}
444+
445+
void gdb_feature_builder_append_reg(const GDBFeatureBuilder *builder,
446+
const char *name,
447+
int bitsize,
448+
int regnum,
449+
const char *type,
450+
const char *group)
451+
{
452+
if (builder->feature->num_regs < regnum) {
453+
builder->feature->num_regs = regnum;
454+
}
455+
456+
if (group) {
457+
gdb_feature_builder_append_tag(
458+
builder,
459+
"<reg name=\"%s\" bitsize=\"%d\" regnum=\"%d\" type=\"%s\" group=\"%s\"/>",
460+
name, bitsize, builder->base_reg + regnum, type, group);
461+
} else {
462+
gdb_feature_builder_append_tag(
463+
builder,
464+
"<reg name=\"%s\" bitsize=\"%d\" regnum=\"%d\" type=\"%s\"/>",
465+
name, bitsize, builder->base_reg + regnum, type);
466+
}
467+
}
468+
469+
void gdb_feature_builder_end(const GDBFeatureBuilder *builder)
470+
{
471+
g_ptr_array_add(builder->xml, (void *)"</feature>");
472+
g_ptr_array_add(builder->xml, NULL);
473+
474+
builder->feature->xml = g_strjoinv(NULL, (void *)builder->xml->pdata);
475+
476+
for (guint i = 0; i < builder->xml->len - 2; i++) {
477+
g_free(g_ptr_array_index(builder->xml, i));
478+
}
479+
480+
g_ptr_array_free(builder->xml, TRUE);
481+
}
482+
483+
const GDBFeature *gdb_find_static_feature(const char *xmlname)
484+
{
485+
const GDBFeature *feature;
486+
487+
for (feature = gdb_static_features; feature->xmlname; feature++) {
488+
if (!strcmp(feature->xmlname, xmlname)) {
489+
return feature;
490+
}
491+
}
492+
493+
g_assert_not_reached();
494+
}
495+
418496
static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg)
419497
{
420498
CPUClass *cc = CPU_GET_CLASS(cpu);

Diff for: hw/core/cpu-common.c

+10
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,23 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
220220
cpu_resume(cpu);
221221
}
222222

223+
/* Plugin initialization must wait until the cpu is fully realized. */
224+
if (tcg_enabled()) {
225+
qemu_plugin_vcpu_init_hook(cpu);
226+
}
227+
223228
/* NOTE: latest generic point where the cpu is fully realized */
224229
}
225230

226231
static void cpu_common_unrealizefn(DeviceState *dev)
227232
{
228233
CPUState *cpu = CPU(dev);
229234

235+
/* Call the plugin hook before clearing the cpu is fully unrealized */
236+
if (tcg_enabled()) {
237+
qemu_plugin_vcpu_exit_hook(cpu);
238+
}
239+
230240
/* NOTE: latest generic point before the cpu is fully unrealized */
231241
cpu_exec_unrealizefn(cpu);
232242
}

0 commit comments

Comments
 (0)