lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250728-luo-pci-v1-25-955b078dd653@kernel.org>
Date: Mon, 28 Jul 2025 01:24:55 -0700
From: chrisl@...nel.org
To: Bjorn Helgaas <bhelgaas@...gle.com>, 
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
 "Rafael J. Wysocki" <rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>, 
 Len Brown <lenb@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org, 
 linux-acpi@...r.kernel.org, David Matlack <dmatlack@...gle.com>, 
 Pasha Tatashin <tatashin@...gle.com>, Jason Miu <jasonmiu@...gle.com>, 
 Vipin Sharma <vipinsh@...gle.com>, Saeed Mahameed <saeedm@...dia.com>, 
 Adithya Jayachandran <ajayachandra@...dia.com>, 
 Parav Pandit <parav@...dia.com>, William Tu <witu@...dia.com>, 
 Mike Rapoport <rppt@...nel.org>, Chris Li <chrisl@...nel.org>, 
 Jason Gunthorpe <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>
Subject: [PATCH RFC 25/25] PCI/LUO: Clean up PCI_SER_GET()

From: David Matlack <dmatlack@...gle.com>

Refactor PCI_SER_GET() to be more readable by storing the pointer
to struct pci_dev_ser in an intermediate variable and adding a helper
function to_pci_dev_ser().

Change pci_lu_adopt() to return a boolean since it is only used to check
if a device has preserved state.

Opportunistically fix the formatting on the static inline prototype of
pci_liveupdate_reclaim_resource() as well.

No functional change intended.

Signed-off-by: David Matlack <dmatlack@...gle.com>
Signed-off-by: Chris Li <chrisl@...nel.org>
---
 drivers/pci/pci.h | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 7af32edb128faef9c5e2665ca5055374f7fd30ea..d092cea96dc22cca5d3526c720cfb8b330c47683 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1196,27 +1196,37 @@ static inline int pci_msix_write_tph_tag(struct pci_dev *pdev, unsigned int inde
 	 PCI_CONF1_EXT_REG(reg))
 
 #ifdef CONFIG_LIVEUPDATE
-#define PCI_SER_GET(__pci_dev, __var, __def)			\
-	(__pci_dev->dev.lu.dev_state) ?				\
-	((struct pci_dev_ser *)__pci_dev->dev.lu.dev_state)->__var : __def
-
 void pci_liveupdate_restore(struct pci_dev *dev);
 void pci_liveupdate_override_driver(struct pci_dev *dev);
-static inline struct pci_dev_ser *pci_lu_adopt(struct pci_dev *dev)
+static inline struct pci_dev_ser *to_pci_dev_ser(struct pci_dev *dev)
+{
+	return dev->dev.lu.dev_state;
+}
+static inline bool pci_lu_adopt(struct pci_dev *dev)
 {
-	return dev->dev.lu.requested ? dev->dev.lu.dev_state : NULL;
+	return dev->dev.lu.requested && to_pci_dev_ser(dev);
 }
 int pci_liveupdate_reclaim_resource(struct pci_dev *dev);
 #else
-#define PCI_SER_GET(__dev, __var, __def) __def
-
 static inline void pci_liveupdate_restore(struct pci_dev *dev) {}
 static inline void pci_liveupdate_override_driver(struct pci_dev *dev) {}
-static inline struct pci_dev_ser *pci_lu_adopt(struct pci_dev *dev)
+static inline struct pci_dev_ser *to_pci_dev_ser(struct pci_dev *dev)
 {
 	return NULL;
 }
-static inline int pci_liveupdate_reclaim_resource(
-	struct pci_dev *dev) { return -ENXIO; }
+static inline bool pci_lu_adopt(struct pci_dev *dev)
+{
+	return false;
+}
+static inline int pci_liveupdate_reclaim_resource(struct pci_dev *dev)
+{
+	return -ENXIO;
+}
 #endif
+
+#define PCI_SER_GET(__pci_dev, __field, __default) ({			\
+	struct pci_dev_ser *__ser = to_pci_dev_ser(__pci_dev);		\
+									\
+	__ser ? __ser->__field : __default;				\
+})
 #endif /* DRIVERS_PCI_H */

-- 
2.50.1.487.gc89ff58d15-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