yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
c687bc
From 722078f9fdb766c2f0990145de6732f0c36a63b7 Mon Sep 17 00:00:00 2001
c687bc
From: Thomas Huth <thuth@redhat.com>
c687bc
Date: Wed, 11 Nov 2020 12:03:16 -0500
c687bc
Subject: [PATCH 16/18] s390x: pv: Fix diag318 PV fencing
c687bc
c687bc
RH-Author: Thomas Huth <thuth@redhat.com>
c687bc
Message-id: <20201111120316.707489-13-thuth@redhat.com>
c687bc
Patchwork-id: 99509
c687bc
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 12/12] s390x: pv: Fix diag318 PV fencing
c687bc
Bugzilla: 1798506
c687bc
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
c687bc
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
c687bc
RH-Acked-by: David Hildenbrand <david@redhat.com>
c687bc
c687bc
From: Janosch Frank <frankja@linux.ibm.com>
c687bc
c687bc
Diag318 fencing needs to be determined on the current VM PV state and
c687bc
not on the state that the VM has when we create the CPU model.
c687bc
c687bc
Fixes: fabdada935 ("s390: guest support for diagnose 0x318")
c687bc
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
c687bc
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
c687bc
Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
c687bc
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
c687bc
Reviewed-by: Collin Walling <walling@linux.ibm.com>
c687bc
Acked-by: David Hildenbrand <david@redhat.com>
c687bc
Message-Id: <20201022103135.126033-3-frankja@linux.ibm.com>
c687bc
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
c687bc
(cherry picked from commit 3ded270a2697852a71961b45291519ae044f25e3)
c687bc
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
c687bc
---
c687bc
 target/s390x/cpu_features.c | 5 +++++
c687bc
 target/s390x/cpu_features.h | 4 ++++
c687bc
 target/s390x/cpu_models.c   | 4 ++++
c687bc
 target/s390x/kvm.c          | 3 +--
c687bc
 4 files changed, 14 insertions(+), 2 deletions(-)
c687bc
c687bc
diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c
c687bc
index 9f817e3cfa7..e5cdf232607 100644
c687bc
--- a/target/s390x/cpu_features.c
c687bc
+++ b/target/s390x/cpu_features.c
c687bc
@@ -14,6 +14,7 @@
c687bc
 #include "qemu/osdep.h"
c687bc
 #include "qemu/module.h"
c687bc
 #include "cpu_features.h"
c687bc
+#include "hw/s390x/pv.h"
c687bc
 
c687bc
 #define DEF_FEAT(_FEAT, _NAME, _TYPE, _BIT, _DESC) \
c687bc
     [S390_FEAT_##_FEAT] = {                        \
c687bc
@@ -105,6 +106,10 @@ void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type,
c687bc
         }
c687bc
         feat = find_next_bit(features, S390_FEAT_MAX, feat + 1);
c687bc
     }
c687bc
+
c687bc
+    if (type == S390_FEAT_TYPE_SCLP_FAC134 && s390_is_pv()) {
c687bc
+        clear_be_bit(s390_feat_def(S390_FEAT_DIAG_318)->bit, data);
c687bc
+    }
c687bc
 }
c687bc
 
c687bc
 void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type,
c687bc
diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h
c687bc
index f74f7fc3a11..d3c685a04c8 100644
c687bc
--- a/target/s390x/cpu_features.h
c687bc
+++ b/target/s390x/cpu_features.h
c687bc
@@ -81,6 +81,10 @@ const S390FeatGroupDef *s390_feat_group_def(S390FeatGroup group);
c687bc
 
c687bc
 #define BE_BIT_NR(BIT) (BIT ^ (BITS_PER_LONG - 1))
c687bc
 
c687bc
+static inline void clear_be_bit(unsigned int bit_nr, uint8_t *array)
c687bc
+{
c687bc
+    array[bit_nr / 8] &= ~(0x80 >> (bit_nr % 8));
c687bc
+}
c687bc
 static inline void set_be_bit(unsigned int bit_nr, uint8_t *array)
c687bc
 {
c687bc
     array[bit_nr / 8] |= 0x80 >> (bit_nr % 8);
c687bc
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
c687bc
index bf6a3faba9e..d489923cb8a 100644
c687bc
--- a/target/s390x/cpu_models.c
c687bc
+++ b/target/s390x/cpu_models.c
c687bc
@@ -29,6 +29,7 @@
c687bc
 #include "hw/pci/pci.h"
c687bc
 #endif
c687bc
 #include "qapi/qapi-commands-machine-target.h"
c687bc
+#include "hw/s390x/pv.h"
c687bc
 
c687bc
 #define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \
c687bc
     {                                                                    \
c687bc
@@ -238,6 +239,9 @@ bool s390_has_feat(S390Feat feat)
c687bc
         }
c687bc
         return 0;
c687bc
     }
c687bc
+    if (feat == S390_FEAT_DIAG_318 && s390_is_pv()) {
c687bc
+        return false;
c687bc
+    }
c687bc
     return test_bit(feat, cpu->model->features);
c687bc
 }
c687bc
 
c687bc
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
c687bc
index e5e190d21c9..6edb52f6d25 100644
c687bc
--- a/target/s390x/kvm.c
c687bc
+++ b/target/s390x/kvm.c
c687bc
@@ -2483,8 +2483,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)
c687bc
      */
c687bc
     set_bit(S390_FEAT_EXTENDED_LENGTH_SCCB, model->features);
c687bc
 
c687bc
-    /* DIAGNOSE 0x318 is not supported under protected virtualization */
c687bc
-    if (!s390_is_pv() && kvm_check_extension(kvm_state, KVM_CAP_S390_DIAG318)) {
c687bc
+    if (kvm_check_extension(kvm_state, KVM_CAP_S390_DIAG318)) {
c687bc
         set_bit(S390_FEAT_DIAG_318, model->features);
c687bc
     }
c687bc
 
c687bc
-- 
c687bc
2.27.0
c687bc