Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging

* GNU/Hurd support
* More patches to support qemu-ga builds with clang-cl
* gdbstub: Update x86 control register bits
* rust: fix incorrect dependency in Cargo.toml
* target/i386: apply mod to immediate count of an RCL/RCR operation

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmoynoYUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroNaIgf8D6Nb0jy5hP2t43s6ZT5VEM+k889p
# 89TiRelrnzvcrZ8GhfB+JeA87LCd0pNn0nIspsMzA6butOzO/tlft2vLlNEXevli
# MNhZVdj2PNGwN3TqW4EM4zM1VmLFxMshEEtAcBtHkUCCxlkscju+zSmwnJ0zzHy/
# fQpOAXO3HtDlHEzLF1QWjjpHQd6IorjeWqRVzH8i+djlgk6YGn51mNYOwgvBOSUZ
# IET2FVabLpJkoQWlr11mt3woL+cxi5tKeVFAUzHB6q6rvkbLp85tyDx2nW4O+M8C
# G7Hb82z/nV6Rh0E6ehq3x0DDdYTxt1ARyljnx3QQIsZo5uAVP+1WtqIgkg==
# =nh+D
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 17 Jun 2026 09:17:58 EDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu:
  qga/vss: Drop unused define uuid(x)
  qga/vss: Remove unused undefs
  qga/vss: Use MAX_PATH instead of PATH_MAX
  qga/meson: Allow to use MSVC message compiler 'mc'
  qga/meson: Use windows.compile_resources instead of custom_target
  qga/meson: Remove unused lib stdc++
  qga/win: Use swprintf instead of snwprintf
  Make copy_file_range non-static on GNU/Hurd
  block/file-posix: Clean up sys/ioctl import
  tpm: Add conditional to not compile ioctls on GNU/Hurd
  Add GNU/Hurd host_os=gnu
  Include new arbitrary limits if not already defined
  gdbstub: Update x86 control register bits
  target/i386: add more easy cases to gen_eflags_adcox
  target/i386: apply mod to immediate count of an RCL/RCR operation
  rust: fix incorrect dependency in Cargo.toml

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi
2026-06-18 09:46:49 -04:00
13 changed files with 103 additions and 94 deletions

View File

@@ -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),

View File

@@ -43,9 +43,11 @@
#include "scsi/constants.h"
#include "scsi/utils.h"
#if defined(__APPLE__) && (__MACH__)
#ifndef __sun__
#include <sys/ioctl.h>
#if defined(HAVE_HOST_BLOCK_DEVICE)
#endif
#if defined(__APPLE__) && (__MACH__) && defined(HAVE_HOST_BLOCK_DEVICE)
#include <paths.h>
#include <sys/param.h>
#include <sys/mount.h>
@@ -57,7 +59,6 @@
//#include <IOKit/storage/IOCDTypes.h>
#include <IOKit/storage/IODVDMedia.h>
#include <CoreFoundation/CoreFoundation.h>
#endif /* defined(HAVE_HOST_BLOCK_DEVICE) */
#endif
#ifdef __sun__
@@ -65,7 +66,6 @@
#include <sys/dkio.h>
#endif
#ifdef __linux__
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/vfs.h>
@@ -95,27 +95,20 @@
#endif
#ifdef __OpenBSD__
#include <sys/ioctl.h>
#include <sys/disklabel.h>
#include <sys/dkio.h>
#endif
#ifdef __NetBSD__
#include <sys/ioctl.h>
#include <sys/disklabel.h>
#include <sys/dkio.h>
#include <sys/disk.h>
#endif
#ifdef __DragonFly__
#include <sys/ioctl.h>
#include <sys/diskslice.h>
#endif
#ifdef EMSCRIPTEN
#include <sys/ioctl.h>
#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,

2
configure vendored
View File

@@ -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

View File

@@ -87,27 +87,34 @@
</flags>
<flags id="i386_cr4" size="4">
<field name="VME" start="0" end="0"/>
<field name="PVI" start="1" end="1"/>
<field name="TSD" start="2" end="2"/>
<field name="DE" start="3" end="3"/>
<field name="PSE" start="4" end="4"/>
<field name="PAE" start="5" end="5"/>
<field name="MCE" start="6" end="6"/>
<field name="PGE" start="7" end="7"/>
<field name="PCE" start="8" end="8"/>
<field name="OSFXSR" start="9" end="9"/>
<field name="OSXMMEXCPT" start="10" end="10"/>
<field name="UMIP" start="11" end="11"/>
<field name="LA57" start="12" end="12"/>
<field name="VMXE" start="13" end="13"/>
<field name="SMXE" start="14" end="14"/>
<field name="FSGSBASE" start="16" end="16"/>
<field name="PCIDE" start="17" end="17"/>
<field name="OSXSAVE" start="18" end="18"/>
<field name="SMEP" start="20" end="20"/>
<field name="SMAP" start="21" end="21"/>
<field name="LAM_SUP" start="28" end="28"/>
<field name="LASS" start="27" end="27"/>
<field name="UINTR" start="25" end="25"/>
<field name="PKS" start="24" end="24"/>
<field name="CET" start="23" end="23"/>
<field name="PKE" start="22" end="22"/>
<field name="PKE" start="22" end="22"/>
<field name="SMAP" start="21" end="21"/>
<field name="SMEP" start="20" end="20"/>
<field name="KL" start="19" end="19"/>
<field name="OSXSAVE" start="18" end="18"/>
<field name="PCIDE" start="17" end="17"/>
<field name="FSGSBASE" start="16" end="16"/>
<field name="SMXE" start="14" end="14"/>
<field name="VMXE" start="13" end="13"/>
<field name="LA57" start="12" end="12"/>
<field name="UMIP" start="11" end="11"/>
<field name="OSXMMEXCPT" start="10" end="10"/>
<field name="OSFXSR" start="9" end="9"/>
<field name="PCE" start="8" end="8"/>
<field name="PGE" start="7" end="7"/>
<field name="MCE" start="6" end="6"/>
<field name="PAE" start="5" end="5"/>
<field name="PSE" start="4" end="4"/>
<field name="DE" start="3" end="3"/>
<field name="TSD" start="2" end="2"/>
<field name="PVI" start="1" end="1"/>
<field name="VME" start="0" end="0"/>
</flags>
<flags id="i386_efer" size="4">

View File

@@ -102,9 +102,16 @@
</flags>
<flags id="x64_cr4" size="8">
<field name="FRED" start="32" end="32"/>
<field name="LAM_SUP" start="28" end="28"/>
<field name="LASS" start="27" end="27"/>
<field name="UINTR" start="25" end="25"/>
<field name="PKS" start="24" end="24"/>
<field name="CET" start="23" end="23"/>
<field name="PKE" start="22" end="22"/>
<field name="SMAP" start="21" end="21"/>
<field name="SMEP" start="20" end="20"/>
<field name="KL" start="19" end="19"/>
<field name="OSXSAVE" start="18" end="18"/>
<field name="PCIDE" start="17" end="17"/>
<field name="FSGSBASE" start="16" end="16"/>

View File

@@ -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 <stdint.h> 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);

View File

@@ -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) {

View File

@@ -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

View File

@@ -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) &&

View File

@@ -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 <vss.h>
#include "vss-handles.h"

View File

@@ -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

View File

@@ -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

View File

@@ -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();