aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-08-20 17:41:18 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-08-20 17:41:18 +0100
commitd0092d90eb546a8bbe9e9120426c189474123797 (patch)
tree4eb27ac9db3ebc7ce01425e0605f8d7682639a88 /target
parent44b69d503797cd2b4acd005327923894e69c58ea (diff)
parent09c6c754804df4d997f84fd9c17d90c5b4ce948c (diff)
downloadqemu-d0092d90eb546a8bbe9e9120426c189474123797.zip
qemu-d0092d90eb546a8bbe9e9120426c189474123797.tar.gz
qemu-d0092d90eb546a8bbe9e9120426c189474123797.tar.bz2
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20180820' into staging
First round of s390x patches for 3.1: - add compat machine for 3.1 - remove deprecated 's390-squash-mcss' option - cpu models: add "max" cpu model, enhance feature group code - kvm: add support for etoken facility and huge page backing # gpg: Signature made Mon 20 Aug 2018 13:47:38 BST # gpg: using RSA key DECF6B93C6F02FAF # gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" # gpg: aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" # gpg: aka "Cornelia Huck <cohuck@kernel.org>" # gpg: aka "Cornelia Huck <cohuck@redhat.com>" # Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0 18CE DECF 6B93 C6F0 2FAF * remotes/cohuck/tags/s390x-20180820: s390x: Enable KVM huge page backing support s390x/kvm: add etoken facility linux-headers: update s390x/cpumodel: Add "-cpu max" support s390x: remove 's390-squash-mcss' option s390x/cpumodel: enum type S390FeatGroup now gets generated s390x: introduce 3.1 compat machine Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target')
-rw-r--r--target/s390x/cpu.c10
-rw-r--r--target/s390x/cpu.h4
-rw-r--r--target/s390x/cpu_features.c4
-rw-r--r--target/s390x/cpu_features.h19
-rw-r--r--target/s390x/cpu_features_def.h3
-rw-r--r--target/s390x/cpu_models.c82
-rw-r--r--target/s390x/gen-features.c21
-rw-r--r--target/s390x/kvm.c46
-rw-r--r--target/s390x/machine.c20
9 files changed, 147 insertions, 62 deletions
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 271c5ce..8ed4823 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -421,16 +421,6 @@ void s390_crypto_reset(void)
}
}
-bool s390_get_squash_mcss(void)
-{
- if (object_property_get_bool(OBJECT(qdev_get_machine()), "s390-squash-mcss",
- NULL)) {
- return true;
- }
-
- return false;
-}
-
void s390_enable_css_support(S390CPU *cpu)
{
if (kvm_enabled()) {
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 2c3dd2d..6f8861e 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -2,6 +2,7 @@
* S/390 virtual CPU header
*
* Copyright (c) 2009 Ulrich Hecht
+ * Copyright IBM Corp. 2012, 2018
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -68,6 +69,8 @@ struct CPUS390XState {
uint32_t aregs[16]; /* access registers */
uint8_t riccb[64]; /* runtime instrumentation control */
uint64_t gscb[4]; /* guarded storage control */
+ uint64_t etoken; /* etoken */
+ uint64_t etoken_extension; /* etoken extension */
/* Fields up to this point are not cleared by initial CPU reset */
struct {} start_initial_reset_fields;
@@ -713,7 +716,6 @@ static inline void s390_do_cpu_load_normal(CPUState *cs, run_on_cpu_data arg)
/* cpu.c */
void s390_crypto_reset(void);
-bool s390_get_squash_mcss(void);
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit);
void s390_cmma_reset(void);
void s390_enable_css_support(S390CPU *cpu);
diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c
index 3b9e274..172fb18 100644
--- a/target/s390x/cpu_features.c
+++ b/target/s390x/cpu_features.c
@@ -1,7 +1,7 @@
/*
* CPU features/facilities for s390x
*
- * Copyright 2016 IBM Corp.
+ * Copyright IBM Corp. 2016, 2018
*
* Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
*
@@ -13,7 +13,6 @@
#include "qemu/osdep.h"
#include "qemu/module.h"
#include "cpu_features.h"
-#include "gen-features.h"
#define FEAT_INIT(_name, _type, _bit, _desc) \
{ \
@@ -106,6 +105,7 @@ static const S390FeatDef s390_features[] = {
FEAT_INIT("irbm", S390_FEAT_TYPE_STFL, 145, "Insert-reference-bits-multiple facility"),
FEAT_INIT("msa8-base", S390_FEAT_TYPE_STFL, 146, "Message-security-assist-extension-8 facility (excluding subfunctions)"),
FEAT_INIT("cmmnt", S390_FEAT_TYPE_STFL, 147, "CMM: ESSA-enhancement (no translate) facility"),
+ FEAT_INIT("etoken", S390_FEAT_TYPE_STFL, 156, "Etoken facility"),
/* SCLP SCCB Byte 80 - 98 (bit numbers relative to byte-80) */
FEAT_INIT("gsls", S390_FEAT_TYPE_SCLP_CONF_CHAR, 40, "SIE: Guest-storage-limit-suppression facility"),
diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h
index 968b12f..effe790 100644
--- a/target/s390x/cpu_features.h
+++ b/target/s390x/cpu_features.h
@@ -16,6 +16,7 @@
#include "qemu/bitmap.h"
#include "cpu_features_def.h"
+#include "gen-features.h"
/* CPU features are announced via different ways */
typedef enum {
@@ -64,24 +65,6 @@ void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type,
void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque,
void (*fn)(const char *name, void *opaque));
-/* static groups that will never change */
-typedef enum {
- S390_FEAT_GROUP_PLO,
- S390_FEAT_GROUP_TOD_CLOCK_STEERING,
- S390_FEAT_GROUP_GEN13_PTFF_ENH,
- S390_FEAT_GROUP_MSA,
- S390_FEAT_GROUP_MSA_EXT_1,
- S390_FEAT_GROUP_MSA_EXT_2,
- S390_FEAT_GROUP_MSA_EXT_3,
- S390_FEAT_GROUP_MSA_EXT_4,
- S390_FEAT_GROUP_MSA_EXT_5,
- S390_FEAT_GROUP_MSA_EXT_6,
- S390_FEAT_GROUP_MSA_EXT_7,
- S390_FEAT_GROUP_MSA_EXT_8,
- S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
- S390_FEAT_GROUP_MAX,
-} S390FeatGroup;
-
/* Definition of a CPU feature group */
typedef struct {
const char *name; /* name exposed to the user */
diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_def.h
index 7c5915c..ac2c947 100644
--- a/target/s390x/cpu_features_def.h
+++ b/target/s390x/cpu_features_def.h
@@ -1,7 +1,7 @@
/*
* CPU features/facilities for s390
*
- * Copyright 2016 IBM Corp.
+ * Copyright IBM Corp. 2016, 2018
*
* Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
* David Hildenbrand <dahi@linux.vnet.ibm.com>
@@ -93,6 +93,7 @@ typedef enum {
S390_FEAT_INSERT_REFERENCE_BITS_MULT,
S390_FEAT_MSA_EXT_8,
S390_FEAT_CMM_NT,
+ S390_FEAT_ETOKEN,
/* Sclp Conf Char */
S390_FEAT_SIE_GSLS,
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 604898a..12e765b 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -307,7 +307,10 @@ static gint s390_cpu_list_compare(gconstpointer a, gconstpointer b)
const char *name_a = object_class_get_name((ObjectClass *)a);
const char *name_b = object_class_get_name((ObjectClass *)b);
- /* move qemu and host to the top of the list, qemu first, host second */
+ /*
+ * Move qemu, host and max to the top of the list, qemu first, host second,
+ * max third.
+ */
if (name_a[0] == 'q') {
return -1;
} else if (name_b[0] == 'q') {
@@ -316,6 +319,10 @@ static gint s390_cpu_list_compare(gconstpointer a, gconstpointer b)
return -1;
} else if (name_b[0] == 'h') {
return 1;
+ } else if (name_a[0] == 'm') {
+ return -1;
+ } else if (name_b[0] == 'm') {
+ return 1;
}
/* keep the same order we have in our table (sorted by release date) */
@@ -1077,27 +1084,6 @@ static void s390_cpu_model_initfn(Object *obj)
}
}
-#ifdef CONFIG_KVM
-static void s390_host_cpu_model_initfn(Object *obj)
-{
- S390CPU *cpu = S390_CPU(obj);
- Error *err = NULL;
-
- if (!kvm_enabled() || !kvm_s390_cpu_models_supported()) {
- return;
- }
-
- cpu->model = g_malloc0(sizeof(*cpu->model));
- kvm_s390_get_host_cpu_model(cpu->model, &err);
- if (err) {
- error_report_err(err);
- g_free(cpu->model);
- /* fallback to unsupported cpu models */
- cpu->model = NULL;
- }
-}
-#endif
-
static S390CPUDef s390_qemu_cpu_def;
static S390CPUModel s390_qemu_cpu_model;
@@ -1136,6 +1122,31 @@ static void s390_qemu_cpu_model_initfn(Object *obj)
memcpy(cpu->model, &s390_qemu_cpu_model, sizeof(*cpu->model));
}
+static void s390_max_cpu_model_initfn(Object *obj)
+{
+ const S390CPUModel *max_model;
+ S390CPU *cpu = S390_CPU(obj);
+ Error *local_err = NULL;
+
+ if (kvm_enabled() && !kvm_s390_cpu_models_supported()) {
+ /* "max" and "host" always work, even without CPU model support */
+ return;
+ }
+
+ max_model = get_max_cpu_model(&local_err);
+ if (local_err) {
+ /* we expect errors only under KVM, when actually querying the kernel */
+ g_assert(kvm_enabled());
+ error_report_err(local_err);
+ /* fallback to unsupported CPU models */
+ return;
+ }
+
+ cpu->model = g_new(S390CPUModel, 1);
+ /* copy the CPU model so we can modify it */
+ memcpy(cpu->model, max_model, sizeof(*cpu->model));
+}
+
static void s390_cpu_model_finalize(Object *obj)
{
S390CPU *cpu = S390_CPU(obj);
@@ -1209,6 +1220,20 @@ static void s390_qemu_cpu_model_class_init(ObjectClass *oc, void *data)
qemu_hw_version());
}
+static void s390_max_cpu_model_class_init(ObjectClass *oc, void *data)
+{
+ S390CPUClass *xcc = S390_CPU_CLASS(oc);
+
+ /*
+ * The "max" model is neither static nor migration safe. Under KVM
+ * it represents the "host" model. Under TCG it represents some kind of
+ * "qemu" CPU model without compat handling and maybe with some additional
+ * CPU features that are not yet unlocked in the "qemu" model.
+ */
+ xcc->desc =
+ "Enables all features supported by the accelerator in the current host";
+}
+
/* Generate type name for a cpu model. Caller has to free the string. */
static char *s390_cpu_type_name(const char *model_name)
{
@@ -1239,12 +1264,18 @@ static const TypeInfo qemu_s390_cpu_type_info = {
.class_init = s390_qemu_cpu_model_class_init,
};
+static const TypeInfo max_s390_cpu_type_info = {
+ .name = S390_CPU_TYPE_NAME("max"),
+ .parent = TYPE_S390_CPU,
+ .instance_init = s390_max_cpu_model_initfn,
+ .instance_finalize = s390_cpu_model_finalize,
+ .class_init = s390_max_cpu_model_class_init,
+};
+
#ifdef CONFIG_KVM
static const TypeInfo host_s390_cpu_type_info = {
.name = S390_CPU_TYPE_NAME("host"),
- .parent = TYPE_S390_CPU,
- .instance_init = s390_host_cpu_model_initfn,
- .instance_finalize = s390_cpu_model_finalize,
+ .parent = S390_CPU_TYPE_NAME("max"),
.class_init = s390_host_cpu_model_class_init,
};
#endif
@@ -1326,6 +1357,7 @@ static void register_types(void)
}
type_register_static(&qemu_s390_cpu_type_info);
+ type_register_static(&max_s390_cpu_type_info);
#ifdef CONFIG_KVM
type_register_static(&host_s390_cpu_type_info);
#endif
diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c
index 6626b6f..384b61c 100644
--- a/target/s390x/gen-features.c
+++ b/target/s390x/gen-features.c
@@ -1,7 +1,7 @@
/*
* S390 feature list generator
*
- * Copyright 2016 IBM Corp.
+ * Copyright IBM Corp. 2016, 2018
*
* Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
* David Hildenbrand <dahi@linux.vnet.ibm.com>
@@ -471,6 +471,7 @@ static uint16_t full_GEN14_GA1[] = {
S390_FEAT_GROUP_MSA_EXT_7,
S390_FEAT_GROUP_MSA_EXT_8,
S390_FEAT_CMM_NT,
+ S390_FEAT_ETOKEN,
S390_FEAT_HPMA2,
S390_FEAT_SIE_KSS,
S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
@@ -661,6 +662,7 @@ static CpuFeatDefSpec CpuFeatDef[] = {
#define FEAT_GROUP_INITIALIZER(_name) \
{ \
.name = "S390_FEAT_GROUP_LIST_" #_name, \
+ .enum_name = "S390_FEAT_GROUP_" #_name, \
.bits = \
{ .data = group_##_name, \
.len = ARRAY_SIZE(group_##_name) }, \
@@ -668,6 +670,7 @@ static CpuFeatDefSpec CpuFeatDef[] = {
typedef struct {
const char *name;
+ const char *enum_name;
BitSpec bits;
} FeatGroupDefSpec;
@@ -678,7 +681,6 @@ static FeatGroupDefSpec FeatGroupDef[] = {
FEAT_GROUP_INITIALIZER(PLO),
FEAT_GROUP_INITIALIZER(TOD_CLOCK_STEERING),
FEAT_GROUP_INITIALIZER(GEN13_PTFF),
- FEAT_GROUP_INITIALIZER(MULTIPLE_EPOCH_PTFF),
FEAT_GROUP_INITIALIZER(MSA),
FEAT_GROUP_INITIALIZER(MSA_EXT_1),
FEAT_GROUP_INITIALIZER(MSA_EXT_2),
@@ -688,6 +690,7 @@ static FeatGroupDefSpec FeatGroupDef[] = {
FEAT_GROUP_INITIALIZER(MSA_EXT_6),
FEAT_GROUP_INITIALIZER(MSA_EXT_7),
FEAT_GROUP_INITIALIZER(MSA_EXT_8),
+ FEAT_GROUP_INITIALIZER(MULTIPLE_EPOCH_PTFF),
};
#define QEMU_FEAT_INITIALIZER(_name) \
@@ -810,6 +813,19 @@ static void print_feature_group_defs(void)
}
}
+static void print_feature_group_enum_type(void)
+{
+ int i;
+
+ printf("\n/* CPU feature group enum type */\n"
+ "typedef enum {\n");
+ for (i = 0; i < ARRAY_SIZE(FeatGroupDef); i++) {
+ printf("\t%s,\n", FeatGroupDef[i].enum_name);
+ }
+ printf("\tS390_FEAT_GROUP_MAX,\n"
+ "} S390FeatGroup;\n");
+}
+
int main(int argc, char *argv[])
{
printf("/*\n"
@@ -826,6 +842,7 @@ int main(int argc, char *argv[])
print_feature_defs();
print_feature_group_defs();
print_qemu_feature_defs();
+ print_feature_group_enum_type();
printf("\n#endif\n");
return 0;
}
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index d923cf4..348e8cc 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -34,6 +34,8 @@
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/timer.h"
+#include "qemu/units.h"
+#include "qemu/mmap-alloc.h"
#include "sysemu/sysemu.h"
#include "sysemu/hw_accel.h"
#include "hw/hw.h"
@@ -139,6 +141,7 @@ static int cap_mem_op;
static int cap_s390_irq;
static int cap_ri;
static int cap_gs;
+static int cap_hpage_1m;
static int active_cmma;
@@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
.attr = KVM_S390_VM_MEM_ENABLE_CMMA,
};
- if (mem_path) {
+ if (cap_hpage_1m) {
warn_report("CMM will not be enabled because it is not "
- "compatible with hugetlbfs.");
+ "compatible with huge memory backings.");
return;
}
rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
@@ -281,10 +284,38 @@ void kvm_s390_crypto_reset(void)
}
}
+static int kvm_s390_configure_mempath_backing(KVMState *s)
+{
+ size_t path_psize = qemu_mempath_getpagesize(mem_path);
+
+ if (path_psize == 4 * KiB) {
+ return 0;
+ }
+
+ if (path_psize != 1 * MiB) {
+ error_report("Memory backing with 2G pages was specified, "
+ "but KVM does not support this memory backing");
+ return -EINVAL;
+ }
+
+ if (kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE_1M, 0)) {
+ error_report("Memory backing with 1M pages was specified, "
+ "but KVM does not support this memory backing");
+ return -EINVAL;
+ }
+
+ cap_hpage_1m = 1;
+ return 0;
+}
+
int kvm_arch_init(MachineState *ms, KVMState *s)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
+ if (mem_path && kvm_s390_configure_mempath_backing(s)) {
+ return -EINVAL;
+ }
+
mc->default_cpu_type = S390_CPU_TYPE_NAME("host");
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
@@ -493,6 +524,12 @@ int kvm_arch_put_registers(CPUState *cs, int level)
cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_BPBC;
}
+ if (can_sync_regs(cs, KVM_SYNC_ETOKEN)) {
+ cs->kvm_run->s.regs.etoken = env->etoken;
+ cs->kvm_run->s.regs.etoken_extension = env->etoken_extension;
+ cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_ETOKEN;
+ }
+
/* Finally the prefix */
if (can_sync_regs(cs, KVM_SYNC_PREFIX)) {
cs->kvm_run->s.regs.prefix = env->psa;
@@ -607,6 +644,11 @@ int kvm_arch_get_registers(CPUState *cs)
env->bpbc = cs->kvm_run->s.regs.bpbc;
}
+ if (can_sync_regs(cs, KVM_SYNC_ETOKEN)) {
+ env->etoken = cs->kvm_run->s.regs.etoken;
+ env->etoken_extension = cs->kvm_run->s.regs.etoken_extension;
+ }
+
/* pfault parameters */
if (can_sync_regs(cs, KVM_SYNC_PFAULT)) {
env->pfault_token = cs->kvm_run->s.regs.pft;
diff --git a/target/s390x/machine.c b/target/s390x/machine.c
index bd3230d..cb792aa 100644
--- a/target/s390x/machine.c
+++ b/target/s390x/machine.c
@@ -1,7 +1,7 @@
/*
* S390x machine definitions and functions
*
- * Copyright IBM Corp. 2014
+ * Copyright IBM Corp. 2014, 2018
*
* Authors:
* Thomas Huth <thuth@linux.vnet.ibm.com>
@@ -216,6 +216,23 @@ const VMStateDescription vmstate_bpbc = {
}
};
+static bool etoken_needed(void *opaque)
+{
+ return s390_has_feat(S390_FEAT_ETOKEN);
+}
+
+const VMStateDescription vmstate_etoken = {
+ .name = "cpu/etoken",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = etoken_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT64(env.etoken, S390CPU),
+ VMSTATE_UINT64(env.etoken_extension, S390CPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
const VMStateDescription vmstate_s390_cpu = {
.name = "cpu",
.post_load = cpu_post_load,
@@ -251,6 +268,7 @@ const VMStateDescription vmstate_s390_cpu = {
&vmstate_exval,
&vmstate_gscb,
&vmstate_bpbc,
+ &vmstate_etoken,
NULL
},
};