yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-s390x-s390-virtio-ccw-Fix-build-on-systems-without-K.patch

ddf19c
From 0db8d909a2f3c53d12b0ae12307965f9a8193dbc Mon Sep 17 00:00:00 2001
ddf19c
From: Thomas Huth <thuth@redhat.com>
ddf19c
Date: Fri, 29 May 2020 05:54:19 -0400
ddf19c
Subject: [PATCH 37/42] s390x/s390-virtio-ccw: Fix build on systems without KVM
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Thomas Huth <thuth@redhat.com>
ddf19c
Message-id: <20200529055420.16855-38-thuth@redhat.com>
ddf19c
Patchwork-id: 97047
ddf19c
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 37/38] s390x/s390-virtio-ccw: Fix build on systems without KVM
ddf19c
Bugzilla: 1828317
ddf19c
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
RH-Acked-by: David Hildenbrand <david@redhat.com>
ddf19c
ddf19c
From: Christian Borntraeger <borntraeger@de.ibm.com>
ddf19c
ddf19c
linux/kvm.h is not available on all platforms. Let us move
ddf19c
s390_machine_inject_pv_error into pv.c as it uses KVM structures.
ddf19c
Also rename the function to s390_pv_inject_reset_error.
ddf19c
ddf19c
While at it, ipl.h needs an include for "exec/address-spaces.h"
ddf19c
as it uses address_space_memory.
ddf19c
ddf19c
Fixes: c3347ed0d2ee ("s390x: protvirt: Support unpack facility")
ddf19c
Reported-by: Bruce Rogers <brogers@suse.com>
ddf19c
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
ddf19c
Message-Id: <20200406100158.5940-2-borntraeger@de.ibm.com>
ddf19c
Reviewed-by: David Hildenbrand <david@redhat.com>
ddf19c
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ddf19c
(cherry picked from commit fbc1384ccd48fa7c0c38f950adf7992a4fb6042e)
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 hw/s390x/ipl.h             |  1 +
ddf19c
 hw/s390x/pv.c              | 11 +++++++++++
ddf19c
 hw/s390x/s390-virtio-ccw.c | 12 +-----------
ddf19c
 include/hw/s390x/pv.h      |  3 +++
ddf19c
 4 files changed, 16 insertions(+), 11 deletions(-)
ddf19c
ddf19c
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
ddf19c
index 89b3044d7a..53cc9eb5ac 100644
ddf19c
--- a/hw/s390x/ipl.h
ddf19c
+++ b/hw/s390x/ipl.h
ddf19c
@@ -14,6 +14,7 @@
ddf19c
 #define HW_S390_IPL_H
ddf19c
 
ddf19c
 #include "cpu.h"
ddf19c
+#include "exec/address-spaces.h"
ddf19c
 #include "hw/qdev-core.h"
ddf19c
 
ddf19c
 struct IPLBlockPVComp {
ddf19c
diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
ddf19c
index cb0dce4a4f..f11868e865 100644
ddf19c
--- a/hw/s390x/pv.c
ddf19c
+++ b/hw/s390x/pv.c
ddf19c
@@ -13,8 +13,10 @@
ddf19c
 
ddf19c
 #include <linux/kvm.h>
ddf19c
 
ddf19c
+#include "cpu.h"
ddf19c
 #include "qemu/error-report.h"
ddf19c
 #include "sysemu/kvm.h"
ddf19c
+#include "hw/s390x/ipl.h"
ddf19c
 #include "hw/s390x/pv.h"
ddf19c
 
ddf19c
 static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data)
ddf19c
@@ -100,3 +102,12 @@ void s390_pv_unshare(void)
ddf19c
 {
ddf19c
     s390_pv_cmd_exit(KVM_PV_UNSHARE_ALL, NULL);
ddf19c
 }
