Blame SOURCES/kvm-s390x-kvm-add-etoken-facility.patch

357786
From d5c27d4667cc1fb8065c27dc7e7d0e5d29f34e29 Mon Sep 17 00:00:00 2001
357786
From: Thomas Huth <thuth@redhat.com>
357786
Date: Tue, 28 Aug 2018 17:03:12 +0200
357786
Subject: [PATCH 02/29] s390x/kvm: add etoken facility
357786
357786
RH-Author: Thomas Huth <thuth@redhat.com>
357786
Message-id: <1535475792-21136-3-git-send-email-thuth@redhat.com>
357786
Patchwork-id: 81948
357786
O-Subject: [RHEL-7.6 qemu-kvm-ma PATCH 2/2] s390x/kvm: add etoken facility
357786
Bugzilla: 1622962
357786
RH-Acked-by: David Hildenbrand <david@redhat.com>
357786
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
357786
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
357786
357786
From: Christian Borntraeger <borntraeger@de.ibm.com>
357786
357786
Provide the etoken facility. We need to handle cpu model, migration and
357786
clear reset.
357786
357786
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
357786
Acked-by: Janosch Frank <frankja@linux.ibm.com>
357786
Message-Id: <20180731090448.36662-3-borntraeger@de.ibm.com>
357786
Reviewed-by: David Hildenbrand <david@redhat.com>
357786
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
357786
(cherry picked from commit 27e84d4ebd25b981ab27cb590fe06d1b0fcd06d2)
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 target/s390x/cpu.h              |  3 +++
357786
 target/s390x/cpu_features.c     |  3 ++-
357786
 target/s390x/cpu_features_def.h |  3 ++-
357786
 target/s390x/gen-features.c     |  3 ++-
357786
 target/s390x/kvm.c              | 11 +++++++++++
357786
 target/s390x/machine.c          | 20 +++++++++++++++++++-
357786
 6 files changed, 39 insertions(+), 4 deletions(-)
357786
357786
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
357786
index 3ee40f0..86d08fa 100644
357786
--- a/target/s390x/cpu.h
357786
+++ b/target/s390x/cpu.h
357786
@@ -2,6 +2,7 @@
357786
  * S/390 virtual CPU header
357786
  *
357786
  *  Copyright (c) 2009 Ulrich Hecht
357786
+ *  Copyright IBM Corp. 2012, 2018
357786
  *
357786
  * This library is free software; you can redistribute it and/or
357786
  * modify it under the terms of the GNU Lesser General Public
