Blame SOURCES/kvm-s390x-ipl-Consolidate-iplb-validity-check-into-one-f.patch

902636
From 536b6081c0739bebbb33583370f62116d0cb42da Mon Sep 17 00:00:00 2001
902636
From: Thomas Huth <thuth@redhat.com>
902636
Date: Fri, 29 May 2020 05:54:01 -0400
902636
Subject: [PATCH 19/42] s390x: ipl: Consolidate iplb validity check into one
902636
 function
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-20-thuth@redhat.com>
902636
Patchwork-id: 97038
902636
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 19/38] s390x: ipl: Consolidate iplb validity check into one function
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: Janosch Frank <frankja@linux.ibm.com>
902636
902636
It's nicer to just call one function than calling a function for each
902636
possible iplb type.
902636
902636
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
902636
Reviewed-by: David Hildenbrand <david@redhat.com>
902636
Message-Id: <20200310090950.61172-1-frankja@linux.ibm.com>
902636
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
902636
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
902636
(cherry picked from commit 94c21436e5a89143f8b9cb4d089d1a2f3f4fd377)
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 hw/s390x/ipl.h      | 18 +++++++++---------
902636
 target/s390x/diag.c |  2 +-
902636
 2 files changed, 10 insertions(+), 10 deletions(-)
902636
902636
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
902636
index d4813105db..3e44abe1c6 100644
902636
--- a/hw/s390x/ipl.h
902636
+++ b/hw/s390x/ipl.h
902636
@@ -173,16 +173,16 @@ static inline bool iplb_valid_len(IplParameterBlock *iplb)
902636
     return be32_to_cpu(iplb->len) <= sizeof(IplParameterBlock);
902636
 }
902636
 
902636
-static inline bool iplb_valid_ccw(IplParameterBlock *iplb)
902636
+static inline bool iplb_valid(IplParameterBlock *iplb)
902636
 {
902636
-    return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_CCW_LEN &&
902636
-           iplb->pbt == S390_IPL_TYPE_CCW;
902636
-}
902636
-
902636
-static inline bool iplb_valid_fcp(IplParameterBlock *iplb)
902636
-{
902636
-    return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_FCP_LEN &&
902636
-           iplb->pbt == S390_IPL_TYPE_FCP;
902636
+    switch (iplb->pbt) {
902636
+    case S390_IPL_TYPE_FCP:
902636
+        return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_FCP_LEN;
902636
+    case S390_IPL_TYPE_CCW:
902636
+        return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_CCW_LEN;
902636
+    default:
902636
+        return false;
902636
+    }
902636
 }
902636
 
902636
 #endif
902636
diff --git a/target/s390x/diag.c b/target/s390x/diag.c
902636
index b5aec06d6b..54e5670b3f 100644
902636
--- a/target/s390x/diag.c
902636
+++ b/target/s390x/diag.c
902636
@@ -117,7 +117,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)
902636
 
902636
         cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len));
902636
 
902636
-        if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb)) {
902636
+        if (!iplb_valid(iplb)) {
902636
             env->regs[r1 + 1] = DIAG_308_RC_INVALID;
902636
             goto out;
902636
         }
902636
-- 
902636
2.27.0
902636