public inbox for stable@vger.kernel.org
 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, Michael Neuling <mikey@neuling.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: [ 086/127] powerpc/tm: Abort on emulation and alignment faults
Date: Wed,  5 Jun 2013 14:34:13 -0700	[thread overview]
Message-ID: <20130605213227.685711779@linuxfoundation.org> (raw)
In-Reply-To: <20130605213217.966891866@linuxfoundation.org>

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

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

From: Michael Neuling <mikey@neuling.org>

commit 6ce6c629fd8254b3177650de99699682ff7f6707 upstream.

If we are emulating an instruction inside an active user transaction that
touches memory, the kernel can't emulate it as it operates in transactional
suspend context.  We need to abort these transactions and send them back to
userspace for the hardware to rollback.

We can service these if the user transaction is in suspend mode, since the
kernel will operate in the same suspend context.

This adds a check to all alignment faults and to specific instruction
emulations (only string instructions for now).  If the user process is in an
active (non-suspended) transaction, we abort the transaction go back to
userspace allowing the HW to roll back the transaction and tell the user of the
failure.  This also adds new tm abort cause codes to report the reason of the
persistent error to the user.

Crappy test case here http://neuling.org/devel/junkcode/aligntm.c

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 Documentation/powerpc/transactional_memory.txt |    7 ++++--
 arch/powerpc/include/asm/reg.h                 |    2 +
 arch/powerpc/kernel/traps.c                    |   29 +++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)

--- a/Documentation/powerpc/transactional_memory.txt
+++ b/Documentation/powerpc/transactional_memory.txt
@@ -180,9 +180,12 @@ kernel aborted a transaction:
                         transactions for consistency will use this.
  TM_CAUSE_SIGNAL        Signal delivered.
  TM_CAUSE_MISC          Currently unused.
+ TM_CAUSE_ALIGNMENT     Alignment fault.
+ TM_CAUSE_EMULATE       Emulation that touched memory.
 
-These can be checked by the user program's abort handler as TEXASR[0:7].
-
+These can be checked by the user program's abort handler as TEXASR[0:7].  If
+bit 7 is set, it indicates that the error is consider persistent.  For example
+a TM_CAUSE_ALIGNMENT will be persistent while a TM_CAUSE_RESCHED will not.q
 
 GDB
 ===
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -122,6 +122,8 @@
 #define TM_CAUSE_SYSCALL	0xd8  /* future use */
 #define TM_CAUSE_MISC		0xd6  /* future use */
 #define TM_CAUSE_SIGNAL		0xd4
+#define TM_CAUSE_ALIGNMENT	0xd2
+#define TM_CAUSE_EMULATE	0xd0
 
 #if defined(CONFIG_PPC_BOOK3S_64)
 #define MSR_64BIT	MSR_SF
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -52,6 +52,7 @@
 #ifdef CONFIG_PPC64
 #include <asm/firmware.h>
 #include <asm/processor.h>
+#include <asm/tm.h>
 #endif
 #include <asm/kexec.h>
 #include <asm/ppc-opcode.h>
