All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v8 0/3] rng-builtin: add an RNG backend that uses qemu_guest_getrandom()
@ 2019-08-20 16:06 Laurent Vivier
  2019-09-04 12:00   ` [Qemu-devel] [PULL 1/6] " Michael S. Tsirkin
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Laurent Vivier @ 2019-08-20 16:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Daniel P . Berrangé,
	Kashyap Chamarthy, Amit Shah, Richard Henderson,
	Richard W . M . Jones, Markus Armbruster, Michael S. Tsirkin

Add a new RNG backend using QEMU builtin getrandom function.

v8: rebase on v4.1

v7: rebase on master
    Make rng-builtin asynchronous with QEMUBH (removed existing R-b)

v6: remove "sysemu/rng-random.h" from virtio-rng.c
    rebase on qemu_getrandom v8

v5: PATCH 1 s/linux/Linux/
    remove superfluous includes from rng-builtin.c
    don't update rng-random documentation
    add a patch from Markus to keep the default backend out of VirtIORNGConf
    move TYPE_RNG_BUILTIN to sysemu/rng.h and remove sysemu/rng-builtin.h

v4: update PATCH 1 commit message

v3: Include Kashyap's patch in the series
    Add a patch to change virtio-rng default backend to rng-builtin

v2: Update qemu-options.hx
    describe the new backend and specify virtio-rng uses the
    rng-random by default

Laurent Vivier (2):
  rng-builtin: add an RNG backend that uses qemu_guest_getrandom()
  virtio-rng: change default backend to rng-builtin

Markus Armbruster (1):
  virtio-rng: Keep the default backend out of VirtIORNGConf

 backends/Makefile.objs         |  2 +-
 backends/rng-builtin.c         | 77 ++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-rng.c         | 19 ++++-----
 include/hw/virtio/virtio-rng.h |  2 -
 include/sysemu/rng.h           |  2 +
 qemu-options.hx                |  7 ++++
 6 files changed, 95 insertions(+), 14 deletions(-)
 create mode 100644 backends/rng-builtin.c

-- 
2.21.0



^ permalink raw reply	[flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2] virtio-pci: Add Function Level Reset support
@ 2019-09-04 12:01 ` Michael S. Tsirkin
  0 siblings, 0 replies; 19+ messages in thread
From: Julia Suvorova @ 2019-08-20 16:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Williamson, Julia Suvorova, mst

Using FLR becomes convenient in cases where resetting the bus is
impractical, for example, when debugging the behavior of individual
functions.

Signed-off-by: Julia Suvorova <jusual@redhat.com>
---
Requires definition of 4.2 machines:
Based-on: <20190724103524.20916-1-cohuck@redhat.com>

v2:
    Add compatibility property "x-pcie-flr-init"

 hw/core/machine.c      |  4 +++-
 hw/virtio/virtio-pci.c | 10 ++++++++++
 hw/virtio/virtio-pci.h |  4 ++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 83cd1bfeec..829ada099e 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -27,7 +27,9 @@
 #include "hw/pci/pci.h"
 #include "hw/mem/nvdimm.h"
 
