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

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