@@ -913,6 +914,28 @@ static int emulate_isel(struct pt_regs *
 	return 0;
 }
 
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+static inline bool tm_abort_check(struct pt_regs *regs, int cause)
+{
+        /* If we're emulating a load/store in an active transaction, we cannot
+         * emulate it as the kernel operates in transaction suspended context.
+         * We need to abort the transaction.  This creates a persistent TM
+         * abort so tell the user what caused it with a new code.
+	 */
+	if (MSR_TM_TRANSACTIONAL(regs->msr)) {
+		tm_enable();
+		tm_abort(cause);
+		return true;
+	}
+	return false;
+}
+#else
+static inline bool tm_abort_check(struct pt_regs *regs, int reason)
+{
+	return false;
+}
+#endif
+
 static int emulate_instruction(struct pt_regs *regs)
 {
 	u32 instword;
@@ -952,6 +975,9 @@ static int emulate_instruction(struct pt
 
 	/* Emulate load/store string insn. */
 	if ((instword & PPC_INST_STRING_GEN_MASK) == PPC_INST_STRING) {
+		if (tm_abort_check(regs,
+				   TM_CAUSE_EMULATE | TM_CAUSE_PERSISTENT))
+			return -EINVAL;
 		PPC_WARN_EMULATED(string, regs);
 		return emulate_string_inst(regs, instword);
 	}
@@ -1124,6 +1150,9 @@ void alignment_exception(struct pt_regs
 	if (!arch_irq_disabled_regs(regs))
 		local_irq_enable();
 
+	if (tm_abort_check(regs, TM_CAUSE_ALIGNMENT | TM_CAUSE_PERSISTENT))
+		goto bail;
+
 	/* we don't implement logging of alignment exceptions */
 	if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
 		fixed = fix_alignment(regs);



  parent reply	other threads:[~2013-06-05 21:34 UTC|newest]

Thread overview: 128+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-05 21:32 [ 000/127] 3.9.5-stable review Greg Kroah-Hartman
2013-06-05 21:32 ` [ 001/127] avr32: fix relocation check for signed 18-bit offset Greg Kroah-Hartman
2013-06-05 21:32 ` [ 002/127] USB: OHCI: fix logic for scheduling isochronous URBs Greg Kroah-Hartman
2013-06-05 21:32 ` [ 003/127] USB: fix latency in uhci-hcd and ohci-hcd Greg Kroah-Hartman
2013-06-05 21:32 ` [ 004/127] ARM: plat-orion: Fix num_resources and id for ge10 and ge11 Greg Kroah-Hartman
2013-06-05 21:32 ` [ 005/127] ARM: OMAP: fix __init section mismatch for _enable_preprogram Greg Kroah-Hartman
2013-06-05 21:32 ` [ 006/127] ARM: AM33XX: Add missing .clkdm_name to clkdiv32k_ick clock Greg Kroah-Hartman
2013-06-05 21:32 ` [ 007/127] ARM: 7723/1: crypto: sha1-armv4-large.S: fix SP handling Greg Kroah-Hartman
2013-06-05 21:32 ` [ 008/127] ARM: at91/trivial: fix model name for SAM9X25-EK Greg Kroah-Hartman
2013-06-05 21:32 ` [ 009/127] ARM: at91: rm9200 fix time support Greg Kroah-Hartman
2013-06-05 21:32 ` [ 010/127] ARM: at91/dt: fix macb pinctrl_macb_rmii_mii_alt definition Greg Kroah-Hartman
2013-06-05 21:32 ` [ 011/127] cfg80211: fix WoWLAN wakeup tracing Greg Kroah-Hartman
2013-06-05 21:32 ` [ 012/127] cfg80211: fix wiphy_register error path Greg Kroah-Hartman
2013-06-05 21:33 ` [ 013/127] cfg80211: fix sending WoWLAN TCP wakeup settings Greg Kroah-Hartman
2013-06-05 21:33 ` [ 014/127] mac80211: use just spin_lock() in ieee80211_get_tkip_p2k() Greg Kroah-Hartman
2013-06-05 21:33 ` [ 015/127] mac80211: fix AP-mode frame matching Greg Kroah-Hartman
2013-06-05 21:33 ` [ 016/127] iwlwifi: mvm: Always use SCAN_TYPE_FORCED Greg Kroah-Hartman
2013-06-05 21:33 ` [ 017/127] iwlwifi: mvm: Prevent setting assoc flag in MAC_CONTEXT_CMD Greg Kroah-Hartman
2013-06-05 21:33 ` [ 018/127] staging: vt6656: [bug] Fix missing spin lock in iwctl_siwpower Greg Kroah-Hartman
2013-06-05 21:33 ` [ 019/127] staging: vt6656: use free_netdev instead of kfree Greg Kroah-Hartman
2013-06-05 21:33 ` [ 020/127] usb, chipidea: fix link error when USB_EHCI_HCD is a module Greg Kroah-Hartman
2013-06-05 21:33 ` [ 021/127] usb: option: Add Telewell TW-LTE 4G Greg Kroah-Hartman
2013-06-05 21:33 ` [ 022/127] USB: option: add device IDs for Dell 5804 (Novatel E371) WWAN card Greg Kroah-Hartman
2013-06-05 21:33 ` [ 023/127] USB: ftdi_sio: Add support for Newport CONEX motor drivers Greg Kroah-Hartman
2013-06-05 21:33 ` [ 024/127] USB: cxacru: potential underflow in cxacru_cm_get_array() Greg Kroah-Hartman
2013-06-05 21:33 ` [ 025/127] TTY: Fix tty miss restart after we turn off flow-control Greg Kroah-Hartman
2013-06-05 21:33 ` [ 026/127] USB: Blacklisted Cinterions PLxx WWAN Interface Greg Kroah-Hartman
2013-06-05 21:33 ` [ 027/127] USB: reset resume quirk needed by a hub Greg Kroah-Hartman
2013-06-05 21:33 ` [ 028/127] USB: xHCI: override bogus bulk wMaxPacketSize values Greg Kroah-Hartman
2013-06-05 21:33 ` [ 029/127] USB: UHCI: fix for suspend of virtual HP controller Greg Kroah-Hartman
2013-06-05 21:33 ` [ 030/127] Input: egalax_ts - ABS_MT_POSITION_Y not reported well Greg Kroah-Hartman
2013-06-05 21:33 ` [ 031/127] Drivers: hv: Fix a bug in get_vp_index() Greg Kroah-Hartman
2013-06-05 21:33 ` [ 032/127] cifs: only set ops for inodes in I_NEW state Greg Kroah-Hartman
2013-06-05 21:33 ` [ 033/127] ARC: copy_(to|from)_user() to honor usermode-access permissions Greg Kroah-Hartman
2013-06-05 21:33 ` [ 034/127] drivers/char/random.c: fix priming of last_data Greg Kroah-Hartman
2013-06-05 21:33 ` [ 035/127] random: fix accounting race condition with lockless irq entropy_count update Greg Kroah-Hartman
2013-06-05 21:33 ` [ 036/127] fat: fix possible overflow for fat_clusters Greg Kroah-Hartman
2013-06-05 21:33 ` [ 037/127] tg3: Skip powering down function 0 on certain serdes devices Greg Kroah-Hartman
2013-06-05 21:33 ` [ 038/127] tg3: Fix data corruption on 5725 with TSO Greg Kroah-Hartman
2013-06-05 21:33 ` [ 039/127] perf: net_dropmonitor: Fix trace parameter order Greg Kroah-Hartman
2013-06-05 21:33 ` [ 040/127] perf: net_dropmonitor: Fix symbol-relative addresses Greg Kroah-Hartman
2013-06-05 21:33 ` [ 041/127] ath9k: Fix crash on module unload Greg Kroah-Hartman
2013-06-05 21:33 ` [ 042/127] ath9k_hw: Enable manual peak calibration for AR9485 Greg Kroah-Hartman
2013-06-05 21:33 ` [ 043/127] ocfs2: goto out_unlock if ocfs2_get_clusters_nocache() failed in ocfs2_fiemap() Greg Kroah-Hartman
2013-06-05 21:33 ` [ 044/127] Kirkwood: Enable PCIe port 1 on QNAP TS-11x/TS-21x Greg Kroah-Hartman
2013-06-05 21:33 ` [ 045/127] drivers/leds/leds-ot200.c: fix error caused by shifted mask Greg Kroah-Hartman
2013-06-05 21:33 ` [ 046/127] rapidio/tsi721: fix bug in MSI interrupt handling Greg Kroah-Hartman
2013-06-05 21:33 ` [ 047/127] mm compaction: fix of improper cache flush in migration code Greg Kroah-Hartman
2013-06-05 21:33 ` [ 048/127] klist: del waiter from klist_remove_waiters before wakeup waitting process Greg Kroah-Hartman
2013-06-05 21:33 ` [ 049/127] wait: fix false timeouts when using wait_event_timeout() Greg Kroah-Hartman
2013-06-05 21:33 ` [ 050/127] nilfs2: fix issue of nilfs_set_page_dirty() for page at EOF boundary Greg Kroah-Hartman
2013-06-05 21:33 ` [ 051/127] mm: mmu_notifier: re-fix freed page still mapped in secondary MMU Greg Kroah-Hartman
2013-06-05 21:33 ` [ 052/127] mm: memcg: remove incorrect VM_BUG_ON for swap cache pages in uncharge Greg Kroah-Hartman
2013-06-05 21:33 ` [ 053/127] drivers/block/brd.c: fix brd_lookup_page() race Greg Kroah-Hartman
2013-06-05 21:33 ` [ 054/127] mm/pagewalk.c: walk_page_range should avoid VM_PFNMAP areas Greg Kroah-Hartman
2013-06-05 21:33 ` [ 055/127] mm/THP: use pmd_populate() to update the pmd with pgtable_t pointer Greg Kroah-Hartman
2013-06-05 21:33 ` [ 056/127] SCSI: ipr: Need to reset adapter after the 6th EEH error Greg Kroah-Hartman
2013-06-05 21:33 ` [ 057/127] x86: Allow FPU to be used at interrupt time even with eagerfpu Greg Kroah-Hartman
2013-06-05 21:33 ` [ 058/127] x86-64, init: Fix a possible wraparound bug in switchover in head_64.S Greg Kroah-Hartman
2013-06-05 21:33 ` [ 059/127] x86, range: fix missing merge during add range Greg Kroah-Hartman
2013-06-05 21:33 ` [ 060/127] x86, crc32-pclmul: Fix build with older binutils Greg Kroah-Hartman
2013-06-05 21:33 ` [ 061/127] module: dont unlink the module until weve removed all exposure Greg Kroah-Hartman
2013-06-05 21:33 ` [ 062/127] xfs: kill suid/sgid through the truncate path Greg Kroah-Hartman
2013-06-05 21:33 ` [ 063/127] arm64: dont kill the kernel on a bad esr from el0 Greg Kroah-Hartman
2013-06-05 21:33 ` [ 064/127] ARM: SAMSUNG: Export MIPI CSIS/DSIM PHY control functions Greg Kroah-Hartman
2013-06-05 21:33 ` [ 065/127] SUNRPC: Prevent an rpc_task wakeup race Greg Kroah-Hartman
2013-06-05 21:33 ` [ 066/127] svcrpc: fix failures to handle -1 uids and gids Greg Kroah-Hartman
2013-06-05 21:33 ` [ 067/127] ASoC: cs42l52: fix default value for MASTERA_VOL Greg Kroah-Hartman
2013-06-05 21:33 ` [ 068/127] ASoC: wm5110: Correct DSP4R Mixer control name Greg Kroah-Hartman
2013-06-05 21:33 ` [ 069/127] drm/i915: Adding more reserved PCI IDs for Haswell Greg Kroah-Hartman
2013-06-05 21:33 ` [ 070/127] drm/radeon: fix typo in cu_per_sh on verde Greg Kroah-Hartman
2013-06-05 21:33 ` [ 071/127] drm/radeon: fix card_posted check for newer asics Greg Kroah-Hartman
2013-06-05 21:33 ` [ 072/127] crypto: caam - fix inconsistent assoc dma mapping direction Greg Kroah-Hartman
2013-06-05 21:34 ` [ 073/127] cifs: fix potential buffer overrun when composing a new options string Greg Kroah-Hartman
2013-06-05 21:34 ` [ 074/127] sata_rcar: clear STOP bit in bmdma_start() method Greg Kroah-Hartman
2013-06-05 21:34 ` [ 075/127] sata_rcar: fix interrupt handling Greg Kroah-Hartman
2013-06-05 21:34 ` [ 076/127] ata_piix: add PCI IDs for Intel BayTail Greg Kroah-Hartman
2013-06-05 21:34 ` [ 077/127] libata: make ata_exec_internal_sg honor DMADIR Greg Kroah-Hartman
2013-06-05 21:34 ` [ 078/127] m68k/mac: Fix unexpected interrupt with CONFIG_EARLY_PRINTK Greg Kroah-Hartman
2013-06-05 21:34 ` [ 079/127] s390/pgtable: Fix check for pgste/storage key handling Greg Kroah-Hartman
2013-06-05 21:34 ` [ 080/127] cgroup: initialize xattr before calling d_instantiate() Greg Kroah-Hartman
2013-06-05 21:34 ` [ 081/127] cgroup: fix a subtle bug in descendant pre-order walk Greg Kroah-Hartman
2013-06-05 21:34 ` [ 082/127] powerpc/32bit:Store temporary result in r0 instead of r8 Greg Kroah-Hartman
2013-06-05 21:34 ` [ 083/127] powerpc/tm: Make room for hypervisor in abort cause codes Greg Kroah-Hartman
2013-06-05 21:34 ` [ 084/127] powerpc/tm: Update cause codes documentation Greg Kroah-Hartman
2013-06-05 21:34 ` [ 085/127] powerpc/tm: Fix userspace stack corruption on signal delivery for active transactions Greg Kroah-Hartman
2013-06-05 21:34 ` Greg Kroah-Hartman [this message]
2013-06-05 21:34 ` [ 087/127] powerpc/tm: Move TM abort cause codes to uapi Greg Kroah-Hartman
2013-06-05 21:34 ` [ 088/127] iscsi-target: fix heap buffer overflow on error Greg Kroah-Hartman
2013-06-05 21:34 ` [ 089/127] ib_srpt: Call target_sess_cmd_list_set_waiting during shutdown_session Greg Kroah-Hartman
2013-06-05 21:34 ` [ 090/127] NFSv4: Fix a thinko in nfs4_try_open_cached Greg Kroah-Hartman
2013-06-05 21:34 ` [ 091/127] KVM: Emulate multibyte NOP Greg Kroah-Hartman
2013-06-05 21:34 ` [ 092/127] KVM: fix sil/dil/bpl/spl in the mod/rm fields Greg Kroah-Hartman
2013-06-05 21:34 ` [ 093/127] regulator: palmas: Fix "enable_reg" to point to the correct reg for SMPS10 Greg Kroah-Hartman
2013-06-05 21:34 ` [ 094/127] powerpc/pseries: Always enable CONFIG_HOTPLUG_CPU on PSERIES SMP Greg Kroah-Hartman
2013-06-05 21:34 ` [ 095/127] reiserfs: fix deadlock with nfs racing on create/lookup Greg Kroah-Hartman
2013-06-05 21:34 ` [ 096/127] reiserfs: fix problems with chowning setuid file w/ xattrs Greg Kroah-Hartman
2013-06-05 21:34 ` [ 097/127] reiserfs: fix spurious multiple-fill in reiserfs_readdir_dentry Greg Kroah-Hartman
2013-06-05 21:34 ` [ 098/127] jfs: fix a couple races Greg Kroah-Hartman
2013-06-05 21:34 ` [ 099/127] xen-netback: remove skb in xen_netbk_alloc_page Greg Kroah-Hartman
2013-06-05 21:34 ` [ 100/127] iwlwifi: mvm: fix aggregation drain flow Greg Kroah-Hartman
2013-06-05 21:34 ` [ 101/127] iommu/amd: Re-enable IOMMU event log interrupt after handling Greg Kroah-Hartman
2013-06-05 21:34 ` [ 102/127] iommu/amd: Workaround for ERBT1312 Greg Kroah-Hartman
2013-06-05 21:34 ` [ 103/127] ACPI / PM: Allow device power states to be used for CONFIG_PM unset Greg Kroah-Hartman
2013-06-05 21:34 ` [ 104/127] ACPI / video: Add "Asus UL30A" to ACPI video detect blacklist Greg Kroah-Hartman
2013-06-05 21:34 ` [ 105/127] drm/nvc0/ce: disable ce1 on a number of chipsets Greg Kroah-Hartman
2013-06-05 21:34 ` [ 106/127] mac80211: fix direct probe auth Greg Kroah-Hartman
2013-06-05 21:34 ` [ 107/127] mac80211: close AP_VLAN interfaces before unregistering all Greg Kroah-Hartman
2013-06-05 21:34 ` [ 108/127] iwlwifi: dvm: fix zero LQ CMD sending avoidance Greg Kroah-Hartman
2013-06-05 21:34 ` [ 109/127] iwlwifi: mvm: tell firmware to let multicast frames in Greg Kroah-Hartman
2013-06-05 21:34 ` [ 110/127] cfg80211: check wdev->netdev in connection work Greg Kroah-Hartman
2013-06-05 21:34 ` [ 111/127] ath9k: use correct OTP register offsets for AR9550 Greg Kroah-Hartman
2013-06-05 21:34 ` [ 112/127] tg3: Add read dma workaround for 5720 Greg Kroah-Hartman
2013-06-05 21:34 ` [ 113/127] net: can: kvaser_usb: fix reception on "USBcan Pro" and "USBcan R" type hardware Greg Kroah-Hartman
2013-06-05 21:34 ` [ 114/127] IB/iser: Return error to upper layers on EAGAIN registration failures Greg Kroah-Hartman
2013-06-05 21:34 ` [ 115/127] ASoC: davinci: fix sample rotation Greg Kroah-Hartman
2013-06-05 21:34 ` [ 116/127] fuse: fix readdirplus Oops in fuse_dentry_revalidate Greg Kroah-Hartman
2013-06-05 21:34 ` [ 117/127] target: Re-instate sess_wait_list for target_wait_for_sess_cmds Greg Kroah-Hartman
2013-06-05 21:34 ` [ 118/127] target/file: Fix off-by-one READ_CAPACITY bug for !S_ISBLK export Greg Kroah-Hartman
2013-06-05 21:34 ` [ 119/127] leds: leds-gpio: reserve gpio before using it Greg Kroah-Hartman
2013-06-05 21:34 ` [ 120/127] xen-netback: coalesce slots in TX path and fix regressions Greg Kroah-Hartman
2013-06-05 21:34 ` [ 121/127] xen-netback: dont disconnect frontend when seeing oversize packet Greg Kroah-Hartman
2013-06-05 21:34 ` [ 122/127] xen-netback: remove redundent parameter in netbk_count_requests Greg Kroah-Hartman
2013-06-05 21:34 ` [ 123/127] xen-netback: avoid allocating variable size array on stack Greg Kroah-Hartman
2013-06-05 21:34 ` [ 124/127] xen-netfront: reduce gso_max_size to account for max TCP header Greg Kroah-Hartman
2013-06-05 21:34 ` [ 125/127] iwlwifi: mvm: remove P2P_DEVICE support Greg Kroah-Hartman
2013-06-05 21:34 ` [ 126/127] mac80211_hwsim: " Greg Kroah-Hartman
2013-06-05 21:34 ` [ 127/127] xen-netback: better names for thresholds 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=20130605213227.685711779@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikey@neuling.org \
    --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