From: Bjorn Helgaas <helgaas@kernel.org>
To: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Cc: linux-pci <linux-pci@vger.kernel.org>,
Marc Zyngier <marc.zyngier@arm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Robin Murphy <robin.murphy@arm.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
David Laight <david.laight@aculab.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Thibaud Cornic <thibaud_cornic@sigmadesigns.com>,
Phuong Nguyen <phuong_nguyen@sigmadesigns.com>,
LKML <linux-kernel@vger.kernel.org>, Mason <slash.tmp@free.fr>
Subject: Re: [PATCH v4 2/2] PCI: Add tango PCIe host bridge support
Date: Tue, 23 May 2017 12:24:09 -0500 [thread overview]
Message-ID: <20170523172409.GD24431@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <4a354b33-d59c-4ebb-4b31-0388ac8090d4@sigmadesigns.com>
On Thu, Apr 20, 2017 at 04:31:25PM +0200, Marc Gonzalez wrote:
> This driver is required to work around several hardware bugs in the
> PCIe controller.
>
> NB: Revision 1 does not support legacy interrupts, or IO space.
>
> Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
> ---
> Documentation/devicetree/bindings/pci/tango-pcie.txt | 32 ++++++++
> drivers/pci/host/Kconfig | 8 ++
> drivers/pci/host/Makefile | 1 +
> drivers/pci/host/pcie-tango.c | 161 +++++++++++++++++++++++++++++++++++++++
> include/linux/pci_ids.h | 2 +
> 5 files changed, 204 insertions(+)
> ...
> +static int smp8759_config_read(struct pci_bus *bus,
> + unsigned int devfn, int where, int size, u32 *val)
> +{
> + int ret;
> + struct pci_config_window *cfg = bus->sysdata;
> + struct tango_pcie *pcie = dev_get_drvdata(cfg->parent);
> +
> + /*
> + * QUIRK #1
> + * Reads in configuration space outside devfn 0 return garbage.
> + */
> + if (devfn != 0)
> + return PCIBIOS_FUNC_NOT_SUPPORTED;
> +
> + /*
> + * QUIRK #2
> + * Unfortunately, config and mem spaces are muxed.
> + * Linux does not support such a setting, since drivers are free
> + * to access mem space directly, at any time.
> + * Therefore, we can only PRAY that config and mem space accesses
> + * NEVER occur concurrently.
> + */
> + writel_relaxed(1, pcie->mux);
> + ret = pci_generic_config_read(bus, devfn, where, size, val);
> + writel_relaxed(0, pcie->mux);
This is a major issue and possibly even a security problem.
Unprivileged users can cause config accesses via lspci/setpci.
I don't have a good suggestion for addressing it, but if you can't
make this work reliably, you need at least a dev_err() in the probe
function and probably a taint of the kernel (see add_taint()).
> + return ret;
> +}
> +
> +static int smp8759_config_write(struct pci_bus *bus,
> + unsigned int devfn, int where, int size, u32 val)
> +{
> + int ret;
> + struct pci_config_window *cfg = bus->sysdata;
> + struct tango_pcie *pcie = dev_get_drvdata(cfg->parent);
> +
> + writel_relaxed(1, pcie->mux);
> + ret = pci_generic_config_write(bus, devfn, where, size, val);
> + writel_relaxed(0, pcie->mux);
> +
> + return ret;
> +}
> +
> +static struct pci_ecam_ops smp8759_ecam_ops = {
> + .bus_shift = 20,
> + .pci_ops = {
> + .map_bus = pci_ecam_map_bus,
> + .read = smp8759_config_read,
> + .write = smp8759_config_write,
> + }
> +};
next prev parent reply other threads:[~2017-05-23 17:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 14:24 [PATCH v4 0/2] Tango PCIe controller support Marc Gonzalez
2017-04-20 14:28 ` [PATCH v4 1/2] PCI: Add tango MSI " Marc Gonzalez
2017-05-17 14:56 ` Marc Gonzalez
2017-05-23 17:03 ` Bjorn Helgaas
2017-05-23 17:54 ` Mason
2017-05-23 18:03 ` Robin Murphy
2017-05-23 19:15 ` Mason
2017-05-24 10:00 ` Robin Murphy
2017-05-24 10:22 ` Marc Zyngier
2017-05-31 14:18 ` Mason
2017-05-31 17:34 ` Bjorn Helgaas
2017-05-31 18:49 ` Mason
2017-05-31 19:00 ` Bjorn Helgaas
2017-05-31 19:12 ` Bjorn Helgaas
2017-05-31 19:27 ` Mason
2017-05-31 20:04 ` Bjorn Helgaas
2017-05-31 21:55 ` Mason
2017-05-25 8:37 ` Marc Zyngier
2017-05-31 7:32 ` Marc Gonzalez
2017-04-20 14:31 ` [PATCH v4 2/2] PCI: Add tango PCIe host bridge support Marc Gonzalez
2017-05-23 17:24 ` Bjorn Helgaas [this message]
2017-05-23 17:43 ` Mason
2017-05-23 18:35 ` Bjorn Helgaas
2017-05-23 19:29 ` Mason
2017-05-25 8:48 ` Marc Zyngier
2017-05-25 12:00 ` Mason
2017-05-25 12:23 ` Marc Zyngier
2017-05-25 12:41 ` Mason
2017-05-25 13:20 ` Marc Zyngier
2017-05-15 8:16 ` [PATCH v4 0/2] Tango PCIe controller support Marc Gonzalez
2017-05-23 17:17 ` Bjorn Helgaas
2017-05-23 18:07 ` Mason
2017-05-23 18:30 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170523172409.GD24431@bhelgaas-glaptop.roam.corp.google.com \
--to=helgaas@kernel.org \
--cc=david.laight@aculab.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=lorenzo.pieralisi@arm.com \
--cc=marc.zyngier@arm.com \
--cc=marc_gonzalez@sigmadesigns.com \
--cc=phuong_nguyen@sigmadesigns.com \
--cc=robin.murphy@arm.com \
--cc=slash.tmp@free.fr \
--cc=tglx@linutronix.de \
--cc=thibaud_cornic@sigmadesigns.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®