Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1438337rwb; Fri, 28 Jul 2023 09:21:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlHp9japO16LN3iJ3LjDyfVKAQOZDdm88e4fJDvMiU8NzPfUkMTw+i8BlNztdfljLpQsH1zr X-Received: by 2002:a05:6512:3a85:b0:4f9:52f3:9a2b with SMTP id q5-20020a0565123a8500b004f952f39a2bmr2715711lfu.54.1690561310960; Fri, 28 Jul 2023 09:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690561310; cv=none; d=google.com; s=arc-20160816; b=KOLhWN+fOWPTUiEUZjrobzt9TjKoiVCuBQkNrpaXOA3xtfuw2TNoulh+gNpMP4v7Pe qOXfzYo+iVfIzHh0IV5dwFAj8w93Buk9T8gfMB+ojNc0P3KocvanWnjjU88xz0jjJa6l 3b+tmc2oGSDExVPvmBhaG1Ykzzvfv/eGurUP4Docz5Ht4CPHIBDP9W9Mp5KEDYCgpzKR DQeQBNYRBAQJQSNWDQV9AIME+RDA1baksMZcwqjfzkidX+bWyiPA+kNAWvqYmeDJQPzD GaqK9ke8JImAZhUw7P06AHZqAfFtjzAJ+zlRi+G0Hyxwcw3ex1dVgLVLiuqLAsmkng+h RBmw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=NA5x7LpmDsxwcFP3IyTHomLTdnzMLPsHmmR5ITWV0mk=; fh=Zg72T/L7Qr+APoyns+vBXfQo05JbVqWLJ2Hz+67yyzk=; b=QidxT8Oh9B74LpXtV2W+0aDhUQcobtlDde0ZbN7A4U5hsNp9zsJRari1X49AFpc3sA 0nG82RT18TryD0V9hRqqRBVaPsUwSsBk5DtngLaHLAT2bvi7MAAsoUqtt+IwYzIQ1Gos xRdHNk3nry7uw2ovQeyNYDPJwNqgENAkV0HBErLjZ+D2NrPCvMKBwxprmIjjQkQP0E8j Kz4Nuaf29qw0AXIn3ovb9wXlhN3kJD7cI/kAc5r/DUwjMtWJgCntIOUTAQfvQOnQ9HH5 D8DgHGw+L5lkIwE93gzLFOvEmyg2mse47Z7o/MKfu6ZtP9Rh/vMmLBpvjq8lu3LQ1Zml Z7hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ny7mbA2x; 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 i26-20020a50fc1a000000b00522378a2e06si3008055edr.35.2023.07.28.09.21.25; Fri, 28 Jul 2023 09:21:50 -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=Ny7mbA2x; 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 S236340AbjG1PWp (ORCPT + 99 others); Fri, 28 Jul 2023 11:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjG1PWn (ORCPT ); Fri, 28 Jul 2023 11:22:43 -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 E38F13592 for ; Fri, 28 Jul 2023 08:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690557714; 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=NA5x7LpmDsxwcFP3IyTHomLTdnzMLPsHmmR5ITWV0mk=; b=Ny7mbA2xBWNKyWpsDVQDGl8JT0eoWXzW6IlcJaE3M1hnLs1nkBktkRoodMDO21jQWU6+2F t1j+FeHPv0yHzzA08HK/EoaST6xsmxY6kVvq+pH2Doa6WN7F6mMWzgGrIOcn4mVDW4y+du 7hb1qtLfjhw9GPFUYRgBKv+S9KqsnBA= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-442--Nchrw5TOT6AQIu6-7t2Og-1; Fri, 28 Jul 2023 11:21:49 -0400 X-MC-Unique: -Nchrw5TOT6AQIu6-7t2Og-1 Received: by mail-il1-f199.google.com with SMTP id e9e14a558f8ab-34603502e5aso15588735ab.1 for ; Fri, 28 Jul 2023 08:21:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690557709; x=1691162509; h=content-transfer-encoding:mime-version:organization: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=NA5x7LpmDsxwcFP3IyTHomLTdnzMLPsHmmR5ITWV0mk=; b=FgVlVTFLQhH5+a1FpcD+j7eff93DIGaqhRS1JEqoSqRlAmd+I/Q+zSEYlQkHupVWPp Ek7aVmUCz2vX1BMxNowrXCzdk34vQTYBlbNzxLv6XDX4KiX98OL8KoUbUutBpHVxSZSR Qbzq29CJFmRQ4y77MLJEA5Bh567CQTwT6RB0ocxdKl0wRT3uS8GpnF/hJZiDmJZZ7aqT vxf2lth+pxYdPwOkcTbEAI50cIkwpPq/jCHQWYkXCd7/Hoe67u3YNQobcMGt/acup/Wz n89A4mt9mmeE6+94T+UddZWou+0zN6hf1h0iPXJStDktsFQFa07Ut4wSxdv8TXGUi8RD 2IQQ== X-Gm-Message-State: ABy/qLaaS4SGDE2aWGj7emgRaTgjOfiMGDjceV6q2khytjGmcsamYgk1 /QmqLYrm/ydRr/PSCjsn696laHOF4T3h2Cn7nNC0qD7zM65DIqB3usBD0UPtPl7hum6PyjsVgzD K95my2XWwOQOLKTOkUi24MNh3 X-Received: by 2002:a05:6e02:218f:b0:348:f152:e02b with SMTP id j15-20020a056e02218f00b00348f152e02bmr3938131ila.5.1690557708757; Fri, 28 Jul 2023 08:21:48 -0700 (PDT) X-Received: by 2002:a05:6e02:218f:b0:348:f152:e02b with SMTP id j15-20020a056e02218f00b00348f152e02bmr3938109ila.5.1690557708545; Fri, 28 Jul 2023 08:21:48 -0700 (PDT) Received: from redhat.com ([38.15.60.12]) by smtp.gmail.com with ESMTPSA id b2-20020a029a02000000b0042b37dda71asm1119387jal.136.2023.07.28.08.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 08:21:48 -0700 (PDT) Date: Fri, 28 Jul 2023 09:21:44 -0600 From: Alex Williamson To: Jason Gunthorpe Cc: Ankit Agrawal , Aniket Agashe , Neo Jia , Kirti Wankhede , "Tarun Gupta (SW-GPU)" , Vikram Sethi , Andy Currid , Alistair Popple , John Hubbard , Dan Williams , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 1/1] vfio/nvgpu: Add vfio pci variant module for grace hopper Message-ID: <20230728092144.5f51343f.alex.williamson@redhat.com> In-Reply-To: References: <20230716174333.8221-1-ankita@nvidia.com> <20230727142937.536e7259.alex.williamson@redhat.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 Fri, 28 Jul 2023 09:31:27 -0300 Jason Gunthorpe wrote: > On Fri, Jul 28, 2023 at 04:36:05AM +0000, Ankit Agrawal wrote: > > > > >> +static ssize_t nvgrace_gpu_vfio_pci_read(struct vfio_device *core_vdev, > > >> + char __user *buf, size_t count, loff_t *ppos) > > >> +{ > > >> + unsigned int index = VFIO_PCI_OFFSET_TO_INDEX(*ppos); > > >> + struct nvgrace_gpu_vfio_pci_core_device *nvdev = container_of( > > >> + core_vdev, struct nvgrace_gpu_vfio_pci_core_device, core_device.vdev); > > >> + u64 offset = *ppos & VFIO_PCI_OFFSET_MASK; > > >> + u8 val = 0xFF; > > >> + size_t i; > > >> + > > >> + /* > > >> + * Only the device memory present on the hardware is mapped, which may > > >> + * not be power-of-2 aligned. A read to the BAR2 region implies an > > >> + * access outside the available device memory on the hardware. > > >> + */ > > > > > > This is not true, userspace has no requirement to only access BAR2 via > > > mmap. This should support reads from within the coherent memory area. > > > > Just to confirm, the ask is to just update the comment to reflect the behavior, > > right? (I missed to do that in this posting). Because we do redirect the call to > > vfio_pci_core_read() here which will perform the read that is within the device > > region. The read response to synthesize -1 is only for the range that is outside > > the device memory region. > > This doesn't seem right, vfio_pci_core_read() will use pci_iomap() to > get a mapping which will be a DEVICE mapping, this will make the > access incoherent with any cachable mappings. Right, but also vfio_pci_core_read() doesn't know anything about this virtual BAR2, so any in-range BAR2 accesses will error the same as trying to access an unimplemented BAR. It's not just the comment, there's no code here to handle a read(2) from in-bound BAR2 accesses. Thanks, Alex