From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel <qemu-devel@nongnu.org>,
Alexander Graf <agraf@suse.de>,
Richard Henderson <rth@twiddle.net>,
Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>,
Fei Li <sherrylf@linux.vnet.ibm.com>,
Yi Min Zhao <zyimin@linux.vnet.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [Qemu-devel] [PULL 08/40] s390x/flic: introduce modify_ais_mode callback
Date: Fri, 14 Jul 2017 12:40:35 +0200 [thread overview]
Message-ID: <1500028867-134709-9-git-send-email-borntraeger@de.ibm.com> (raw)
In-Reply-To: <1500028867-134709-1-git-send-email-borntraeger@de.ibm.com>
From: Fei Li <sherrylf@linux.vnet.ibm.com>
In order to emulate the adapter interruption suppression (AIS)
facility properly, the guest needs to be able to modify the AIS mask.
Interrupt suppression will be handled via the flic (for kvm, via a
recently introduced kernel backend; for !kvm, in the flic code), so
let's introduce a method to change the mode via the flic interface.
We introduce the 'simm' and 'nimm' fields to QEMUS390FLICState
to store interruption modes for each ISC. Each bit in 'simm' and
'nimm' targets one ISC, and collaboratively indicate three modes:
ALL-Interruptions, SINGLE-Interruption and NO-Interruptions. This
interface can initiate most transitions between the states; transition
from SINGLE-Interruption to NO-Interruptions via adapter interrupt
injection will be introduced in a following patch. The meaningful
combinations are as follows:
interruption mode | simm bit | nimm bit
------------------|----------|----------
ALL | 0 | 0
SINGLE | 1 | 0
NO | 1 | 1
Co-authored-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Signed-off-by: Fei Li <sherrylf@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
hw/intc/s390_flic.c | 37 ++++++++++++++++++++++++++++++++++++-
hw/intc/s390_flic_kvm.c | 36 ++++++++++++++++++++++++++++++++++++
include/hw/s390x/s390_flic.h | 9 ++++++++-
3 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c
index d3938b3..ce7f355 100644
--- a/hw/intc/s390_flic.c
+++ b/hw/intc/s390_flic.c
@@ -79,15 +79,47 @@ static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
return -ENOSYS;
}
+static int qemu_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,
+ uint16_t mode)
+{
+ QEMUS390FLICState *flic = QEMU_S390_FLIC(fs);
+
+ switch (mode) {
+ case SIC_IRQ_MODE_ALL:
+ flic->simm &= ~AIS_MODE_MASK(isc);
+ flic->nimm &= ~AIS_MODE_MASK(isc);
+ break;
+ case SIC_IRQ_MODE_SINGLE:
+ flic->simm |= AIS_MODE_MASK(isc);
+ flic->nimm &= ~AIS_MODE_MASK(isc);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static void qemu_s390_flic_reset(DeviceState *dev)
+{
+ QEMUS390FLICState *flic = QEMU_S390_FLIC(dev);
+
+ flic->simm = 0;
+ flic->nimm = 0;
+}
+
static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
{
+ DeviceClass *dc = DEVICE_CLASS(oc);
S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
+ dc->reset = qemu_s390_flic_reset;
fsc->register_io_adapter = qemu_s390_register_io_adapter;
fsc->io_adapter_map = qemu_s390_io_adapter_map;
fsc->add_adapter_routes = qemu_s390_add_adapter_routes;
fsc->release_adapter_routes = qemu_s390_release_adapter_routes;
fsc->clear_io_irq = qemu_s390_clear_io_flic;
+ fsc->modify_ais_mode = qemu_s390_modify_ais_mode;
}
static Property s390_flic_common_properties[] = {
@@ -98,12 +130,15 @@ static Property s390_flic_common_properties[] = {
static void s390_flic_common_realize(DeviceState *dev, Error **errp)
{
- uint32_t max_batch = S390_FLIC_COMMON(dev)->adapter_routes_max_batch;
+ S390FLICState *fs = S390_FLIC_COMMON(dev);
+ uint32_t max_batch = fs->adapter_routes_max_batch;
if (max_batch > ADAPTER_ROUTES_MAX_GSI) {
error_setg(errp, "flic property adapter_routes_max_batch too big"
" (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI);
}
+
+ fs->ais_supported = true;
}
static void s390_flic_class_init(ObjectClass *oc, void *data)
diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
index 15ff534..55aa35f 100644
--- a/hw/intc/s390_flic_kvm.c
+++ b/hw/intc/s390_flic_kvm.c
@@ -20,6 +20,7 @@
#include "sysemu/kvm.h"
#include "hw/s390x/s390_flic.h"
#include "hw/s390x/adapter.h"
+#include "hw/s390x/css.h"
#include "trace.h"
#define FLIC_SAVE_INITIAL_SIZE getpagesize()
@@ -149,6 +150,26 @@ static int kvm_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
return rc ? -errno : 0;
}
+static int kvm_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,
+ uint16_t mode)
+{
+ KVMS390FLICState *flic = KVM_S390_FLIC(fs);
+ struct kvm_s390_ais_req req = {
+ .isc = isc,
+ .mode = mode,
+ };
+ struct kvm_device_attr attr = {
+ .group = KVM_DEV_FLIC_AISM,
+ .addr = (uint64_t)&req,
+ };
+
+ if (!fs->ais_supported) {
+ return -ENOSYS;
+ }
+
+ return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0;
+}
+
/**
* __get_all_irqs - store all pending irqs in buffer
* @flic: pointer to flic device state
@@ -406,6 +427,7 @@ typedef struct KVMS390FLICStateClass {
static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
{
+ S390FLICState *fs = S390_FLIC_COMMON(dev);
KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);
struct kvm_create_device cd = {0};
struct kvm_device_attr test_attr = {0};
@@ -438,6 +460,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
flic_state->clear_io_supported = !ioctl(flic_state->fd,
KVM_HAS_DEVICE_ATTR, test_attr);
+ fs->ais_supported = false;
return;
fail:
error_propagate(errp, errp_local);
@@ -446,10 +469,12 @@ fail:
static void kvm_s390_flic_reset(DeviceState *dev)
{
KVMS390FLICState *flic = KVM_S390_FLIC(dev);
+ S390FLICState *fs = S390_FLIC_COMMON(dev);
struct kvm_device_attr attr = {
.group = KVM_DEV_FLIC_CLEAR_IRQS,
};
int rc = 0;
+ uint8_t isc;
if (flic->fd == -1) {
return;
@@ -457,6 +482,16 @@ static void kvm_s390_flic_reset(DeviceState *dev)
flic_disable_wait_pfault(flic);
+ if (fs->ais_supported) {
+ for (isc = 0; isc <= MAX_ISC; isc++) {
+ rc = kvm_s390_modify_ais_mode(fs, isc, SIC_IRQ_MODE_ALL);
+ if (rc) {
+ error_report("Failed to reset ais mode for isc %d: %s",
+ isc, strerror(-rc));
+ }
+ }
+ }
+
rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
if (rc) {
trace_flic_reset_failed(errno);
@@ -479,6 +514,7 @@ static void kvm_s390_flic_class_init(ObjectClass *oc, void *data)
fsc->add_adapter_routes = kvm_s390_add_adapter_routes;
fsc->release_adapter_routes = kvm_s390_release_adapter_routes;
fsc->clear_io_irq = kvm_s390_clear_io_flic;
+ fsc->modify_ais_mode = kvm_s390_modify_ais_mode;
}
static const TypeInfo kvm_s390_flic_info = {
diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h
index d4145ad..f500184 100644
--- a/include/hw/s390x/s390_flic.h
+++ b/include/hw/s390x/s390_flic.h
@@ -44,7 +44,7 @@ typedef struct S390FLICState {
SysBusDevice parent_obj;
/* to limit AdapterRoutes.num_routes for compat */
uint32_t adapter_routes_max_batch;
-
+ bool ais_supported;
} S390FLICState;
#define S390_FLIC_COMMON_CLASS(klass) \
@@ -63,6 +63,7 @@ typedef struct S390FLICStateClass {
void (*release_adapter_routes)(S390FLICState *fs, AdapterRoutes *routes);
int (*clear_io_irq)(S390FLICState *fs, uint16_t subchannel_id,
uint16_t subchannel_nr);
+ int (*modify_ais_mode)(S390FLICState *fs, uint8_t isc, uint16_t mode);
} S390FLICStateClass;
#define TYPE_KVM_S390_FLIC "s390-flic-kvm"
@@ -73,8 +74,14 @@ typedef struct S390FLICStateClass {
#define QEMU_S390_FLIC(obj) \
OBJECT_CHECK(QEMUS390FLICState, (obj), TYPE_QEMU_S390_FLIC)
+#define SIC_IRQ_MODE_ALL 0
+#define SIC_IRQ_MODE_SINGLE 1
+#define AIS_MODE_MASK(isc) (0x80 >> isc)
+
typedef struct QEMUS390FLICState {
S390FLICState parent_obj;
+ uint8_t simm;
+ uint8_t nimm;
} QEMUS390FLICState;
void s390_flic_init(void);
--
2.7.4
next prev parent reply other threads:[~2017-07-14 11:05 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 10:40 [Qemu-devel] [PULL 00/40] s390x: fixes, enhancements for 2.10 softfreeze Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 01/40] s390x/kvm: Rework cmma management Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 02/40] linux-headers: update to 4.13-rc0 Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 03/40] s390x/migration: Storage attributes device Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 04/40] s390x/migration: Monitor commands for storage attributes Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 05/40] s390x/cpumodel: clean up spacing and comments Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 06/40] s390x/cpumodel: provide compat handling for new cpu features Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 07/40] s390x: add flags field for registering I/O adapter Christian Borntraeger
2017-07-14 10:40 ` Christian Borntraeger [this message]
2017-07-14 10:40 ` [Qemu-devel] [PULL 09/40] s390x/flic: introduce inject_airq callback Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 10/40] s390x/sic: realize SIC handling Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 11/40] s390x/css: update css_adapter_interrupt Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 12/40] s390x: add helper get_machine_class Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 13/40] s390x: add css_migration_enabled to machine class Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 14/40] s390x/css: add missing css state conditionally Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 15/40] s390x/css: add ORB to SubchDev Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 16/40] s390x/css: activate ChannelSubSys migration Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 17/40] s390x/css: use SubchDev.orb Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 18/40] pc-bios/s390-ccw: Move libc functions to separate header Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 19/40] pc-bios/s390-ccw: Move ebc2asc to sclp.c Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 20/40] pc-bios/s390-ccw: Move virtio-block related functions into a separate file Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 21/40] pc-bios/s390-ccw: Add a write() function for stdio Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 22/40] pc-bios/s390-ccw: Move byteswap functions to a separate header Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 23/40] pc-bios/s390-ccw: Remove unused structs from virtio.h Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 24/40] pc-bios/s390-ccw: Add code for virtio feature negotiation Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 25/40] roms/SLOF: Update submodule to latest status Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 26/40] pc-bios/s390-ccw: Add core files for the network bootloading program Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 27/40] pc-bios/s390-ccw: Add virtio-net driver code Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 28/40] pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP load Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 29/40] pc-bios/s390: add s390-netboot.img Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 30/40] pc-bios/s390: rebuild s390-ccw.img Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 31/40] s390x: initialize cpu firstly Christian Borntraeger
2017-07-14 10:40 ` [Qemu-devel] [PULL 32/40] s390x/cpumodel: add zpci, aen and ais facilities Christian Borntraeger
2017-07-17 17:23 ` David Hildenbrand
2017-07-17 18:12 ` Christian Borntraeger
2017-07-18 14:49 ` David Hildenbrand
2017-07-14 10:41 ` [Qemu-devel] [PULL 33/40] s390x/flic: migrate ais states Christian Borntraeger
2017-09-20 12:39 ` Christian Borntraeger
2017-09-20 12:53 ` [Qemu-devel] block ais migration for machines <= 2.9 Christian Borntraeger
2017-09-20 12:59 ` Cornelia Huck
2017-09-20 14:04 ` Christian Borntraeger
2017-09-20 16:04 ` Dr. David Alan Gilbert
2017-09-21 3:40 ` Yi Min Zhao
2017-09-21 7:41 ` Christian Borntraeger
2017-09-20 16:20 ` no-reply
2017-07-14 10:41 ` [Qemu-devel] [PULL 34/40] s390x/cpumodel: wire up new hardware features Christian Borntraeger
2017-07-17 17:30 ` David Hildenbrand
2017-07-17 18:14 ` Christian Borntraeger
2017-07-18 14:52 ` David Hildenbrand
2017-07-14 10:41 ` [Qemu-devel] [PULL 35/40] s390x/cpumodel: we are always in zarchitecture mode Christian Borntraeger
2017-07-17 17:33 ` David Hildenbrand
2017-07-17 17:36 ` David Hildenbrand
2017-07-14 10:41 ` [Qemu-devel] [PULL 36/40] s390x/cpumodel: add esop/esop2 to z12 model Christian Borntraeger
2017-07-14 10:41 ` [Qemu-devel] [PULL 37/40] s390x/kvm: Enable KSS facility for nested virtualization Christian Borntraeger
2017-07-17 17:35 ` David Hildenbrand
2017-07-17 18:12 ` Christian Borntraeger
2017-07-14 10:41 ` [Qemu-devel] [PULL 38/40] s390x/kvm: enable guarded storage Christian Borntraeger
2017-07-14 10:41 ` [Qemu-devel] [PULL 39/40] s390x/arch_dump: also dump guarded storage control block Christian Borntraeger
2017-07-14 10:41 ` [Qemu-devel] [PULL 40/40] s390x/gdb: add gs registers Christian Borntraeger
2017-07-14 14:32 ` [Qemu-devel] [PULL 00/40] s390x: fixes, enhancements for 2.10 softfreeze Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1500028867-134709-9-git-send-email-borntraeger@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=agraf@suse.de \
--cc=cohuck@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=sherrylf@linux.vnet.ibm.com \
--cc=thuth@redhat.com \
--cc=zyimin@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).