public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Ben Hutchings <bhutchings@solarflare.com>,
	Jesse Barnes <jbarnes@virtuousgeek.org>
Subject: [017/129] PCI: MSI: Remove unsafe and unnecessary hardware access
Date: Sat, 18 Sep 2010 12:11:55 -0700	[thread overview]
Message-ID: <20100918191258.717423689@clark.site> (raw)
In-Reply-To: <20100918191317.GA11386@kroah.com>

2.6.35-stable review patch.  If anyone has any objections, please let us know.

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

From: Ben Hutchings <bhutchings@solarflare.com>

commit fcd097f31a6ee207cc0c3da9cccd2a86d4334785 upstream.

During suspend on an SMP system, {read,write}_msi_msg_desc() may be
called to mask and unmask interrupts on a device that is already in a
reduced power state.  At this point memory-mapped registers including
MSI-X tables are not accessible, and config space may not be fully
functional either.

While a device is in a reduced power state its interrupts are
effectively masked and its MSI(-X) state will be restored when it is
brought back to D0.  Therefore these functions can simply read and
write msi_desc::msg for devices not in D0.

Further, read_msi_msg_desc() should only ever be used to update a
previously written message, so it can always read msi_desc::msg
and never needs to touch the hardware.

Tested-by: "Michael Chan" <mchan@broadcom.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/pci/msi.c |   36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -196,30 +196,15 @@ void unmask_msi_irq(unsigned int irq)
 void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg)
 {
 	struct msi_desc *entry = get_irq_desc_msi(desc);
-	if (entry->msi_attrib.is_msix) {
-		void __iomem *base = entry->mask_base +
-			entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE;
 
-		msg->address_lo = readl(base + PCI_MSIX_ENTRY_LOWER_ADDR);
-		msg->address_hi = readl(base + PCI_MSIX_ENTRY_UPPER_ADDR);
-		msg->data = readl(base + PCI_MSIX_ENTRY_DATA);
-	} else {
-		struct pci_dev *dev = entry->dev;
-		int pos = entry->msi_attrib.pos;
-		u16 data;
-
-		pci_read_config_dword(dev, msi_lower_address_reg(pos),
-					&msg->address_lo);
-		if (entry->msi_attrib.is_64) {
-			pci_read_config_dword(dev, msi_upper_address_reg(pos),
-						&msg->address_hi);
-			pci_read_config_word(dev, msi_data_reg(pos, 1), &data);
-		} else {
-			msg->address_hi = 0;
-			pci_read_config_word(dev, msi_data_reg(pos, 0), &data);
-		}
-		msg->data = data;
-	}
+	/* We do not touch the hardware (which may not even be
+	 * accessible at the moment) but return the last message
+	 * written.  Assert that this is valid, assuming that
+	 * valid messages are not all-zeroes. */
+	BUG_ON(!(entry->msg.address_hi | entry->msg.address_lo |
+		 entry->msg.data));
+
+	*msg = entry->msg;
 }
 
 void read_msi_msg(unsigned int irq, struct msi_msg *msg)
