From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E7E42D063E for ; Wed, 25 Feb 2026 22:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772057192; cv=none; b=j2ZDqTI7XmPj8qiymT6p98lpGDW5fAseBd1Kz5T+vkzqzhmZvS0C3+0U2DGHdnOhuokNxU8lbGfi+jjWfWHDeIhAsKn9JIdt0sqlHOPwM7/ngg8bcZ37DB2Ln0rYssYix93Uc2HXqYAiACfxNm0CWNOixkp5rN8gMOG+B7nKlnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772057192; c=relaxed/simple; bh=LJWtxfMSbjaR7UL7hdep9H/YDcNXa8SN1R3pQvw0+Fc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Gg7TjcwHr5MnDudL5c85zcuCaf1Ln1uju+29V1HgpQNvwbF7MQ55rj4gdUyh9Xe+EuJZsS0FotgW2JwTmY87CvU3F5Xe/A/vIxf/ZdE1sQTEe1kbtKI/hlz8HCn6hkw/rjAV04RwXHWlPVKsO88xeom8rUiNwt7J3TxrbdbhaP0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tA+Pbm0Y; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tA+Pbm0Y" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2ada9e4ea32so11375ad.1 for ; Wed, 25 Feb 2026 14:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772057189; x=1772661989; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=yKxFO5jbcj0n3yx3uCDHTRhkwPsNZ/ADjqKpvoexazc=; b=tA+Pbm0YWZZbEJBWS4Tr4W7PpkLvYJdLDNIcSF8/87i9oDVFj+Oz+s3bBv0r6W7PlG NEcFRl6QB/YdLaxiel9L3DCwLztCmQrSXxaUxtdkefuFoWFIHG3VgRMJv0nj0eSkW2AI /G3DvLZmmXsW7d1ZDWanlu+GBMsmI3FhtUrnRlW9tgPwglg1jugdpYuUjdwZbuj7aHK1 CbBmH2tQ70fyIVwV+ZJtG1FEJ/z3vmGea+A/4TMAJ3ZHCx6TrHQtCxC+YVbWui3pWRu0 jHvSqojoeLrA7wPutUbnsggmp2BfW13G/svB/7nm7sLAoLTHZsCb+8kGv34V2nIapyAp eF5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772057189; x=1772661989; h=in-reply-to:content-disposition: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; bh=yKxFO5jbcj0n3yx3uCDHTRhkwPsNZ/ADjqKpvoexazc=; b=qFReuRG+tZH68QvZME0tJxtPvvidmy8SYWd6c7VNZZvFbVmc6r7H0GXxYYiYzBSOUL ZDp50VsqU9jtkqN5F9SdIdenOQS+pnPDGTUn4WZzvMG+te8EgmD3RprGaA0O4j735zII pTtjVdiPCIMrouuEQYexzfGJW1rqicYf3TR8muZwwdkeoWwVvxyKcWQjJEGeYEfbWxAr RrfylLqwJQUZvEoWwAr4z14ynODlBL38xRLQV5uqwrbQ93SIRJE9eYRbCpAn9oa36WLO n192sDF7gzwoMWbC2ztDpdC0iF9uKnOcsPkjDX3e6TKxTRVE+NsKU847CpQNwdERbSsg nMNA== X-Forwarded-Encrypted: i=1; AJvYcCUKgJd+XIpX98O0tZf+HgMJhNSYX1p8hD6DVCISmGJ5tysyxP+z1NjhwhROmwIkGiC7uUCe2/EO/R4H5M4=@vger.kernel.org X-Gm-Message-State: AOJu0YyIH0Nmzi+M8mHqAjxGtUW+dNoLBRGsX/ZQEkPnYvnE4ReuVlqJ wt5ZDiJxu9OAEN5HYDgwbd1yZNmCHFrnZ84+3JLvph1NlyVNyB11tl6UoB8P4nDyNQ== X-Gm-Gg: ATEYQzy0ljxYHoS+nTYBO8hc9vzYF1Ea9ULJV3+y0bwg3F+adnVzhdeL4vEie2RFh6Q 5tuhC2lPpb/UkOqVhc/3O3BKBk3QnmOWxD8ti7n3lo7B1N+UdACC9yEq8vJ+fNmhdrk3obmcy/2 TTghy3FXDLdxrfuA5itPHLYmFoOLKPbjn5GobDLqz+UnSHikz4txYIqJrv3Er5JohYdFnr6n3O0 CjIb+wjTizrDxmM0A/Plw0NJE7nG8ABQ5Q3r/Gv9JiIETRNS6tfOYEqPHTVG9ObU0gATvBNQejo qQ2vo3E/iXO7V6qzq81YzkWR88c3bC/v0LEwftVGQxLB3HhJ1Yd7MTdQF4BM2bBPnfi70L110Ed qZIX284MNPkef8rgaf+dsSE3HXxc+gIjsqhbDk0SRc4/IFApAUohGc2Etk1ty7Yw2QsDJ2+YzUn znqrTTGLCyntoQWFJVPa26vstAmGISgX08Yb1yn/fXVtmF0RKVmgWJUkeub10SRIAxSiqgAHk= X-Received: by 2002:a17:903:2a86:b0:29e:27f4:bac0 with SMTP id d9443c01a7336-2adf77c692amr672495ad.16.1772057188344; Wed, 25 Feb 2026 14:06:28 -0800 (PST) Received: from google.com (222.245.187.35.bc.googleusercontent.com. [35.187.245.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8273a05e831sm236247b3a.58.2026.02.25.14.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Feb 2026 14:06:27 -0800 (PST) Date: Wed, 25 Feb 2026 22:06:18 +0000 From: Pranjal Shrivastava To: Alex Williamson Cc: David Matlack , Adithya Jayachandran , Alexander Graf , Alex Mastro , Alistair Popple , Andrew Morton , Ankit Agrawal , Bjorn Helgaas , Chris Li , David Rientjes , Jacob Pan , Jason Gunthorpe , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Kevin Tian , kexec@lists.infradead.org, kvm@vger.kernel.org, Leon Romanovsky , Leon Romanovsky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Lukas Wunner , =?utf-8?Q?Micha=C5=82?= Winiarski , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pratyush Yadav , Raghavendra Rao Ananta , Rodrigo Vivi , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Tomita Moeko , Vipin Sharma , Vivek Kasireddy , William Tu , Yi Liu , Zhu Yanjun Subject: Re: [PATCH v2 04/22] vfio/pci: Register a file handler with Live Update Orchestrator Message-ID: References: <20260129212510.967611-1-dmatlack@google.com> <20260129212510.967611-5-dmatlack@google.com> <20260225143328.35be89f6@shazbot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260225143328.35be89f6@shazbot.org> On Wed, Feb 25, 2026 at 02:33:28PM -0700, Alex Williamson wrote: > On Thu, 29 Jan 2026 21:24:51 +0000 > David Matlack wrote: > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > > index 0c771064c0b8..19e88322af2c 100644 > > --- a/drivers/vfio/pci/vfio_pci.c > > +++ b/drivers/vfio/pci/vfio_pci.c > > @@ -258,6 +258,10 @@ static int __init vfio_pci_init(void) > > int ret; > > bool is_disable_vga = true; > > > > + ret = vfio_pci_liveupdate_init(); > > + if (ret) > > + return ret; > > + > > #ifdef CONFIG_VFIO_PCI_VGA > > is_disable_vga = disable_vga; > > #endif > > @@ -266,8 +270,10 @@ static int __init vfio_pci_init(void) > > > > /* Register and scan for devices */ > > ret = pci_register_driver(&vfio_pci_driver); > > - if (ret) > > + if (ret) { > > + vfio_pci_liveupdate_cleanup(); > > return ret; > > + } > > > > vfio_pci_fill_ids(); > > > > @@ -281,6 +287,7 @@ module_init(vfio_pci_init); > > static void __exit vfio_pci_cleanup(void) > > { > > pci_unregister_driver(&vfio_pci_driver); > > + vfio_pci_liveupdate_cleanup(); > > } > > module_exit(vfio_pci_cleanup); > > > > diff --git a/drivers/vfio/pci/vfio_pci_liveupdate.c b/drivers/vfio/pci/vfio_pci_liveupdate.c > > new file mode 100644 > > index 000000000000..b84e63c0357b > > --- /dev/null > > +++ b/drivers/vfio/pci/vfio_pci_liveupdate.c > > @@ -0,0 +1,69 @@ > ... > > +static const struct liveupdate_file_ops vfio_pci_liveupdate_file_ops = { > > + .can_preserve = vfio_pci_liveupdate_can_preserve, > > + .preserve = vfio_pci_liveupdate_preserve, > > + .unpreserve = vfio_pci_liveupdate_unpreserve, > > + .retrieve = vfio_pci_liveupdate_retrieve, > > + .finish = vfio_pci_liveupdate_finish, > > + .owner = THIS_MODULE, > > +}; > > + > > +static struct liveupdate_file_handler vfio_pci_liveupdate_fh = { > > + .ops = &vfio_pci_liveupdate_file_ops, > > + .compatible = VFIO_PCI_LUO_FH_COMPATIBLE, > > +}; > > + > > +int __init vfio_pci_liveupdate_init(void) > > +{ > > + if (!liveupdate_enabled()) > > + return 0; > > + > > + return liveupdate_register_file_handler(&vfio_pci_liveupdate_fh); > > +} > > liveupdate_register_file_handler() "pins" vfio-pci with a > try_module_get(). Since this is done in our module_init function and > unregister occurs in our module_exit function, rather than relative > to any actual device binding or usage, this means vfio-pci CANNOT be > unloaded. That seems bad. Thanks, Hmm... IIUC the concern here is about liveupdate policy if the user wants to unload a module which was previously marked for preservation? AFAICT, In such a case, the user is expected to close the LUO session FD, which "unpreserves" the FD. Finally, when rmmod is executed, the __exit (vfio_pci_cleanup) calls vfio_pci_liveupdate_cleanup() which ends up calling liveupdate_unregister_file_handler(), thereby dropping the ref held by the liveupdate orchestrator which allows the module to be unloaded. I think we should document this policy somewhere or have a dev_warn to scream at the users when they try unloading the module without closing the session FD. Thanks, Praan > > Alex > > > + > > +void vfio_pci_liveupdate_cleanup(void) > > +{ > > + if (!liveupdate_enabled()) > > + return; > > + > > + liveupdate_unregister_file_handler(&vfio_pci_liveupdate_fh); > > +}