stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Pratyush Anand <pratyush.anand@gmail.com>
Subject: [PATCH 4.8 123/125] PCI: designware: Fix pci_remap_iospace() failure path
Date: Sat, 29 Oct 2016 09:50:41 -0400	[thread overview]
Message-ID: <20161029134952.247423949@linuxfoundation.org> (raw)
In-Reply-To: <20161029134947.232372651@linuxfoundation.org>

4.8-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

commit bcd7b7186fcba434e7486648de85cf93a56c845c upstream.

On ARM/ARM64 architectures, PCI IO ports are emulated through memory mapped
IO, by reserving a chunk of virtual address space starting at PCI_IOBASE
and by mapping the PCI host bridges memory address space driving PCI IO
cycles to it.

PCI host bridge drivers that enable downstream PCI IO cycles map the host
bridge memory address responding to PCI IO cycles to the fixed virtual
address space through the pci_remap_iospace() API.

This means that if the pci_remap_iospace() function fails, the
corresponding host bridge PCI IO resource must be considered invalid, in
that there is no way for the kernel to actually drive PCI IO transactions
if the memory addresses responding to PCI IO cycles cannot be mapped into
the CPU virtual address space.

The PCI designware host bridge driver does not remove the PCI IO resource
from the host bridge resource windows if the pci_remap_iospace() call
fails; this is an actual bug in that the PCI host bridge would consider the
PCI IO resource valid (and possibly assign it to downstream devices) even
if the kernel was not able to map the PCI host bridge memory address
driving IO cycle to the CPU virtual address space (ie pci_remap_iospace()
failures).

Fix the PCI host bridge driver pci_remap_iospace() failure path, by
destroying the PCI host bridge PCI IO resources retrieved through firmware
when the pci_remap_iospace() function call fails, therefore preventing the
kernel from adding the respective PCI IO resource to the list of PCI host
bridge valid resources, fixing the issue.

