All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault()
@ 2019-05-29 12:34 ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, Mark Rutland,
	James Morse, Andrey Konovalov

This series contains some fixes and cleanups for page fault handling in
do_page_fault(). This has been boot tested on arm64 platform along with
some stress test but just build tested on others.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Andrey Konovalov <andreyknvl@google.com>

Anshuman Khandual (4):
  arm64/mm: Drop mmap_sem before calling __do_kernel_fault()
  arm64/mm: Drop task_struct argument from __do_page_fault()
  arm64/mm: Consolidate page fault information capture
  arm64/mm: Drop vm_fault_t argument from __do_page_fault()

 arch/arm64/mm/fault.c | 77 +++++++++++++++++++++++++--------------------------
 1 file changed, 38 insertions(+), 39 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault()
@ 2019-05-29 12:34 ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Mark Rutland, Anshuman Khandual, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov

This series contains some fixes and cleanups for page fault handling in
do_page_fault(). This has been boot tested on arm64 platform along with
some stress test but just build tested on others.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Andrey Konovalov <andreyknvl@google.com>

Anshuman Khandual (4):
  arm64/mm: Drop mmap_sem before calling __do_kernel_fault()
  arm64/mm: Drop task_struct argument from __do_page_fault()
  arm64/mm: Consolidate page fault information capture
  arm64/mm: Drop vm_fault_t argument from __do_page_fault()

 arch/arm64/mm/fault.c | 77 +++++++++++++++++++++++++--------------------------
 1 file changed, 38 insertions(+), 39 deletions(-)

-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 1/4] arm64/mm: Drop mmap_sem before calling __do_kernel_fault()
  2019-05-29 12:34 ` Anshuman Khandual
@ 2019-05-29 12:34   ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, Mark Rutland,
	James Morse, Andrey Konovalov

There is an inconsistency between down_read_trylock() success and failure
paths while dealing with kernel access for non exception table areas where
it calls __do_kernel_fault(). In case of failure it just bails out without
holding mmap_sem but when it succeeds it does so while holding mmap_sem.
Fix this inconsistency by just dropping mmap_sem in success path as well.

__do_kernel_fault() calls die_kernel_fault() which then calls show_pte().
show_pte() in this path might become bit more unreliable without holding
mmap_sem. But there are already instances [1] in do_page_fault() where
die_kernel_fault() gets called without holding mmap_sem. show_pte() can
be made more robust independently but in a later patch.

[1] Conditional block for (is_ttbr0_addr && is_el1_permission_fault)

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
---
 arch/arm64/mm/fault.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index a30818e..dc1cf32 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -503,8 +503,10 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 */
 		might_sleep();
 #ifdef CONFIG_DEBUG_VM
-		if (!user_mode(regs) && !search_exception_tables(regs->pc))
+		if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
+			up_read(&mm->mmap_sem);
 			goto no_context;
+		}
 #endif
 	}
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 1/4] arm64/mm: Drop mmap_sem before calling __do_kernel_fault()
@ 2019-05-29 12:34   ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Mark Rutland, Anshuman Khandual, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov

There is an inconsistency between down_read_trylock() success and failure
paths while dealing with kernel access for non exception table areas where
it calls __do_kernel_fault(). In case of failure it just bails out without
holding mmap_sem but when it succeeds it does so while holding mmap_sem.
Fix this inconsistency by just dropping mmap_sem in success path as well.

__do_kernel_fault() calls die_kernel_fault() which then calls show_pte().
show_pte() in this path might become bit more unreliable without holding
mmap_sem. But there are already instances [1] in do_page_fault() where
die_kernel_fault() gets called without holding mmap_sem. show_pte() can
be made more robust independently but in a later patch.

[1] Conditional block for (is_ttbr0_addr && is_el1_permission_fault)

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
---
 arch/arm64/mm/fault.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index a30818e..dc1cf32 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -503,8 +503,10 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 */
 		might_sleep();
 #ifdef CONFIG_DEBUG_VM
-		if (!user_mode(regs) && !search_exception_tables(regs->pc))
+		if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
+			up_read(&mm->mmap_sem);
 			goto no_context;
+		}
 #endif
 	}
 
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 2/4] arm64/mm: Drop task_struct argument from __do_page_fault()
  2019-05-29 12:34 ` Anshuman Khandual
@ 2019-05-29 12:34   ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, Mark Rutland,
	James Morse, Andrey Konovalov

The task_struct argument is not getting used in __do_page_fault(). Hence
just drop it and use current or cuurent->mm instead where ever required.
This does not change any functionality.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com> 
Cc: Andrey Konovalov <andreyknvl@google.com>
---

 arch/arm64/mm/fault.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index dc1cf32..da02678 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -395,8 +395,7 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
 #define VM_FAULT_BADACCESS	0x020000
 
 static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
-			   unsigned int mm_flags, unsigned long vm_flags,
-			   struct task_struct *tsk)
+			   unsigned int mm_flags, unsigned long vm_flags)
 {
 	struct vm_area_struct *vma;
 	vm_fault_t fault;
@@ -440,8 +439,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 				   struct pt_regs *regs)
 {
 	const struct fault_info *inf;
-	struct task_struct *tsk;
-	struct mm_struct *mm;
+	struct mm_struct *mm = current->mm;
 	vm_fault_t fault, major = 0;
 	unsigned long vm_flags = VM_READ | VM_WRITE;
 	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
@@ -449,9 +447,6 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	if (notify_page_fault(regs, esr))
 		return 0;
 
-	tsk = current;
-	mm  = tsk->mm;
-
 	/*
 	 * If we're in an interrupt or have no user context, we must not take
 	 * the fault.
@@ -510,7 +505,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 #endif
 	}
 
-	fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk);
+	fault = __do_page_fault(mm, addr, mm_flags, vm_flags);
 	major |= fault & VM_FAULT_MAJOR;
 
 	if (fault & VM_FAULT_RETRY) {
@@ -550,11 +545,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 * that point.
 		 */
 		if (major) {
-			tsk->maj_flt++;
+			current->maj_flt++;
 			perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
 				      addr);
 		} else {
-			tsk->min_flt++;
+			current->min_flt++;
 			perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs,
 				      addr);
 		}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 2/4] arm64/mm: Drop task_struct argument from __do_page_fault()
