Skip to contentSkip to conversation

Qemu virtio pmem device

PATCH In review Pankaj Gupta 5 participants 55 messages Jun 19, 2019 – Jul 26, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Qemu virtio pmem device

This patch series has implementation for "virtio pmem" device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G -object memory-backend-file,id=mem1,share,mem-path=test.img,
size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

 hmp.c                                        |   27 ++-
 hw/i386/Kconfig                              |    1 
 hw/i386/pc.c                                 |   72 ++++++++++
 hw/virtio/Kconfig                            |   10 +
 hw/virtio/Makefile.objs                      |    2 
 hw/virtio/virtio-pci.c                       |    1 
 hw/virtio/virtio-pci.h                       |    1 
 hw/virtio/virtio-pmem-pci.c                  |  131 ++++++++++++++++++
 hw/virtio/virtio-pmem-pci.h                  |   34 ++++
 hw/virtio/virtio-pmem.c                      |  189 +++++++++++++++++++++++++++
 include/hw/pci/pci.h                         |    1 
 include/hw/virtio/virtio-pmem.h              |   49 +++++++
 include/standard-headers/linux/virtio_ids.h  |    1 
 include/standard-headers/linux/virtio_pmem.h |   35 +++++
 numa.c                                       |   24 +--
 qapi/misc.json                               |   28 +++-
 16 files changed, 580 insertions(+), 26 deletions(-)

----

#1 lore raw

PATCH v2 1/7 virtio-pmem: add virtio device

This is the implementation of virtio-pmem device. Support will require machine changes for the architectures that will support it, so it will not yet be compiled. It can be unlocked with VIRTIO_PMEM_SUPPORTED per machine and disabled globally via VIRTIO_PMEM.

We cannot use the "addr" property as that is already used e.g. for virtio-pci/pci devices. And we will have e.g. virtio-pmem-pci as a proxy. So we have to choose a different one (unfortunately). "memaddr" it is. That name should ideally be used by all other virtio-* based memory devices in the future.

    -device virtio-pmem-pci,id=p0,bus=bux0,addr=0x01,memaddr=0x1000000...

[ MemoryDevice/MemoryRegion changes, cleanups, addr property "memaddr",
split up patches, unplug handler ]

---
 hw/virtio/Kconfig               |  10 +++
 hw/virtio/Makefile.objs         |   1 +
 hw/virtio/virtio-pmem.c         | 189 ++++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-pmem.h |  49 +++++++++++
 qapi/misc.json                  |  28 +++++-
 5 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 hw/virtio/virtio-pmem.c
 create mode 100644 include/hw/virtio/virtio-pmem.h
hw/virtio/Kconfig +10 -0
index e0452de4ba..3724ff8bac 100644
@@ -29,3 +29,13 @@ config VIRTIO_CRYPTO
     bool
     default y
     depends on VIRTIO
+
+config VIRTIO_PMEM_SUPPORTED
+    bool
+
+config VIRTIO_PMEM
+    bool
+    default y
+    depends on VIRTIO
+    depends on VIRTIO_PMEM_SUPPORTED
+    select MEM_DEVICE
hw/virtio/Makefile.objs +1 -0
index 5570ea8df8..5857e3b8e1 100644
@@ -12,6 +12,7 @@ common-obj-$(CONFIG_VIRTIO_MMIO) += virtio-mmio.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon.o
 obj-$(CONFIG_VIRTIO_CRYPTO) += virtio-crypto.o
 obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_PCI)) += virtio-crypto-pci.o
+obj-$(CONFIG_VIRTIO_PMEM) += virtio-pmem.o
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o
 
 ifeq ($(CONFIG_VIRTIO_PCI),y)
hw/virtio/virtio-pmem.c new file +189 -0

189 lines not on this page · raw message

include/hw/virtio/virtio-pmem.h new file +49 -0

49 lines not on this page · raw message

qapi/misc.json +27 -1
index dc4cf9da20..6f1bff10e4 100644
@@ -2738,16 +2738,42 @@
           }
 }
 
+##
+# @VirtioPMEMDeviceInfo:
+#
+# VirtioPMEM state information
+#
+# @id: device's ID
+#
+# @memaddr: physical address in memory, where device is mapped
+#
+# @size: size of memory that the device provides
+#
+# @memdev: memory backend linked with device
+#
+# Since: 4.1
+##
+{ 'struct': 'VirtioPMEMDeviceInfo',
+  'data': { '*id': 'str',
+            'memaddr': 'size',
+            'size': 'size',
+            'memdev': 'str'
+          }
+}
+
 ##
 # @MemoryDeviceInfo:
 #
 # Union containing information about a memory device
 #
+# nvdimm is included since 2.12. virtio-pmem is included since 4.1.
+#
 # Since: 2.1
 ##
 { 'union': 'MemoryDeviceInfo',
   'data': { 'dimm': 'PCDIMMDeviceInfo',
-            'nvdimm': 'PCDIMMDeviceInfo'
+            'nvdimm': 'PCDIMMDeviceInfo',
+            'virtio-pmem': 'VirtioPMEMDeviceInfo'
           }
 }
 
Signature · 1 line
2.14.5
Reviewed-by on v2 1/7
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/7] virtio-pmem: add virtio device

Quoted 41 lines · On Wed, 19 Jun 2019 15:19:01 +0530 Pankaj Gupta <[email protected]> wrote:

This is the implementation of virtio-pmem device. Support will require machine changes for the architectures that will support it, so it will not yet be compiled. It can be unlocked with VIRTIO_PMEM_SUPPORTED per machine and disabled globally via VIRTIO_PMEM.

We cannot use the "addr" property as that is already used e.g. for virtio-pci/pci devices. And we will have e.g. virtio-pmem-pci as a proxy. So we have to choose a different one (unfortunately). "memaddr" it is. That name should ideally be used by all other virtio-* based memory devices in the future.

    -device virtio-pmem-pci,id=p0,bus=bux0,addr=0x01,memaddr=0x1000000...

[ MemoryDevice/MemoryRegion changes, cleanups, addr property "memaddr",
split up patches, unplug handler ]

---
 hw/virtio/Kconfig               |  10 +++
 hw/virtio/Makefile.objs         |   1 +
 hw/virtio/virtio-pmem.c         | 189 ++++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-pmem.h |  49 +++++++++++
 qapi/misc.json                  |  28 +++++-
 5 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 hw/virtio/virtio-pmem.c
 create mode 100644 include/hw/virtio/virtio-pmem.h
qapi/misc.json +4 -0
index dc4cf9da20..6f1bff10e4 100644
@@ -2738,16 +2738,42 @@
           }
 }
 
+##
+# @VirtioPMEMDeviceInfo:
+#
+# VirtioPMEM state information

qapi/misc.json line 2754

Quoted 10 lines
qapi/misc.json +10 -0
+#
+# @id: device's ID
+#
+# @memaddr: physical address in memory, where device is mapped
+#
+# @size: size of memory that the device provides
+#
+# @memdev: memory backend linked with device
+#
+# Since: 4.1

Not sure if this can still make it...

Quoted 16 lines
qapi/misc.json +11 -0
+##
+{ 'struct': 'VirtioPMEMDeviceInfo',
+  'data': { '*id': 'str',
+            'memaddr': 'size',
+            'size': 'size',
+            'memdev': 'str'
+          }
+}
+
 ##
 # @MemoryDeviceInfo:
 #
 # Union containing information about a memory device
 #
+# nvdimm is included since 2.12. virtio-pmem is included since 4.1.
+#

qapi/misc.json line 2779

Quoted 10 lines
qapi/misc.json +2 -1
 # Since: 2.1
 ##
 { 'union': 'MemoryDeviceInfo',
   'data': { 'dimm': 'PCDIMMDeviceInfo',
-            'nvdimm': 'PCDIMMDeviceInfo'
+            'nvdimm': 'PCDIMMDeviceInfo',
+            'virtio-pmem': 'VirtioPMEMDeviceInfo'
           }
 }
 
#3 lore raw

Re: [Qemu-devel] [PULL 05/22] virtio-pmem: add virtio device

In reply to Pankaj Gupta
Quoted 25 lines · Michael S. Tsirkin

From: Pankaj Gupta <[email protected]>

This is the implementation of virtio-pmem device. Support will require machine changes for the architectures that will support it, so it will not yet be compiled. It can be unlocked with VIRTIO_PMEM_SUPPORTED per machine and disabled globally via VIRTIO_PMEM.

We cannot use the "addr" property as that is already used e.g. for virtio-pci/pci devices. And we will have e.g. virtio-pmem-pci as a proxy. So we have to choose a different one (unfortunately). "memaddr" it is. That name should ideally be used by all other virtio-* based memory devices in the future.

    -device virtio-pmem-pci,id=p0,bus=bux0,addr=0x01,memaddr=0x1000000...

[ MemoryDevice/MemoryRegion changes, cleanups, addr property "memaddr",
split up patches, unplug handler ]

Message-Id: <[email protected]>

hw/virtio/virtio-pmem.c line 138

Quoted 6 lines
hw/virtio/virtio-pmem.c new file +6 -0
+static void virtio_pmem_fill_device_info(const VirtIOPMEM *pmem,
+                                         VirtioPMEMDeviceInfo *vi)
+{
+    vi->memaddr = pmem->start;
+    vi->size = pmem->memdev ? memory_region_size(&pmem->memdev->mr) : 0;
+    vi->memdev = object_get_canonical_path(OBJECT(pmem->memdev));

Hi; Coverity points out (CID 1403009) that when we're assigning vi->size we handle the "pmem->memdev is NULL" case; but we then pass it into object_get_canonical_path(), which unconditionally dereferences it and will crash if it is NULL. If this pointer can be NULL then we need to do something else here.

Quoted 1 line

+}

thanks
-- PMM

#4 lore raw

Re: [Qemu-devel] [PULL 05/22] virtio-pmem: add virtio device

Quoted 26 lines
Quoted 25 lines

From: Pankaj Gupta <[email protected]>

This is the implementation of virtio-pmem device. Support will require machine changes for the architectures that will support it, so it will not yet be compiled. It can be unlocked with VIRTIO_PMEM_SUPPORTED per machine and disabled globally via VIRTIO_PMEM.

We cannot use the "addr" property as that is already used e.g. for virtio-pci/pci devices. And we will have e.g. virtio-pmem-pci as a proxy. So we have to choose a different one (unfortunately). "memaddr" it is. That name should ideally be used by all other virtio-* based memory devices in the future.

    -device virtio-pmem-pci,id=p0,bus=bux0,addr=0x01,memaddr=0x1000000...

[ MemoryDevice/MemoryRegion changes, cleanups, addr property "memaddr",
split up patches, unplug handler ]

Message-Id: <[email protected]>

Quoted 12 lines

hw/virtio/virtio-pmem.c line 138

Quoted 6 lines
hw/virtio/virtio-pmem.c new file +6 -0
+static void virtio_pmem_fill_device_info(const VirtIOPMEM *pmem,
+                                         VirtioPMEMDeviceInfo *vi)
+{
+    vi->memaddr = pmem->start;
+    vi->size = pmem->memdev ? memory_region_size(&pmem->memdev->mr) : 0;
+    vi->memdev = object_get_canonical_path(OBJECT(pmem->memdev));

Hi; Coverity points out (CID 1403009) that when we're assigning vi->size we handle the "pmem->memdev is NULL" case; but we then pass it into object_get_canonical_path(), which unconditionally dereferences it and will crash if it is NULL. If this pointer can be NULL then we need to do something else here.

This will never be NULL. I will send below patch to pass coverity.

- vi->size = pmem->memdev ? memory_region_size(&pmem->memdev->mr) : 0;
+ vi->size = memory_region_size(&pmem->memdev->mr);

Thanks,
Pankaj

Quoted 7 lines
Quoted 2 lines

+}

thanks
-- PMM

#5 lore raw

PATCH v2 2/7 virtio-pci: Allow to specify additional interfaces for the base type

In reply to Pankaj Gupta

From: David Hildenbrand <[email protected]>

Let's allow to specify additional interfaces for the base type (e.g. later TYPE_MEMORY_DEVICE), something that was possible before the rework of virtio PCI device instantiation.

---
 hw/virtio/virtio-pci.c | 1 +
 hw/virtio/virtio-pci.h | 1 +
 2 files changed, 2 insertions(+)
hw/virtio/virtio-pci.c +1 -0
index cb44e19b67..0ac451ed0f 100644
@@ -1939,6 +1939,7 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t)
         .class_init    = virtio_pci_base_class_init,
         .class_data    = (void *)t,
         .abstract      = true,
+        .interfaces    = t->interfaces,
     };
     TypeInfo generic_type_info = {
         .name = t->generic_name,
hw/virtio/virtio-pci.h +1 -0
index 18581854ca..292275acb1 100644
@@ -233,6 +233,7 @@ typedef struct VirtioPCIDeviceTypeInfo {
     size_t class_size;
     void (*instance_init)(Object *obj);
     void (*class_init)(ObjectClass *klass, void *data);
+    InterfaceInfo *interfaces;
 } VirtioPCIDeviceTypeInfo;
 
 /* Register virtio-pci type(s).  @t must be static. */
Signature · 1 line
2.14.5
#6 lore raw

PATCH v2 3/7 virtio-pmem: sync linux headers

In reply to Pankaj Gupta

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
include/standard-headers/linux/virtio_ids.h +1 -0
index 6d5c3b2d4f..32b2f94d1f 100644
@@ -43,5 +43,6 @@
 #define VIRTIO_ID_INPUT        18 /* virtio input */
 #define VIRTIO_ID_VSOCK        19 /* virtio vsock transport */
 #define VIRTIO_ID_CRYPTO       20 /* virtio crypto */
+#define VIRTIO_ID_PMEM         27 /* virtio pmem */
 
 #endif /* _LINUX_VIRTIO_IDS_H */
include/standard-headers/linux/virtio_pmem.h new file +35 -0
new file mode 100644
index 0000000000..7a3e2fe524
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
+/*
+ * Definitions for virtio-pmem devices.
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * Author(s): Pankaj Gupta <[email protected]>
+ */
+
+#ifndef _UAPI_LINUX_VIRTIO_PMEM_H
+#define _UAPI_LINUX_VIRTIO_PMEM_H
+
+#include <linux/types.h>
+#include <linux/virtio_types.h>
+#include <linux/virtio_ids.h>
+#include <linux/virtio_config.h>
+
+struct virtio_pmem_config {
+	__le64 start;
+	__le64 size;
+};
+
+#define VIRTIO_PMEM_REQ_TYPE_FLUSH      0
+
+struct virtio_pmem_resp {
+	/* Host return status corresponding to flush request */
+	__virtio32 ret;
+};
+
+struct virtio_pmem_req {
+	/* command type */
+	__virtio32 type;
+};
+
+#endif
Signature · 1 line
2.14.5
#7 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] virtio-pmem: sync linux headers

Quoted 8 lines · On Wed, 19 Jun 2019 15:19:03 +0530 Pankaj Gupta <[email protected]> wrote:

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h

That's not yet upstream, right?

If so, I fear this feature won't make 4.1, as the merge window for Linux only opens in one or two weeks :(

#8 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] virtio-pmem: sync linux headers

Quoted 15 lines
Quoted 9 lines · On Wed, 19 Jun 2019 15:19:03 +0530 Pankaj Gupta <[email protected]> wrote:

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35
 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
Quoted 1 line

That's not yet upstream, right?

right.

Quoted 3 lines

If so, I fear this feature won't make 4.1, as the merge window for Linux only opens in one or two weeks :(

Looks so. Its lined up for 5.3 merge window.

Waiting for the kernel patch series to be merged and send an updated version of qemu series with review suggestion if any :)

