Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7418870imu; Thu, 31 Jan 2019 09:46:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN6ee3kYlAXRor3lY5K+LYtKfsGVLnRdmfwX3p9czr4vV+MPMAm48+U2gPAWxbsG6pF5j/oO X-Received: by 2002:a17:902:e08b:: with SMTP id cb11mr36105928plb.263.1548956804609; Thu, 31 Jan 2019 09:46:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548956804; cv=none; d=google.com; s=arc-20160816; b=E1VecUXLki/NfR9SJznls9LplkS3ofZZVB6C9QszybC7DsXCjPQJFqPiKSHtFSfPh1 uYaEYe8q5skLMr2xUaaXaNHPPwyecvsFVOcvj8UvA3mc3WpSoyeX6xPTjoR+qM35cZQV pek7Mo48NFV2489+uw0pAfHnTMiTH4I4QTo5Uu5/I0Ozh+QUAg3xCf3IvBYsV1osXS+7 pa3ZXMIeNgdDq6zy5eLkGe/4IJud5Kgnqx4ukxUmPxRY+TfePYPfC8nNc/oRpM2uprLu EnG2K+9do9GajV+hha1Db7MCXECP5obk3vFTzJi3vMoBmaElBDzqN4QZgHch91EOIW/g vEgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=bjGgQ2qDgmmoEhRPjAYI2pj0U4ED8T9E3lIADVs048s=; b=bhRODiDhBY6o0b4WLZuknUMVE2nqHr0ayLTD0LJnxSAsTjprxJ4+wkLugAPif8ZLTn LHChlWaiiqBhgL3e1ZtmOwpMsEYpP01UHYHcA8F23Vbf64UXq/C5v5aDHuHXJ6xPdQX2 mQszzBfn305GyFWBqzHnU9po0AAiW1Phdzcq/zG5ShX5Iu9IaP3HePx41i/qsxxB4qo4 CbzziCC+RhgcZtOFPludupNkGnvJcKVeGOkKeJz1JKCoqK/u1o9In78+Eu00v8Idwl57 1gm31nsGkobkwaw0XQN59Ros2IjE0eaoEra5uO21V4qN89/KRk9IE3cdMsPRjgQ+13Sx gAmg== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j132si5128064pfc.84.2019.01.31.09.46.29; Thu, 31 Jan 2019 09:46:44 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbfAaRlY (ORCPT + 99 others); Thu, 31 Jan 2019 12:41:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51088 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725822AbfAaRlY (ORCPT ); Thu, 31 Jan 2019 12:41:24 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD134DF872; Thu, 31 Jan 2019 17:41:23 +0000 (UTC) Received: from gondolin (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id D89F660BF7; Thu, 31 Jan 2019 17:41:16 +0000 (UTC) Date: Thu, 31 Jan 2019 18:41:13 +0100 From: Cornelia Huck To: Michael Mueller Cc: KVM Mailing List , Linux-S390 Mailing List , linux-kernel@vger.kernel.org, Martin Schwidefsky , Heiko Carstens , Christian Borntraeger , Janosch Frank , David Hildenbrand , Halil Pasic , Pierre Morel Subject: Re: [PATCH v7 11/15] KVM: s390: add functions to (un)register GISC with GISA Message-ID: <20190131184113.15dcf927.cohuck@redhat.com> In-Reply-To: <20190131085247.13826-12-mimu@linux.ibm.com> References: <20190131085247.13826-1-mimu@linux.ibm.com> <20190131085247.13826-12-mimu@linux.ibm.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 31 Jan 2019 17:41:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 31 Jan 2019 09:52:42 +0100 Michael Mueller wrote: > Add the Interruption Alert Mask (IAM) to the architecture specific > kvm struct. This mask in the GISA is used to define for which ISC > a GIB alert will be issued. > > The functions kvm_s390_gisc_register() and kvm_s390_gisc_unregister() > are used to (un)register a GISC (guest ISC) with a virtual machine and > its GISA. > > Upon successful completion, kvm_s390_gisc_register() returns the > ISC to be used for GIB alert interruptions. A negative return code > indicates an error during registration. > > Theses functions will be used by other adapter types like AP and PCI to > request pass-through interruption support. > > Signed-off-by: Michael Mueller > Acked-by: Pierre Morel > Acked-by: Halil Pasic > --- > arch/s390/include/asm/kvm_host.h | 13 +++++ > arch/s390/kvm/interrupt.c | 112 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 125 insertions(+) > +/** > + * kvm_s390_gisc_register - register a guest ISC > + * > + * @kvm: the kernel vm to work with > + * @gisc: the guest interruption sub class to register > + * > + * The function extends the vm specific alert mask to use. > + * The effectve IAM mask in the GISA is updated as well Typo: s/effectve/effective/ > + * in case the GISA is not part of the GIB alert list. > + * It will be updated latest when the IAM gets restored > + * by gisa_get_ipm_or_restore_iam(). > + * > + * Returns: the nonspecific ISC (NISC) the gib alert mechanism > + * has registered with the channel subsystem. > + * -ENODEV in case the vm uses no GISA > + * -ERANGE in case the guest ISC is invalid > + */ > +int kvm_s390_gisc_register(struct kvm *kvm, u32 gisc) > +{ > + struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; > + > + if (!gi->origin) > + return -ENODEV; > + if (gisc > MAX_ISC) > + return -ERANGE; > + > + spin_lock(&gi->alert.ref_lock); > + gi->alert.ref_count[gisc]++; > + if (gi->alert.ref_count[gisc] == 1) { > + gi->alert.mask |= 0x80 >> gisc; > + gisa_set_iam(gi->origin, gi->alert.mask); > + } > + spin_unlock(&gi->alert.ref_lock); > + > + return gib->nisc; > +} > +EXPORT_SYMBOL_GPL(kvm_s390_gisc_register); > + > +/** > + * kvm_s390_gisc_unregister - unregister a guest ISC > + * > + * @kvm: the kernel vm to work with > + * @gisc: the guest interruption sub class to register > + * > + * The function reduces the vm specific alert mask to use. > + * The effectve IAM mask in the GISA is updated as well Same here. > + * in case the GISA is not part of the GIB alert list. > + * It will be updated latest when the IAM gets restored > + * by gisa_get_ipm_or_restore_iam(). > + * > + * Returns: the nonspecific ISC (NISC) the gib alert mechanism > + * has registered with the channel subsystem. > + * -ENODEV in case the vm uses no GISA > + * -ERANGE in case the guest ISC is invalid > + * -EINVAL in case the guest ISC is not registered > + */ > +int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc) > +{ > + struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int; > + int rc = 0; > + > + if (!gi->origin) > + return -ENODEV; > + if (gisc > MAX_ISC) > + return -ERANGE; > + > + spin_lock(&gi->alert.ref_lock); > + if (gi->alert.ref_count[gisc] == 0) { > + rc = -EINVAL; > + goto out; > + } > + gi->alert.ref_count[gisc]--; > + if (gi->alert.ref_count[gisc] == 0) { > + gi->alert.mask &= ~(0x80 >> gisc); > + gisa_set_iam(gi->origin, gi->alert.mask); > + } > +out: > + spin_unlock(&gi->alert.ref_lock); > + > + return rc; > +} > +EXPORT_SYMBOL_GPL(kvm_s390_gisc_unregister); > + > void kvm_s390_gib_destroy(void) > { > if (!gib) Otherwise, looks good AFAICS. Reviewed-by: Cornelia Huck