Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1921640rwp; Thu, 13 Jul 2023 20:06:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGYS8bCS49UV9sih5+WmNEjDdesjAqL7A3nHx6t9Qr1Gr+XqR15r6i9eCn1+tNGiLyt4F5+ X-Received: by 2002:a05:6a20:244f:b0:12c:30f4:bd0b with SMTP id t15-20020a056a20244f00b0012c30f4bd0bmr4018621pzc.11.1689304019133; Thu, 13 Jul 2023 20:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689304019; cv=none; d=google.com; s=arc-20160816; b=UzQInG3vr3h4aRqkypQWJixhb6cxFhJrZn3e0u14swmaWNgiyDnI/aSKbWDeaTrwMU DjVbvVke/f3bKFOnKEyr5YWxyJo5GjpnruCFDbzrU7W7/iKb1ADu2FybE2YJ5zKH2uoJ cFZQlblWa9pDewZNDNNApv4+cXMSaP2hphejyLgq9j8uvLNZMsHwoA3A+pO5LBLXYiGZ 2yx3RA64B3T4Muyd9boPwcXJidbwFBDv/S33Tq3OQpDXec2vQXffnYLUoZBYW9nUr81b jyv/ifZNMArWwYQmp5Uyh3b+rRrsLKoBrFncwPuPmwsOP/Y6l7iDu+ClxPI2DjyIOAeJ p2cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:date:cc:to:from:subject:message-id; bh=CjzNDsakiCqFHVZ924kxUWSFYKdMWwNXJrtNhOauJPM=; fh=HyBzcb3RddO1NQ1oVkJMhsJP9KDltzhpdVV7tJMetgw=; b=qEpUdebel07lJVBLu2enSmmE0P/gRLaUPRgfxMgLq+jM2wuMY+9WQuMadPaEvqNCGl zoatVxy8zTcmjMpFxcC0LmV9FzJv/Txj8uZ5itvgcA8Lse6ygSYrGNdZxf6On1VyJ4FQ ELbewcFXY8qDm+MB1x26GLWlqKWJ8NbeS9IPRVUUiIwRzbfvu5cquk0sxoSfH3Wob8Wi WF2IN6Sv3plz08xHa2PoOGGCK+E5CsNF3nXl/96aEMueicMv69HbC5zXBs1zE6WTz8u8 iLq96/ryAI6PYq5xFpqBiqWRdzIzT3lPJrEjbOrXzlDVz5GBIcVz3Fk5HAmwVAZpL2ol kZNA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj33-20020a056a003a2100b0067d204bf281si6375532pfb.3.2023.07.13.20.06.47; Thu, 13 Jul 2023 20:06:59 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233731AbjGNCk3 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 13 Jul 2023 22:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjGNCk3 (ORCPT ); Thu, 13 Jul 2023 22:40:29 -0400 X-Greylist: delayed 388 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 13 Jul 2023 19:40:27 PDT Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6EB622121; Thu, 13 Jul 2023 19:40:27 -0700 (PDT) Received: from [IPv6:::1] (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 36E2WobL023295; Thu, 13 Jul 2023 21:32:50 -0500 Message-ID: <2838d716b08c78ed24fdd3fe392e21222ee70067.camel@kernel.crashing.org> Subject: VFIO (PCI) and write combine mapping of BARs From: Benjamin Herrenschmidt To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, alex.williamson@redhat.com, osamaabb@amazon.com, linux-pci@vger.kernel.org, Clint Sbisa Date: Fri, 14 Jul 2023 12:32:49 +1000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Hi Folks ! I'd like to revive an old discussion as we (Amazon Linux) have been getting asks for it. What's the best interface to provide the option of write combine mmap's of BARs via VFIO ? The problem isn't so much the low level implementation, we just have to play with the pgprot, the question is more around what API to present to control this. One trivial way would be to have an ioctl to set a flag for a given region/BAR that cause subsequent mmap's to use write-combine. We would have to keep a bitmap for the "legacy" regions, and use a flag in struct vfio_pci_region for the others. One potentially better way is to make it strictly an attribute of vfio_pci_region, along with an ioctl that creates a "subregion". The idea here is that we would have an ioctl to create a region from an existing region dynamically, which represents a subset of the original region (typically a BAR), with potentially different attributes (or we keep the attribute get/set separate). I like the latter more because it will allow to more easily define that portions of a BAR can need different attributes without causing state/race issues between setting the attribute and mmap. This will also enable other attributes than write-combine if/when the need arises. Any better idea ? thoughs ? objections ? This is still quite specific to PCI, but so is the entire regions mechanism, so I don't see an easy path to something more generic at this stage. Cheers, Ben.