@ 2019-05-29 12:34   ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Mark Rutland, Anshuman Khandual, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov

The task_struct argument is not getting used in __do_page_fault(). Hence
just drop it and use current or cuurent->mm instead where ever required.
This does not change any functionality.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com> 
Cc: Andrey Konovalov <andreyknvl@google.com>
---

 arch/arm64/mm/fault.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index dc1cf32..da02678 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -395,8 +395,7 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
 #define VM_FAULT_BADACCESS	0x020000
 
 static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
-			   unsigned int mm_flags, unsigned long vm_flags,
-			   struct task_struct *tsk)
+			   unsigned int mm_flags, unsigned long vm_flags)
 {
 	struct vm_area_struct *vma;
 	vm_fault_t fault;
@@ -440,8 +439,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 				   struct pt_regs *regs)
 {
 	const struct fault_info *inf;
-	struct task_struct *tsk;
-	struct mm_struct *mm;
+	struct mm_struct *mm = current->mm;
 	vm_fault_t fault, major = 0;
 	unsigned long vm_flags = VM_READ | VM_WRITE;
 	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
@@ -449,9 +447,6 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	if (notify_page_fault(regs, esr))
 		return 0;
 
-	tsk = current;
-	mm  = tsk->mm;
-
 	/*
 	 * If we're in an interrupt or have no user context, we must not take
 	 * the fault.
@@ -510,7 +505,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 #endif
 	}
 
-	fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk);
+	fault = __do_page_fault(mm, addr, mm_flags, vm_flags);
 	major |= fault & VM_FAULT_MAJOR;
 
 	if (fault & VM_FAULT_RETRY) {
@@ -550,11 +545,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 * that point.
 		 */
 		if (major) {
-			tsk->maj_flt++;
+			current->maj_flt++;
 			perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
 				      addr);
 		} else {
-			tsk->min_flt++;
+			current->min_flt++;
 			perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs,
 				      addr);
 		}
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 3/4] arm64/mm: Consolidate page fault information capture
  2019-05-29 12:34 ` Anshuman Khandual
@ 2019-05-29 12:34   ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, Mark Rutland,
	James Morse, Andrey Konovalov

This consolidates page fault information capture and move them bit earlier.
While here it also adds an wrapper is_write_abort(). It also saves some
cycles by replacing multiple user_mode() calls into a single one earlier
during the fault.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com> 
Cc: Andrey Konovalov <andreyknvl@google.com>
---
 arch/arm64/mm/fault.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index da02678..170c71f 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -435,6 +435,11 @@ static bool is_el0_instruction_abort(unsigned int esr)
 	return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW;
 }
 
+static bool is_write_abort(unsigned int esr)
+{
+	return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
+}
+
 static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 				   struct pt_regs *regs)
 {
@@ -443,6 +448,9 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	vm_fault_t fault, major = 0;
 	unsigned long vm_flags = VM_READ | VM_WRITE;
 	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
+	bool is_user = user_mode(regs);
+	bool is_el0_exec = is_el0_instruction_abort(esr);
+	bool is_write = is_write_abort(esr);
 
 	if (notify_page_fault(regs, esr))
 		return 0;
@@ -454,12 +462,12 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	if (faulthandler_disabled() || !mm)
 		goto no_context;
 
-	if (user_mode(regs))
+	if (is_user)
 		mm_flags |= FAULT_FLAG_USER;
 
-	if (is_el0_instruction_abort(esr)) {
+	if (is_el0_exec) {
 		vm_flags = VM_EXEC;
-	} else if ((esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM)) {
+	} else if (is_write) {
 		vm_flags = VM_WRITE;
 		mm_flags |= FAULT_FLAG_WRITE;
 	}
@@ -487,7 +495,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	 * we can bug out early if this is from code which shouldn't.
 	 */
 	if (!down_read_trylock(&mm->mmap_sem)) {
-		if (!user_mode(regs) && !search_exception_tables(regs->pc))
+		if (!is_user && !search_exception_tables(regs->pc))
 			goto no_context;
 retry:
 		down_read(&mm->mmap_sem);
@@ -498,7 +506,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 */
 		might_sleep();
 #ifdef CONFIG_DEBUG_VM
-		if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
+		if (!is_user && !search_exception_tables(regs->pc)) {
 			up_read(&mm->mmap_sem);
 			goto no_context;
 		}
@@ -516,7 +524,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 * in __lock_page_or_retry in mm/filemap.c.
 		 */
 		if (fatal_signal_pending(current)) {
-			if (!user_mode(regs))
+			if (!is_user)
 				goto no_context;
 			return 0;
 		}
@@ -561,7 +569,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	 * If we are in kernel mode at this point, we have no context to
 	 * handle this fault with.
 	 */
-	if (!user_mode(regs))
+	if (!is_user)
 		goto no_context;
 
 	if (fault & VM_FAULT_OOM) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 3/4] arm64/mm: Consolidate page fault information capture
@ 2019-05-29 12:34   ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Mark Rutland, Anshuman Khandual, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov

This consolidates page fault information capture and move them bit earlier.
While here it also adds an wrapper is_write_abort(). It also saves some
cycles by replacing multiple user_mode() calls into a single one earlier
during the fault.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com> 
Cc: Andrey Konovalov <andreyknvl@google.com>
---
 arch/arm64/mm/fault.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index da02678..170c71f 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -435,6 +435,11 @@ static bool is_el0_instruction_abort(unsigned int esr)
 	return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW;
 }
 
+static bool is_write_abort(unsigned int esr)
+{
+	return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
+}
+
 static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 				   struct pt_regs *regs)
 {
@@ -443,6 +448,9 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	vm_fault_t fault, major = 0;
 	unsigned long vm_flags = VM_READ | VM_WRITE;
 	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
+	bool is_user = user_mode(regs);
+	bool is_el0_exec = is_el0_instruction_abort(esr);
+	bool is_write = is_write_abort(esr);
 
 	if (notify_page_fault(regs, esr))
 		return 0;
@@ -454,12 +462,12 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	if (faulthandler_disabled() || !mm)
 		goto no_context;
 
-	if (user_mode(regs))
+	if (is_user)
 		mm_flags |= FAULT_FLAG_USER;
 
-	if (is_el0_instruction_abort(esr)) {
+	if (is_el0_exec) {
 		vm_flags = VM_EXEC;
-	} else if ((esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM)) {
+	} else if (is_write) {
 		vm_flags = VM_WRITE;
 		mm_flags |= FAULT_FLAG_WRITE;
 	}
@@ -487,7 +495,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	 * we can bug out early if this is from code which shouldn't.
 	 */
 	if (!down_read_trylock(&mm->mmap_sem)) {
-		if (!user_mode(regs) && !search_exception_tables(regs->pc))
+		if (!is_user && !search_exception_tables(regs->pc))
 			goto no_context;
 retry:
 		down_read(&mm->mmap_sem);
@@ -498,7 +506,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 */
 		might_sleep();
 #ifdef CONFIG_DEBUG_VM
-		if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
+		if (!is_user && !search_exception_tables(regs->pc)) {
 			up_read(&mm->mmap_sem);
 			goto no_context;
 		}
@@ -516,7 +524,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 		 * in __lock_page_or_retry in mm/filemap.c.
 		 */
 		if (fatal_signal_pending(current)) {
-			if (!user_mode(regs))
+			if (!is_user)
 				goto no_context;
 			return 0;
 		}
@@ -561,7 +569,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
 	 * If we are in kernel mode at this point, we have no context to
 	 * handle this fault with.
 	 */
-	if (!user_mode(regs))
+	if (!is_user)
 		goto no_context;
 
 	if (fault & VM_FAULT_OOM) {
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
  2019-05-29 12:34 ` Anshuman Khandual
