On 6/6/22 22:36, Matthew Rosato wrote:
If the ZPCI_OP ioctl reports that is is available and usable, then the
underlying KVM host will enable load/store intepretation for any guest
device without a SHM bit in the guest function handle.  For a device that
will be using interpretation support, ensure the guest function handle
matches the host function handle; this value is re-checked every time the
guest issues a SET PCI FN to enable the guest device as it is the only
opportunity to reflect function handle changes.

By default, unless interpret=off is specified, interpretation support will
always be assumed and exploited if the necessary ioctl and features are
available on the host kernel.  When these are unavailable, we will silently
revert to the interception model; this allows existing guest configurations
to work unmodified on hosts with and without zPCI interpretation support,
allowing QEMU to choose the best support model available.

Signed-off-by: Matthew Rosato <mjros...@linux.ibm.com>
---
  hw/s390x/meson.build            |  1 +
  hw/s390x/s390-pci-bus.c         | 66 ++++++++++++++++++++++++++++++++-
  hw/s390x/s390-pci-inst.c        | 16 ++++++++
  hw/s390x/s390-pci-kvm.c         | 22 +++++++++++
  include/hw/s390x/s390-pci-bus.h |  1 +
  include/hw/s390x/s390-pci-kvm.h | 24 ++++++++++++
  target/s390x/kvm/kvm.c          |  7 ++++
  target/s390x/kvm/kvm_s390x.h    |  1 +
  8 files changed, 137 insertions(+), 1 deletion(-)
  create mode 100644 hw/s390x/s390-pci-kvm.c
  create mode 100644 include/hw/s390x/s390-pci-kvm.h

diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
index feefe0717e..f291016fee 100644
--- a/hw/s390x/meson.build
+++ b/hw/s390x/meson.build
@@ -23,6 +23,7 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
    's390-skeys-kvm.c',
    's390-stattrib-kvm.c',
    'pv.c',
+  's390-pci-kvm.c',
  ))

Here...

diff --git a/hw/s390x/s390-pci-kvm.c b/hw/s390x/s390-pci-kvm.c
new file mode 100644
index 0000000000..0f16104a74
--- /dev/null
+++ b/hw/s390x/s390-pci-kvm.c

...and here:

Shouldn't this file go in target/s390x/kvm ?


@@ -0,0 +1,22 @@
+/*
+ * s390 zPCI KVM interfaces
+ *
+ * Copyright 2022 IBM Corp.
+ * Author(s): Matthew Rosato <mjros...@linux.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#include "qemu/osdep.h"
+
+#include "kvm/kvm_s390x.h"
+#include "hw/s390x/pv.h"
+#include "hw/s390x/s390-pci-kvm.h"
+#include "cpu_models.h"
+
+bool s390_pci_kvm_interp_allowed(void)
+{
+    return kvm_s390_get_zpci_op() && !s390_is_pv();
+}


--
Pierre Morel
IBM Lab Boeblingen

Reply via email to