s390x updates:

- tcg: implement STCK and friends for CONFIG_USER_ONLY
 - add zpci to qemu cpu model, as pci is now always built
 - add mepoch to default z14 cpu model
 - add cpu model for z14 GA2
 - various improvements
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAlxqka8SHGNvaHVja0By
 ZWRoYXQuY29tAAoJEN7Pa5PG8C+veMEP/RicbBsksTl5JjO0+isR8+H+qBYr/3ts
 lr/LE8xDKvbkbakKAkXry/3OrNEt8l3NQ5Zd22R5zM/tGgZ2y3n5xi8nIZcNw2v1
 K8/DZmEa2ta/x4RpYnuxuuYImOiAJBWIsAYdzOPZDfsVRfHfMxqYUtTz0sOv0SH6
 H3kQL7JOwlrbSfT3fbZLoJt/wdp2ri77P2HelfY2bVbwYLQHE7NSqF6a9TiS6VWQ
 SeWzGQk5DlaG5g6dvY49QkbDd4RFHTSviFCJ0FEWoyQTXbQxxKkTS4cr45Dt/HRe
 2OwSd0XQurH41WUTNao5h0+cZwhCoyfKUrkXGUOsmJpQXDhgRvOYqXtJZezBR9Xn
 q8fNykjXTAWdhVAggr/UlOiJy0ftoN73HYY2UxXK55SlZry3hJjNudk+6+rdRRXB
 VlRJDhO17KWFn95PLnQ5zRtvnR4Yhq2EsvtpZ6U/k2w/3qexmzMmQRcv0dRSTMBK
 CWrjbcptlvPbknPfgpTuzcLJS9zQj2PlOwFQ0K37gpbsj+dhzzqlP/+4Q0DqUjQN
 Fzfm+fHPfELUKXRi0wRJbjNtK/OPo85/cU1gaCwDZiMrpajFLl1+WMPiyjo9jFNB
 HrZ3z/ZuFua3M41QET/rcvrNktTYoZ38jvQ7Je8F5tipdG9UjvtHea9IQlsgNlWl
 QaDUqyZTaOmE
 =YlmZ
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190218' into staging

s390x updates:
- tcg: implement STCK and friends for CONFIG_USER_ONLY
- add zpci to qemu cpu model, as pci is now always built
- add mepoch to default z14 cpu model
- add cpu model for z14 GA2
- various improvements

# gpg: Signature made Mon 18 Feb 2019 11:06:23 GMT
# gpg:                using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF
# gpg:                issuer "cohuck@redhat.com"
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" [unknown]
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" [full]
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>" [full]
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>" [unknown]
# gpg:                 aka "Cornelia Huck <cohuck@redhat.com>" [unknown]
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20190218:
  s390x: upgrade status of KVM cores to "supported"
  s390x/kvm: add tracepoint to ioeventfd interface
  s390x/cpumodel: add z14 GA2 model
  s390x/cpumodel: default enable mepoch for z14 and later
  s390x/cpumodel: mepochptff: warn when no mepoch and re-align group init
  s390x: add zPCI feature to "qemu" CPU model
  target/s390x: Implement STCK et al for CONFIG_USER_ONLY
  target/s390x: Split out s390-tod.h
  s390x: always provide pci support
  s390x: Fix the confusing contributions-after-2012 license statements

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-02-18 11:32:00 +00:00
commit 1c5d9d8f11
19 changed files with 150 additions and 173 deletions

View File

@ -375,7 +375,7 @@ S390
M: Halil Pasic <pasic@linux.ibm.com>
M: Cornelia Huck <cohuck@redhat.com>
M: Christian Borntraeger <borntraeger@de.ibm.com>
S: Maintained
S: Supported
F: target/s390x/kvm.c
F: target/s390x/kvm_s390x.h
F: target/s390x/kvm-stub.c

View File