@ 2019-05-29 12:34   ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, Mark Rutland,
	James Morse, Andrey Konovalov

__do_page_fault() is over complicated with multiple goto statements. This
cleans up code flow and while there drops the vm_fault_t argument.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com> 
Cc: Andrey Konovalov <andreyknvl@google.com>
---
 arch/arm64/mm/fault.c | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 170c71f..a53a30e 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -397,37 +397,31 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
 static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
 			   unsigned int mm_flags, unsigned long vm_flags)
 {
-	struct vm_area_struct *vma;
-	vm_fault_t fault;
+	struct vm_area_struct *vma = find_vma(mm, addr);
 
-	vma = find_vma(mm, addr);
-	fault = VM_FAULT_BADMAP;
 	if (unlikely(!vma))
-		goto out;
-	if (unlikely(vma->vm_start > addr))
-		goto check_stack;
+		return VM_FAULT_BADMAP;
 
 	/*
-	 * Ok, we have a good vm_area for this memory access, so we can handle
-	 * it.
+	 * Check if the VMA has got the required permssion with respect
+	 * to the access fault here.
 	 */
-good_area:
+	if (!(vma->vm_flags & vm_flags))
+		return VM_FAULT_BADACCESS;
+
 	/*
-	 * Check that the permissions on the VMA allow for the fault which
-	 * occurred.
+	 * There is a valid VMA for this access. But before proceeding
+	 * make sure that it has required flags if there is an attempt
+	 * to expand the stack downwards.
 	 */
-	if (!(vma->vm_flags & vm_flags)) {
-		fault = VM_FAULT_BADACCESS;
-		goto out;
-	}
+	if (unlikely(vma->vm_start > addr)) {
+		if (!(vma->vm_flags & VM_GROWSDOWN))
+			return VM_FAULT_BADMAP;
 
+		if (expand_stack(vma, addr))
+			return VM_FAULT_BADMAP;
+	}
 	return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
-
-check_stack:
-	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
-		goto good_area;
-out:
-	return fault;
 }
 
 static bool is_el0_instruction_abort(unsigned int esr)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
@ 2019-05-29 12:34   ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Mark Rutland, Anshuman Khandual, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov

__do_page_fault() is over complicated with multiple goto statements. This
cleans up code flow and while there drops the vm_fault_t argument.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: James Morse <james.morse@arm.com> 
Cc: Andrey Konovalov <andreyknvl@google.com>
---
 arch/arm64/mm/fault.c | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 170c71f..a53a30e 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -397,37 +397,31 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
 static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
 			   unsigned int mm_flags, unsigned long vm_flags)
 {
-	struct vm_area_struct *vma;
-	vm_fault_t fault;
+	struct vm_area_struct *vma = find_vma(mm, addr);
 
-	vma = find_vma(mm, addr);
-	fault = VM_FAULT_BADMAP;
 	if (unlikely(!vma))
-		goto out;
-	if (unlikely(vma->vm_start > addr))
-		goto check_stack;
+		return VM_FAULT_BADMAP;
 
 	/*
-	 * Ok, we have a good vm_area for this memory access, so we can handle
-	 * it.
+	 * Check if the VMA has got the required permssion with respect
+	 * to the access fault here.
 	 */
-good_area:
+	if (!(vma->vm_flags & vm_flags))
+		return VM_FAULT_BADACCESS;
+
 	/*
-	 * Check that the permissions on the VMA allow for the fault which
-	 * occurred.
+	 * There is a valid VMA for this access. But before proceeding
+	 * make sure that it has required flags if there is an attempt
+	 * to expand the stack downwards.
 	 */
-	if (!(vma->vm_flags & vm_flags)) {
-		fault = VM_FAULT_BADACCESS;
-		goto out;
-	}
+	if (unlikely(vma->vm_start > addr)) {
+		if (!(vma->vm_flags & VM_GROWSDOWN))
+			return VM_FAULT_BADMAP;
 
+		if (expand_stack(vma, addr))
+			return VM_FAULT_BADMAP;
+	}
 	return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
-
-check_stack:
-	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
-		goto good_area;
-out:
-	return fault;
 }
 
 static bool is_el0_instruction_abort(unsigned int esr)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault()
  2019-05-29 12:34 ` Anshuman Khandual
@ 2019-05-29 12:41   ` Will Deacon
  -1 siblings, 0 replies; 26+ messages in thread
From: Will Deacon @ 2019-05-29 12:41 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Mark Rutland,
	James Morse, Andrey Konovalov

Hi Anshuman,

On Wed, May 29, 2019 at 06:04:41PM +0530, Anshuman Khandual wrote:
> This series contains some fixes and cleanups for page fault handling in
> do_page_fault(). This has been boot tested on arm64 platform along with
> some stress test but just build tested on others.

