thebeanogamer / rpms / qemu-kvm

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