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]
Date:	Fri, 18 Mar 2016 01:48:33 +0530
From:	Jayachandran C <jchandra@...adcom.com>
To:	Bjorn Helgaas <helgaas@...nel.org>,
	Tomasz Nowicki <tn@...ihalf.com>, rafael@...nel.org
Cc:	Jayachandran C <jchandra@...adcom.com>,
	Arnd Bergmann <arnd@...db.de>,
	Will Deacon <will.deacon@....com>,
	Catalin Marinas <catalin.marinas@....com>,
	Hanjun Guo <hanjun.guo@...aro.org>,
	Lorenzo Pieralisi <Lorenzo.Pieralisi@....com>,
	okaya@...eaurora.org, jiang.liu@...ux.intel.com,
	Stefano Stabellini <Stefano.Stabellini@...citrix.com>,
	robert.richter@...iumnetworks.com, Marcin Wojtas <mw@...ihalf.com>,
	Liviu.Dudau@....com, David Daney <ddaney@...iumnetworks.com>,
	wangyijing@...wei.com, Suravee.Suthikulpanit@....com,
	msalter@...hat.com, linux-pci@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-acpi@...r.kernel.org,
	linux-kernel@...r.kernel.org, linaro-acpi@...ts.linaro.org,
	Jon Masters <jcm@...hat.com>
Subject: [RFC PATCH 4/4] ACPI: PCI: Add raw_pci_read/write operations

Provide implementations of raw_pci_read and raw_pci_write needed
by ACPI.

We already maintain a gen_acpi_pci_roots list with all the ACPI
PCI controllers, so we walk thru this list to see if there is
an existing mapping. If there is one, we can use the generic
config space access.

If there is no existing mapping, create a temporary mapping with
information available in the saved MCFG table and use it to do raw
config space access.

Signed-off-by: Jayachandran C <jchandra@...adcom.com>
---
 drivers/acpi/pci_gen_host.c | 87 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/drivers/acpi/pci_gen_host.c b/drivers/acpi/pci_gen_host.c
index a43f2cee..b5472f0 100644
--- a/drivers/acpi/pci_gen_host.c
+++ b/drivers/acpi/pci_gen_host.c
@@ -245,3 +245,90 @@ void __init pci_mmcfg_late_init(void)
 			mcfgsav.cfg, mcfgsav.size);
 	}
 }
+
+/*
+ * First walk thru the root infos of all the known ACPI PCI
+ * controllers to see if there is an existing mapping and
+ * use it if we find one.
+ * Otherwise check the MCFG table and setup a temporary mapping
+ */
+static int raw_pci_op(int domain, unsigned int busn, unsigned int devfn,
+		      int reg, int len, u32 *val, bool write)
+{
+	void __iomem *m;
+	struct acpi_pci_generic_root_info *ri;
+	struct acpi_pci_root *root;
+	bool tmpmap = false;
+	int i, ret = PCIBIOS_DEVICE_NOT_FOUND;
+
+	mutex_lock(&gen_acpi_pci_lock);
+	list_for_each_entry(ri, &gen_acpi_pci_roots, node) {
+		root = ri->common.root;
+		if (domain == root->segment &&
+		    busn >= (u8)root->secondary.start &&
+		    busn <= (u8)root->secondary.end) {
+			m = pci_generic_map_bus(ri->cfg, busn, devfn, reg);
+			if (m)
+				goto found;
+			else
+				goto err_out;
+		}
+	}
+
+	/* not found in existing root buses, check in mcfg */
+	i = mcfg_lookup(domain, busn, busn);
+	if (i < 0)
+		goto err_out;
+
+	/* get a temporary mapping */
+	busn -= mcfgsav.cfg[i].bus_start;
+	m = ioremap(mcfgsav.cfg[i].addr + (busn << 20 | devfn << 12), 1 << 12);
+	if (!m)
+		goto err_out;
+	tmpmap = true;
+	m += reg;
+found:
+	if (write) {
+		switch (len) {
+		case 1:
+			writeb(*val, m);
+			break;
+		case 2:
+			writew(*val, m);
+			break;
+		case 4:
+			writel(*val, m);
+			break;
+		}
+	} else {
+		switch (len) {
+		case 1:
+			*val = readb(m);
+			break;
+		case 2:
+			*val = readw(m);
+			break;
+		case 4:
+			*val = readl(m);
+			break;
+		}
+	}
+	if (tmpmap)
+		iounmap(m);
+	ret = 0;
+err_out:
+	mutex_unlock(&gen_acpi_pci_lock);
+	return ret;
+}
+
+int raw_pci_read(unsigned int domain, unsigned int busn, unsigned int devfn,
+		 int reg, int len, u32 *val)
+{
+	return raw_pci_op(domain, busn, devfn, reg, len, val, false);
+}
+
+int raw_pci_write(unsigned int domain, unsigned int busn, unsigned int devfn,
+		  int reg, int len, u32 val)
+{
+	return raw_pci_op(domain, busn, devfn, reg, len, &val, true);
+}
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