Skip to content

Commit 671ad7c

Browse files
committed
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-cap-20201003' into staging
Update capstone submodule from v3.0.5 to v5 ("next"). Convert submodule build to meson. Enable capstone disassembly for s390x. Code cleanups in disas.c # gpg: Signature made Sat 03 Oct 2020 10:33:44 BST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "[email protected]" # gpg: Good signature from "Richard Henderson <[email protected]>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * remotes/rth-gitlab/tags/pull-cap-20201003: disas/capstone: Add skipdata hook for s390x disas: Enable capstone disassembly for s390x disas: Split out capstone code to disas/capstone.c disas: Configure capstone for aarch64 host without libvixl disas: Cleanup plugin_disas disas: Use qemu/bswap.h for bfd endian loads disas: Clean up CPUDebug initialization disas: Move host asm annotations to tb_gen_code capstone: Require version 4.0 from a system library capstone: Update to upstream "next" branch capstone: Convert Makefile bits to meson bits Signed-off-by: Peter Maydell <[email protected]>
2 parents 469e72a + c6d3da9 commit 671ad7c

File tree

14 files changed

+680
-699
lines changed

14 files changed

+680
-699
lines changed

Makefile

+4-14
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,11 @@ dtc/all: .git-submodule-status dtc/libfdt
156156
dtc/%: .git-submodule-status
157157
@mkdir -p $@
158158

159-
# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
160-
# Not overriding CFLAGS leads to mis-matches between compilation modes.
161-
# Therefore we replicate some of the logic in the sub-makefile.
162-
# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
163-
# no need to annoy QEMU developers with such things.
164-
CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS)) $(CAPSTONE_CFLAGS)
165-
CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
166-
CAP_CFLAGS += -DCAPSTONE_HAS_ARM
167-
CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
168-
CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
169-
CAP_CFLAGS += -DCAPSTONE_HAS_X86
170-
159+
# Retain for a while so that incremental build across this patch
160+
# does not raise an error for missing target "capstone/all", which
161+
# comes from the saved SUBDIRS value.
171162
.PHONY: capstone/all
172-
capstone/all: .git-submodule-status
173-
$(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/$(LIBCAPSTONE))
163+
capstone/all:
174164

175165
.PHONY: slirp/all
176166
slirp/all: .git-submodule-status

accel/tcg/translate-all.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -1816,10 +1816,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
18161816
qemu_log_in_addr_range(tb->pc)) {
18171817
FILE *logfile = qemu_log_lock();
18181818
int code_size, data_size = 0;
1819-
g_autoptr(GString) note = g_string_new("[tb header & initial instruction]");
1820-
size_t chunk_start = 0;
1819+
size_t chunk_start;
18211820
int insn = 0;
1822-
qemu_log("OUT: [size=%d]\n", gen_code_size);
1821+
18231822
if (tcg_ctx->data_gen_ptr) {
18241823
code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr;
18251824
data_size = gen_code_size - code_size;
@@ -1828,26 +1827,33 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
18281827
}
18291828

18301829
/* Dump header and the first instruction */
1830+
qemu_log("OUT: [size=%d]\n", gen_code_size);
1831+
qemu_log(" -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n",
1832+
tcg_ctx->gen_insn_data[insn][0]);
18311833
chunk_start = tcg_ctx->gen_insn_end_off[insn];
1832-
log_disas(tb->tc.ptr, chunk_start, note->str);
1834+
log_disas(tb->tc.ptr, chunk_start);
18331835

18341836
/*
18351837
* Dump each instruction chunk, wrapping up empty chunks into
18361838
* the next instruction. The whole array is offset so the
18371839
* first entry is the beginning of the 2nd instruction.
18381840
*/
1839-
while (insn <= tb->icount && chunk_start < code_size) {
1841+
while (insn < tb->icount) {
18401842
size_t chunk_end = tcg_ctx->gen_insn_end_off[insn];
18411843
if (chunk_end > chunk_start) {
1842-
g_string_printf(note, "[guest addr: " TARGET_FMT_lx "]",
1843-
tcg_ctx->gen_insn_data[insn][0]);
1844-
log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_start,
1845-
note->str);
1844+
qemu_log(" -- guest addr 0x" TARGET_FMT_lx "\n",
1845+
tcg_ctx->gen_insn_data[insn][0]);
1846+
log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_start);
18461847
chunk_start = chunk_end;
18471848
}
18481849
insn++;
18491850
}
18501851

