Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp143798imu; Wed, 19 Dec 2018 15:20:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/V2ozRkHJJwP/oir0PbFgIlmiCvUzXnVJ2euVFOaV2FlyIyns4f/0jv3B5TNHmw2M7/2spV X-Received: by 2002:a63:7044:: with SMTP id a4mr4533583pgn.359.1545261641979; Wed, 19 Dec 2018 15:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545261641; cv=none; d=google.com; s=arc-20160816; b=SCF3X8BryDGaOGPCrrBJnALb+lp/W1s4yLn8s0h2jhN16qtuY0DZP2vsGOsIZEHeQn sN8sBrsrKBMWy8YYYF3uML3XnI/r/GeuVgT6y+vRbcD8oWqrBxVaN2ayjxPO0DBHSXH4 LJhb14r0ZuL3jI4TsZSLUx2mz1T+RPwJZz9xui39OSJbUwQC7WqI76afZPzcM9sAYVe8 a/VIRB+EHQlS/QLCczylofoBKP+zxid9DKVfcPRPPvkwCzwBvPWPl0cxvqDYjMNZ875b D7vKEyUUt7CYQKLsGQ2sRJK9aaMGGf54L3kmvuFKOiw8g/K2yoiBMz2HcDYJhWT43Ujh fhpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=z68QVJzFvcKtoYQAt2kLglrCQXCiL3s/SA5f/os+qyo=; b=0iZj7c15qpN2dCkqC6lxBlwiwb0I+DvMa+qBI57lwhlRR4qcqAld7kRZnUJWtuhgzU CKX2R41M0PG8TMyc1XS8IePWBUC4gWTdDBZFSw5RWJvkHVWyJA9cE47WrX56YSVjvAwC F3oCuQM/T8SEFBf45rg15+1B3HlJZBDsnwwDuj4+qc0qOItsWcrZL5xsGLsD7rrredYo jIqIwO2ZRWUbWVb29PV3yEIcGGjfRhd0CysS4PVdcCnGlRcupd/VTy8Mny5yBUA0NbWA ArycVoBRiQDqbnIFZrVw+9bctvlHKBRWzfc8G4pTmwOK72c5ZRY1igBjUepENbVVCulI PPFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si16436015pgg.382.2018.12.19.15.19.56; Wed, 19 Dec 2018 15:20:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730572AbeLSTSZ (ORCPT + 99 others); Wed, 19 Dec 2018 14:18:25 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45942 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729677AbeLSTSX (ORCPT ); Wed, 19 Dec 2018 14:18:23 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wBJIwfA1036594 for ; Wed, 19 Dec 2018 14:18:22 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pfte359q9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 19 Dec 2018 14:18:22 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Dec 2018 19:18:19 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 19 Dec 2018 19:18:16 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wBJJIFoF61735024 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 19 Dec 2018 19:18:15 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDE2F52051; Wed, 19 Dec 2018 19:18:14 +0000 (GMT) Received: from s38lp84.lnxne.boe (unknown [9.152.108.100]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 934505204E; Wed, 19 Dec 2018 19:18:14 +0000 (GMT) From: Michael Mueller To: KVM Mailing List Cc: Linux-S390 Mailing List , linux-kernel@vger.kernel.org, kvm390-list@tuxmaker.boeblingen.de.ibm.com, Martin Schwidefsky , Heiko Carstens , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Halil Pasic , Pierre Morel , Michael Mueller Subject: [PATCH v5 11/15] KVM: s390: restore IAM in get_ipm() when IPM is clean Date: Wed, 19 Dec 2018 20:17:52 +0100 X-Mailer: git-send-email 2.13.4 In-Reply-To: <20181219191756.57973-1-mimu@linux.ibm.com> References: <20181219191756.57973-1-mimu@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18121919-0016-0000-0000-00000238D576 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18121919-0017-0000-0000-000032912D03 Message-Id: <20181219191756.57973-12-mimu@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-19_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812190150 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch adds the parameter irq_flags and allows to restore the Interruption Alert Mask (IAM) in the GISA atomically while guaranteeing the IPM is clean. The function returns the IPM of the GISA. If the returned value is 0x00 and the IRQ_FLAG_IAM was set, the IAM has been restored. New irq flag: IRQ_FLAG_IAM: When set, the IAM is restored if no ISC bit is set in the IPM, i.e. no new airqs are pending. The test and restore operations are done atomically. Signed-off-by: Michael Mueller --- arch/s390/kvm/interrupt.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 1cc3ad2e6c7e..8307717e3caf 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -37,6 +37,7 @@ #define IRQ_FLAG_LOCAL 0x8000 /* include local interruption pending mask */ #define IRQ_FLAG_FLOATING 0x4000 /* include float interruption pending mask */ #define IRQ_FLAG_GISA 0x2000 /* include GISA interruption pending mask */ +#define IRQ_FLAG_IAM 0x0080 /* when set try to restore IAM */ #define IRQ_MASK_ALL (IRQ_FLAG_LOCAL | IRQ_FLAG_FLOATING | IRQ_FLAG_GISA) #define IRQ_MASK_NO_GISA (IRQ_MASK_ALL & ~IRQ_FLAG_GISA) @@ -253,9 +254,32 @@ static inline void set_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc) set_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa); } -static inline u8 get_ipm(struct kvm_s390_gisa *gisa) +static inline u8 get_ipm(struct kvm_s390_gisa *gisa, u16 irq_flags) { - return READ_ONCE(gisa->ipm); + u64 word, _word; + u8 ipm; + + if (!(irq_flags & IRQ_FLAG_IAM)) + return READ_ONCE(gisa->ipm); + + do { + word = READ_ONCE(gisa->u64.word[0]); + ipm = word >> 24; + /* If the GISA is in the alert list, return the IPM. */ + if ((u64)gisa != word >> 32) + return ipm; + /* If the IPM is dirty, return the IPM. */ + if (ipm) + return ipm; + /* + * Try to restore the IAM or loop, if the IPM is dirty + * again or the GISA has been inserted into the alert list. + */ + _word = (word & ~0xffUL) | + container_of(gisa, struct sie_page2, gisa)->kvm->arch.iam; + } while (cmpxchg(&gisa->u64.word[0], word, _word) != _word); + + return 0; } static inline void clear_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc) @@ -277,7 +301,7 @@ static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu, u16 irq_flags) if (irq_flags & IRQ_FLAG_FLOATING) pending_irqs |= vcpu->kvm->arch.float_int.pending_irqs; if (irq_flags & IRQ_FLAG_GISA) - pending_irqs |= get_ipm(vcpu->kvm->arch.gisa) << + pending_irqs |= get_ipm(vcpu->kvm->arch.gisa, irq_flags) << IRQ_PEND_IO_ISC_7; return pending_irqs; } @@ -1574,7 +1598,7 @@ static int get_top_gisa_isc(struct kvm *kvm, u64 isc_mask, u32 schid) if (!kvm->arch.gisa) goto out; - active_mask = (isc_mask & get_ipm(kvm->arch.gisa) << 24) << 32; + active_mask = (isc_mask & get_ipm(kvm->arch.gisa, IRQ_FLAG_IAM) << 24) << 32; while (active_mask) { isc = __fls(active_mask) ^ (BITS_PER_LONG - 1); if (tac_ipm_gisc(kvm->arch.gisa, isc)) @@ -2060,7 +2084,7 @@ static int get_all_floating_irqs(struct kvm *kvm, u8 __user *usrbuf, u64 len) max_irqs = len / sizeof(struct kvm_s390_irq); if (kvm->arch.gisa && - get_ipm(kvm->arch.gisa)) { + get_ipm(kvm->arch.gisa, IRQ_FLAG_IAM)) { for (i = 0; i <= MAX_ISC; i++) { if (n == max_irqs) { /* signal userspace to try again */ -- 2.13.4