Thanks,
Pankaj

Quoted 1 line
#9 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] virtio-pmem: sync linux headers

Quoted 17 lines · Pankaj Gupta
Quoted 15 lines
Quoted 9 lines · On Wed, 19 Jun 2019 15:19:03 +0530 Pankaj Gupta <[email protected]> wrote:

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35
 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
Quoted 1 line

That's not yet upstream, right?

Quoted 7 lines

right.

Quoted 3 lines

If so, I fear this feature won't make 4.1, as the merge window for Linux only opens in one or two weeks :(

Looks so. Its lined up for 5.3 merge window.

In which tree is it?

Quoted 7 lines

Waiting for the kernel patch series to be merged and send an updated version of qemu series with review suggestion if any :)

Thanks,
Pankaj

Quoted 1 line
#10 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] virtio-pmem: sync linux headers

----- Original Message -----

Quoted 22 lines · Pankaj Gupta
Quoted 20 lines
Quoted 15 lines
Quoted 9 lines · On Wed, 19 Jun 2019 15:19:03 +0530 Pankaj Gupta <[email protected]> wrote:

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35
 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
Quoted 1 line

That's not yet upstream, right?

right.

Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

If so, I fear this feature won't make 4.1, as the merge window for Linux only opens in one or two weeks :(

Looks so. Its lined up for 5.3 merge window.

In which tree is it?

Patches are in Dan's tree:
https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git/log/?h=libnvdimm-pending

Thanks,
Pankaj

Quoted 10 lines
Quoted 9 lines

Waiting for the kernel patch series to be merged and send an updated version
of qemu series with review suggestion if any :)

Thanks,
Pankaj

Quoted 1 line
#11 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] virtio-pmem: sync linux headers

Quoted 30 lines · Pankaj Gupta

----- Original Message -----

Quoted 27 lines · Pankaj Gupta
Quoted 24 lines
Quoted 15 lines
Quoted 9 lines · On Wed, 19 Jun 2019 15:19:03 +0530 Pankaj Gupta <[email protected]> wrote:

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35
 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
Quoted 1 line

That's not yet upstream, right?

right.

Quoted 3 lines

If so, I fear this feature won't make 4.1, as the merge window for Linux only opens in one or two weeks :(

Looks so. Its lined up for 5.3 merge window.

Quoted 7 lines
Quoted 1 line

In which tree is it?

Patches are in Dan's tree:
https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git/log/?h=libnvdimm-pending

Thanks,
Pankaj

Hmm ok, but that isn't part of linux-next. Do you know why?

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

Waiting for the kernel patch series to be merged and send an updated version
of qemu series with review suggestion if any :)

Thanks,
Pankaj

Quoted 1 line
#12 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] virtio-pmem: sync linux headers

Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 18 lines
Quoted 16 lines
Quoted 9 lines · On Wed, 19 Jun 2019 15:19:03 +0530 Pankaj Gupta <[email protected]> wrote:

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35
 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
Quoted 1 line

That's not yet upstream, right?

Quoted 7 lines

right.

Quoted 3 lines

If so, I fear this feature won't make 4.1, as the merge window for Linux only opens in one or two weeks :(

Looks so. Its lined up for 5.3 merge window.

In which tree is it?

Quoted 7 lines
Quoted 5 lines

Patches are in Dan's tree:
https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git/log/?h=libnvdimm-pending

Thanks,
Pankaj

Hmm ok, but that isn't part of linux-next. Do you know why?

Dan suggested to first apply in libnvdimm-pending tree to check for any zero day test bot warnings and then apply in linux-next. So, I think next step is to merge in linux-next.

Thanks,
Pankaj

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Waiting for the kernel patch series to be merged and send an updated version
of qemu series with review suggestion if any :)

Thanks,
Pankaj

Quoted 1 line
#13 lore raw

Re: [Qemu-devel] [PATCH v2 3/7] virtio-pmem: sync linux headers

In reply to Cornelia Huck
Quoted 12 lines · Cornelia Huck
Quoted 8 lines · On Wed, 19 Jun 2019 15:19:03 +0530 Pankaj Gupta <[email protected]> wrote:

Sync linux headers for virtio pmem.

---
 include/standard-headers/linux/virtio_ids.h  |  1 +
 include/standard-headers/linux/virtio_pmem.h | 35 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
Quoted 4 lines

That's not yet upstream, right?

If so, I fear this feature won't make 4.1, as the merge window for Linux only opens in one or two weeks :(

I think it's ok from that POV, I put the driver in my tree to break the deadlock for now.

Signature · 1 line
MST
#14 lore raw

PATCH v2 4/7 virtio-pci: Proxy for virtio-pmem

In reply to Pankaj Gupta

We need a proxy device for virtio-pmem, and this device has to be the actual memory device so we can cleanly hotplug it.

Forward memory device class functions either to the actual device or use properties of the virtio-pmem device to implement these in the proxy.

virtio-pmem will only be compiled for selected, supported architectures (that can deal with virtio/pci devices being memory devices). An architecture that is prepared for that can simply enable CONFIG_VIRTIO_PMEM to make it work.

As not all architectures support memory devices (and CONFIG_VIRTIO_PMEM will be enabled per supported architecture), we have to move the PCI proxy to a separate file.

[ split up patches, memory-device changes, move pci proxy]
---
 hw/virtio/Makefile.objs     |   1 +
 hw/virtio/virtio-pmem-pci.c | 131 ++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pmem-pci.h |  34 ++++++++++++
 include/hw/pci/pci.h        |   1 +
 4 files changed, 167 insertions(+)
 create mode 100644 hw/virtio/virtio-pmem-pci.c
 create mode 100644 hw/virtio/virtio-pmem-pci.h
hw/virtio/Makefile.objs +1 -0
index 5857e3b8e1..964ce78607 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon.o
 obj-$(CONFIG_VIRTIO_CRYPTO) += virtio-crypto.o
 obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_PCI)) += virtio-crypto-pci.o
 obj-$(CONFIG_VIRTIO_PMEM) += virtio-pmem.o
+common-obj-$(call land,$(CONFIG_VIRTIO_PMEM),$(CONFIG_VIRTIO_PCI)) += virtio-pmem-pci.o
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o
 
 ifeq ($(CONFIG_VIRTIO_PCI),y)
hw/virtio/virtio-pmem-pci.c new file +131 -0

131 lines not on this page · raw message

hw/virtio/virtio-pmem-pci.h new file +34 -0
new file mode 100644
index 0000000000..616abef093
@@ -0,0 +1,34 @@
+/*
+ * Virtio PMEM PCI device
+ *
+ * Copyright (C) 2018-2019 Red Hat, Inc.
+ *
+ * Authors:
+ *  Pankaj Gupta <[email protected]>
+ *  David Hildenbrand <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_VIRTIO_PMEM_PCI_H
+#define QEMU_VIRTIO_PMEM_PCI_H
+
+#include "hw/virtio/virtio-pci.h"
+#include "hw/virtio/virtio-pmem.h"
+
+typedef struct VirtIOPMEMPCI VirtIOPMEMPCI;
+
+/*
+ * virtio-pmem-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VIRTIO_PMEM_PCI "virtio-pmem-pci-base"
+#define VIRTIO_PMEM_PCI(obj) \
+        OBJECT_CHECK(VirtIOPMEMPCI, (obj), TYPE_VIRTIO_PMEM_PCI)
+
+struct VirtIOPMEMPCI {
+    VirtIOPCIProxy parent_obj;
+    VirtIOPMEM vdev;
+};
+
+#endif /* QEMU_VIRTIO_PMEM_PCI_H */
include/hw/pci/pci.h +1 -0
index edf44de21d..097feb2cb7 100644
@@ -85,6 +85,7 @@ extern bool pci_available;
 #define PCI_DEVICE_ID_VIRTIO_RNG         0x1005
 #define PCI_DEVICE_ID_VIRTIO_9P          0x1009
 #define PCI_DEVICE_ID_VIRTIO_VSOCK       0x1012
+#define PCI_DEVICE_ID_VIRTIO_PMEM        0x1013
 
 #define PCI_VENDOR_ID_REDHAT             0x1b36
 #define PCI_DEVICE_ID_REDHAT_BRIDGE      0x0001
Signature · 1 line
2.14.5
#15 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] virtio-pci: Proxy for virtio-pmem

Quoted 26 lines · On Wed, 19 Jun 2019 15:19:04 +0530 Pankaj Gupta <[email protected]> wrote:

We need a proxy device for virtio-pmem, and this device has to be the actual memory device so we can cleanly hotplug it.

Forward memory device class functions either to the actual device or use properties of the virtio-pmem device to implement these in the proxy.

virtio-pmem will only be compiled for selected, supported architectures (that can deal with virtio/pci devices being memory devices). An architecture that is prepared for that can simply enable CONFIG_VIRTIO_PMEM to make it work.

As not all architectures support memory devices (and CONFIG_VIRTIO_PMEM will be enabled per supported architecture), we have to move the PCI proxy to a separate file.

[ split up patches, memory-device changes, move pci proxy]
---
 hw/virtio/Makefile.objs     |   1 +
 hw/virtio/virtio-pmem-pci.c | 131 ++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pmem-pci.h |  34 ++++++++++++
 include/hw/pci/pci.h        |   1 +
 4 files changed, 167 insertions(+)
 create mode 100644 hw/virtio/virtio-pmem-pci.c
 create mode 100644 hw/virtio/virtio-pmem-pci.h

(...)

hw/virtio/virtio-pmem-pci.c line 116

Quoted 4 lines
hw/virtio/virtio-pmem-pci.c new file +4 -0
+static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = {
+    .base_name             = TYPE_VIRTIO_PMEM_PCI,
+    .generic_name          = "virtio-pmem-pci",
+    .transitional_name     = "virtio-pmem-pci-transitional",

Do we even have a transitional device for this? I.e., do we have a legacy version? I don't think that makes sense for new devices.

Quoted 9 lines
hw/virtio/virtio-pmem-pci.c new file +9 -0
+    .non_transitional_name = "virtio-pmem-pci-non-transitional",
+    .instance_size = sizeof(VirtIOPMEMPCI),
+    .instance_init = virtio_pmem_pci_instance_init,
+    .class_init    = virtio_pmem_pci_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_MEMORY_DEVICE },
+        { }
+    },
+};

(...)

#16 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] virtio-pci: Proxy for virtio-pmem

Quoted 35 lines
Quoted 27 lines · On Wed, 19 Jun 2019 15:19:04 +0530 Pankaj Gupta <[email protected]> wrote:

We need a proxy device for virtio-pmem, and this device has to be the actual memory device so we can cleanly hotplug it.

Forward memory device class functions either to the actual device or use properties of the virtio-pmem device to implement these in the proxy.

virtio-pmem will only be compiled for selected, supported architectures (that can deal with virtio/pci devices being memory devices). An architecture that is prepared for that can simply enable CONFIG_VIRTIO_PMEM to make it work.

As not all architectures support memory devices (and CONFIG_VIRTIO_PMEM will be enabled per supported architecture), we have to move the PCI proxy to a separate file.

[ split up patches, memory-device changes, move pci proxy]
---
 hw/virtio/Makefile.objs     |   1 +
 hw/virtio/virtio-pmem-pci.c | 131
 ++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pmem-pci.h |  34 ++++++++++++
 include/hw/pci/pci.h        |   1 +
 4 files changed, 167 insertions(+)
 create mode 100644 hw/virtio/virtio-pmem-pci.c
 create mode 100644 hw/virtio/virtio-pmem-pci.h

(...)

Quoted 7 lines

hw/virtio/virtio-pmem-pci.c line 116

Quoted 4 lines
hw/virtio/virtio-pmem-pci.c new file +4 -0
+static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = {
+    .base_name             = TYPE_VIRTIO_PMEM_PCI,
+    .generic_name          = "virtio-pmem-pci",
+    .transitional_name     = "virtio-pmem-pci-transitional",

Do we even have a transitional device for this? I.e., do we have a legacy version? I don't think that makes sense for new devices.

No. Sure, will remove this.

Thank you,
Pankaj

Quoted 13 lines
Quoted 10 lines
hw/virtio/virtio-pmem-pci.c new file +9 -0
+    .non_transitional_name = "virtio-pmem-pci-non-transitional",
+    .instance_size = sizeof(VirtIOPMEMPCI),
+    .instance_init = virtio_pmem_pci_instance_init,
+    .class_init    = virtio_pmem_pci_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_MEMORY_DEVICE },
+        { }
+    },
+};

(...)

#17 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] virtio-pci: Proxy for virtio-pmem

