77c23f
From 27f5d8a3af2863e39b7c46a3128009988d772f15 Mon Sep 17 00:00:00 2001
77c23f
From: Thomas Huth <thuth@redhat.com>
77c23f
Date: Fri, 29 May 2020 05:54:09 -0400
77c23f
Subject: [PATCH 27/42] s390x: protvirt: Move STSI data over SIDAD
77c23f
77c23f
RH-Author: Thomas Huth <thuth@redhat.com>
77c23f
Message-id: <20200529055420.16855-28-thuth@redhat.com>
77c23f
Patchwork-id: 97046
77c23f
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 27/38] s390x: protvirt: Move STSI data over SIDAD
77c23f
Bugzilla: 1828317
77c23f
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
77c23f
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
77c23f
RH-Acked-by: David Hildenbrand <david@redhat.com>
77c23f
77c23f
From: Janosch Frank <frankja@linux.ibm.com>
77c23f
77c23f
For protected guests, we need to put the STSI emulation results into
77c23f
the SIDA, so SIE will write them into the guest at the next entry.
77c23f
77c23f
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
77c23f
Reviewed-by: David Hildenbrand <david@redhat.com>
77c23f
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
77c23f
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
77c23f
Message-Id: <20200319131921.2367-9-frankja@linux.ibm.com>
77c23f
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
77c23f
(cherry picked from commit 7c713b8acb70fb61f9650f8a7702dec546752bb6)
77c23f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
77c23f
---
77c23f
 target/s390x/kvm.c | 11 +++++++++--
77c23f
 1 file changed, 9 insertions(+), 2 deletions(-)
77c23f
77c23f
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
77c23f
index f67bb5ce2c..6809a5ac40 100644
77c23f
--- a/target/s390x/kvm.c
77c23f
+++ b/target/s390x/kvm.c
77c23f
@@ -50,6 +50,7 @@
77c23f
 #include "exec/memattrs.h"
77c23f
 #include "hw/s390x/s390-virtio-ccw.h"
77c23f
 #include "hw/s390x/s390-virtio-hcall.h"
77c23f
+#include "hw/s390x/pv.h"
77c23f
 
77c23f
 #ifndef DEBUG_KVM
77c23f
 #define DEBUG_KVM  0
77c23f
@@ -1803,7 +1804,9 @@ static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr, uint8_t ar)
77c23f
     SysIB_322 sysib;
77c23f
     int del;
77c23f
 
77c23f
-    if (s390_cpu_virt_mem_read(cpu, addr, ar, &sysib, sizeof(sysib))) {
77c23f
+    if (s390_is_pv()) {
77c23f
+        s390_cpu_pv_mem_read(cpu, 0, &sysib, sizeof(sysib));
77c23f
+    } else if (s390_cpu_virt_mem_read(cpu, addr, ar, &sysib, sizeof(sysib))) {
77c23f
         return;
77c23f
     }
77c23f
     /* Shift the stack of Extended Names to prepare for our own data */
77c23f
@@ -1843,7 +1846,11 @@ static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr, uint8_t ar)
77c23f
     /* Insert UUID */
77c23f
     memcpy(sysib.vm[0].uuid, &qemu_uuid, sizeof(sysib.vm[0].uuid));
77c23f
 
77c23f
-    s390_cpu_virt_mem_write(cpu, addr, ar, &sysib, sizeof(sysib));
77c23f
+    if (s390_is_pv()) {
77c23f
+        s390_cpu_pv_mem_write(cpu, 0, &sysib, sizeof(sysib));
77c23f
+    } else {
77c23f
+        s390_cpu_virt_mem_write(cpu, addr, ar, &sysib, sizeof(sysib));
77c23f
+    }
77c23f
 }
77c23f
 
77c23f
 static int handle_stsi(S390CPU *cpu)
77c23f
-- 
77c23f
2.27.0
77c23f