Bug fix: JVM crashes with SIGILL when using TraceBytecodes

Shanyao Chen shanyao.chen at linaro.org
Wed Jan 20 11:57:33 UTC 2016


Hi all,
There is a bug on slowdebug. JVM crashes with SIGILL when using
-XX:+TraceBytecodes. The illegal instruction is
pop{r0,r1,...sp,lr,pc}, the sp can only be in the list before ARMv7,
and it's illegal in ARMv7.
This instruction is generated by following codes:

/************************code start**************************/
address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
  address entry = __ pc();

  __ push(lr);
  __ push(state);
  __ push(RegSet::range(r0, r15), sp);
  __ mov(c_rarg2, r0);  // Pass itos
  __ call_VM(noreg,
             CAST_FROM_FN_PTR(address, SharedRuntime::trace_bytecode),
             c_rarg1, c_rarg2, c_rarg3);
  __ pop(RegSet::range(r0, r15), sp);
  __ pop(state);
  __ pop(lr);
  __ b(lr);                                   // return from result handler

  return entry;
}
/************************code end***************************/

r13 can't be in the pop/ldmia list, r14 is already pushed, and
push/pop pc also cause an another problem.
The patch use push/pop(RegSet::range(r0,12),sp) instead of using
push/pop(RegSet::range(r0,15),sp).

/************************patch start**************************/
--- a/src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp        Mon
Jan 11 14:58:34 2016 +0000
+++ b/src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp        Tue
Jan 19 11:03:03 2016 +0800
@@ -1864,12 +1864,12 @@

   __ push(lr);
   __ push(state);
-  __ push(RegSet::range(r0, r15), sp);
+  __ push(RegSet::range(r0, r12), sp);
   __ mov(c_rarg2, r0);  // Pass itos
   __ call_VM(noreg,
              CAST_FROM_FN_PTR(address, SharedRuntime::trace_bytecode),
              c_rarg1, c_rarg2, c_rarg3);
-  __ pop(RegSet::range(r0, r15), sp);
+  __ pop(RegSet::range(r0, r12), sp);
   __ pop(state);
   __ pop(lr);
   __ b(lr);
/************************patch end****************************/
-------------- next part --------------
diff -r d84c0075a377 src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp
--- a/src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp	Mon Jan 11 14:58:34 2016 +0000
+++ b/src/cpu/aarch32/vm/templateInterpreter_aarch32.cpp	Tue Jan 19 11:03:38 2016 +0800
@@ -1864,12 +1864,12 @@
 
   __ push(lr);
   __ push(state);
-  __ push(RegSet::range(r0, r15), sp);
+  __ push(RegSet::range(r0, r12), sp);
   __ mov(c_rarg2, r0);  // Pass itos
   __ call_VM(noreg,
              CAST_FROM_FN_PTR(address, SharedRuntime::trace_bytecode),
              c_rarg1, c_rarg2, c_rarg3);
-  __ pop(RegSet::range(r0, r15), sp);
+  __ pop(RegSet::range(r0, r12), sp);
   __ pop(state);
   __ pop(lr);
   __ b(lr);                                   // return from result handler


More information about the aarch32-port-dev mailing list