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=1796339204; b=qyRvQhuOHenuMBZoVU7WN/A97OYs54n9hSVZFRclPhE9LFxOI4nxU+SObr2mkEZcMSTz SkEkWiRHRah9Fy6UdRi7BDQvuh1v/cMJjIyGr6guMwKZsETWV1Nc8Q7ShySRWe4546w1R VMS/Tb70nESvcWQjCkT3nINP6HmrXqVYVuE03tI5IJDQc4WDse84ICXBx/FhAv+tjXETc qIAiLEKNkRgov+6VTa6z6sPkjxYKto6sH965hOfnyADQfjfL33zZSC2imS4Y1reENxyIB 6BssMjjtEfzp1XVc2X5WhsBzVOtlqd+trNUM/Jt29Kjy/VHmOA7+du/zFfoClAuLHgw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796339204; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: 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=AFcOV/FI/mkydCiXmhbmlp/WeD65SRPlc/mHf2kqTwuY/Jt/oIje/5EooR0hU3uweMrK fEOHFF5wwOYcJE9C+lFVDYSxsE5sLhwNbyZA3Uuh1j1wUbRyWPr0+ouJT4L3sHtxIIXp3 Nf8Gdb4eovSENBIR+h/QGPsgJlG2uKjCBJODx4lhqhTBcpJ6P9HM6m8mIq4s7qUXP3XPK fp6jqmb6OlACFjvpULSCkV1kj1JJQgVTROco3gxZMDfmN6dAaUxi2iefALYRZDGDGjw8D k/ISdK+2JWoHYi0itSaLmNyOgRxb1OVOXQeYoCqrgAk46aSh5lUfMSy6/7ypYHsvjsw== 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 50A49606A32C for ; Thu, 3 Dec 2026 23:06:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 50A49606A32C 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) 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-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-U08LD-siPo2HsSG4MFfVBg-1; Thu, 3 Dec 2026 23:06:40 +0000 X-MC-Unique: U08LD-siPo2HsSG4MFfVBg-1 X-Mimecast-MFC-AGG-ID: U08LD-siPo2HsSG4MFfVBg_1796339199 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4aa0500c979so210979f8f.2 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: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 2002:a05:6000:2085:b0:4ce:a6cc:18d2 with SMTP id ffacd0b85a97d-4d1e89e596amr532574f8f.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: linux-kernel@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