ddf19c
+
ddf19c
+void s390_pv_inject_reset_error(CPUState *cs)
ddf19c
+{
ddf19c
+    int r1 = (cs->kvm_run->s390_sieic.ipa & 0x00f0) >> 4;
ddf19c
+    CPUS390XState *env = &S390_CPU(cs)->env;
ddf19c
+
ddf19c
+    /* Report that we are unable to enter protected mode */
ddf19c
+    env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV;
ddf19c
+}
ddf19c
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
ddf19c
index c08e42bda1..07773a12b2 100644
ddf19c
--- a/hw/s390x/s390-virtio-ccw.c
ddf19c
+++ b/hw/s390x/s390-virtio-ccw.c
ddf19c
@@ -44,7 +44,6 @@
ddf19c
 #include "sysemu/sysemu.h"
ddf19c
 #include "sysemu/balloon.h"
ddf19c
 #include "hw/s390x/pv.h"
ddf19c
-#include <linux/kvm.h>
ddf19c
 #include "migration/blocker.h"
ddf19c
 
ddf19c
 static Error *pv_mig_blocker;
ddf19c
@@ -391,15 +390,6 @@ out_err:
ddf19c
     return rc;
ddf19c
 }
ddf19c
 
ddf19c
-static void s390_machine_inject_pv_error(CPUState *cs)
ddf19c
-{
ddf19c
-    int r1 = (cs->kvm_run->s390_sieic.ipa & 0x00f0) >> 4;
ddf19c
-    CPUS390XState *env = &S390_CPU(cs)->env;
ddf19c
-
ddf19c
-    /* Report that we are unable to enter protected mode */
ddf19c
-    env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV;
ddf19c
-}
ddf19c
-
ddf19c
 static void s390_pv_prepare_reset(S390CcwMachineState *ms)
ddf19c
 {
ddf19c
     CPUState *cs;
ddf19c
@@ -485,7 +475,7 @@ static void s390_machine_reset(MachineState *machine)
ddf19c
         run_on_cpu(cs, s390_do_cpu_reset, RUN_ON_CPU_NULL);
ddf19c
 
ddf19c
         if (s390_machine_protect(ms)) {
ddf19c
-            s390_machine_inject_pv_error(cs);
ddf19c
+            s390_pv_inject_reset_error(cs);
ddf19c
             /*
ddf19c
              * Continue after the diag308 so the guest knows something
ddf19c
              * went wrong.
ddf19c
diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h
ddf19c
index c6cb360f2f..522ca6a04e 100644
ddf19c
--- a/include/hw/s390x/pv.h
ddf19c
+++ b/include/hw/s390x/pv.h
ddf19c
@@ -13,6 +13,7 @@
ddf19c
 #define HW_S390_PV_H
ddf19c
 
ddf19c
 #ifdef CONFIG_KVM
ddf19c
+#include "cpu.h"
ddf19c
 #include "hw/s390x/s390-virtio-ccw.h"
ddf19c
 
ddf19c
 static inline bool s390_is_pv(void)
ddf19c
@@ -41,6 +42,7 @@ int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak);
ddf19c
 void s390_pv_perf_clear_reset(void);
ddf19c
 int s390_pv_verify(void);
ddf19c
 void s390_pv_unshare(void);
ddf19c
+void s390_pv_inject_reset_error(CPUState *cs);
ddf19c
 #else /* CONFIG_KVM */
ddf19c
 static inline bool s390_is_pv(void) { return false; }
ddf19c
 static inline int s390_pv_vm_enable(void) { return 0; }
ddf19c
@@ -50,6 +52,7 @@ static inline int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak) {
ddf19c
 static inline void s390_pv_perf_clear_reset(void) {}
ddf19c
 static inline int s390_pv_verify(void) { return 0; }
ddf19c
 static inline void s390_pv_unshare(void) {}
ddf19c
+static inline void s390_pv_inject_reset_error(CPUState *cs) {};
ddf19c
 #endif /* CONFIG_KVM */
ddf19c
 
ddf19c
 #endif /* HW_S390_PV_H */
ddf19c
-- 
ddf19c
2.27.0
ddf19c