Skip to content
Snippets Groups Projects
  1. Mar 06, 2021
  2. Feb 16, 2021
  3. Feb 09, 2021
  4. Feb 08, 2021
  5. Feb 07, 2021
  6. Feb 03, 2021
  7. Feb 01, 2021
  8. Jan 26, 2021
    • Hanna Reitz's avatar
      coroutine-sigaltstack: Add SIGUSR2 mutex · f4be8225
      Hanna Reitz authored
      Disposition (action) for any given signal is global for the process.
      When two threads run coroutine-sigaltstack's qemu_coroutine_new()
      concurrently, they may interfere with each other: One of them may revert
      the SIGUSR2 handler to SIG_DFL, between the other thread (a) setting up
      coroutine_trampoline() as the handler and (b) raising SIGUSR2.  That
      SIGUSR2 will then terminate the QEMU process abnormally.
      
      We have to ensure that only one thread at a time can modify the
      process-global SIGUSR2 handler.  To do so, wrap the whole section where
      that is done in a mutex.
      
      Alternatively, we could for example have the SIGUSR2 handler always be
      coroutine_trampoline(), so there would be no need to invoke sigaction()
      in qemu_coroutine_new().  Laszlo has posted a patch to do so here:
      
        https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg05962.html
      
      
      
      However, given that coroutine-sigaltstack is more of a fallback
      implementation for platforms that do not support ucontext, that change
      may be a bit too invasive to be comfortable with it.  The mutex proposed
      here may negatively impact performance, but the change is much simpler.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20210125120305.19520-1-mreitz@redhat.com>
      Reviewed-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      f4be8225
  9. Jan 24, 2021
  10. Jan 23, 2021
    • Paolo Bonzini's avatar
      qemu-option: warn for short-form boolean options · ccd3b3b8
      Paolo Bonzini authored
      
      Options such as "server" or "nowait", that are commonly found in -chardev,
      are sugar for "server=on" and "wait=off".  This is quite surprising and
      also does not have any notion of typing attached.  It is even possible to
      do "-device e1000,noid" and get a device with "id=off".
      
      Deprecate it and print a warning when it is encountered.  In general,
      this short form for boolean options only seems to be in wide use for
      -chardev and -spice.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ccd3b3b8
    • Paolo Bonzini's avatar
      qemu-option: move help handling to get_opt_name_value · afd73625
      Paolo Bonzini authored
      
      Right now, help options are parsed normally and then checked
      specially in opt_validate, but only if coming from
      qemu_opts_parse_noisily.  has_help_option does the check on its own.
      
      opt_validate() has two callers: qemu_opt_set(), which passes null and is
      therefore unaffected, and opts_do_parse(), which is affected.
      
      opts_do_parse() is called by qemu_opts_do_parse(), which passes null and
      is therefore unaffected, and opts_parse().
      
      opts_parse() is called by qemu_opts_parse() and qemu_opts_set_defaults(),
      which pass null and are therefore unaffected, and
      qemu_opts_parse_noisily().
      
      Move the check from opt_validate to the parsing workhorse of QemuOpts,
      get_opt_name_value.  This will come in handy in the next patch, which
      will raise a warning for "-object memory-backend-ram,share" ("flag" option
      with no =on/=off part) but not for "-object memory-backend-ram,help".
      
      As a result:
      
      - opts_parse and opts_do_parse do not return an error anymore
        when help is requested; qemu_opts_parse_noisily does not have
        to work around that anymore.
      
      - various crazy ways to request help are not recognized anymore:
        - "help=..."
        - "nohelp" (sugar for "help=off")
        - "?=..."
        - "no?" (sugar for "?=off")
      
      - "help" would be recognized as help request even if there is a (foolishly
        named) parameter "help".  No such parameters exist, though.
      
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      afd73625
    • Paolo Bonzini's avatar
      qemu-option: clean up id vs. list->merge_lists · 63758d10
      Paolo Bonzini authored
      
      Looking at all merge-lists QemuOptsList, here is how they access their
      QemuOpts:
      
      reopen_opts in qemu-io-cmds.c ("qemu-img reopen -o")
      	qemu_opts_find(&reopen_opts, NULL)
      
      empty_opts in qemu-io.c ("qemu-io open -o")
      	qemu_opts_find(&empty_opts, NULL)
      
      qemu_rtc_opts ("-rtc")
      	qemu_find_opts_singleton("rtc")
      
      qemu_machine_opts ("-M")
      	qemu_find_opts_singleton("machine")
      
      qemu_action_opts ("-name")
      	qemu_opts_foreach->process_runstate_actions
      
      qemu_boot_opts ("-boot")
      	in hw/nvram/fw_cfg.c and hw/s390x/ipl.c:
      	  QTAILQ_FIRST(&qemu_find_opts("bootopts")->head)
      	in softmmu/vl.c:
      	  qemu_opts_find(qemu_find_opts("boot-opts"), NULL)
      
      qemu_name_opts ("-name")
      	qemu_opts_foreach->parse_name
      	parse_name does not use id
      
      qemu_mem_opts ("-m")
      	qemu_find_opts_singleton("memory")
      
      qemu_icount_opts ("-icount")
      	qemu_opts_foreach->do_configure_icount
      	do_configure_icount->icount_configure
      	icount_configure does not use id
      
      qemu_smp_opts ("-smp")
      	qemu_opts_find(qemu_find_opts("smp-opts"), NULL)
      
      qemu_spice_opts ("-spice")
      	QTAILQ_FIRST(&qemu_spice_opts.head)
      
      i.e. they don't need an id.  Sometimes its presence is ignored
      (e.g. when using qemu_opts_foreach), sometimes all the options
      with the id are skipped, sometimes only the first option on the
      command line is considered.  -boot does two different things
      depending on who's looking at the options.
      
      With this patch we just forbid id on merge-lists QemuOptsLists; if the
      command line still works, it has the same semantics as before.
      
      qemu_opts_create's fail_if_exists parameter is now unnecessary:
      
      - it is unused if id is NULL
      
      - opts_parse only passes false if reached from qemu_opts_set_defaults,
      in which case this patch enforces that id must be NULL
      
      - other callers that can pass a non-NULL id always set it to true
      
      Assert that it is true in the only case where "fail_if_exists" matters,
      i.e. "id && !lists->merge_lists".  This means that if an id is present,
      duplicates are always forbidden, which was already the status quo.
      
      Discounting the case that aborts as it's not user-controlled (it's
      "just" a matter of inspecting qemu_opts_create callers), the paths
      through qemu_opts_create can be summarized as:
      
      - merge_lists = true: singleton opts with NULL id; non-NULL id fails
      
      - merge_lists = false: always return new opts; non-NULL id fails if dup
      
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      63758d10
  11. Jan 21, 2021
  12. Jan 18, 2021
  13. Jan 13, 2021
  14. Jan 11, 2021
  15. Jan 08, 2021
  16. Jan 07, 2021
  17. Jan 06, 2021
  18. Jan 04, 2021
  19. Jan 02, 2021
    • Richard Henderson's avatar
      util: Extract flush_icache_range to cacheflush.c · 084cfca1
      Richard Henderson authored
      
      This has been a tcg-specific function, but is also in use
      by hardware accelerators via physmem.c.  This can cause
      link errors when tcg is disabled.
      
      Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarJoelle van Dyne <j@getutm.app>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Message-Id: <20201214140314.18544-3-richard.henderson@linaro.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      084cfca1
    • Daniele Buono's avatar
      cfi: Initial support for cfi-icall in QEMU · c905a368
      Daniele Buono authored
      
      LLVM/Clang, supports runtime checks for forward-edge Control-Flow
      Integrity (CFI).
      
      CFI on indirect function calls (cfi-icall) ensures that, in indirect
      function calls, the function called is of the right signature for the
      pointer type defined at compile time.
      
      For this check to work, the code must always respect the function
      signature when using function pointer, the function must be defined
      at compile time, and be compiled with link-time optimization.
      
      This rules out, for example, shared libraries that are dynamically loaded
      (given that functions are not known at compile time), and code that is
      dynamically generated at run-time.
      
      This patch:
      
      1) Introduces the CONFIG_CFI flag to support cfi in QEMU
      
      2) Introduces a decorator to allow the definition of "sensitive"
      functions, where a non-instrumented function may be called at runtime
      through a pointer. The decorator will take care of disabling cfi-icall
      checks on such functions, when cfi is enabled.
      
      3) Marks functions currently in QEMU that exhibit such behavior,
      in particular:
      - The function in TCG that calls pre-compiled TBs
      - The function in TCI that interprets instructions
      - Functions in the plugin infrastructures that jump to callbacks
      - Functions in util that directly call a signal handler
      
      Signed-off-by: default avatarDaniele Buono <dbuono@linux.vnet.ibm.com>
      Acked-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Message-Id: <20201204230615.2392-3-dbuono@linux.vnet.ibm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c905a368
  20. Dec 19, 2020
    • Markus Armbruster's avatar
      keyval: Use GString to accumulate value strings · 7ece4211
      Markus Armbruster authored
      
      QString supports modifying its string, but it's quite limited: you can
      only append.  The remaining callers use it for building an initial
      string, never for modifying it later.
      
      Change keyval_parse_one() to do build the initial string with GString.
      This is another step towards making QString immutable.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-19-armbru@redhat.com>
      7ece4211
    • Eric Blake's avatar
      qapi: Use QAPI_LIST_PREPEND() where possible · 54aa3de7
      Eric Blake authored
      
      Anywhere we create a list of just one item or by prepending items
      (typically because order doesn't matter), we can use
      QAPI_LIST_PREPEND().  But places where we must keep the list in order
      by appending remain open-coded until later patches.
      
      Note that as a side effect, this also performs a cleanup of two minor
      issues in qga/commands-posix.c: the old code was performing
       new = g_malloc0(sizeof(*ret));
      which 1) is confusing because you have to verify whether 'new' and
      'ret' are variables with the same type, and 2) would conflict with C++
      compilation (not an actual problem for this file, but makes
      copy-and-paste harder).
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201113011340.463563-5-eblake@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Acked-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      [Straightforward conflicts due to commit a8aa94b5 "qga: update
      schema for guest-get-disks 'dependents' field" and commit a10b453a
      "target/mips: Move mips_cpu_add_definition() from helper.c to cpu.c"
      resolved.  Commit message tweaked.]
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      54aa3de7
  21. Dec 15, 2020
  22. Dec 10, 2020
    • Paolo Bonzini's avatar
      config-file: move -set implementation to vl.c · ed7fa564
      Paolo Bonzini authored
      
      We want to make it independent of QemuOpts.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ed7fa564
    • Paolo Bonzini's avatar
      qemu-option: restrict qemu_opts_set to merge-lists QemuOpts · 32c02fdd
      Paolo Bonzini authored
      
      qemu_opts_set is used to create default network backends and to
      parse sugar options -kernel, -initrd, -append, -bios and -dtb.
      These are very different uses:
      
      I would *expect* a function named qemu_opts_set to set an option in a
      merge-lists QemuOptsList, such as -kernel, and possibly to set an option
      in a non-merge-lists QemuOptsList with non-NULL id, similar to -set.
      
      However, it wouldn't *work* to use qemu_opts_set for the latter
      because qemu_opts_set uses fail_if_exists==1. So, for non-merge-lists
      QemuOptsList and non-NULL id, the semantics of qemu_opts_set (fail if the
      (QemuOptsList, id) pair already exists) are debatable.
      
      On the other hand, I would not expect qemu_opts_set to create a
      non-merge-lists QemuOpts with a single option; which it does, though.
      For this case of non-merge-lists QemuOptsList and NULL id, qemu_opts_set
      hardly adds value over qemu_opts_parse.  It does skip some parsing and
      unescaping, but that's not needed when creating default network
      backends.
      
      So qemu_opts_set has warty behavior for non-merge-lists QemuOptsList
      if id is non-NULL, and it's mostly pointless if id is NULL.  My
      solution to keeping the API as simple as possible is to limit
      qemu_opts_set to merge-lists QemuOptsList.  For them, it's useful (we
      don't want comma-unescaping for -kernel) *and* has sane semantics.
      Network backend creation is switched to qemu_opts_parse.
      
      qemu_opts_set is now only used on merge-lists QemuOptsList... except
      in the testcase, which is changed to use a merge-list QemuOptsList.
      
      With this change we can also remove the id parameter.  With the
      parameter always NULL, we know that qemu_opts_create cannot fail
      and can pass &error_abort to it.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      32c02fdd
    • Markus Armbruster's avatar
      Clean up includes · 4bd802b2
      Markus Armbruster authored
      
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes, with the changes
      to the following files manually reverted:
      
          contrib/libvhost-user/libvhost-user-glib.h
          contrib/libvhost-user/libvhost-user.c
          contrib/libvhost-user/libvhost-user.h
          contrib/plugins/hotblocks.c
          contrib/plugins/hotpages.c
          contrib/plugins/howvec.c
          contrib/plugins/lockstep.c
          linux-user/mips64/cpu_loop.c
          linux-user/mips64/signal.c
          linux-user/sparc64/cpu_loop.c
          linux-user/sparc64/signal.c
          linux-user/x86_64/cpu_loop.c
          linux-user/x86_64/signal.c
          target/s390x/gen-features.c
          tests/fp/platform.h
          tests/migration/s390x/a-b-bios.c
          tests/plugin/bb.c
          tests/plugin/empty.c
          tests/plugin/insn.c
          tests/plugin/mem.c
          tests/test-rcu-simpleq.c
          tests/test-rcu-slist.c
          tests/test-rcu-tailq.c
          tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.c
      
      contrib/plugins/, tests/plugin/, and tests/test-rcu-slist.c appear not
      to include osdep.h intentionally.  The remaining reverts are the same
      as in commit bbfff196.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201113061216.2483385-1-armbru@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Acked-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Tested-by: default avatarThomas Huth <thuth@redhat.com>
      Acked-by: default avatarCornelia Huck <cohuck@redhat.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Acked-by: default avatarAlexander Bulekov <alxndr@bu.edu>
      4bd802b2
  23. Nov 17, 2020
  24. Nov 16, 2020
    • David Hildenbrand's avatar
      util/vfio-helpers.c: Use ram_block_discard_disable() in qemu_vfio_open_pci() · b430b513
      David Hildenbrand authored
      
      Currently, when using "nvme://" for a block device, like
          -drive file=nvme://0000:01:00.0/1,if=none,id=drive0 \
          -device virtio-blk,drive=drive0 \
      
      VFIO may pin all guest memory, and discarding of RAM no longer works as
      expected. I was able to reproduce this easily with my
          01:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd
                  NVMe SSD Controller SM981/PM981/PM983
      
      Similar to common VFIO, we have to disable it, making sure that:
      a) virtio-balloon won't discard any memory ("silently disabled")
      b) virtio-mem and nvme:// run mutually exclusive
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Wei Yang <richardw.yang@linux.intel.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Peter Xu <peterx@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20201116105947.9194-1-david@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b430b513
  25. Nov 15, 2020
Loading