These all seem to be cleanups, which is fine, but I just wanted to make
sure I'm not missing something that should be aiming for 5.2. Are there
actually fixes in this series?

(in future, it's best to post fixes separately so I don't miss them)

Cheers,

Will

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault()
@ 2019-05-29 12:41   ` Will Deacon
  0 siblings, 0 replies; 26+ messages in thread
From: Will Deacon @ 2019-05-29 12:41 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Mark Rutland, Catalin Marinas, linux-kernel, James Morse,
	Andrey Konovalov, linux-arm-kernel

Hi Anshuman,

On Wed, May 29, 2019 at 06:04:41PM +0530, Anshuman Khandual wrote:
> This series contains some fixes and cleanups for page fault handling in
> do_page_fault(). This has been boot tested on arm64 platform along with
> some stress test but just build tested on others.

These all seem to be cleanups, which is fine, but I just wanted to make
sure I'm not missing something that should be aiming for 5.2. Are there
actually fixes in this series?

(in future, it's best to post fixes separately so I don't miss them)

Cheers,

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault()
  2019-05-29 12:41   ` Will Deacon
@ 2019-05-29 12:59     ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:59 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Mark Rutland,
	James Morse, Andrey Konovalov



On 05/29/2019 06:11 PM, Will Deacon wrote:
> Hi Anshuman,
> 
> On Wed, May 29, 2019 at 06:04:41PM +0530, Anshuman Khandual wrote:
>> This series contains some fixes and cleanups for page fault handling in
>> do_page_fault(). This has been boot tested on arm64 platform along with
>> some stress test but just build tested on others.
> 
> These all seem to be cleanups, which is fine, but I just wanted to make
> sure I'm not missing something that should be aiming for 5.2. Are there
> actually fixes in this series?

The following one might qualify (I would not insist though) but right now
this is not very problematic.

- arm64/mm: Drop mmap_sem before calling __do_kernel_fault() 

> 
> (in future, it's best to post fixes separately so I don't miss them)

Sure will do.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault()
@ 2019-05-29 12:59     ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-29 12:59 UTC (permalink / raw)
  To: Will Deacon
  Cc: Mark Rutland, Catalin Marinas, linux-kernel, James Morse,
	Andrey Konovalov, linux-arm-kernel



On 05/29/2019 06:11 PM, Will Deacon wrote:
> Hi Anshuman,
> 
> On Wed, May 29, 2019 at 06:04:41PM +0530, Anshuman Khandual wrote:
>> This series contains some fixes and cleanups for page fault handling in
>> do_page_fault(). This has been boot tested on arm64 platform along with
>> some stress test but just build tested on others.
> 
> These all seem to be cleanups, which is fine, but I just wanted to make
> sure I'm not missing something that should be aiming for 5.2. Are there
> actually fixes in this series?

The following one might qualify (I would not insist though) but right now
this is not very problematic.

- arm64/mm: Drop mmap_sem before calling __do_kernel_fault() 

> 
> (in future, it's best to post fixes separately so I don't miss them)

Sure will do.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/4] arm64/mm: Consolidate page fault information capture
  2019-05-29 12:34   ` Anshuman Khandual
@ 2019-05-29 14:53     ` Mark Rutland
  -1 siblings, 0 replies; 26+ messages in thread
From: Mark Rutland @ 2019-05-29 14:53 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov

On Wed, May 29, 2019 at 06:04:44PM +0530, Anshuman Khandual wrote:
> This consolidates page fault information capture and move them bit earlier.
> While here it also adds an wrapper is_write_abort(). It also saves some
> cycles by replacing multiple user_mode() calls into a single one earlier
> during the fault.

To be honest, I doubt this has any measureable impact, but I agree that
using variables _may_ make the flow control easier to understand.

> 
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: James Morse <james.morse@arm.com> 
> Cc: Andrey Konovalov <andreyknvl@google.com>
> ---
>  arch/arm64/mm/fault.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index da02678..170c71f 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -435,6 +435,11 @@ static bool is_el0_instruction_abort(unsigned int esr)
>  	return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW;
>  }
>  
> +static bool is_write_abort(unsigned int esr)
> +{
> +	return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
> +}

In off-list review, I mentioned that this isn't true for EL1, and I
think that we should name this 'is_el0_write_abort()' or add a comment
explaining the caveats if factored into a helper.

Thanks,
Mark.

