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

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