[x264-devel] checkasm: aarch64: Add filler args to make sure all parameters are passed on the stack

Martin Storsjö git at videolan.org
Thu Dec 1 21:01:44 CET 2016


x264 | branch: master | Martin Storsjö <martin at martin.st> | Wed Nov 16 10:57:31 2016 +0200| [983acc911543453449a65bd02bbdff4c8cfe8e6a] | committer: Henrik Gramner

checkasm: aarch64: Add filler args to make sure all parameters are passed on the stack

This, combined with clobbering the stack space prior to the call,
increases the chances of finding cases where 32 bit parameters
are erroneously treated as 64 bit.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=983acc911543453449a65bd02bbdff4c8cfe8e6a
---

 tools/checkasm-aarch64.S | 15 ++++++---------
 tools/checkasm.c         |  2 +-
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/tools/checkasm-aarch64.S b/tools/checkasm-aarch64.S
index 1eb4546..7f66ead 100644
--- a/tools/checkasm-aarch64.S
+++ b/tools/checkasm-aarch64.S
@@ -99,21 +99,18 @@ function x264_checkasm_call, export=1
 
     sub         sp,  sp,  #ARG_STACK
 .equ pos, 0
-// first two stacked args are copied to x6, x7
 .rept MAX_ARGS-8
-    ldr         x9, [x29, #16 + 16 + pos]
+    // Skip the first 8 args, that are loaded into registers
+    ldr         x9, [x29, #16 + 8*8 + pos]
     str         x9, [sp, #pos]
 .equ pos, pos + 8
 .endr
 
     mov         x12, x0
-    mov         x0,  x2
-    mov         x1,  x3
-    mov         x2,  x4
-    mov         x3,  x5
-    mov         x4,  x6
-    mov         x5,  x7
-    ldp         x6,  x7,  [x29, #16]
+    ldp         x0,  x1,  [x29, #16]
+    ldp         x2,  x3,  [x29, #32]
+    ldp         x4,  x5,  [x29, #48]
+    ldp         x6,  x7,  [x29, #64]
     blr         x12
     add         sp,  sp,  #ARG_STACK
     ldr         x2,  [sp]
diff --git a/tools/checkasm.c b/tools/checkasm.c
index cd0e275..6de6bc7 100644
--- a/tools/checkasm.c
+++ b/tools/checkasm.c
@@ -263,7 +263,7 @@ void x264_checkasm_stack_clobber( uint64_t clobber, ... );
 #define call_a1(func,...) ({ \
     uint64_t r = (rand() & 0xffff) * 0x0001000100010001ULL; \
     x264_checkasm_stack_clobber( r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r,r ); /* max_args+8 */ \
-    x264_checkasm_call(( intptr_t(*)())func, &ok, __VA_ARGS__ ); })
+    x264_checkasm_call(( intptr_t(*)())func, &ok, 0, 0, 0, 0, 0, 0, __VA_ARGS__ ); })
 #elif ARCH_X86 || ARCH_ARM
 #define call_a1(func,...) x264_checkasm_call( (intptr_t(*)())func, &ok, __VA_ARGS__ )
 #else



More information about the x264-devel mailing list