-GlobalProperty hw_compat_4_1[] = {};
+GlobalProperty hw_compat_4_1[] = {
+    { "virtio-pci", "x-pcie-flr-init", "off" },
+};
 const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1);
 
 GlobalProperty hw_compat_4_0[] = {
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 8babd92e59..0075b3e2af 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -601,6 +601,10 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
 
     pci_default_write_config(pci_dev, address, val, len);
 
+    if (proxy->flags & VIRTIO_PCI_FLAG_INIT_FLR) {
+        pcie_cap_flr_write_config(pci_dev, address, val, len);
+    }
+
     if (range_covers_byte(address, len, PCI_COMMAND) &&
         !(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
         virtio_pci_stop_ioeventfd(proxy);
@@ -1777,6 +1781,10 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
             pcie_ats_init(pci_dev, 256);
         }
 
+        if (proxy->flags & VIRTIO_PCI_FLAG_INIT_FLR) {
+            /* Set Function Level Reset capability bit */
+            pcie_cap_flr_init(pci_dev);
+        }
     } else {
         /*
          * make future invocations of pci_is_express() return false
@@ -1844,6 +1852,8 @@ static Property virtio_pci_properties[] = {
                     VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true),
     DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_INIT_PM_BIT, true),
+    DEFINE_PROP_BIT("x-pcie-flr-init", VirtIOPCIProxy, flags,
+                    VIRTIO_PCI_FLAG_INIT_FLR_BIT, true),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index 292275acb1..e2eaaa9182 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -44,6 +44,7 @@ enum {
     VIRTIO_PCI_FLAG_INIT_DEVERR_BIT,
     VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT,
     VIRTIO_PCI_FLAG_INIT_PM_BIT,
+    VIRTIO_PCI_FLAG_INIT_FLR_BIT,
 };
 
 /* Need to activate work-arounds for buggy guests at vmstate load. */
@@ -80,6 +81,9 @@ enum {
 /* Init Power Management */
 #define VIRTIO_PCI_FLAG_INIT_PM (1 << VIRTIO_PCI_FLAG_INIT_PM_BIT)
 
+/* Init Function Level Reset capability */
+#define VIRTIO_PCI_FLAG_INIT_FLR (1 << VIRTIO_PCI_FLAG_INIT_FLR_BIT)
+
 typedef struct {
     MSIMessage msg;
     int virq;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH v2] libvhost-user: fix SLAVE_SEND_FD handling
@ 2019-09-04 12:01 ` Michael S. Tsirkin
  0 siblings, 0 replies; 19+ messages in thread
From: Johannes Berg @ 2019-09-03 20:04 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Johannes Berg, Tiwei Bie, Michael S . Tsirkin

From: Johannes Berg <johannes.berg@intel.com>

It doesn't look like this could possibly work properly since
VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD is defined to 10, but the
dev->protocol_features has a bitmap. I suppose the peer this
was tested with also supported VHOST_USER_PROTOCOL_F_LOG_SHMFD,
in which case the test would always be false, but nevertheless
the code seems wrong.

Use has_feature() to fix this.

Fixes: d84599f56c82 ("libvhost-user: support host notifier")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 contrib/libvhost-user/libvhost-user.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index 6a02eaffc672..fcf4a8a00ed2 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -1097,7 +1097,8 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *vq, int fd,
 
     vmsg.fd_num = fd_num;
 
-    if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) == 0) {
+    if (!has_feature(dev->protocol_features,
+                     VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) {
         return false;
     }
 
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH] libvhost-user: introduce and use vu_has_protocol_feature()
@ 2019-09-04 12:01 ` Michael S. Tsirkin
  0 siblings, 0 replies; 19+ messages in thread
From: Johannes Berg @ 2019-09-04  6:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Johannes Berg, Tiwei Bie, Michael S . Tsirkin

From: Johannes Berg <johannes.berg@intel.com>

This simplifies the various has_feature() checks, we already
have vu_has_feature() but it checks features, not protocol
features.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 contrib/libvhost-user/libvhost-user.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index fcf4a8a00ed2..fba291c13db4 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -94,6 +94,11 @@ bool vu_has_feature(VuDev *dev,
     return has_feature(dev->features, fbit);
 }
 
+static inline bool vu_has_protocol_feature(VuDev *dev, unsigned int fbit)
+{
+    return has_feature(dev->protocol_features, fbit);
+}
+
 static const char *
 vu_request_to_string(unsigned int req)
 {
@@ -951,8 +956,7 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq)
 {
     int i = 0;
 
-    if (!has_feature(dev->protocol_features,
-        VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
+    if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
         return 0;
     }
 
@@ -1097,8 +1101,7 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *vq, int fd,
 
     vmsg.fd_num = fd_num;
 
-    if (!has_feature(dev->protocol_features,
-                     VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) {
+    if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) {
         return false;
     }
 
@@ -2199,8 +2202,7 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned int idx, size_t sz)
 static int
 vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx)
 {
-    if (!has_feature(dev->protocol_features,
-        VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
+    if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
         return 0;
     }
 
@@ -2217,8 +2219,7 @@ vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx)
 static int
 vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx)
 {
-    if (!has_feature(dev->protocol_features,
-        VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
+    if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
         return 0;
     }
 
@@ -2234,8 +2235,7 @@ vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx)
 static int
 vu_queue_inflight_post_put(VuDev *dev, VuVirtq *vq, int desc_idx)
 {
-    if (!has_feature(dev->protocol_features,
-        VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
+    if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
         return 0;
     }
 
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 0/6] virtio,vhost: fixes, features, cleanups.
@ 2019-09-04 12:00 Michael S. Tsirkin
  2019-09-04 17:16 ` [Qemu-devel] [PULL 0/6] virtio, vhost: " Peter Maydell
  0 siblings, 1 reply; 19+ messages in thread
From: Michael S. Tsirkin @ 2019-09-04 12:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The following changes since commit 379d83f2c92879f4418aa9c57fd1fcbc3c82d384:

  Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-aug-29-2019' into staging (2019-09-04 10:16:00 +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 eeb39263aa9b05b4ac3f8d8e957958071834a7b6:

  libvhost-user: introduce and use vu_has_protocol_feature() (2019-09-04 07:53:12 -0400)

----------------------------------------------------------------
virtio,vhost: fixes, features, cleanups.

FLR support.
Misc fixes, cleanups.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

----------------------------------------------------------------
Johannes Berg (2):
      libvhost-user: fix SLAVE_SEND_FD handling
      libvhost-user: introduce and use vu_has_protocol_feature()

Julia Suvorova (1):
      virtio-pci: Add Function Level Reset support

Laurent Vivier (2):
      rng-builtin: add an RNG backend that uses qemu_guest_getrandom()
      virtio-rng: change default backend to rng-builtin

Markus Armbruster (1):
      virtio-rng: Keep the default backend out of VirtIORNGConf

 hw/virtio/virtio-pci.h                |  4 ++
 include/hw/virtio/virtio-rng.h        |  2 -
 include/sysemu/rng.h                  |  2 +
 backends/rng-builtin.c                | 77 +++++++++++++++++++++++++++++++++++
 contrib/libvhost-user/libvhost-user.c | 19 +++++----
 hw/core/machine.c                     |  4 +-
 hw/virtio/virtio-pci.c                | 10 +++++
 hw/virtio/virtio-rng.c                | 19 ++++-----
 backends/Makefile.objs                |  2 +-
 qemu-options.hx                       |  7 ++++
 10 files changed, 122 insertions(+), 24 deletions(-)
 create mode 100644 backends/rng-builtin.c



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-09-04 17:34 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 16:06 [Qemu-devel] [PATCH v8 0/3] rng-builtin: add an RNG backend that uses qemu_guest_getrandom() Laurent Vivier
2019-08-20 16:06 ` [Qemu-devel] [PATCH v8 1/3] " Laurent Vivier
2019-09-04 12:00   ` [Qemu-devel] [PULL 1/6] " Michael S. Tsirkin
2019-08-20 16:06 ` [Qemu-devel] [PATCH v8 2/3] virtio-rng: Keep the default backend out of VirtIORNGConf Laurent Vivier
2019-09-04 12:00   ` [Qemu-devel] [PULL 2/6] " Michael S. Tsirkin
2019-08-20 16:06 ` [Qemu-devel] [PATCH v8 3/3] virtio-rng: change default backend to rng-builtin Laurent Vivier
2019-09-04 12:00   ` [Qemu-devel] [PULL 3/6] " Michael S. Tsirkin
2019-09-04 10:26 ` [Qemu-devel] [PATCH v8 0/3] rng-builtin: add an RNG backend that uses qemu_guest_getrandom() Michael S. Tsirkin
2019-08-20 16:30 [Qemu-devel] [PATCH v2] virtio-pci: Add Function Level Reset support Julia Suvorova
2019-09-04 12:01 ` [Qemu-devel] [PULL 4/6] " Michael S. Tsirkin
2019-09-03 20:04 [Qemu-devel] [PATCH v2] libvhost-user: fix SLAVE_SEND_FD handling Johannes Berg
2019-09-04 12:01 ` [Qemu-devel] [PULL 5/6] " Michael S. Tsirkin
2019-09-04  2:06 ` [Qemu-devel] [PATCH v2] " Tiwei Bie
2019-09-04  9:01   ` Tiwei Bie
2019-09-04  6:50 [Qemu-devel] [PATCH] libvhost-user: introduce and use vu_has_protocol_feature() Johannes Berg
2019-09-04 12:01 ` [Qemu-devel] [PULL 6/6] " Michael S. Tsirkin
2019-09-04  9:22 ` [Qemu-devel] [PATCH] " Tiwei Bie
2019-09-04 12:00 [Qemu-devel] [PULL 0/6] virtio,vhost: fixes, features, cleanups Michael S. Tsirkin
2019-09-04 17:16 ` [Qemu-devel] [PULL 0/6] virtio, vhost: " Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.