Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp599683iog; Fri, 17 Jun 2022 09:27:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uJGYg+yuqlFGCis0Ol8LsDMGrtml5pV9k+bBoIEj2ts0BgGOP5BisjnZvGQSLcn7lRDb2V X-Received: by 2002:a17:906:7948:b0:6f7:d5a3:3b91 with SMTP id l8-20020a170906794800b006f7d5a33b91mr10189376ejo.354.1655483221286; Fri, 17 Jun 2022 09:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655483221; cv=none; d=google.com; s=arc-20160816; b=Bntda7aBON4ZxBMUftP+ed8rWsCV/vXeIWlgJBFwqItuIBgm71tFmUD01fkgFjUaAp 1Dwf4T8Wjm7RT2sXCub1ZwsST9qojUbg/6cQtKvLl7JPB1LvFUyvOZ3R8SNNke0ZTFCQ Sg8FFH7GRf6AfUMH0Ppt9MkncDF7S2jDHBgRQSjN/6C+CcHja15Oa5dISgUAoyCKigsI LosHD0qPIOWqcHI9cghSpjdNqh3iFugUALFl1u1gMfOJyM6IEGfnBBWo374Q8HD2f8d4 /GzzMzeHRDaqLcySBRpYf/IMQE2co9FNR44PaumN+N4Tm4BHvWBUAICGw5RjW+1vs7Kj LQBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=G9hj+GC+aBxxfrK7yuFLDUJOFaX8GPKOTNDfbOgBveY=; b=XNkLWgqdlwpH5+jAOSLDZMdvpzovF17GvsbtdWPt8cV78GteaibugnRTxbJExF/qgn RpNW7b5pQ0n308bGxzX9HZBlHcmTWg1Ld55XOcrW2ByB6Baac+quKSVvV8ekQ90D9gQP Pho9gibwB4inFWWNYCFskQnSu3A1Uo8QsuUBjirf0nAoUdTXwOpm/fwltd+pJoHQn/M+ 8L7HqXPvlwZk6rKVToOJu+r8V+fsalSdoOhNpX2KX8bZxgfZQKlOeoZfDcSa9fnxewYk wp9iqG4IWf6qig2rMRDfgYtxoYigMaupJXO+qUnc0eCeN6GgTFyLOxKc7kHGEPIE/Qe1 XA5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UgzTbiM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a170906778e00b0070bf8e73c8dsi4797077ejm.374.2022.06.17.09.26.27; Fri, 17 Jun 2022 09:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UgzTbiM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383207AbiFQQPu (ORCPT + 99 others); Fri, 17 Jun 2022 12:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbiFQQPt (ORCPT ); Fri, 17 Jun 2022 12:15:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 715DD22BFC for ; Fri, 17 Jun 2022 09:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655482546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G9hj+GC+aBxxfrK7yuFLDUJOFaX8GPKOTNDfbOgBveY=; b=UgzTbiM7C/OtPS42a/pxfF48F9Wy0xRN3NtxKB2p4Hwli4MS/opfP5zuPp+4YP4hqqOXr/ J71Baj+zruD0aLBXSw3jr5xNBEtAu1Lkp9Qx37SIBpQx/ZP0ke4i3RX3krOUuddsvyRgxR rQwhmkF9yBj3LJJEGIhzY7r0RLxqcv0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-K1cB6QrePrapH0KKBanEzw-1; Fri, 17 Jun 2022 12:15:44 -0400 X-MC-Unique: K1cB6QrePrapH0KKBanEzw-1 Received: by mail-wm1-f72.google.com with SMTP id l17-20020a05600c4f1100b0039c860db521so2375727wmq.5 for ; Fri, 17 Jun 2022 09:15:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=G9hj+GC+aBxxfrK7yuFLDUJOFaX8GPKOTNDfbOgBveY=; b=L8SGDKa/qt4BTaM1+sNaeIj6aMBh4EojgUJEa4OErQ32lYwpW2OlzuByCCYLpkaDl6 xUK2JbwVGEUzRgbSzCY3GijzLleQEcjE5EvyeJUhRnsbg2yvaWiqmr63MS8rUqIBgMjG ciUM8NMhqOpnCBmoXjjFgkwIhEoqhp7i0MNnHCwml3f5wbAYbeVdMmCJgsJS+HqQiw+j B5DeerlVYzro+eS32/SDbcwKNsy5R2r2lPv5za0o5fyL6Gs7Um30zYXpzJrbN+5yHjJw Ugm7b+Q59kg0mAdVMM9jpSoDX4scpQu+r0v7alGppFzpv4Z9y/HIlZZ7nsre/Xw7NsQJ UhIg== X-Gm-Message-State: AOAM531YpkWuF3jOBV/62TKr0fTxRUIZ4LesoJ9O92V2Y93DG8TGvNts MwExWWdnKBP625UC8fPZJQ4MOV6lIihBnZ4EO14z6gSITGlrNag5TX22oAWGQTbj7QUal6ttXWw Vx0t/9L64bDhtjV9iMQTMf1kE X-Received: by 2002:a05:600c:1e1c:b0:39c:65a1:7c3a with SMTP id ay28-20020a05600c1e1c00b0039c65a17c3amr21846091wmb.6.1655482543313; Fri, 17 Jun 2022 09:15:43 -0700 (PDT) X-Received: by 2002:a05:600c:1e1c:b0:39c:65a1:7c3a with SMTP id ay28-20020a05600c1e1c00b0039c65a17c3amr21846038wmb.6.1655482542887; Fri, 17 Jun 2022 09:15:42 -0700 (PDT) Received: from [192.168.0.3] (ip-109-42-114-75.web.vodafone.de. [109.42.114.75]) by smtp.gmail.com with ESMTPSA id c7-20020a05600c0a4700b003942a244f51sm8708616wmq.42.2022.06.17.09.15.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jun 2022 09:15:42 -0700 (PDT) Message-ID: <08c0cf37-afd2-bad3-d1e4-88667e3e5b69@redhat.com> Date: Fri, 17 Jun 2022 18:15:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v9 10/21] vfio/pci: introduce CONFIG_VFIO_PCI_ZDEV_KVM Content-Language: en-US To: Pierre Morel , Matthew Rosato , linux-s390@vger.kernel.org Cc: alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, pasic@linux.ibm.com, pbonzini@redhat.com, corbet@lwn.net, jgg@nvidia.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org References: <20220606203325.110625-1-mjrosato@linux.ibm.com> <20220606203325.110625-11-mjrosato@linux.ibm.com> <025699e6-b870-2648-d4a4-ffbc5fff22e8@redhat.com> <69ec8abd-c579-46d0-08cd-2714de91b6cb@linux.ibm.com> From: Thomas Huth In-Reply-To: <69ec8abd-c579-46d0-08cd-2714de91b6cb@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/06/2022 10.56, Pierre Morel wrote: > > > On 6/8/22 15:15, Matthew Rosato wrote: >> On 6/8/22 2:19 AM, Thomas Huth wrote: >>> On 06/06/2022 22.33, Matthew Rosato wrote: >>>> The current contents of vfio-pci-zdev are today only useful in a KVM >>>> environment; let's tie everything currently under vfio-pci-zdev to >>>> this Kconfig statement and require KVM in this case, reducing complexity >>>> (e.g. symbol lookups). >>>> >>>> Signed-off-by: Matthew Rosato > > Reviewed-by: Pierre Morel > > >>>> --- >>>>   drivers/vfio/pci/Kconfig      | 11 +++++++++++ >>>>   drivers/vfio/pci/Makefile     |  2 +- >>>>   include/linux/vfio_pci_core.h |  2 +- >>>>   3 files changed, 13 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig >>>> index 4da1914425e1..f9d0c908e738 100644 >>>> --- a/drivers/vfio/pci/Kconfig >>>> +++ b/drivers/vfio/pci/Kconfig >>>> @@ -44,6 +44,17 @@ config VFIO_PCI_IGD >>>>         To enable Intel IGD assignment through vfio-pci, say Y. >>>>   endif >>>> +config VFIO_PCI_ZDEV_KVM >>>> +    bool "VFIO PCI extensions for s390x KVM passthrough" >>>> +    depends on S390 && KVM >>>> +    default y >>>> +    help >>>> +      Support s390x-specific extensions to enable support for enhancements >>>> +      to KVM passthrough capabilities, such as interpretive execution of >>>> +      zPCI instructions. >>>> + >>>> +      To enable s390x KVM vfio-pci extensions, say Y. >>> >>> Is it still possible to disable CONFIG_VFIO_PCI_ZDEV_KVM ? Looking at the >>> later patches (e.g. 20/21 where you call kvm_s390_pci_zpci_op() from >>> kvm-s390.c), it rather seems to me that it currently cannot be disabled >>> independently (as long as KVM is enabled). >> >> Yes, you can build with, for example, CONFIG_VFIO_PCI_ZDEV_KVM=n and >> CONFIG_KVM=m -- I tested it again just now.  The result is kvm and >> vfio-pci are built and vfio-pci works, but none of the vfio-pci-zdev >> extensions are available (including zPCI interpretation). >> >> This is accomplished via the placement of some IS_ENABLED checks.  Some >> calls (e.g. AEN init) are fenced by IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM). >> There are also some areas that are fenced off via a call to >> kvm_s390_pci_interp_allowed() which also includes an IS_ENABLED check >> along with checks for facility and cpu id. >> >> Using patch 20 as an example, KVM_CAP_S390_ZPCI_OP will always be reported >> as unavailable to userspace if CONFIG_VFIO_PCI_ZDEV_KVM=n due to the call >> to kvm_s390_pci_interp_allowed().  If userspace sends us the ioctl anyway, >> we will return -EINVAL because there is again a >> IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) check before we read the ioctl args >> from userspace. > > Yes and the code will not be generated by the compiler in patch 20 after the > break if CONFIG_VFIO_PCI_ZDEV_KVM is not enabled. > > +    case KVM_S390_ZPCI_OP: { > +        struct kvm_s390_zpci_op args; > + > +        r = -EINVAL; > +        if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) > +            break; > > Code not generated----v > > +        if (copy_from_user(&args, argp, sizeof(args))) { > +            r = -EFAULT; > +            break; > +        } > +        r = kvm_s390_pci_zpci_op(kvm, &args); > +        break; > > ----------^ OK, good to know, thanks for the clarification! Thomas