@ -21,8 +21,7 @@ obj-$(call land,$(CONFIG_VIRTIO_9P),$(CONFIG_VIRTFS)) += virtio-ccw-9p.o
obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock-ccw.o
obj-y += css-bridge.o
obj-y += ccw-device.o
obj-$(CONFIG_PCI) += s390-pci-bus.o s390-pci-inst.o
obj-$(call lnot,$(CONFIG_PCI)) += s390-pci-stub.o
obj-y += s390-pci-bus.o s390-pci-inst.o
obj-y += s390-skeys.o
obj-y += s390-stattrib.o
obj-y += tod.o

View File

@ -1,77 +0,0 @@
/* stubs for non-pci builds */
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "cpu.h"
#include "s390-pci-inst.h"
#include "s390-pci-bus.h"
/* target/s390x/ioinst.c */
int pci_chsc_sei_nt2_get_event(void *res)
{
return 1;
}
int pci_chsc_sei_nt2_have_event(void)
{
return 0;
}
/* hw/s390x/sclp.c */
void s390_pci_sclp_configure(SCCB *sccb)
{
sccb->h.response_code = cpu_to_be16(SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED);
}
void s390_pci_sclp_deconfigure(SCCB *sccb)
{
sccb->h.response_code = cpu_to_be16(SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED);
}
/* target/s390x/kvm.c */
int clp_service_call(S390CPU *cpu, uint8_t r2)
{
return -1;
}
int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
{
return -1;
}
int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
{
return -1;
}
int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
return -1;
}
int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
{
return -1;
}
int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
uint8_t ar)
{
return -1;
}
int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
return -1;
}
S390pciState *s390_get_phb(void)
{
return NULL;
}
S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s,
const char *target)
{
return NULL;
}

View File

@ -272,10 +272,6 @@ static void ccw_init(MachineState *machine)
machine->initrd_filename, "s390-ccw.img",
"s390-netboot.img", true);
/*
* We cannot easily make the pci host bridge conditional as older QEMUs
* always created it. Doing so would break migration across QEMU versions.
*/
dev = qdev_create(NULL, TYPE_S390_PCI_HOST_BRIDGE);
object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE,
OBJECT(dev), NULL);
@ -661,7 +657,11 @@ DEFINE_CCW_MACHINE(4_0, "4.0", true);
static void ccw_machine_3_1_instance_options(MachineState *machine)
{
static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V3_1 };
ccw_machine_4_0_instance_options(machine);
s390_cpudef_featoff_greater(14, 1, S390_FEAT_MULTIPLE_EPOCH);
s390_cpudef_group_featoff_greater(14, 1, S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF);
s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
}
static void ccw_machine_3_1_class_options(MachineClass *mc)

View File

@ -12,6 +12,7 @@
#define HW_S390_TOD_H
#include "hw/qdev.h"
#include "s390-tod.h"
typedef struct S390TOD {
uint8_t high;
@ -50,21 +51,6 @@ typedef struct S390TODClass {
void (*set)(S390TODState *td, const S390TOD *tod, Error **errp);
} S390TODClass;
/* The value of the TOD clock for 1.1.1970. */
#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
/* Converts ns to s390's clock format */
static inline uint64_t time2tod(uint64_t ns)
{
return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9);
}
/* Converts s390's clock format to ns */
static inline uint64_t tod2time(uint64_t t)
{
return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9);
}
void s390_init_tod(void);
S390TODState *s390_get_todstate(void);

View File

@ -3,21 +3,18 @@
*
* Copyright (c) 2009 Ulrich Hecht
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* General Public License for more details.
*
* Contributions after 2012-10-29 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*
* You should have received a copy of the GNU (Lesser) General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef S390X_TARGET_CPU_H
#define S390X_TARGET_CPU_H

View File

@ -6,21 +6,18 @@
* Copyright (c) 2012 SUSE LINUX Products GmbH
* Copyright (c) 2012 IBM Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>
* Contributions after 2012-12-11 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"

