Received: by 10.213.65.68 with SMTP id h4csp3531872imn; Tue, 3 Apr 2018 06:39:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/NJXL6cf2ozlea3o4IW4Nq/lneQSVYyMYTa+w8UvetYRjsITNRWBCgXXVKdr2Kah4KxyIJ X-Received: by 10.101.92.138 with SMTP id a10mr9195787pgt.64.1522762778732; Tue, 03 Apr 2018 06:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522762778; cv=none; d=google.com; s=arc-20160816; b=L57In8lJHpa/JxZQFwkoHNjHLpnAIOeocSW8v+fdWuZ/MVVWzz1MccKhLS71VmGxhA GVGMEMNJtE3xpUwJpaulvnFbiBkSU3Hbh8llvbkH9jieXkfQV4AA/6+MEJ1rVYRd9c62 lS5KLTdHRfAWWavU87JJvGJRIbVmHt4eF/IBTZ2T9nz+KPfJF2c3XFHOtdOdBRfMRvZL F8i038NF8nJS4V5YmqvqHYkOkGGvqVnmm7ls0igdNGlDB3Nl+ypUUWsgvpwML/v31WRS rTyeZPVULbL8btcohZD5b3ytE+TlmYwNj13b0WvpgvyiQy79S0M+10tsrSinY6A7TBy4 lwHg== 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:arc-authentication-results; bh=3OqOq3wILFUmulCkhfNtu33TikcqwC0ehDKKrQZFfLI=; b=hzzV3x7MpA+NFLPvDAZsWemSzM+s+MPnHtpQ10nSWWdoIakZ/v2WY970D8M+a8AHP5 D7loG/aoTe92apw8QrHfzFqKb89/Bkkwi8TizD8k79Nk3rNqxY4ci2sgjQFPohkRb8fa ernSfMFC68OMyzfBCbHoK7d+IXITy9g34hv01PG+RAvxk52w4qCc32sUllPn4LuByeYJ FRGE+fSh5gfHsT0QJg4qkauv2DiouSNFCnb3GBrnuDdmQcaIXZRTpqTPwmK+xLY4k5Gw +3l8wxJ/Q/G/l9dKwMyRkpddKIJ+TFLCWoxJKTq/00jaoBsCLawHCcdmm/zqtOY12N4/ QNYA== 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 4-v6si555600pld.371.2018.04.03.06.39.25; Tue, 03 Apr 2018 06:39:38 -0700 (PDT) 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 S1750852AbeDCNiT (ORCPT + 99 others); Tue, 3 Apr 2018 09:38:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54312 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750714AbeDCNiR (ORCPT ); Tue, 3 Apr 2018 09:38:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0641406804F; Tue, 3 Apr 2018 13:38:16 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBA092026E0E; Tue, 3 Apr 2018 13:38:13 +0000 (UTC) Date: Tue, 3 Apr 2018 15:38:11 +0200 From: Cornelia Huck To: Tony Krowiak Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, mjrosato@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, thuth@redhat.com, pasic@linux.vnet.ibm.com, berrange@redhat.com, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com Subject: Re: [PATCH v3 07/14] KVM: s390: interfaces to configure/deconfigure guest's AP matrix Message-ID: <20180403153811.64c16788.cohuck@redhat.com> In-Reply-To: <474b7d18-69ea-631f-214c-f9345119e537@linux.vnet.ibm.com> References: <1521051954-25715-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1521051954-25715-8-git-send-email-akrowiak@linux.vnet.ibm.com> <20180403130758.43851026.cohuck@redhat.com> <474b7d18-69ea-631f-214c-f9345119e537@linux.vnet.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.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 03 Apr 2018 13:38:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 03 Apr 2018 13:38:16 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Apr 2018 09:17:59 -0400 Tony Krowiak wrote: > On 04/03/2018 07:07 AM, Cornelia Huck wrote: > > On Wed, 14 Mar 2018 14:25:47 -0400 > > Tony Krowiak wrote: > > > >> Provides interfaces to assign AP adapters, usage domains > >> and control domains to a KVM guest. > >> > >> A KVM guest is started by executing the Start Interpretive Execution (SIE) > >> instruction. The SIE state description is a control block that contains the > >> state information for a KVM guest and is supplied as input to the SIE > >> instruction. The SIE state description has a satellite structure called the > >> Crypto Control Block (CRYCB). The CRYCB contains three bitmask fields > >> identifying the adapters, queues (domains) and control domains assigned to > >> the KVM guest: > >> > >> * The AP Adapter Mask (APM) field identifies the AP adapters assigned to > >> the KVM guest > >> > >> * The AP Queue Mask (AQM) field identifies the AP queues assigned to > >> the KVM guest. Each AP queue is connected to a usage domain within > >> an AP adapter. > >> > >> * The AP Domain Mask (ADM) field identifies the control domains > >> assigned to the KVM guest. > >> > >> Each adapter, queue (usage domain) and control domain are identified by > >> a number from 0 to 255. The bits in each mask, from most significant to > >> least significant bit, correspond to the numbers 0-255. When a bit is > >> set, the corresponding adapter, queue (usage domain) or control domain > >> is assigned to the KVM guest. > >> > >> This patch will set the bits in the APM, AQM and ADM fields of the > >> CRYCB referenced by the KVM guest's SIE state description. The process > >> used is: > >> > >> 1. Verify that the bits to be set do not exceed the maximum bit > >> number for the given mask. > >> > >> 2. Verify that the APQNs that can be derived from the intersection > >> of the bits set in the APM and AQM fields of the KVM guest's CRYCB > >> are not assigned to any other KVM guest running on the same linux > >> host. > >> > >> 3. Set the APM, AQM and ADM in the CRYCB according to the matrix > >> configured for the mediated matrix device via its sysfs > >> adapter, domain and control domain attribute files respectively. > >> > >> Signed-off-by: Tony Krowiak > >> --- > >> arch/s390/include/asm/kvm-ap.h | 36 +++++ > >> arch/s390/kvm/kvm-ap.c | 268 +++++++++++++++++++++++++++++++++ > >> drivers/s390/crypto/vfio_ap_ops.c | 19 +++ > >> drivers/s390/crypto/vfio_ap_private.h | 4 + > >> 4 files changed, 327 insertions(+), 0 deletions(-) > >> > >> diff --git a/arch/s390/kvm/kvm-ap.c b/arch/s390/kvm/kvm-ap.c > >> index a2c6ad2..eb365e2 100644 > >> --- a/arch/s390/kvm/kvm-ap.c > >> +++ b/arch/s390/kvm/kvm-ap.c > >> @@ -8,9 +8,129 @@ > >> > >> #include > >> #include > >> +#include > >> > >> #include "kvm-s390.h" > >> > >> +static inline void kvm_ap_clear_crycb_masks(struct kvm *kvm) > >> +{ > >> + int crycb_fmt = kvm->arch.crypto.crycbd & CRYCB_FORMAT_MASK; > >> + > >> + if (crycb_fmt == CRYCB_FORMAT2) > >> + memset(&kvm->arch.crypto.crycb->apcb1, 0, > >> + sizeof(kvm->arch.crypto.crycb->apcb1)); > >> + else > >> + memset(&kvm->arch.crypto.crycb->apcb0, 0, > >> + sizeof(kvm->arch.crypto.crycb->apcb0)); > >> +} > > Should that rather be a switch/case? If there's a CRYCB_FORMAT3 in the > > future, I'd think that it's more likely that it uses apcb1 and not > > apcb0. Can't comment further without the architecture, obviously. > Maybe we should just clear both structures without regard to the CRYCB > format. Yes; but my concern applies to the other checks for CRYCB_FORMAT2 as well (snipped).