diff --git a/backends/tpm/tpm_ioctl.h b/backends/tpm/tpm_ioctl.h index ee2dd15d35..e466311455 100644 --- a/backends/tpm/tpm_ioctl.h +++ b/backends/tpm/tpm_ioctl.h @@ -285,7 +285,7 @@ typedef struct ptm_lockstorage ptm_lockstorage; #define PTM_CAP_SEND_COMMAND_HEADER (1 << 15) #define PTM_CAP_LOCK_STORAGE (1 << 16) -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__GNU__) enum { PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap), PTM_INIT = _IOWR('P', 1, ptm_init), diff --git a/block/file-posix.c b/block/file-posix.c index 5019ddade9..3c985da94f 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -43,9 +43,11 @@ #include "scsi/constants.h" #include "scsi/utils.h" -#if defined(__APPLE__) && (__MACH__) +#ifndef __sun__ #include -#if defined(HAVE_HOST_BLOCK_DEVICE) +#endif + +#if defined(__APPLE__) && (__MACH__) && defined(HAVE_HOST_BLOCK_DEVICE) #include #include #include @@ -57,7 +59,6 @@ //#include #include #include -#endif /* defined(HAVE_HOST_BLOCK_DEVICE) */ #endif #ifdef __sun__ @@ -65,7 +66,6 @@ #include #endif #ifdef __linux__ -#include #include #include #include @@ -95,27 +95,20 @@ #endif #ifdef __OpenBSD__ -#include #include #include #endif #ifdef __NetBSD__ -#include #include #include #include #endif #ifdef __DragonFly__ -#include #include #endif -#ifdef EMSCRIPTEN -#include -#endif - /* OS X does not have O_DSYNC */ #ifndef O_DSYNC #ifdef O_SYNC @@ -2098,7 +2091,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque) } #ifndef HAVE_COPY_FILE_RANGE -#ifndef EMSCRIPTEN +#if !defined(EMSCRIPTEN) && !defined(__GNU__) static #endif ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd, diff --git a/configure b/configure index d786d3a7c9..bf728d6d99 100755 --- a/configure +++ b/configure @@ -371,6 +371,8 @@ elif check_define __APPLE__; then elif check_define EMSCRIPTEN ; then host_os=emscripten cross_compile="yes" +elif check_define __GNU__; then + host_os=gnu else # This is a fatal error, but don't report it yet, because we # might be going to just print the --help text, or it might diff --git a/gdbstub/gdb-xml/i386-32bit.xml b/gdbstub/gdb-xml/i386-32bit.xml index 7a66a02b67..1dec40e1d2 100644 --- a/gdbstub/gdb-xml/i386-32bit.xml +++ b/gdbstub/gdb-xml/i386-32bit.xml @@ -87,27 +87,34 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdbstub/gdb-xml/i386-64bit.xml b/gdbstub/gdb-xml/i386-64bit.xml index 6d88969211..9ac9164e6a 100644 --- a/gdbstub/gdb-xml/i386-64bit.xml +++ b/gdbstub/gdb-xml/i386-64bit.xml @@ -102,9 +102,16 @@ + + + + + + + diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 2f0e61ad6b..1ec5b42230 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -384,6 +384,17 @@ void QEMU_ERROR("code path is reachable") #define TIME_MAX TYPE_MAXIMUM(time_t) #endif +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +/* + * Use the same value as Linux for now. + */ +#ifndef IOV_MAX +#define IOV_MAX 1024 +#endif + /* Mac OSX has a bug that incorrectly defines SIZE_MAX with * the wrong type. Our replacement isn't usable in preprocessor * expressions, but it is sufficient for our needs. */ @@ -661,10 +672,6 @@ struct iovec { void *iov_base; size_t iov_len; }; -/* - * Use the same value as Linux for now. - */ -#define IOV_MAX 1024 ssize_t readv(int fd, const struct iovec *iov, int iov_cnt); ssize_t writev(int fd, const struct iovec *iov, int iov_cnt); diff --git a/qga/commands-win32.c b/qga/commands-win32.c index c0bf3467bd..2bf5581aaa 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1590,7 +1590,7 @@ static DWORD get_interface_index(const char *guid) ULONG index; DWORD status; wchar_t wbuf[INTERFACE_PATH_BUF_SZ]; - snwprintf(wbuf, INTERFACE_PATH_BUF_SZ, L"\\device\\tcpip_%s", guid); + swprintf(wbuf, INTERFACE_PATH_BUF_SZ, L"\\device\\tcpip_%s", guid); wbuf[INTERFACE_PATH_BUF_SZ - 1] = 0; status = GetAdapterIndex (wbuf, &index); if (status != NO_ERROR) { diff --git a/qga/meson.build b/qga/meson.build index 89a4a8f713..cfa2157efb 100644 --- a/qga/meson.build +++ b/qga/meson.build @@ -97,24 +97,22 @@ if host_os == 'windows' qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32', '-lsetupapi', '-lcfgmgr32', '-luserenv', '-lpdh' ] if have_qga_vss - qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-lstdc++', '-Wl,--enable-stdcall-fixup'] + qga_libs += ['-lole32', '-loleaut32', '-lshlwapi', '-Wl,--enable-stdcall-fixup'] subdir('vss-win32') endif endif qga_objs = [] if host_os == 'windows' - windmc = find_program('windmc', required: true) - windres = find_program('windres', required: true) + windmc = find_program('windmc', 'mc', required: true) msgrc = custom_target('messages-win32.rc', input: 'messages-win32.mc', output: ['messages-win32.rc', 'MSG00409.bin', 'messages-win32.h'], command: [windmc, '-h', '@OUTDIR@', '-r', '@OUTDIR@', '@INPUT@']) - msgobj = custom_target('messages-win32.o', - input: msgrc[0], - output: 'messages-win32.o', - command: [windres, '-I', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@']) + + windows = import('windows') + msgobj = windows.compile_resources(msgrc[0]) qga_objs = [msgobj] endif diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp index 626d6ab1ff..493ecd5717 100644 --- a/qga/vss-win32/requester.cpp +++ b/qga/vss-win32/requester.cpp @@ -444,7 +444,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset) hr = vss_ctx.pVssbc->AddToSnapshotSet(short_volume_name, g_gProviderId, &pid); if (FAILED(hr)) { - WCHAR volume_path_name[PATH_MAX]; + WCHAR volume_path_name[MAX_PATH]; if (GetVolumePathNamesForVolumeNameW( short_volume_name, volume_path_name, sizeof(volume_path_name), NULL) && diff --git a/qga/vss-win32/vss-common.h b/qga/vss-win32/vss-common.h index 0e67e7822c..5e993f9eda 100644 --- a/qga/vss-win32/vss-common.h +++ b/qga/vss-win32/vss-common.h @@ -30,21 +30,6 @@ #define __RPC__out_ecount_part(x, y) #endif #define _declspec(x) -#undef uuid -#define uuid(x) - -/* Undef some duplicated error codes redefined in vss.h */ -#undef VSS_E_BAD_STATE -#undef VSS_E_PROVIDER_NOT_REGISTERED -#undef VSS_E_PROVIDER_VETO -#undef VSS_E_OBJECT_NOT_FOUND -#undef VSS_E_VOLUME_NOT_SUPPORTED -#undef VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER -#undef VSS_E_OBJECT_ALREADY_EXISTS -#undef VSS_E_UNEXPECTED_PROVIDER_ERROR -#undef VSS_E_INVALID_XML_DOCUMENT -#undef VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED -#undef VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED #include #include "vss-handles.h" diff --git a/rust/bindings/hwcore-sys/Cargo.toml b/rust/bindings/hwcore-sys/Cargo.toml index c20024e921..b5ae33da8e 100644 --- a/rust/bindings/hwcore-sys/Cargo.toml +++ b/rust/bindings/hwcore-sys/Cargo.toml @@ -21,7 +21,6 @@ chardev-sys = { path = "../chardev-sys" } qom-sys = { path = "../qom-sys" } migration-sys = { path = "../migration-sys" } util-sys = { path = "../util-sys" } -system-sys = { path = "../system-sys" } [lints] workspace = true diff --git a/rust/bindings/system-sys/Cargo.toml b/rust/bindings/system-sys/Cargo.toml index 7e527130ff..1e0fa8cf79 100644 --- a/rust/bindings/system-sys/Cargo.toml +++ b/rust/bindings/system-sys/Cargo.toml @@ -20,6 +20,7 @@ common = { path = "../../common" } migration-sys = { path = "../migration-sys" } util-sys = { path = "../util-sys" } qom-sys = { path = "../qom-sys" } +hwcore-sys = { path = "../hwcore-sys" } [lints] workspace = true diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index ce636b6c56..83c889cc3b 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -3244,8 +3244,9 @@ static void gen_PUSHF(DisasContext *s, X86DecodedInsn *decode) assume_cc_op(s, CC_OP_EFLAGS); } -static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode, - bool *can_be_zero, TCGv *count, int unit) +static MemOp gen_shift_count_1(DisasContext *s, X86DecodedInsn *decode, + bool *can_be_zero, TCGv *count, int unit, + int mod) { MemOp ot = decode->op[0].ot; int mask = (ot <= MO_32 ? 0x1f : 0x3f); @@ -3255,16 +3256,31 @@ static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode, case X86_OP_INT: *count = tcg_temp_new(); tcg_gen_andi_tl(*count, cpu_regs[R_ECX], mask); + + if (mod < mask) { + TCGv temp = tcg_temp_new(); + assert(mod * 4 >= mask); + if (mod * 2 < mask) { + tcg_gen_subi_tl(temp, *count, mod * 2); + tcg_gen_movcond_tl(TCG_COND_GE, *count, temp, tcg_constant_tl(0), temp, *count); + } + tcg_gen_subi_tl(temp, *count, mod); + tcg_gen_movcond_tl(TCG_COND_GE, *count, temp, tcg_constant_tl(0), temp, *count); + } *can_be_zero = true; break; case X86_OP_IMM: - if ((decode->immediate & mask) == 0) { + decode->immediate &= mask; + if (mod < mask) { + decode->immediate %= mod; + } + if (decode->immediate == 0) { *count = NULL; break; } *count = tcg_temp_new(); - tcg_gen_movi_tl(*count, decode->immediate & mask); + tcg_gen_movi_tl(*count, decode->immediate); break; case X86_OP_SKIP: @@ -3279,6 +3295,13 @@ static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode, return ot; } +static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode, + bool *can_be_zero, TCGv *count, int unit) +{ + return gen_shift_count_1(s, decode, can_be_zero, count, unit, + INT_MAX); +} + /* * Compute existing flags in decode->cc_src, for gen_* functions that wants * to set the cc_op set to CC_OP_ADCOX. In particular, this allows rotate @@ -3309,17 +3332,21 @@ static bool gen_eflags_adcox(DisasContext *s, X86DecodedInsn *decode, bool want_ * to be followed by rotations within the same basic block. */ switch (s->cc_op) { + case CC_OP_ADCX: + case CC_OP_ADOX: case CC_OP_ADCOX: /* No need to compute the full EFLAGS, CF/OF are already isolated. */ - tcg_gen_mov_tl(decode->cc_src, cpu_cc_src); - if (need_flags) { + if (s->cc_op != CC_OP_ADCX && need_flags) { tcg_gen_mov_tl(decode->cc_src2, cpu_cc_src2); got_of = true; } - if (want_carry || need_flags) { + if (s->cc_op != CC_OP_ADOX && (want_carry || need_flags)) { tcg_gen_mov_tl(decode->cc_dst, cpu_cc_dst); got_cf = true; } + /* fallthrough */ + case CC_OP_EFLAGS: + tcg_gen_mov_tl(decode->cc_src, cpu_cc_src); break; case CC_OP_LOGICB ... CC_OP_LOGICQ: @@ -3397,29 +3424,14 @@ static void gen_rot_overflow(X86DecodedInsn *decode, TCGv result, TCGv old, /* * RCx operations are invariant modulo 8*operand_size+1. For 8 and 16-bit operands, * this is less than 0x1f (the mask applied by gen_shift_count) so reduce further. + * FIXME: are flags updated if the count is nonzero, but a multiple of (8 << op) + 1? */ -static void gen_rotc_mod(MemOp ot, TCGv count) +static MemOp gen_rotc_count(DisasContext *s, X86DecodedInsn *decode, + bool *can_be_zero, TCGv *count, int unit) { - TCGv temp; - - switch (ot) { - case MO_8: - temp = tcg_temp_new(); - tcg_gen_subi_tl(temp, count, 18); - tcg_gen_movcond_tl(TCG_COND_GE, count, temp, tcg_constant_tl(0), temp, count); - tcg_gen_subi_tl(temp, count, 9); - tcg_gen_movcond_tl(TCG_COND_GE, count, temp, tcg_constant_tl(0), temp, count); - break; - - case MO_16: - temp = tcg_temp_new(); - tcg_gen_subi_tl(temp, count, 17); - tcg_gen_movcond_tl(TCG_COND_GE, count, temp, tcg_constant_tl(0), temp, count); - break; - - default: - break; - } + MemOp ot = decode->op[0].ot; + return gen_shift_count_1(s, decode, can_be_zero, count, unit, + (8 << ot) + 1); } /* @@ -3440,7 +3452,7 @@ static void gen_RCL(DisasContext *s, X86DecodedInsn *decode) bool have_1bit_cin, can_be_zero; TCGv count; TCGLabel *zero_label = NULL; - MemOp ot = gen_shift_count(s, decode, &can_be_zero, &count, decode->op[2].unit); + MemOp ot = gen_rotc_count(s, decode, &can_be_zero, &count, decode->op[2].unit); TCGv low, high, low_count; if (!count) { @@ -3451,7 +3463,6 @@ static void gen_RCL(DisasContext *s, X86DecodedInsn *decode) high = tcg_temp_new(); low_count = tcg_temp_new(); - gen_rotc_mod(ot, count); have_1bit_cin = gen_eflags_adcox(s, decode, true, can_be_zero); if (can_be_zero) { zero_label = gen_new_label(); @@ -3492,7 +3503,7 @@ static void gen_RCR(DisasContext *s, X86DecodedInsn *decode) bool have_1bit_cin, can_be_zero; TCGv count; TCGLabel *zero_label = NULL; - MemOp ot = gen_shift_count(s, decode, &can_be_zero, &count, decode->op[2].unit); + MemOp ot = gen_rotc_count(s, decode, &can_be_zero, &count, decode->op[2].unit); TCGv low, high, high_count; if (!count) { @@ -3503,7 +3514,6 @@ static void gen_RCR(DisasContext *s, X86DecodedInsn *decode) high = tcg_temp_new(); high_count = tcg_temp_new(); - gen_rotc_mod(ot, count); have_1bit_cin = gen_eflags_adcox(s, decode, true, can_be_zero); if (can_be_zero) { zero_label = gen_new_label();