> +
>  static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  				   struct pt_regs *regs)
>  {
> @@ -443,6 +448,9 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	vm_fault_t fault, major = 0;
>  	unsigned long vm_flags = VM_READ | VM_WRITE;
>  	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
> +	bool is_user = user_mode(regs);
> +	bool is_el0_exec = is_el0_instruction_abort(esr);
> +	bool is_write = is_write_abort(esr);
>  
>  	if (notify_page_fault(regs, esr))
>  		return 0;
> @@ -454,12 +462,12 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	if (faulthandler_disabled() || !mm)
>  		goto no_context;
>  
> -	if (user_mode(regs))
> +	if (is_user)
>  		mm_flags |= FAULT_FLAG_USER;
>  
> -	if (is_el0_instruction_abort(esr)) {
> +	if (is_el0_exec) {
>  		vm_flags = VM_EXEC;
> -	} else if ((esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM)) {
> +	} else if (is_write) {
>  		vm_flags = VM_WRITE;
>  		mm_flags |= FAULT_FLAG_WRITE;
>  	}
> @@ -487,7 +495,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	 * we can bug out early if this is from code which shouldn't.
>  	 */
>  	if (!down_read_trylock(&mm->mmap_sem)) {
> -		if (!user_mode(regs) && !search_exception_tables(regs->pc))
> +		if (!is_user && !search_exception_tables(regs->pc))
>  			goto no_context;
>  retry:
>  		down_read(&mm->mmap_sem);
> @@ -498,7 +506,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  		 */
>  		might_sleep();
>  #ifdef CONFIG_DEBUG_VM
> -		if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
> +		if (!is_user && !search_exception_tables(regs->pc)) {
>  			up_read(&mm->mmap_sem);
>  			goto no_context;
>  		}
> @@ -516,7 +524,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  		 * in __lock_page_or_retry in mm/filemap.c.
>  		 */
>  		if (fatal_signal_pending(current)) {
> -			if (!user_mode(regs))
> +			if (!is_user)
>  				goto no_context;
>  			return 0;
>  		}
> @@ -561,7 +569,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	 * If we are in kernel mode at this point, we have no context to
>  	 * handle this fault with.
>  	 */
> -	if (!user_mode(regs))
> +	if (!is_user)
>  		goto no_context;
>  
>  	if (fault & VM_FAULT_OOM) {
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/4] arm64/mm: Consolidate page fault information capture
@ 2019-05-29 14:53     ` Mark Rutland
  0 siblings, 0 replies; 26+ messages in thread
From: Mark Rutland @ 2019-05-29 14:53 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Andrey Konovalov, Will Deacon, linux-kernel, James Morse,
	Catalin Marinas, linux-arm-kernel

On Wed, May 29, 2019 at 06:04:44PM +0530, Anshuman Khandual wrote:
> This consolidates page fault information capture and move them bit earlier.
> While here it also adds an wrapper is_write_abort(). It also saves some
> cycles by replacing multiple user_mode() calls into a single one earlier
> during the fault.

To be honest, I doubt this has any measureable impact, but I agree that
using variables _may_ make the flow control easier to understand.

> 
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: James Morse <james.morse@arm.com> 
> Cc: Andrey Konovalov <andreyknvl@google.com>
> ---
>  arch/arm64/mm/fault.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index da02678..170c71f 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -435,6 +435,11 @@ static bool is_el0_instruction_abort(unsigned int esr)
>  	return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW;
>  }
>  
> +static bool is_write_abort(unsigned int esr)
> +{
> +	return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
> +}

In off-list review, I mentioned that this isn't true for EL1, and I
think that we should name this 'is_el0_write_abort()' or add a comment
explaining the caveats if factored into a helper.

Thanks,
Mark.

> +
>  static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  				   struct pt_regs *regs)
>  {
> @@ -443,6 +448,9 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	vm_fault_t fault, major = 0;
>  	unsigned long vm_flags = VM_READ | VM_WRITE;
>  	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
> +	bool is_user = user_mode(regs);
> +	bool is_el0_exec = is_el0_instruction_abort(esr);
> +	bool is_write = is_write_abort(esr);
>  
>  	if (notify_page_fault(regs, esr))
>  		return 0;
> @@ -454,12 +462,12 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	if (faulthandler_disabled() || !mm)
>  		goto no_context;
>  
> -	if (user_mode(regs))
> +	if (is_user)
>  		mm_flags |= FAULT_FLAG_USER;
>  
> -	if (is_el0_instruction_abort(esr)) {
> +	if (is_el0_exec) {
>  		vm_flags = VM_EXEC;
> -	} else if ((esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM)) {
> +	} else if (is_write) {
>  		vm_flags = VM_WRITE;
>  		mm_flags |= FAULT_FLAG_WRITE;
>  	}
> @@ -487,7 +495,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	 * we can bug out early if this is from code which shouldn't.
>  	 */
>  	if (!down_read_trylock(&mm->mmap_sem)) {
> -		if (!user_mode(regs) && !search_exception_tables(regs->pc))
> +		if (!is_user && !search_exception_tables(regs->pc))
>  			goto no_context;
>  retry:
>  		down_read(&mm->mmap_sem);
> @@ -498,7 +506,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  		 */
>  		might_sleep();
>  #ifdef CONFIG_DEBUG_VM
> -		if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
> +		if (!is_user && !search_exception_tables(regs->pc)) {
>  			up_read(&mm->mmap_sem);
>  			goto no_context;
>  		}
> @@ -516,7 +524,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  		 * in __lock_page_or_retry in mm/filemap.c.
>  		 */
>  		if (fatal_signal_pending(current)) {
> -			if (!user_mode(regs))
> +			if (!is_user)
>  				goto no_context;
>  			return 0;
>  		}
> @@ -561,7 +569,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>  	 * If we are in kernel mode at this point, we have no context to
>  	 * handle this fault with.
>  	 */
> -	if (!user_mode(regs))
> +	if (!is_user)
>  		goto no_context;
>  
>  	if (fault & VM_FAULT_OOM) {
> -- 
> 2.7.4
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
  2019-05-29 12:34   ` Anshuman Khandual
@ 2019-05-29 15:11     ` Mark Rutland
  -1 siblings, 0 replies; 26+ messages in thread
From: Mark Rutland @ 2019-05-29 15:11 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov

On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
> __do_page_fault() is over complicated with multiple goto statements. This
> cleans up code flow and while there drops the vm_fault_t argument.
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: James Morse <james.morse@arm.com> 
> Cc: Andrey Konovalov <andreyknvl@google.com>
> ---
>  arch/arm64/mm/fault.c | 38 ++++++++++++++++----------------------
>  1 file changed, 16 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index 170c71f..a53a30e 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -397,37 +397,31 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
>  static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
>  			   unsigned int mm_flags, unsigned long vm_flags)
>  {
> -	struct vm_area_struct *vma;
> -	vm_fault_t fault;
> +	struct vm_area_struct *vma = find_vma(mm, addr);
>  
> -	vma = find_vma(mm, addr);
> -	fault = VM_FAULT_BADMAP;
>  	if (unlikely(!vma))
> -		goto out;
> -	if (unlikely(vma->vm_start > addr))
> -		goto check_stack;
> +		return VM_FAULT_BADMAP;
>  
>  	/*
> -	 * Ok, we have a good vm_area for this memory access, so we can handle
> -	 * it.
> +	 * Check if the VMA has got the required permssion with respect
> +	 * to the access fault here.
>  	 */

We already had a perfectly good comment for this check:

	/*
	 * Check that the permissions on the VMA allow for the fault which
	 * occurred.
	 */

... so please keep that and minimize the diff.

> -good_area:
> +	if (!(vma->vm_flags & vm_flags))
> +		return VM_FAULT_BADACCESS;
> +
>  	/*
> -	 * Check that the permissions on the VMA allow for the fault which
> -	 * occurred.
> +	 * There is a valid VMA for this access. But before proceeding
> +	 * make sure that it has required flags if there is an attempt
> +	 * to expand the stack downwards.
>  	 */

I think we can drop this comment, given we didn't have it previously.

> -	if (!(vma->vm_flags & vm_flags)) {
> -		fault = VM_FAULT_BADACCESS;
> -		goto out;
> -	}
> +	if (unlikely(vma->vm_start > addr)) {
> +		if (!(vma->vm_flags & VM_GROWSDOWN))
> +			return VM_FAULT_BADMAP;
>  
> +		if (expand_stack(vma, addr))
> +			return VM_FAULT_BADMAP;

You can drop the line space between these two if statements.

> +	}
>  	return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
> -
> -check_stack:
> -	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
> -		goto good_area;
> -out:
> -	return fault;

We used to check the stack before the checknig the rest of the vm_flags,
so this changes the precedence of the VM_FAULT_BADMAP and
VM_FAULT_BADACCESS return codes.

Please check the stack before checking the other vm_flags.

Otherwise, this looks like a nice cleanup -- the old control flow was
hideous.

Thanks,
Mark.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
@ 2019-05-29 15:11     ` Mark Rutland
  0 siblings, 0 replies; 26+ messages in thread
From: Mark Rutland @ 2019-05-29 15:11 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Andrey Konovalov, Will Deacon, linux-kernel, James Morse,
	Catalin Marinas, linux-arm-kernel

On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
> __do_page_fault() is over complicated with multiple goto statements. This
> cleans up code flow and while there drops the vm_fault_t argument.
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: James Morse <james.morse@arm.com> 
> Cc: Andrey Konovalov <andreyknvl@google.com>
> ---
>  arch/arm64/mm/fault.c | 38 ++++++++++++++++----------------------
>  1 file changed, 16 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index 170c71f..a53a30e 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -397,37 +397,31 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
>  static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
>  			   unsigned int mm_flags, unsigned long vm_flags)
>  {
> -	struct vm_area_struct *vma;
> -	vm_fault_t fault;
> +	struct vm_area_struct *vma = find_vma(mm, addr);
>  
> -	vma = find_vma(mm, addr);
> -	fault = VM_FAULT_BADMAP;
>  	if (unlikely(!vma))
> -		goto out;
> -	if (unlikely(vma->vm_start > addr))
> -		goto check_stack;
> +		return VM_FAULT_BADMAP;
>  
>  	/*
> -	 * Ok, we have a good vm_area for this memory access, so we can handle
> -	 * it.
> +	 * Check if the VMA has got the required permssion with respect
> +	 * to the access fault here.
>  	 */

We already had a perfectly good comment for this check:

	/*
	 * Check that the permissions on the VMA allow for the fault which
	 * occurred.
	 */

... so please keep that and minimize the diff.

> -good_area:
> +	if (!(vma->vm_flags & vm_flags))
> +		return VM_FAULT_BADACCESS;
> +
>  	/*
> -	 * Check that the permissions on the VMA allow for the fault which
> -	 * occurred.
> +	 * There is a valid VMA for this access. But before proceeding
> +	 * make sure that it has required flags if there is an attempt
> +	 * to expand the stack downwards.
>  	 */

I think we can drop this comment, given we didn't have it previously.

> -	if (!(vma->vm_flags & vm_flags)) {
> -		fault = VM_FAULT_BADACCESS;
> -		goto out;
> -	}
> +	if (unlikely(vma->vm_start > addr)) {
> +		if (!(vma->vm_flags & VM_GROWSDOWN))
> +			return VM_FAULT_BADMAP;
>  
> +		if (expand_stack(vma, addr))
> +			return VM_FAULT_BADMAP;

You can drop the line space between these two if statements.

> +	}
>  	return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
> -
> -check_stack:
> -	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
> -		goto good_area;
> -out:
> -	return fault;

We used to check the stack before the checknig the rest of the vm_flags,
so this changes the precedence of the VM_FAULT_BADMAP and
VM_FAULT_BADACCESS return codes.

Please check the stack before checking the other vm_flags.

Otherwise, this looks like a nice cleanup -- the old control flow was
hideous.

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
  2019-05-29 12:34   ` Anshuman Khandual
@ 2019-05-30  6:34     ` Christoph Hellwig
  -1 siblings, 0 replies; 26+ messages in thread
From: Christoph Hellwig @ 2019-05-30  6:34 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Will Deacon,
	Mark Rutland, James Morse, Andrey Konovalov

On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
> __do_page_fault() is over complicated with multiple goto statements. This
> cleans up code flow and while there drops the vm_fault_t argument.

There is no argument dropped anywhere, just a local variable.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
@ 2019-05-30  6:34     ` Christoph Hellwig
  0 siblings, 0 replies; 26+ messages in thread
From: Christoph Hellwig @ 2019-05-30  6:34 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Mark Rutland, Catalin Marinas, Will Deacon, linux-kernel,
	James Morse, Andrey Konovalov, linux-arm-kernel

On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
> __do_page_fault() is over complicated with multiple goto statements. This
> cleans up code flow and while there drops the vm_fault_t argument.

There is no argument dropped anywhere, just a local variable.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
  2019-05-30  6:34     ` Christoph Hellwig
@ 2019-05-31  8:55       ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-31  8:55 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Will Deacon,
	Mark Rutland, James Morse, Andrey Konovalov



On 05/30/2019 12:04 PM, Christoph Hellwig wrote:
> On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
>> __do_page_fault() is over complicated with multiple goto statements. This
>> cleans up code flow and while there drops the vm_fault_t argument.
> 
> There is no argument dropped anywhere, just a local variable.
> 

You are right. Will fix both subject line and the commit message.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
@ 2019-05-31  8:55       ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-31  8:55 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Mark Rutland, Catalin Marinas, Will Deacon, linux-kernel,
	James Morse, Andrey Konovalov, linux-arm-kernel



On 05/30/2019 12:04 PM, Christoph Hellwig wrote:
> On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
>> __do_page_fault() is over complicated with multiple goto statements. This
>> cleans up code flow and while there drops the vm_fault_t argument.
> 
> There is no argument dropped anywhere, just a local variable.
> 

You are right. Will fix both subject line and the commit message.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
  2019-05-29 15:11     ` Mark Rutland
@ 2019-05-31  9:05       ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-31  9:05 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov



On 05/29/2019 08:41 PM, Mark Rutland wrote:
> On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
>> __do_page_fault() is over complicated with multiple goto statements. This
>> cleans up code flow and while there drops the vm_fault_t argument.
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: James Morse <james.morse@arm.com> 
>> Cc: Andrey Konovalov <andreyknvl@google.com>
>> ---
>>  arch/arm64/mm/fault.c | 38 ++++++++++++++++----------------------
>>  1 file changed, 16 insertions(+), 22 deletions(-)
>>
>> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
>> index 170c71f..a53a30e 100644
>> --- a/arch/arm64/mm/fault.c
>> +++ b/arch/arm64/mm/fault.c
>> @@ -397,37 +397,31 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
>>  static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
>>  			   unsigned int mm_flags, unsigned long vm_flags)
>>  {
>> -	struct vm_area_struct *vma;
>> -	vm_fault_t fault;
>> +	struct vm_area_struct *vma = find_vma(mm, addr);
>>  
>> -	vma = find_vma(mm, addr);
>> -	fault = VM_FAULT_BADMAP;
>>  	if (unlikely(!vma))
>> -		goto out;
>> -	if (unlikely(vma->vm_start > addr))
>> -		goto check_stack;
>> +		return VM_FAULT_BADMAP;
>>  
>>  	/*
>> -	 * Ok, we have a good vm_area for this memory access, so we can handle
>> -	 * it.
>> +	 * Check if the VMA has got the required permssion with respect
>> +	 * to the access fault here.
>>  	 */
> 
> We already had a perfectly good comment for this check:
> 
> 	/*
> 	 * Check that the permissions on the VMA allow for the fault which
> 	 * occurred.
> 	 */
> 
> ... so please keep that and minimize the diff.

Sure, will keep all the existing comments here.

> 
>> -good_area:
>> +	if (!(vma->vm_flags & vm_flags))
>> +		return VM_FAULT_BADACCESS;
>> +
>>  	/*
>> -	 * Check that the permissions on the VMA allow for the fault which
>> -	 * occurred.
>> +	 * There is a valid VMA for this access. But before proceeding
>> +	 * make sure that it has required flags if there is an attempt
>> +	 * to expand the stack downwards.
>>  	 */
> 
> I think we can drop this comment, given we didn't have it previously.

Okay.

> 
>> -	if (!(vma->vm_flags & vm_flags)) {
>> -		fault = VM_FAULT_BADACCESS;
>> -		goto out;
>> -	}
>> +	if (unlikely(vma->vm_start > addr)) {
>> +		if (!(vma->vm_flags & VM_GROWSDOWN))
>> +			return VM_FAULT_BADMAP;
>>  
>> +		if (expand_stack(vma, addr))
>> +			return VM_FAULT_BADMAP;
> 
> You can drop the line space between these two if statements.

Will do.

> 
>> +	}
>>  	return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
>> -
>> -check_stack:
>> -	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
>> -		goto good_area;
>> -out:
>> -	return fault;
> 
> We used to check the stack before the checknig the rest of the vm_flags,
> so this changes the precedence of the VM_FAULT_BADMAP and
> VM_FAULT_BADACCESS return codes.
> 
> Please check the stack before checking the other vm_flags.

Though it makes some sense to move VMA permission check earlier in the function as it
is the quicker one but I understand need to maintain the existing code flow in a clean
up patch like this. Will retain the existing flow.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault()
@ 2019-05-31  9:05       ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-31  9:05 UTC (permalink / raw)
  To: Mark Rutland
  Cc: Andrey Konovalov, Will Deacon, linux-kernel, James Morse,
	Catalin Marinas, linux-arm-kernel



On 05/29/2019 08:41 PM, Mark Rutland wrote:
> On Wed, May 29, 2019 at 06:04:45PM +0530, Anshuman Khandual wrote:
>> __do_page_fault() is over complicated with multiple goto statements. This
>> cleans up code flow and while there drops the vm_fault_t argument.
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: James Morse <james.morse@arm.com> 
>> Cc: Andrey Konovalov <andreyknvl@google.com>
>> ---
>>  arch/arm64/mm/fault.c | 38 ++++++++++++++++----------------------
>>  1 file changed, 16 insertions(+), 22 deletions(-)
>>
>> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
>> index 170c71f..a53a30e 100644
>> --- a/arch/arm64/mm/fault.c
>> +++ b/arch/arm64/mm/fault.c
>> @@ -397,37 +397,31 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
>>  static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
>>  			   unsigned int mm_flags, unsigned long vm_flags)
>>  {
>> -	struct vm_area_struct *vma;
>> -	vm_fault_t fault;
>> +	struct vm_area_struct *vma = find_vma(mm, addr);
>>  
>> -	vma = find_vma(mm, addr);
>> -	fault = VM_FAULT_BADMAP;
>>  	if (unlikely(!vma))
>> -		goto out;
>> -	if (unlikely(vma->vm_start > addr))
>> -		goto check_stack;
>> +		return VM_FAULT_BADMAP;
>>  
>>  	/*
>> -	 * Ok, we have a good vm_area for this memory access, so we can handle
>> -	 * it.
>> +	 * Check if the VMA has got the required permssion with respect
>> +	 * to the access fault here.
>>  	 */
> 
> We already had a perfectly good comment for this check:
> 
> 	/*
> 	 * Check that the permissions on the VMA allow for the fault which
> 	 * occurred.
> 	 */
> 
> ... so please keep that and minimize the diff.

Sure, will keep all the existing comments here.

> 
>> -good_area:
>> +	if (!(vma->vm_flags & vm_flags))
>> +		return VM_FAULT_BADACCESS;
>> +
>>  	/*
>> -	 * Check that the permissions on the VMA allow for the fault which
>> -	 * occurred.
>> +	 * There is a valid VMA for this access. But before proceeding
>> +	 * make sure that it has required flags if there is an attempt
>> +	 * to expand the stack downwards.
>>  	 */
> 
> I think we can drop this comment, given we didn't have it previously.

Okay.

> 
>> -	if (!(vma->vm_flags & vm_flags)) {
>> -		fault = VM_FAULT_BADACCESS;
>> -		goto out;
>> -	}
>> +	if (unlikely(vma->vm_start > addr)) {
>> +		if (!(vma->vm_flags & VM_GROWSDOWN))
>> +			return VM_FAULT_BADMAP;
>>  
>> +		if (expand_stack(vma, addr))
>> +			return VM_FAULT_BADMAP;
> 
> You can drop the line space between these two if statements.

Will do.

> 
>> +	}
>>  	return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
>> -
>> -check_stack:
>> -	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
>> -		goto good_area;
>> -out:
>> -	return fault;
> 
> We used to check the stack before the checknig the rest of the vm_flags,
> so this changes the precedence of the VM_FAULT_BADMAP and
> VM_FAULT_BADACCESS return codes.
> 
> Please check the stack before checking the other vm_flags.

Though it makes some sense to move VMA permission check earlier in the function as it
is the quicker one but I understand need to maintain the existing code flow in a clean
up patch like this. Will retain the existing flow.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/4] arm64/mm: Consolidate page fault information capture
  2019-05-29 14:53     ` Mark Rutland
@ 2019-05-31  9:10       ` Anshuman Khandual
  -1 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-31  9:10 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-kernel, linux-arm-kernel, Catalin Marinas, Will Deacon,
	James Morse, Andrey Konovalov



On 05/29/2019 08:23 PM, Mark Rutland wrote:
> On Wed, May 29, 2019 at 06:04:44PM +0530, Anshuman Khandual wrote:
>> This consolidates page fault information capture and move them bit earlier.
>> While here it also adds an wrapper is_write_abort(). It also saves some
>> cycles by replacing multiple user_mode() calls into a single one earlier
>> during the fault.
> 
> To be honest, I doubt this has any measureable impact, but I agree that
> using variables _may_ make the flow control easier to understand.
> 
>>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: James Morse <james.morse@arm.com> 
>> Cc: Andrey Konovalov <andreyknvl@google.com>
>> ---
>>  arch/arm64/mm/fault.c | 22 +++++++++++++++-------
>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
>> index da02678..170c71f 100644
>> --- a/arch/arm64/mm/fault.c
>> +++ b/arch/arm64/mm/fault.c
>> @@ -435,6 +435,11 @@ static bool is_el0_instruction_abort(unsigned int esr)
>>  	return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW;
>>  }
>>  
>> +static bool is_write_abort(unsigned int esr)
>> +{
>> +	return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
>> +}
> 
> In off-list review, I mentioned that this isn't true for EL1, and I
> think that we should name this 'is_el0_write_abort()' or add a comment
> explaining the caveats if factored into a helper.
> 
> Thanks,
> Mark.

Okay will change the wrapper name to is_el0_write_abort() and add a comment
explaining how this is only applicable to aborts originating from EL0.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/4] arm64/mm: Consolidate page fault information capture
@ 2019-05-31  9:10       ` Anshuman Khandual
  0 siblings, 0 replies; 26+ messages in thread
From: Anshuman Khandual @ 2019-05-31  9:10 UTC (permalink / raw)
  To: Mark Rutland
  Cc: Andrey Konovalov, Will Deacon, linux-kernel, James Morse,
	Catalin Marinas, linux-arm-kernel



On 05/29/2019 08:23 PM, Mark Rutland wrote:
> On Wed, May 29, 2019 at 06:04:44PM +0530, Anshuman Khandual wrote:
>> This consolidates page fault information capture and move them bit earlier.
>> While here it also adds an wrapper is_write_abort(). It also saves some
>> cycles by replacing multiple user_mode() calls into a single one earlier
>> during the fault.
> 
> To be honest, I doubt this has any measureable impact, but I agree that
> using variables _may_ make the flow control easier to understand.
> 
>>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: James Morse <james.morse@arm.com> 
>> Cc: Andrey Konovalov <andreyknvl@google.com>
>> ---
>>  arch/arm64/mm/fault.c | 22 +++++++++++++++-------
>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
>> index da02678..170c71f 100644
>> --- a/arch/arm64/mm/fault.c
>> +++ b/arch/arm64/mm/fault.c
>> @@ -435,6 +435,11 @@ static bool is_el0_instruction_abort(unsigned int esr)
>>  	return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW;
>>  }
>>  
>> +static bool is_write_abort(unsigned int esr)
>> +{
>> +	return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
>> +}
> 
> In off-list review, I mentioned that this isn't true for EL1, and I
> think that we should name this 'is_el0_write_abort()' or add a comment
> explaining the caveats if factored into a helper.
> 
> Thanks,
> Mark.

Okay will change the wrapper name to is_el0_write_abort() and add a comment
explaining how this is only applicable to aborts originating from EL0.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2019-05-31  9:10 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29 12:34 [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault() Anshuman Khandual
2019-05-29 12:34 ` Anshuman Khandual
2019-05-29 12:34 ` [PATCH 1/4] arm64/mm: Drop mmap_sem before calling __do_kernel_fault() Anshuman Khandual
2019-05-29 12:34   ` Anshuman Khandual
2019-05-29 12:34 ` [PATCH 2/4] arm64/mm: Drop task_struct argument from __do_page_fault() Anshuman Khandual
2019-05-29 12:34   ` Anshuman Khandual
2019-05-29 12:34 ` [PATCH 3/4] arm64/mm: Consolidate page fault information capture Anshuman Khandual
2019-05-29 12:34   ` Anshuman Khandual
2019-05-29 14:53   ` Mark Rutland
2019-05-29 14:53     ` Mark Rutland
2019-05-31  9:10     ` Anshuman Khandual
2019-05-31  9:10       ` Anshuman Khandual
2019-05-29 12:34 ` [PATCH 4/4] arm64/mm: Drop vm_fault_t argument from __do_page_fault() Anshuman Khandual
2019-05-29 12:34   ` Anshuman Khandual
2019-05-29 15:11   ` Mark Rutland
2019-05-29 15:11     ` Mark Rutland
2019-05-31  9:05     ` Anshuman Khandual
2019-05-31  9:05       ` Anshuman Khandual
2019-05-30  6:34   ` Christoph Hellwig
2019-05-30  6:34     ` Christoph Hellwig
2019-05-31  8:55     ` Anshuman Khandual
2019-05-31  8:55       ` Anshuman Khandual
2019-05-29 12:41 ` [PATCH 0/4] arm64/mm: Fixes and cleanups for do_page_fault() Will Deacon
2019-05-29 12:41   ` Will Deacon
2019-05-29 12:59   ` Anshuman Khandual
2019-05-29 12:59     ` Anshuman Khandual

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.