Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Upstream-Status: Pending |
| 2 | |
| 3 | Properly load arguments 5 an 6 for x86-64 syscall |
| 4 | Use asm ("r10") and asm ("r8") to load arguments 5 an 6 for x86-64 |
| 5 | syscall so that it works with both x32 and x86-64. |
| 6 | |
| 7 | Received this patch from H.J. Lu <hjl.tools@gmail.com> |
| 8 | |
| 9 | Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com> |
| 10 | 2011/12/02 |
| 11 | |
| 12 | --- libaio-0.3.109/src/syscall-x86_64.h.x32 2009-10-09 11:17:02.000000000 -0700 |
| 13 | +++ libaio-0.3.109/src/syscall-x86_64.h 2011-12-02 09:09:07.537603224 -0800 |
| 14 | @@ -1,8 +1,18 @@ |
| 15 | +#ifndef __NR_io_setup |
| 16 | #define __NR_io_setup 206 |
| 17 | +#endif |
| 18 | +#ifndef __NR_io_destroy |
| 19 | #define __NR_io_destroy 207 |
| 20 | +#endif |
| 21 | +#ifndef __NR_io_getevents |
| 22 | #define __NR_io_getevents 208 |
| 23 | +#endif |
| 24 | +#ifndef __NR_io_submit |
| 25 | #define __NR_io_submit 209 |
| 26 | +#endif |
| 27 | +#ifndef __NR_io_cancel |
| 28 | #define __NR_io_cancel 210 |
| 29 | +#endif |
| 30 | |
| 31 | #define __syscall_clobber "r11","rcx","memory" |
| 32 | #define __syscall "syscall" |
| 33 | @@ -42,10 +52,11 @@ return __res; \ |
| 34 | type fname (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ |
| 35 | { \ |
| 36 | long __res; \ |
| 37 | -__asm__ volatile ("movq %5,%%r10 ;" __syscall \ |
| 38 | +register long __a4 asm ("r10") = (long) arg4; \ |
| 39 | +__asm__ volatile (__syscall \ |
| 40 | : "=a" (__res) \ |
| 41 | : "0" (__NR_##sname),"D" ((long)(arg1)),"S" ((long)(arg2)), \ |
| 42 | - "d" ((long)(arg3)),"g" ((long)(arg4)) : __syscall_clobber,"r10" ); \ |
| 43 | + "d" ((long)(arg3)),"r" (__a4)); \ |
| 44 | return __res; \ |
| 45 | } |
| 46 | |
| 47 | @@ -54,10 +65,11 @@ return __res; \ |
| 48 | type fname (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ |
| 49 | { \ |
| 50 | long __res; \ |
| 51 | -__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall \ |
| 52 | +register long __a4 asm ("r10") = (long) arg4; \ |
| 53 | +register long __a5 asm ("r8") = (long) arg5; \ |
| 54 | +__asm__ volatile ( __syscall \ |
| 55 | : "=a" (__res) \ |
| 56 | : "0" (__NR_##sname),"D" ((long)(arg1)),"S" ((long)(arg2)), \ |
| 57 | - "d" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5)) : \ |
| 58 | - __syscall_clobber,"r8","r10" ); \ |
| 59 | + "d" ((long)(arg3)),"r" (__a4),"r" (__a5)); \ |
| 60 | return __res; \ |
| 61 | } |