In reply to Cornelia Huck
Quoted 32 lines · Cornelia Huck
Quoted 26 lines · On Wed, 19 Jun 2019 15:19:04 +0530 Pankaj Gupta <[email protected]> wrote:

We need a proxy device for virtio-pmem, and this device has to be the actual memory device so we can cleanly hotplug it.

Forward memory device class functions either to the actual device or use properties of the virtio-pmem device to implement these in the proxy.

virtio-pmem will only be compiled for selected, supported architectures (that can deal with virtio/pci devices being memory devices). An architecture that is prepared for that can simply enable CONFIG_VIRTIO_PMEM to make it work.

As not all architectures support memory devices (and CONFIG_VIRTIO_PMEM will be enabled per supported architecture), we have to move the PCI proxy to a separate file.

[ split up patches, memory-device changes, move pci proxy]
---
 hw/virtio/Makefile.objs     |   1 +
 hw/virtio/virtio-pmem-pci.c | 131 ++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pmem-pci.h |  34 ++++++++++++
 include/hw/pci/pci.h        |   1 +
 4 files changed, 167 insertions(+)
 create mode 100644 hw/virtio/virtio-pmem-pci.c
 create mode 100644 hw/virtio/virtio-pmem-pci.h

(...)

Quoted 7 lines

hw/virtio/virtio-pmem-pci.c line 116

Quoted 4 lines
hw/virtio/virtio-pmem-pci.c new file +4 -0
+static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = {
+    .base_name             = TYPE_VIRTIO_PMEM_PCI,
+    .generic_name          = "virtio-pmem-pci",
+    .transitional_name     = "virtio-pmem-pci-transitional",

Do we even have a transitional device for this? I.e., do we have a legacy version? I don't think that makes sense for new devices.

I agree - I applied so pls send a patch on top. Or if you end up having to respin pls include this.

Quoted 1 line
Quoted 1 line

+ .non_transitional_name = "virtio-pmem-pci-non-transitional",

Neither do we need a non transitional name.

Quoted 10 lines
Quoted 8 lines
hw/virtio/virtio-pmem-pci.c new file +8 -0
+    .instance_size = sizeof(VirtIOPMEMPCI),
+    .instance_init = virtio_pmem_pci_instance_init,
+    .class_init    = virtio_pmem_pci_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_MEMORY_DEVICE },
+        { }
+    },
+};

(...)

#18 lore raw

Re: [Qemu-devel] [PATCH v2 4/7] virtio-pci: Proxy for virtio-pmem

Quoted 42 lines · Cornelia Huck
Quoted 39 lines
Quoted 28 lines · On Wed, 19 Jun 2019 15:19:04 +0530 Pankaj Gupta <[email protected]> wrote:

We need a proxy device for virtio-pmem, and this device has to be the actual memory device so we can cleanly hotplug it.

Forward memory device class functions either to the actual device or use properties of the virtio-pmem device to implement these in the proxy.

virtio-pmem will only be compiled for selected, supported architectures (that can deal with virtio/pci devices being memory devices). An architecture that is prepared for that can simply enable CONFIG_VIRTIO_PMEM to make it work.

As not all architectures support memory devices (and CONFIG_VIRTIO_PMEM will be enabled per supported architecture), we have to move the PCI proxy
to a separate file.

[ split up patches, memory-device changes, move pci proxy]
---
 hw/virtio/Makefile.objs     |   1 +
 hw/virtio/virtio-pmem-pci.c | 131
 ++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-pmem-pci.h |  34 ++++++++++++
 include/hw/pci/pci.h        |   1 +
 4 files changed, 167 insertions(+)
 create mode 100644 hw/virtio/virtio-pmem-pci.c
 create mode 100644 hw/virtio/virtio-pmem-pci.h

(...)

Quoted 4 lines
hw/virtio/virtio-pmem-pci.c new file +4 -0
+static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = {
+    .base_name             = TYPE_VIRTIO_PMEM_PCI,
+    .generic_name          = "virtio-pmem-pci",
+    .transitional_name     = "virtio-pmem-pci-transitional",
Quoted 6 lines
Quoted 2 lines

Do we even have a transitional device for this? I.e., do we have a legacy version? I don't think that makes sense for new devices.

I agree - I applied so pls send a patch on top. Or if you end up having to respin pls include this.

Sure. Thank you!

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

+ .non_transitional_name = "virtio-pmem-pci-non-transitional",

Neither do we need a non transitional name.

o.k

Best regards,
Pankaj

Quoted 12 lines
Quoted 11 lines
Quoted 9 lines
hw/virtio/virtio-pmem-pci.c new file +8 -0
+    .instance_size = sizeof(VirtIOPMEMPCI),
+    .instance_init = virtio_pmem_pci_instance_init,
+    .class_init    = virtio_pmem_pci_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_MEMORY_DEVICE },
+        { }
+    },
+};

(...)

#19 lore raw

Re: [Qemu-devel] [PULL 08/22] virtio-pci: Proxy for virtio-pmem

In reply to Pankaj Gupta
Quoted 18 lines · Michael S. Tsirkin

From: Pankaj Gupta <[email protected]>

We need a proxy device for virtio-pmem, and this device has to be the actual memory device so we can cleanly hotplug it.

Forward memory device class functions either to the actual device or use properties of the virtio-pmem device to implement these in the proxy.

virtio-pmem will only be compiled for selected, supported architectures (that can deal with virtio/pci devices being memory devices). An architecture that is prepared for that can simply enable CONFIG_VIRTIO_PMEM to make it work.

As not all architectures support memory devices (and CONFIG_VIRTIO_PMEM will be enabled per supported architecture), we have to move the PCI proxy to a separate file.

Quoted 7 lines
[ split up patches, memory-device changes, move pci proxy]

Message-Id: <[email protected]>

---

Hi; Coverity spotted a bug here (CID 1403010):

hw/virtio/virtio-pmem-pci.c line 60

Quoted 10 lines
hw/virtio/virtio-pmem-pci.c new file +10 -0
+static uint64_t virtio_pmem_pci_get_plugged_size(const MemoryDeviceState *md,
+                                                 Error **errp)
+{
+    VirtIOPMEMPCI *pci_pmem = VIRTIO_PMEM_PCI(md);
+    VirtIOPMEM *pmem = VIRTIO_PMEM(&pci_pmem->vdev);
+    VirtIOPMEMClass *vpc = VIRTIO_PMEM_GET_CLASS(pmem);
+    MemoryRegion *mr = vpc->get_memory_region(pmem, errp);
+
+    /* the plugged size corresponds to the region size */
+    return mr ? 0 : memory_region_size(mr);

This looks like maybe the arguments to ?: have been put the wrong way round? If mr is non-NULL we'll return 0 and if it is NULL then we'll crash because memory_region_size() dereferences mr...

Quoted 1 line

+}

thanks
-- PMM

#20 lore raw

Re: [Qemu-devel] [PULL 08/22] virtio-pci: Proxy for virtio-pmem

Hi Peter,

Quoted 27 lines
Quoted 17 lines

From: Pankaj Gupta <[email protected]>

We need a proxy device for virtio-pmem, and this device has to be the actual memory device so we can cleanly hotplug it.

Forward memory device class functions either to the actual device or use properties of the virtio-pmem device to implement these in the proxy.

virtio-pmem will only be compiled for selected, supported architectures (that can deal with virtio/pci devices being memory devices). An architecture that is prepared for that can simply enable CONFIG_VIRTIO_PMEM to make it work.

As not all architectures support memory devices (and CONFIG_VIRTIO_PMEM will be enabled per supported architecture), we have to move the PCI proxy to a separate file.

Quoted 7 lines
[ split up patches, memory-device changes, move pci proxy]

Message-Id: <[email protected]>

---

Hi; Coverity spotted a bug here (CID 1403010):

Quoted 16 lines

hw/virtio/virtio-pmem-pci.c line 60

Quoted 11 lines

+static uint64_t virtio_pmem_pci_get_plugged_size(const MemoryDeviceState *md,

hw/virtio/virtio-pmem-pci.c new file +9 -0
+                                                 Error **errp)
+{
+    VirtIOPMEMPCI *pci_pmem = VIRTIO_PMEM_PCI(md);
+    VirtIOPMEM *pmem = VIRTIO_PMEM(&pci_pmem->vdev);
+    VirtIOPMEMClass *vpc = VIRTIO_PMEM_GET_CLASS(pmem);
+    MemoryRegion *mr = vpc->get_memory_region(pmem, errp);
+
+    /* the plugged size corresponds to the region size */
+    return mr ? 0 : memory_region_size(mr);

This looks like maybe the arguments to ?: have been put the wrong way round? If mr is non-NULL we'll return 0 and if it is NULL then we'll crash because memory_region_size() dereferences mr...

Yes. I will send a patch to fix this.

Thanks,
Pankaj

Quoted 7 lines
Quoted 2 lines

+}

thanks
-- PMM

#21 lore raw

PATCH v2 5/7 hmp: Handle virtio-pmem when printing memory device infos

In reply to Pankaj Gupta

From: David Hildenbrand <[email protected]>

Print the memory device info just like for PCDIMM/NVDIMM.

---
 hmp.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
hmp.c +15 -12
index 92941142af..e1866bc7f1 100644
@@ -2650,6 +2650,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
     MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
     MemoryDeviceInfoList *info;
+    VirtioPMEMDeviceInfo *vpi;
     MemoryDeviceInfo *value;
     PCDIMMDeviceInfo *di;
 
@@ -2659,19 +2660,9 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
         if (value) {
             switch (value->type) {
             case MEMORY_DEVICE_INFO_KIND_DIMM:
-                di = value->u.dimm.data;
-                break;
-
             case MEMORY_DEVICE_INFO_KIND_NVDIMM:
-                di = value->u.nvdimm.data;
-                break;
-
-            default:
-                di = NULL;
-                break;
-            }
-
-            if (di) {
+                di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
+                     value->u.dimm.data : value->u.nvdimm.data;
                 monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
                                MemoryDeviceInfoKind_str(value->type),
                                di->id ? di->id : "");
@@ -2684,6 +2675,18 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
                                di->hotplugged ? "true" : "false");
                 monitor_printf(mon, "  hotpluggable: %s\n",
                                di->hotpluggable ? "true" : "false");
+                break;
+            case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
+                vpi = value->u.virtio_pmem.data;
+                monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
+                               MemoryDeviceInfoKind_str(value->type),
+                               vpi->id ? vpi->id : "");
+                monitor_printf(mon, "  memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
+                monitor_printf(mon, "  size: %" PRIu64 "\n", vpi->size);
+                monitor_printf(mon, "  memdev: %s\n", vpi->memdev);
+                break;
+            default:
+                g_assert_not_reached();
             }
         }
     }
Signature · 1 line
2.14.5
#22 lore raw

Re: [Qemu-devel] [PATCH v2 5/7] hmp: Handle virtio-pmem when printing memory device infos

Quoted 6 lines · Pankaj Gupta

From: David Hildenbrand <[email protected]>

Print the memory device info just like for PCDIMM/NVDIMM.

This one not apply on latest code. Need to rebase it.

Quoted 60 lines

---
hmp.c | 27 +++++++++++++++------------

1 file changed, 15 insertions(+), 12 deletions(-)
hmp.c +15 -12
index 92941142af..e1866bc7f1 100644
@@ -2650,6 +2650,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
    Error *err = NULL;
    MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
    MemoryDeviceInfoList *info;
+    VirtioPMEMDeviceInfo *vpi;
    MemoryDeviceInfo *value;
    PCDIMMDeviceInfo *di;
 
@@ -2659,19 +2660,9 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
        if (value) {
            switch (value->type) {
            case MEMORY_DEVICE_INFO_KIND_DIMM:
-                di = value->u.dimm.data;
-                break;
-
            case MEMORY_DEVICE_INFO_KIND_NVDIMM:
-                di = value->u.nvdimm.data;
-                break;
-
-            default:
-                di = NULL;
-                break;
-            }
-
-            if (di) {
+                di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
+                     value->u.dimm.data : value->u.nvdimm.data;
                monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
                               MemoryDeviceInfoKind_str(value->type),
                               di->id ? di->id : "");
@@ -2684,6 +2675,18 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
                               di->hotplugged ? "true" : "false");
                monitor_printf(mon, "  hotpluggable: %s\n",
                               di->hotpluggable ? "true" : "false");
+                break;
+            case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
+                vpi = value->u.virtio_pmem.data;
+                monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
+                               MemoryDeviceInfoKind_str(value->type),
+                               vpi->id ? vpi->id : "");
+                monitor_printf(mon, "  memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
+                monitor_printf(mon, "  size: %" PRIu64 "\n", vpi->size);
+                monitor_printf(mon, "  memdev: %s\n", vpi->memdev);
+                break;
+            default:
+                g_assert_not_reached();
            }
        }
    }
Signature · 1 line
2.14.5
Signature · 2 lines
Wei Yang
Help you, Help me
#23 lore raw

Re: [Qemu-devel] [PATCH v2 5/7] hmp: Handle virtio-pmem when printing memory device infos

Quoted 11 lines · Pankaj Gupta
Quoted 6 lines

From: David Hildenbrand <[email protected]>

Print the memory device info just like for PCDIMM/NVDIMM.

This one not apply on latest code. Need to rebase it.

Yes,

Thanks,
Pankaj

Quoted 71 lines
Quoted 62 lines

---
hmp.c | 27 +++++++++++++++------------

1 file changed, 15 insertions(+), 12 deletions(-)
hmp.c +3 -12
index 92941142af..e1866bc7f1 100644
@@ -2650,6 +2650,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict
 *qdict)
    Error *err = NULL;
    MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
    MemoryDeviceInfoList *info;
+    VirtioPMEMDeviceInfo *vpi;
    MemoryDeviceInfo *value;
    PCDIMMDeviceInfo *di;
