android_kernel_motorola_sm6225/arch/powerpc/mm
Christophe Leroy da929f6af4 powerpc/mm: Evaluate user_mode(regs) only once in do_page_fault()
Analysis of the assembly code shows that when using user_mode(regs),
at least the 'andi.' is redone all the time, and also
the 'lwz ,132(r31)' most of the time. With the new form, the 'is_user'
is mapped to cr4, then all further use of is_user results in just
things like 'beq cr4,218 <do_page_fault+0x218>'

Without the patch:

  50:	81 1e 00 84 	lwz     r8,132(r30)
  54:	71 09 40 00 	andi.   r9,r8,16384
  58:	40 82 00 0c 	bne     64 <do_page_fault+0x64>

  84:	81 3e 00 84 	lwz     r9,132(r30)
  8c:	71 2a 40 00 	andi.   r10,r9,16384
  90:	41 a2 01 64 	beq     1f4 <do_page_fault+0x1f4>

  d4:	81 3e 00 84 	lwz     r9,132(r30)
  dc:	71 28 40 00 	andi.   r8,r9,16384
  e0:	41 82 02 08 	beq     2e8 <do_page_fault+0x2e8>

 108:	81 3e 00 84 	lwz     r9,132(r30)
 110:	71 28 40 00 	andi.   r8,r9,16384
 118:	41 82 02 28 	beq     340 <do_page_fault+0x340>

 1e4:	81 3e 00 84 	lwz     r9,132(r30)
 1e8:	71 2a 40 00 	andi.   r10,r9,16384
 1ec:	40 82 01 68 	bne     354 <do_page_fault+0x354>

 228:	81 3e 00 84 	lwz     r9,132(r30)
 22c:	71 28 40 00 	andi.   r8,r9,16384
 230:	41 82 ff c4 	beq     1f4 <do_page_fault+0x1f4>

 288:	71 2a 40 00 	andi.   r10,r9,16384
 294:	41 a2 fe 60 	beq     f4 <do_page_fault+0xf4>

 50c:	81 3e 00 84 	lwz     r9,132(r30)
 514:	71 2a 40 00 	andi.   r10,r9,16384
 518:	40 a2 fc e0 	bne     1f8 <do_page_fault+0x1f8>

 534:	81 3e 00 84 	lwz     r9,132(r30)
 53c:	71 2a 40 00 	andi.   r10,r9,16384
 540:	41 82 fc b8 	beq     1f8 <do_page_fault+0x1f8>

This patch creates a local var called 'is_user' which contains the
result of user_mode(regs)