357786
@@ -68,6 +69,8 @@ struct CPUS390XState {
357786
     uint32_t aregs[16];    /* access registers */
357786
     uint8_t riccb[64];     /* runtime instrumentation control */
357786
     uint64_t gscb[4];      /* guarded storage control */
357786
+    uint64_t etoken;       /* etoken */
357786
+    uint64_t etoken_extension; /* etoken extension */
357786
 
357786
     /* Fields up to this point are not cleared by initial CPU reset */
357786
     struct {} start_initial_reset_fields;
357786
diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c
357786
index 3b9e274..e05e6aa 100644
357786
--- a/target/s390x/cpu_features.c
357786
+++ b/target/s390x/cpu_features.c
357786
@@ -1,7 +1,7 @@
357786
 /*
357786
  * CPU features/facilities for s390x
357786
  *
357786
- * Copyright 2016 IBM Corp.
357786
+ * Copyright IBM Corp. 2016, 2018
357786
  *
357786
  * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
357786
  *
357786
@@ -106,6 +106,7 @@ static const S390FeatDef s390_features[] = {
357786
     FEAT_INIT("irbm", S390_FEAT_TYPE_STFL, 145, "Insert-reference-bits-multiple facility"),
357786
     FEAT_INIT("msa8-base", S390_FEAT_TYPE_STFL, 146, "Message-security-assist-extension-8 facility (excluding subfunctions)"),
357786
     FEAT_INIT("cmmnt", S390_FEAT_TYPE_STFL, 147, "CMM: ESSA-enhancement (no translate) facility"),
357786
+    FEAT_INIT("etoken", S390_FEAT_TYPE_STFL, 156, "Etoken facility"),
357786
 
357786
     /* SCLP SCCB Byte 80 - 98  (bit numbers relative to byte-80) */
357786
     FEAT_INIT("gsls", S390_FEAT_TYPE_SCLP_CONF_CHAR, 40, "SIE: Guest-storage-limit-suppression facility"),
357786
diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_def.h
357786
index 7c5915c..ac2c947 100644
357786
--- a/target/s390x/cpu_features_def.h
357786
+++ b/target/s390x/cpu_features_def.h
357786
@@ -1,7 +1,7 @@
357786
 /*
357786
  * CPU features/facilities for s390
357786
  *
357786
- * Copyright 2016 IBM Corp.
357786
+ * Copyright IBM Corp. 2016, 2018
357786
  *
357786
  * Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
357786
  *            David Hildenbrand <dahi@linux.vnet.ibm.com>
357786
@@ -93,6 +93,7 @@ typedef enum {
357786
     S390_FEAT_INSERT_REFERENCE_BITS_MULT,
357786
     S390_FEAT_MSA_EXT_8,
357786
     S390_FEAT_CMM_NT,
357786
+    S390_FEAT_ETOKEN,
357786
 
357786
     /* Sclp Conf Char */
357786
     S390_FEAT_SIE_GSLS,
357786
diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c
357786
index 6626b6f..5af042c 100644
357786
--- a/target/s390x/gen-features.c
357786
+++ b/target/s390x/gen-features.c
357786
@@ -1,7 +1,7 @@
357786
 /*
357786
  * S390 feature list generator
357786
  *
357786
- * Copyright 2016 IBM Corp.
357786
+ * Copyright IBM Corp. 2016, 2018
357786
  *
357786
  * Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
357786
  *            David Hildenbrand <dahi@linux.vnet.ibm.com>
357786
@@ -471,6 +471,7 @@ static uint16_t full_GEN14_GA1[] = {
357786
     S390_FEAT_GROUP_MSA_EXT_7,
357786
     S390_FEAT_GROUP_MSA_EXT_8,
357786
     S390_FEAT_CMM_NT,
357786
+    S390_FEAT_ETOKEN,
357786
     S390_FEAT_HPMA2,
357786
     S390_FEAT_SIE_KSS,
357786
     S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
357786
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
357786
index fbccceb..ca8c32e 100644
357786
--- a/target/s390x/kvm.c
357786
+++ b/target/s390x/kvm.c
357786
@@ -494,6 +494,12 @@ int kvm_arch_put_registers(CPUState *cs, int level)
357786
         cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_BPBC;
357786
     }
357786
 
357786
+    if (can_sync_regs(cs, KVM_SYNC_ETOKEN)) {
357786
+        cs->kvm_run->s.regs.etoken = env->etoken;
357786
+        cs->kvm_run->s.regs.etoken_extension  = env->etoken_extension;
357786
+        cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_ETOKEN;
357786
+    }
357786
+
357786
     /* Finally the prefix */
357786
     if (can_sync_regs(cs, KVM_SYNC_PREFIX)) {
357786
         cs->kvm_run->s.regs.prefix = env->psa;
357786
@@ -608,6 +614,11 @@ int kvm_arch_get_registers(CPUState *cs)
357786
         env->bpbc = cs->kvm_run->s.regs.bpbc;
357786
     }
357786
 
357786
+    if (can_sync_regs(cs, KVM_SYNC_ETOKEN)) {
357786
+        env->etoken = cs->kvm_run->s.regs.etoken;
357786
+        env->etoken_extension = cs->kvm_run->s.regs.etoken_extension;
357786
+    }
357786
+
357786
     /* pfault parameters */
357786
     if (can_sync_regs(cs, KVM_SYNC_PFAULT)) {
357786
         env->pfault_token = cs->kvm_run->s.regs.pft;
357786
diff --git a/target/s390x/machine.c b/target/s390x/machine.c
357786
index 84b4928..8421deb 100644
357786
--- a/target/s390x/machine.c
357786
+++ b/target/s390x/machine.c
357786
@@ -1,7 +1,7 @@
357786
 /*
357786
  * S390x machine definitions and functions
357786
  *
357786
- * Copyright IBM Corp. 2014
357786
+ * Copyright IBM Corp. 2014, 2018
357786
  *
357786
  * Authors:
357786
  *   Thomas Huth <thuth@linux.vnet.ibm.com>
357786
@@ -210,6 +210,23 @@ const VMStateDescription vmstate_bpbc = {
357786
     }
357786
 };
357786
 
357786
+static bool etoken_needed(void *opaque)
357786
+{
357786
+    return s390_has_feat(S390_FEAT_ETOKEN);
357786
+}
357786
+
357786
+const VMStateDescription vmstate_etoken = {
357786
+    .name = "cpu/etoken",
357786
+    .version_id = 1,
357786
+    .minimum_version_id = 1,
357786
+    .needed = etoken_needed,
357786
+    .fields = (VMStateField[]) {
357786
+        VMSTATE_UINT64(env.etoken, S390CPU),
357786
+        VMSTATE_UINT64(env.etoken_extension, S390CPU),
357786
+        VMSTATE_END_OF_LIST()
357786
+    }
357786
+};
357786
+
357786
 const VMStateDescription vmstate_s390_cpu = {
357786
     .name = "cpu",
357786
     .post_load = cpu_post_load,
357786
@@ -245,6 +262,7 @@ const VMStateDescription vmstate_s390_cpu = {
357786
         &vmstate_exval,
357786
         &vmstate_gscb,
357786
         &vmstate_bpbc,
357786
+        &vmstate_etoken,
357786
         NULL
357786
     },
357786
 };
357786
-- 
357786
1.8.3.1
357786