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-next>] [day] [month] [year] [list]
Date:	Tue, 30 Dec 2014 17:21:47 +0900
From:	Ethan Zhao <ethan.zhao@...cle.com>
To:	bhelgaas@...gle.com
Cc:	linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
	ethan.kernel@...il.com, Ethan Zhao <ethan.zhao@...cle.com>
Subject: [PATCH] PCI: export pci device assignment info as read only via sysfs

This patch exports assignment flag of PCI device via sysfs, so user
space application could know if PCI device was assigned to guest OS
or not via interface as following from viewpoint of host device
management:

 PCI device was assigned to guest OS
 $cat /sys/devices/pci0000:00/0000:00:1f.3/assigned
 1

 PCI device isn't assigned to guest OS
 $cat /sys/devices/pci0000:00/0000:00:1f.3/assigned
 0

Compiled and tested with v3.18.1

Signed-off-by: Ethan Zhao <ethan.zhao@...cle.com>
---
 drivers/pci/pci-sysfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 2c6643f..0ac3780 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -547,6 +547,15 @@ static ssize_t driver_override_show(struct device *dev,
 }
 static DEVICE_ATTR_RW(driver_override);
 
+static ssize_t assigned_show(struct device *dev, struct device_attribute *attr,
+			 char *buf)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	return sprintf(buf, "%d\n", pci_is_dev_assigned(pdev) ? 1 : 0);
+}
+static DEVICE_ATTR_RO(assigned);
+
 static struct attribute *pci_dev_attrs[] = {
 	&dev_attr_resource.attr,
 	&dev_attr_vendor.attr,
@@ -573,6 +582,7 @@ static struct attribute *pci_dev_attrs[] = {
 	&dev_attr_devspec.attr,
 #endif
 	&dev_attr_driver_override.attr,
+	&dev_attr_assigned.attr,
 	NULL,
 };
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