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

Side by Side Diff: sandbox/linux/seccomp-bpf/kernel_return_value_helpers.cc

Issue 260793003: [MIPS] Add seccomp bpf support (Closed) Base URL: https://git.chromium.org/git/chromium/src.git@master
Patch Set: Update per code review Created 6 years, 6 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sandbox/linux/seccomp-bpf/kernel_return_value_helpers.h"
6 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h"
7
8 namespace sandbox {
9
10 int ErrnoToKernelRet(int kernel_ret) {
11 #if defined(__mips__)
12 return kernel_ret;
13 #else
14 return -kernel_ret;
15 #endif
16 }
17
18 void PutValueInUcontext(int ret_val, ucontext_t* ctx) {
19 #if defined(__mips__)
20 // Mips ABI states that on error a3 CPU register has non zero value and if
21 // there is no error, it should be zero.
22 if (ret_val < 0) {
jln (very slow on Chromium) 2014/06/03 01:00:33 This can't work for instance with mmap(2). mmap()
23 // The sign of errno that is returned from the kernel was changed in
24 // SandboxSyscall() in case of Mips in order for SandboxSyscall() to
25 // behave the same for all supported architectures. In order to write
26 // correct value to return register this sign needs to be changed back.
27 ret_val = -ret_val;
28 SECCOMP_PARM4(ctx) = 1;
29 } else
30 SECCOMP_PARM4(ctx) = 0;
31 #endif
32 SECCOMP_RESULT(ctx) = static_cast<greg_t>(ret_val);
33 }
34
35 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698