1852+
if (chunk_start < code_size) {
1853+
qemu_log(" -- tb slow paths + alignment\n");
1854+
log_disas(tb->tc.ptr + chunk_start, code_size - chunk_start);
1855+
}
1856+
18511857
/* Finally dump any data we may have after the block */
18521858
if (data_size) {
18531859
int i;

capstone

Submodule capstone updated from 22ead3e to f8b1b83

configure

+9-59
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ opengl=""
478478
opengl_dmabuf="no"
479479
cpuid_h="no"
480480
avx2_opt=""
481-
capstone=""
481+
capstone="auto"
482482
lzo=""
483483
snappy=""
484484
bzip2=""
@@ -1575,11 +1575,11 @@ for opt do
15751575
;;
15761576
--enable-vhost-kernel) vhost_kernel="yes"
15771577
;;
1578-
--disable-capstone) capstone="no"
1578+
--disable-capstone) capstone="disabled"
15791579
;;
1580-
--enable-capstone) capstone="yes"
1580+
--enable-capstone) capstone="enabled"
15811581
;;
1582-
--enable-capstone=git) capstone="git"
1582+
--enable-capstone=git) capstone="internal"
15831583
;;
15841584
--enable-capstone=system) capstone="system"
15851585
;;
@@ -5017,51 +5017,11 @@ fi
50175017
# capstone
50185018

50195019
case "$capstone" in
5020-
"" | yes)
5021-
if $pkg_config capstone; then
5022-
capstone=system
5023-
elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5024-
capstone=git
5025-
elif test -e "${source_path}/capstone/Makefile" ; then
5026-
capstone=internal
5027-
elif test -z "$capstone" ; then
5028-
capstone=no
5029-
else
5030-
feature_not_found "capstone" "Install capstone devel or git submodule"
5031-
fi
5032-
;;
5033-
5034-
system)
5035-
if ! $pkg_config capstone; then
5036-
feature_not_found "capstone" "Install capstone devel"
5037-
fi
5038-
;;
5039-
esac
5040-
5041-
case "$capstone" in
5042-
git | internal)
5043-
if test "$capstone" = git; then
5020+
auto | enabled | internal)
5021+
# Simpler to always update submodule, even if not needed.
5022+
if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
50445023
git_submodules="${git_submodules} capstone"
50455024
fi
5046-
mkdir -p capstone
5047-
if test "$mingw32" = "yes"; then
5048-
LIBCAPSTONE=capstone.lib
5049-
else
5050-
LIBCAPSTONE=libcapstone.a
5051-
fi
5052-
capstone_libs="-Lcapstone -lcapstone"
5053-
capstone_cflags="-I${source_path}/capstone/include"
5054-
;;
5055-
5056-
system)
5057-
capstone_libs="$($pkg_config --libs capstone)"
5058-
capstone_cflags="$($pkg_config --cflags capstone)"
5059-
;;
5060-
5061-
no)
5062-
;;
5063-
*)
5064-
error_exit "Unknown state for capstone: $capstone"
50655025
;;
50665026
esac
50675027

@@ -7142,11 +7102,6 @@ fi
71427102
if test "$ivshmem" = "yes" ; then
71437103
echo "CONFIG_IVSHMEM=y" >> $config_host_mak
71447104
fi
7145-
if test "$capstone" != "no" ; then
7146-
echo "CONFIG_CAPSTONE=y" >> $config_host_mak
7147-
echo "CAPSTONE_CFLAGS=$capstone_cflags" >> $config_host_mak
7148-
echo "CAPSTONE_LIBS=$capstone_libs" >> $config_host_mak
7149-
fi
71507105
if test "$debug_mutex" = "yes" ; then
71517106
echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
71527107
fi
@@ -7664,13 +7619,7 @@ done # for target in $targets
76647619
if [ "$fdt" = "git" ]; then
76657620
subdirs="$subdirs dtc"
76667621
fi
7667-
if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7668-
subdirs="$subdirs capstone"
7669-
fi
76707622
echo "SUBDIRS=$subdirs" >> $config_host_mak
7671-
if test -n "$LIBCAPSTONE"; then
7672-
echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7673-
fi
76747623

76757624
if test "$numa" = "yes"; then
76767625
echo "CONFIG_NUMA=y" >> $config_host_mak
@@ -7846,7 +7795,8 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
78467795
-Dmalloc=$malloc -Dmalloc_trim=$malloc_trim \
78477796
-Dcocoa=$cocoa -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
78487797
-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
7849-
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f\
7798+
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
7799+
-Dcapstone=$capstone \
78507800
$cross_arg \
78517801
"$PWD" "$source_path"
78527802

0 commit comments

Comments
 (0)