From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796339203; b=ycgE8kNF/WxU0xRGnBvQUlTFIIxdqvO1lynEs15RBJUkdiihHsvBhd8BDtcNOyHXq24G W2AvU2ld34NPkYcOMeFdE9dZyqf7ccjzDPj79vGcLDLg5d15h5QeTJjD4YTGy3g1uI3ZI I9jeAlM+1e2bqW66bCkjpL19mqE5jKF/kcIq2hQUa+tEshv9kmjqoJh/BgxgeKRi6wo1u ElTGgW3Mlr9LCzvO7IzudP+J8uciIp7w48RcUZLodi2qCHrSvFEDs5OYV4FSlYD1NR5Dw Psrhn2N1v/VuBQ3j2sWLZT76H9KFbtbXqttyQqjCRwoTI0cfwNbHOW1zrChuNg846JA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796339203; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=4v9OWbBjTUaS2BZvbVfJFKZBak9zZR/PJ07soMX8pDU=; b=xx/X/x1a2jcykb+3BB52MAYTiwUY9+LKqHSLnta37vne993g0ZJjD0dNqSWTcZCj+GIc dUqaeH7P9S9EewKkgAZu2YMeQglVNxyZEvGSLBeyRvvmr1o+cDxbT4sDyZOTqCBhyoI4+ 0B0IhPcJBhow4LXKknNXqlk31YEijkCCHFUTGSHflB4muncCHR+XYWxFgyXr79GHsTbx/ ckF4IdSMTGP6iOjYwlRNYQVIJ7TAjgjF1BwiZz17XOJQkU4+E7ehALyR3H+UlpyicL+kn DvhRZVE72o3TNpT/FR5ntuuexrkjnrdmYLwuiUR8GA0y5SZcsFwa5csqU9JeuqcYFrw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GTQLHL78; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=jWiNNz5N; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4405A606A322 for ; Thu, 3 Dec 2026 23:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4405A606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GTQLHL78; dkim=pass (2048-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=jWiNNz5N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796339202; 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: in-reply-to:in-reply-to:references:references; bh=4v9OWbBjTUaS2BZvbVfJFKZBak9zZR/PJ07soMX8pDU=; b=GTQLHL78ipwfXNfZQkCgRmFaifgdRFObD/NNx1zgzPHDQm2SjpaSMJQ9rWYnr1Cp2k0ry7 H7Vu+NWwUNBijmLyT7OuulKhziZKPQPp+wd55TpQAvJNeOmoUJqBSfhp6ELmWh+GGcTHmx dQu+X04ne0s/alKm0l1ClkMY2QHKx6k= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-XwZ_mCcyPwanepK0tx0TGg-1; Thu, 3 Dec 2026 23:06:40 +0000 X-MC-Unique: XwZ_mCcyPwanepK0tx0TGg-1 X-Mimecast-MFC-AGG-ID: XwZ_mCcyPwanepK0tx0TGg_1796339199 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4bbc86e1eb0so260887f8f.0 for ; Thu, 03 Dec 2026 15:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796339199; x=1796943999; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=4v9OWbBjTUaS2BZvbVfJFKZBak9zZR/PJ07soMX8pDU=; b=jWiNNz5NXlzXiL0iNMEtm1CQuaWZAY8ULTO/tluFqazJRA8nsV8pJhNlb/uAVyW8qx fEtPURgtHDYXMp4XzKSLmyhqCTTVVZ2nyKMHO3l8L7fmm7BQSIibRp+MFLk9xGZo/1ee 85IZKZ52zzfR7euScdssiDx6eEx8doTR1wf7ZaLS/EPSL9l0Qzgkke6GmmOHFIWHkeNm wCsAPcxOyH4nFoV0RvzYJKZWfzUdpeb93DA7Dr1RHY6XMwjb69Um5RkRXWjOe0RbKZi3 Gj5QUKUQJMrXTBN4Jt+ybveKcm+WHJhWktolzTAhaPHBsLKKEsVLWTsa9YgGL+5VPMbg t+Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796339199; x=1796943999; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4v9OWbBjTUaS2BZvbVfJFKZBak9zZR/PJ07soMX8pDU=; b=bmubI957TRfpgxQlVGxwXQ+ByQ99gMtTNnG48YctXnooxxYZ2ArBI8kYqVA8gk+aqc O8c72hHZ6wdP9yJijmPCtlyoSJB+I+sYGT8E+oKJVipklacoJeCZ6XRixAzdQx8CGhzl xh/LUih60Tfi8twHwJxWTe/xT/3Dx/+rYys532jTDN4dkV1XOkQ3Shj9ZiQPLNplXoBk GOYGzVfT4/Si9FLxgIzoqLcAIoLXkaOTj30hSsmHQILrppUjqgB17Lfu58mZoVH6rXQu IzrP73AhsCwp7WkNYQXdD+mcuptPeH2M0/py5TMuZBK20kc3fBxlQ3g6AqAziF8ZU/ZH 4cGQ== X-Forwarded-Encrypted: i=1; AL+hErEGCPH8EbmbwwEb4ZoitulLUknVncTSGogg4zRzi/XfHOtYaAULwISfhSZc6M5VOGalvPg=@vger.kernel.org X-Gm-Message-State: APuU4Z8iat+rhAa7GS9FODerJujYPO5XpRttWx0zQoWC9NhH9LkasQdy cHVVoQ9MiMK/GNmEljZUFK8KXclYaHtlY59rVoEC64icnq1W02NAP/agvQy9irGnb9mwmYTis2g anugiKlsYoYZziOpSoZUPQ/B7F52J1ZQNFftvZj8n45iJ6mC3isGkSg== X-Gm-Gg: AZFdTZfgUki5IeqIYgK0Okh2jGcTLiDYmNLr14St5BLEyMUya+eS2d38sSdY7iqpuN2 c4KJUnDzD+y6io0WOKq3zjQvG2XDgPTDdFL1V8Gy8ECuXE+szNvsiaxHQ9FVg4QheSeuEj7Oycs Jj+KBGMrt9E8CcWZv9mg/ZJvxTz9yxG2QQa+IzaBHm27eMFIi+vznLR2RJ2gz261xW6YmFJNHoc zMRa7SdyqklxGLCceX+A7KfujDlnj+ScPifKWz2dawxxO4dXqAoM+BMd4ayNRj2JRTg1qoVmNOz DYmHLdm+tIxkYvpjPMNheK4BBCaqMrQxC6bLJhwWBq5Di63Wb2nbxqu4hzh+BNMVAiWPp1NA8Hx IipVfOFOK//8DaMOtGbemlBmiE9NE3KbZ78OzsZBD9A== X-Received: by 2002:a05:6000:2085:b0:4ce:a6cc:18d2 with SMTP id ffacd0b85a97d-4d1e89e596amr532575f8f.10.1796339198925; Thu, 03 Dec 2026 15:06:38 -0800 (PST) X-Received: by 2002:a05:6000:2085:b0:4ce:a6cc:18d2 with SMTP id ffacd0b85a97d-4d1e89e596amr532548f8f.10.1796339198387; Thu, 03 Dec 2026 15:06:38 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:153a:4c00:6468:7acf:febf:a046]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1723b8aadsm1933584f8f.18.2026.12.03.15.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 15:06:37 -0800 (PST) Date: Thu, 3 Dec 2026 18:06:34 -0500 From: "Michael S. Tsirkin" To: Alex Williamson Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v3] vfio/pci: expose ACPI _ROM through a device region Message-ID: <20261203173520-mutt-send-email-mst@kernel.org> References: <147be6bed8795824d27429a8c717e2d1d08ad89f.1796307888.git.mst@redhat.com> <20261203145709.29c06f89@shazbot.org> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203145709.29c06f89@shazbot.org> On Thu, Dec 03, 2026 at 02:57:09PM -0700, Alex Williamson wrote: > On Thu, 3 Dec 2026 09:35:01 -0500 > "Michael S. Tsirkin" wrote: > > +void vfio_pci_register_acpi_rom(struct vfio_pci_core_device *vdev) > > +{ > > + acpi_handle handle = ACPI_HANDLE(&vdev->pdev->dev); > > + union acpi_object args[] = { > > + { .integer = { .type = ACPI_TYPE_INTEGER } }, > > + { .integer = { .type = ACPI_TYPE_INTEGER, .value = SZ_4K } }, > > + }; > > + struct acpi_object_list params = { ARRAY_SIZE(args), args }; > > + size_t size = 0, capacity = 0; > > + void *rom = NULL; > > + acpi_handle method; > > + int ret = -EIO; > > + > > + if (!handle || ACPI_FAILURE(acpi_get_handle(handle, "_ROM", &method))) > > + return; > > + > > + /* > > + * Some firmware requires 4 KiB-aligned requests. Snapshot the image > > + * at open so reads never invoke AML and the size and contents agree. > > + */ > > Can you cite some firmware that has this requirement? I don't want to > come back to this in the future without an example of firmware that > imposes this requirement. Yes, it's in nouveau history: In 2012 Ben Skeggs changed the initial ACPI ROM header probe from _ROM(0, 3) to _ROM(0, 4096) for firmware compatibility. https://github.com/torvalds/linux/commit/d1626a965141 > That alone also doesn't feel like it justifies allocating up to 16MB of > kernel memory and holding it for the whole user session. 16M of virtually contiguos memory a problem? Well I started with reading exactly what userspace requested. I then got a comment that userspace reading byte by byte will invoke 4K ACPI calls per page. So now I am caching it all. It is simple, at least. > We can > perform reads with 4K alignment and return short reads to get the user > onto the alignment we require. > > Sashiko notes a couple issues, particularly in this method of sizing > the ROM. Why shouldn't we walk the ROM image chain read through _ROM > to determine the size, save only that size in the init phase, then do > aligned reads (if necessary), on demand as the user accesses? I don't mind, but didn't you worry about malformed firmware earlier? Something about firmware burners? > Aside from the alignment, and the device specific region proposed here, > I basically proposed those mechanics in > https://lore.kernel.org/all/20261015112719.20d08b4c@shazbot.org/ You actually complained about "letting the user so easily monopolize the ACPI interpreter lock". If we invoke ACPI in response to userspace system calls we do exactly that. Confused. > Architecturally I'm fine with the device specific region approach. > > > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h > > index e41437fa17ad0..0d77f860020e9 100644 > > --- a/include/uapi/linux/vfio.h > > +++ b/include/uapi/linux/vfio.h > > @@ -345,6 +345,15 @@ struct vfio_region_info_cap_type { > > #define VFIO_REGION_TYPE_GFX (1) > > #define VFIO_REGION_TYPE_CCW (2) > > #define VFIO_REGION_TYPE_MIGRATION_DEPRECATED (3) > > +#define VFIO_REGION_TYPE_ACPI (4) > > + > > +/* sub-types for VFIO_REGION_TYPE_ACPI */ > > +/* > > + * The device firmware's ACPI _ROM image, when available. The region size is > > + * the exact image length in bytes. This region supports read() and pread() > > + * only. It is independent of the PCI expansion ROM region. > > + */ > > +#define VFIO_REGION_SUBTYPE_ACPI_ROM (1) > > > > /* sub-types for VFIO_REGION_TYPE_PCI_* */ > > > > Note that the sub-type definitions are in the same order as the types > are defined. This jumps the line. Thanks, > > Alex