Skip to content
Snippets Groups Projects
  1. Jan 20, 2024
  2. Nov 01, 2023
  3. Oct 20, 2023
  4. Sep 19, 2023
    • David Hildenbrand's avatar
      backends/hostmem-file: Add "rom" property to support VM templating with R/O files · e92666b0
      David Hildenbrand authored
      
      For now, "share=off,readonly=on" would always result in us opening the
      file R/O and mmap'ing the opened file MAP_PRIVATE R/O -- effectively
      turning it into ROM.
      
      Especially for VM templating, "share=off" is a common use case. However,
      that use case is impossible with files that lack write permissions,
      because "share=off,readonly=on" will not give us writable RAM.
      
      The sole user of ROM via memory-backend-file are R/O NVDIMMs, but as we
      have users (Kata Containers) that rely on the existing behavior --
      malicious VMs should not be able to consume COW memory for R/O NVDIMMs --
      we cannot change the semantics of "share=off,readonly=on"
      
      So let's add a new "rom" property with on/off/auto values. "auto" is
      the default and what most people will use: for historical reasons, to not
      change the old semantics, it defaults to the value of the "readonly"
      property.
      
      For VM templating, one can now use:
          -object memory-backend-file,share=off,readonly=on,rom=off,...
      
      But we'll disallow:
          -object memory-backend-file,share=on,readonly=on,rom=off,...
      because we would otherwise get an error when trying to mmap the R/O file
      shared and writable. An explicit error message is cleaner.
      
      We will also disallow for now:
          -object memory-backend-file,share=off,readonly=off,rom=on,...
          -object memory-backend-file,share=on,readonly=off,rom=on,...
      It's not harmful, but also not really required for now.
      
      Alternatives that were abandoned:
      * Make "unarmed=on" for the NVDIMM set the memory region container
        readonly. We would still see a change of ROM->RAM and possibly run
        into memslot limits with vhost-user. Further, there might be use cases
        for "unarmed=on" that should still allow writing to that memory
        (temporary files, system RAM, ...).
      * Add a new "readonly=on/off/auto" parameter for NVDIMMs. Similar issues
        as with "unarmed=on".
      * Make "readonly" consume "on/off/file" instead of being a 'bool' type.
        This would slightly changes the behavior of the "readonly" parameter:
        values like true/false (as accepted by a 'bool'type) would no longer be
        accepted.
      
      Message-ID: <20230906120503.359863-4-david@redhat.com>
      Acked-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      e92666b0
    • David Hildenbrand's avatar
      softmmu/physmem: Distinguish between file access mode and mmap protection · 5c52a219
      David Hildenbrand authored
      
      There is a difference between how we open a file and how we mmap it,
      and we want to support writable private mappings of readonly files. Let's
      define RAM_READONLY and RAM_READONLY_FD flags, to replace the single
      "readonly" parameter for file-related functions.
      
      In memory_region_init_ram_from_fd() and memory_region_init_ram_from_file(),
      initialize mr->readonly based on the new RAM_READONLY flag.
      
      While at it, add some RAM_* flags we missed to add to the list of accepted
      flags in the documentation of some functions.
      
      No change in functionality intended. We'll make use of both flags next
      and start setting them independently for memory-backend-file.
      
      Message-ID: <20230906120503.359863-3-david@redhat.com>
      Acked-by: default avatarPeter Xu <peterx@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      5c52a219
  5. Sep 13, 2023
  6. Sep 08, 2023
  7. Aug 29, 2023
  8. Aug 03, 2023
  9. Jun 23, 2023
  10. Jun 20, 2023
  11. Jun 13, 2023
    • Steve Sistare's avatar
      exec/memory: Introduce RAM_NAMED_FILE flag · b0182e53
      Steve Sistare authored
      
      migrate_ignore_shared() is an optimization that avoids copying memory
      that is visible and can be mapped on the target.  However, a
      memory-backend-ram or a memory-backend-memfd block with the RAM_SHARED
      flag set is not migrated when migrate_ignore_shared() is true.  This is
      wrong, because the block has no named backing store, and its contents will
      be lost.  To fix, ignore shared memory iff it is a named file.  Define a
      new flag RAM_NAMED_FILE to distinguish this case.
      
      Signed-off-by: default avatarSteve Sistare <steven.sistare@oracle.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Message-Id: <1686151116-253260-1-git-send-email-steven.sistare@oracle.com>
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
      b0182e53
  12. May 23, 2023
  13. Apr 25, 2023
  14. Mar 13, 2023
  15. Mar 07, 2023
  16. Mar 02, 2023
    • Alex Bennée's avatar
      backends/vhost-user: remove the ioeventfd check · e1a0e635
      Alex Bennée authored
      
      While ioeventfds are needed for good performance with KVM guests it
      should not be a gating requirement. We can run vhost-user backends using
      simulated ioeventfds or inband signalling.
      
      With this change I can run:
      
        $QEMU $OPTS \
          -display gtk,gl=on \
          -device vhost-user-gpu-pci,chardev=vhgpu \
          -chardev socket,id=vhgpu,path=vhgpu.sock
      
      with:
      
        ./contrib/vhost-user-gpu/vhost-user-gpu \
          -s vhgpu.sock \
          -v
      
      and at least see things start-up - although the display gets rotated by
      180 degrees. Once lightdm takes over we never make it to the login
      prompt and just get a blank screen.
      
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Message-Id: <20221202132231.1048669-1-alex.bennee@linaro.org>
      
      Message-Id: <20230130124728.175610-1-alex.bennee@linaro.org>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      e1a0e635
  17. Feb 23, 2023
  18. Feb 08, 2023
  19. Jan 16, 2023
  20. Dec 28, 2022
    • Michal Privoznik's avatar
      hostmem: Honor multiple preferred nodes if possible · 6bb613f0
      Michal Privoznik authored
      
      If a memory-backend is configured with mode
      HOST_MEM_POLICY_PREFERRED then
      host_memory_backend_memory_complete() calls mbind() as:
      
        mbind(..., MPOL_PREFERRED, nodemask, ...);
      
      Here, 'nodemask' is a bitmap of host NUMA nodes and corresponds
      to the .host-nodes attribute. Therefore, there can be multiple
      nodes specified. However, the documentation to MPOL_PREFERRED
      says:
      
        MPOL_PREFERRED
          This mode sets the preferred node for allocation. ...
          If nodemask specifies more than one node ID, the first node
          in the mask will be selected as the preferred node.
      
      Therefore, only the first node is honored and the rest is
      silently ignored. Well, with recent changes to the kernel and
      numactl we can do better.
      
      The Linux kernel added in v5.15 via commit cfcaa66f8032
      ("mm/hugetlb: add support for mempolicy MPOL_PREFERRED_MANY")
      support for MPOL_PREFERRED_MANY, which accepts multiple preferred
      NUMA nodes instead.
      
      Then, numa_has_preferred_many() API was introduced to numactl
      (v2.0.15~26) allowing applications to query kernel support.
      
      Wiring this all together, we can pass MPOL_PREFERRED_MANY to the
      mbind() call instead and stop ignoring multiple nodes, silently.
      
      Signed-off-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      Message-Id: <a0b4adce1af5bd2344c2218eb4a04b3ff7bcfdb4.1671097918.git.mprivozn@redhat.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      6bb613f0
  21. Dec 14, 2022
    • Markus Armbruster's avatar
      qapi tpm: Elide redundant has_FOO in generated C · ced29396
      Markus Armbruster authored
      
      The has_FOO for pointer-valued FOO are redundant, except for arrays.
      They are also a nuisance to work with.  Recent commit "qapi: Start to
      elide redundant has_FOO in generated C" provided the means to elide
      them step by step.  This is the step for qapi/tpm.json.
      
      Said commit explains the transformation in more detail.  The invariant
      violations mentioned there do not occur here.
      
      Cc: Stefan Berger <stefanb@linux.vnet.ibm.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Message-Id: <20221104160712.3005652-26-armbru@redhat.com>
      ced29396
  22. Dec 01, 2022
  23. Nov 02, 2022
  24. Oct 27, 2022
    • David Hildenbrand's avatar
      hostmem: Allow for specifying a ThreadContext for preallocation · e6816458
      David Hildenbrand authored
      
      Let's allow for specifying a thread context via the "prealloc-context"
      property. When set, preallcoation threads will be crated via the
      thread context -- inheriting the same CPU affinity as the thread
      context.
      
      Pinning preallcoation threads to CPUs can heavily increase performance
      in NUMA setups, because, preallocation from a CPU close to the target
      NUMA node(s) is faster then preallocation from a CPU further remote,
      simply because of memory bandwidth for initializing memory with zeroes.
      This is especially relevant for very large VMs backed by huge/gigantic
      pages, whereby preallocation is mandatory.
      
      Reviewed-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      Message-Id: <20221014134720.168738-7-david@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      e6816458
Loading