← Back to team overview

openjdk team mailing list archive

[Bug 605042] [PATCH lucid/fsl-imx51] ARM: 5746/1: Handle possible translation errors in ARMv6/v7 coherent_user_range

 

From: Catalin Marinas <catalin.marinas@xxxxxxx>

BugLink: http://launchpad.net/bugs/605042

This is needed because applications using the sys_cacheflush system call
can pass a memory range which isn't mapped yet even though the
corresponding vma is valid. The patch also adds unwinding annotations
for correct backtraces from the coherent_user_range() functions.

Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
Signed-off-by: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx>

cherry-picked from upstream commit
32cfb1b16f2b68d2296536811cadfffe26a06c1b

Signed-off-by: Jeremy Kerr <jeremy.kerr@xxxxxxxxxxxxx>

---
 arch/arm/mm/cache-v6.S |   20 ++++++++++++++++++--
 arch/arm/mm/cache-v7.S |   19 +++++++++++++++++--
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mm/cache-v6.S b/arch/arm/mm/cache-v6.S
index 8f5c13f..295e25d 100644
--- a/arch/arm/mm/cache-v6.S
+++ b/arch/arm/mm/cache-v6.S
@@ -12,6 +12,7 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/unwind.h>
 
 #include "proc-macros.S"
 
@@ -121,11 +122,13 @@ ENTRY(v6_coherent_kern_range)
  *	- the Icache does not read data from the write buffer
  */
 ENTRY(v6_coherent_user_range)
-
+ UNWIND(.fnstart		)
 #ifdef HARVARD_CACHE
 	bic	r0, r0, #CACHE_LINE_SIZE - 1
-1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D line
+1:
+ USER(	mcr	p15, 0, r0, c7, c10, 1	)	@ clean D line
 	add	r0, r0, #CACHE_LINE_SIZE
+2:
 	cmp	r0, r1
 	blo	1b
 #endif
@@ -143,6 +146,19 @@ ENTRY(v6_coherent_user_range)
 	mov	pc, lr
 
 /*
+ * Fault handling for the cache operation above. If the virtual address in r0
+ * isn't mapped, just try the next page.
+ */
+9001:
+	mov	r0, r0, lsr #12
+	mov	r0, r0, lsl #12
+	add	r0, r0, #4096
+	b	2b
+ UNWIND(.fnend		)
+ENDPROC(v6_coherent_user_range)
+ENDPROC(v6_coherent_kern_range)
+
+/*
  *	v6_flush_kern_dcache_page(kaddr)
  *
  *	Ensure that the data held in the page kaddr is written back
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
index be93ff0..3290dac 100644
--- a/arch/arm/mm/cache-v7.S
+++ b/arch/arm/mm/cache-v7.S
@@ -13,6 +13,7 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 #include <asm/assembler.h>
+#include <asm/unwind.h>
 
 #include "proc-macros.S"
 
@@ -147,13 +148,16 @@ ENTRY(v7_coherent_kern_range)
  *	- the Icache does not read data from the write buffer
  */
 ENTRY(v7_coherent_user_range)
+ UNWIND(.fnstart		)
 	dcache_line_size r2, r3
 	sub	r3, r2, #1
 	bic	r0, r0, r3
-1:	mcr	p15, 0, r0, c7, c11, 1		@ clean D line to the point of unification
+1:
+ USER(	mcr	p15, 0, r0, c7, c11, 1	)	@ clean D line to the point of unification
 	dsb
-	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I line
+ USER(	mcr	p15, 0, r0, c7, c5, 1	)	@ invalidate I line
 	add	r0, r0, r2
+2:
 	cmp	r0, r1
 	blo	1b
 	mov	r0, #0
@@ -161,6 +165,17 @@ ENTRY(v7_coherent_user_range)
 	dsb
 	isb
 	mov	pc, lr
+
+/*
+ * Fault handling for the cache operation above. If the virtual address in r0
+ * isn't mapped, just try the next page.
+ */
+9001:
+	mov	r0, r0, lsr #12
+	mov	r0, r0, lsl #12
+	add	r0, r0, #4096
+	b	2b
+ UNWIND(.fnend		)
 ENDPROC(v7_coherent_kern_range)
 ENDPROC(v7_coherent_user_range)

-- 
You received this bug notification because you are a member of OpenJDK,
which is subscribed to openjdk-6 in ubuntu.
https://bugs.launchpad.net/bugs/605042

Title:
  [armel] java fails to start with eglibc-2.12-0ubuntu4

Status in Linaro Toolchain Miscellanies:
  Confirmed
Status in Release Notes for Ubuntu:
  New
Status in “eglibc” package in Ubuntu:
  Fix Released
Status in “linux-fsl-imx51” package in Ubuntu:
  Invalid
