mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Will Deacon <will.deacon@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 35/75] arm64: mm: don't treat user cache maintenance faults as writes
Date: Tue, 30 Jul 2013 11:44:39 -0700	[thread overview]
Message-ID: <1375209919-1768-2-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1375197464-27962-1-git-send-email-kamal@canonical.com>

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

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

From: Will Deacon <will.deacon@arm.com>

commit db6f41063cbdb58b14846e600e6bc3f4e4c2e888 upstream.

On arm64, cache maintenance faults appear as data aborts with the CM
bit set in the ESR. The WnR bit, usually used to distinguish between
faulting loads and stores, always reads as 1 and (slightly confusingly)
the instructions are treated as reads by the architecture.

This patch fixes our fault handling code to treat cache maintenance
faults in the same way as loads.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/arm64/mm/fault.c | 46 ++++++++++++++++++++--------------------------
 1 file changed, 20 insertions(+), 26 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 0782eaf..af4cd30 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -151,25 +151,8 @@ void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)
 #define ESR_CM			(1 << 8)
 #define ESR_LNX_EXEC		(1 << 24)
 
-/*
- * Check that the permissions on the VMA allow for the fault which occurred.
- * If we encountered a write fault, we must have write permission, otherwise
- * we allow any permission.
- */
-static inline bool access_error(unsigned int esr, struct vm_area_struct *vma)
-{
-	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
-
-	if (esr & ESR_WRITE)
-		mask = VM_WRITE;
-	if (esr & ESR_LNX_EXEC)
-		mask = VM_EXEC;
-
-	return vma->vm_flags & mask ? false : true;
-}
-
 static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
-			   unsigned int esr, unsigned int flags,
+			   unsigned int mm_flags, unsigned long vm_flags,
 			   struct task_struct *tsk)
 {
 	struct vm_area_struct *vma;
@@ -187,12 +170,17 @@ static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
 	 * it.
 	 */
 good_area:
-	if (access_error(esr, vma)) {
+	/*
+	 * Check that the permissions on the VMA allow for the fault which
+	 * occurred. If we encountered a write or exec fault, we must have
+	 * appropriate permissions, otherwise we allow any permission.
+	 */
+	if (!(vma->vm_flags & vm_flags)) {
 		fault = VM_FAULT_BADACCESS;
 		goto out;
 	}
 
-	return handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
+	return handle_mm_fault(mm, vma, addr & PAGE_MASK, mm_flags);
 
 check_stack:
 	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
@@ -207,9 +195,15 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	struct task_struct *tsk;
 	struct mm_struct *mm;
 	int fault, sig, code;
-	bool write = (esr & ESR_WRITE) && !(esr & ESR_CM);
-	unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
-		(write ? FAULT_FLAG_WRITE : 0);
+	unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
+	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
+
+	if (esr & ESR_LNX_EXEC) {
+		vm_flags = VM_EXEC;
+	} else if ((esr & ESR_WRITE) && !(esr & ESR_CM)) {
+		vm_flags = VM_WRITE;
+		mm_flags |= FAULT_FLAG_WRITE;
+	}
 
 	tsk = current;
 	mm  = tsk->mm;
@@ -247,7 +241,7 @@ retry:
 #endif
 	}
 
-	fault = __do_page_fault(mm, addr, esr, flags, tsk);
+	fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk);
 
 	/*
 	 * If we need to retry but a fatal signal is pending, handle the
@@ -264,7 +258,7 @@ retry:
 	 */
 
 	perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
