]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 3 Nov 2022 14:54:37 +0000 (10:54 -0400)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 3 Nov 2022 14:54:37 +0000 (10:54 -0400)
* bug fixes
* reduced memory footprint for IPI virtualization on Intel processors
* asynchronous teardown support (Linux only)

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmNiVykUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroN0Swf/YxjphCtFgYYSO14WP+7jAnfRZLhm
# 0xWChWP8rco5I352OBFeFU64Av5XoLGNn6SZLl8lcg86lQ/G0D27jxu6wOcDDHgw
# 0yTDO1gevj51UKsbxoC66OWSZwKTEo398/BHPDcI2W41yOFycSdtrPgspOrFRVvf
# 7M3nNjuNPsQorZeuu8NGr3jakqbt99ZDXcyDEWbrEAcmy2JBRMbGgT0Kdnc6aZfW
# CvL+1ljxzldNwGeNBbQW2QgODbfHx5cFZcy4Daze35l5Ra7K/FrgAzr6o/HXptya
# 9fEs5LJQ1JWI6JtpaWwFy7fcIIOsJ0YW/hWWQZSDt9JdAJFE5/+vF+Kz5Q==
# =CgrO
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 02 Nov 2022 07:40:25 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:
  target/i386: Fix test for paging enabled
  util/log: Close per-thread log file on thread termination
  target/i386: Set maximum APIC ID to KVM prior to vCPU creation
  os-posix: asynchronous teardown for shutdown on Linux
  target/i386: Fix calculation of LOCK NEG eflags

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
1  2 
meson.build
qemu-options.hx
target/i386/tcg/translate.c
util/meson.build

diff --combined meson.build
index d809d51791298f58c627c22821b12076b87a289b,17834b3c3def574ca5f23ea22adf18f8f78c9b32..1d448272ab88ab1e4966e377b654c516331b9bd4
@@@ -49,7 -49,7 +49,7 @@@ qapi_trace_events = [
  bsd_oses = ['gnu/kfreebsd', 'freebsd', 'netbsd', 'openbsd', 'dragonfly', 'darwin']
  supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
  supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64',
 -  'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc', 'sparc64']
 +  'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc64']
  
  cpu = host_machine.cpu_family()
  