@@ -232,7 +217,10 @@ void read_msi_msg(unsigned int irq, stru
 void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg)
 {
 	struct msi_desc *entry = get_irq_desc_msi(desc);
-	if (entry->msi_attrib.is_msix) {
+
+	if (entry->dev->current_state != PCI_D0) {
+		/* Don't touch the hardware now */
+	} else if (entry->msi_attrib.is_msix) {
 		void __iomem *base;
 		base = entry->mask_base +
 			entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE;



  parent reply	other threads:[~2010-09-18 19:38 UTC|newest]

Thread overview: 132+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-18 19:13 [000/129] 2.6.35.5 -stable review Greg KH
2010-09-18 19:11 ` [001/129] hwmon: (ads7871) Fix ads7871_probe error paths Greg KH
2010-09-18 19:11 ` [002/129] hwmon: (k8temp) Differentiate between AM2 and ASB1 Greg KH
2010-09-18 19:11 ` [003/129] xen: handle events as edge-triggered Greg KH
2010-09-18 19:11 ` [004/129] xen: use percpu interrupts for IPIs and VIRQs Greg KH
2010-09-18 19:11 ` [005/129] xfs: fix untrusted inode number lookup Greg KH
2010-09-18 19:11 ` [006/129] xfs: ensure we mark all inodes in a freed cluster XFS_ISTALE Greg KH
2010-09-18 19:11 ` [007/129] ALSA: hda - Add Sony VAIO quirk for ALC269 Greg KH
2010-09-18 19:11 ` [008/129] ALSA: HDA: Use model=auto for LG R510 Greg KH
2010-09-18 19:11 ` [009/129] ALSA: hda - Rename iMic to Int Mic on Lenovo NB0763 Greg KH
2010-09-18 19:11 ` [010/129] libata-sff: remove harmful BUG_ON from ata_bmdma_qc_issue Greg KH
2010-09-18 19:11 ` [011/129] sata_mv: fix broken DSM/TRIM support (v2) Greg KH
2010-09-18 19:11 ` [012/129] pata_cmd64x: revert commit d62f5576 Greg KH
2010-09-18 19:11 ` [013/129] writeback: write_cache_pages doesnt terminate at nr_to_write <= 0 Greg KH
2010-09-18 19:11 ` [014/129] x86, tsc, sched: Recompute cyc2ns_offsets during resume from sleep states Greg KH
2010-09-18 19:11 ` [015/129] perf, x86, Pentium4: Clear the P4_CCCR_FORCE_OVF flag Greg KH
2010-09-18 19:11 ` [016/129] netfilter: fix CONFIG_COMPAT support Greg KH
2010-09-18 19:11 ` Greg KH [this message]
2010-09-18 19:11 ` [018/129] PCI: MSI: Restore read_msi_msg_desc(); add get_cached_msi_msg_desc() Greg KH
2010-09-18 19:11 ` [019/129] direct-io: move aio_complete into ->end_io Greg KH
2010-09-18 19:11 ` [020/129] ext4: move aio completion after unwritten extent conversion Greg KH
2010-09-18 19:11 ` [021/129] xfs: " Greg KH
2010-09-18 19:12 ` [022/129] Revert "Input: appletouch - fix integer overflow issue" Greg KH
2010-09-18 19:12 ` [023/129] ALSA: hda - Handle missing NID 0x1b on ALC259 codec Greg KH
2010-09-18 19:12 ` [024/129] ALSA: hda - Handle pin NID 0x1a on ALC259/269 Greg KH
2010-09-18 19:12 ` [025/129] Staging: rt2870sta: Add more device IDs from vendor drivers Greg KH
2010-09-18 19:12 ` [026/129] staging: hv: Fix missing functions for net_device_ops Greg KH
2010-09-18 19:12 ` [027/129] staging: hv: Fixed bounce kmap problem by using correct index Greg KH
2010-09-18 19:12 ` [028/129] staging: hv: Fixed the value of the 64bit-hole inside ring buffer Greg KH
2010-09-18 19:12 ` [029/129] staging: hv: Increased storvsc ringbuffer and max_io_requests Greg KH
2010-09-18 19:12 ` [030/129] staging: hv: Fixed lockup problem with bounce_buffer scatter list Greg KH
2010-09-18 19:12 ` [031/129] fuse: flush background queue on connection close Greg KH
2010-09-18 19:12 ` [032/129] mac80211: delete work timer Greg KH
2010-09-18 19:12 ` [033/129] ath9k_htc: Fix disconnect issue in HT40 mode Greg KH
2010-09-18 19:12 ` [034/129] ath9k_hw: Fix EEPROM uncompress block reading on AR9003 Greg KH
2010-09-18 19:12 ` [035/129] ath9k_hw: fix parsing of HT40 5 GHz CTLs Greg KH
2010-09-18 19:12 ` [036/129] ocfs2: Fix incorrect checksum validation error Greg KH
2010-09-18 19:12 ` [037/129] serial: bfin_sport_uart: restore transmit frame sync fix Greg KH
2010-09-18 19:12 ` [038/129] USB: ehci-ppc-of: problems in unwind Greg KH
2010-09-18 19:12 ` [039/129] USB: Fix kernel oops with g_ether and Windows Greg KH
2010-09-18 19:12 ` [040/129] USB: CP210x Add new device ID Greg KH
2010-09-18 19:12 ` [041/129] USB: cp210x: Add B&G H3000 link cable ID Greg KH
2010-09-18 19:12 ` [042/129] usb: allow drivers to use allocated bandwidth until unbound Greg KH
2010-09-18 19:12 ` [043/129] USB: ftdi_sio: Added custom PIDs for ChamSys products Greg KH
2010-09-18 19:12 ` [044/129] usb: serial: mos7840: Add USB ID to support the B&B Electronics USOPTL4-2P Greg KH
2010-09-18 19:12 ` [045/129] usb: serial: mos7840: Add USB IDs to support more B&B USB/RS485 converters Greg KH
2010-09-18 19:12 ` [046/129] ima: always maintain counters Greg KH
2010-09-18 19:12 ` [047/129] USB: cxacru: Use a bulk/int URB to access the command endpoint Greg KH
2010-09-18 19:12 ` [048/129] USB: cdc-acm: Adding second ACM channel support for various Nokia and one Samsung phones Greg KH
2010-09-18 19:12 ` [049/129] USB: cdc-acm: Add pseudo modem without AT command capabilities Greg KH
2010-09-18 19:12 ` [050/129] USB: cdc-acm: Fixing crash when ACM probing interfaces with no endpoint descriptors Greg KH
2010-09-18 19:12 ` [051/129] ALSA: hda - Add a new hp-laptop model for Conexant 5066, tested on HP G60 Greg KH
2010-09-18 19:12 ` [052/129] ALSA: usb-audio: fix detection of vendor-specific device protocol settings Greg KH
2010-09-18 19:12 ` [053/129] ALSA: virtuoso: work around missing reset in the Xonar DS Windows driver Greg KH
2010-09-18 19:12 ` [054/129] ALSA: virtuoso: fix setting of Xonar DS line-in/mic-in controls Greg KH
2010-09-18 19:12 ` [055/129] ALSA: seq/oss - Fix double-free at error path of snd_seq_oss_open() Greg KH
2010-09-18 19:12 ` [056/129] ALSA: usb - Release capture substream URBs properly Greg KH
2010-09-18 19:12 ` [057/129] ALSA: hda - Add quirk for Lenovo T400s Greg KH
2010-09-18 19:12 ` [058/129] ALSA: hda - Add errata initverb sequence for CS42xx codecs Greg KH
2010-09-18 19:12 ` [059/129] ALSA: hda - Fix wrong HP pin detection in snd_hda_parse_pin_def_config() Greg KH
2010-09-18 19:12 ` [060/129] ALSA: usb-audio: Assume first control interface is for audio Greg KH
2010-09-18 19:12 ` [061/129] ALSA: hda - patch_nvhdmi.c: Add missing codec IDs, unify names Greg KH
2010-09-18 19:12 ` [062/129] swap: prevent reuse during hibernation Greg KH
2010-09-18 19:12 ` [063/129] swap: discard while swapping only if SWAP_FLAG_DISCARD Greg KH
2010-09-18 19:12 ` [064/129] swap: do not send discards as barriers Greg KH
2010-09-18 19:12 ` [065/129] sysfs: checking for NULL instead of ERR_PTR Greg KH
2010-09-18 19:12 ` [066/129] oprofile: fix crash when accessing freed task structs Greg KH
2010-09-18 19:12 ` [067/129] oprofile, x86: fix init_sysfs error handling Greg KH
2010-09-18 19:12 ` [068/129] oprofile, x86: fix init_sysfs() function stub Greg KH
2010-09-18 19:12 ` [069/129] HID: Set Report ID properly for Output reports on the Control endpoint Greg KH
2010-09-18 19:12 ` [070/129] libata: skip EH autopsy and recovery during suspend Greg KH
2010-09-18 19:12 ` [071/129] libata,pata_via: revert ata_wait_idle() removal from ata_sff/via_tf_load() Greg KH
2010-09-18 19:12 ` [072/129] ahci: fix hang on failed softreset Greg KH
2010-09-18 19:12 ` [073/129] O_DIRECT: fix the splitting up of contiguous I/O Greg KH
2010-09-18 19:12 ` [074/129] tracing: Fix a race in function profile Greg KH
2010-09-18 19:12 ` [075/129] tracing: Do not allow llseek to set_ftrace_filter Greg KH
2010-09-18 19:12 ` [076/129] tracing: t_start: reset FTRACE_ITER_HASH in case of seek/pread Greg KH
2010-09-18 19:12 ` [077/129] irda: off by one Greg KH
2010-09-18 19:12 ` [078/129] hp_accel: add quirks for HP ProBook 532x and HP Mini 5102 Greg KH
2010-09-18 19:12 ` [079/129] gcov: fix null-pointer dereference for certain module types Greg KH
2010-09-18 19:12 ` [080/129] tmio_mmc: dont clear unhandled pending interrupts Greg KH
2010-09-18 19:12 ` [081/129] mmc: fix the use of kunmap_atomic() in tmio_mmc.h Greg KH
2010-09-18 19:13 ` [082/129] mmc: fix all hangs related to mmc/sd card insert/removal during suspend/resume Greg KH
2010-09-18 19:13 ` [083/129] mmc: build fix: mmc_pm_notify is only available with CONFIG_PM=y Greg KH
2010-09-18 19:13 ` [084/129] statfs() gives ESTALE error Greg KH
2010-09-18 19:13 ` [085/129] minix: fix regression in minix_mkdir() Greg KH
2010-09-18 19:13 ` [086/129] bounce: call flush_dcache_page() after bounce_copy_vec() Greg KH
2010-09-18 19:13 ` [087/129] mm: compaction: handle active and inactive fairly in too_many_isolated Greg KH
2010-09-18 19:13 ` [088/129] kernel/groups.c: fix integer overflow in groups_search Greg KH
2010-09-18 19:13 ` [089/129] binfmt_misc: fix binfmt_misc priority Greg KH
2010-09-18 19:13 ` [090/129] Input: i8042 - fix device removal on unload Greg KH
2010-09-18 19:13 ` [091/129] Input: i8042 - reset keyboard controller wehen resuming from S2R Greg KH
2010-09-18 19:13 ` [092/129] memory hotplug: fix next block calculation in is_removable Greg KH
2010-09-18 19:13 ` [093/129] perf: Initialize callchains rootss childen hits Greg KH
2010-09-18 19:13 ` [094/129] powerpc/perf_event: Reduce latency of calling perf_event_do_pending Greg KH
2010-09-18 19:13 ` [095/129] p54: fix tx feedback status flag check Greg KH
2010-09-18 19:13 ` [096/129] ath5k: check return value of ieee80211_get_tx_rate Greg KH
2010-09-18 19:13 ` [097/129] wireless extensions: fix kernel heap content leak Greg KH
2010-09-18 19:13 ` [098/129] RDMA/cxgb3: Dont exceed the max HW CQ depth Greg KH
2010-09-18 19:13 ` [099/129] x86, tsc: Fix a preemption leak in restore_sched_clock_state() Greg KH
2010-09-18 19:13 ` [100/129] x86-64, compat: Test %rax for the syscall number, not %eax Greg KH
2010-09-18 19:13 ` [101/129] compat: Make compat_alloc_user_space() incorporate the access_ok() Greg KH
2010-09-18 19:13 ` [102/129] x86-64, compat: Retruncate rax after ia32 syscall entry tracing Greg KH
2010-09-18 19:13 ` [103/129] ALSA: HDA: Enable internal speaker on Dell M101z Greg KH
2010-09-18 19:13 ` [104/129] x86: hpet: Work around hardware stupidity Greg KH
2010-09-18 19:13 ` [105/129] arm: fix really nasty sigreturn bug Greg KH
2010-09-18 19:13 ` [106/129] hwmon: (emc1403) Remove unnecessary hwmon_device_unregister Greg KH
2010-09-18 19:13 ` [107/129] hwmon: (f75375s) Shift control mode to the correct bit position Greg KH
2010-09-18 19:13 ` [108/129] hwmon: (f75375s) Do not overwrite values read from registers Greg KH
2010-09-18 19:13 ` [109/129] apm_power: Add missing break statement Greg KH
2010-09-18 19:13 ` [110/129] cifs: fix potential double put of TCP session reference Greg KH
2010-09-18 19:13 ` [111/129] NFS: Fix a typo in nfs_sockaddr_match_ipaddr6 Greg KH
2010-09-18 19:13 ` [112/129] SUNRPC: Fix race corrupting rpc upcall Greg KH
2010-09-18 19:13 ` [113/129] agp/intel: Promote warning about failure to setup flush to error Greg KH
2010-09-18 19:13 ` [114/129] drm/radeon/kms: fix a regression on r7xx AGP due to the HDP flush fix Greg KH
2010-09-18 19:13 ` [115/129] drm/i915: Enable MI_FLUSH on Sandybridge Greg KH
2010-09-18 19:13 ` [116/129] drm/radeon/kms: force legacy pll algo for RV515 LVDS Greg KH
2010-09-18 19:13 ` [117/129] drm/radeon/kms: force legacy pll algo for RV620 LVDS Greg KH
2010-09-18 19:13 ` [118/129] drm/radeon/kms: properly set crtc high base on r7xx Greg KH
2010-09-18 19:13 ` [119/129] drm/radeon/kms/evergreen: fix gpu hangs in userspace accel code Greg KH
2010-09-18 19:13 ` [120/129] drm/radeon/kms/evergreen: fix backend setup Greg KH
2010-09-18 19:13 ` [121/129] i915: return -EFAULT if copy_to_user fails Greg KH
2010-09-18 19:13 ` [122/129] i915_gem: " Greg KH
2010-09-18 19:13 ` [123/129] drm/i915/dp: Really try 5 times before giving up Greg KH
2010-09-18 19:13 ` [124/129] drm/i915: Allocate the PCI resource for the MCHBAR Greg KH
2010-09-18 19:13 ` [125/129] drm/i915: overlay on gen2 cant address above 1G Greg KH
2010-09-18 19:13 ` [126/129] drm/i915: Prevent double dpms on Greg KH
2010-09-18 19:13 ` [127/129] drm/i915: dont enable self-refresh on Ironlake Greg KH
2010-09-18 19:13 ` [128/129] Revert "drm/i915: Allow LVDS on pipe A on gen4+" Greg KH
2010-09-18 19:13 ` [129/129] drm: Only decouple the old_fb from the crtc is we call mode_set* Greg KH
2010-09-18 21:08 ` [000/129] 2.6.35.5 -stable review Marcin Slusarz
2010-09-19  4:04   ` Greg KH

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=20100918191258.717423689@clark.site \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=bhutchings@solarflare.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.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