Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: sandbox/linux/seccomp/linux_syscall_support.h

Issue 320008: Add assembly constraints to disable some overly aggressive GCC optimizations (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sandbox/linux/seccomp/sandbox.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2005-2008, Google Inc. 1 /* Copyright (c) 2005-2008, Google Inc.
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 * So, we just have to redefine all of the _syscallX() macros. 1439 * So, we just have to redefine all of the _syscallX() macros.
1440 */ 1440 */
1441 #undef LSS_BODY 1441 #undef LSS_BODY
1442 #define LSS_BODY(type,args...) \ 1442 #define LSS_BODY(type,args...) \
1443 long __res; \ 1443 long __res; \
1444 __asm__ __volatile__("push %%ebx\n" \ 1444 __asm__ __volatile__("push %%ebx\n" \
1445 "movl %2,%%ebx\n" \ 1445 "movl %2,%%ebx\n" \
1446 "int $0x80\n" \ 1446 "int $0x80\n" \
1447 "pop %%ebx" \ 1447 "pop %%ebx" \
1448 args \ 1448 args \
1449 : "memory"); \ 1449 : "esp", "memory"); \
1450 LSS_RETURN(type,__res) 1450 LSS_RETURN(type,__res)
1451 #undef _syscall0 1451 #undef _syscall0
1452 #define _syscall0(type,name) \ 1452 #define _syscall0(type,name) \
1453 type LSS_NAME(name)(void) { \ 1453 type LSS_NAME(name)(void) { \
1454 long __res; \ 1454 long __res; \
1455 __asm__ volatile("int $0x80" \ 1455 __asm__ volatile("int $0x80" \
1456 : "=a" (__res) \ 1456 : "=a" (__res) \
1457 : "0" (__NR_##name) \ 1457 : "0" (__NR_##name) \
1458 : "memory"); \ 1458 : "memory"); \
1459 LSS_RETURN(type,__res); \ 1459 LSS_RETURN(type,__res); \
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 long __res; \ 1496 long __res; \
1497 __asm__ __volatile__("push %%ebx\n" \ 1497 __asm__ __volatile__("push %%ebx\n" \
1498 "movl %2,%%ebx\n" \ 1498 "movl %2,%%ebx\n" \
1499 "movl %1,%%eax\n" \ 1499 "movl %1,%%eax\n" \
1500 "int $0x80\n" \ 1500 "int $0x80\n" \
1501 "pop %%ebx" \ 1501 "pop %%ebx" \
1502 : "=a" (__res) \ 1502 : "=a" (__res) \
1503 : "i" (__NR_##name), "ri" ((long)(arg1)), \ 1503 : "i" (__NR_##name), "ri" ((long)(arg1)), \
1504 "c" ((long)(arg2)), "d" ((long)(arg3)), \ 1504 "c" ((long)(arg2)), "d" ((long)(arg3)), \
1505 "S" ((long)(arg4)), "D" ((long)(arg5)) \ 1505 "S" ((long)(arg4)), "D" ((long)(arg5)) \
1506 : "memory"); \ 1506 : "esp", "memory"); \
1507 LSS_RETURN(type,__res); \ 1507 LSS_RETURN(type,__res); \
1508 } 1508 }
1509 #undef _syscall6 1509 #undef _syscall6
1510 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ 1510 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
1511 type5,arg5,type6,arg6) \ 1511 type5,arg5,type6,arg6) \
1512 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 1512 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
1513 type5 arg5, type6 arg6) { \ 1513 type5 arg5, type6 arg6) { \
1514 long __res; \ 1514 long __res; \
1515 struct { long __a1; long __a6; } __s = { (long)arg1, (long) arg6 }; \ 1515 struct { long __a1; long __a6; } __s = { (long)arg1, (long) arg6 }; \
1516 __asm__ __volatile__("push %%ebp\n" \ 1516 __asm__ __volatile__("push %%ebp\n" \
1517 "push %%ebx\n" \ 1517 "push %%ebx\n" \
1518 "movl 4(%2),%%ebp\n" \ 1518 "movl 4(%2),%%ebp\n" \
1519 "movl 0(%2), %%ebx\n" \ 1519 "movl 0(%2), %%ebx\n" \
1520 "movl %1,%%eax\n" \ 1520 "movl %1,%%eax\n" \
1521 "int $0x80\n" \ 1521 "int $0x80\n" \
1522 "pop %%ebx\n" \ 1522 "pop %%ebx\n" \
1523 "pop %%ebp" \ 1523 "pop %%ebp" \
1524 : "=a" (__res) \ 1524 : "=a" (__res) \
1525 : "i" (__NR_##name), "0" ((long)(&__s)), \ 1525 : "i" (__NR_##name), "0" ((long)(&__s)), \
1526 "c" ((long)(arg2)), "d" ((long)(arg3)), \ 1526 "c" ((long)(arg2)), "d" ((long)(arg3)), \
1527 "S" ((long)(arg4)), "D" ((long)(arg5)) \ 1527 "S" ((long)(arg4)), "D" ((long)(arg5)) \
1528 : "memory"); \ 1528 : "esp", "memory"); \
1529 LSS_RETURN(type,__res); \ 1529 LSS_RETURN(type,__res); \
1530 } 1530 }
1531 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, 1531 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
1532 int flags, void *arg, int *parent_tidptr, 1532 int flags, void *arg, int *parent_tidptr,
1533 void *newtls, int *child_tidptr) { 1533 void *newtls, int *child_tidptr) {
1534 long __res; 1534 long __res;
1535 __asm__ __volatile__(/* if (fn == NULL) 1535 __asm__ __volatile__(/* if (fn == NULL)
1536 * return -EINVAL; 1536 * return -EINVAL;
1537 */ 1537 */
1538 "movl %3,%%ecx\n" 1538 "movl %3,%%ecx\n"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 "movl $1,%%eax\n" 1604 "movl $1,%%eax\n"
1605 "int $0x80\n" 1605 "int $0x80\n"
1606 1606
1607 /* Return to parent. 1607 /* Return to parent.
1608 */ 1608 */
1609 "1:\n" 1609 "1:\n"
1610 : "=a" (__res) 1610 : "=a" (__res)
1611 : "0"(-EINVAL), "i"(__NR_clone), 1611 : "0"(-EINVAL), "i"(__NR_clone),
1612 "m"(fn), "m"(child_stack), "m"(flags), "m"(arg), 1612 "m"(fn), "m"(child_stack), "m"(flags), "m"(arg),
1613 "m"(parent_tidptr), "m"(newtls), "m"(child_tidptr) 1613 "m"(parent_tidptr), "m"(newtls), "m"(child_tidptr)
1614 : "memory", "ecx", "edx", "esi", "edi"); 1614 : "esp", "memory", "ecx", "edx", "esi", "edi");
1615 LSS_RETURN(int, __res); 1615 LSS_RETURN(int, __res);
1616 } 1616 }
1617 1617
1618 #define __NR__fadvise64_64 __NR_fadvise64_64 1618 #define __NR__fadvise64_64 __NR_fadvise64_64
1619 LSS_INLINE _syscall6(int, _fadvise64_64, int, fd, 1619 LSS_INLINE _syscall6(int, _fadvise64_64, int, fd,
1620 unsigned, offset_lo, unsigned, offset_hi, 1620 unsigned, offset_lo, unsigned, offset_hi,
1621 unsigned, len_lo, unsigned, len_hi, 1621 unsigned, len_lo, unsigned, len_hi,
1622 int, advice) 1622 int, advice)
1623 1623
1624 LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset, 1624 LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 "movq %3,%%rax\n" 1813 "movq %3,%%rax\n"
1814 "syscall\n" 1814 "syscall\n"
1815 1815
1816 /* Return to parent. 1816 /* Return to parent.
1817 */ 1817 */
1818 "1:\n" 1818 "1:\n"
1819 : "=a" (__res) 1819 : "=a" (__res)
1820 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), 1820 : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit),
1821 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg), 1821 "r"(fn), "S"(child_stack), "D"(flags), "r"(arg),
1822 "d"(parent_tidptr), "r"(__tls), "r"(__ctid) 1822 "d"(parent_tidptr), "r"(__tls), "r"(__ctid)
1823 : "memory", "r11", "rcx"); 1823 : "rsp", "memory", "r11", "rcx");
1824 } 1824 }
1825 LSS_RETURN(int, __res); 1825 LSS_RETURN(int, __res);
1826 } 1826 }
1827 LSS_INLINE _syscall2(int, arch_prctl, int, c, void *, a) 1827 LSS_INLINE _syscall2(int, arch_prctl, int, c, void *, a)
1828 LSS_INLINE _syscall4(int, fadvise64, int, fd, loff_t, offset, loff_t, len, 1828 LSS_INLINE _syscall4(int, fadvise64, int, fd, loff_t, offset, loff_t, len,
1829 int, advice) 1829 int, advice)
1830 1830
1831 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { 1831 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) {
1832 /* On x86-64, the kernel does not know how to return from 1832 /* On x86-64, the kernel does not know how to return from
1833 * a signal handler. Instead, it relies on user space to provide a 1833 * a signal handler. Instead, it relies on user space to provide a
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
3223 } 3223 }
3224 #endif 3224 #endif
3225 #endif 3225 #endif
3226 3226
3227 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) 3227 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)
3228 } 3228 }
3229 #endif 3229 #endif
3230 3230
3231 #endif 3231 #endif
3232 #endif 3232 #endif
OLDNEW
« no previous file with comments | « no previous file | sandbox/linux/seccomp/sandbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698