View File

@ -4,21 +4,18 @@
* 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
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* General Public License for more details.
*
* Contributions after 2012-10-29 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*
* You should have received a copy of the GNU (Lesser) General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef S390X_CPU_H

View File

@ -456,7 +456,6 @@ static S390FeatGroupDef s390_feature_groups[] = {
FEAT_GROUP_INIT("plo", PLO, "Perform-locked-operation facility"),
FEAT_GROUP_INIT("tods", TOD_CLOCK_STEERING, "Tod-clock-steering facility"),
FEAT_GROUP_INIT("gen13ptff", GEN13_PTFF, "PTFF enhancements introduced with z13"),
FEAT_GROUP_INIT("mepochptff", MULTIPLE_EPOCH_PTFF, "PTFF enhancements introduced with Multiple-epoch facility"),
FEAT_GROUP_INIT("msa", MSA, "Message-security-assist facility"),
FEAT_GROUP_INIT("msa1", MSA_EXT_1, "Message-security-assist-extension 1 facility"),
FEAT_GROUP_INIT("msa2", MSA_EXT_2, "Message-security-assist-extension 2 facility"),
@ -466,6 +465,7 @@ static S390FeatGroupDef s390_feature_groups[] = {
FEAT_GROUP_INIT("msa6", MSA_EXT_6, "Message-security-assist-extension 6 facility"),
FEAT_GROUP_INIT("msa7", MSA_EXT_7, "Message-security-assist-extension 7 facility"),
FEAT_GROUP_INIT("msa8", MSA_EXT_8, "Message-security-assist-extension 8 facility"),
FEAT_GROUP_INIT("mepochptff", MULTIPLE_EPOCH_PTFF, "PTFF enhancements introduced with Multiple-epoch facility"),
};
const S390FeatGroupDef *s390_feat_group_def(S390FeatGroup group)

View File

@ -79,6 +79,7 @@ static S390CPUDef s390_cpu_defs[] = {
CPUDEF_INIT(0x2964, 13, 2, 47, 0x08000000U, "z13.2", "IBM z13 GA2"),
CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"),
CPUDEF_INIT(0x3906, 14, 1, 47, 0x08000000U, "z14", "IBM z14 GA1"),
CPUDEF_INIT(0x3906, 14, 2, 47, 0x08000000U, "z14.2", "IBM z14 GA2"),
CPUDEF_INIT(0x3907, 14, 1, 47, 0x08000000U, "z14ZR1", "IBM z14 Model ZR1 GA1"),
};
@ -117,6 +118,30 @@ void s390_cpudef_featoff_greater(uint8_t gen, uint8_t ec_ga, S390Feat feat)
}
}
void s390_cpudef_group_featoff_greater(uint8_t gen, uint8_t ec_ga,
S390FeatGroup group)
{
const S390FeatGroupDef *group_def = s390_feat_group_def(group);
S390FeatBitmap group_def_off;
int i;
bitmap_complement(group_def_off, group_def->feat, S390_FEAT_MAX);
for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
const S390CPUDef *cpu_def = &s390_cpu_defs[i];
if (cpu_def->gen < gen) {
continue;
}
if (cpu_def->gen == gen && cpu_def->ec_ga < ec_ga) {
continue;
}
bitmap_and((unsigned long *)&cpu_def->default_feat,
cpu_def->default_feat, group_def_off, S390_FEAT_MAX);
}
}
uint32_t s390_get_hmfai(void)
{
static S390CPU *cpu;
@ -788,6 +813,10 @@ static void check_consistency(const S390CPUModel *model)
{ S390_FEAT_SIE_KSS, S390_FEAT_SIE_F2 },
{ S390_FEAT_AP_QUERY_CONFIG_INFO, S390_FEAT_AP },
{ S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP },
{ S390_FEAT_PTFF_QSIE, S390_FEAT_MULTIPLE_EPOCH },
{ S390_FEAT_PTFF_QTOUE, S390_FEAT_MULTIPLE_EPOCH },
{ S390_FEAT_PTFF_STOE, S390_FEAT_MULTIPLE_EPOCH },
{ S390_FEAT_PTFF_STOUE, S390_FEAT_MULTIPLE_EPOCH },
};
int i;
@ -1314,11 +1343,6 @@ static void register_types(void)
/* init all bitmaps from gnerated data initially */
s390_init_feat_bitmap(qemu_max_cpu_feat_init, qemu_max_cpu_feat);
#ifndef CONFIG_USER_ONLY
if (!pci_available) {
clear_bit(S390_FEAT_ZPCI, qemu_max_cpu_feat);
}
#endif
for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
s390_init_feat_bitmap(s390_cpu_defs[i].base_init,
s390_cpu_defs[i].base_feat);