Status in “openjdk-6” package in Ubuntu:
  Invalid
Status in “eglibc” source package in Lucid:
  Invalid
Status in “linux-fsl-imx51” source package in Lucid:
  In Progress
Status in “openjdk-6” source package in Lucid:
  Invalid
Status in “eglibc” source package in Maverick:
  Triaged
Status in “linux-fsl-imx51” source package in Maverick:
  Invalid
Status in “openjdk-6” source package in Maverick:
  Invalid
Status in “eglibc” source package in Natty:
  Fix Released
Status in “linux-fsl-imx51” source package in Natty:
  Invalid
Status in “openjdk-6” source package in Natty:
  Invalid
Status in “eglibc” package in Debian:
  Unknown

Bug description:
  reverting back to eglibc-2.12-0ubuntu3 works around the problem

  $ strace java -version
  [...]
  access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
  open("/lib/libm.so.6", O_RDONLY)        = 3
  read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\3701\0\0004\0\0\0"..., 512) = 512
  fstat64(3, {st_mode=S_IFREG|0644, st_size=407156, ...}) = 0
  mmap2(NULL, 438440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40424000
  mprotect(0x40487000, 28672, PROT_NONE)  = 0
  mmap2(0x4048e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x62) = 0x4048e000
  close(3)                                = 0
  mprotect(0x4048e000, 4096, PROT_READ)   = 0
  mprotect(0x40169000, 2572288, PROT_READ|PROT_WRITE) = 0
  mprotect(0x40169000, 2572288, PROT_READ|PROT_EXEC) = 0
  cacheflush(0x40169000, 0x403dd000, 0, 0x40169000, 0x19448 <unfinished ...>
  +++ killed by SIGSEGV +++
  Segmentation fault

  Unable to handle kernel paging request at virtual address 401a1000
  pgd = cd108000
  [401a1000] *pgd=99a5b031, *pte=00000000, *ppte=00000000
  Internal error: Oops: 817 [#4455]
  Modules linked in: ov3640_camera v4l2_int_device uio_pdrv_genirq joydev uio
  CPU: 0    Tainted: G      D     (2.6.31-608-imx51 #14-Ubuntu)
  PC is at v7_coherent_kern_range+0x18/0x44
  LR is at arm_syscall+0x2a8/0x2c4
  pc : [<c003e1e8>]    lr : [<c003a858>]    psr: 80000013
  sp : cc81be80  ip : dc172bb0  fp : cc81bfa4
  r10: 4001e568  r9 : cc81a000  r8 : 00000000
  r7 : 000f0002  r6 : 00000000  r5 : 40169000  r4 : 403dd000
  r3 : 0000003f  r2 : 00000040  r1 : 403dd000  r0 : 401a1000
  Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
  Control: 10c5387d  Table: 9d108019  DAC: 00000015
  Process java (pid: 6558, stack limit = 0xcc81a2f0)
  Stack: (0xcc81be80 to 0xcc81c000)
  be80: cc81bed4 cc81be90 c047edc0 c005d290 c047edc0 c006e6dc c060d26c c006e6dc 
  bea0: c060d288 c060d270 cc81befc 00000005 cc81a000 00000005 cc81bee8 c0036ae4 
  bec0: cc81a000 00000005 cc81bee4 cc81bed8 c006e724 c006bd04 cc81bf84 cc81bee8 
  bee0: c006e7e0 c006e64c 00000005 00000000 00000005 0000199e 000009db 00000000 
  bf00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
  bf20: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
  bf40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
  bf60: 00000000 00000000 cc81a000 cc81bfb0 000f0002 000f0002 cc81bfa4 cc81bf88 
  bf80: c0037a50 c006e76c 40169000 00019448 be970fa8 00000050 00000000 cc81bfa8 
  bfa0: c0036ac0 c003a5bc 00019448 be970fa8 40169000 403dd000 00000000 40169000 
  bfc0: 00019448 be970fa8 00000050 000f0002 40169000 00000cc0 4001e568 4001e8b8 
  bfe0: 000f0002 be970f90 400093cd 4000fd96 00000030 40169000 696c4075 2e737473 
  Backtrace: 
  [<c003a5b0>] (arm_syscall+0x0/0x2c4) from [<c0036ac0>] (__sys_trace_return+0x0/0x20)
   r6:00000050 r5:be970fa8 r4:00019448
  Code: e3a02010 e1a02312 e2423001 e1c00003 (ee070f3b) 
  mxc_ipu mxc_ipu: Channel already disabled 9
  mxc_ipu mxc_ipu: Channel already uninitialized 9
  DMFC high resolution has set, will not change
  ---[ end trace b707ea3bd34d5698 ]---



Follow ups