From patchwork Thu Feb 7 12:20:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 218907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 282E82C029A for ; Thu, 7 Feb 2013 23:21:14 +1100 (EST) Received: from localhost ([::1]:35000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3QTX-0004ms-K7 for incoming@patchwork.ozlabs.org; Thu, 07 Feb 2013 07:21:11 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3QTK-0004lg-GE for qemu-devel@nongnu.org; Thu, 07 Feb 2013 07:21:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U3QTI-0002ot-Tn for qemu-devel@nongnu.org; Thu, 07 Feb 2013 07:20:58 -0500 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:45530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3QTI-0002oD-Lb for qemu-devel@nongnu.org; Thu, 07 Feb 2013 07:20:56 -0500 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Feb 2013 12:18:26 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 7 Feb 2013 12:18:25 -0000 Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r17CKiLG24117458 for ; Thu, 7 Feb 2013 12:20:44 GMT Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r17CKq2L016503 for ; Thu, 7 Feb 2013 05:20:52 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r17CKp2R016469; Thu, 7 Feb 2013 05:20:52 -0700 From: Cornelia Huck To: Alexander Graf Date: Thu, 7 Feb 2013 13:20:51 +0100 Message-Id: <1360239651-52283-3-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1360239651-52283-1-git-send-email-cornelia.huck@de.ibm.com> References: <1360239651-52283-1-git-send-email-cornelia.huck@de.ibm.com> x-cbid: 13020712-1948-0000-0000-0000043D4D6F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.110 Cc: Christian Borntraeger , Jens Freimann , qemu-devel Subject: [Qemu-devel] [PATCH 2/2] s390: Fix handling of iscs. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There are two ways to express an interruption subclass: - As a bitmask, as used in cr6. - As a number, as used in the I/O interruption word. Unfortunately, we have treated to I/O interruption word as if it contained the bitmask as well, which went unnoticed so far as - (queued-for-next) kvm made the same mistake, and - Linux guest kernels don't check the isc value in the I/O interruption word for subchannel interrupts. Make sure that we treat the I/O interruption word correctly. Signed-off-by: Cornelia Huck --- hw/s390x/css.c | 4 ++-- target-s390x/cpu.h | 2 +- target-s390x/helper.c | 5 ++++- target-s390x/ioinst.h | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 3244201..85f6f22 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -87,7 +87,7 @@ static void css_inject_io_interrupt(SubchDev *sch) css_build_subchannel_id(sch), sch->schid, sch->curr_status.pmcw.intparm, - (0x80 >> isc) << 24); + isc << 27); } void css_conditional_io_interrupt(SubchDev *sch) @@ -111,7 +111,7 @@ void css_conditional_io_interrupt(SubchDev *sch) css_build_subchannel_id(sch), sch->schid, sch->curr_status.pmcw.intparm, - (0x80 >> isc) << 24); + isc << 27); } } diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 01e59b9..fa8dfe0 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -1001,7 +1001,7 @@ static inline void cpu_inject_io(S390CPU *cpu, uint16_t subchannel_id, uint32_t io_int_parm, uint32_t io_int_word) { CPUS390XState *env = &cpu->env; - int isc = ffs(io_int_word << 2) - 1; + int isc = IO_INT_WORD_ISC(io_int_word); if (env->io_index[isc] == MAX_IO_QUEUE - 1) { /* ugh - can't queue anymore. Let's drop. */ diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 9f9088b..7626831 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -628,6 +628,8 @@ static void do_io_interrupt(CPUS390XState *env) } for (isc = 0; isc < ARRAY_SIZE(env->io_index); isc++) { + uint64_t isc_bits; + if (env->io_index[isc] < 0) { continue; } @@ -637,7 +639,8 @@ static void do_io_interrupt(CPUS390XState *env) } q = &env->io_queue[env->io_index[isc]][isc]; - if (!(env->cregs[6] & q->word)) { + isc_bits = ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word)); + if (!(env->cregs[6] & isc_bits)) { disable = 0; continue; } diff --git a/target-s390x/ioinst.h b/target-s390x/ioinst.h index d5a43f4..7bed291 100644 --- a/target-s390x/ioinst.h +++ b/target-s390x/ioinst.h @@ -209,6 +209,9 @@ typedef struct IOIntCode { #define IOINST_SCHID_SSID(_schid) ((_schid & 0x00060000) >> 17) #define IOINST_SCHID_NR(_schid) (_schid & 0x0000ffff) +#define IO_INT_WORD_ISC(_int_word) ((_int_word & 0x38000000) >> 24) +#define ISC_TO_ISC_BITS(_isc) ((0x80 >> _isc) << 24) + int ioinst_disassemble_sch_ident(uint32_t value, int *m, int *cssid, int *ssid, int *schid); int ioinst_handle_xsch(CPUS390XState *env, uint64_t reg1);