@@ -2659,19 +2660,9 @@ void hmp_info_memory_devices(Monitor *mon, const
 QDict *qdict)
        if (value) {
            switch (value->type) {
            case MEMORY_DEVICE_INFO_KIND_DIMM:
-                di = value->u.dimm.data;
-                break;
-
            case MEMORY_DEVICE_INFO_KIND_NVDIMM:
-                di = value->u.nvdimm.data;
-                break;
-
-            default:
-                di = NULL;
-                break;
-            }
-
-            if (di) {
+                di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
+                     value->u.dimm.data : value->u.nvdimm.data;
                monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
                               MemoryDeviceInfoKind_str(value->type),
                               di->id ? di->id : "");
hmp.c +12 -0
@@ -2684,6 +2675,18 @@ void hmp_info_memory_devices(Monitor *mon, const
 QDict *qdict)
                               di->hotplugged ? "true" : "false");
                monitor_printf(mon, "  hotpluggable: %s\n",
                               di->hotpluggable ? "true" : "false");
+                break;
+            case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
+                vpi = value->u.virtio_pmem.data;
+                monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
+                               MemoryDeviceInfoKind_str(value->type),
+                               vpi->id ? vpi->id : "");
+                monitor_printf(mon, "  memaddr: 0x%" PRIx64 "\n",
 vpi->memaddr);
+                monitor_printf(mon, "  size: %" PRIu64 "\n", vpi->size);
+                monitor_printf(mon, "  memdev: %s\n", vpi->memdev);
+                break;
+            default:
+                g_assert_not_reached();
            }
        }
    }
Quoted 3 lines

--
2.14.5

--
Wei Yang
Help you, Help me

#24 lore raw

PATCH v2 6/7 numa: Handle virtio-pmem in NUMA stats

In reply to Pankaj Gupta

From: David Hildenbrand <[email protected]>

Account the memory to node 0 for now. Once (if ever) virtio-pmem supports NUMA, we can account it to the right node.

---
 numa.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
numa.c +12 -12
index 3875e1efda..42cca616e7 100644
@@ -549,6 +549,7 @@ static void numa_stat_memory_devices(NumaNodeMem node_mem[])
     MemoryDeviceInfoList *info_list = qmp_memory_device_list();
     MemoryDeviceInfoList *info;
     PCDIMMDeviceInfo     *pcdimm_info;
+    VirtioPMEMDeviceInfo *vpi;
 
     for (info = info_list; info; info = info->next) {
         MemoryDeviceInfo *value = info->value;
@@ -556,22 +557,21 @@ static void numa_stat_memory_devices(NumaNodeMem node_mem[])
         if (value) {
             switch (value->type) {
             case MEMORY_DEVICE_INFO_KIND_DIMM:
-                pcdimm_info = value->u.dimm.data;
-                break;
-
             case MEMORY_DEVICE_INFO_KIND_NVDIMM:
-                pcdimm_info = value->u.nvdimm.data;
-                break;
-
-            default:
-                pcdimm_info = NULL;
-                break;
-            }
-
-            if (pcdimm_info) {
+                pcdimm_info = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
+                              value->u.dimm.data : value->u.nvdimm.data;
                 node_mem[pcdimm_info->node].node_mem += pcdimm_info->size;
                 node_mem[pcdimm_info->node].node_plugged_mem +=
                     pcdimm_info->size;
+                break;
+            case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
+                vpi = value->u.virtio_pmem.data;
+                /* TODO: once we support numa, assign to right node */
+                node_mem[0].node_mem += vpi->size;
+                node_mem[0].node_plugged_mem += vpi->size;
+                break;
+            default:
+                g_assert_not_reached();
             }
         }
     }
Signature · 1 line
2.14.5
#25 lore raw

PATCH v2 7/7 pc: Support for virtio-pmem-pci

In reply to Pankaj Gupta

From: David Hildenbrand <[email protected]>

Override the device hotplug handler to properly handle the memory device part via virtio-pmem-pci callbacks from the machine hotplug handler and forward to the actual PCI bus hotplug handler.

As PCI hotplug has not been properly factored out into hotplug handlers, most magic is performed in the (un)realize functions. Also some PCI host buses don't have a PCI hotplug handler at all yet, just to be sure that we alway have a hotplug handler on x86, add a simple error check.

Unlocking virtio-pmem will unlock virtio-pmem-pci.

[ Disable virtio-pmem hotunplug ]
---
 hw/i386/Kconfig |  1 +
 hw/i386/pc.c    | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 1 deletion(-)
hw/i386/Kconfig +1 -0
index 9817888216..4ddf2a9c55 100644
@@ -30,6 +30,7 @@ config PC
     # For ACPI builder:
     select SERIAL_ISA
     select ACPI_VMGENID
+    select VIRTIO_PMEM_SUPPORTED
 
 config PC_PCI
     bool
hw/i386/pc.c +71 -1

114 lines not on this page · raw message

Signature · 1 line
2.14.5
#26 lore raw
In reply to Pankaj Gupta

Ping.

Quoted 120 lines

This patch series has implementation for "virtio pmem"
device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G -object memory-backend-file,id=mem1,share,mem-path=test.img,
size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

 hmp.c                                        |   27 ++-
 hw/i386/Kconfig                              |    1
 hw/i386/pc.c                                 |   72 ++++++++++
 hw/virtio/Kconfig                            |   10 +
 hw/virtio/Makefile.objs                      |    2
 hw/virtio/virtio-pci.c                       |    1
 hw/virtio/virtio-pci.h                       |    1
 hw/virtio/virtio-pmem-pci.c                  |  131 ++++++++++++++++++
 hw/virtio/virtio-pmem-pci.h                  |   34 ++++
 hw/virtio/virtio-pmem.c                      |  189
 +++++++++++++++++++++++++++
 include/hw/pci/pci.h                         |    1
 include/hw/virtio/virtio-pmem.h              |   49 +++++++
 include/standard-headers/linux/virtio_ids.h  |    1
 include/standard-headers/linux/virtio_pmem.h |   35 +++++
 numa.c                                       |   24 +--
 qapi/misc.json                               |   28 +++-
 16 files changed, 580 insertions(+), 26 deletions(-)

----

#27 lore raw
In reply to Pankaj Gupta
Quoted 15 lines · Pankaj Gupta

This patch series has implementation for "virtio pmem" device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G

Review

Quoted 3 lines
(quoted diff) +0 -2
-object memory-backend-file,id=mem1,share,mem-path=test.img,
 size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

Hi, Pankaj

I tried this series with v14 kernel driver, while getting some error on using this. Not sure this is my error configuration.

The qemu command line is:

    -object memory-backend-file,id=mem1,share=on,mem-path=/dev/dax0.0,size=1G,align=2M 
    -device virtio-pmem-pci,memdev=mem1,id=nv1

The guest boots up and I can see /dev/pmem0 device. But when I want to partition this device, I got the error:

    # parted /dev/pmem0 mklabel gpt
    Warning: Error fsyncing/closing /dev/pmem0: Input/output error

Also I see an error when running "ndctl list":

libndctl: __sysfs_device_parse: ndctl0: add_dev() failed

Would you mind letting me know which part I am wrong?

Quoted 98 lines

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

hmp.c                                        |   27 ++-
hw/i386/Kconfig                              |    1 
hw/i386/pc.c                                 |   72 ++++++++++
hw/virtio/Kconfig                            |   10 +
hw/virtio/Makefile.objs                      |    2 
hw/virtio/virtio-pci.c                       |    1 
hw/virtio/virtio-pci.h                       |    1 
hw/virtio/virtio-pmem-pci.c                  |  131 ++++++++++++++++++
hw/virtio/virtio-pmem-pci.h                  |   34 ++++
hw/virtio/virtio-pmem.c                      |  189 +++++++++++++++++++++++++++
include/hw/pci/pci.h                         |    1 
include/hw/virtio/virtio-pmem.h              |   49 +++++++
include/standard-headers/linux/virtio_ids.h  |    1 
include/standard-headers/linux/virtio_pmem.h |   35 +++++
numa.c                                       |   24 +--
qapi/misc.json                               |   28 +++-
16 files changed, 580 insertions(+), 26 deletions(-)

----

Signature · 2 lines
Wei Yang
Help you, Help me
#28 lore raw
Quoted 15 lines · Pankaj Gupta
Quoted 12 lines

This patch series has implementation for "virtio pmem" device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Quoted 8 lines

Review

Quoted 6 lines

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G

(quoted diff) +0 -2
-object memory-backend-file,id=mem1,share,mem-path=test.img,
 size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

Hi, Pankaj

Hi Wei,

Quoted 9 lines

I tried this series with v14 kernel driver, while getting some error on using this. Not sure this is my error configuration.

The qemu command line is:

    -object
    memory-backend-file,id=mem1,share=on,mem-path=/dev/dax0.0,size=1G,align=2M
    -device virtio-pmem-pci,memdev=mem1,id=nv1

Are you using host backing on real NVDIMM? Currently, we only support backing image file on regular SSD. We have plans to support backing file on real NVDIMM device as well but this is part of future work.

Can you please try by allocating a raw image file on regular SSD. It is working fine for me.

Quoted 10 lines

The guest boots up and I can see /dev/pmem0 device. But when I want to partition this device, I got the error:

    # parted /dev/pmem0 mklabel gpt
    Warning: Error fsyncing/closing /dev/pmem0: Input/output error

Also I see an error when running "ndctl list":

libndctl: __sysfs_device_parse: ndctl0: add_dev() failed

Will look at this if it is related.

Thanks,
Pankaj

Quoted 108 lines

Would you mind letting me know which part I am wrong?

Quoted 98 lines

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

hmp.c                                        |   27 ++-
hw/i386/Kconfig                              |    1
hw/i386/pc.c                                 |   72 ++++++++++
hw/virtio/Kconfig                            |   10 +
hw/virtio/Makefile.objs                      |    2
hw/virtio/virtio-pci.c                       |    1
hw/virtio/virtio-pci.h                       |    1
hw/virtio/virtio-pmem-pci.c                  |  131 ++++++++++++++++++
hw/virtio/virtio-pmem-pci.h                  |   34 ++++
hw/virtio/virtio-pmem.c                      |  189
+++++++++++++++++++++++++++
include/hw/pci/pci.h                         |    1
include/hw/virtio/virtio-pmem.h              |   49 +++++++
include/standard-headers/linux/virtio_ids.h  |    1
include/standard-headers/linux/virtio_pmem.h |   35 +++++
numa.c                                       |   24 +--
qapi/misc.json                               |   28 +++-
16 files changed, 580 insertions(+), 26 deletions(-)
Quoted 1 line

----

--
Wei Yang
Help you, Help me

#29 lore raw
Quoted 36 lines · Pankaj Gupta
Quoted 15 lines · Pankaj Gupta
Quoted 12 lines

This patch series has implementation for "virtio pmem" device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Quoted 8 lines

Review

Quoted 6 lines

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G

(quoted diff) +0 -2
-object memory-backend-file,id=mem1,share,mem-path=test.img,
 size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

Hi, Pankaj

Hi Wei,

Quoted 9 lines

I tried this series with v14 kernel driver, while getting some error on using this. Not sure this is my error configuration.

The qemu command line is:

    -object
    memory-backend-file,id=mem1,share=on,mem-path=/dev/dax0.0,size=1G,align=2M
    -device virtio-pmem-pci,memdev=mem1,id=nv1
Quoted 7 lines

Are you using host backing on real NVDIMM? Currently, we only support backing image file on regular SSD. We have plans to support backing file on real NVDIMM device as well but this is part of future work.

Can you please try by allocating a raw image file on regular SSD. It is working fine for me.

I created a file with 2G on my disk.

#ll -h 2G-file
-rw-r--r-- 1 richard richard 2.0G 6月 26 09:26 2G-file

The command line is changed to:

-object memory-backend-file,id=mem1,share,mem-path=/home/richard/guest/2G-file,size=2G -device virtio-pmem-pci,memdev=mem1,id=nv1

The behavior in guest is the same.

I took a look into the directory /sys/bus/nd/device. These files are listed. Compared with normal system, one device file is missed.

btt0.0 dax0.0 namespace0.0 ndbus0 pfn0.0 region0

But the sysfs shows pmem0 block device is created.

/sys/devices/pci0000:00/0000:00:04.0/virtio0/ndbus0/region0/namespace0.0/block/pmem0

Then I took a look into the pci device:

# lspci -vs 00:04.0
00:04.0 Unclassified device [00ff]: Red Hat, Inc. Device 1013
	Subsystem: Red Hat, Inc. Device 001b
	Physical Slot: 4
	Flags: bus master, fast devsel, latency 0, IRQ 11
	I/O ports at c040 [size=64]
	Memory at fe000000 (64-bit, prefetchable) [size=16K]
	Capabilities: [84] Vendor Specific Information: VirtIO: <unknown>
	Capabilities: [70] Vendor Specific Information: VirtIO: Notify
	Capabilities: [60] Vendor Specific Information: VirtIO: DeviceCfg
	Capabilities: [50] Vendor Specific Information: VirtIO: ISR
	Capabilities: [40] Vendor Specific Information: VirtIO: CommonCfg
	Kernel driver in use: virtio-pci

This looks good.

Quoted 4 lines
Quoted 4 lines

The guest boots up and I can see /dev/pmem0 device. But when I want to partition this device, I got the error:

Quoted 8 lines
Quoted 6 lines
    # parted /dev/pmem0 mklabel gpt
    Warning: Error fsyncing/closing /dev/pmem0: Input/output error

Also I see an error when running "ndctl list":

libndctl: __sysfs_device_parse: ndctl0: add_dev() failed

Will look at this if it is related.

This log still there.

Quoted 111 lines

Thanks,
Pankaj

Quoted 108 lines

Would you mind letting me know which part I am wrong?

Quoted 98 lines

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

hmp.c                                        |   27 ++-
hw/i386/Kconfig                              |    1
hw/i386/pc.c                                 |   72 ++++++++++
hw/virtio/Kconfig                            |   10 +
hw/virtio/Makefile.objs                      |    2
hw/virtio/virtio-pci.c                       |    1
hw/virtio/virtio-pci.h                       |    1
hw/virtio/virtio-pmem-pci.c                  |  131 ++++++++++++++++++
hw/virtio/virtio-pmem-pci.h                  |   34 ++++
hw/virtio/virtio-pmem.c                      |  189
+++++++++++++++++++++++++++
include/hw/pci/pci.h                         |    1
include/hw/virtio/virtio-pmem.h              |   49 +++++++
include/standard-headers/linux/virtio_ids.h  |    1
include/standard-headers/linux/virtio_pmem.h |   35 +++++
numa.c                                       |   24 +--
qapi/misc.json                               |   28 +++-
16 files changed, 580 insertions(+), 26 deletions(-)
Quoted 1 line