@@@ -469,6 -469,8 +469,6 @@@ if get_option('tcg').allowed(
    endif
    if get_option('tcg_interpreter')
      tcg_arch = 'tci'
 -  elif host_arch == 'sparc64'
 -    tcg_arch = 'sparc'
    elif host_arch == 'x86_64'
      tcg_arch = 'i386'
    elif host_arch == 'ppc64'
@@@ -634,16 -636,10 +634,16 @@@ if vmnet.found() and not cc.has_header_
  endif
  
  seccomp = not_found
 +seccomp_has_sysrawrc = false
  if not get_option('seccomp').auto() or have_system or have_tools
    seccomp = dependency('libseccomp', version: '>=2.3.0',
                         required: get_option('seccomp'),
                         method: 'pkg-config', kwargs: static_kwargs)
 +  if seccomp.found()
 +    seccomp_has_sysrawrc = cc.has_header_symbol('seccomp.h',
 +                                                'SCMP_FLTATR_API_SYSRAWRC',
 +                                                dependencies: seccomp)
 +  endif
  endif
  
  libcap_ng = not_found
@@@ -1851,6 -1847,7 +1851,6 @@@ config_host_data.set('CONFIG_LIBNFS', l
  config_host_data.set('CONFIG_LIBSSH', libssh.found())
  config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
  config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
 -config_host_data.set('CONFIG_LIBURING_REGISTER_RING_FD', cc.has_function('io_uring_register_ring_fd', prefix: '#include <liburing.h>', dependencies:linux_io_uring))
  config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
  config_host_data.set('CONFIG_NUMA', numa.found())
  config_host_data.set('CONFIG_OPENGL', opengl.found())
@@@ -1860,9 -1857,6 +1860,9 @@@ config_host_data.set('CONFIG_RDMA', rdm
  config_host_data.set('CONFIG_SDL', sdl.found())
  config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
  config_host_data.set('CONFIG_SECCOMP', seccomp.found())
 +if seccomp.found()
 +  config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc)
 +endif
  config_host_data.set('CONFIG_SNAPPY', snappy.found())
  config_host_data.set('CONFIG_TPM', have_tpm)
  config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
@@@ -1955,6 -1949,7 +1955,7 @@@ if targetos == 'windows
  endif
  
  # has_function
+ config_host_data.set('CONFIG_CLOSE_RANGE', cc.has_function('close_range'))
  config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
  config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
  config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
@@@ -2128,23 -2123,7 +2129,23 @@@ config_host_data.set('CONFIG_PTHREAD_CO
      pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
      return 0;
    }''', dependencies: threads))
 +config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(gnu_source_prefix + '''
 +  #include <pthread.h>
  
 +  static void *f(void *p) { return NULL; }
 +  int main(void)
 +  {
 +    int setsize = CPU_ALLOC_SIZE(64);
 +    pthread_t thread;
 +    cpu_set_t *cpuset;
 +    pthread_create(&thread, 0, f, 0);
 +    cpuset = CPU_ALLOC(64);
 +    CPU_ZERO_S(setsize, cpuset);
 +    pthread_setaffinity_np(thread, setsize, cpuset);
 +    pthread_getaffinity_np(thread, setsize, cpuset);
 +    CPU_FREE(cpuset);
 +    return 0;
 +  }''', dependencies: threads))
  config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
    #include <sys/signalfd.h>
    #include <stddef.h>
@@@ -3638,7 -3617,6 +3639,7 @@@ if host_machine.system() == 'windows
      '@OUTPUT@',
      get_option('prefix'),
      meson.current_source_dir(),
 +    config_host['GLIB_BINDIR'],
      host_machine.cpu(),
      '--',
      '-DDISPLAYVERSION=' + meson.project_version(),
diff --combined qemu-options.hx
index ceee0ddc255d6ff3f47d8f63dbdcb1bdb24101fe,e26d1dad3990df8141b0e0a9cde7b04a4c0e0a03..911d82afa5af4b958048d082e05beebcb99b7c3f
@@@ -2772,20 -2772,6 +2772,20 @@@ DEF("netdev", HAS_ARG, QEMU_OPTION_netd
      "-netdev socket,id=str[,fd=h][,udp=host:port][,localaddr=host:port]\n"
      "                configure a network backend to connect to another network\n"
      "                using an UDP tunnel\n"
 +    "-netdev stream,id=str[,server=on|off],addr.type=inet,addr.host=host,addr.port=port[,to=maxport][,numeric=on|off][,keep-alive=on|off][,mptcp=on|off][,addr.ipv4=on|off][,addr.ipv6=on|off]\n"
 +    "-netdev stream,id=str[,server=on|off],addr.type=unix,addr.path=path[,abstract=on|off][,tight=on|off]\n"
 +    "-netdev stream,id=str[,server=on|off],addr.type=fd,addr.str=file-descriptor\n"
 +    "                configure a network backend to connect to another network\n"
 +    "                using a socket connection in stream mode.\n"
 +    "-netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=inet,local.host=addr]\n"
 +    "-netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=fd,local.str=file-descriptor]\n"
 +    "                configure a network backend to connect to a multicast maddr and port\n"
 +    "                use ``local.host=addr`` to specify the host address to send packets from\n"
 +    "-netdev dgram,id=str,local.type=inet,local.host=addr,local.port=port[,remote.type=inet,remote.host=addr,remote.port=port]\n"
 +    "-netdev dgram,id=str,local.type=unix,local.path=path[,remote.type=unix,remote.path=path]\n"
 +    "-netdev dgram,id=str,local.type=fd,local.str=file-descriptor\n"
 +    "                configure a network backend to connect to another network\n"
 +    "                using an UDP tunnel\n"
  #ifdef CONFIG_VDE
      "-netdev vde,id=str[,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
      "                configure a network backend to connect to port 'n' of a vde switch\n"
      "                configure a vhost-user network, backed by a chardev 'dev'\n"
  #endif
  #ifdef __linux__
 -    "-netdev vhost-vdpa,id=str,vhostdev=/path/to/dev\n"
 +    "-netdev vhost-vdpa,id=str[,vhostdev=/path/to/dev][,vhostfd=h]\n"
      "                configure a vhost-vdpa network,Establish a vhost-vdpa netdev\n"
 +    "                use 'vhostdev=/path/to/dev' to open a vhost vdpa device\n"
 +    "                use 'vhostfd=h' to connect to an already opened vhost vdpa device\n"
  #endif
  #ifdef CONFIG_VMNET
      "-netdev vmnet-host,id=str[,isolated=on|off][,net-uuid=uuid]\n"
@@@ -3312,7 -3296,7 +3312,7 @@@ SRS
               -netdev type=vhost-user,id=net0,chardev=chr0 \
               -device virtio-net-pci,netdev=net0
  
 -``-netdev vhost-vdpa,vhostdev=/path/to/dev``
 +``-netdev vhost-vdpa[,vhostdev=/path/to/dev][,vhostfd=h]``
      Establish a vhost-vdpa netdev.
  
      vDPA device is a device that uses a datapath which complies with
@@@ -4790,6 -4774,25 +4790,25 @@@ HXCOMM Internal us
  DEF("qtest", HAS_ARG, QEMU_OPTION_qtest, "", QEMU_ARCH_ALL)
  DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "", QEMU_ARCH_ALL)
  
+ #ifdef __linux__
+ DEF("async-teardown", 0, QEMU_OPTION_asyncteardown,
+     "-async-teardown enable asynchronous teardown\n",
+     QEMU_ARCH_ALL)
+ #endif
+ SRST
+ ``-async-teardown``
+     Enable asynchronous teardown. A new process called "cleanup/<QEMU_PID>"
+     will be created at startup sharing the address space with the main qemu
+     process, using clone. It will wait for the main qemu process to
+     terminate completely, and then exit.
+     This allows qemu to terminate very quickly even if the guest was
+     huge, leaving the teardown of the address space to the cleanup
+     process. Since the cleanup process shares the same cgroups as the
+     main qemu process, accounting is performed correctly. This only
+     works if the cleanup process is not forcefully killed with SIGKILL
+     before the main qemu process has terminated completely.
+ ERST
  DEF("msg", HAS_ARG, QEMU_OPTION_msg,
      "-msg [timestamp[=on|off]][,guest-name=[on|off]]\n"
      "                control error message format\n"
index 0ee548ce569a10d8b9bbf275ac3afc0c8f25e393,c477a10f410c55085869b7c7d412712f2de14e03..28a4e6dc1ded0948138c80d4bfba0f6a3b5da342
@@@ -2746,26 -2746,6 +2746,26 @@@ static void gen_reset_hflag(DisasContex
      }
  }
  
 +static void gen_set_eflags(DisasContext *s, target_ulong mask)
 +{
 +    TCGv t = tcg_temp_new();
 +
 +    tcg_gen_ld_tl(t, cpu_env, offsetof(CPUX86State, eflags));
 +    tcg_gen_ori_tl(t, t, mask);
 +    tcg_gen_st_tl(t, cpu_env, offsetof(CPUX86State, eflags));
 +    tcg_temp_free(t);
 +}
 +
 +static void gen_reset_eflags(DisasContext *s, target_ulong mask)
 +{
 +    TCGv t = tcg_temp_new();
 +
 +    tcg_gen_ld_tl(t, cpu_env, offsetof(CPUX86State, eflags));
 +    tcg_gen_andi_tl(t, t, ~mask);
 +    tcg_gen_st_tl(t, cpu_env, offsetof(CPUX86State, eflags));
 +    tcg_temp_free(t);
 +}
 +
  /* Clear BND registers during legacy branches.  */
  static void gen_bnd_jmp(DisasContext *s)
  {
@@@ -2796,7 -2776,7 +2796,7 @@@ do_gen_eob_worker(DisasContext *s, boo
      }
  
      if (s->base.tb->flags & HF_RF_MASK) {
 -        gen_helper_reset_rf(cpu_env);
 +        gen_reset_eflags(s, RF_MASK);
      }
      if (recheck_tf) {
          gen_helper_rechecking_single_step(cpu_env);
@@@ -3320,7 -3300,7 +3320,7 @@@ static bool disas_insn(DisasContext *s
  
                  tcg_temp_free(t2);
                  tcg_temp_free(a0);
-                 tcg_gen_mov_tl(s->T0, t0);
+                 tcg_gen_neg_tl(s->T0, t0);
                  tcg_temp_free(t0);
              } else {
                  tcg_gen_neg_tl(s->T0, s->T0);
  #endif
      case 0xfa: /* cli */
          if (check_iopl(s)) {
 -            gen_helper_cli(cpu_env);
 +            gen_reset_eflags(s, IF_MASK);
          }
          break;
      case 0xfb: /* sti */
          if (check_iopl(s)) {
 -            gen_helper_sti(cpu_env);
 +            gen_set_eflags(s, IF_MASK);
              /* interruptions are enabled only the first insn after sti */
              gen_update_eip_next(s);
              gen_eob_inhibit_irq(s, true);
                  || CPL(s) != 0) {
                  goto illegal_op;
              }
 -            gen_helper_clac(cpu_env);
 +            gen_reset_eflags(s, AC_MASK);
              s->base.is_jmp = DISAS_EOB_NEXT;
              break;
  
                  || CPL(s) != 0) {
                  goto illegal_op;
              }
 -            gen_helper_stac(cpu_env);
 +            gen_set_eflags(s, AC_MASK);
              s->base.is_jmp = DISAS_EOB_NEXT;
              break;
  
diff --combined util/meson.build
index c0a7bc54d4599cf5a15e8f43429d6738001a3609,63acd59bb02ce1d9a63276db8d94f7c13ca08442..59c1f467bbeaf06c53cb9644fd45d8719e6516aa
@@@ -1,8 -1,8 +1,9 @@@
  util_ss.add(files('osdep.c', 'cutils.c', 'unicode.c', 'qemu-timer-common.c'))
 +util_ss.add(files('thread-context.c'), numa)
  if not config_host_data.get('CONFIG_ATOMIC64')
    util_ss.add(files('atomic64.c'))
  endif
+ util_ss.add(when: 'CONFIG_LINUX', if_true: files('async-teardown.c'))
  util_ss.add(when: 'CONFIG_POSIX', if_true: files('aio-posix.c'))
  util_ss.add(when: 'CONFIG_POSIX', if_true: files('fdmon-poll.c'))
  if config_host_data.get('CONFIG_EPOLL_CREATE1')