-	if (flags & FAULT_FLAG_ALLOW_RETRY) {
+	if (mm_flags & FAULT_FLAG_ALLOW_RETRY) {
 		if (fault & VM_FAULT_MAJOR) {
 			tsk->maj_flt++;
 			perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
@@ -279,7 +273,7 @@ retry:
 			 * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of
 			 * starvation.
 			 */
-			flags &= ~FAULT_FLAG_ALLOW_RETRY;
+			mm_flags &= ~FAULT_FLAG_ALLOW_RETRY;
 			goto retry;
 		}
 	}
-- 
1.8.1.2


  parent reply	other threads:[~2013-07-30 18:59 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 15:16 [ 3.8.y.z extended stable ] Linux 3.8.13.6 stable review Kamal Mostafa
2013-07-30 15:16 ` [PATCH 01/75] xen/blkback: Check device permissions before allowing OP_DISCARD Kamal Mostafa
2013-07-30 15:16 ` [PATCH 02/75] ASoC: sglt5000: Fix the default value of CHIP_SSS_CTRL Kamal Mostafa
2013-07-30 15:16 ` [PATCH 03/75] ASoC: sglt5000: Fix SGTL5000_PLL_FRAC_DIV_MASK Kamal Mostafa
2013-07-30 15:16 ` [PATCH 04/75] drm/i915: Correct obj->mm_list link to dev_priv->dev_priv->mm.inactive_list Kamal Mostafa
2013-07-30 15:16 ` [PATCH 05/75] drm/i915: fix up ring cleanup for the i830/i845 CS tlb w/a Kamal Mostafa
2013-07-30 15:16 ` [PATCH 06/75] Partially revert "drm/i915: unconditionally use mt forcewake on hsw/ivb" Kamal Mostafa
2013-07-30 15:16 ` [PATCH 07/75] drm/i915: Fix write-read race with multiple rings Kamal Mostafa
2013-07-30 15:16 ` [PATCH 08/75] drm/i915: merge {i965, sandybridge}_write_fence_reg() Kamal Mostafa
2013-07-30 15:16 ` [PATCH 09/75] drm/i915: Fix incoherence with fence updates on Sandybridge+ Kamal Mostafa
2013-07-30 15:16 ` [PATCH 10/75] Revert "drm/i915: Workaround incoherence between fences and LLC across multiple CPUs" Kamal Mostafa
2013-07-30 15:16 ` [PATCH 11/75] drm/i915: rename sdvox_reg to hdmi_reg on HDMI context Kamal Mostafa
2013-07-30 15:16 ` [PATCH 12/75] drm/i915: don't setup hdmi for port D edp in ddi_init Kamal Mostafa
2013-07-30 15:16 ` [PATCH 13/75] drm/i915: Preserve the DDI_A_4_LANES bit from the bios Kamal Mostafa
2013-07-30 15:16 ` [PATCH 14/75] drm/radeon/hdmi: make sure we have an afmt block assigned Kamal Mostafa
2013-07-30 15:16 ` [PATCH 15/75] drm/radeon: allocate SA bo in the requested domain Kamal Mostafa
2013-07-30 15:16 ` [PATCH 16/75] drm/radeon: allow selection of alignment in the sub-allocator Kamal Mostafa
2013-07-30 15:16 ` [PATCH 17/75] ACPI / memhotplug: Fix a stale pointer in error path Kamal Mostafa
2013-07-30 15:16 ` [PATCH 18/75] PM / Sleep: avoid 'autosleep' in shutdown progress Kamal Mostafa
2013-07-30 15:16 ` [PATCH 19/75] ext4: fix error handling in ext4_ext_truncate() Kamal Mostafa
2013-07-30 15:16 ` [PATCH 20/75] radeon kms: do not flush uninitialized hotplug work Kamal Mostafa
2013-07-30 15:16 ` [PATCH 21/75] ALSA: asihpi: Fix unlocked snd_pcm_stop() call Kamal Mostafa
2013-07-30 15:16 ` [PATCH 22/75] ALSA: atiixp: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 23/75] ALSA: 6fire: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 24/75] ALSA: ua101: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 25/75] ALSA: usx2y: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 26/75] ALSA: pxa2xx: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 27/75] ASoC: atmel: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 28/75] ASoC: s6000: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 29/75] [media] saa7134: " Kamal Mostafa
2013-07-30 15:16 ` [PATCH 30/75] staging: line6: " Kamal Mostafa
2013-07-30 15:17 ` [PATCH 31/75] x86, suspend: Handle CPUs which fail to #GP on RDMSR Kamal Mostafa
2013-07-30 15:17 ` [PATCH 32/75] ALSA: hda - Add new GPU codec ID to snd-hda Kamal Mostafa
2013-07-30 18:42 ` [PATCH 33/75] drm/i915: fix long-standing SNB regression in power consumption after resume v2 Kamal Mostafa
2013-07-30 18:44 ` [PATCH 34/75] ACPI / video: ignore BIOS initial backlight value for Fujitsu E753 Kamal Mostafa
2013-07-30 18:44 ` Kamal Mostafa [this message]
2013-07-30 18:44 ` [PATCH 36/75] Btrfs: fix lock leak when resuming snapshot deletion Kamal Mostafa
2013-07-30 18:44 ` [PATCH 37/75] Btrfs: re-add root to dead root list if we stop dropping it Kamal Mostafa
2013-07-30 18:44 ` [PATCH 38/75] drm/i915: inverted brightness quirk for Acer Aspire 4736Z Kamal Mostafa
2013-07-30 18:44 ` [PATCH 39/75] drm/i915: quirk no PCH_PWM_ENABLE for Dell XPS13 backlight Kamal Mostafa
2013-07-30 18:44 ` [PATCH 40/75] drm/i915: Serialize almost all register access Kamal Mostafa
2013-07-30 18:44 ` [PATCH 41/75] drm/i915: fix up gt init sequence fallout Kamal Mostafa
2013-07-30 18:44 ` [PATCH 42/75] powerpc/modules: Module CRC relocation fix causes perf issues Kamal Mostafa
2013-07-30 18:44 ` [PATCH 43/75] [PATCH] sparc32: vm_area_struct access for old Sun SPARCs Kamal Mostafa
2013-07-30 18:44 ` [PATCH 44/75] sparc64 address-congruence property Kamal Mostafa
2013-07-30 18:44 ` [PATCH 45/75] sparc: tsb must be flushed before tlb Kamal Mostafa
2013-07-30 18:44 ` [PATCH 46/75] bridge: fix switched interval for MLD Query types Kamal Mostafa
2013-07-30 18:44 ` [PATCH 47/75] ipv4: Fixed MD5 key lookups when adding/ removing MD5 to/ from TCP sockets Kamal Mostafa
2013-07-30 18:44 ` [PATCH 48/75] ipv6: don't call addrconf_dst_alloc again when enable lo Kamal Mostafa
2013-07-30 18:44 ` [PATCH 49/75] macvtap: fix recovery from gup errors Kamal Mostafa
2013-07-30 18:44 ` [PATCH 50/75] ipv6: ip6_sk_dst_check() must not assume ipv6 dst Kamal Mostafa
2013-07-30 18:44 ` [PATCH 51/75] af_key: fix info leaks in notify messages Kamal Mostafa
2013-07-30 18:44 ` [PATCH 52/75] sh_eth: fix unhandled RFE interrupt Kamal Mostafa
2013-07-30 18:44 ` [PATCH 53/75] neighbour: fix a race in neigh_destroy() Kamal Mostafa
2013-07-30 18:44 ` [PATCH 54/75] x25: Fix broken locking in ioctl error paths Kamal Mostafa
2013-07-30 18:44 ` [PATCH 55/75] net: Swap ver and type in pppoe_hdr Kamal Mostafa
2013-07-30 18:45 ` [PATCH 56/75] vti: remove duplicated code to fix a memory leak Kamal Mostafa
2013-07-30 18:45 ` [PATCH 57/75] ipv6,mcast: always hold idev->lock before mca_lock Kamal Mostafa
2013-07-30 18:45 ` [PATCH 58/75] l2tp: add missing .owner to struct pppox_proto Kamal Mostafa
2013-07-30 18:45 ` [PATCH 59/75] ipv6: call udp_push_pending_frames when uncorking a socket with AF_INET pending data Kamal Mostafa
2013-07-30 18:45 ` [PATCH 60/75] ipv6: ip6_append_data_mtu did not care about pmtudisc and frag_size Kamal Mostafa
2013-07-30 18:45 ` [PATCH 61/75] sunvnet: vnet_port_remove must call unregister_netdev Kamal Mostafa
2013-07-30 18:45 ` [PATCH 62/75] ifb: fix rcu_sched self-detected stalls Kamal Mostafa
2013-07-30 18:45 ` [PATCH 63/75] tuntap: correctly linearize skb when zerocopy is used Kamal Mostafa
2013-07-30 18:45 ` [PATCH 64/75] macvtap: " Kamal Mostafa
2013-07-30 18:45 ` [PATCH 65/75] ipv6: in case of link failure remove route directly instead of letting it expire Kamal Mostafa
2013-07-30 18:45 ` [PATCH 66/75] 9p: fix off by one causing access violations and memory corruption Kamal Mostafa
2013-07-30 18:45 ` [PATCH 67/75] dummy: fix oops when loading the dummy failed Kamal Mostafa
2013-07-30 18:45 ` [PATCH 68/75] ifb: fix oops when loading the ifb failed Kamal Mostafa
2013-07-30 18:45 ` [PATCH 69/75] ipv6: only static routes qualify for equal cost multipathing Kamal Mostafa
2013-07-30 18:45 ` [PATCH 70/75] atl1e: fix dma mapping warnings Kamal Mostafa
2013-07-30 18:45 ` [PATCH 71/75] atl1e: unmap partially mapped skb on dma error and free skb Kamal Mostafa
2013-07-30 18:45 ` [PATCH 72/75] ipv4: set transport header earlier Kamal Mostafa
2013-07-30 18:45 ` [PATCH 73/75] tuntap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS Kamal Mostafa
2013-07-30 18:45 ` [PATCH 74/75] macvtap: " Kamal Mostafa
2013-07-30 18:45 ` [PATCH 75/75] vlan: fix a race in egress prio management Kamal Mostafa

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=1375209919-1768-2-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=catalin.marinas@arm.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=will.deacon@arm.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®