----

--
Wei Yang
Help you, Help me

Signature · 2 lines
Wei Yang
Help you, Help me
#30 lore raw
Quoted 54 lines
Quoted 44 lines
Quoted 16 lines · Pankaj Gupta
Quoted 12 lines

This patch series has implementation for "virtio pmem" device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Quoted 8 lines

Review

Quoted 6 lines

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G

(quoted diff) +0 -2
-object memory-backend-file,id=mem1,share,mem-path=test.img,
 size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

Hi, Pankaj

Hi Wei,

Quoted 10 lines

I tried this series with v14 kernel driver, while getting some error on using
this. Not sure this is my error configuration.

The qemu command line is:

    -object
    memory-backend-file,id=mem1,share=on,mem-path=/dev/dax0.0,size=1G,align=2M
    -device virtio-pmem-pci,memdev=mem1,id=nv1

Are you using host backing on real NVDIMM? Currently, we only support backing image
file on regular SSD. We have plans to support backing file on real NVDIMM device
as well but this is part of future work.

Quoted 4 lines

Can you please try by allocating a raw image file on regular SSD. It is working fine
for me.

I created a file with 2G on my disk.

#ll -h 2G-file
-rw-r--r-- 1 richard richard 2.0G 6月 26 09:26 2G-file

Quoted 7 lines

The command line is changed to:

-object memory-backend-file,id=mem1,share,mem-path=/home/richard/guest/2G-file,size=2G -device virtio-pmem-pci,memdev=mem1,id=nv1

The behavior in guest is the same.

Are you still facing an error with this? or its working fine for you?

Quoted 3 lines

I took a look into the directory /sys/bus/nd/device. These files are listed. Compared with normal system, one device file is missed.

virtio pmem does not support namespace/region mappings which ACPI NFIT supports.

Quoted 23 lines

btt0.0 dax0.0 namespace0.0 ndbus0 pfn0.0 region0

But the sysfs shows pmem0 block device is created.

/sys/devices/pci0000:00/0000:00:04.0/virtio0/ndbus0/region0/namespace0.0/block/pmem0

Then I took a look into the pci device:

# lspci -vs 00:04.0
00:04.0 Unclassified device [00ff]: Red Hat, Inc. Device 1013
        Subsystem: Red Hat, Inc. Device 001b
        Physical Slot: 4
        Flags: bus master, fast devsel, latency 0, IRQ 11
        I/O ports at c040 [size=64]
        Memory at fe000000 (64-bit, prefetchable) [size=16K]
        Capabilities: [84] Vendor Specific Information: VirtIO: 
        Capabilities: [70] Vendor Specific Information: VirtIO: Notify
        Capabilities: [60] Vendor Specific Information: VirtIO: DeviceCfg
        Capabilities: [50] Vendor Specific Information: VirtIO: ISR
        Capabilities: [40] Vendor Specific Information: VirtIO: CommonCfg
        Kernel driver in use: virtio-pci
Quoted 1 line

This looks good.

Good to know.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

The guest boots up and I can see /dev/pmem0 device. But when I want to partition this device, I got the error:

    # parted /dev/pmem0 mklabel gpt
    Warning: Error fsyncing/closing /dev/pmem0: Input/output error
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Also I see an error when running "ndctl list":

libndctl: __sysfs_device_parse: ndctl0: add_dev() failed

Will look at this if it is related.

This log still there.

It looks to me libndctl needs to be taught about about virtio pmem data parsing. But this is unrelated to kernel and qemu patch series.

Quoted 118 lines
Quoted 112 lines

Thanks,
Pankaj

Quoted 108 lines

Would you mind letting me know which part I am wrong?

Quoted 98 lines

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

hmp.c                                        |   27 ++-
hw/i386/Kconfig                              |    1
hw/i386/pc.c                                 |   72 ++++++++++
hw/virtio/Kconfig                            |   10 +
hw/virtio/Makefile.objs                      |    2
hw/virtio/virtio-pci.c                       |    1
hw/virtio/virtio-pci.h                       |    1
hw/virtio/virtio-pmem-pci.c                  |  131 ++++++++++++++++++
hw/virtio/virtio-pmem-pci.h                  |   34 ++++
hw/virtio/virtio-pmem.c                      |  189
+++++++++++++++++++++++++++
include/hw/pci/pci.h                         |    1
include/hw/virtio/virtio-pmem.h              |   49 +++++++
include/standard-headers/linux/virtio_ids.h  |    1
include/standard-headers/linux/virtio_pmem.h |   35 +++++
numa.c                                       |   24 +--
qapi/misc.json                               |   28 +++-
16 files changed, 580 insertions(+), 26 deletions(-)
Quoted 1 line

----

--
Wei Yang
Help you, Help me

--
Wei Yang
Help you, Help me

#31 lore raw
Quoted 56 lines · Pankaj Gupta
Quoted 56 lines
Quoted 44 lines
Quoted 16 lines · Pankaj Gupta
Quoted 12 lines

This patch series has implementation for "virtio pmem" device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Quoted 8 lines

Review

Quoted 6 lines

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G

(quoted diff) +0 -2
-object memory-backend-file,id=mem1,share,mem-path=test.img,
 size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

Hi, Pankaj

Hi Wei,

Quoted 10 lines

I tried this series with v14 kernel driver, while getting some error on using
this. Not sure this is my error configuration.

The qemu command line is:

    -object
    memory-backend-file,id=mem1,share=on,mem-path=/dev/dax0.0,size=1G,align=2M
    -device virtio-pmem-pci,memdev=mem1,id=nv1

Are you using host backing on real NVDIMM? Currently, we only support backing image
file on regular SSD. We have plans to support backing file on real NVDIMM device
as well but this is part of future work.

Quoted 4 lines

Can you please try by allocating a raw image file on regular SSD. It is working fine
for me.

I created a file with 2G on my disk.

#ll -h 2G-file
-rw-r--r-- 1 richard richard 2.0G 6月 26 09:26 2G-file

The command line is changed to:

Quoted 8 lines
Quoted 5 lines

-object memory-backend-file,id=mem1,share,mem-path=/home/richard/guest/2G-file,size=2G -device virtio-pmem-pci,memdev=mem1,id=nv1

The behavior in guest is the same.

Are you still facing an error with this? or its working fine for you?

I can partition and mkfs with /dev/pmem0 after I use the SSD backend.

Quoted 6 lines
Quoted 3 lines

I took a look into the directory /sys/bus/nd/device. These files are listed. Compared with normal system, one device file is missed.

virtio pmem does not support namespace/region mappings which ACPI NFIT supports.

Ok, thanks.

Quoted 37 lines
Quoted 23 lines

btt0.0 dax0.0 namespace0.0 ndbus0 pfn0.0 region0

But the sysfs shows pmem0 block device is created.

/sys/devices/pci0000:00/0000:00:04.0/virtio0/ndbus0/region0/namespace0.0/block/pmem0

Then I took a look into the pci device:

# lspci -vs 00:04.0
00:04.0 Unclassified device [00ff]: Red Hat, Inc. Device 1013
        Subsystem: Red Hat, Inc. Device 001b
        Physical Slot: 4
        Flags: bus master, fast devsel, latency 0, IRQ 11
        I/O ports at c040 [size=64]
        Memory at fe000000 (64-bit, prefetchable) [size=16K]
        Capabilities: [84] Vendor Specific Information: VirtIO: 
        Capabilities: [70] Vendor Specific Information: VirtIO: Notify
        Capabilities: [60] Vendor Specific Information: VirtIO: DeviceCfg
        Capabilities: [50] Vendor Specific Information: VirtIO: ISR
        Capabilities: [40] Vendor Specific Information: VirtIO: CommonCfg
        Kernel driver in use: virtio-pci
Quoted 1 line

This looks good.

Good to know.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

The guest boots up and I can see /dev/pmem0 device. But when I want to partition this device, I got the error:

    # parted /dev/pmem0 mklabel gpt
    Warning: Error fsyncing/closing /dev/pmem0: Input/output error

Also I see an error when running "ndctl list":

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

libndctl: __sysfs_device_parse: ndctl0: add_dev() failed

Will look at this if it is related.

This log still there.

It looks to me libndctl needs to be taught about about virtio pmem data parsing. But this is unrelated to kernel and qemu patch series.

Ok, if it works, we could list those regions? and change pmem0 mode to dax mode, right?

Quoted 118 lines
Quoted 118 lines
Quoted 112 lines

Thanks,
Pankaj

Quoted 108 lines

Would you mind letting me know which part I am wrong?

Quoted 98 lines

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6] https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

hmp.c                                        |   27 ++-
hw/i386/Kconfig                              |    1
hw/i386/pc.c                                 |   72 ++++++++++
hw/virtio/Kconfig                            |   10 +
hw/virtio/Makefile.objs                      |    2
hw/virtio/virtio-pci.c                       |    1
hw/virtio/virtio-pci.h                       |    1
hw/virtio/virtio-pmem-pci.c                  |  131 ++++++++++++++++++
hw/virtio/virtio-pmem-pci.h                  |   34 ++++
hw/virtio/virtio-pmem.c                      |  189
+++++++++++++++++++++++++++
include/hw/pci/pci.h                         |    1
include/hw/virtio/virtio-pmem.h              |   49 +++++++
include/standard-headers/linux/virtio_ids.h  |    1
include/standard-headers/linux/virtio_pmem.h |   35 +++++
numa.c                                       |   24 +--
qapi/misc.json                               |   28 +++-
16 files changed, 580 insertions(+), 26 deletions(-)
Quoted 1 line

----

--
Wei Yang
Help you, Help me

--
Wei Yang
Help you, Help me

Signature · 2 lines
Wei Yang
Help you, Help me
#32 lore raw
Quoted 61 lines
Quoted 61 lines
Quoted 61 lines
Quoted 45 lines
Quoted 17 lines · Pankaj Gupta
Quoted 12 lines

This patch series has implementation for "virtio pmem" device. "virtio pmem" is persistent memory(nvdimm) device in guest which allows to bypass the guest page cache. This also implements a VIRTIO based asynchronous flush mechanism. Details of project idea for 'virtio pmem' flushing interface is shared [2] & [3].

Sharing Qemu device emulation in this patchset. Tested with guest kernel driver [1]. This series is based on David's memory device refactoring [5] work with modified version of my initial virtio pmem [4] series.

Quoted 8 lines

Review

Quoted 6 lines

Usage:
./qemu -name test -machine pc -m 8G,slots=240,maxmem=20G

(quoted diff) +0 -2
-object memory-backend-file,id=mem1,share,mem-path=test.img,
 size=4G,share
-device virtio-pmem-pci,memdev=mem1,id=nv1

Hi, Pankaj

Hi Wei,

Quoted 10 lines

I tried this series with v14 kernel driver, while getting some error on using
this. Not sure this is my error configuration.

The qemu command line is:

    -object
    memory-backend-file,id=mem1,share=on,mem-path=/dev/dax0.0,size=1G,align=2M
    -device virtio-pmem-pci,memdev=mem1,id=nv1

Are you using host backing on real NVDIMM? Currently, we only support backing image
file on regular SSD. We have plans to support backing file on real NVDIMM device
as well but this is part of future work.

Quoted 4 lines

Can you please try by allocating a raw image file on regular SSD. It is working fine
for me.

I created a file with 2G on my disk.

#ll -h 2G-file
-rw-r--r-- 1 richard richard 2.0G 6月 26 09:26 2G-file

The command line is changed to:

-object memory-backend-file,id=mem1,share,mem-path=/home/richard/guest/2G-file,size=2G -device virtio-pmem-pci,memdev=mem1,id=nv1

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

The behavior in guest is the same.

Are you still facing an error with this? or its working fine for you?

I can partition and mkfs with /dev/pmem0 after I use the SSD backend.

Good to know. Thanks for the confirmation.

Quoted 53 lines
Quoted 9 lines
Quoted 5 lines

I took a look into the directory /sys/bus/nd/device. These files are listed.
Compared with normal system, one device file is missed.

virtio pmem does not support namespace/region mappings which ACPI NFIT supports.

Ok, thanks.

Quoted 41 lines
Quoted 23 lines

btt0.0 dax0.0 namespace0.0 ndbus0 pfn0.0 region0

But the sysfs shows pmem0 block device is created.

/sys/devices/pci0000:00/0000:00:04.0/virtio0/ndbus0/region0/namespace0.0/block/pmem0

Then I took a look into the pci device:

# lspci -vs 00:04.0
00:04.0 Unclassified device [00ff]: Red Hat, Inc. Device 1013
        Subsystem: Red Hat, Inc. Device 001b
        Physical Slot: 4
        Flags: bus master, fast devsel, latency 0, IRQ 11
        I/O ports at c040 [size=64]
        Memory at fe000000 (64-bit, prefetchable) [size=16K]
        Capabilities: [84] Vendor Specific Information: VirtIO:
        Capabilities: [70] Vendor Specific Information: VirtIO: Notify
        Capabilities: [60] Vendor Specific Information: VirtIO: DeviceCfg
        Capabilities: [50] Vendor Specific Information: VirtIO: ISR
        Capabilities: [40] Vendor Specific Information: VirtIO: CommonCfg
        Kernel driver in use: virtio-pci
Quoted 1 line

This looks good.

Good to know.

Quoted 14 lines
Quoted 13 lines
Quoted 11 lines

The guest boots up and I can see /dev/pmem0 device. But when I want to partition this device, I got the error:

    # parted /dev/pmem0 mklabel gpt
    Warning: Error fsyncing/closing /dev/pmem0: Input/output error

Also I see an error when running "ndctl list":

libndctl: __sysfs_device_parse: ndctl0: add_dev() failed

Will look at this if it is related.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

This log still there.

It looks to me libndctl needs to be taught about about virtio pmem data parsing. But this is unrelated to kernel and qemu patch series.

Ok, if it works, we could list those regions? and change pmem0 mode to dax mode, right?

