qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

plugin: add API symbols to qemu-plugins.symbols

Signed-off-by: Emilio G. Cota <cota@braap.org>
[AJB: moved into plugins]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

authored by

Emilio G. Cota and committed by
Alex Bennée
26fffe29 40e8c6f4

+133
+7
Makefile
··· 74 74 config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION 75 75 @echo $@ is out-of-date, running configure 76 76 @./config.status 77 + 78 + # Force configure to re-run if the API symbols are updated 79 + ifeq ($(CONFIG_PLUGIN),y) 80 + config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols 81 + endif 82 + 77 83 else 78 84 config-host.mak: 79 85 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) ··· 737 743 rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys 738 744 rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp 739 745 rm -f qemu-doc.vr qemu-doc.txt 746 + rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols 740 747 rm -f config.log 741 748 rm -f linux-headers/asm 742 749 rm -f docs/version.texi
+72
configure
··· 30 30 TMPCXX="${TMPDIR1}/${TMPB}.cxx" 31 31 TMPE="${TMPDIR1}/${TMPB}.exe" 32 32 TMPMO="${TMPDIR1}/${TMPB}.mo" 33 + TMPTXT="${TMPDIR1}/${TMPB}.txt" 33 34 34 35 rm -f config.log 35 36 ··· 5476 5477 atomic64=yes 5477 5478 fi 5478 5479 5480 + ######################################### 5481 + # See if --dynamic-list is supported by the linker 5482 + ld_dynamic_list="no" 5483 + if test "$static" = "no" ; then 5484 + cat > $TMPTXT <<EOF 5485 + { 5486 + foo; 5487 + }; 5488 + EOF 5489 + 5490 + cat > $TMPC <<EOF 5491 + #include <stdio.h> 5492 + void foo(void); 5493 + 5494 + void foo(void) 5495 + { 5496 + printf("foo\n"); 5497 + } 5498 + 5499 + int main(void) 5500 + { 5501 + foo(); 5502 + return 0; 5503 + } 5504 + EOF 5505 + 5506 + if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then 5507 + ld_dynamic_list="yes" 5508 + fi 5509 + fi 5510 + 5511 + ######################################### 5512 + # See if -exported_symbols_list is supported by the linker 5513 + 5514 + ld_exported_symbols_list="no" 5515 + if test "$static" = "no" ; then 5516 + cat > $TMPTXT <<EOF 5517 + _foo 5518 + EOF 5519 + 5520 + if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then 5521 + ld_exported_symbols_list="yes" 5522 + fi 5523 + fi 5524 + 5525 + if test "$plugins" = "yes" && 5526 + test "$ld_dynamic_list" = "no" && 5527 + test "$ld_exported_symbols_list" = "no" ; then 5528 + error_exit \ 5529 + "Plugin support requires dynamic linking and specifying a set of symbols " \ 5530 + "that are exported to plugins. Unfortunately your linker doesn't " \ 5531 + "support the flag (--dynamic-list or -exported_symbols_list) used " \ 5532 + "for this purpose. You can't build with --static." 5533 + fi 5534 + 5479 5535 ######################################## 5480 5536 # See if 16-byte vector operations are supported. 5481 5537 # Even without a vector unit the compiler may expand these. ··· 7283 7339 if test "$plugins" = "yes" ; then 7284 7340 echo "CONFIG_PLUGIN=y" >> $config_host_mak 7285 7341 LIBS="-ldl $LIBS" 7342 + # Copy the export object list to the build dir 7343 + if test "$ld_dynamic_list" = "yes" ; then 7344 + echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak 7345 + ld_symbols=qemu-plugins-ld.symbols 7346 + cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols 7347 + elif test "$ld_exported_symbols_list" = "yes" ; then 7348 + echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak 7349 + ld64_symbols=qemu-plugins-ld64.symbols 7350 + echo "# Automatically generated by configure - do not modify" > $ld64_symbols 7351 + grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \ 7352 + sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols 7353 + else 7354 + error_exit \ 7355 + "If \$plugins=yes, either \$ld_dynamic_list or " \ 7356 + "\$ld_exported_symbols_list should have been set to 'yes'." 7357 + fi 7286 7358 fi 7287 7359 7288 7360 if test "$tcg_interpreter" = "yes"; then
+2
plugins/.gitignore
··· 1 + qemu-plugins-ld.symbols 2 + qemu-plugins-ld64.symbols
+14
plugins/Makefile.objs
··· 5 5 obj-y += loader.o 6 6 obj-y += core.o 7 7 obj-y += api.o 8 + 9 + # Abuse -libs suffix to only link with --dynamic-list/-exported_symbols_list 10 + # when the final binary includes the plugin object. 11 + # 12 + # Note that simply setting LDFLAGS is not enough: we build binaries that 13 + # never link plugin.o, and the linker might fail (at least ld64 does) 14 + # if the symbols in the list are not in the output binary. 15 + ifdef CONFIG_HAS_LD_DYNAMIC_LIST 16 + api.o-libs := -Wl,--dynamic-list=$(BUILD_DIR)/qemu-plugins-ld.symbols 17 + else 18 + ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST 19 + api.o-libs := -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols 20 + endif 21 + endif
+38
plugins/qemu-plugins.symbols
··· 1 + { 2 + qemu_plugin_uninstall; 3 + qemu_plugin_reset; 4 + qemu_plugin_register_vcpu_init_cb; 5 + qemu_plugin_register_vcpu_exit_cb; 6 + qemu_plugin_register_vcpu_idle_cb; 7 + qemu_plugin_register_vcpu_resume_cb; 8 + qemu_plugin_register_vcpu_insn_exec_cb; 9 + qemu_plugin_register_vcpu_insn_exec_inline; 10 + qemu_plugin_register_vcpu_mem_cb; 11 + qemu_plugin_register_vcpu_mem_haddr_cb; 12 + qemu_plugin_register_vcpu_mem_inline; 13 + qemu_plugin_ram_addr_from_host; 14 + qemu_plugin_register_vcpu_tb_trans_cb; 15 + qemu_plugin_register_vcpu_tb_exec_cb; 16 + qemu_plugin_register_vcpu_tb_exec_inline; 17 + qemu_plugin_register_flush_cb; 18 + qemu_plugin_register_vcpu_syscall_cb; 19 + qemu_plugin_register_vcpu_syscall_ret_cb; 20 + qemu_plugin_register_atexit_cb; 21 + qemu_plugin_tb_n_insns; 22 + qemu_plugin_tb_get_insn; 23 + qemu_plugin_tb_vaddr; 24 + qemu_plugin_insn_data; 25 + qemu_plugin_insn_size; 26 + qemu_plugin_insn_vaddr; 27 + qemu_plugin_insn_haddr; 28 + qemu_plugin_mem_size_shift; 29 + qemu_plugin_mem_is_sign_extended; 30 + qemu_plugin_mem_is_big_endian; 31 + qemu_plugin_mem_is_store; 32 + qemu_plugin_get_hwaddr; 33 + qemu_plugin_hwaddr_is_io; 34 + qemu_plugin_hwaddr_to_raddr; 35 + qemu_plugin_vcpu_for_each; 36 + qemu_plugin_n_vcpus; 37 + qemu_plugin_n_max_vcpus; 38 + };