1. 03 7月, 2020 2 次提交
    • D
      virtio-pci: Proxy for virtio-mem · 0b9a2443
      David Hildenbrand 提交于
      Let's add a proxy for virtio-mem, make it a memory device, and
      pass-through the properties.
      Reviewed-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
      Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20200626072248.78761-12-david@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      0b9a2443
    • D
      virtio-mem: Paravirtualized memory hot(un)plug · 910b2576
      David Hildenbrand 提交于
      This is the very basic/initial version of virtio-mem. An introduction to
      virtio-mem can be found in the Linux kernel driver [1]. While it can be
      used in the current state for hotplug of a smaller amount of memory, it
      will heavily benefit from resizeable memory regions in the future.
      
      Each virtio-mem device manages a memory region (provided via a memory
      backend). After requested by the hypervisor ("requested-size"), the
      guest can try to plug/unplug blocks of memory within that region, in order
      to reach the requested size. Initially, and after a reboot, all memory is
      unplugged (except in special cases - reboot during postcopy).
      
      The guest may only try to plug/unplug blocks of memory within the usable
      region size. The usable region size is a little bigger than the
      requested size, to give the device driver some flexibility. The usable
      region size will only grow, except on reboots or when all memory is
      requested to get unplugged. The guest can never plug more memory than
      requested. Unplugged memory will get zapped/discarded, similar to in a
      balloon device.
      
      The block size is variable, however, it is always chosen in a way such that
      THP splits are avoided (e.g., 2MB). The state of each block
      (plugged/unplugged) is tracked in a bitmap.
      
      As virtio-mem devices (e.g., virtio-mem-pci) will be memory devices, we now
      expose "VirtioMEMDeviceInfo" via "query-memory-devices".
      
      --------------------------------------------------------------------------
      
      There are two important follow-up items that are in the works:
      1. Resizeable memory regions: Use resizeable allocations/RAM blocks to
         grow/shrink along with the usable region size. This avoids creating
         initially very big VMAs, RAM blocks, and KVM slots.
      2. Protection of unplugged memory: Make sure the gust cannot actually
         make use of unplugged memory.
      
      Other follow-up items that are in the works:
      1. Exclude unplugged memory during migration (via precopy notifier).
      2. Handle remapping of memory.
      3. Support for other architectures.
      
      --------------------------------------------------------------------------
      
      Example usage (virtio-mem-pci is introduced in follow-up patches):
      
      Start QEMU with two virtio-mem devices (one per NUMA node):
       $ qemu-system-x86_64 -m 4G,maxmem=20G \
        -smp sockets=2,cores=2 \
        -numa node,nodeid=0,cpus=0-1 -numa node,nodeid=1,cpus=2-3 \
        [...]
        -object memory-backend-ram,id=mem0,size=8G \
        -device virtio-mem-pci,id=vm0,memdev=mem0,node=0,requested-size=0M \
        -object memory-backend-ram,id=mem1,size=8G \
        -device virtio-mem-pci,id=vm1,memdev=mem1,node=1,requested-size=1G
      
      Query the configuration:
       (qemu) info memory-devices
       Memory device [virtio-mem]: "vm0"
         memaddr: 0x140000000
         node: 0
         requested-size: 0
         size: 0
         max-size: 8589934592
         block-size: 2097152
         memdev: /objects/mem0
       Memory device [virtio-mem]: "vm1"
         memaddr: 0x340000000
         node: 1
         requested-size: 1073741824
         size: 1073741824
         max-size: 8589934592
         block-size: 2097152
         memdev: /objects/mem1
      
      Add some memory to node 0:
       (qemu) qom-set vm0 requested-size 500M
      
      Remove some memory from node 1:
       (qemu) qom-set vm1 requested-size 200M
      
      Query the configuration again:
       (qemu) info memory-devices
       Memory device [virtio-mem]: "vm0"
         memaddr: 0x140000000
         node: 0
         requested-size: 524288000
         size: 524288000
         max-size: 8589934592
         block-size: 2097152
         memdev: /objects/mem0
       Memory device [virtio-mem]: "vm1"
         memaddr: 0x340000000
         node: 1
         requested-size: 209715200
         size: 209715200
         max-size: 8589934592
         block-size: 2097152
         memdev: /objects/mem1
      
      [1] https://lkml.kernel.org/r/20200311171422.10484-1-david@redhat.com
      
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Eric Blake <eblake@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20200626072248.78761-11-david@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      910b2576
  2. 02 7月, 2020 5 次提交
  3. 30 6月, 2020 1 次提交
    • P
      hw/misc/pca9552: Add missing TypeInfo::class_size field · fc1bff95
      Philippe Mathieu-Daudé 提交于
      When adding the generic PCA955xClass in commit 736132e4, we
      forgot to set the class_size field. Fill it now to avoid:
      
        (gdb) run -machine mcimx6ul-evk -m 128M -display none -serial stdio -kernel ./OS.elf
        Starting program: ../../qemu/qemu/arm-softmmu/qemu-system-arm -machine mcimx6ul-evk -m 128M -display none -serial stdio -kernel ./OS.elf
        double free or corruption (!prev)
        Thread 1 "qemu-system-arm" received signal SIGABRT, Aborted.
        __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
        (gdb) where
        #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
        #1  0x00007ffff75d8859 in __GI_abort () at abort.c:79
        #2  0x00007ffff76433ee in __libc_message
            (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff776d285 "%s\n")
            at ../sysdeps/posix/libc_fatal.c:155
        #3  0x00007ffff764b47c in malloc_printerr
            (str=str@entry=0x7ffff776f690 "double free or corruption (!prev)")
            at malloc.c:5347
        #4  0x00007ffff764d12c in _int_free
            (av=0x7ffff779eb80 <main_arena>, p=0x5555567a3990, have_lock=<optimized out>) at malloc.c:4317
        #5  0x0000555555c906c3 in type_initialize_interface
            (ti=ti@entry=0x5555565b8f40, interface_type=0x555556597ad0, parent_type=0x55555662ca10) at qom/object.c:259
        #6  0x0000555555c902da in type_initialize (ti=ti@entry=0x5555565b8f40)
            at qom/object.c:323
        #7  0x0000555555c90d20 in type_initialize (ti=0x5555565b8f40)
            at qom/object.c:1028
      
        $ valgrind --track-origins=yes qemu-system-arm -M mcimx6ul-evk -m 128M -display none -serial stdio -kernel ./OS.elf
        ==77479== Memcheck, a memory error detector
        ==77479== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
        ==77479== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
        ==77479== Command: qemu-system-arm -M mcimx6ul-evk -m 128M -display none -serial stdio -kernel ./OS.elf
        ==77479==
        ==77479== Invalid write of size 2
        ==77479==    at 0x6D8322: pca9552_class_init (pca9552.c:424)
        ==77479==    by 0x844D1F: type_initialize (object.c:1029)
        ==77479==    by 0x844D1F: object_class_foreach_tramp (object.c:1016)
        ==77479==    by 0x4AE1057: g_hash_table_foreach (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6400.2)
        ==77479==    by 0x8453A4: object_class_foreach (object.c:1038)
        ==77479==    by 0x8453A4: object_class_get_list (object.c:1095)
        ==77479==    by 0x556194: select_machine (vl.c:2416)
        ==77479==    by 0x556194: qemu_init (vl.c:3828)
        ==77479==    by 0x40AF9C: main (main.c:48)
        ==77479==  Address 0x583f108 is 0 bytes after a block of size 200 alloc'd
        ==77479==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
        ==77479==    by 0x4AF8D30: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6400.2)
        ==77479==    by 0x844258: type_initialize.part.0 (object.c:306)
        ==77479==    by 0x844D1F: type_initialize (object.c:1029)
        ==77479==    by 0x844D1F: object_class_foreach_tramp (object.c:1016)
        ==77479==    by 0x4AE1057: g_hash_table_foreach (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.6400.2)
        ==77479==    by 0x8453A4: object_class_foreach (object.c:1038)
        ==77479==    by 0x8453A4: object_class_get_list (object.c:1095)
        ==77479==    by 0x556194: select_machine (vl.c:2416)
        ==77479==    by 0x556194: qemu_init (vl.c:3828)
        ==77479==    by 0x40AF9C: main (main.c:48)
      
      Fixes: 736132e4 ("hw/misc/pca9552: Add generic PCA955xClass")
      Reported-by: NJean-Christophe DUBOIS <jcd@tribudubois.net>
      Signed-off-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Tested-by: NJean-Christophe DUBOIS <jcd@tribudubois.net>
      Message-id: 20200629074704.23028-1-f4bug@amsat.org
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      fc1bff95
  4. 28 6月, 2020 1 次提交
  5. 26 6月, 2020 31 次提交