You mean fs dax?
I don't think currently we support this because raw image wont have any metadata. Will have to think if this is at all possible or how we can achieve such behavior.

Also, there is requirement to support host backing file on real NVDIMM and virtio. Once we have have first version of virtio pmem series merged upstream we will continue to work on advance features depending upon feasibility.

Thanks,
Pankaj

Quoted 127 lines
Quoted 116 lines
Quoted 116 lines
Quoted 115 lines

Thanks,
Pankaj

Quoted 110 lines

Would you mind letting me know which part I am wrong?

Quoted 93 lines

(qemu) info memory-devices
Memory device [virtio-pmem]: "nv1"
memaddr: 0x240000000
size: 4294967296
memdev: /objects/mem1

Implementation is divided into two parts:
New virtio pmem guest driver and qemu code changes for new virtio pmem paravirtualized device. In this series we are sharing Qemu device emulation.

1. Guest virtio-pmem kernel driver
---------------------------------
- Reads persistent memory range from paravirt device and registers with 'nvdimm_bus'.
- 'nvdimm/pmem' driver uses this information to allocate persistent memory region and setup filesystem operations to the allocated memory.
- virtio pmem driver implements asynchronous flushing interface to flush from guest to host.

2. Qemu virtio-pmem device
---------------------------------
- Creates virtio pmem device and exposes a memory range to KVM guest.
- At host side this is file backed memory which acts as persistent memory.
- Qemu side flush uses aio thread pool API's and virtio for asynchronous guest multi request handling.

Virtio-pmem security implications and suggested countermeasures:
---------------------------------------------------------------

In previous posting of kernel driver, there was discussion [7] on possible implications of page cache side channel attacks with virtio pmem. After thorough analysis of details of known side channel attacks, below are the suggestions:

- Depends entirely on how host backing image file is mapped into guest address space.

- virtio-pmem device emulation, by default shared mapping is used to map host backing file. It is recommended to use separate backing file at host side for every guest. This will prevent any possibility of executing common code from multiple guests and any chance of inferring guest local data based based on execution time.

- If backing file is required to be shared among multiple guests it is recommended to don't support host page cache eviction commands from the guest driver. This will avoid any possibility of inferring guest local data or host data from another guest.

- Proposed device specification [6] for virtio-pmem device with details of possible security implications and suggested countermeasures for device emulation.

Changes from PATCH v1:
- Change proposed version from qemu 4.0 to 4.1 - Eric
- Remove virtio queue_add from unrealize function - Cornelia

[1] https://lkml.org/lkml/2019/6/12/624
[2] https://www.spinics.net/lists/kvm/msg149761.html
[3] https://www.spinics.net/lists/kvm/msg153095.html
[4] https://marc.info/?l=linux-kernel&m=153572228719237&w=2
[5] https://marc.info/?l=qemu-devel&m=153555721901824&w=2
[6]
https://lists.oasis-open.org/archives/virtio-dev/201903/msg00083.html
[7] https://lkml.org/lkml/2019/1/9/1191

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: proxy for virtio-pmem

David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

hmp.c                                        |   27 ++-
hw/i386/Kconfig                              |    1
hw/i386/pc.c                                 |   72 ++++++++++
hw/virtio/Kconfig                            |   10 +
hw/virtio/Makefile.objs                      |    2
hw/virtio/virtio-pci.c                       |    1
hw/virtio/virtio-pci.h                       |    1
hw/virtio/virtio-pmem-pci.c                  |  131

++++++++++++++++++
hw/virtio/virtio-pmem-pci.h | 34 ++++
hw/virtio/virtio-pmem.c | 189
+++++++++++++++++++++++++++

Quoted 8 lines
include/hw/pci/pci.h                         |    1
include/hw/virtio/virtio-pmem.h              |   49 +++++++
include/standard-headers/linux/virtio_ids.h  |    1
include/standard-headers/linux/virtio_pmem.h |   35 +++++
numa.c                                       |   24 +--
qapi/misc.json                               |   28 +++-
16 files changed, 580 insertions(+), 26 deletions(-)

----

--
Wei Yang
Help you, Help me

Quoted 5 lines
Quoted 5 lines

--
Wei Yang
Help you, Help me

--
Wei Yang
Help you, Help me

#33 lore raw
Quoted 10 lines · Pankaj Gupta
Quoted 5 lines

Ok, if it works, we could list those regions? and change pmem0 mode to dax mode, right?

You mean fs dax?
I don't think currently we support this because raw image wont have any metadata. Will have to think if this is at all possible or how we can achieve such behavior.

Ok, I got it.

Quoted 4 lines

Also, there is requirement to support host backing file on real NVDIMM and virtio. Once we have have first version of virtio pmem series merged upstream we will continue to work on advance features depending upon feasibility.

One curiosity, what difference make NVDIMM backend doesn't work now?

The /dev/dax0.0 is a char file. The nvdimm device use mmap to map HVA to HPA. It looks a normal file to me. Would appreciated it if you would share some light on it.

Quoted 4 lines

Thanks,
Pankaj

Signature · 2 lines
Wei Yang
Help you, Help me
#34 lore raw
Quoted 21 lines
Quoted 12 lines
Quoted 5 lines

Ok, if it works, we could list those regions? and change pmem0 mode to dax mode, right?

You mean fs dax?
I don't think currently we support this because raw image wont have any metadata.
Will have to think if this is at all possible or how we can achieve such behavior.

Ok, I got it.

Quoted 5 lines

Also, there is requirement to support host backing file on real NVDIMM and virtio. Once we have have first version of virtio pmem series merged upstream
we will continue to work on advance features depending upon feasibility.

Quoted 6 lines

One curiosity, what difference make NVDIMM backend doesn't work now?

The /dev/dax0.0 is a char file. The nvdimm device use mmap to map HVA to HPA. It looks a normal file to me. Would appreciated it if you would share some light on it.

It will require support of MAP_SYNC at host side without an explicit flush/fsync. We need to add the usecase in both guest and host drivers/device. Also, thorough testing is required to fix any issues.

I will do the required changes for the next step.

Thanks,
Pankaj

#35 lore raw

[Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

The following changes since commit 7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

----------------------------------------------------------------
David Hildenbrand (4):
virtio-pci: Allow to specify additional interfaces for the base type
hmp: Handle virtio-pmem when printing memory device infos
numa: Handle virtio-pmem in NUMA stats
pc: Support for virtio-pmem-pci

Eduardo Habkost (1):
pc: Move compat_apic_id_mode variable to PCMachineClass

Marc-André Lureau (1):
virtio-pci: fix missing device properties

Michael S. Tsirkin (4):
pcie: don't skip multi-mask events
pcie: check that slt ctrl changed before deleting
pcie: work around for racy guest init
pcie: minor cleanups for slot control/status

Pankaj Gupta (3):
virtio-pmem: add virtio device
virtio-pmem: sync linux headers
virtio-pci: Proxy for virtio-pmem

Stefan Hajnoczi (4):
libvhost-user: add vmsg_set_reply_u64() helper
libvhost-user: support many virtqueues
libvhost-user: implement VHOST_USER_PROTOCOL_F_MQ
docs: avoid vhost-user-net specifics in multiqueue section

Xie Yongji (5):
virtio: add "use-started" property
virtio: Set "start_on_kick" for legacy devices
virtio: Set "start_on_kick" on virtio_set_features()
virtio: Make sure we get correct state of device on handle_aio_output()
virtio: Don't change "started" flag on virtio_vmstate_change()

 qapi/misc.json                               |  28 +++-
 contrib/libvhost-user/libvhost-user-glib.h   |   2 +-
 contrib/libvhost-user/libvhost-user.h        |  10 +-
 hw/virtio/virtio-pci.h                       |   1 +
 hw/virtio/virtio-pmem-pci.h                  |  34 +++++
 include/hw/i386/pc.h                         |   3 +
 include/hw/pci/pci.h                         |   1 +
 include/hw/pci/pcie.h                        |   2 +
 include/hw/virtio/virtio-pmem.h              |  49 +++++++
 include/hw/virtio/virtio.h                   |  23 +++-
 include/standard-headers/linux/virtio_ids.h  |   1 +
 include/standard-headers/linux/virtio_pmem.h |  35 +++++
 contrib/libvhost-user/libvhost-user-glib.c   |  12 +-
 contrib/libvhost-user/libvhost-user.c        |  66 ++++++----
 contrib/vhost-user-blk/vhost-user-blk.c      |  16 ++-
 contrib/vhost-user-gpu/main.c                |   9 +-
 contrib/vhost-user-input/main.c              |  11 +-
 contrib/vhost-user-scsi/vhost-user-scsi.c    |  21 ++-
 hw/block/vhost-user-blk.c                    |   4 +-
 hw/core/machine.c                            |   1 +
 hw/i386/pc.c                                 |  94 +++++++++++--
 hw/i386/pc_piix.c                            |   3 +-
 hw/pci-bridge/pcie_root_port.c               |   5 +-
 hw/pci-bridge/xio3130_downstream.c           |   5 +-
 hw/pci/pcie.c                                |  40 +++++-
 hw/virtio/virtio-pci.c                       |  29 ++--
 hw/virtio/virtio-pmem-pci.c                  | 131 +++++++++++++++++++
 hw/virtio/virtio-pmem.c                      | 189 +++++++++++++++++++++++++++
 hw/virtio/virtio.c                           |  53 ++++----
 monitor/hmp-cmds.c                           |  27 ++--
 numa.c                                       |  24 ++--
 tests/vhost-user-bridge.c                    |  42 ++++--
 docs/interop/vhost-user.rst                  |  21 +--
 hw/i386/Kconfig                              |   1 +
 hw/virtio/Kconfig                            |  10 ++
 hw/virtio/Makefile.objs                      |   2 +
 36 files changed, 844 insertions(+), 161 deletions(-)
 create mode 100644 hw/virtio/virtio-pmem-pci.h
 create mode 100644 include/hw/virtio/virtio-pmem.h
 create mode 100644 include/standard-headers/linux/virtio_pmem.h
 create mode 100644 hw/virtio/virtio-pmem-pci.c
 create mode 100644 hw/virtio/virtio-pmem.c
#36 lore raw

[Qemu-devel] [PULL 02/22] pcie: check that slt ctrl changed before deleting

During boot, linux would sometimes overwrites control of a powered off slot before powering it on. Unfortunately QEMU interprets that as a power off request and ejects the device.

For example:

/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -S -machine q35 \
-device pcie-root-port,id=pcie_root_port_0,slot=2,chassis=2,addr=0x2,bus=pcie.0 \
-monitor stdio disk.qcow2
(qemu)device_add virtio-balloon-pci,id=balloon,bus=pcie_root_port_0 (qemu)cont

Balloon is deleted during guest boot.

To fix, save control beforehand and check that power or led state actually change before ejecting.

Note: this is more a hack than a solution, ideally we'd find a better way to detect ejects, or move away from ejects completely and instead monitor whether it's safe to delete device due to e.g. its power state.

---
 include/hw/pci/pcie.h              |  3 ++-
 hw/pci-bridge/pcie_root_port.c     |  5 ++++-
 hw/pci-bridge/xio3130_downstream.c |  5 ++++-
 hw/pci/pcie.c                      | 14 ++++++++++++--
 4 files changed, 22 insertions(+), 5 deletions(-)
include/hw/pci/pcie.h +2 -1
index e30334d74d..8d90c0e193 100644
@@ -107,7 +107,8 @@ void pcie_cap_lnkctl_reset(PCIDevice *dev);
 
 void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot);
 void pcie_cap_slot_reset(PCIDevice *dev);
-void pcie_cap_slot_write_config(PCIDevice *dev,
+void pcie_cap_slot_get(PCIDevice *dev, uint16_t *slot_ctl, uint16_t *slt_sta);
+void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t slot_ctl, uint16_t slt_sta,
                                 uint32_t addr, uint32_t val, int len);
 int pcie_cap_slot_post_load(void *opaque, int version_id);
 void pcie_cap_slot_push_attention_button(PCIDevice *dev);
hw/pci-bridge/pcie_root_port.c +4 -1
index 92f253c924..09019ca05d 100644
@@ -31,10 +31,13 @@ static void rp_write_config(PCIDevice *d, uint32_t address,
 {
     uint32_t root_cmd =
         pci_get_long(d->config + d->exp.aer_cap + PCI_ERR_ROOT_COMMAND);
+    uint16_t slt_ctl, slt_sta;
+
+    pcie_cap_slot_get(d, &slt_ctl, &slt_sta);
 
     pci_bridge_write_config(d, address, val, len);
     rp_aer_vector_update(d);
-    pcie_cap_slot_write_config(d, address, val, len);
+    pcie_cap_slot_write_config(d, slt_ctl, slt_sta, address, val, len);
     pcie_aer_write_config(d, address, val, len);
     pcie_aer_root_write_config(d, address, val, len, root_cmd);
 }
hw/pci-bridge/xio3130_downstream.c +4 -1
index 264e37d6a6..899b0fd6c9 100644
@@ -41,9 +41,12 @@
 static void xio3130_downstream_write_config(PCIDevice *d, uint32_t address,
                                          uint32_t val, int len)
 {
+    uint16_t slt_ctl, slt_sta;
+
+    pcie_cap_slot_get(d, &slt_sta, &slt_ctl);
     pci_bridge_write_config(d, address, val, len);
     pcie_cap_flr_write_config(d, address, val, len);
-    pcie_cap_slot_write_config(d, address, val, len);
+    pcie_cap_slot_write_config(d, slt_ctl, slt_sta, address, val, len);
     pcie_aer_write_config(d, address, val, len);
 }
 
hw/pci/pcie.c +12 -2
index b22527000d..f8490a00de 100644
@@ -594,7 +594,15 @@ void pcie_cap_slot_reset(PCIDevice *dev)
     hotplug_event_update_event_status(dev);
 }
 
