diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index d9176e23..3150aa07 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -68,7 +68,7 @@ fn build_with_cmake() { let profile = env::var("PROFILE").unwrap(); if let Some(unicorn_dir) = find_unicorn(&out_dir()) { - let rust_build_path = unicorn_dir.join("rust_build"); + let rust_build_path = unicorn_dir.join("build_rust"); println!( "cargo:rustc-link-search={}", rust_build_path.to_str().unwrap() @@ -89,7 +89,7 @@ fn build_with_cmake() { download_unicorn() }; - let rust_build_path = unicorn_dir.join("rust_build"); + let rust_build_path = unicorn_dir.join("build_rust"); let mut cmd = Command::new("cmake"); @@ -98,7 +98,7 @@ fn build_with_cmake() { // Windows cmd.current_dir(&unicorn_dir) .arg("-B") - .arg("rust_build") + .arg("build_rust") .arg("-DBUILD_SHARED_LIBS=OFF") .arg("-G") .arg("Visual Studio 16 2019"); @@ -138,7 +138,7 @@ fn build_with_cmake() { let mut cmd = Command::new("cmake"); cmd.current_dir(&unicorn_dir) .arg("-B") - .arg("rust_build") + .arg("build_rust") .arg("-DBUILD_SHARED_LIBS=OFF"); if profile == "debug" { @@ -163,35 +163,8 @@ fn build_with_cmake() { } } - // This is a workaround for Unicorn static link since libunicorn.a is also linked again lib*-softmmu.a. - // Static libs is just a bundle of objects files. The link relation defined in CMakeLists is only - // valid within the cmake project scope and cmake would help link again sub static libs automatically. - // // Lazymio(@wtdcode): Why do I stick to static link? See: https://github.com/rust-lang/cargo/issues/5077 - println!("cargo:rustc-link-lib=unicorn"); - for arch in [ - "x86_64", - "arm", - "aarch64", - "riscv32", - "riscv64", - "mips", - "mipsel", - "mips64", - "mips64el", - "sparc", - "sparc64", - "m68k", - "ppc", - "ppc64", - "s390x" - ] - .iter() - { - println!("cargo:rustc-link-lib={}-softmmu", arch); - } - println!("cargo:rustc-link-lib=unicorn-common"); - + println!("cargo:rustc-link-lib=unicorn-static"); println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=src"); } diff --git a/qemu/exec.c b/qemu/exec.c index 5d65c7a2..59beefaf 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -1439,6 +1439,25 @@ static void tcg_commit(MemoryListener *listener) tlb_flush(cpuas->cpu); } +static uint64_t unassigned_io_read(struct uc_struct *uc, void* opaque, hwaddr addr, unsigned size) +{ +#ifdef _MSC_VER + return (uint64_t)0xffffffffffffffffULL; +#else + return (uint64_t)-1ULL; +#endif +} + +static void unassigned_io_write(struct uc_struct *uc, void* opaque, hwaddr addr, uint64_t data, unsigned size) +{ +} + +static const MemoryRegionOps unassigned_io_ops = { + .read = unassigned_io_read, + .write = unassigned_io_write, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + static void memory_map_init(struct uc_struct *uc) { uc->system_memory = g_malloc(sizeof(*(uc->system_memory))); diff --git a/qemu/include/exec/ioport.h b/qemu/include/exec/ioport.h index e5a5fbce..93d39b43 100644 --- a/qemu/include/exec/ioport.h +++ b/qemu/include/exec/ioport.h @@ -40,8 +40,6 @@ typedef struct MemoryRegionPortio { #define PORTIO_END_OF_LIST() { } -extern const MemoryRegionOps unassigned_io_ops; - void cpu_outb(struct uc_struct *uc, uint32_t addr, uint8_t val); void cpu_outw(struct uc_struct *uc, uint32_t addr, uint16_t val); void cpu_outl(struct uc_struct *uc, uint32_t addr, uint32_t val); diff --git a/qemu/s390x.h b/qemu/s390x.h index 4de8fd9d..dcda0fd4 100644 --- a/qemu/s390x.h +++ b/qemu/s390x.h @@ -1278,4 +1278,7 @@ #define gen_helper_cpsr_read gen_helper_cpsr_read_s390x #define gen_helper_cpsr_write gen_helper_cpsr_write_s390x #define helper_uc_s390x_exit helper_uc_s390x_exit_s390x +#define tcg_s390_tod_updated tcg_s390_tod_updated_s390x +#define tcg_s390_program_interrupt tcg_s390_program_interrupt_s390x +#define tcg_s390_data_exception tcg_s390_data_exception_s390x #endif diff --git a/qemu/target/s390x/excp_helper.c b/qemu/target/s390x/excp_helper.c index 30c61359..a91c407c 100644 --- a/qemu/target/s390x/excp_helper.c +++ b/qemu/target/s390x/excp_helper.c @@ -26,7 +26,7 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "hw/s390x/ioinst.h" -#//include "exec/address-spaces.h" +//include "exec/address-spaces.h" #include "tcg_s390x.h" #include "sysemu/sysemu.h" //#include "hw/s390x/s390_flic.h" diff --git a/qemu/target/s390x/tcg-stub.c b/qemu/target/s390x/tcg-stub.c index d22c8988..f0dc8f30 100644 --- a/qemu/target/s390x/tcg-stub.c +++ b/qemu/target/s390x/tcg-stub.c @@ -13,18 +13,4 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "cpu.h" -#include "tcg_s390x.h" - -void tcg_s390_tod_updated(CPUState *cs, run_on_cpu_data opaque) -{ -} -void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, - uint32_t code, uintptr_t ra) -{ - g_assert_not_reached(); -} -void QEMU_NORETURN tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc, - uintptr_t ra) -{ - g_assert_not_reached(); -} +#include "tcg_s390x.h" \ No newline at end of file diff --git a/symbols.sh b/symbols.sh index bddb11da..497183cc 100755 --- a/symbols.sh +++ b/symbols.sh @@ -6269,6 +6269,9 @@ ppc_irq_reset \ ppc64_SYMBOLS=${ppc_SYMBOLS} s390x_SYMBOLS="helper_uc_s390x_exit \ +tcg_s390_tod_updated \ +tcg_s390_program_interrupt \ +tcg_s390_data_exception \ " ARCHS="x86_64 arm aarch64 riscv32 riscv64 mips mipsel mips64 mips64el sparc sparc64 m68k ppc ppc64 s390x"