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

Unified Diff: sandbox/linux/seccomp-bpf/syscall.cc

Issue 1908253003: [MIPS] Avoid using LA macro in inline assembly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment regarding LA macro Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/syscall.cc
diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc
index bc6461f11773b245919596162eb4230162be56a4..4d55936189b17761ed71fa14df6752583cdf5cc5 100644
--- a/sandbox/linux/seccomp-bpf/syscall.cc
+++ b/sandbox/linux/seccomp-bpf/syscall.cc
@@ -190,12 +190,15 @@ asm(// We need to be able to tell the kernel exactly where we made a
"9:.size SyscallAsm, 9b-SyscallAsm\n"
#elif defined(__mips__)
".text\n"
+ ".option pic2\n"
".align 4\n"
+ ".global SyscallAsm\n"
".type SyscallAsm, @function\n"
"SyscallAsm:.ent SyscallAsm\n"
".frame $sp, 40, $ra\n"
".set push\n"
".set noreorder\n"
+ ".cpload $t9\n"
"addiu $sp, $sp, -40\n"
"sw $ra, 36($sp)\n"
// Check if "v0" is negative. If so, do not attempt to make a
@@ -204,7 +207,11 @@ asm(// We need to be able to tell the kernel exactly where we made a
// used as a marker that BPF code inspects.
"bgez $v0, 1f\n"
" nop\n"
- "la $v0, 2f\n"
+ // This is equivalent to "la $v0, 2f".
+ // LA macro has to be avoided since LLVM-AS has issue with LA in PIC mode
+ // https://llvm.org/bugs/show_bug.cgi?id=27644
+ "lw $v0, %got(2f)($gp)\n"
+ "addiu $v0, $v0, %lo(2f)\n"
"b 2f\n"
" nop\n"
// On MIPS first four arguments go to registers a0 - a3 and any
@@ -262,6 +269,10 @@ asm(// We need to be able to tell the kernel exactly where we made a
extern "C" {
intptr_t SyscallAsm(intptr_t nr, const intptr_t args[6]);
}
+#elif defined(__mips__)
+extern "C" {
+intptr_t SyscallAsm(intptr_t nr, const intptr_t args[8]);
+}
#endif
} // namespace
@@ -395,20 +406,21 @@ intptr_t Syscall::SandboxSyscallRaw(int nr,
const intptr_t* args,
intptr_t* err_ret) {
register intptr_t ret __asm__("v0") = nr;
+ register intptr_t syscallasm __asm__("t9") = (intptr_t) &SyscallAsm;
// a3 register becomes non zero on error.
register intptr_t err_stat __asm__("a3") = 0;
{
register const intptr_t* data __asm__("a0") = args;
asm volatile(
- "la $t9, SyscallAsm\n"
"jalr $t9\n"
" nop\n"
: "=r"(ret), "=r"(err_stat)
: "0"(ret),
- "r"(data)
+ "r"(data),
+ "r"(syscallasm)
// a2 is in the clober list so inline assembly can not change its
// value.
- : "memory", "ra", "t9", "a2");
+ : "memory", "ra", "a2");
}
// Set an error status so it can be used outside of this function
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698