thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
902636
From 33d4e21cfd236aecd9e4dbe8228d058fd1f22400 Mon Sep 17 00:00:00 2001
902636
From: Thomas Huth <thuth@redhat.com>
902636
Date: Fri, 29 May 2020 05:54:12 -0400
902636
Subject: [PATCH 30/42] s390x: protvirt: Move diag 308 data over SIDA
902636
902636
RH-Author: Thomas Huth <thuth@redhat.com>
902636
Message-id: <20200529055420.16855-31-thuth@redhat.com>
902636
Patchwork-id: 97048
902636
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 30/38] s390x: protvirt: Move diag 308 data over SIDA
902636
Bugzilla: 1828317
902636
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
902636
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
902636
RH-Acked-by: David Hildenbrand <david@redhat.com>
902636
902636
From: Janosch Frank <frankja@linux.ibm.com>
902636
902636
For protected guests the IPIB is written/read to/from the SIDA, so we
902636
need those accesses to go through s390_cpu_pv_mem_read/write().
902636
902636
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
902636
Reviewed-by: David Hildenbrand <david@redhat.com>
902636
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
902636
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
902636
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
902636
Message-Id: <20200319131921.2367-12-frankja@linux.ibm.com>
902636
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
902636
(cherry picked from commit 9c61e11238cfa8f70e3eb90aac5d3e5646e5432f)
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 target/s390x/diag.c | 25 ++++++++++++++++++++-----
902636
 1 file changed, 20 insertions(+), 5 deletions(-)
902636
902636
diff --git a/target/s390x/diag.c b/target/s390x/diag.c
902636
index b2cbefb8cf..1a48429564 100644
902636
--- a/target/s390x/diag.c
902636
+++ b/target/s390x/diag.c
902636
@@ -75,6 +75,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)
902636
 {
902636
     bool valid;
902636
     CPUState *cs = env_cpu(env);
902636
+    S390CPU *cpu = S390_CPU(cs);
902636
     uint64_t addr =  env->regs[r1];
902636
     uint64_t subcode = env->regs[r3];
902636
     IplParameterBlock *iplb;
902636
@@ -111,13 +112,22 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)
902636
             return;
902636
         }
902636
         iplb = g_new0(IplParameterBlock, 1);
902636
-        cpu_physical_memory_read(addr, iplb, sizeof(iplb->len));
902636
+        if (!s390_is_pv()) {
902636
+            cpu_physical_memory_read(addr, iplb, sizeof(iplb->len));
902636
+        } else {
902636
+            s390_cpu_pv_mem_read(cpu, 0, iplb, sizeof(iplb->len));
902636
+        }
902636
+
902636
         if (!iplb_valid_len(iplb)) {
902636
             env->regs[r1 + 1] = DIAG_308_RC_INVALID;
902636
             goto out;
902636
         }
902636
 
902636
-        cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len));
902636
+        if (!s390_is_pv()) {
902636
+            cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len));
902636
+        } else {
902636
+            s390_cpu_pv_mem_read(cpu, 0, iplb, be32_to_cpu(iplb->len));
902636
+        }
902636
 
902636
         valid = subcode == DIAG308_PV_SET ? iplb_valid_pv(iplb) : iplb_valid(iplb);
902636
         if (!valid) {
902636
@@ -140,12 +150,17 @@ out:
902636
         } else {
902636
             iplb = s390_ipl_get_iplb();
902636
         }
902636
-        if (iplb) {
902636
+        if (!iplb) {
902636
+            env->regs[r1 + 1] = DIAG_308_RC_NO_CONF;
902636
+            return;
902636
+        }
902636
+
902636
+        if (!s390_is_pv()) {
902636
             cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->len));
902636
-            env->regs[r1 + 1] = DIAG_308_RC_OK;
902636
         } else {
902636
-            env->regs[r1 + 1] = DIAG_308_RC_NO_CONF;
902636
+            s390_cpu_pv_mem_write(cpu, 0, iplb, be32_to_cpu(iplb->len));
902636
         }
902636
+        env->regs[r1 + 1] = DIAG_308_RC_OK;
902636
         return;
902636
     case DIAG308_PV_START:
902636
         iplb = s390_ipl_get_iplb_pv();
902636
-- 
902636
2.27.0
902636