View File

@ -75,6 +75,8 @@ struct S390CPUModel {
void s390_cpudef_featoff(uint8_t gen, uint8_t ec_ga, S390Feat feat);
void s390_cpudef_featoff_greater(uint8_t gen, uint8_t ec_ga, S390Feat feat);
void s390_cpudef_group_featoff_greater(uint8_t gen, uint8_t ec_ga,
S390FeatGroup group);
uint32_t s390_get_hmfai(void);
uint8_t s390_get_mha_pow(void);
uint32_t s390_get_ibc_val(void);

View File

@ -353,6 +353,8 @@ static uint16_t base_GEN14_GA1[] = {
S390_FEAT_ORDER_PRESERVING_COMPRESSION,
};
#define base_GEN14_GA2 EmptyFeat
/* Full features (in order of release)
* Automatically includes corresponding base features.
* Full features are all features this hardware supports even if kvm/QEMU do not
@ -480,6 +482,8 @@ static uint16_t full_GEN14_GA1[] = {
S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
};
#define full_GEN14_GA2 EmptyFeat
/* Default features (in order of release)
* Automatically includes corresponding base features.
* Default features are all features this version of QEMU supports for this
@ -550,8 +554,12 @@ static uint16_t default_GEN14_GA1[] = {
S390_FEAT_GROUP_MSA_EXT_6,
S390_FEAT_GROUP_MSA_EXT_7,
S390_FEAT_GROUP_MSA_EXT_8,
S390_FEAT_MULTIPLE_EPOCH,
S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
};
#define default_GEN14_GA2 EmptyFeat
/* QEMU (CPU model) features */
static uint16_t qemu_V2_11[] = {
@ -560,7 +568,7 @@ static uint16_t qemu_V2_11[] = {
S390_FEAT_ZARCH,
};
static uint16_t qemu_LATEST[] = {
static uint16_t qemu_V3_1[] = {
S390_FEAT_DAT_ENH,
S390_FEAT_IDTE_SEGMENT,
S390_FEAT_STFLE,
@ -592,14 +600,16 @@ static uint16_t qemu_LATEST[] = {
S390_FEAT_MSA_EXT_4,
};
static uint16_t qemu_LATEST[] = {
S390_FEAT_ZPCI,
};
/* add all new definitions before this point */
static uint16_t qemu_MAX[] = {
/* z13+ features */
S390_FEAT_STFLE_53,
/* generates a dependency warning, leave it out for now */
S390_FEAT_MSA_EXT_5,
/* only with CONFIG_PCI */
S390_FEAT_ZPCI,
};
/****** END FEATURE DEFS ******/
@ -660,6 +670,7 @@ static CpuFeatDefSpec CpuFeatDef[] = {
CPU_FEAT_INITIALIZER(GEN13_GA1),
CPU_FEAT_INITIALIZER(GEN13_GA2),
CPU_FEAT_INITIALIZER(GEN14_GA1),
CPU_FEAT_INITIALIZER(GEN14_GA2),
};
#define FEAT_GROUP_INITIALIZER(_name) \
@ -709,6 +720,7 @@ static FeatGroupDefSpec FeatGroupDef[] = {
*******************************/
static FeatGroupDefSpec QemuFeatDef[] = {
QEMU_FEAT_INITIALIZER(V2_11),
QEMU_FEAT_INITIALIZER(V3_1),
QEMU_FEAT_INITIALIZER(LATEST),
QEMU_FEAT_INITIALIZER(MAX),
};

View File

@ -121,13 +121,13 @@ DEF_HELPER_4(cu41, i32, env, i32, i32, i32)
DEF_HELPER_4(cu42, i32, env, i32, i32, i32)
DEF_HELPER_5(msa, i32, env, i32, i32, i32, i32)
DEF_HELPER_FLAGS_1(stpt, TCG_CALL_NO_RWG, i64, env)
DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env)
#ifndef CONFIG_USER_ONLY
DEF_HELPER_3(servc, i32, env, i64, i64)
DEF_HELPER_4(diag, void, env, i32, i32, i32)
DEF_HELPER_3(load_psw, noreturn, env, i64, i64)
DEF_HELPER_FLAGS_2(spx, TCG_CALL_NO_RWG, void, env, i64)
DEF_HELPER_FLAGS_1(stck, TCG_CALL_NO_RWG_SE, i64, env)
DEF_HELPER_FLAGS_2(sck, TCG_CALL_NO_RWG, i32, env, i64)
DEF_HELPER_FLAGS_2(sckc, TCG_CALL_NO_RWG, void, env, i64)
DEF_HELPER_FLAGS_2(sckpf, TCG_CALL_NO_RWG, void, env, i64)

View File

@ -837,6 +837,12 @@
C(0xe33e, STRV, RXY_a, Z, la2, r1_32u, new, m1_32, rev32, 0)
C(0xe32f, STRVG, RXY_a, Z, la2, r1_o, new, m1_64, rev64, 0)
/* STORE CLOCK */
C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0)
C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0)
/* STORE CLOCK EXTENDED */
C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0)
/* STORE FACILITY LIST EXTENDED */
C(0xb2b0, STFLE, S, SFLE, 0, a2, 0, 0, stfle, 0)
/* STORE FPC */
@ -1020,11 +1026,6 @@
F(0x8000, SSM, S, Z, 0, m2_8u, 0, 0, ssm, 0, IF_PRIV)
/* SIGNAL PROCESSOR */
F(0xae00, SIGP, RS_a, Z, 0, a2, 0, 0, sigp, 0, IF_PRIV)
/* STORE CLOCK */
C(0xb205, STCK, S, Z, la2, 0, new, m1_64, stck, 0)
C(0xb27c, STCKF, S, SCF, la2, 0, new, m1_64, stck, 0)
/* STORE CLOCK EXTENDED */
C(0xb278, STCKE, S, Z, 0, a2, 0, 0, stcke, 0)
/* STORE CLOCK COMPARATOR */
F(0xb207, STCKC, S, Z, la2, 0, new, m1_64a, stckc, 0, IF_PRIV)
/* STORE CONTROL */

View File

@ -4,21 +4,18 @@
* Copyright (c) 2009 Alexander Graf <agraf@suse.de>
* Copyright IBM Corp. 2012
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* General Public License for more details.
*
* Contributions after 2012-10-29 are licensed under the terms of the
* GNU GPL, version 2 or (at your option) any later version.
*
* You should have received a copy of the GNU (Lesser) General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
@ -1889,6 +1886,8 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
.addr = sch,
.len = 8,
};
trace_kvm_assign_subch_ioeventfd(kick.fd, kick.addr, assign,
kick.datamatch);
if (!kvm_check_extension(kvm_state, KVM_CAP_IOEVENTFD)) {
return -ENOSYS;
}
@ -2281,9 +2280,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)
}
/* We emulate a zPCI bus and AEN, therefore we don't need HW support */
if (pci_available) {
set_bit(S390_FEAT_ZPCI, model->features);
}
set_bit(S390_FEAT_ZPCI, model->features);
set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features);
if (s390_known_cpu_type(cpu_type)) {

View File

@ -30,6 +30,7 @@
#include "exec/cpu_ldst.h"
#include "qapi/error.h"
#include "tcg_s390x.h"
#include "s390-tod.h"
#if !defined(CONFIG_USER_ONLY)
#include "sysemu/cpus.h"
@ -76,8 +77,28 @@ uint64_t HELPER(stpt)(CPUS390XState *env)
#endif
}
#ifndef CONFIG_USER_ONLY
/* Store Clock */
uint64_t HELPER(stck)(CPUS390XState *env)
{
#ifdef CONFIG_USER_ONLY
struct timespec ts;
uint64_t ns;
clock_gettime(CLOCK_REALTIME, &ts);
ns = ts.tv_sec * NANOSECONDS_PER_SECOND + ts.tv_nsec;
return TOD_UNIX_EPOCH + time2tod(ns);
#else
S390TODState *td = s390_get_todstate();
S390TODClass *tdc = S390_TOD_GET_CLASS(td);
S390TOD tod;
tdc->get(td, &tod, &error_abort);
return tod.low;
#endif
}
#ifndef CONFIG_USER_ONLY
/* SCLP service call */
uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r1, uint64_t r2)
{
@ -138,17 +159,6 @@ void HELPER(spx)(CPUS390XState *env, uint64_t a1)
tlb_flush_page(cs, TARGET_PAGE_SIZE);
}
/* Store Clock */
uint64_t HELPER(stck)(CPUS390XState *env)
{
S390TODState *td = s390_get_todstate();
S390TODClass *tdc = S390_TOD_GET_CLASS(td);
S390TOD tod;
tdc->get(td, &tod, &error_abort);
return tod.low;
}
static void update_ckc_timer(CPUS390XState *env)
{
S390TODState *td = s390_get_todstate();

29
target/s390x/s390-tod.h Normal file
View File

@ -0,0 +1,29 @@
/*
* TOD (Time Of Day) clock
*
* Copyright 2018 Red Hat, Inc.
* Author(s): David Hildenbrand <david@redhat.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef TARGET_S390_TOD_H
#define TARGET_S390_TOD_H
/* The value of the TOD clock for 1.1.1970. */
#define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
/* Converts ns to s390's clock format */
static inline uint64_t time2tod(uint64_t ns)
{
return (ns << 9) / 125 + (((ns & 0xff80000000000000ull) / 125) << 9);
}
/* Converts s390's clock format to ns */
static inline uint64_t tod2time(uint64_t t)
{
return ((t >> 9) * 125) + (((t & 0x1ff) * 125) >> 9);
}
#endif

View File

@ -14,6 +14,7 @@ ioinst_chsc_cmd(uint16_t cmd, uint16_t len) "IOINST: chsc command 0x%04x, len 0x
kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) "Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s"
kvm_assign_subch_ioeventfd(int fd, uint32_t addr, bool assign, int datamatch) "fd: %d sch: @0x%x assign: %d vq: %d"
# target/s390x/cpu.c
cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d state to %" PRIu8

View File

@ -4060,6 +4060,7 @@ static DisasJumpType op_stap(DisasContext *s, DisasOps *o)
tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, core_id));
return DISAS_NEXT;
}
#endif
static DisasJumpType op_stck(DisasContext *s, DisasOps *o)
{
@ -4096,6 +4097,7 @@ static DisasJumpType op_stcke(DisasContext *s, DisasOps *o)
return DISAS_NEXT;
}
#ifndef CONFIG_USER_ONLY
static DisasJumpType op_sck(DisasContext *s, DisasOps *o)
{
tcg_gen_qemu_ld_i64(o->in1, o->addr1, get_mem_index(s), MO_TEQ | MO_ALIGN);