Skip to contentSkip to conversation

vfio: mdev: make mdev_bus_type const

PATCH Applied Ricardo B. Marliere 5 participants 5 messages Feb 8, 2024 – Feb 22, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: mdev: make mdev_bus_type const

Now that the driver core can properly handle constant struct bus_type, move the mdev_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/vfio/mdev/mdev_driver.c  | 2 +-
 drivers/vfio/mdev/mdev_private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/mdev/mdev_driver.c +1 -1
index 7825d83a55f8..b98322966b3e 100644
@@ -40,7 +40,7 @@ static int mdev_match(struct device *dev, struct device_driver *drv)
 	return 0;
 }
 
-struct bus_type mdev_bus_type = {
+const struct bus_type mdev_bus_type = {
 	.name		= "mdev",
 	.probe		= mdev_probe,
 	.remove		= mdev_remove,
drivers/vfio/mdev/mdev_private.h +1 -1
index af457b27f607..63a1316b08b7 100644
@@ -13,7 +13,7 @@
 int  mdev_bus_register(void);
 void mdev_bus_unregister(void);
 
-extern struct bus_type mdev_bus_type;
+extern const struct bus_type mdev_bus_type;
 extern const struct attribute_group *mdev_device_groups[];
 
 #define to_mdev_type_attr(_attr)	\

---
base-commit: 78f70c02bdbccb5e9b0b0c728185d4aeb7044ace
change-id: 20240208-bus_cleanup-vfio-75a6180b5efe

Best regards,

Signature · 1 line
Ricardo B. Marliere <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Ricardo B. Marliere

Now that the driver core can properly handle constant struct bus_type, move the mdev_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/vfio/mdev/mdev_driver.c  | 2 +-
 drivers/vfio/mdev/mdev_private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ricardo B. Marliere
Quoted 11 lines · Ricardo B. Marliere

Now that the driver core can properly handle constant struct bus_type, move the mdev_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/vfio/mdev/mdev_driver.c  | 2 +-
 drivers/vfio/mdev/mdev_private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Jason

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Ricardo B. Marliere
Quoted 10 lines

-----Original Message-----
From: Ricardo B. Marliere <[email protected]>
Sent: Friday, February 9, 2024 1:32 AM
To: Kirti Wankhede <[email protected]>; Alex Williamson <[email protected]>
Cc: [email protected]; [email protected]; Greg Kroah-Hartman <[email protected]>; Ricardo B. Marliere <[email protected]>
Subject: [PATCH] vfio: mdev: make mdev_bus_type const

Quoted 7 lines

Now that the driver core can properly handle constant struct bus_type, move the mdev_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

Quoted 41 lines
---
 drivers/vfio/mdev/mdev_driver.c  | 2 +-
 drivers/vfio/mdev/mdev_private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/mdev/mdev_driver.c +1 -1
index 7825d83a55f8..b98322966b3e 100644
@@ -40,7 +40,7 @@ static int mdev_match(struct device *dev, struct
 device_driver *drv)
 	return 0;
 }
 
-struct bus_type mdev_bus_type = {
+const struct bus_type mdev_bus_type = {
 	.name		= "mdev",
 	.probe		= mdev_probe,
drivers/vfio/mdev/mdev_driver.c +0 -0
 	.remove		= mdev_remove,
drivers/vfio/mdev/mdev_private.h +1 -2
index af457b27f607..63a1316b08b7 100644
@@ -13,7 +13,7 @@
 int  mdev_bus_register(void);
 void mdev_bus_unregister(void);
 
-extern struct bus_type mdev_bus_type;
+extern const struct bus_type mdev_bus_type;
 extern const struct attribute_group *mdev_device_groups[];
 
 #define to_mdev_type_attr(_attr)	\
 
---

base-commit: 78f70c02bdbccb5e9b0b0c728185d4aeb7044ace
change-id: 20240208-bus_cleanup-vfio-75a6180b5efe

Best regards,
--
Ricardo B. Marliere <[email protected]>

#4 lore raw
In reply to Ricardo B. Marliere
Quoted 43 lines · On Thu, 08 Feb 2024 17:02:04 -0300 "Ricardo B. Marliere"…

Now that the driver core can properly handle constant struct bus_type, move the mdev_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/vfio/mdev/mdev_driver.c  | 2 +-
 drivers/vfio/mdev/mdev_private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/mdev/mdev_driver.c +1 -1
index 7825d83a55f8..b98322966b3e 100644
@@ -40,7 +40,7 @@ static int mdev_match(struct device *dev, struct device_driver *drv)
 	return 0;
 }
 
-struct bus_type mdev_bus_type = {
+const struct bus_type mdev_bus_type = {
 	.name		= "mdev",
 	.probe		= mdev_probe,
 	.remove		= mdev_remove,
drivers/vfio/mdev/mdev_private.h +1 -2
index af457b27f607..63a1316b08b7 100644
@@ -13,7 +13,7 @@
 int  mdev_bus_register(void);
 void mdev_bus_unregister(void);
 
-extern struct bus_type mdev_bus_type;
+extern const struct bus_type mdev_bus_type;
 extern const struct attribute_group *mdev_device_groups[];
 
 #define to_mdev_type_attr(_attr)	\
 
---

base-commit: 78f70c02bdbccb5e9b0b0c728185d4aeb7044ace
change-id: 20240208-bus_cleanup-vfio-75a6180b5efe

Quoted 1 line

Best regards,

Applied to vfio next branch for v6.9. Thanks,

Alex