Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1272905rda; Mon, 23 Oct 2023 07:46:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk6HwcinhkWTCZwEmIiQ6ogvl12RsbkVlTRZUn0O40yKKlsZiQ99VCo4WqPWuFEHO6p40C X-Received: by 2002:a05:6a20:3ca3:b0:151:35ad:f331 with SMTP id b35-20020a056a203ca300b0015135adf331mr12470978pzj.14.1698072368166; Mon, 23 Oct 2023 07:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698072368; cv=none; d=google.com; s=arc-20160816; b=yDqhW7lfFxD/TMbs3CPsUCI+XA6QYdx0eVCO2eIPSW5mUbRUnyp1QD3FZgf/IcFvQn qeysTVKFBUJBjIgxKS+UGryQkJQ0iks7MYfruNfW7qpA5Zg8PHLowk02oWwq+rxKcZd3 7BpLoWl7X3bhPVaLTfMhGxlsyzBr5cknQJqt6cb9k8Tude8Svth6dvo0//jrbTGM+JZr jQUjB5JavjcMO1hUv6zHWFr0l8HDldB1RG6iletejSBcW6HUTFNOSPTIZbngm3u6Afxy l5Hya04YzQ3VyvhiIuN1nYr/5VCXKlU1FlOdnUyzcvqfV50BCT1Spb3nZmSYZa2QfUfY K2Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=EY/dfoODqe4KZBPQl8Uid5gopBq/vqnIAJCIMWwL5kA=; fh=RuDaKoiKVSZuEyq7VgDNZFBXOiCcEenUqykOa8MrxYI=; b=PDplf34ddGl3guJmKzJlOu5JdK+z/KkMnia/v/JMePNdV+uttcYKAKpF3Qb2sMoXbZ EiQ/gxFTZUW/oNdIeV55W+D28o1DHbdj5PrB8itB3QOhne/sBH172LmIfRnXbekYCeyj 76TBgiPiG8UKbmIrTiZ1zQsCC9DsduGQkRgEb7GAtl/pw6w7/ZgKvX2Bp52zzEssosEX 20ADtYxWVlGebl3va3RlKbfW0t7QjRcgY3ufHyZcVUX+enhopjcEbpsorG771/77Olsp ukYg1U7G0cJJJ5CZ8awVFfrLWWb+rqp6PlCufNkttrXaD6tA3umnfOo23tIld3ZKKPYZ FrqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZcY0dq9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s62-20020a632c41000000b005aff4be59a1si6667510pgs.59.2023.10.23.07.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:46:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZcY0dq9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 46E09808287C; Mon, 23 Oct 2023 07:46:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234058AbjJWOpx (ORCPT + 99 others); Mon, 23 Oct 2023 10:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234063AbjJWOp3 (ORCPT ); Mon, 23 Oct 2023 10:45:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 926DF1735 for ; Mon, 23 Oct 2023 07:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698072202; 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=EY/dfoODqe4KZBPQl8Uid5gopBq/vqnIAJCIMWwL5kA=; b=ZcY0dq9JKDcHgueFL/WqQK7TiEUHqM7rs7uvdOMsiZr6wksogxGGWEQrJxziaOSeZShru+ DOI4+4qI12nQSw8qfFlI3YVfhTDKXH8JZ+6H/5NFfr3vSY915aLfCfki8Kgn2TZbd7qfmQ WQPmAbeWtoQQe/CPLPcj016CQ9yzQlQ= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-Aq6JmeiwN2qVlWIfTdBEqQ-1; Mon, 23 Oct 2023 10:43:16 -0400 X-MC-Unique: Aq6JmeiwN2qVlWIfTdBEqQ-1 Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-7a64eb9c96aso399490339f.1 for ; Mon, 23 Oct 2023 07:43:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698072195; x=1698676995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EY/dfoODqe4KZBPQl8Uid5gopBq/vqnIAJCIMWwL5kA=; b=pRHpr1pcwsGY+MfXBPH/zohyrWe4x+zcQ/ycG5NSusgiAd0II9PfEVUtwugpP5VvtQ FS324ZpukrDBRAXkwFB+f9iNstMJB/Cc9QWBbZZD1wnY17M+Xdc/liW1lsmEiTFyPzqo SQvaVAyyNY5GUuF2UppfIYS87hqVpt4QQBmf9lQyouZJrwV8/vPw5chKDbMFCvGjkfqk Wrlgb4t3lNpT3ul4acYdjsFqpHjQixS8BWVg8G5iDRq2H2LNPq61QtUCxWzuUyS+ae8F DCeHDEoL70RYTZ48p0bcaDbHx+0YMaqnAjxAHZiuqZ8PVt8oJ3pv47O7Apjs/zVjrU/9 +fIg== X-Gm-Message-State: AOJu0YzPXbYG2d9r3J9zZACd3Q3scDrU3meDlGggy6gPLOFOg6fRNKVR AySO8rnxJJKTrU48OGKJlKmG/tVTmnSG25evPTMQ9aAZ5D/MktktHP0gksLv9X6kfBK+QBRAcNk +q+ky6Yg10GVK0kcx2dlJmFXy X-Received: by 2002:a05:6e02:1a6c:b0:357:a272:dbc with SMTP id w12-20020a056e021a6c00b00357a2720dbcmr11030721ilv.9.1698072195627; Mon, 23 Oct 2023 07:43:15 -0700 (PDT) X-Received: by 2002:a05:6e02:1a6c:b0:357:a272:dbc with SMTP id w12-20020a056e021a6c00b00357a2720dbcmr11030701ilv.9.1698072195310; Mon, 23 Oct 2023 07:43:15 -0700 (PDT) Received: from redhat.com ([38.15.60.12]) by smtp.gmail.com with ESMTPSA id o11-20020a02cc2b000000b0045c5908ddb7sm2309724jap.69.2023.10.23.07.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:43:14 -0700 (PDT) Date: Mon, 23 Oct 2023 08:43:12 -0600 From: Alex Williamson To: Ankit Agrawal Cc: Jason Gunthorpe , Yishai Hadas , "shameerali.kolothum.thodi@huawei.com" , "kevin.tian@intel.com" , Aniket Agashe , Neo Jia , Kirti Wankhede , "Tarun Gupta (SW-GPU)" , Vikram Sethi , Andy Currid , Alistair Popple , John Hubbard , Dan Williams , "Anuj Aggarwal (SW-GPU)" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v12 1/1] vfio/nvgpu: Add vfio pci variant module for grace hopper Message-ID: <20231023084312.15b8e37e.alex.williamson@redhat.com> In-Reply-To: References: <20231015163047.20391-1-ankita@nvidia.com> <20231017165437.69a84f0c.alex.williamson@redhat.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.35; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 23 Oct 2023 07:46:05 -0700 (PDT) On Mon, 23 Oct 2023 12:48:22 +0000 Ankit Agrawal wrote: > > After looking at Yishai's virtio-vfio-pci driver where BAR0 is emulated > > as an IO Port BAR, it occurs to me that there's no config space > > emulation of BAR2 (or BAR3) here.=C2=A0 Doesn't this mean that QEMU reg= isters > > the BAR as 32-bit, non-prefetchable?=C2=A0 ie. VFIOBAR.type & .mem64 are > > wrong? =20 >=20 > Maybe I didn't understand the question, but the PCI config space read/wri= te > would still be handled by vfio_pci_core_read/write() which returns the > appropriate flags. I have checked that the device BARs are 64b and > prefetchable in the VM. vfio_pci_core_read/write() accesses the physical device, which doesn't implement BAR2. Why would an unimplemented BAR2 on the physical device report 64-bit, prefetchable? QEMU records VFIOBAR.type and .mem64 from reading the BAR register in vfio_bar_prepare() and passes this type to pci_register_bar() in vfio_bar_register(). Without an implementation of a config space read op in the variant driver and with no physical implementation of BAR2 on the device, I don't see how we get correct values in these fields. > > We also need to decide how strictly variant drivers need to emulate > > vfio_pci_config_rw with respect to BAR sizing, where the core code > > provides emulation of sizing and Yishai's virtio driver only emulates > > the IO port indicator bit. =20 >=20 > Sorry, it isn't clear to me how would resizable BAR is applicable in this > variant driver as the BAR represents the device memory. Should we be > exposing such feature as unsupported for this variant driver? Bar SIZING, not resizing. This is the standard in-band mechanism for determining the BAR size as described in PCIe 6.0.1, 7.5.1.2.1. QEMU makes use of the region size but does rely on the BAR flags when registering the BAR into QEMU as described above. Additionally, vfio-pci-core supports this in-band sizing mechanism for physical BARs. A variant driver which does not implement config space BAR sizing for a virtual BAR is arguably not presenting a PCI compatible config space where a non-QEMU userspace may depend on standard PCI behavior here. Thanks, Alex