Clean up syscall stub/seccomp filter generation.
Test: treehugger
Change-Id: Iceb1c22d82b4d402166c3712b5b8b48a30937c6d
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index fa5420b..0271a04 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -81,56 +81,6 @@
#
-# MIPS assembler template for each syscall stub
-#
-
-mips_call = syscall_stub_header + """\
- .set noreorder
- .cpload $t9
- li $v0, %(__NR_name)s
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno_internal
- j $t9
- nop
- .set reorder
-END(%(func)s)
-"""
-
-
-#
-# MIPS64 assembler template for each syscall stub
-#
-
-mips64_call = syscall_stub_header + """\
- .set push
- .set noreorder
- li $v0, %(__NR_name)s
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- move $t0, $ra
- bal 2f
- nop
-2:
- .cpsetup $ra, $t1, 2b
- LA $t9, __set_errno_internal
- .cpreturn
- j $t9
- move $ra, $t0
- .set pop
-END(%(func)s)
-"""
-
-
-#
# x86 assembler templates for each syscall stub
#
@@ -279,14 +229,6 @@
return arm64_call % syscall
-def mips_genstub(syscall):
- return mips_call % syscall
-
-
-def mips64_genstub(syscall):
- return mips64_call % syscall
-
-
def x86_genstub(syscall):
result = syscall_stub_header % syscall
@@ -455,21 +397,18 @@
if arch_list == "all":
for arch in SupportedArchitectures:
t[arch] = True
- elif arch_list == "lp32":
- for arch in SupportedArchitectures:
- if "64" not in arch:
- t[arch] = True
- elif arch_list == "lp64":
- for arch in SupportedArchitectures:
- if "64" in arch:
- t[arch] = True
else:
for arch in string.split(arch_list, ','):
- if arch in SupportedArchitectures:
+ if arch == "lp32":
+ for arch in SupportedArchitectures:
+ if "64" not in arch:
+ t[arch] = True
+ elif arch == "lp64":
+ for arch in SupportedArchitectures:
+ if "64" in arch:
+ t[arch] = True
+ elif arch in SupportedArchitectures:
t[arch] = True
- elif arch in ['mips', 'mips64']:
- # Unused.
- pass
else:
E("invalid syscall architecture '%s' in '%s'" % (arch, line))
return
@@ -511,12 +450,6 @@
E("socketcall_id for dispatch syscalls is only supported for x86 in '%s'" % t)
return
- if syscall.has_key("mips"):
- syscall["asm-mips"] = add_footer(32, mips_genstub(syscall), syscall)
-
- if syscall.has_key("mips64"):
- syscall["asm-mips64"] = add_footer(64, mips64_genstub(syscall), syscall)
-
if syscall.has_key("x86_64"):
syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
diff --git a/libc/tools/test_genseccomp.py b/libc/tools/test_genseccomp.py
index 71a78d1..0c2699a 100755
--- a/libc/tools/test_genseccomp.py
+++ b/libc/tools/test_genseccomp.py
@@ -25,8 +25,8 @@
def test_get_names(self):
bionic = cStringIO.StringIO(textwrap.dedent("""\
-int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) arm,mips,x86
-int fchown:fchown(int, uid_t, gid_t) arm64,mips,mips64,x86_64
+int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) arm,x86
+int fchown:fchown(int, uid_t, gid_t) arm64,x86_64
"""))
whitelist = cStringIO.StringIO(textwrap.dedent("""\
@@ -54,7 +54,7 @@
# Blacklist item must be in bionic
blacklist = cStringIO.StringIO(textwrap.dedent("""\
-int fchown2:fchown2(int, uid_t, gid_t) arm64,mips,mips64,x86_64
+int fchown2:fchown2(int, uid_t, gid_t) arm64,x86_64
"""))
with self.assertRaises(RuntimeError):
genseccomp.get_names([bionic, whitelist, blacklist], "arm")
@@ -64,7 +64,7 @@
# Test blacklist item is removed
blacklist = cStringIO.StringIO(textwrap.dedent("""\
-int fchown:fchown(int, uid_t, gid_t) arm64,mips,mips64,x86_64
+int fchown:fchown(int, uid_t, gid_t) arm64,x86_64
"""))
names = genseccomp.get_names([bionic, whitelist, blacklist], "arm64")
bionic.seek(0)
@@ -75,7 +75,7 @@
# Blacklist item must not be in whitelist
whitelist = cStringIO.StringIO(textwrap.dedent("""\
-int fchown:fchown(int, uid_t, gid_t) arm64,mips,mips64,x86_64
+int fchown:fchown(int, uid_t, gid_t) arm64,x86_64
"""))
with self.assertRaises(RuntimeError):
genseccomp.get_names([empty, whitelist, blacklist], "arm")
@@ -85,7 +85,7 @@
# No dups in bionic and whitelist
whitelist = cStringIO.StringIO(textwrap.dedent("""\
-int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) arm,mips,x86
+int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) arm,x86
"""))
with self.assertRaises(RuntimeError):
genseccomp.get_names([bionic, whitelist, empty], "arm")
@@ -119,16 +119,6 @@
self.get_switches("x86_64")),
[("openat", 257)])
- self.assertEquals(genseccomp.convert_names_to_NRs(["openat"],
- self.get_headers("mips"),
- self.get_switches("mips")),
- [("openat", 4288)])
-
- self.assertEquals(genseccomp.convert_names_to_NRs(["openat"],
- self.get_headers("mips64"),
- self.get_switches("mips64")),
- [("openat", 5247)])
-
def test_convert_NRs_to_ranges(self):
ranges = genseccomp.convert_NRs_to_ranges([("b", 2), ("a", 1)])
@@ -192,8 +182,8 @@
def test_construct_bpf(self):
syscalls = cStringIO.StringIO(textwrap.dedent("""\
- int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) arm,mips,x86
- int fchown:fchown(int, uid_t, gid_t) arm64,mips,mips64,x86_64
+ int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) arm,x86
+ int fchown:fchown(int, uid_t, gid_t) arm64,x86_64
"""))
whitelist = cStringIO.StringIO(textwrap.dedent("""\