-void pcie_cap_slot_write_config(PCIDevice *dev,
+void pcie_cap_slot_get(PCIDevice *dev, uint16_t *slt_ctl, uint16_t *slt_sta)
+{
+    uint32_t pos = dev->exp.exp_cap;
+    uint8_t *exp_cap = dev->config + pos;
+    *slt_ctl = pci_get_word(exp_cap + PCI_EXP_SLTCTL);
+    *slt_sta = pci_get_word(exp_cap + PCI_EXP_SLTSTA);
+}
+
+void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t slt_ctl, uint16_t slt_sta,
                                 uint32_t addr, uint32_t val, int len)
 {
     uint32_t pos = dev->exp.exp_cap;
@@ -623,7 +631,9 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
      * controller is off, it is safe to detach the devices.
      */
     if ((sltsta & PCI_EXP_SLTSTA_PDS) && (val & PCI_EXP_SLTCTL_PCC) &&
-        ((val & PCI_EXP_SLTCTL_PIC_OFF) == PCI_EXP_SLTCTL_PIC_OFF)) {
+        (val & PCI_EXP_SLTCTL_PIC_OFF) == PCI_EXP_SLTCTL_PIC_OFF &&
+        (!(slt_ctl & PCI_EXP_SLTCTL_PCC) ||
+        (slt_ctl & PCI_EXP_SLTCTL_PIC_OFF) != PCI_EXP_SLTCTL_PIC_OFF)) {
         PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(dev));
         pci_for_each_device(sec_bus, pci_bus_num(sec_bus),
                             pcie_unplug_device, NULL);
Signature · 1 line
MST
#37 lore raw

Re: [Qemu-devel] [PULL 02/22] pcie: check that slt ctrl changed before deleting

Quoted 23 lines · Michael S. Tsirkin

During boot, linux would sometimes overwrites control of a powered off slot before powering it on. Unfortunately QEMU interprets that as a power off request and ejects the device.

For example:

/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -S -machine q35 \
-device pcie-root-port,id=pcie_root_port_0,slot=2,chassis=2,addr=0x2,bus=pcie.0 \
-monitor stdio disk.qcow2
(qemu)device_add virtio-balloon-pci,id=balloon,bus=pcie_root_port_0 (qemu)cont

Balloon is deleted during guest boot.

To fix, save control beforehand and check that power or led state actually change before ejecting.

Note: this is more a hack than a solution, ideally we'd find a better way to detect ejects, or move away from ejects completely and instead monitor whether it's safe to delete device due to e.g. its power state.

Quoted 4 lines

Hi; Coverity points out (CID 1403007) that...

include/hw/pci/pcie.h void pcie_cap_lnkctl_reset(PCIDevice *dev); · line 110

Quoted 10 lines
include/hw/pci/pcie.h +1 -1
index e30334d74d..8d90c0e193 100644
@@ -107,7 +107,8 @@ void pcie_cap_lnkctl_reset(PCIDevice *dev);
 
 void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot);
 void pcie_cap_slot_reset(PCIDevice *dev);
-void pcie_cap_slot_write_config(PCIDevice *dev,
+void pcie_cap_slot_get(PCIDevice *dev, uint16_t *slot_ctl, uint16_t *slt_sta);

...in the declaration of pci_cap_slot_get() the last 2 arguments are slot_ctl then slt_sta...

hw/pci-bridge/pcie_root_port.c static void rp_write_config(PCIDevice *d, uint32_t address, · line 36

Quoted 9 lines
hw/pci-bridge/pcie_root_port.c +3 -0
@@ -31,10 +31,13 @@ static void rp_write_config(PCIDevice *d, uint32_t address,
 {
     uint32_t root_cmd =
         pci_get_long(d->config + d->exp.aer_cap + PCI_ERR_ROOT_COMMAND);
+    uint16_t slt_ctl, slt_sta;
+
+    pcie_cap_slot_get(d, &slt_ctl, &slt_sta);

...which is the order we use here...

Quoted 13 lines
hw/pci-bridge/pcie_root_port.c +1 -1
     pci_bridge_write_config(d, address, val, len);
     rp_aer_vector_update(d);
-    pcie_cap_slot_write_config(d, address, val, len);
+    pcie_cap_slot_write_config(d, slt_ctl, slt_sta, address, val, len);
     pcie_aer_write_config(d, address, val, len);
     pcie_aer_root_write_config(d, address, val, len, root_cmd);
 }
hw/pci-bridge/xio3130_downstream.c +0 -0
index 264e37d6a6..899b0fd6c9 100644

hw/pci-bridge/xio3130_downstream.c line 46

Quoted 6 lines
hw/pci-bridge/xio3130_downstream.c +3 -0
@@ -41,9 +41,12 @@
 static void xio3130_downstream_write_config(PCIDevice *d, uint32_t address,
                                          uint32_t val, int len)
 {
+    uint16_t slt_ctl, slt_sta;
+
+    pcie_cap_slot_get(d, &slt_sta, &slt_ctl);

...but in this callsite we pass slt_sta, slt_ctl.

Presumably this is a bug?

Also, but more trivially, the function declarations for pci_cap_slot_get and pci_cap_slot_write_config call the argument "slot_ctl", but the function definitions and all the call sites drop the 'o' and call it "slt_ctl". Could we be consistent?

thanks
-- PMM

#38 lore raw

[Qemu-devel] [PULL 01/22] pcie: don't skip multi-mask events

In reply to Michael S. Tsirkin

If we are trying to set multiple bits at once, testing that just one of them is already set gives a false positive. As a result we won't interrupt guest if e.g. presence detection change and attention button press are both set. This happens with multi-function device removal.

---
 hw/pci/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci/pcie.c +1 -1
index 88c30ff74c..b22527000d 100644
@@ -383,7 +383,7 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event)
 {
     /* Minor optimization: if nothing changed - no event is needed. */
     if (pci_word_test_and_set_mask(dev->config + dev->exp.exp_cap +
-                                   PCI_EXP_SLTSTA, event)) {
+                                   PCI_EXP_SLTSTA, event) == event) {
         return;
     }
     hotplug_event_notify(dev);
Signature · 1 line
MST
#39 lore raw

[Qemu-devel] [PULL 04/22] pcie: minor cleanups for slot control/status

In reply to Michael S. Tsirkin

Rename function arguments to make intent clearer. Better documentation for slot control logic.

---
 include/hw/pci/pcie.h |  3 ++-
 hw/pci/pcie.c         | 17 +++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)
include/hw/pci/pcie.h +2 -1
index 8d90c0e193..34f277735c 100644
@@ -108,7 +108,8 @@ void pcie_cap_lnkctl_reset(PCIDevice *dev);
 void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot);
 void pcie_cap_slot_reset(PCIDevice *dev);
 void pcie_cap_slot_get(PCIDevice *dev, uint16_t *slot_ctl, uint16_t *slt_sta);
-void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t slot_ctl, uint16_t slt_sta,
+void pcie_cap_slot_write_config(PCIDevice *dev,
+                                uint16_t old_slot_ctl, uint16_t old_slt_sta,
                                 uint32_t addr, uint32_t val, int len);
 int pcie_cap_slot_post_load(void *opaque, int version_id);
 void pcie_cap_slot_push_attention_button(PCIDevice *dev);
hw/pci/pcie.c +11 -6
index c605d32dd4..a6beb567bd 100644
@@ -602,7 +602,8 @@ void pcie_cap_slot_get(PCIDevice *dev, uint16_t *slt_ctl, uint16_t *slt_sta)
     *slt_sta = pci_get_word(exp_cap + PCI_EXP_SLTSTA);
 }
 
-void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t slt_ctl, uint16_t slt_sta,
+void pcie_cap_slot_write_config(PCIDevice *dev,
+                                uint16_t old_slt_ctl, uint16_t old_slt_sta,
                                 uint32_t addr, uint32_t val, int len)
 {
     uint32_t pos = dev->exp.exp_cap;
@@ -625,8 +626,8 @@ void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t slt_ctl, uint16_t slt_s
                           PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC | \
                           PCI_EXP_SLTSTA_CC)
 
-        if (val & ~slt_sta & PCIE_SLOT_EVENTS) {
-            sltsta = (sltsta & ~PCIE_SLOT_EVENTS) | (slt_sta & PCIE_SLOT_EVENTS);
+        if (val & ~old_slt_sta & PCIE_SLOT_EVENTS) {
+            sltsta = (sltsta & ~PCIE_SLOT_EVENTS) | (old_slt_sta & PCIE_SLOT_EVENTS);
             pci_set_word(exp_cap + PCI_EXP_SLTSTA, sltsta);
         }
         hotplug_event_clear(dev);
@@ -646,13 +647,17 @@ void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t slt_ctl, uint16_t slt_s
     }
 
     /*
-     * If the slot is polulated, power indicator is off and power
+     * If the slot is populated, power indicator is off and power
      * controller is off, it is safe to detach the devices.
+     *
+     * Note: don't detach if condition was already true:
+     * this is a work around for guests that overwrite
+     * control of powered off slots before powering them on.
      */
     if ((sltsta & PCI_EXP_SLTSTA_PDS) && (val & PCI_EXP_SLTCTL_PCC) &&
         (val & PCI_EXP_SLTCTL_PIC_OFF) == PCI_EXP_SLTCTL_PIC_OFF &&
-        (!(slt_ctl & PCI_EXP_SLTCTL_PCC) ||
-        (slt_ctl & PCI_EXP_SLTCTL_PIC_OFF) != PCI_EXP_SLTCTL_PIC_OFF)) {
+        (!(old_slt_ctl & PCI_EXP_SLTCTL_PCC) ||
+        (old_slt_ctl & PCI_EXP_SLTCTL_PIC_OFF) != PCI_EXP_SLTCTL_PIC_OFF)) {
         PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(dev));
         pci_for_each_device(sec_bus, pci_bus_num(sec_bus),
                             pcie_unplug_device, NULL);
Signature · 1 line
MST
#40 lore raw

[Qemu-devel] [PULL 03/22] pcie: work around for racy guest init

In reply to Michael S. Tsirkin

During boot, linux guests tend to clear all bits in pcie slot status register which is used for hotplug.
If they clear bits that weren't set this is racy and will lose events:
not a big problem for manual hotplug on bare-metal, but a problem for us.

For example, the following is broken ATM:

/x86_64-softmmu/qemu-system-x86_64 -enable-kvm -S -machine q35  \
    -device pcie-root-port,id=pcie_root_port_0,slot=2,chassis=2,addr=0x2,bus=pcie.0 \
    -device virtio-balloon-pci,id=balloon,bus=pcie_root_port_0 \
    -monitor stdio disk.qcow2

(qemu)device_del balloon
(qemu)cont

Balloon isn't deleted as it should.

As a work-around, detect this attempt to clear slot status and revert status to what it was before the write.

Note: in theory this can be detected as a duplicate button press which cancels the previous press. Does not seem to happen in practice as guests seem to only have this bug during init.

Note2: the right thing to do is probably to fix Linux to read status before clearing it, and act on the bits that are set.

---
 hw/pci/pcie.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
hw/pci/pcie.c +19 -0
index f8490a00de..c605d32dd4 100644
@@ -610,6 +610,25 @@ void pcie_cap_slot_write_config(PCIDevice *dev, uint16_t slt_ctl, uint16_t slt_s
     uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA);
 
     if (ranges_overlap(addr, len, pos + PCI_EXP_SLTSTA, 2)) {
+        /*
+         * Guests tend to clears all bits during init.
+         * If they clear bits that weren't set this is racy and will lose events:
+         * not a big problem for manual button presses, but a problem for us.
+         * As a work-around, detect this and revert status to what it was
+         * before the write.
+         *
+         * Note: in theory this can be detected as a duplicate button press
+         * which cancels the previous press. Does not seem to happen in
+         * practice as guests seem to only have this bug during init.
+         */
+#define PCIE_SLOT_EVENTS (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | \
+                          PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC | \
+                          PCI_EXP_SLTSTA_CC)
+
+        if (val & ~slt_sta & PCIE_SLOT_EVENTS) {
+            sltsta = (sltsta & ~PCIE_SLOT_EVENTS) | (slt_sta & PCIE_SLOT_EVENTS);
+            pci_set_word(exp_cap + PCI_EXP_SLTSTA, sltsta);
+        }
         hotplug_event_clear(dev);
     }
 
Signature · 1 line
MST
#41 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

In reply to Michael S. Tsirkin
Quoted 20 lines · Michael S. Tsirkin

The following changes since commit 7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

Quoted 5 lines

Pankaj Gupta (3):
virtio-pmem: sync linux headers

Hi. This header sync doesn't look like it was a proper sync made with the update-headers script against some upstream kernel -- at least the commit message doesn't say what the sync was against and the fact that it only changes the virtio-pmem headers looks suspicious.

Can you respin with a proper header sync against upstream mainline, please?

thanks
-- PMM

#42 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 33 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin

The following changes since commit 7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

Quoted 5 lines

Pankaj Gupta (3):
virtio-pmem: sync linux headers

Hi. This header sync doesn't look like it was a proper sync made with the update-headers script against some upstream kernel -- at least the commit message doesn't say what the sync was against and the fact that it only changes the virtio-pmem headers looks suspicious.

Quoted 5 lines

Can you respin with a proper header sync against upstream mainline, please?

thanks
-- PMM

This isn't from mainline. We have a bit of a deadlock with linux merge window opening soon. I think it's reasonable temporarily and then before release either virtio-pmem gets there or I will revert it and drop the header.

Updated the commit and re-pushed.

But if you disagree pls let me know.

Signature · 1 line
MST
#43 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · Peter Maydell

On Tue, 2 Jul 2019 at 16:06, Michael S. Tsirkin <[email protected]> wrote:
Hi. This header sync doesn't look like it was a proper
sync made with the update-headers script against some upstream kernel -- at least the commit message doesn't
say what the sync was against and the fact that it only changes the virtio-pmem headers looks suspicious.

Quoted 7 lines
Quoted 2 lines

Can you respin with a proper header sync against upstream mainline, please?

This isn't from mainline. We have a bit of a deadlock with linux merge window opening soon. I think it's reasonable temporarily and then before release either virtio-pmem gets there or I will revert it and drop the header.

It's definitely not ideal: until the headers are actually upstream there's no guarantee that they won't change ABI. Are the headers at least in some kvm-next or equivalent tree ? When are they expected to hit mainline?

thanks
-- PMM

#44 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 13 lines · Peter Maydell
Quoted 11 lines · Michael S. Tsirkin
Quoted 9 lines · Peter Maydell

