Received: by 10.192.165.148 with SMTP id m20csp732460imm; Wed, 2 May 2018 07:59:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrqEjzYSN1HCUmvQjNAooMFf6dHM/0M/apIGIiTI9GqrcU4OCz6PSw/+d1d90kRMm2/YB9u X-Received: by 2002:a17:902:5a5:: with SMTP id f34-v6mr20192839plf.288.1525273184893; Wed, 02 May 2018 07:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525273184; cv=none; d=google.com; s=arc-20160816; b=cf2LR6OTiEMhduChY7SjXW/e9TS7Vs2YJLtLbedtAoyN1TP7eST/UYU7Ile4eVyKg6 LMd4CnnANBP1QypmLBfYJiTJBA7PvbJwZRn3NpvSv0TxEGPfqgqpDX7LA46teFytWb0N mWH2MMW9xSsDMTgJl/0SIpGQlH6d+vy4Gi/WD6Sy/fW5p2rXbKNn6FRRMMmNDhLxZj/w DB9nZg5a/qyiMX1lIW3wN5lW8T2cmDmTkmXodJFrHfBBuGX5LtDOkN+hafCf4kuAPW2O /N+b2fGSrsK/5WzHf/wDqsLZ+oNzTryN2Bfig45x9wo0h15RkZ4L/WMMvgECCYbltgv2 /bNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject:arc-authentication-results; bh=G3aKCCSdtF29gfc8oz77wPLf0i+mZ6BOTzRbi3zYtkU=; b=KT27kp2p+Bl0N/a2iPSZAm1UwRPHpgeAoTTJZVQH2jyBmryqC0LcRjLV0uqw96qveY 6kgsmx8+q935ieLniucOIWwwpGDqGMv1KUIcB0haa6F5sWX80wdvQaN5ZMHkr4Z0xTU0 n/eLXy4DJAivqyXSX3nzplgC3nWVOOwj14TVEuf9qhbGc39hoxNadtUFVZ1IprVlx38x QGaYYAyIQIhPLasZhAxpa/G76tUGrygcpFlN0NnfyOI/XWgJWEdmUwQf+Krg/g/0w+Bd GS6gQy6ZmKP9qpZ2O6z5lv1uMpmGgz+hCCxLQw1e1kUXtVV49dZ7HU86FrF35CSmdwqt n9QQ== 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 o9-v6si3541808pgn.199.2018.05.02.07.59.29; Wed, 02 May 2018 07:59:44 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbeEBO57 (ORCPT + 99 others); Wed, 2 May 2018 10:57:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43200 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525AbeEBO5z (ORCPT ); Wed, 2 May 2018 10:57:55 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w42Esk3j064315 for ; Wed, 2 May 2018 10:57:55 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hqf1c1kuu-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 02 May 2018 10:57:54 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 May 2018 15:57:49 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 2 May 2018 15:57:47 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w42EvjiX66781346; Wed, 2 May 2018 14:57:45 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F13852041; Wed, 2 May 2018 14:48:13 +0100 (BST) Received: from [9.152.224.146] (unknown [9.152.224.146]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id A38AD52043; Wed, 2 May 2018 14:48:12 +0100 (BST) Subject: Re: [PATCH v4 08/15] KVM: s390: interfaces to (de)configure guest's AP matrix To: Tony Krowiak , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.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 References: <1523827345-11600-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1523827345-11600-9-git-send-email-akrowiak@linux.vnet.ibm.com> <99f4752a-1358-61e4-bf9e-5672b2d4036f@linux.vnet.ibm.com> <0f47c442-47b8-ee57-d014-5200c59125d7@linux.vnet.ibm.com> From: Pierre Morel Date: Wed, 2 May 2018 16:57:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <0f47c442-47b8-ee57-d014-5200c59125d7@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18050214-0044-0000-0000-0000054E2CCB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050214-0045-0000-0000-0000288F4DE3 Message-Id: <54e4c3ef-0750-981b-7b0e-6b18d1a77c3c@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-02_05:,, 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=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805020123 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/04/2018 18:21, Tony Krowiak wrote: > On 04/23/2018 09:46 AM, Pierre Morel wrote: >> On 15/04/2018 23:22, Tony Krowiak wrote: >>> Provides interfaces to assign AP adapters, usage domains >>> and control domains to a KVM guest. >>> ... >>> +/** >>> + * kvm_ap_matrix_create >>> + * >>> + * Create an AP matrix to hold a configuration of AP adapters, >>> domains and >>> + * control domains. >>> + * >>> + * @ap_matrix: holds the matrix that is created >>> + * >>> + * Returns 0 if the matrix is successfully created. Returns an >>> error if an APQN >>> + * derived from the cross product of the AP adapter IDs and AP >>> queue indexes >>> + * comprising the AP matrix is configured for another guest. >>> + */ >>> +int kvm_ap_matrix_create(struct kvm_ap_matrix **ap_matrix); >> >> why not simply return the pointer? > > The function returns a value indicating the reason a matrix could not > be created. > Returning a NULL pointer provides no clue as to why the call failed. That is why the ERR_PTR exist :) ... >>> + * Returns 0 if the APQNs are valid, otherwise; returns -EBUSY. >>> + */ >>> +static int kvm_ap_validate_queue_sharing(struct kvm *kvm, >>> +                     struct kvm_ap_matrix *matrix) >>> +{ >>> +    struct kvm *vm; >>> +    unsigned long *apm, *aqm; >>> +    unsigned long apid, apqi; >>> + >>> + >>> +    /* No other VM may share an AP Queue with the input VM */ >> >> I wonder if these functions and structures should really belong to KVM. >> The only have sense with the VFIO driver. >> My opinion is that they belong there, in the VFIO driver code. > > I disagree for two reasons: > > 1. The vfio_ap driver should not have to know how to configure the KVM >    guest's matrix nor anything else about KVM for that matter. > > 2. The interfaces and structures defined in kvm-ap.h and implemented > in kvm-ap.c don't have anything to do with VFIO and can stand alone >    to be used by any client code to configure a guest's matrix. Doing this you will have to change KVM if the AP VFIO matrix protocol to access the queues change. i.e. suppose some day the queues may be shared between guests. ... >>> +static int kvm_ap_matrix_apm_create(struct kvm_ap_matrix *ap_matrix, >>> +                    struct ap_config_info *config) >>> +{ >>> +    int apm_max = (config && config->apxa) ? config->Na + 1 : 16; >> >> At this moment you already know the format of the crycb. > > How? you calculated this in kvm_ap_build_crycbd() which is called from kvm_s390_crypto_init() itself called from kvm_arch_init_vm(). It is when starting the VM. kvm_ap_matrix_apm_create() is called much later when realizing the device ... -- Pierre Morel Linux/KVM/QEMU in Böblingen - Germany