Fixes: cbce7900598c ("PCI: designware: Make driver arch-agnostic")
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Jingoo Han <jingoohan1@gmail.com>
CC: Pratyush Anand <pratyush.anand@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/pci/host/pcie-designware.c |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -436,7 +436,7 @@ int dw_pcie_host_init(struct pcie_port *
 	struct resource *cfg_res;
 	int i, ret;
 	LIST_HEAD(res);
-	struct resource_entry *win;
+	struct resource_entry *win, *tmp;
 
 	cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
 	if (cfg_res) {
@@ -457,17 +457,20 @@ int dw_pcie_host_init(struct pcie_port *
 		goto error;
 
 	/* Get the I/O and memory ranges from DT */
-	resource_list_for_each_entry(win, &res) {
+	resource_list_for_each_entry_safe(win, tmp, &res) {
 		switch (resource_type(win->res)) {
 		case IORESOURCE_IO:
-			pp->io = win->res;
-			pp->io->name = "I/O";
-			pp->io_size = resource_size(pp->io);
-			pp->io_bus_addr = pp->io->start - win->offset;
-			ret = pci_remap_iospace(pp->io, pp->io_base);
-			if (ret)
+			ret = pci_remap_iospace(win->res, pp->io_base);
+			if (ret) {
 				dev_warn(pp->dev, "error %d: failed to map resource %pR\n",
-					 ret, pp->io);
+					 ret, win->res);
+				resource_list_destroy_entry(win);
+			} else {
+				pp->io = win->res;
+				pp->io->name = "I/O";
+				pp->io_size = resource_size(pp->io);
+				pp->io_bus_addr = pp->io->start - win->offset;
+			}
 			break;
 		case IORESOURCE_MEM:
 			pp->mem = win->res;



  parent reply	other threads:[~2016-10-29 13:54 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161029135133uscas1p244a56d26b4705445442b5e2e8454ba28@uscas1p2.samsung.com>
2016-10-29 13:48 ` [PATCH 4.8 000/125] 4.8.6-stable review Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 001/125] drm/vc4: Fix races when the CS reads from render targets Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 005/125] drm/amdgpu: fix IB alignment for UVD Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 006/125] drm/amdgpu/dce10: disable hpd on local panels Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 007/125] drm/amdgpu/dce8: " Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 008/125] drm/amdgpu/dce11: " Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 009/125] drm/amdgpu/dce11: add missing drm_mode_config_cleanup call Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 011/125] drm/amdgpu: change vblank_times calculation method to reduce computational error Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 012/125] drm/radeon: narrow asic_init for virtualization Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 013/125] drm/radeon/si/dpm: fix phase shedding setup Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 014/125] drm/radeon: change vblank_times calculation method to reduce computational error Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 015/125] drm/vmwgfx: Limit the user-space command buffer size Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 016/125] drm/fsl-dcu: fix endian issue when using clk_register_divider Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 017/125] drm/amd/powerplay: fix mclk not switching back after multi-head was disabled Greg Kroah-Hartman
2016-10-29 13:48   ` [PATCH 4.8 018/125] HID: add quirk for Akai MIDImix Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 022/125] drm/i915/skl: Dont try to update plane watermarks if they havent changed Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 023/125] drm/i915/gen9: only add the planes actually affected by ddb changes Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 024/125] drm/i915/gen9: fix the WaWmMemoryReadLatency implementation Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 025/125] drm/i915/gen9: minimum scanlines for Y tile is not always 4 Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 026/125] drm/i915/gen9: fix plane_blocks_per_line on watermarks calculations Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 027/125] drm/i915/gen9: fix the watermark res_blocks value Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 028/125] drm/i915: SAGV is not SKL-only, so rename a few things Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 029/125] drm/i915: introduce intel_has_sagv() Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 030/125] drm/i915/kbl: KBL also needs to run the SAGV code Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 031/125] Revert "drm/i915: Check live status before reading edid" Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 037/125] drm/i915: Just clear the mmiodebug before a register access Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 038/125] drm/i915: Unalias obj->phys_handle and obj->userptr Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 039/125] posix_acl: Clear SGID bit when setting file permissions Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 040/125] rt2x00usb: Fix error return code Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 041/125] scsi: cxlflash: Remove the device cleanly in the system shutdown path Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 042/125] genirq/generic_chip: Add irq_unmap callback Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 043/125] coresight: Remove erroneous dma_free_coherent in tmc_probe Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 044/125] uio: fix dmem_region_start computation Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 046/125] spi: spi-fsl-dspi: Drop extra spi_master_put in device remove function Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 047/125] i40e: remove a stray unlock Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 048/125] i40e: fix broken i40e_config_rss_aq function Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 049/125] mwifiex: correct aid value during tdls setup Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 050/125] mwifiex: fix failed to reconnect after interface disabled/enabled Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 051/125] ath10k: Add WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT wmi service Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 052/125] ath10k: fix sending frame in management path in push txq logic Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 053/125] ath10k: fix reporting channel survey data Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 054/125] ath10k: fix throughput regression in multi client mode Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 055/125] crypto: marvell - Dont overwrite default creq->state during initialization Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 057/125] crypto: marvell - Update transformation context for each dequeued req Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 058/125] crypto: arm/ghash-ce - add missing async import/export Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 059/125] crypto: ccp - Fix return value check in ccp_dmaengine_register() Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 060/125] hwrng: omap - Only fail if pm_runtime_get_sync returns < 0 Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 061/125] ASoC: topology: Fix error return code in soc_tplg_dapm_widget_create() Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 062/125] ASoC: dapm: Fix possible uninitialized variable in snd_soc_dapm_get_volsw() Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 063/125] ASoC: dapm: Fix value setting for _ENUM_DOUBLE MUXs second channel Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 064/125] ASoC: dapm: Fix kcontrol creation for output driver widget Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 065/125] ASoC: sst-bxt-rt298: fix obsoleted initializers for array Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 066/125] ASoC: sst-bxt-da7219_max98357a: " Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 067/125] iio: ad5755: fix off-by-one on devnr limit check Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 068/125] iio: light: us5182d: Add missing error code assignment before test Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 069/125] staging: android ion/hisi: fix dependencies Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 070/125] staging: sm750fb: Correctly set CLOCK_PHASE bit of display controller Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 071/125] staging: r8188eu: Fix scheduling while atomic splat Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 072/125] staging: ks7010: fix wait_for_completion_interruptible_timeout return handling Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 073/125] staging: ks7010: declare private functions static Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 074/125] IB/hfi1: Move iowait_init() to priv allocate Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 075/125] IB/rdmavt: Correct sparse annotation Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 076/125] IB/qib: Remove qpt_mask global Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 077/125] IB/mlx5: Fix steering resource leak Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 078/125] power: bq24257: Fix use of uninitialized pointer bq->charger Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 079/125] dmaengine: ipu: remove bogus NO_IRQ reference Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 080/125] mm/hugetlb: check for reserved hugepages during memory offline Greg Kroah-Hartman
2016-10-29 13:49   ` [PATCH 4.8 081/125] mm/hugetlb: improve locking in dissolve_free_huge_pages() Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 082/125] drm/vmwgfx: Avoid validating views on view destruction Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 083/125] s390/cio: fix accidental interrupt enabling during resume Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 084/125] s390/con3270: fix use of uninitialised data Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 085/125] s390/con3270: fix insufficient space padding Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 086/125] clk: bcm2835: Skip PLLC clocks when deciding on a new clock parent Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 087/125] clk: gcc-msm8996: Fix pcie 2 pipe register offset Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 088/125] clk: qcom: select GDSC for msm8996 gcc and mmcc Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 089/125] clk: qoriq: fix a register offset error Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 090/125] clk: Return errors from clk providers in __of_clk_get_from_provider() Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 091/125] clk: core: Force setting the phase delay when no change Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 092/125] clk: divider: Fix clk_divider_round_rate() to use clk_readl() Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 093/125] perf data: Fix building in 32 bit platform with libbabeltrace Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 094/125] perf hists browser: Fix event group display Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 095/125] perf powerpc: Fix build-test failure Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 097/125] perf ui/stdio: Always reset output width for hierarchy Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 098/125] perf symbols: Check symbol_conf.allow_aliases for kallsyms loading too Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 099/125] perf symbols: Fixup symbol sizes before picking best ones Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 100/125] iwlwifi: check for valid ethernet address provided by OEM Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 101/125] iwlwifi: mvm: fix pending frames tracking on tx resp Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 102/125] iwlwifi: mvm: call a different txq_enable function Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 103/125] iwlwifi: mvm: free reserved queue on STA removal Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 104/125] iwlwifi: mvm: support BAR in reorder buffer Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 105/125] iwlwifi: mvm: disable P2P queue on mac context release Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 106/125] iwlwifi: mvm: bail out if CTDP start operation fails Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 107/125] ARM: dts: sun9i: Add missing #interrupt-cells to R_PIO pinctrl device node Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 108/125] pinctrl: qcom: fix masking of pinmux functions Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 109/125] mpt3sas: Dont spam logs if logging level is 0 Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 110/125] powerpc: Always restore FPU/VEC/VSX if hardware transactional memory in use Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 111/125] powerpc: Add check_if_tm_restore_required() to giveup_all() Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 112/125] powerpc/nvram: Fix an incorrect partition merge Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 113/125] powerpc: Fix usage of _PAGE_RO in hugepage Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 114/125] ARM: pxa: pxa_cplds: fix interrupt handling Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 115/125] ARM: pxa: fix GPIO double shifts Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 116/125] ARM: dts: NSP: Correct RAM amount for BCM958625HR board Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 117/125] ARM: dts: fix RealView EB SMSC ethernet version Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 118/125] ARM: dts: omap3: overo: add missing unit name for lcd35 display Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 119/125] PCI: rcar: Fix pci_remap_iospace() failure path Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 120/125] PCI: aardvark: " Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 121/125] PCI: generic: " Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 122/125] PCI: versatile: " Greg Kroah-Hartman
2016-10-29 13:50   ` Greg Kroah-Hartman [this message]
2016-10-29 13:50   ` [PATCH 4.8 124/125] PCI: tegra: " Greg Kroah-Hartman
2016-10-29 13:50   ` [PATCH 4.8 125/125] libnvdimm: clear the internal poison_list when clearing badblocks Greg Kroah-Hartman
2016-10-29 23:07   ` [PATCH 4.8 000/125] 4.8.6-stable review Shuah Khan
2016-10-30 10:29     ` Greg Kroah-Hartman
2016-10-30  0:44   ` Guenter Roeck
2016-10-30 10:28     ` Greg Kroah-Hartman

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=20161029134952.247423949@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=bhelgaas@google.com \
    --cc=jingoohan1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=pratyush.anand@gmail.com \
    --cc=stable@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).