With the patch:

  20:	81 03 00 84 	lwz     r8,132(r3)
  48:	55 09 97 fe 	rlwinm  r9,r8,18,31,31
  58:	2e 09 00 00 	cmpwi   cr4,r9,0
  5c:	40 92 00 0c 	bne     cr4,68 <do_page_fault+0x68>

  88:	41 b2 01 90 	beq     cr4,218 <do_page_fault+0x218>

  d4:	40 92 01 d0 	bne     cr4,2a4 <do_page_fault+0x2a4>

 120:	41 b2 00 f8 	beq     cr4,218 <do_page_fault+0x218>

 138:	41 b2 ff a0 	beq     cr4,d8 <do_page_fault+0xd8>

 1d4:	40 92 00 e0 	bne     cr4,2b4 <do_page_fault+0x2b4>

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-06-02 19:19:45 +10:00
..
8xx_mmu.c powerpc/8xx: add CONFIG_PIN_TLB_IMMR 2016-07-09 02:02:48 -05:00
40x_mmu.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
44x_mmu.c powerpc: Delete __cpuinit usage from all users 2013-07-01 11:10:36 +10:00
copro_fault.c powerpc/mm: Update PROTFAULT handling in the page fault path 2017-02-15 20:02:39 +11:00
dma-noncoherent.c powerpc: Simplify test in __dma_sync() 2016-03-11 17:20:12 -06:00
dump_hashpagetable.c powerpc/mm/ptdump: Dump the first entry of the linear mapping as well 2017-06-02 19:09:52 +10:00
dump_linuxpagetables.c powerpc/mm: Fix crash in page table dump with huge pages 2017-05-17 11:56:33 +10:00
fault.c powerpc/mm: Evaluate user_mode(regs) only once in do_page_fault() 2017-06-02 19:19:45 +10:00
fsl_booke_mmu.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
hash64_4k.c powerpc/mm: Fix lazy icache flush on pre-POWER5 2016-11-29 23:59:40 +11:00
hash64_64k.c powerpc/mm: Fix lazy icache flush on pre-POWER5 2016-11-29 23:59:40 +11:00
hash_low_32.S powerpc/32: Remove Mac-on-Linux/rtlinux hooks 2017-03-21 22:09:26 +11:00
hash_native_64.c powerpc/mm: Add missing global TLB invalidate if cxl is active 2017-04-05 22:13:37 +10:00
hash_utils_64.c powerpc: Create asm/debugfs.h and move powerpc_debugfs_root there 2017-04-11 07:46:03 +10:00
highmem.c sched/preempt, mm/kmap: Explicitly disable/enable preemption in kmap_atomic_* 2015-05-19 08:39:14 +02:00
hugepage-hash64.c powerpc/mm: Move hash table ops to a separate structure 2016-07-21 18:59:09 +10:00
hugetlbpage-book3e.c powerpc/mm/nohash: MM_SLICE is only used by book3s 64 2017-03-31 23:09:47 +11:00
hugetlbpage-hash64.c powerpc/mm: Remove the debug hugepd_ok check 2017-01-23 19:19:28 +11:00
hugetlbpage-radix.c powerpc/mm/radix: Use mm->task_size for boundary checking instead of addr_limit 2017-04-19 20:00:18 +10:00
hugetlbpage.c powerpc/mm/hugetlb: Filter out hugepage size not supported by page table layout 2017-03-31 23:09:50 +11:00
icswx.c scripts/spelling.txt: add regsiter -> register spelling mistake 2017-05-08 17:15:13 -07:00
icswx.h powerpc/icswx: Fix race condition with IPI setting ACOP 2012-03-07 17:06:09 +11:00
icswx_pid.c powerpc: Split ICSWX ACOP and PID processing 2011-11-25 14:11:27 +11:00
init-common.c Merge branch 'topic/ppc-kvm' into next 2017-02-14 17:18:29 +11:00
init_32.c powerpc/32: Add missing \n and switch to pr_warn() 2016-09-13 17:37:11 +10:00
init_64.c powerpc updates for 4.12 part 1. 2017-05-05 11:36:44 -07:00
Makefile Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/scottwood/linux into next 2016-12-16 15:05:38 +11:00
mem.c powerpc/pseries: Automatically resize HPT for memory hot add/remove 2017-02-10 13:28:02 +11:00
mmap.c powerpc/mm: Fix possible out-of-bounds shift in arch_mmap_rnd() 2017-04-26 15:35:01 +10:00
mmu_context_book3s64.c powerpc/powernv: Introduce address translation services for Nvlink2 2017-04-04 13:27:26 +10:00
mmu_context_hash32.c powerpc: Remove power3 from comments 2014-07-28 14:10:26 +10:00
mmu_context_iommu.c Merge branch 'topic/ppc-kvm' into next 2017-04-28 20:19:37 +10:00
mmu_context_nohash.c powerpc/mm/nohash: MM_SLICE is only used by book3s 64 2017-03-31 23:09:47 +11:00
mmu_decl.h powerpc/8xx: Map IMMR area with 512k page at a fixed address 2016-07-09 02:02:48 -05:00
numa.c powerpc/mm: Remove reduntant initmem information from log 2017-04-11 07:46:05 +10:00
pgtable-book3e.c powerpc/mm: Make page table size a variable 2016-05-01 18:32:48 +10:00
pgtable-book3s64.c sched/headers: Prepare to remove the <linux/mm_types.h> dependency from <linux/sched.h> 2017-03-02 08:42:37 +01:00
pgtable-hash64.c sched/headers: Prepare to remove the <linux/mm_types.h> dependency from <linux/sched.h> 2017-03-02 08:42:37 +01:00
pgtable-radix.c powerpc fixes for 4.11 #3 2017-03-07 10:46:10 -08:00
pgtable.c powerpc/mm: Fix typo in set_pte_at() 2017-02-17 22:16:25 +11:00
pgtable_32.c powerpc/mm: Remove __this_fixmap_does_not_exist() 2017-06-02 19:09:53 +10:00
pgtable_64.c Merge branch 'topic/ppc-kvm' into next 2017-02-14 17:18:29 +11:00
ppc_mmu_32.c powerpc32: refactor x_mapped_by_bats() and x_mapped_by_tlbcam() together 2016-03-11 17:18:02 -06:00
slb.c powerpc/mm/hash: Don't open code VMALLOC_INDEX 2017-04-13 23:34:31 +10:00
slb_low.S powerpc/mm/hash: Store addr_limit in PACA 2017-04-01 21:12:27 +11:00
slice.c powerpc/mmap: Any hint > 128TB searches the full VA space 2017-04-19 20:00:19 +10:00
subpage-prot.c powerpc/mm/radix: Use mm->task_size for boundary checking instead of addr_limit 2017-04-19 20:00:18 +10:00
tlb-radix.c powerpc/mm/radix: Drop support for CPUs without lockless tlbie 2017-05-03 20:45:45 +10:00
tlb_hash32.c powerpc/mm: remove flush_tlb_page_nohash 2016-08-01 11:15:13 +10:00
tlb_hash64.c powerpc/mm: Hash abstraction for tlbflush routines 2016-05-01 18:33:08 +10:00
tlb_low_64e.S powerpc: Fix misspellings in comments. 2016-03-01 19:27:20 +11:00
tlb_nohash.c powerpc/nohash: Fix use of mmu_has_feature() in setup_initial_memory_limit() 2017-04-11 07:46:04 +10:00
tlb_nohash_low.S powerpc: Fix misspellings in comments. 2016-03-01 19:27:20 +11:00
vphn.c powerpc/vphn: parsing code rewrite 2015-03-18 10:48:59 +11:00
vphn.h powerpc/vphn: parsing code rewrite 2015-03-18 10:48:59 +11:00