On Tue, 2 Jul 2019 at 16:06, Michael S. Tsirkin <[email protected]> wrote:
Hi. This header sync doesn't look like it was a proper
sync made with the update-headers script against some upstream kernel -- at least the commit message doesn't
say what the sync was against and the fact that it only changes the virtio-pmem headers looks suspicious.

Can you respin with a proper header sync against upstream mainline, please?

Quoted 7 lines
Quoted 4 lines

This isn't from mainline. We have a bit of a deadlock with linux merge window opening soon. I think it's reasonable temporarily and then before release either virtio-pmem gets there or I will revert it and drop the header.

It's definitely not ideal: until the headers are actually upstream there's no guarantee that they won't change ABI.

But then I'm watching it, if I see that I'll drop the device from qemu for now.

Quoted 1 line

Are the headers at least in some kvm-next or equivalent tree ?

Yes - libnvdimm maintainer's tree.

Quoted 1 line

When are they expected to hit mainline?

Next merge window.

Quoted 3 lines

thanks
-- PMM

#45 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 8 lines · Michael S. Tsirkin
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Michael S. Tsirkin

This isn't from mainline. We have a bit of a deadlock with linux merge window opening soon. I think it's reasonable temporarily and then before release either virtio-pmem gets there or I will revert it and drop the header.

Quoted 5 lines
Quoted 2 lines

It's definitely not ideal: until the headers are actually upstream there's no guarantee that they won't change ABI.

But then I'm watching it, if I see that I'll drop the device from qemu for now.

OK; I guess we can take this for now if we make sure we revert if the headers aren't upstream by the time we get to say rc2 (23rd July). (That is, we'd want to do any revert shortly after rc2, since rc3 might be the last rc before release.)

Quoted 8 lines
Quoted 1 line

Are the headers at least in some kvm-next or equivalent tree ?

Yes - libnvdimm maintainer's tree.

Quoted 1 line

When are they expected to hit mainline?

Next merge window.

When's that?

thanks
-- PMM

#46 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 12 lines · Peter Maydell
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Peter Maydell
Quoted 4 lines · Michael S. Tsirkin

This isn't from mainline. We have a bit of a deadlock with linux merge window opening soon. I think it's reasonable temporarily and then before release either virtio-pmem gets there or I will revert it and drop the header.

It's definitely not ideal: until the headers are actually upstream there's no guarantee that they won't change ABI.

Quoted 7 lines
Quoted 2 lines

But then I'm watching it, if I see that I'll drop the device from qemu for now.

OK; I guess we can take this for now if we make sure we revert if the headers aren't upstream by the time we get to say rc2 (23rd July). (That is, we'd want to do any revert shortly after rc2, since rc3 might be the last rc before release.)

Right, that's the plan.

Quoted 10 lines
Quoted 8 lines
Quoted 1 line

Are the headers at least in some kvm-next or equivalent tree ?

Yes - libnvdimm maintainer's tree.

Quoted 1 line

When are they expected to hit mainline?

Next merge window.

When's that?

Likely opens next Sunday and lasts 2 weeks. So we'll know by July 23.

Quoted 2 lines

thanks
-- PMM

#47 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

In reply to Peter Maydell
Quoted 13 lines · Peter Maydell
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Peter Maydell
Quoted 4 lines · Michael S. Tsirkin

This isn't from mainline. We have a bit of a deadlock with linux merge window opening soon. I think it's reasonable temporarily and then before release either virtio-pmem gets there or I will revert it and drop the header.

It's definitely not ideal: until the headers are actually upstream there's no guarantee that they won't change ABI.

Quoted 7 lines
Quoted 2 lines

But then I'm watching it, if I see that I'll drop the device from qemu for now.

OK; I guess we can take this for now if we make sure we revert if the headers aren't upstream by the time we get to say rc2 (23rd July). (That is, we'd want to do any revert shortly after rc2, since rc3 might be the last rc before release.)

Ping for status update -- have the headers hit the mainline kernel yet? Do they match the versions we put into QEMU?

thanks
-- PMM

#48 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 22 lines · Peter Maydell
Quoted 13 lines · Peter Maydell
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Peter Maydell
Quoted 4 lines · Michael S. Tsirkin

This isn't from mainline. We have a bit of a deadlock with linux merge window opening soon. I think it's reasonable temporarily and then before release either virtio-pmem gets there or I will revert it and drop the header.

It's definitely not ideal: until the headers are actually upstream there's no guarantee that they won't change ABI.

Quoted 7 lines
Quoted 2 lines

But then I'm watching it, if I see that I'll drop the device from qemu for now.

OK; I guess we can take this for now if we make sure we revert if the headers aren't upstream by the time we get to say rc2 (23rd July). (That is, we'd want to do any revert shortly after rc2, since rc3 might be the last rc before release.)

Quoted 5 lines

Ping for status update -- have the headers hit the mainline kernel yet? Do they match the versions we put into QEMU?

thanks
-- PMM

Yes they do: here's the diff:

include/standard-headers/linux/virtio_pmem.h +2 -2
index 7e3d43b121..c5f610ed6b 100644
@@ -7,8 +7,8 @@
  * Author(s): Pankaj Gupta <[email protected]>
  */
 
-#ifndef _UAPI_LINUX_VIRTIO_PMEM_H
-#define _UAPI_LINUX_VIRTIO_PMEM_H
+#ifndef _LINUX_VIRTIO_PMEM_H
+#define _LINUX_VIRTIO_PMEM_H
 
 #include "standard-headers/linux/types.h"
 #include "standard-headers/linux/virtio_ids.h"

Didn't decide whether I want to update it now or after the pull, but it shouldn't matter. If you want to do an update now, go ahead.

Signature · 1 line
MST
#49 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

In reply to Michael S. Tsirkin
Quoted 13 lines · Michael S. Tsirkin

The following changes since commit 7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

Quoted 9 lines

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

This fails to build on all the non-Linux platforms:

In file included from /Users/pm215/src/qemu-for-merges/hw/virtio/virtio-pmem.c:21:
/Users/pm215/src/qemu-for-merges/include/standard-headers/linux/virtio_pmem.h:13:10:
fatal error: 'linux/types.h' file not found

#include <linux/types.h>
         ^~~~~~~~~~~~~~~

thanks
-- PMM

#50 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 28 lines
Quoted 18 lines

The following changes since commit
7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

Quoted 9 lines

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

Quoted 8 lines

This fails to build on all the non-Linux platforms:

In file included from /Users/pm215/src/qemu-for-merges/hw/virtio/virtio-pmem.c:21:
/Users/pm215/src/qemu-for-merges/include/standard-headers/linux/virtio_pmem.h:13:10:
fatal error: 'linux/types.h' file not found

#include <linux/types.h>
         ^~~~~~~~~~~~~~~

Sorry for this.
Can we please apply below patch on top. I only tested this in linux but I think this will solve the issue. Let me know if you want to resend entire series.

Thank you,
Pankaj

===================

From: Pankaj Gupta <[email protected]>
Date: Thu, 4 Jul 2019 16:27:08 +0530
Subject: [PATCH] Sync header and fix non linux build issue

---
 include/standard-headers/linux/virtio_pmem.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
include/standard-headers/linux/virtio_pmem.h +5 -6
index 7a3e2fe524..a60236f63d 100644
@@ -10,14 +10,13 @@
 #ifndef _UAPI_LINUX_VIRTIO_PMEM_H
 #define _UAPI_LINUX_VIRTIO_PMEM_H
 
-#include <linux/types.h>
-#include <linux/virtio_types.h>
-#include <linux/virtio_ids.h>
-#include <linux/virtio_config.h>
+#include "standard-headers/linux/virtio_types.h"
+#include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_config.h"
 
 struct virtio_pmem_config {
-       __le64 start;
-       __le64 size;
+       uint64_t start;
+       uint64_t size;
 };
 
 #define VIRTIO_PMEM_REQ_TYPE_FLUSH      0
#51 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 70 lines · Pankaj Gupta
Quoted 28 lines
Quoted 18 lines

The following changes since commit
7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

Quoted 9 lines

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

Quoted 8 lines

This fails to build on all the non-Linux platforms:

In file included from /Users/pm215/src/qemu-for-merges/hw/virtio/virtio-pmem.c:21:
/Users/pm215/src/qemu-for-merges/include/standard-headers/linux/virtio_pmem.h:13:10:
fatal error: 'linux/types.h' file not found

#include <linux/types.h>
         ^~~~~~~~~~~~~~~

Sorry for this.
Can we please apply below patch on top. I only tested this in linux but I think this will solve the issue. Let me know if you want to resend entire series.

Thank you,
Pankaj

===================

From: Pankaj Gupta <[email protected]>
Date: Thu, 4 Jul 2019 16:27:08 +0530
Subject: [PATCH] Sync header and fix non linux build issue

---
 include/standard-headers/linux/virtio_pmem.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
include/standard-headers/linux/virtio_pmem.h +2 -4
index 7a3e2fe524..a60236f63d 100644
@@ -10,14 +10,13 @@
 #ifndef _UAPI_LINUX_VIRTIO_PMEM_H
 #define _UAPI_LINUX_VIRTIO_PMEM_H
 
-#include <linux/types.h>
-#include <linux/virtio_types.h>
-#include <linux/virtio_ids.h>
-#include <linux/virtio_config.h>
+#include "standard-headers/linux/virtio_types.h"
+#include "standard-headers/linux/virtio_ids.h"

include/standard-headers/linux/virtio_pmem.h line 22

Quoted 10 lines
include/standard-headers/linux/virtio_pmem.h +3 -2
+#include "standard-headers/linux/virtio_config.h"
 
 struct virtio_pmem_config {
-       __le64 start;
-       __le64 size;
+       uint64_t start;
+       uint64_t size;
 };
 
 #define VIRTIO_PMEM_REQ_TYPE_FLUSH      0

You need to get rid of __virtio things too. I fixed up, hopefully well.
If that's not enough then I will drop pmem for now.

Signature · 1 line
MST
#52 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 83 lines
Quoted 83 lines
Quoted 31 lines
Quoted 21 lines

The following changes since commit
7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01
11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to
a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01
10:39:35 -0400)

Quoted 9 lines

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

Quoted 8 lines

This fails to build on all the non-Linux platforms:

In file included from /Users/pm215/src/qemu-for-merges/hw/virtio/virtio-pmem.c:21:
/Users/pm215/src/qemu-for-merges/include/standard-headers/linux/virtio_pmem.h:13:10:
fatal error: 'linux/types.h' file not found

#include <linux/types.h>
         ^~~~~~~~~~~~~~~

Sorry for this.
Can we please apply below patch on top. I only tested this in linux but I think this will solve the issue. Let me know if you want to resend entire series.

Thank you,
Pankaj

===================

From: Pankaj Gupta <[email protected]>
Date: Thu, 4 Jul 2019 16:27:08 +0530
Subject: [PATCH] Sync header and fix non linux build issue

---
 include/standard-headers/linux/virtio_pmem.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
include/standard-headers/linux/virtio_pmem.h +5 -6
index 7a3e2fe524..a60236f63d 100644
@@ -10,14 +10,13 @@
 #ifndef _UAPI_LINUX_VIRTIO_PMEM_H
 #define _UAPI_LINUX_VIRTIO_PMEM_H
 
-#include <linux/types.h>
-#include <linux/virtio_types.h>
-#include <linux/virtio_ids.h>
-#include <linux/virtio_config.h>
+#include "standard-headers/linux/virtio_types.h"
+#include "standard-headers/linux/virtio_ids.h"
+#include "standard-headers/linux/virtio_config.h"
 
 struct virtio_pmem_config {
-       __le64 start;
-       __le64 size;
+       uint64_t start;
+       uint64_t size;
 };
 
Quoted 4 lines

include/standard-headers/linux/virtio_pmem.h line 22

Quoted 1 line
include/standard-headers/linux/virtio_pmem.h +0 -0
 #define VIRTIO_PMEM_REQ_TYPE_FLUSH      0

You need to get rid of __virtio things too.
I fixed up, hopefully well.

o.k. Thank you Michael

Best regards,
Pankaj

Quoted 6 lines

If that's not enough then I will drop pmem for now.

--
MST

#53 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

In reply to Peter Maydell
Quoted 30 lines · Peter Maydell
Quoted 13 lines · Michael S. Tsirkin

The following changes since commit 7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

Quoted 9 lines

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

This fails to build on all the non-Linux platforms:

In file included from /Users/pm215/src/qemu-for-merges/hw/virtio/virtio-pmem.c:21:
/Users/pm215/src/qemu-for-merges/include/standard-headers/linux/virtio_pmem.h:13:10:
fatal error: 'linux/types.h' file not found

Quoted 5 lines
#include <linux/types.h>
         ^~~~~~~~~~~~~~~

thanks
-- PMM

Amended and re-pushed. Pls try again, sorry about that.

Signature · 1 line
MST
#54 lore raw

Re: [Qemu-devel] [PULL 00/22] virtio, pc, pci: features, fixes, cleanups

Quoted 35 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Maydell
Quoted 13 lines · Michael S. Tsirkin

The following changes since commit 7fec76a02267598a4e437ddfdaeaeb6de09b92f3:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-24' into staging (2019-07-01 11:28:28 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to a360cd11de5ae59db55e128fd209290c777eb177:

docs: avoid vhost-user-net specifics in multiqueue section (2019-07-01 10:39:35 -0400)

Quoted 9 lines

----------------------------------------------------------------
virtio, pc, pci: features, fixes, cleanups

virtio-pmem support.
libvhost user mq support.
A bunch of fixes all over the place.

This fails to build on all the non-Linux platforms:

In file included from /Users/pm215/src/qemu-for-merges/hw/virtio/virtio-pmem.c:21:
/Users/pm215/src/qemu-for-merges/include/standard-headers/linux/virtio_pmem.h:13:10:
fatal error: 'linux/types.h' file not found

#include <linux/types.h>
         ^~~~~~~~~~~~~~~
Quoted 5 lines
Quoted 2 lines

thanks
-- PMM

Amended and re-pushed. Pls try again, sorry about that.

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.

-- PMM