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

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