From patchwork Sun May 19 20:36:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164493 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4779865ili; Sun, 19 May 2019 13:41:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwodlkHJlsuZwRBIyiYiq/5IDbyC8Yxy/Z/TtbEs9EHgPanpPGj73snckNgNDPrs6LIV7UF X-Received: by 2002:a50:9601:: with SMTP id y1mr58153465eda.27.1558298460419; Sun, 19 May 2019 13:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298460; cv=none; d=google.com; s=arc-20160816; b=K6MIOd396E3jIVCmMKslOFyDT13iFSTPhVp1OeJ9QlLVS9+AJQkDXErPINQu/PAfwA WYhsCIpu9KKVW/JUz3Qg0amie8QfwACUHdaKU0CcWdmVUcmz9lVrffbvJJxtdstAG4Uc KMYm+gYpeINNw7hfS1jCj/zop8eueBjl8W4JRRFXDN/hxY1XGv6fkMSJDGQvqaIZIjvA FK+KljyTCXRW8PrHR7ZMXXBCQh8XF/1f4mxCIOazlFyOmarghUfRcQ05ryuCCGvOlPHv dJWvh947YlKQa35ESXjMHS4tmdLfFxlghCFEAmE+aCRdSFNruIJKemrSYjvLED+APRem JlZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=cmoV0D7GN+O7XMTBinQw7l8h/uqp/z8ssaPQ/O0YSSk=; b=WSoVN1eMX/ygrvApxgnnrEPS8aQOnhbx3yM5vRLnlxGmS3C6CsSLGVhGQ5as8vOM+B P/lWj8aE0220/G98TpTJDbkOrWKyzHCzr27sYgX9N2pqVTcGjND4TrEieCnMzd7Wrdd3 28+MUOZwQZ/a65tiWvH7c1cnVclS8GCfZbeQ/lgkn/E4jY07aUtT2LIK9V3agt1v04I2 LLhRL6PkCv2LgWEvaX3o+5Wq3XGVffMFlKtJiPHHKNw3frglGliluvfsYINyVEjKOzdR bgjscjYpXXO+fxxQtrOMD6LaKfyuZs4GJFJVb+FyC2QP6YQKY4jvrjAHG0p0Czv0Of74 blcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=spB9JcPk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g18si2034653ejw.9.2019.05.19.13.41.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:41:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=spB9JcPk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSc7-0005ey-54 for patch@linaro.org; Sun, 19 May 2019 16:40:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYo-0002j5-8N for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYl-0003LX-Ib for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:34 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:46925) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYl-0003KY-8n for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:31 -0400 Received: by mail-pl1-x643.google.com with SMTP id r18so5698374pls.13 for ; Sun, 19 May 2019 13:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cmoV0D7GN+O7XMTBinQw7l8h/uqp/z8ssaPQ/O0YSSk=; b=spB9JcPkJE9212Ohu8Z9VbpQGH+3q35l5tXjegomRNFuJEcvwwG65i3F0E1Y9M07Br ow468ffcsjrdSRY9hsPPDqjsxA28e+e6oYNeQr90RKKoCDjZRFKj/RwM/SCbQNyvvlDX y3PY0+LTgtyNv8dmGwYQTRGgJBKjse+lHQjDQKk29ytrPMwuvTCYHYtonUF3ol+yIAhp OEv7OtwYZe0vJowK7m1swE3iRwttLBgEzFCBDreYvxF0ht45eVGHhwoVL4/MaooS8C6q Gt5Z7U/jRnneFxfBHMGALk0vq4a4lcLj4fLrNvGrh+0hQ6GqThEgVJ7E1vsMT3R3lNXc I+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cmoV0D7GN+O7XMTBinQw7l8h/uqp/z8ssaPQ/O0YSSk=; b=lr1gcxHve7mA02xCnSKgNMTb0tk6KmiyWfSSalesXUR2Frxn5sAJejXJdf6zJIMMp6 zJV0nz+SMnA7jT/pUNdF0hm9iRybMkjjFbLYLKtbF7xL8TC0HS/0r5TK3I9x7GeoPtAk U2RhTz4K7I96JO/zsnn8toAwdQTgj3DBFQsbez3uWxHBrJJE7Qmyn8RRwvVpbrI2mP1t rt+NH5mCIcIKmXEJuW/3eqLv4oT36r839q6ssVa6BoQUkrfpiSa1riQDVdTCqY4InmN6 58zai6xK9uaAfrvoNjqlHrnu5gjqMXv5OCLYgHiWYmUyjp3rTOiBmQgIKgjB9nbG7PPA ql6A== X-Gm-Message-State: APjAAAVYRkl71Ag5seOy+hV/0HqwnC+O5ArJ4eu4YSRjTz77upj6kqNY XHjskxXqdZs46WqOoS8TA3CWfQL0hdY= X-Received: by 2002:a17:902:f81:: with SMTP id 1mr22215188plz.242.1558298249521; Sun, 19 May 2019 13:37:29 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:13 -0700 Message-Id: <20190519203726.20729-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v7 01/74] linux-user: Setup split syscall infrastructure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Defines a unified structure for implementation and strace. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 17 ++ linux-user/syscall.h | 89 +++++++++ linux-user/strace.c | 388 +++++++++++++++++++++++++++----------- linux-user/syscall.c | 103 +++++++++- 4 files changed, 484 insertions(+), 113 deletions(-) create mode 100644 linux-user/syscall-defs.h create mode 100644 linux-user/syscall.h -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h new file mode 100644 index 0000000000..8c0490425a --- /dev/null +++ b/linux-user/syscall-defs.h @@ -0,0 +1,17 @@ +/* + * Linux syscall definitions + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ diff --git a/linux-user/syscall.h b/linux-user/syscall.h new file mode 100644 index 0000000000..43b5dc0684 --- /dev/null +++ b/linux-user/syscall.h @@ -0,0 +1,89 @@ +/* + * Linux syscalls internals + * Copyright (c) 2018 Linaro, Limited. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef LINUX_USER_SYSCALL_H +#define LINUX_USER_SYSCALL_H 1 + +typedef struct SyscallDef SyscallDef; + +/* + * This hook extracts max 6 arguments from max 8 input registers. + * In the process, register pairs that store 64-bit arguments are merged. + * Finally, syscalls are demultipliexed; e.g. the hook for socketcall will + * return the SyscallDef for bind, listen, etc. In the process the hook + * may need to read from guest memory, or otherwise validate operands. + * On failure, set errno (to a host value) and return NULL; + * the (target adjusted) errno will be returned to the guest. + */ +typedef const SyscallDef *SyscallArgsFn(const SyscallDef *, int64_t out[6], + abi_long in[8]); + +/* This hook implements the syscall. */ +typedef abi_long SyscallImplFn(CPUArchState *, int64_t, int64_t, int64_t, + int64_t, int64_t, int64_t); + +/* This hook prints the arguments to the syscall for strace. */ +typedef void SyscallPrintFn(const SyscallDef *, int64_t arg[6]); + +/* This hook print the return value from the syscall for strace. */ +typedef void SyscallPrintRetFn(const SyscallDef *, abi_long); + +/* + * These flags describe the arguments for the generic fallback to + * SyscallPrintFn. ARG_NONE indicates that the argument is not present. + */ +typedef enum { + ARG_NONE = 0, + + /* These print as numbers of abi_long. */ + ARG_DEC, + ARG_HEX, + ARG_OCT, + + /* These print as sets of flags. */ + ARG_ATDIRFD, + ARG_MODEFLAG, + ARG_OPENFLAG, + + /* These are interpreted as pointers. */ + ARG_PTR, + ARG_STR, + ARG_BUF, + + /* For a 32-bit host, force printing as a 64-bit operand. */ +#if TARGET_ABI_BITS == 32 + ARG_DEC64, +#else + ARG_DEC64 = ARG_DEC, +#endif +} SyscallArgType; + +struct SyscallDef { + const char *name; + SyscallArgsFn *args; + SyscallImplFn *impl; + SyscallPrintFn *print; + SyscallPrintRetFn *print_ret; + SyscallArgType arg_type[6]; +}; + +void print_syscall_def(const SyscallDef *def, int64_t args[6]); +void print_syscall_def_ret(const SyscallDef *def, abi_long ret); +void print_syscall_ptr_ret(const SyscallDef *def, abi_long ret); + +#endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 6f72a74c09..33a5b10c0a 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -10,6 +10,7 @@ #include #include #include "qemu.h" +#include "syscall.h" int do_strace=0; @@ -796,7 +797,7 @@ UNUSED static struct flags unlinkat_flags[] = { FLAG_END, }; -UNUSED static struct flags mode_flags[] = { +static struct flags const mode_flags[] = { FLAG_GENERIC(S_IFSOCK), FLAG_GENERIC(S_IFLNK), FLAG_GENERIC(S_IFREG), @@ -807,14 +808,14 @@ UNUSED static struct flags mode_flags[] = { FLAG_END, }; -UNUSED static struct flags open_access_flags[] = { +static struct flags const open_access_flags[] = { FLAG_TARGET(O_RDONLY), FLAG_TARGET(O_WRONLY), FLAG_TARGET(O_RDWR), FLAG_END, }; -UNUSED static struct flags open_flags[] = { +static struct flags const open_flags[] = { FLAG_TARGET(O_APPEND), FLAG_TARGET(O_CREAT), FLAG_TARGET(O_DIRECTORY), @@ -989,84 +990,86 @@ get_comma(int last) return ((last) ? "" : ","); } +static int add_flags(char *buf, int size, const struct flags *f, + int flags, bool octal) +{ + const char *sep = ""; + int off = 0; + + if (flags == 0 && f->f_value == 0) { + return snprintf(buf, size, "%s", f->f_string); + } + + for (; f->f_string != NULL; f++) { + if (f->f_value != 0 && (flags & f->f_value) == f->f_value) { + off += snprintf(buf + off, size - off, "%s%s", sep, f->f_string); + flags &= ~f->f_value; + sep = "|"; + } + } + + /* Print rest of the flags as numeric. */ + if (flags) { + if (octal) { + off += snprintf(buf + off, size - off, "%s%#o", sep, flags); + } else { + off += snprintf(buf + off, size - off, "%s%#x", sep, flags); + } + } + return off; +} + static void print_flags(const struct flags *f, abi_long flags, int last) { - const char *sep = ""; - int n; + char buf[256]; + add_flags(buf, sizeof(buf), f, flags, false); + gemu_log("%s%s", buf, get_comma(last)); +} - if ((flags == 0) && (f->f_value == 0)) { - gemu_log("%s%s", f->f_string, get_comma(last)); - return; - } - for (n = 0; f->f_string != NULL; f++) { - if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { - gemu_log("%s%s", sep, f->f_string); - flags &= ~f->f_value; - sep = "|"; - n++; - } - } - - if (n > 0) { - /* print rest of the flags as numeric */ - if (flags != 0) { - gemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); - } else { - gemu_log("%s", get_comma(last)); - } +static int add_atdirfd(char *buf, int size, int fd) +{ + if (fd == AT_FDCWD) { + return snprintf(buf, size, "AT_FDCWD"); } else { - /* no string version of flags found, print them in hex then */ - gemu_log("%#x%s", (unsigned int)flags, get_comma(last)); + return snprintf(buf, size, "%d", fd); } } static void print_at_dirfd(abi_long dirfd, int last) { -#ifdef AT_FDCWD - if (dirfd == AT_FDCWD) { - gemu_log("AT_FDCWD%s", get_comma(last)); - return; - } -#endif - gemu_log("%d%s", (int)dirfd, get_comma(last)); + char buf[16]; + add_atdirfd(buf, sizeof(buf), dirfd); + gemu_log("%s%s", buf, get_comma(last)); } static void print_file_mode(abi_long mode, int last) { - const char *sep = ""; - const struct flags *m; + char buf[256]; + add_flags(buf, sizeof(buf), mode_flags, mode, true); + gemu_log("%s%s", buf, get_comma(last)); +} - for (m = &mode_flags[0]; m->f_string != NULL; m++) { - if ((m->f_value & mode) == m->f_value) { - gemu_log("%s%s", m->f_string, sep); - sep = "|"; - mode &= ~m->f_value; - break; - } +static int add_open_flags(char *buf, int size, int flags) +{ + int off = add_flags(buf, size, open_access_flags, + flags & TARGET_O_ACCMODE, false); + flags &= ~TARGET_O_ACCMODE; + if (flags == 0 || off + 2 >= size) { + return off; } - - mode &= ~S_IFMT; - /* print rest of the mode as octal */ - if (mode != 0) - gemu_log("%s%#o", sep, (unsigned int)mode); - - gemu_log("%s", get_comma(last)); + buf[off++] = '|'; + return off + add_flags(buf + off, size - off, open_flags, flags, true); } static void print_open_flags(abi_long flags, int last) { - print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); - flags &= ~TARGET_O_ACCMODE; - if (flags == 0) { - gemu_log("%s", get_comma(last)); - return; - } - gemu_log("|"); - print_flags(open_flags, flags, last); + char buf[256]; + add_open_flags(buf, sizeof(buf), flags); + gemu_log("%s%s", buf, get_comma(last)); } static void @@ -1083,48 +1086,86 @@ print_syscall_epilogue(const struct syscallname *sc) gemu_log(")"); } -static void -print_string(abi_long addr, int last) +static int add_pointer(char *buf, int size, abi_ulong addr) { - char *s; - - if ((s = lock_user_string(addr)) != NULL) { - gemu_log("\"%s\"%s", s, get_comma(last)); - unlock_user(s, addr, 0); + if (addr) { + return snprintf(buf, size, "0x" TARGET_ABI_FMT_lx, addr); } else { - /* can't get string out of it, so print it as pointer */ - print_pointer(addr, last); + return snprintf(buf, size, "NULL"); } } +static int add_string(char *buf, int size, abi_ulong addr) +{ + char *s = lock_user_string(addr); + if (s) { + /* TODO: Escape special characters within the string. */ + /* TODO: Limit the string length for logging. */ + int len = snprintf(buf, size, "\"%s\"", s); + unlock_user(s, addr, 0); + return len; + } + return add_pointer(buf, size, addr); +} + +static void +print_string(abi_long addr, int last) +{ + char buf[256]; + add_string(buf, sizeof(buf), addr); + gemu_log("%s%s", buf, get_comma(last)); +} + #define MAX_PRINT_BUF 40 + +static int add_buffer(char *buf, int size, abi_long addr, abi_ulong len) +{ + unsigned char *p; + int off = 0; + abi_ulong i; + + p = lock_user(VERIFY_READ, addr, MIN(len, MAX_PRINT_BUF), 1); + if (!p) { + return add_pointer(buf, size, addr); + } + + buf[0] = '"'; + off = 1; + + for (i = 0; i < MAX_PRINT_BUF; ++i) { + int len; + + if (isprint(p[i])) { + buf[off] = p[i]; + len = 1; + } else { + len = snprintf(buf + off, size - off, "\\%o", p[i]); + } + off += len; + if (off + 2 >= size) { + goto overflow; + } + } + unlock_user(p, addr, 0); + + if (i == len && off + 2 < size) { + buf[off] = '"'; + buf[off + 1] = 0; + return off + 1; + } + + overflow: + off = MIN(off, size - 5); + strcpy(buf + off, "...\""); + return off + 4; +} + static void print_buf(abi_long addr, abi_long len, int last) { - uint8_t *s; - int i; - - s = lock_user(VERIFY_READ, addr, len, 1); - if (s) { - gemu_log("\""); - for (i = 0; i < MAX_PRINT_BUF && i < len; i++) { - if (isprint(s[i])) { - gemu_log("%c", s[i]); - } else { - gemu_log("\\%o", s[i]); - } - } - gemu_log("\""); - if (i != len) { - gemu_log("..."); - } - if (!last) { - gemu_log(","); - } - unlock_user(s, addr, 0); - } else { - print_pointer(addr, last); - } + char buf[256]; + add_buffer(buf, sizeof(buf), addr, len); + gemu_log("%s%s", buf, get_comma(last)); } /* @@ -1143,10 +1184,9 @@ print_raw_param(const char *fmt, abi_long param, int last) static void print_pointer(abi_long p, int last) { - if (p == 0) - gemu_log("NULL%s", get_comma(last)); - else - gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); + char buf[24]; + add_pointer(buf, sizeof(buf), p); + gemu_log("%s%s", buf, get_comma(last)); } /* @@ -2650,32 +2690,170 @@ print_syscall(int num, gemu_log("Unknown syscall %d\n", num); } +static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) +{ + char buf[1024], *b = buf; + int i, rest = sizeof(buf); + + /* + * Render the argument list into BUF. This allows us to log the + * entire syscall in one write statement at the end. + * While this is still not quite as good as separate files, a-la + * strace -ff, it can minimize confusion with a multithreaded guest. + */ + buf[0] = 0; + for (i = 0; i < 6; ++i) { + SyscallArgType type = def->arg_type[i]; + int64_t arg = args[i]; + int len; + + if (type == ARG_NONE) { + break; + } + + /* Validate remaining space. */ + if (rest < 4) { + goto overflow; + } + + /* Add separator. */ + if (i > 0) { + b[0] = ','; + b[1] = ' '; + b += 2; + rest -= 2; + } + + switch (type) { +#if TARGET_ABI_BITS == 32 + /* + * ??? We don't have TARGET_ABI_FMT_* macros for exactly + * what we want here. For this case it probably makes + * most sense to just special case. + */ + case ARG_DEC: + len = snprintf(b, rest, "%d", (int32_t)arg); + break; + case ARG_HEX: + len = snprintf(b, rest, "%#x", (uint32_t)arg); + break; + case ARG_OCT: + len = snprintf(b, rest, "%#o", (uint32_t)arg); + break; + case ARG_DEC64: + len = snprintf(b, rest, "%" PRId64, arg); + break; +#else + case ARG_DEC: + len = snprintf(b, rest, "%" PRId64, arg); + break; + case ARG_OCT: + len = snprintf(b, rest, "%" PRIo64, arg); + break; + case ARG_HEX: + len = snprintf(b, rest, "%" PRIx64, arg); + break; +#endif + case ARG_ATDIRFD: + len = add_atdirfd(b, rest, arg); + break; + case ARG_MODEFLAG: + len = add_flags(b, rest, mode_flags, arg, true); + break; + case ARG_OPENFLAG: + len = add_open_flags(b, rest, arg); + break; + case ARG_PTR: + len = add_pointer(b, rest, arg); + break; + case ARG_STR: + len = add_string(b, rest, arg); + break; + case ARG_BUF: + len = add_buffer(b, rest, arg, MAX_PRINT_BUF); + break; + default: + g_assert_not_reached(); + } + + b += len; + rest -= len; + if (rest == 0) { + goto overflow; + } + } + goto done; + + overflow: + strcpy(buf + sizeof(buf) - 4, "..."); + done: + gemu_log("%d %s(%s)", getpid(), def->name, buf); +} + +void print_syscall_def(const SyscallDef *def, int64_t args[6]) +{ + SyscallPrintFn *print = def->print; + if (!print) { + print = print_syscall_def1; + } + print(def, args); +} + +static void print_syscall_def_ret1(const SyscallDef *def, abi_long ret) +{ + if (is_error(ret)) { + const char *errstr = target_strerror(-ret); + if (errstr) { + gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", + -ret, errstr); + } else { + gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld "\n", -ret); + } + } else { + gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); + } +} void print_syscall_ret(int num, abi_long ret) { int i; - const char *errstr = NULL; for(i=0;iprint_ret; + if (!print) { + print = print_syscall_def_ret1; + } + print(def, ret); +} + void print_taken_signal(int target_signum, const target_siginfo_t *tinfo) { /* Print the strace output for a signal being taken: diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1feb740f66..e27cab34af 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -108,6 +108,7 @@ #include "qemu.h" #include "fd-trans.h" +#include "syscall.h" #ifndef CLONE_IO #define CLONE_IO 0x80000000 /* Clone io context */ @@ -11631,12 +11632,70 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } +/* Emit the signature for a SyscallArgsFn. */ +#define SYSCALL_ARGS(NAME) \ + static const SyscallDef *args_##NAME(const SyscallDef *def, \ + int64_t out[6], abi_long in[8]) + +/* Emit the signature for a SyscallImplFn. */ +#define SYSCALL_IMPL(NAME) \ + static abi_long impl_##NAME(CPUArchState *cpu_env, int64_t arg1, \ + int64_t arg2, int64_t arg3, int64_t arg4, \ + int64_t arg5, int64_t arg6) + + +#undef SYSCALL_IMPL +#undef SYSCALL_ARGS + +/* + * Emit a complete SyscallDef structure. + */ +#define SYSCALL_DEF_FULL(NAME, ...) \ + static const SyscallDef def_##NAME = { .name = #NAME, __VA_ARGS__ } + +/* + * Emit the definition for a "simple" syscall. Such does not use + * SyscallArgsFn and only uses arg_type for strace. + */ +#define SYSCALL_DEF(NAME, ...) \ + SYSCALL_DEF_FULL(NAME, .impl = impl_##NAME, .arg_type = { __VA_ARGS__ }) + +/* Similarly, but also uses an args hook. */ +#define SYSCALL_DEF_ARGS(NAME, ...) \ + SYSCALL_DEF_FULL(NAME, .impl = impl_##NAME, .args = args_##NAME, \ + .arg_type = { __VA_ARGS__ }) + +#include "syscall-defs.h" + +#undef SYSCALL_DEF +#undef SYSCALL_DEF_ARGS +#undef SYSCALL_DEF_FULL + +static const SyscallDef *syscall_table(int num) +{ +#define SYSCALL_DEF(NAME, ...) case TARGET_NR_##NAME: return &def_##NAME +#define SYSCALL_DEF_ARGS(NAME, ...) SYSCALL_DEF(NAME) +#define SYSCALL_DEF_FULL(NAME, ...) SYSCALL_DEF(NAME) + + switch (num) { +#include "syscall-defs.h" + } + return NULL; + +#undef SYSCALL_DEF +#undef SYSCALL_DEF_ARGS +#undef SYSCALL_DEF_FULL +} + abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { CPUState *cpu = ENV_GET_CPU(cpu_env); + const SyscallDef *def, *orig_def; + abi_long raw_args[8] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }; + int64_t out_args[6] = { arg1, arg2, arg3, arg4, arg5, arg6 }; abi_long ret; #ifdef DEBUG_ERESTARTSYS @@ -11656,16 +11715,44 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - if (unlikely(do_strace)) { - print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, - arg5, arg6, arg7, arg8); - print_syscall_ret(num, ret); - } else { - ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, - arg5, arg6, arg7, arg8); + orig_def = def = syscall_table(num); + if (def == NULL) { + /* Unconverted. */ + if (unlikely(do_strace)) { + print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); + ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + print_syscall_ret(num, ret); + } else { + ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + } + goto fini; } + if (def->args) { + def = def->args(def, out_args, raw_args); + if (unlikely(def == NULL)) { + ret = -host_to_target_errno(errno); + if (unlikely(do_strace)) { + print_syscall_def(orig_def, out_args); + print_syscall_def_ret(orig_def, ret); + } + goto fini; + } + } + + if (unlikely(do_strace)) { + print_syscall_def(def, out_args); + ret = def->impl(cpu_env, out_args[0], out_args[1], out_args[2], + out_args[3], out_args[4], out_args[5]); + print_syscall_def_ret(def, ret); + } else { + ret = def->impl(cpu_env, out_args[0], out_args[1], out_args[2], + out_args[3], out_args[4], out_args[5]); + } + + fini: trace_guest_user_syscall_ret(cpu, num, ret); return ret; } From patchwork Sun May 19 20:36:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164495 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4780189ili; Sun, 19 May 2019 13:41:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGKRvaOVe9wnUN21KI9oq+1uVKU7X8jNnXGEXQpbEze0Ca2gQUJTh8CYOcpJioqxy5Zy/0 X-Received: by 2002:a50:90db:: with SMTP id d27mr71251351eda.50.1558298493541; Sun, 19 May 2019 13:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298493; cv=none; d=google.com; s=arc-20160816; b=merzSpgXMBHNX6qyjLSEqc4DkucXUHBDmQS+8m40brBWR2w0N+vCdDm7be+ffUcwwv Zt+JGSMLZBpOB8Q1R9I4ZMCMvzPzYXYsHx6o/hBVuSbh52cf/0MvhhcEJQSjH4DlA23B jZahs3AIjxwSPk+YGt8wzDVSY2uCk4LOPhD0G0NpeNkFR1Se5Q+wFI4OL+oFuq8msv73 PyQaOnmcxmkmX2qQFdCWcOB6kREBHNCMK7w+Btn+5BTEKSNgPG7VZrf+lnZOII63jVhp xJKpvq9N1B0eVej+ltS/lnfqvtKf6pUAd9xPoxSeYx6FYcDCpzZgvJseLBdx6yIzFIat yzTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bfIW3dDz2FoSPZN1vIes2S+TXhduA0I/DLj9+BFzzwg=; b=ggDslCWBk0oxIxu2zR7hPjK/WV1Z9pywpEFZn/ppYwyKfOh51FlqMxmo9V9EgdcZRr NXDhVYMp5+jk0yHLdi2Lb9o4mhC0twj9yLHKvLNdL/4fEND/28kbLPIRCR0pPOo72axW HXjWae2E2Mcc1YwGxqkiSDKRLozCJTh7wR9myM3eS9VFF+9dY90vRxF0WRhC8wXuhKn/ RZvwQWF2vZG3MhHtt4h4iBrA1m+1ZOhlb6O5OZ7yQtOn0UVrlqRuuLr0zAJp9/S8d8wd INcKWeleH597t4srtZKWsbz6PKg97NUWIyspA4uCmIafpSc3ucPOTcw3QFDK8UldkNTr UcvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xonhWcZl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s45si3573340eda.107.2019.05.19.13.41.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:41:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xonhWcZl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSce-0005pu-AC for patch@linaro.org; Sun, 19 May 2019 16:41:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYp-0002k3-Fc for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYm-0003N1-Tz for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:35 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44232) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYm-0003MF-Kt for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:32 -0400 Received: by mail-pl1-x641.google.com with SMTP id c5so5690384pll.11 for ; Sun, 19 May 2019 13:37:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bfIW3dDz2FoSPZN1vIes2S+TXhduA0I/DLj9+BFzzwg=; b=xonhWcZlyONqzYHuOJbZW56Uv8Jd/wIsn0iyyY/7gXe2anegQGmFmnboRAAsBIJ+7R fVs25sgKqCGC0Cz+KFUsrNfDG7O+btOo1D0SB60JAG3gZd6YJlV+NuytrbosquJBKqib eaOTHKgnMmfuQyaj2TA10QF9vX7Htp9ZMJIEOVShk9V8HlfAX3n+Tfdy7Iix2urFb8X5 MB+lXsFaaEpFA466wInFbo0YuGGkS5fDM3fZ5xp6ITOaxZfvUpLMe9TrLzO7Tj7etvJY u4RJrYZriOOf9QyIcAToMwDMAlw3wsq6JWQUIiAXdXBlrfv60nsuJRlheX1+3ZSdoRMB wxxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bfIW3dDz2FoSPZN1vIes2S+TXhduA0I/DLj9+BFzzwg=; b=sS/2cRIanFf6iOIlq87kQ4jYRY1xyTb8+KwFcaz/FokUtO2/klN9PCExCVYtf0HOHj oFnw3ss5e4Uks5iHBQJ/9uIfEUR7WpSRplYjM7zfqLUk/nLNoe6buVk07scoQygTSlDn vIln+6FKFVHP1aBSNepsF/ytDJf1HaLNxzoGTfPwnYi1jh1kD/1uVLg26qNAzI5ZhhJN SOMG+gdglnh49eF46ctFiqO7+2QqZHT0zqbwS57hzn6KipMFnOOh8krotbgQd4dihNR4 8odz+WKjAY+whuVz2nIGiIQ4IeGu/K+4eCq1H0lYvdRGvqlm87FL2rdJlYLt8d/W3SuK 2Wsg== X-Gm-Message-State: APjAAAUOynJ4Yb0w58jlmadC67rhUHeW8bxux4fF7mzu50PSi29mr9Go lkUqekinNihUBnvyh5WmjVaQLoJoEZM= X-Received: by 2002:a17:902:4e:: with SMTP id 72mr19183869pla.80.1558298250923; Sun, 19 May 2019 13:37:30 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:14 -0700 Message-Id: <20190519203726.20729-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 02/74] linux-user: Split out open, open_at X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For the moment, leave a forward declaration for is_proc_myself until the readlink syscalls are also moved to syscall-file.inc.c. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 5 + linux-user/strace.c | 35 ---- linux-user/syscall-file.inc.c | 325 ++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 288 +----------------------------- linux-user/strace.list | 6 - 5 files changed, 332 insertions(+), 327 deletions(-) create mode 100644 linux-user/syscall-file.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 8c0490425a..1f3a9c47ab 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -15,3 +15,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ + +#ifdef TARGET_NR_open +SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); +#endif +SYSCALL_DEF(openat, ARG_ATDIRFD, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); diff --git a/linux-user/strace.c b/linux-user/strace.c index 33a5b10c0a..24ef14b5e6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -2228,41 +2228,6 @@ print_mq_open(const struct syscallname *name, } #endif -#ifdef TARGET_NR_open -static void -print_open(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - int is_creat = (arg1 & TARGET_O_CREAT); - - print_syscall_prologue(name); - print_string(arg0, 0); - print_open_flags(arg1, (is_creat == 0)); - if (is_creat) - print_file_mode(arg2, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_openat -static void -print_openat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - int is_creat = (arg2 & TARGET_O_CREAT); - - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_open_flags(arg2, (is_creat == 0)); - if (is_creat) - print_file_mode(arg3, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_mq_unlink static void print_mq_unlink(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c new file mode 100644 index 0000000000..7974148ccb --- /dev/null +++ b/linux-user/syscall-file.inc.c @@ -0,0 +1,325 @@ +/* + * Linux file-related syscall implementations + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* + * Helpers for do_openat, manipulating /proc/self/foo. + */ + +static int open_self_cmdline(void *cpu_env, int fd) +{ + CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); + struct linux_binprm *bprm = ((TaskState *)cpu->opaque)->bprm; + int i; + + for (i = 0; i < bprm->argc; i++) { + size_t len = strlen(bprm->argv[i]) + 1; + + if (write(fd, bprm->argv[i], len) != len) { + return -1; + } + } + + return 0; +} + +static int open_self_maps(void *cpu_env, int fd) +{ + CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); + TaskState *ts = cpu->opaque; + FILE *fp; + char *line = NULL; + size_t len = 0; + ssize_t read; + + fp = fopen("/proc/self/maps", "r"); + if (fp == NULL) { + return -1; + } + + while ((read = getline(&line, &len, fp)) != -1) { + int fields, dev_maj, dev_min, inode; + uint64_t min, max, offset; + char flag_r, flag_w, flag_x, flag_p; + char path[512] = ""; + fields = sscanf(line, "%"PRIx64"-%"PRIx64" %c%c%c%c %"PRIx64" %x:%x %d" + " %512s", &min, &max, &flag_r, &flag_w, &flag_x, + &flag_p, &offset, &dev_maj, &dev_min, &inode, path); + + if ((fields < 10) || (fields > 11)) { + continue; + } + if (h2g_valid(min)) { + int flags = page_get_flags(h2g(min)); + max = h2g_valid(max - 1) ? max : (uintptr_t)g2h(GUEST_ADDR_MAX) + 1; + if (page_check_range(h2g(min), max - min, flags) == -1) { + continue; + } + if (h2g(min) == ts->info->stack_limit) { + pstrcpy(path, sizeof(path), " [stack]"); + } + dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr + " %c%c%c%c %08" PRIx64 " %02x:%02x %d %s%s\n", + h2g(min), h2g(max - 1) + 1, flag_r, flag_w, + flag_x, flag_p, offset, dev_maj, dev_min, inode, + path[0] ? " " : "", path); + } + } + + free(line); + fclose(fp); + + return 0; +} + +static int open_self_stat(void *cpu_env, int fd) +{ + CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); + TaskState *ts = cpu->opaque; + abi_ulong start_stack = ts->info->start_stack; + int i; + + for (i = 0; i < 44; i++) { + char buf[128]; + int len; + uint64_t val = 0; + + if (i == 0) { + /* pid */ + val = getpid(); + snprintf(buf, sizeof(buf), "%"PRId64 " ", val); + } else if (i == 1) { + /* app name */ + snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]); + } else if (i == 27) { + /* stack bottom */ + val = start_stack; + snprintf(buf, sizeof(buf), "%"PRId64 " ", val); + } else { + /* for the rest, there is MasterCard */ + snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' '); + } + + len = strlen(buf); + if (write(fd, buf, len) != len) { + return -1; + } + } + + return 0; +} + +static int open_self_auxv(void *cpu_env, int fd) +{ + CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); + TaskState *ts = cpu->opaque; + abi_ulong auxv = ts->info->saved_auxv; + abi_ulong len = ts->info->auxv_len; + char *ptr; + + /* + * Auxiliary vector is stored in target process stack. + * read in whole auxv vector and copy it to file + */ + ptr = lock_user(VERIFY_READ, auxv, len, 0); + if (ptr != NULL) { + while (len > 0) { + ssize_t r; + r = write(fd, ptr, len); + if (r <= 0) { + break; + } + len -= r; + ptr += r; + } + lseek(fd, 0, SEEK_SET); + unlock_user(ptr, auxv, len); + } + + return 0; +} + +static int is_proc_myself(const char *filename, const char *entry) +{ + if (!strncmp(filename, "/proc/", strlen("/proc/"))) { + filename += strlen("/proc/"); + if (!strncmp(filename, "self/", strlen("self/"))) { + filename += strlen("self/"); + } else if (*filename >= '1' && *filename <= '9') { + char myself[80]; + snprintf(myself, sizeof(myself), "%d/", getpid()); + if (!strncmp(filename, myself, strlen(myself))) { + filename += strlen(myself); + } else { + return 0; + } + } else { + return 0; + } + if (!strcmp(filename, entry)) { + return 1; + } + } + return 0; +} + +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) +static int is_proc(const char *filename, const char *entry) +{ + return strcmp(filename, entry) == 0; +} + +static int open_net_route(void *cpu_env, int fd) +{ + FILE *fp; + char *line = NULL; + size_t len = 0; + ssize_t read; + + fp = fopen("/proc/net/route", "r"); + if (fp == NULL) { + return -1; + } + + /* read header */ + + read = getline(&line, &len, fp); + dprintf(fd, "%s", line); + + /* read routes */ + + while ((read = getline(&line, &len, fp)) != -1) { + char iface[16]; + uint32_t dest, gw, mask; + unsigned int flags, refcnt, use, metric, mtu, window, irtt; + int fields; + + fields = sscanf(line, + "%s\t%08x\t%08x\t%04x\t%d\t%d\t%d\t%08x\t%d\t%u\t%u\n", + iface, &dest, &gw, &flags, &refcnt, &use, &metric, + &mask, &mtu, &window, &irtt); + if (fields != 11) { + continue; + } + dprintf(fd, "%s\t%08x\t%08x\t%04x\t%d\t%d\t%d\t%08x\t%d\t%u\t%u\n", + iface, tswap32(dest), tswap32(gw), flags, refcnt, use, + metric, tswap32(mask), mtu, window, irtt); + } + + free(line); + fclose(fp); + + return 0; +} +#endif + +static int do_openat(void *cpu_env, int dirfd, const char *pathname, + int flags, mode_t mode) +{ + struct fake_open { + const char *filename; + int (*fill)(void *cpu_env, int fd); + int (*cmp)(const char *s1, const char *s2); + }; + const struct fake_open *fake_open; + static const struct fake_open fakes[] = { + { "maps", open_self_maps, is_proc_myself }, + { "stat", open_self_stat, is_proc_myself }, + { "auxv", open_self_auxv, is_proc_myself }, + { "cmdline", open_self_cmdline, is_proc_myself }, +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) + { "/proc/net/route", open_net_route, is_proc }, +#endif + { NULL, NULL, NULL } + }; + + if (is_proc_myself(pathname, "exe")) { + int execfd = qemu_getauxval(AT_EXECFD); + return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode); + } + + for (fake_open = fakes; fake_open->filename; fake_open++) { + if (fake_open->cmp(pathname, fake_open->filename)) { + break; + } + } + + if (fake_open->filename) { + const char *tmpdir; + char filename[PATH_MAX]; + int fd, r; + + /* create temporary file to map stat to */ + tmpdir = getenv("TMPDIR"); + if (!tmpdir) { + tmpdir = "/tmp"; + } + snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir); + fd = mkstemp(filename); + if (fd < 0) { + return fd; + } + unlink(filename); + + r = fake_open->fill(cpu_env, fd); + if (r) { + int e = errno; + close(fd); + errno = e; + return r; + } + lseek(fd, 0, SEEK_SET); + + return fd; + } + + return safe_openat(dirfd, path(pathname), flags, mode); +} + +#ifdef TARGET_NR_open +SYSCALL_IMPL(open) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, + target_to_host_bitmask(arg2, fcntl_flags_tbl), + arg3)); + fd_trans_unregister(ret); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +SYSCALL_IMPL(openat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, arg1, p, + target_to_host_bitmask(arg3, fcntl_flags_tbl), + arg4)); + fd_trans_unregister(ret); + unlock_user(p, arg2, 0); + return ret; +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e27cab34af..fe52ac15c2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6633,272 +6633,7 @@ int host_to_target_waitstatus(int status) return status; } -static int open_self_cmdline(void *cpu_env, int fd) -{ - CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); - struct linux_binprm *bprm = ((TaskState *)cpu->opaque)->bprm; - int i; - - for (i = 0; i < bprm->argc; i++) { - size_t len = strlen(bprm->argv[i]) + 1; - - if (write(fd, bprm->argv[i], len) != len) { - return -1; - } - } - - return 0; -} - -static int open_self_maps(void *cpu_env, int fd) -{ - CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); - TaskState *ts = cpu->opaque; - FILE *fp; - char *line = NULL; - size_t len = 0; - ssize_t read; - - fp = fopen("/proc/self/maps", "r"); - if (fp == NULL) { - return -1; - } - - while ((read = getline(&line, &len, fp)) != -1) { - int fields, dev_maj, dev_min, inode; - uint64_t min, max, offset; - char flag_r, flag_w, flag_x, flag_p; - char path[512] = ""; - fields = sscanf(line, "%"PRIx64"-%"PRIx64" %c%c%c%c %"PRIx64" %x:%x %d" - " %512s", &min, &max, &flag_r, &flag_w, &flag_x, - &flag_p, &offset, &dev_maj, &dev_min, &inode, path); - - if ((fields < 10) || (fields > 11)) { - continue; - } - if (h2g_valid(min)) { - int flags = page_get_flags(h2g(min)); - max = h2g_valid(max - 1) ? max : (uintptr_t)g2h(GUEST_ADDR_MAX) + 1; - if (page_check_range(h2g(min), max - min, flags) == -1) { - continue; - } - if (h2g(min) == ts->info->stack_limit) { - pstrcpy(path, sizeof(path), " [stack]"); - } - dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr - " %c%c%c%c %08" PRIx64 " %02x:%02x %d %s%s\n", - h2g(min), h2g(max - 1) + 1, flag_r, flag_w, - flag_x, flag_p, offset, dev_maj, dev_min, inode, - path[0] ? " " : "", path); - } - } - - free(line); - fclose(fp); - - return 0; -} - -static int open_self_stat(void *cpu_env, int fd) -{ - CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); - TaskState *ts = cpu->opaque; - abi_ulong start_stack = ts->info->start_stack; - int i; - - for (i = 0; i < 44; i++) { - char buf[128]; - int len; - uint64_t val = 0; - - if (i == 0) { - /* pid */ - val = getpid(); - snprintf(buf, sizeof(buf), "%"PRId64 " ", val); - } else if (i == 1) { - /* app name */ - snprintf(buf, sizeof(buf), "(%s) ", ts->bprm->argv[0]); - } else if (i == 27) { - /* stack bottom */ - val = start_stack; - snprintf(buf, sizeof(buf), "%"PRId64 " ", val); - } else { - /* for the rest, there is MasterCard */ - snprintf(buf, sizeof(buf), "0%c", i == 43 ? '\n' : ' '); - } - - len = strlen(buf); - if (write(fd, buf, len) != len) { - return -1; - } - } - - return 0; -} - -static int open_self_auxv(void *cpu_env, int fd) -{ - CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); - TaskState *ts = cpu->opaque; - abi_ulong auxv = ts->info->saved_auxv; - abi_ulong len = ts->info->auxv_len; - char *ptr; - - /* - * Auxiliary vector is stored in target process stack. - * read in whole auxv vector and copy it to file - */ - ptr = lock_user(VERIFY_READ, auxv, len, 0); - if (ptr != NULL) { - while (len > 0) { - ssize_t r; - r = write(fd, ptr, len); - if (r <= 0) { - break; - } - len -= r; - ptr += r; - } - lseek(fd, 0, SEEK_SET); - unlock_user(ptr, auxv, len); - } - - return 0; -} - -static int is_proc_myself(const char *filename, const char *entry) -{ - if (!strncmp(filename, "/proc/", strlen("/proc/"))) { - filename += strlen("/proc/"); - if (!strncmp(filename, "self/", strlen("self/"))) { - filename += strlen("self/"); - } else if (*filename >= '1' && *filename <= '9') { - char myself[80]; - snprintf(myself, sizeof(myself), "%d/", getpid()); - if (!strncmp(filename, myself, strlen(myself))) { - filename += strlen(myself); - } else { - return 0; - } - } else { - return 0; - } - if (!strcmp(filename, entry)) { - return 1; - } - } - return 0; -} - -#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) -static int is_proc(const char *filename, const char *entry) -{ - return strcmp(filename, entry) == 0; -} - -static int open_net_route(void *cpu_env, int fd) -{ - FILE *fp; - char *line = NULL; - size_t len = 0; - ssize_t read; - - fp = fopen("/proc/net/route", "r"); - if (fp == NULL) { - return -1; - } - - /* read header */ - - read = getline(&line, &len, fp); - dprintf(fd, "%s", line); - - /* read routes */ - - while ((read = getline(&line, &len, fp)) != -1) { - char iface[16]; - uint32_t dest, gw, mask; - unsigned int flags, refcnt, use, metric, mtu, window, irtt; - int fields; - - fields = sscanf(line, - "%s\t%08x\t%08x\t%04x\t%d\t%d\t%d\t%08x\t%d\t%u\t%u\n", - iface, &dest, &gw, &flags, &refcnt, &use, &metric, - &mask, &mtu, &window, &irtt); - if (fields != 11) { - continue; - } - dprintf(fd, "%s\t%08x\t%08x\t%04x\t%d\t%d\t%d\t%08x\t%d\t%u\t%u\n", - iface, tswap32(dest), tswap32(gw), flags, refcnt, use, - metric, tswap32(mask), mtu, window, irtt); - } - - free(line); - fclose(fp); - - return 0; -} -#endif - -static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, mode_t mode) -{ - struct fake_open { - const char *filename; - int (*fill)(void *cpu_env, int fd); - int (*cmp)(const char *s1, const char *s2); - }; - const struct fake_open *fake_open; - static const struct fake_open fakes[] = { - { "maps", open_self_maps, is_proc_myself }, - { "stat", open_self_stat, is_proc_myself }, - { "auxv", open_self_auxv, is_proc_myself }, - { "cmdline", open_self_cmdline, is_proc_myself }, -#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) - { "/proc/net/route", open_net_route, is_proc }, -#endif - { NULL, NULL, NULL } - }; - - if (is_proc_myself(pathname, "exe")) { - int execfd = qemu_getauxval(AT_EXECFD); - return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode); - } - - for (fake_open = fakes; fake_open->filename; fake_open++) { - if (fake_open->cmp(pathname, fake_open->filename)) { - break; - } - } - - if (fake_open->filename) { - const char *tmpdir; - char filename[PATH_MAX]; - int fd, r; - - /* create temporary file to map stat to */ - tmpdir = getenv("TMPDIR"); - if (!tmpdir) - tmpdir = "/tmp"; - snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir); - fd = mkstemp(filename); - if (fd < 0) { - return fd; - } - unlink(filename); - - if ((r = fake_open->fill(cpu_env, fd))) { - int e = errno; - close(fd); - errno = e; - return r; - } - lseek(fd, 0, SEEK_SET); - - return fd; - } - - return safe_openat(dirfd, path(pathname), flags, mode); -} +static int is_proc_myself(const char *filename, const char *entry); #define TIMER_MAGIC 0x0caf0000 #define TIMER_MAGIC_MASK 0xffff0000 @@ -7083,26 +6818,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); return ret; -#ifdef TARGET_NR_open - case TARGET_NR_open: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - fd_trans_unregister(ret); - unlock_user(p, arg1, 0); - return ret; -#endif - case TARGET_NR_openat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(do_openat(cpu_env, arg1, p, - target_to_host_bitmask(arg3, fcntl_flags_tbl), - arg4)); - fd_trans_unregister(ret); - unlock_user(p, arg2, 0); - return ret; #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_name_to_handle_at: ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); @@ -11643,6 +11358,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int64_t arg2, int64_t arg3, int64_t arg4, \ int64_t arg5, int64_t arg6) +#include "syscall-file.inc.c" #undef SYSCALL_IMPL #undef SYSCALL_ARGS diff --git a/linux-user/strace.list b/linux-user/strace.list index db21ce4177..2c7a595e19 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -677,12 +677,6 @@ #ifdef TARGET_NR_olduname { TARGET_NR_olduname, "olduname" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_open -{ TARGET_NR_open, "open" , NULL, print_open, NULL }, -#endif -#ifdef TARGET_NR_openat -{ TARGET_NR_openat, "openat" , NULL, print_openat, NULL }, -#endif #ifdef TARGET_NR_osf_adjtime { TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164494 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4779996ili; Sun, 19 May 2019 13:41:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2kFgIZ2bVeBSrDfQ41gvtf7GsapEravmfqW9ueFkhBOvXlZVMOxiKLXTVWSsLyWSZ+hkd X-Received: by 2002:a17:906:1e0a:: with SMTP id g10mr47891804ejj.127.1558298473905; Sun, 19 May 2019 13:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298473; cv=none; d=google.com; s=arc-20160816; b=KP5ITktUuHDHZk8rV2Al4qcRxNkOTq4F0mQKPxZAI/K/tIb7nLOyXyIa+8EgWean6B sv/WAAgajIIpGyiR5n9mdpY6YGx0b7LaofXnPugvGKw+D8FRX5Uv2bR2WdyPcaTKwm+F /OsGmbS4C1Hqrc0nlx6TJx31ClLGtX182xK+S2Hsx8O7z9MYN0zzegEhSvHfVOFEPg6o /bLtGlCiyANMYjH+Nb3t74bvYEyjYPXJOBcN5IHLljptqGaeqHv/UrSXbgPx9I1fQIVj ishfK2Zh/jtXwujAuW6RMCXD0KkVkpChEqLYKGWUttT5piQHI46kqHCOZd4q3GwqmNW+ mDJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eSYdriPx4kdDTBySMjSQ3hbHBLevuc9v6XaVM577ESk=; b=JfEh/B5AgvdZzn10Or/g3X/bAvTdoSNHr+wkofxvSRtuoC+D6bpjg9X32soXj/6Ghi KmLBVrGBWL+KL4Ttx70e3L3VL8RelvywFF9Cqpv01H5l/EIz2mBPdwzDULJIbfeDDTF2 sRSScjie9svh7HPixHFGgr4vLa5iyU/iK5GmvftwMKty4q/KaibX118Olp3vxICTsOpz gxkQOi8m1aK21e+tXFCto0DCiAUDZ25T+gewrzoq7bHuuOUnz7mpZdSsbf1+t60BUH9C CQO2b3Slz5KrVO2VB9CLPO5Oc4b7Yq03zjzzrT5fonl5YzdsUQkk35sM48NTf1geT9eI iLOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Sg/4sKNr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l24si2514345edq.115.2019.05.19.13.41.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Sg/4sKNr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSScK-0005Wg-MR for patch@linaro.org; Sun, 19 May 2019 16:41:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYo-0002jK-I1 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYn-0003Nn-Cg for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:34 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:39842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYn-0003Mi-5l for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:33 -0400 Received: by mail-pl1-x641.google.com with SMTP id g9so5708797plm.6 for ; Sun, 19 May 2019 13:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eSYdriPx4kdDTBySMjSQ3hbHBLevuc9v6XaVM577ESk=; b=Sg/4sKNreLI47I2kSXyvKrfz/F9UXr8TRh0XKbe/P//pAE2vgTHjX0USqkAoNdpenR 1AHiGGzNl8e+QgGrMqaEYMUrYdGlXuBYXWGsJ4XY4dz2IBBhEqpD/iOdJYDs/i1AS3NI s0ZRWShf11oA39tEj2NZUPCj96dwvKsz2sD//woQ5rVHMgzvXDJX6dAEtnWLhD+wo9KU oxiT4rBTbQJ1ckGTbgCqH1VSAJ/vaBV44QHHLMJZMA6+UnT5J+EwV4ax2Gv90NLjFnfI 9W9GwBGMCElBsP9R89Ujbsu1MgNks/D4GHqdQZhHmOeo4IrIr+bPeI55Kd/BgI/Mr7dy HfwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eSYdriPx4kdDTBySMjSQ3hbHBLevuc9v6XaVM577ESk=; b=bS5B/KC70G0uN+dWCEmqizNw0DXlLQqfJwkri9/B+mTRu8hLQSEv5XYccOjDNfmx2c TtHKAh597oU/lLuwydPlRlHB5YIqoBGvswOIkyXZYPC1QgsO+AKWnjc1Pbs+NNJqIM/9 kdrsN2lbmZWUd5CJWkaMOZ8dEF7qDyR75PliWUoXxUqnCduXxkUcN7NGxd5swwVect99 97NmWFFFg9HkbVBGiVfiIP/TuKJk/pFxDMgWmJG2s0f7ERIif3kFoYYgtg8E7CyowNz4 4hfxJVWQcvjZ4ph9C6A6Qd6PyP/qF/kKmVeI9hJeGAP5t5cfi4BCNvQIE3hKRbfl764h yFIg== X-Gm-Message-State: APjAAAUiNWv6d/MG80Jwwe25tf7Ha1ZpRy/XldSguT77PuatZZUEBhK4 Z8hIZ4P6MlzrLtAwRHneG1MYJKHqCGI= X-Received: by 2002:a17:902:bd46:: with SMTP id b6mr10556307plx.173.1558298251963; Sun, 19 May 2019 13:37:31 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:15 -0700 Message-Id: <20190519203726.20729-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 03/74] linux-user: Share more code for open and openat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The do_openat helper can have all of the code that is not directly related to the argument ordering of these two syscalls. Signed-off-by: Richard Henderson --- linux-user/syscall-file.inc.c | 69 ++++++++++++++++------------------- 1 file changed, 31 insertions(+), 38 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 7974148ccb..961eed13ae 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -227,8 +227,8 @@ static int open_net_route(void *cpu_env, int fd) } #endif -static int do_openat(void *cpu_env, int dirfd, const char *pathname, - int flags, mode_t mode) +static abi_long do_openat(void *cpu_env, int dirfd, abi_ulong target_path, + int target_flags, mode_t mode) { struct fake_open { const char *filename; @@ -247,9 +247,20 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, { NULL, NULL, NULL } }; + char *pathname = lock_user_string(target_path); + int flags = target_to_host_bitmask(target_flags, fcntl_flags_tbl); + abi_long ret; + + if (!pathname) { + return -TARGET_EFAULT; + } + if (is_proc_myself(pathname, "exe")) { - int execfd = qemu_getauxval(AT_EXECFD); - return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode); + ret = qemu_getauxval(AT_EXECFD); + if (ret == 0) { + ret = get_errno(safe_openat(dirfd, exec_path, flags, mode)); + } + goto done; } for (fake_open = fakes; fake_open->filename; fake_open++) { @@ -261,7 +272,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, if (fake_open->filename) { const char *tmpdir; char filename[PATH_MAX]; - int fd, r; + int fd; /* create temporary file to map stat to */ tmpdir = getenv("TMPDIR"); @@ -271,55 +282,37 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir); fd = mkstemp(filename); if (fd < 0) { - return fd; + ret = -TARGET_ENOENT; + goto done; } unlink(filename); - r = fake_open->fill(cpu_env, fd); - if (r) { - int e = errno; + ret = fake_open->fill(cpu_env, fd); + if (ret) { + ret = get_errno(ret); close(fd); - errno = e; - return r; + goto done; } lseek(fd, 0, SEEK_SET); - - return fd; + ret = fd; + goto done; } - return safe_openat(dirfd, path(pathname), flags, mode); + ret = get_errno(safe_openat(dirfd, path(pathname), flags, mode)); + done: + fd_trans_unregister(ret); + unlock_user(pathname, target_path, 0); + return ret; } #ifdef TARGET_NR_open SYSCALL_IMPL(open) { - char *p = lock_user_string(arg1); - abi_long ret; - - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); - fd_trans_unregister(ret); - unlock_user(p, arg1, 0); - return ret; + return do_openat(cpu_env, AT_FDCWD, arg1, arg2, arg3); } #endif SYSCALL_IMPL(openat) { - char *p = lock_user_string(arg2); - abi_long ret; - - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(do_openat(cpu_env, arg1, p, - target_to_host_bitmask(arg3, fcntl_flags_tbl), - arg4)); - fd_trans_unregister(ret); - unlock_user(p, arg2, 0); - return ret; + return do_openat(cpu_env, arg1, arg2, arg3, arg4); } From patchwork Sun May 19 20:36:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164497 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4781793ili; Sun, 19 May 2019 13:44:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZSPtpxLyIS15fGetUroZg8b1elt8gihjvVpslki24sRK4hxd43AYLbJ8ZlSfXNOf19/2M X-Received: by 2002:a17:906:5e50:: with SMTP id b16mr33333643eju.287.1558298654442; Sun, 19 May 2019 13:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298654; cv=none; d=google.com; s=arc-20160816; b=eaneKyWF2w75BkE3Yyd+mgQTYhspsRe9gFqr4z74sb8IpJWDYk9XuOFUGmGRQOYowQ 8VkJCFBsNaMA2ISkgePeppBDgn+M5sMoeEyj3zr+zGWwpUaVUFvC1ilz1rm9Rrb0mupJ OtrgLtE4HdNkL7YjBysVn4phFcNLeP41N23NL+AWitb7MR+RYPzaLx0L0z5tvMGJMkZ/ /74oC3Hz0H/R4tADRU3B1STEi1qskCXL1t3NlUFoZFHS+du6ZSYlMvL4lyowklevFMy9 Lhaf1rTrtsTkmhfQj0UxgAUkQPtjVxaz7Qj5MgwQhtciy+AALsUauppxSfIaoOVg9AQ2 +xLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=qYhnP8CmUyN8DJK4QlR57fQbe3qhOBTecaegSn//V4c=; b=rHF/hRrsBfBbgftt02RvF7PUZo83Ps1X91qxCGIl3tknLkJJUBXndg8Npb5HVidepz +ZQdL5p38iUlnVEaQ/3EJzPRqEnTOenExyiaDP88TVw41v5nWqgktSNFbaKJHn26wrxJ ruTMTFYsM1EFKisBUkYa4/CHTzFAgkkUdEykpwCiOD9zOLLlP5mKPjlNLzAFoqR8yZY4 +fAQsbau/TeYtvk0htimEbHgYZQJCyVvSL9ImCq3EyjXg8PY6wTPbcMAj+++gBM9ASXO c5TaRSgbJREU7FyGN0GIk/DFgD45b7hdvvE1gGpJ4Win+XvdsmQVqoNUf3EIkpY32PQ5 v8cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pig4dPrh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 43si2963729edz.253.2019.05.19.13.44.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:44:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Pig4dPrh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSfF-00089M-CI for patch@linaro.org; Sun, 19 May 2019 16:44:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYq-0002kh-8y for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYp-0003Py-9e for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:36 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:38309) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYp-0003P3-3o for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:35 -0400 Received: by mail-pf1-x442.google.com with SMTP id b76so6171269pfb.5 for ; Sun, 19 May 2019 13:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qYhnP8CmUyN8DJK4QlR57fQbe3qhOBTecaegSn//V4c=; b=Pig4dPrhh0IQm2puL4y7L1z5VCzEWx8rAXfTzOzVG954/QZK7RpTsJZy4z1bW2BNJS 9v3NoT/3b/QSvihL1POvzSZRt4gq2lg2io6GZq/U2AEs8N8kExJuGYMNvsuBHsrfUOD7 3Fzr5mz/qoklKqDJChWhpBRxx8gp0NwT8J7SpMUTo9scUeFs7t7wLf4v5AV1HbvuWGT7 1K+GKhj63Z20E7QZ54UdZp5dalZt3qFXAKCA+G4O5E/7aFeU2UrXngO1pcqH/hbsU1Ik 5GFfjOim4KUAgj14hfzp6dH799w/9EeGfavRjwLKoq+GMOxj+Dg9JdIlmXwon58A3vML e8gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qYhnP8CmUyN8DJK4QlR57fQbe3qhOBTecaegSn//V4c=; b=m6M2EXQh0/KffIsSKekup6+dXnG/ftK8S2wS+7t1VmFhV0fFTOvKOJLilpmA8Hb/xZ k7jltatGDXTL28yHap8JE9Rb7nptJ2Ewy0WBgxz6pJblUBcynxhEbgNysoD7nqY4NiF/ xMiHJwnXhi1KRJscI87W1EgWlQo4pExHA6pTbr28GftR5wfX8z7O39uW7pfhWginv7tJ bML9RSf4dYZcQ3o0nkMo+xOq3BDErMWHU+Qbm3rpd3pBlFykHFGNzlbiE/bC9B0f2Der hwhcFFhktcgEaOZIRXf0VwWP6VV8SHZBdegxZk16SN5ry67/Ywh8yLzCRrtgNrwuyoib mKKQ== X-Gm-Message-State: APjAAAUi3OEbEAf+BzUYIZIZov/AdYdnh04IK7rZUYZvjlRCaKKSWdJu A4eQUbdIOGcsKXls48QEN4diPATPamw= X-Received: by 2002:a63:374b:: with SMTP id g11mr15571441pgn.421.1558298253819; Sun, 19 May 2019 13:37:33 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:16 -0700 Message-Id: <20190519203726.20729-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v7 04/74] linux-user: Tidy do_openat loop over fakes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cleaner to use ARRAY_SIZE to loop over elements instead of using a sentinel within the data structure. Signed-off-by: Richard Henderson --- linux-user/syscall-file.inc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 961eed13ae..30f8e35cdd 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -235,7 +235,6 @@ static abi_long do_openat(void *cpu_env, int dirfd, abi_ulong target_path, int (*fill)(void *cpu_env, int fd); int (*cmp)(const char *s1, const char *s2); }; - const struct fake_open *fake_open; static const struct fake_open fakes[] = { { "maps", open_self_maps, is_proc_myself }, { "stat", open_self_stat, is_proc_myself }, @@ -244,12 +243,12 @@ static abi_long do_openat(void *cpu_env, int dirfd, abi_ulong target_path, #if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) { "/proc/net/route", open_net_route, is_proc }, #endif - { NULL, NULL, NULL } }; char *pathname = lock_user_string(target_path); int flags = target_to_host_bitmask(target_flags, fcntl_flags_tbl); abi_long ret; + size_t i; if (!pathname) { return -TARGET_EFAULT; @@ -263,17 +262,16 @@ static abi_long do_openat(void *cpu_env, int dirfd, abi_ulong target_path, goto done; } - for (fake_open = fakes; fake_open->filename; fake_open++) { - if (fake_open->cmp(pathname, fake_open->filename)) { - break; - } - } - - if (fake_open->filename) { + for (i = 0; i < ARRAY_SIZE(fakes); ++i) { + const struct fake_open *fake_open = &fakes[i]; const char *tmpdir; char filename[PATH_MAX]; int fd; + if (!fake_open->cmp(pathname, fake_open->filename)) { + continue; + } + /* create temporary file to map stat to */ tmpdir = getenv("TMPDIR"); if (!tmpdir) { From patchwork Sun May 19 20:36:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164499 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4783477ili; Sun, 19 May 2019 13:46:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2/itkJlVn+Tw4Fkle1yD/vD5rZRZEWnauXMEEwTBg9tgPmUb73wYVqyd7hsbKlws/0Zk4 X-Received: by 2002:a50:9252:: with SMTP id j18mr17428020eda.299.1558298818382; Sun, 19 May 2019 13:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298818; cv=none; d=google.com; s=arc-20160816; b=SG42dZRMeb13mkd1LBQwLPVnG4ygMB1uKvcvHAYorFQzfw2FRLJTw83gpKouzKoeHY TyyrZOQdoBCuodBuVnPtN/Hxu4OXRoEguERKFDjGknAEkLrMAt5OHwMekywom1nB5/Ju tf2jAh+gKIAFnV3QQOQ4suqU2/RnNaOOF9Vz6G3Yugf8XvAzq1mr4RUIQUHdSvGcithD Weeim0KxGfzP6/+vHboFFprN4HKQBNrUOscC7YGSha9+PUdVwcJmxrfj2sAl+7KBe9Cw p+XFCPnvjbjJbFqBgMj2+8CcBoftv/+I82JH1pAQGiWW1WyNeUf1GfjPHIbMDHVYuCpE mqLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=T/gNF/+WQ4Pn+UuyOMg1wvHnA4fUii7t4Tux8xUmkoc=; b=KfTit44jwCYwYvoXAHNEiQVhTNQKW+EdcFdzAm6gD8vg5DcoNE8XZqYGy+iHM/cCVU Rqyn7F97ojvMz7+gHUbU9QqJGTWL0nnQnwMhzJt2vjp91c4303EjFpu6ZkXEKZTE2ZeN wTYUqKDPkO2CuzwsVfzQzME+7ahvXRor75syDDOvLzluGHZpKgMOw5Re6fuhzmcvACod BVR2vhf3mu7KsrPI80W0B9pLb8pmfylJo0VdCJpt63boKQp7o1hl/p/WodzYwfg8W97Q IrE5nf2Ena2bIHfCdCv6WO3r/hOycBcrwG2+/nRKa8tMjkEYt0hogIHeyzl+zfc401L2 1KEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Dt6Oh+GY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w17si4497104edl.369.2019.05.19.13.46.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:46:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Dt6Oh+GY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSht-0002f3-6S for patch@linaro.org; Sun, 19 May 2019 16:46:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYs-0002m9-74 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYq-0003Rl-Qa for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:38 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:36049) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYq-0003Qv-Jr for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:36 -0400 Received: by mail-pg1-x544.google.com with SMTP id a3so5747684pgb.3 for ; Sun, 19 May 2019 13:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=T/gNF/+WQ4Pn+UuyOMg1wvHnA4fUii7t4Tux8xUmkoc=; b=Dt6Oh+GYc5ECBGvXm8k40HNriBNshJGfarJIgu4ZyvWlyiJ7RPVRJRXbceNCNFeHdZ +HXBwmHKQSKyam0OggyMej2UtxVQQEpbzY3AeIhhaoOKO4E6pHgV+Aq8mtJXE8UrCvfi hDiaIpcW7AsenQSdR7tqqEN7Qsx4B2yWK2wMfKNQhk9J5H2/Dovott+pRkDvG0LIE6Tw aTi/a8PkuqOpG4DnnbMTzxJC4ot9S02hjUALTRVErDxBZCG2JV+3zGlIXlJmEbTjHTBK Q1sAILEQ7kqiIRPhk+errWRwwixVqmWL8sRbEIS3mUi0O/nu9kQK7iV8cgZcAmWzHLLY EICg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=T/gNF/+WQ4Pn+UuyOMg1wvHnA4fUii7t4Tux8xUmkoc=; b=qBDKjF0fH6RrsoBwNIC9hcKx4EoFP9kIj9UtZdFu+hD6NiEd3NLfzNA1I49Um3wkKt is3CilLtKU6YhsFnmeCFGXBBwAxwTsV2JvElQOTpjwTxbIi5VFGXJn/Jd1NWYgBHJBcZ Kwbp3vIHffUgbmL6vOXgiFrR1fnLmKY9gSx4ThJetqL0F7hwdmKOBLdzZM99Gr5cYvva SYVeBqDcsTaYdD2veiydQveY+/Wrr221CNb8qfjUnCvyhCZ3LeTfn4gzTKVedHPb5VVt woCdQP7NQ4qPz7Krlz9FiFkUyGm+vBm2HC+tVxnsGwotrR1hvML5kMbvErunCt3y4nIX hrPg== X-Gm-Message-State: APjAAAU/3FzwhjuxQQzt1tYB9lzhpjZKZ+AtL27G54DUeuwQmE0B0GVw 7SMwxOB6DrqFK3e2rh7fGLrY0rBoElc= X-Received: by 2002:a65:5c89:: with SMTP id a9mr71871984pgt.334.1558298255333; Sun, 19 May 2019 13:37:35 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:17 -0700 Message-Id: <20190519203726.20729-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v7 05/74] linux-user: Split out readlink, readlinkat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split out a shared implementation for both of these; unify the best parts of /proc/self/exe checking. Remove the temporary forward declaration for is_proc_self. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++ linux-user/strace.c | 29 ------------------ linux-user/syscall-file.inc.c | 45 ++++++++++++++++++++++++++++ linux-user/syscall.c | 55 ----------------------------------- linux-user/strace.list | 6 ---- 5 files changed, 51 insertions(+), 90 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 1f3a9c47ab..d1a6c6fa3c 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -20,3 +20,9 @@ SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif SYSCALL_DEF(openat, ARG_ATDIRFD, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); +#ifdef TARGET_NR_readlink +SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); +#endif +#ifdef TARGET_NR_readlinkat +SYSCALL_DEF(readlinkat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_DEC); +#endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 24ef14b5e6..2f1c7e537f 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -2256,35 +2256,6 @@ print_fstatat64(const struct syscallname *name, #define print_newfstatat print_fstatat64 #endif -#ifdef TARGET_NR_readlink -static void -print_readlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_pointer(arg1, 0); - print_raw_param("%u", arg2, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_readlinkat -static void -print_readlinkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_pointer(arg2, 0); - print_raw_param("%u", arg3, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_rename static void print_rename(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 30f8e35cdd..4ef0be2c6f 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -314,3 +314,48 @@ SYSCALL_IMPL(openat) { return do_openat(cpu_env, arg1, arg2, arg3, arg4); } + +static abi_long do_readlinkat(int dirfd, abi_ulong target_path, + abi_ulong target_buf, abi_ulong bufsiz) +{ + char *p = lock_user_string(target_path); + void *buf = lock_user(VERIFY_WRITE, target_buf, bufsiz, 0); + abi_long ret; + + if (!p || !buf) { + ret = -TARGET_EFAULT; + } else if (!bufsiz) { + /* Short circuit this for the magic exe check. */ + ret = -TARGET_EINVAL; + } else if (is_proc_myself((const char *)p, "exe")) { + char real[PATH_MAX]; + char *temp = realpath(exec_path, real); + + if (temp == NULL) { + ret = -host_to_target_errno(errno); + } else { + ret = MIN(strlen(real), bufsiz); + /* We cannot NUL terminate the string. */ + memcpy(buf, real, ret); + } + } else { + ret = get_errno(readlinkat(dirfd, path(p), buf, bufsiz)); + } + unlock_user(buf, target_buf, ret); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_readlink +SYSCALL_IMPL(readlink) +{ + return do_readlinkat(AT_FDCWD, arg1, arg2, arg3); +} +#endif + +#ifdef TARGET_NR_readlinkat +SYSCALL_IMPL(readlinkat) +{ + return do_readlinkat(arg1, arg2, arg3, arg4); +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fe52ac15c2..53fb211f16 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6633,8 +6633,6 @@ int host_to_target_waitstatus(int status) return status; } -static int is_proc_myself(const char *filename, const char *entry); - #define TIMER_MAGIC 0x0caf0000 #define TIMER_MAGIC_MASK 0xffff0000 @@ -8108,59 +8106,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif -#ifdef TARGET_NR_readlink - case TARGET_NR_readlink: - { - void *p2; - p = lock_user_string(arg1); - p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!p || !p2) { - ret = -TARGET_EFAULT; - } else if (!arg3) { - /* Short circuit this for the magic exe check. */ - ret = -TARGET_EINVAL; - } else if (is_proc_myself((const char *)p, "exe")) { - char real[PATH_MAX], *temp; - temp = realpath(exec_path, real); - /* Return value is # of bytes that we wrote to the buffer. */ - if (temp == NULL) { - ret = get_errno(-1); - } else { - /* Don't worry about sign mismatch as earlier mapping - * logic would have thrown a bad address error. */ - ret = MIN(strlen(real), arg3); - /* We cannot NUL terminate the string. */ - memcpy(p2, real, ret); - } - } else { - ret = get_errno(readlink(path(p), p2, arg3)); - } - unlock_user(p2, arg2, ret); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_readlinkat) - case TARGET_NR_readlinkat: - { - void *p2; - p = lock_user_string(arg2); - p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0); - if (!p || !p2) { - ret = -TARGET_EFAULT; - } else if (is_proc_myself((const char *)p, "exe")) { - char real[PATH_MAX], *temp; - temp = realpath(exec_path, real); - ret = temp == NULL ? get_errno(-1) : strlen(real) ; - snprintf((char *)p2, arg4, "%s", real); - } else { - ret = get_errno(readlinkat(arg1, path(p), p2, arg4)); - } - unlock_user(p2, arg3, ret); - unlock_user(p, arg2, 0); - } - return ret; -#endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 2c7a595e19..53cee3db92 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1079,12 +1079,6 @@ #ifdef TARGET_NR_readdir { TARGET_NR_readdir, "readdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_readlink -{ TARGET_NR_readlink, "readlink" , NULL, print_readlink, NULL }, -#endif -#ifdef TARGET_NR_readlinkat -{ TARGET_NR_readlinkat, "readlinkat" , NULL, print_readlinkat, NULL }, -#endif #ifdef TARGET_NR_readv { TARGET_NR_readv, "readv" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164492 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4779825ili; Sun, 19 May 2019 13:40:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk+XbddFVeOdrfVTXomUvwNBo1vzOqnn3hOBtpYq9kj+vr/cxlQVyTYYvkNg3GyUKo0X77 X-Received: by 2002:a50:929a:: with SMTP id k26mr29618957eda.52.1558298458396; Sun, 19 May 2019 13:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298458; cv=none; d=google.com; s=arc-20160816; b=PHq+gvNmLUpfRf0ekK5U5GtqWQCYmB8ZrELV2HMkfNgNVXqOn0uO0PzSNb7sJaggPm l+bczRoiXukqPwVFW/3W0ybB/ZwCNI+uKIkeMx3pfyUKdIoG6e0eVoSWtGE1mkNWJdR0 sP2vKgwpQfzB+EadUeawx4o8OvGhnrJJM+QsSHvPyNg1U9NEvhQiG4aIjU1UrKcO5eB7 Qz+xgVMldl5jPLteJ9hv4TXgTBA/UFpOjvg3Ljw0V9TxKupYX3ZGMphlYE93+5vJhGEk vWx4dX8NDPqfHFud0GPF9nGbaDB2Vasbyssgsbnyu/SRKPPbxRNwW0ODloyYlsBEk/Wy vsdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=WUYfVdZEVtBk9MHhOPPZhUCKLb9+xv1voeQk5PhUfpc=; b=wnhaDGhuL29xDNj6OSFBcRPvCD0p0raQBNze52bdHvWvfYqLMfzXTgkF0gGCHwwZXb TCwEy9bIMPU6EjnLOOJG+x0sqZ2D3ZZgBeecyZ6UFcqAYwBGm4ps3RoloLyIeYkzJPIz dmjQL2JRjO/wa4zyoDkbdxYQSiu9JEUQg1lK9rhBgQYYDFCXJaRwLLBvx3NslPglUpFo D/+ir3rtpoKcQ6APTyO3tQi3QWllAai8oaqYKY7gH9iYEZUVRlW3//pOmpKO0f4ydXdu ug7C6+eL0bfY4hVqe1ZeGSlptFMl3fxPPQdBRMpGr/LUMmF65jOt3EA4NZRNL81pvlbM 2PiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=njAw4p97; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id qh3si1408711ejb.193.2019.05.19.13.40.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:40:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=njAw4p97; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSc5-0005dN-9z for patch@linaro.org; Sun, 19 May 2019 16:40:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYs-0002mB-T6 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYr-0003Sw-RR for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:38 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:45406) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYr-0003SL-Lt for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:37 -0400 Received: by mail-pf1-x441.google.com with SMTP id s11so6148107pfm.12 for ; Sun, 19 May 2019 13:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WUYfVdZEVtBk9MHhOPPZhUCKLb9+xv1voeQk5PhUfpc=; b=njAw4p9772b+h3oN2yLFzA7FLillXnb1Lf8lnMJU7VLCfwlmHjFfRH6wFrzE35r7Of Eoc20tumRaLO5akv+ql0lZ4wfyFgYP1E8Uk78KAd27eOQBN4+4pUHNi7m7BW8Nxr6yh/ VXu/svjD30BIoMBlbxEAAP+RM12LYDxTnXif+91CRueKAQEduLGggAm4xsTpzeqY2XeV kwH2hvrXXXr+erMPWjc9X/V4QwnB8owZ87llebOz3vxIGRJ9qydnaAR4VisuyC+lQEKH /Lw6hJAhuHJ6U2O9hkI+VqlBirXbyGEndi0jUiYRg1dhn1VpoimyrB50XrZfdZPKojZm MhIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WUYfVdZEVtBk9MHhOPPZhUCKLb9+xv1voeQk5PhUfpc=; b=uL7Xiwj+O/Zh9bmkfDdMduDrtGWdPMQCGPGn3CsKwGJF+qHsZGDib9eRiOaC1bpj0k XVf1NYSMWL7E+UUxexgNDUq7bB3KDGQLXAzMkFf9t69CKQ4uOTOjAznO+DIecj6lRDPu wBAg67b4HPq9RPl4ZkHZsXxag2zANQsMHqSAeMhKKskNCOU9H4IeBjiVytUlGHwNZ++R WyZZK65tkg9ysvv58P0PXqs5CnfLEyMJspzqBhqWKLLW4TPWxtoCQsmQeGcvgqjSRlnz ClyNfovA3b3Qm03mQlNiG7fvbTq/9LiEG73frIeDDVBFtHNV89nM50IaNsxREvLwsh+i 6rbQ== X-Gm-Message-State: APjAAAV1lT1jzBzUV5pdriC0SIYpw8IPBJNM70FH/xIcjMq5EwEAzgg+ ZNpgGjRNxSU8QI6l7nf4ivpJpCkYPwI= X-Received: by 2002:a63:1316:: with SMTP id i22mr71592462pgl.274.1558298256356; Sun, 19 May 2019 13:37:36 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:18 -0700 Message-Id: <20190519203726.20729-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 06/74] linux-user: Split out close X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-file.inc.c | 8 ++++++++ linux-user/syscall.c | 4 ---- linux-user/strace.list | 3 --- 4 files changed, 9 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index d1a6c6fa3c..797426ae6f 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -16,6 +16,7 @@ * along with this program; if not, see . */ +SYSCALL_DEF(close, ARG_DEC); #ifdef TARGET_NR_open SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 4ef0be2c6f..d9b09c2cd2 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -16,6 +16,14 @@ * along with this program; if not, see . */ +SYSCALL_IMPL(close) +{ + int fd = arg1; + + fd_trans_unregister(fd); + return get_errno(close(fd)); +} + /* * Helpers for do_openat, manipulating /proc/self/foo. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 53fb211f16..d2b1bb76c4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6827,10 +6827,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, fd_trans_unregister(ret); return ret; #endif - case TARGET_NR_close: - fd_trans_unregister(arg1); - return get_errno(close(arg1)); - case TARGET_NR_brk: return do_brk(arg1); #ifdef TARGET_NR_fork diff --git a/linux-user/strace.list b/linux-user/strace.list index 53cee3db92..43d3088669 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -97,9 +97,6 @@ #ifdef TARGET_NR_clone { TARGET_NR_clone, "clone" , NULL, print_clone, NULL }, #endif -#ifdef TARGET_NR_close -{ TARGET_NR_close, "close" , "%s(%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_connect { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL }, #endif From patchwork Sun May 19 20:36:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164501 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4784027ili; Sun, 19 May 2019 13:47:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYB9kX9kA6A0VN7NQgFoAbIK4sctmYAyU/TxZeVcTqIDrFAztoD4bDftS+SEPYVkg7ICdJ X-Received: by 2002:a50:a5ed:: with SMTP id b42mr69913519edc.178.1558298865727; Sun, 19 May 2019 13:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298865; cv=none; d=google.com; s=arc-20160816; b=Uv025Ew+GRxOUejnYYIR1CDw9BQ88Negda1t9eNwaQ28o48RO7liAcr2VNh1FAaFwX 65pk9LKb0ncLAycczMRRdBLuxOfHQyoa3fgRRPtHYIREj9koKi9OOBT8RQ7uCDV1tcOU fm08tLKWI0q7QlIQvA3I2dOJHL1e/+Tbe01QfdejYDpVFZkbIeFsRtpIqhfxSK+AHgqf kvyGalFX6WC7iVb0BlGO2cNAiroW5Oy9kYqFPJnKEfMz0b5akEQFPd4FFkP0Ti4mY4mB 9VNso04c45qY8QR8RJMWh/5FLkVLcyytlCGtcTxaPee4464PuEngJDg5P0WksU5bW2Qn 895Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=v+DSPWFfKETKW6djLG4dV30pA06tpKN/mDvUPl9xg1M=; b=wvyHMtZPOBTM+k4WEAFctiTvXL3aDfUUKNEfjYrS3jGfOIYPKLPMzG6vd9pjt2TSpF wz7q88jw5yt7hNmA9zYckj/Dp5PztPUV+VVRc4z5MnfUEoR9YvXM4EtVdy5PO5Hlqop5 qShBCR1McOkp32BQyaC4hiw41cnwEHLL8XSzV/DG2ArsNrwmP8xY6Pv/AWv+hkLHooWo o/nbTOS2bBZZEFTsNjMzUapHluxPGFRDMB3/kmawQIxEil+fLjI446tqp834Wkmi0RnA tF/BqQagh9KKShSui6JdDSPEnA/UZTh5bRpav5EDYMewrrqUlHcWsnwiVDY1DbZe5Kcm 8YzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kul8EKJ+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z40si243913edc.400.2019.05.19.13.47.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:47:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kul8EKJ+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSie-0003IH-KG for patch@linaro.org; Sun, 19 May 2019 16:47:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYw-0002nl-Ci for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYv-0003Wm-4f for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:42 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:32972) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYu-0003Vo-Ug for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:41 -0400 Received: by mail-pg1-x544.google.com with SMTP id h17so5751680pgv.0 for ; Sun, 19 May 2019 13:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v+DSPWFfKETKW6djLG4dV30pA06tpKN/mDvUPl9xg1M=; b=kul8EKJ+Q4XjOZ96gaPQl3ei1QXKW4h4xkEUQ6XK080ElloUc1iEFs6lO9vKbFR9XY 7yItQEu89XB+RVe1GfGBGgx8UCwOw02bedJvIQWxH5IgnRZYvAtsHdVdQ72LooB5RrBc hh4wqx6aRaaoEQtdJCY+ikK8aMH5LKP1PQT764rE9KUxkk+wpvSH4xFwHJhbu67LKWLg 9Q3APNNKUkiDWwaW65EAa+QJ2sHwD/LK4UQM+yZwYBdQwTLZ8Hnx+sHu0YxXID+X6OQH F+i5qwjcdFRP6k+iuxxvvRgKUqWDUtbWSZEew2Zkk/rG2WpvE3jgcLSrqhGTgmHcQclh ORBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v+DSPWFfKETKW6djLG4dV30pA06tpKN/mDvUPl9xg1M=; b=lDEuC6ATvINchhGeLD35ckGs9uuZ4F1GQYQ5D/RTIe0mS1Fr79kXalqn8ujlh4rpps SlV/DsQ92iqMNskQoxeXGOfcW56HYbdEicnzViPOls3+uQkobveNWmUmu8fu6gOId0vA GZotglboVrWPWCswmOQ3IWIyPYzNnAhgdB7f2k6ovmOrxn12OmvQOTTJyGu+mTipVV1N u79UNwndAReKCnZLPhvT1beWic389wXxVGO0Mp87IENXxykkQ/41wFKI7JnB2syQgPQL 9fD3zIidm0nEhNC5cKzL2XXCIdfdPtk/q02M+iffRyjHDJv071kI5TiLzLSjhrD2muwh vPIQ== X-Gm-Message-State: APjAAAWNBb9ya+pw8T4zCcqBQWU6Iyc7FNhRSxrccB/hfSEVP8Fp8NBM ga5fnCWaYANDRUZ2hDpeib6jUVuk1UQ= X-Received: by 2002:a65:64da:: with SMTP id t26mr71680641pgv.322.1558298259460; Sun, 19 May 2019 13:37:39 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:19 -0700 Message-Id: <20190519203726.20729-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v7 07/74] linux-user: Split out read, write X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-file.inc.c | 58 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 34 -------------------- linux-user/strace.list | 6 ---- 4 files changed, 60 insertions(+), 40 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 797426ae6f..b031de1375 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -21,9 +21,11 @@ SYSCALL_DEF(close, ARG_DEC); SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif SYSCALL_DEF(openat, ARG_ATDIRFD, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); +SYSCALL_DEF(read, ARG_DEC, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlink SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); #endif #ifdef TARGET_NR_readlinkat SYSCALL_DEF(readlinkat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_DEC); #endif +SYSCALL_DEF(write, ARG_DEC, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index d9b09c2cd2..e6adcc351c 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -323,6 +323,32 @@ SYSCALL_IMPL(openat) return do_openat(cpu_env, arg1, arg2, arg3, arg4); } +SYSCALL_IMPL(read) +{ + int fd = arg1; + abi_ulong target_p = arg2; + abi_ulong size = arg3; + void *p; + abi_long ret; + + if (target_p == 0 && size == 0) { + return get_errno(safe_read(fd, NULL, 0)); + } + p = lock_user(VERIFY_WRITE, target_p, size, 0); + if (p == NULL) { + return -TARGET_EFAULT; + } + ret = get_errno(safe_read(fd, p, size)); + if (!is_error(ret)) { + TargetFdDataFunc trans = fd_trans_host_to_target_data(fd); + if (trans) { + ret = trans(p, ret); + } + } + unlock_user(p, target_p, ret); + return ret; +} + static abi_long do_readlinkat(int dirfd, abi_ulong target_path, abi_ulong target_buf, abi_ulong bufsiz) { @@ -367,3 +393,35 @@ SYSCALL_IMPL(readlinkat) return do_readlinkat(arg1, arg2, arg3, arg4); } #endif + +SYSCALL_IMPL(write) +{ + int fd = arg1; + abi_ulong target_p = arg2; + abi_ulong size = arg3; + TargetFdDataFunc trans; + abi_long ret; + void *p; + + if (target_p == 0 && size == 0) { + return get_errno(safe_write(fd, NULL, 0)); + } + p = lock_user(VERIFY_READ, target_p, size, 1); + if (p == NULL) { + return -TARGET_EFAULT; + } + trans = fd_trans_target_to_host_data(fd); + if (trans) { + void *copy = g_malloc(size); + memcpy(copy, p, size); + ret = trans(copy, size); + if (ret >= 0) { + ret = get_errno(safe_write(fd, copy, ret)); + } + g_free(copy); + } else { + ret = get_errno(safe_write(fd, p, size)); + } + unlock_user(p, target_p, 0); + return ret; +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d2b1bb76c4..de80ddb330 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6782,40 +6782,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, preexit_cleanup(cpu_env, arg1); _exit(arg1); return 0; /* avoid warning */ - case TARGET_NR_read: - if (arg2 == 0 && arg3 == 0) { - return get_errno(safe_read(arg1, 0, 0)); - } else { - if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) - return -TARGET_EFAULT; - ret = get_errno(safe_read(arg1, p, arg3)); - if (ret >= 0 && - fd_trans_host_to_target_data(arg1)) { - ret = fd_trans_host_to_target_data(arg1)(p, ret); - } - unlock_user(p, arg2, ret); - } - return ret; - case TARGET_NR_write: - if (arg2 == 0 && arg3 == 0) { - return get_errno(safe_write(arg1, 0, 0)); - } - if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - return -TARGET_EFAULT; - if (fd_trans_target_to_host_data(arg1)) { - void *copy = g_malloc(arg3); - memcpy(copy, p, arg3); - ret = fd_trans_target_to_host_data(arg1)(copy, arg3); - if (ret >= 0) { - ret = get_errno(safe_write(arg1, copy, ret)); - } - g_free(copy); - } else { - ret = get_errno(safe_write(arg1, p, arg3)); - } - unlock_user(p, arg2, 0); - return ret; - #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_name_to_handle_at: ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); diff --git a/linux-user/strace.list b/linux-user/strace.list index 43d3088669..2d6bfec692 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1067,9 +1067,6 @@ #ifdef TARGET_NR_quotactl { TARGET_NR_quotactl, "quotactl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_read -{ TARGET_NR_read, "read" , "%s(%d,%#x,%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_readahead { TARGET_NR_readahead, "readahead" , NULL, NULL, NULL }, #endif @@ -1611,9 +1608,6 @@ #ifdef TARGET_NR_waitpid { TARGET_NR_waitpid, "waitpid" , "%s(%d,%p,%#x)", NULL, NULL }, #endif -#ifdef TARGET_NR_write -{ TARGET_NR_write, "write" , "%s(%d,%#x,%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_writev { TARGET_NR_writev, "writev" , "%s(%d,%p,%#x)", NULL, NULL }, #endif From patchwork Sun May 19 20:36:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164500 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4783843ili; Sun, 19 May 2019 13:47:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3R59EeMiQvuKW7EKVsYG3gZp48z+lrzfQCW7j0NHtBq2JzNgHqMeGdyB+3q+gUOcmd3rI X-Received: by 2002:a50:fa90:: with SMTP id w16mr71265979edr.184.1558298849080; Sun, 19 May 2019 13:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298849; cv=none; d=google.com; s=arc-20160816; b=WeMJjHpVsivstT1lfCI8vDbzun5yUt9IJYpCaevwVn9yZ61HqLG10Lwmg5LvinsoMK tsiPShRWQb8MBL+Q+d50R+4b7yow/soPXeWY3USzsDmjPoflgNGrzzMf3qPIqHrGVz7D JtqjbZbn34p8ipMJaSQL5u7GjKNT4BEaKvpOy9fSvAYdDu64Feeapeyr377GQMCoG0/V kFRVcZ1h55KE2M2rUmKHWEVURkFt1HrqRZ+YAGkdfZICDFVJryGIoKxUU6Rfh+z+UG/u HckHrnXl+oaQVideNMor/7HhqAz04kZh88m57U4eX+qY1S9awmbDjCKR6j+0pV4nN7tf Qxkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=v4TN8eiQB7XlopQZigkJd3iS16AoI2I7VjbeWaf5rzc=; b=OvdLO/CgVHFJMPS0sE68zMbCAltjbt3s9XIEvjSo+vgfIHBZunEQjcWAHtcgDF0GfY ZGGkUqC1SZa0uiHMNUeyJQQzxk7dFkdSxcPn5enAB1+bHUEpGGgw1RMpU6TlrxOPZVxV RBKIP3qBD9Wbdt4qGsucdOdD04XmiSdyXVhl0Ik646VPHZRzmBKQY/aTsCQvOkgu9A16 LTRgcMsSj9EJnikESIlIEb936dvDIDjsNPpr0wGsvk+oUE7DNh78hqteiaGVi5E2LgV5 8IjPMBy7ad4+PdeUv1HhJ7/JjT6EESrpCxxOthLli9vYYuhQhezaNU8xEmObfuTDjh0Y WIsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ltrAgxdo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 24si11225836edu.191.2019.05.19.13.47.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:47:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ltrAgxdo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSiN-0002jj-WA for patch@linaro.org; Sun, 19 May 2019 16:47:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYx-0002on-ER for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYw-0003YA-Dd for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:43 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:39712) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYw-0003XN-6n for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:42 -0400 Received: by mail-pf1-x441.google.com with SMTP id z26so6167151pfg.6 for ; Sun, 19 May 2019 13:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v4TN8eiQB7XlopQZigkJd3iS16AoI2I7VjbeWaf5rzc=; b=ltrAgxdo+sqOTVlbfP4OEyTUTut08QxXb1zpk7dgtyQ93CnBcsxetW6RNelYHnjmcf SdN+rLfpAfSsh9iKcesaPWHVnFyvxO5h1MJEhu9UA2VVWPmbjTaGHQFfeu1NbTM6olhb W5FrxkclUwiCdfil0SsaT70j0efcaUBdqc9oAmGIAjyw5RYLqrbHkdMkwdCqyKv8sslk jChGwj6YqZGtHpq40sQl9Km8jcoio6Y60j+zuYNdH/gArg+tJ3NgW9uR+SSXGqoym0oR t8/sOe/3RL31Q9C15ZvMmqAOHr3/1dbeUAnlkPsrC0JJgKNTDSNFwuzNBlYo98DK7WYV dVIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v4TN8eiQB7XlopQZigkJd3iS16AoI2I7VjbeWaf5rzc=; b=qI8zPMNhYcYvwmDmdYa1Kw8/ziW8T2EBI9uzX2YK7b3QYT/PnHIYnFts05QaxIMfrD bSpYbWmlOEr8AGZlpvxmHz/ZPYCLc+/1BJ/kFLm+Yj2D3QALSenAAOV8YXHZ0JY3uoIf d6YruK96fpkPBblXaqG9RQ3ji7KFdCx+yrGjek9sfmmT5oAeTbfikoJhKS6ulMjcZnfP cCv7bhwl3bv9bwHrnfq9AJT3WTtzdKAGSCxQ8WmLqrzZyGMy80j/hdMqtg72HcV1bvOx BCmP8hS5zz+p3nBpu93HSJZvRLTp3TmPc/0tpTFso3L6eMcxggYxoLGTXrgo4ydkYaWH G4oQ== X-Gm-Message-State: APjAAAXWb7zekd+zkBft1mIS1JHi7OTXV5k7HJsaZM5tHjlhF85BqZFF qmRaCLG1xbjCLOtt0YANDxQNueWVJTU= X-Received: by 2002:a62:d044:: with SMTP id p65mr55690797pfg.37.1558298260905; Sun, 19 May 2019 13:37:40 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:20 -0700 Message-Id: <20190519203726.20729-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 08/74] linux-user: Reduce regpairs_aligned & target_offset64 ifdefs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 54 ++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 29 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index de80ddb330..61cd73db26 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -464,37 +464,38 @@ static inline int next_free_host_timer(void) } #endif -/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ +/* + * Returns true if syscall NUM expects 64bit types aligned even + * on pairs of registers. + */ +static inline bool regpairs_aligned(void *cpu_env, int num) +{ #ifdef TARGET_ARM -static inline int regpairs_aligned(void *cpu_env, int num) -{ - return ((((CPUARMState *)cpu_env)->eabi) == 1) ; -} -#elif defined(TARGET_MIPS) && (TARGET_ABI_BITS == 32) -static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } + return ((CPUARMState *)cpu_env)->eabi; +#elif defined(TARGET_MIPS) && TARGET_ABI_BITS == 32 + return true; #elif defined(TARGET_PPC) && !defined(TARGET_PPC64) -/* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs - * of registers which translates to the same as ARM/MIPS, because we start with - * r3 as arg1 */ -static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } + /* + * SysV AVI for PPC32 expects 64bit parameters to be passed on + * odd/even pairs of registers which translates to the same as + * we start with r3 as arg1. + */ + return true; #elif defined(TARGET_SH4) -/* SH4 doesn't align register pairs, except for p{read,write}64 */ -static inline int regpairs_aligned(void *cpu_env, int num) -{ + /* SH4 doesn't align register pairs, except for p{read,write}64. */ switch (num) { case TARGET_NR_pread64: case TARGET_NR_pwrite64: - return 1; - + return true; default: - return 0; + return false; } -} #elif defined(TARGET_XTENSA) -static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } + return true; #else -static inline int regpairs_aligned(void *cpu_env, int num) { return 0; } + return false; #endif +} #define ERRNO_TABLE_SIZE 1200 @@ -6161,21 +6162,16 @@ void syscall_init(void) } } -#if TARGET_ABI_BITS == 32 -static inline uint64_t target_offset64(uint32_t word0, uint32_t word1) +static inline uint64_t target_offset64(abi_ulong word0, abi_ulong word1) { -#ifdef TARGET_WORDS_BIGENDIAN +#if TARGET_ABI_BITS == 64 + return word0; +#elif defined(TARGET_WORDS_BIGENDIAN) return ((uint64_t)word0 << 32) | word1; #else return ((uint64_t)word1 << 32) | word0; #endif } -#else /* TARGET_ABI_BITS == 32 */ -static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) -{ - return word0; -} -#endif /* TARGET_ABI_BITS != 32 */ #ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, From patchwork Sun May 19 20:36:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164508 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4787641ili; Sun, 19 May 2019 13:53:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxM2wot4T0ugbppC9iuYiPgBZz1lyHvhEk2TaAGTYdHOF9OZHiPwBKf6fu0/TheRznQc+3b X-Received: by 2002:a17:906:e9d3:: with SMTP id kb19mr13577462ejb.248.1558299198663; Sun, 19 May 2019 13:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299198; cv=none; d=google.com; s=arc-20160816; b=qLcvowU1HhsfIXRyBt4AuZBoHCXqasjQ01x3XzN5dHyrj24MbELbiHqEUHwNFCUa2n MatyIhSnzl6iEB+Bl5sb5Nf4l8GcviNUTn+3fKfGU77pmmkYIhg21mC/oepmGAzRCFSS TV9qJ9C7sjo9rbYRFa6ZqWhXomP5DHefLYoD5AKmyxynJRpAdLxwqoASTXPRfuBKdQTY qhUecEUQxVJVMYJ92OQU5E182XqhikhiZkDbykKYpKxoaXDUdVBF9RFC+Q+ZcHsWCBhF rvW4n/sv7+8YzW4zqsrfmuCngqP9QBNZfmycrY3EEE68ik5jPvntY+kPC5wBIhWvWIyz QYJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=JWb0gO0FR8omCjsq9CBOm7HqleJuQXyRTIuggbhXR0I=; b=Q9ZqT4O82kbkuTkkjHeK11rf/WrdR1suoGA+kGtpdd1MTNWHnL5P5J0zAjncuKjvGZ NKsugFC2igsJyBIgDIa2DjMmV3HXQ0wwItDY5EhQEziEAdAF+mqA1WJQ+t3K8eEMmeNV v58MV+aNRRHhKNa0UCmR6/Ly/3c2XtJgUoZgJ2wwK/o4kqHTllyYJ5h92eT8xgyaCinP ItpHigPQ5nM5qfppXG7pDC4Zsv5sFrSD66lU0S7qoeszQdlEC6wfrU4Z1PyYALlEs+m7 1q9CnAke5NHOMur7h1n560eCLr2VKQClVNv2EW0D5TrsD1VU4SV7cHfEdCXcZue64mIs x7oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=knfgDER3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w11si5319245edb.418.2019.05.19.13.53.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:53:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=knfgDER3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSo1-0007gs-Dj for patch@linaro.org; Sun, 19 May 2019 16:53:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSYz-0002tD-Ow for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYy-0003b4-JV for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:45 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:36502) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYy-0003aB-Cd for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:44 -0400 Received: by mail-pf1-x443.google.com with SMTP id v80so6171244pfa.3 for ; Sun, 19 May 2019 13:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JWb0gO0FR8omCjsq9CBOm7HqleJuQXyRTIuggbhXR0I=; b=knfgDER37TXLkkIf/7urgSaz0r/SfBFbkjvXw/XiP6sLx4w7eklJiFggC3UDYdDaqx tUhha63z+Hg5ScSWxjc6KAo1snLcAFEZfsx9RhgITT0zYdt6B6L55bUKfe/oxpk0YCh5 4UEyMJYIMSpSlIhzNZy2QF6HrMAfzyDWMCYbFVWkB1AMa2Eh8AkQGHAQ0pnyVVeeABki CB13GMOWkZWUZ+zWPHpe7qpBnC2H4j8QIcBoTfBOvS1QinQ3bE1LNpaDhg2eNNGYgg+D 4MxCDiaCljbi0qfnbrwygoTy1droAfjhFvlgEKtYFgOJT14E6lczRaMx/SRMOfiPkU+/ r+8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JWb0gO0FR8omCjsq9CBOm7HqleJuQXyRTIuggbhXR0I=; b=o0XgaY4O6Owu052mgraC7SvgORdcXjpuyoo/BYpFMwO4us+JRav8Q0lRxBxfYhSD7J QH1xqmb/CB3q8Pz56zwZ90txPU4cVMHF5gr2COlWqWIx4+aF5RMgm46Fhv5CYZ2dv7Z8 nYCWal1YC//pPPBQ4rkVeJSps8S6BcGh8vnKKB29qvsNA/Mqxu/I18iClm+ev7EH5ih3 qgCGA+1SCQBzTuLS8itoTlywPpmzxhvMNX5IY4QDzbd4Bzw6H4WedMIr+hu/dPgG0Fl1 vSshQ1e/GFolKuBPPtwK+1/xrv0PqIh1qIYNSwIccJjPJy0kLQbExJR1CoP2uxTYeZSE ix/A== X-Gm-Message-State: APjAAAWtXEwPnraL+053KOK5w+LxN94ZpLnC7ox9to9/XvlBXSHYS/q2 1JA8JXQBeebpR4EPkLWPnyTR6A3PEyA= X-Received: by 2002:a62:4281:: with SMTP id h1mr76213248pfd.162.1558298262235; Sun, 19 May 2019 13:37:42 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:21 -0700 Message-Id: <20190519203726.20729-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v7 09/74] linux-user: Split out readv, writev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-file.inc.c | 34 ++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 22 ---------------------- linux-user/strace.list | 6 ------ 4 files changed, 36 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index b031de1375..130ba7e344 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -28,4 +28,6 @@ SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlinkat SYSCALL_DEF(readlinkat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_DEC); #endif +SYSCALL_DEF(readv, ARG_DEC, ARG_PTR, ARG_DEC); SYSCALL_DEF(write, ARG_DEC, ARG_PTR, ARG_DEC); +SYSCALL_DEF(writev, ARG_DEC, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index e6adcc351c..2297ca1760 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -349,6 +349,23 @@ SYSCALL_IMPL(read) return ret; } +SYSCALL_IMPL(readv) +{ + int fd = arg1; + abi_ulong target_vec = arg2; + int count = arg3; + struct iovec *vec = lock_iovec(VERIFY_WRITE, target_vec, count, 0); + abi_long ret; + + if (vec != NULL) { + ret = get_errno(safe_readv(fd, vec, count)); + unlock_iovec(vec, target_vec, count, 1); + } else { + ret = -host_to_target_errno(errno); + } + return ret; +} + static abi_long do_readlinkat(int dirfd, abi_ulong target_path, abi_ulong target_buf, abi_ulong bufsiz) { @@ -425,3 +442,20 @@ SYSCALL_IMPL(write) unlock_user(p, target_p, 0); return ret; } + +SYSCALL_IMPL(writev) +{ + int fd = arg1; + abi_ulong target_vec = arg2; + int count = arg3; + struct iovec *vec = lock_iovec(VERIFY_READ, target_vec, count, 1); + abi_long ret; + + if (vec != NULL) { + ret = get_errno(safe_writev(fd, vec, count)); + unlock_iovec(vec, target_vec, count, 0); + } else { + ret = -host_to_target_errno(errno); + } + return ret; +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 61cd73db26..8086626707 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9005,28 +9005,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* NOTE: the flock constant seems to be the same for every Linux platform */ return get_errno(safe_flock(arg1, arg2)); - case TARGET_NR_readv: - { - struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); - if (vec != NULL) { - ret = get_errno(safe_readv(arg1, vec, arg3)); - unlock_iovec(vec, arg2, arg3, 1); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; - case TARGET_NR_writev: - { - struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); - if (vec != NULL) { - ret = get_errno(safe_writev(arg1, vec, arg3)); - unlock_iovec(vec, arg2, arg3, 0); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; #if defined(TARGET_NR_preadv) case TARGET_NR_preadv: { diff --git a/linux-user/strace.list b/linux-user/strace.list index 2d6bfec692..c4ae70b485 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1073,9 +1073,6 @@ #ifdef TARGET_NR_readdir { TARGET_NR_readdir, "readdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_readv -{ TARGET_NR_readv, "readv" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_reboot { TARGET_NR_reboot, "reboot" , NULL, NULL, NULL }, #endif @@ -1608,9 +1605,6 @@ #ifdef TARGET_NR_waitpid { TARGET_NR_waitpid, "waitpid" , "%s(%d,%p,%#x)", NULL, NULL }, #endif -#ifdef TARGET_NR_writev -{ TARGET_NR_writev, "writev" , "%s(%d,%p,%#x)", NULL, NULL }, -#endif #ifdef TARGET_NR_utimensat { TARGET_NR_utimensat, "utimensat", NULL, print_utimensat, NULL }, #endif From patchwork Sun May 19 20:36:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164496 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4781666ili; Sun, 19 May 2019 13:44:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuJUbsVQKNb08Ab7/XzmboeiIWLZvPQABCwkA39SG/rqByJx2E9NSRhBWwwkCZZDeUsAzQ X-Received: by 2002:a50:ed14:: with SMTP id j20mr72161277eds.84.1558298640115; Sun, 19 May 2019 13:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298640; cv=none; d=google.com; s=arc-20160816; b=rO4MFEyTyZjaFSikFiAZ5F6XmppPDvTHBsEWAUzTsUUvU5UZcQgDj9m/OE6hFmjPtF ZU833f/s58Ct2Gzqa9BK3YkGrQC3I0aFzpknKFpLG3tCchACTet/b8wYbt2DZt8MEk0w mvLPiUonfIjOASjgZAt3pwpCNm9KgjHewxjnh8U+jVegzdYnJeCf6oHHW8b8EvEKPtUZ TZbjsq/ugdNUrrETYjAqhxkUatZCpVbR6eewxY/Xj7+lt+YUjtX7uOETzK2Q7BTx9eE0 +ohiOVqjRam/6C7wLeLt+3fpRCrc2n50KT53PEPzQr8w9lkFlInOtbSkALpVGMBrjjKP GpGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=nuZhVVs0grkA8++mqqAYSgCu6GK8Ulmk49OHI5Gid5E=; b=J3le4FAHQJJ90BAjR/wAirgSR9RfvnIY8r0yBTx5WY/6brlwlOBxOx1654GClJM+ta wiyReIwEe+KnD9uN8uXPQIgydHZODM3dE+EUPOICbdZKKTKQerA1aRIXJLxIPoR1f2Km 4xha2DwvmUL0zcrbMl+9R3f2c+ESa19+UeEwOsGW9Q80VK1JQpiK8dUz+sb+zOz6MeoP WcdtrzmcGpMSlJZYG0zIOZHDxAHP5itx/fT8ACZhRDdoDrVoxjT5q5aDQxpyBniYB2ZH Ld767RaLzktlEyJwuXJ0AwsJ3E+ualjgg5wzxK0W2MTbapJHZjO1VzC/8wJaiG6m4FIq eDmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N0JHQqNf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h41si5243286edh.55.2019.05.19.13.43.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:44:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N0JHQqNf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSf0-0008Gs-T8 for patch@linaro.org; Sun, 19 May 2019 16:43:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZ0-0002tn-BR for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSYz-0003bb-2x for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:46 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:36599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSYy-0003aR-SF for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:45 -0400 Received: by mail-pl1-x644.google.com with SMTP id d21so5723612plr.3 for ; Sun, 19 May 2019 13:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nuZhVVs0grkA8++mqqAYSgCu6GK8Ulmk49OHI5Gid5E=; b=N0JHQqNfxKmMMByWgPuV+E2KnwQJh2aUwKenfhLEps1BNQQOm69z+Lf51CpcuKx+GP E6/amsaEG1/0Q0Ne71CAm4hiSCRcJw0mdF4VCwD+5CRBcG4BYlmqDvVhzqPO7slBj3DC 6nVr8j7UsdW9ubVZ4m4PuFxwPRBPBPLnLT3MbHfaWS8hS3QIDBAE67/bzsxvlxQsXGtv rHsr4LvRhgn36ortXh79KOJILn0/dhsJ8vU4FKx+G8w1oiYSrRQPUcmSLMXN6YSKngjN 2qkKXeWL67f2yxqxQJjMgioVCNWiuoF3q07rDyb8mfgHD91xJh3IIbRtW3DKGAX6A4kU 1yaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nuZhVVs0grkA8++mqqAYSgCu6GK8Ulmk49OHI5Gid5E=; b=XV7T3Ya/AzpGbMLVjZl1b4ICDyqG/tAdlaPzHAbeq9Q0sLwQxCmmgi8UsZIJhq5FOh KgxPuNYNNRGHvipg3aHKXasX5QMhP/iYc48Qam2wyAB/ke2RFkxGSjTGIYjk00r285db dJ+zClnQqdBt6CxEySFTde3ZzmsXJQPUot4aYHG7tPn2BX8FeuWojW+6yLmeMVJZ1S98 6F4EPEXKtLebUnfwPfciTQFEh4XC0vHZ1wBkTuKK771lOCKfv84IpeUKzGGn+I78Il40 PQdv5hJ4673x/d85/Xgtvwo/eraYJIyVhfgBNC0Y2xV2sxz3udPUKbP1EWjbQDqW2GBy Pd1w== X-Gm-Message-State: APjAAAU4Nx4pO4dO3FUb/0qj95URHpF1TgqIcJMijSg/1nBuCfFlnDcE F19BJS7HSNaybhYmA9/YFaHliSLQXRs= X-Received: by 2002:a17:902:201:: with SMTP id 1mr26870277plc.263.1558298263493; Sun, 19 May 2019 13:37:43 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:22 -0700 Message-Id: <20190519203726.20729-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v7 10/74] linux-user: Split out pread64, pwrite64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++ linux-user/syscall-file.inc.c | 62 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 36 -------------------- linux-user/strace.list | 6 ---- 4 files changed, 68 insertions(+), 42 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 130ba7e344..027793d5d0 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -21,6 +21,12 @@ SYSCALL_DEF(close, ARG_DEC); SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif SYSCALL_DEF(openat, ARG_ATDIRFD, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); +SYSCALL_DEF_FULL(pread64, .impl = impl_pread64, + .args = args_pread64_pwrite64, + .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); +SYSCALL_DEF_FULL(pwrite64, .impl = impl_pwrite64, + .args = args_pread64_pwrite64, + .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); SYSCALL_DEF(read, ARG_DEC, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlink SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 2297ca1760..43aa6eeeb8 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -323,6 +323,68 @@ SYSCALL_IMPL(openat) return do_openat(cpu_env, arg1, arg2, arg3, arg4); } +/* + * Both pread64 and pwrite64 merge args into a 64-bit offset, + * but the input registers and ordering are target specific. + */ +#if TARGET_ABI_BITS == 32 +SYSCALL_ARGS(pread64_pwrite64) +{ + /* We have already assigned out[0-2]. */ + int off = regpairs_aligned(cpu_env, TARGET_NR_pread64); + out[3] = target_offset64(in[3 + off], in[4 + off]); + return def; +} +#else +#define args_pread64_pwrite64 NULL +#endif + +SYSCALL_IMPL(pread64) +{ + int fd = arg1; + abi_ulong target_buf = arg2; + abi_ulong len = arg3; + uint64_t off = arg4; + void *p; + abi_long ret; + + if (target_buf == 0 && len == 0) { + /* Special-case NULL buffer and zero length, which should succeed */ + p = NULL; + } else { + p = lock_user(VERIFY_WRITE, target_buf, len, 0); + if (!p) { + return -TARGET_EFAULT; + } + } + ret = get_errno(pread64(fd, p, len, off)); + unlock_user(p, target_buf, ret); + return ret; +} + +SYSCALL_IMPL(pwrite64) +{ + int fd = arg1; + abi_ulong target_buf = arg2; + abi_ulong len = arg3; + uint64_t off = arg4; + void *p; + abi_long ret; + + if (target_buf == 0 && len == 0) { + /* Special-case NULL buffer and zero length, which should succeed */ + p = 0; + } else { + p = lock_user(VERIFY_READ, target_buf, len, 1); + if (!p) { + return -TARGET_EFAULT; + } + } + ret = get_errno(pwrite64(fd, p, len, off)); + unlock_user(p, target_buf, 0); + return ret; +} + SYSCALL_IMPL(read) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8086626707..f636fb8bb3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9404,42 +9404,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #else #error unreachable #endif -#endif -#ifdef TARGET_NR_pread64 - case TARGET_NR_pread64: - if (regpairs_aligned(cpu_env, num)) { - arg4 = arg5; - arg5 = arg6; - } - if (arg2 == 0 && arg3 == 0) { - /* Special-case NULL buffer and zero length, which should succeed */ - p = 0; - } else { - p = lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!p) { - return -TARGET_EFAULT; - } - } - ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); - unlock_user(p, arg2, ret); - return ret; - case TARGET_NR_pwrite64: - if (regpairs_aligned(cpu_env, num)) { - arg4 = arg5; - arg5 = arg6; - } - if (arg2 == 0 && arg3 == 0) { - /* Special-case NULL buffer and zero length, which should succeed */ - p = 0; - } else { - p = lock_user(VERIFY_READ, arg2, arg3, 1); - if (!p) { - return -TARGET_EFAULT; - } - } - ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); - unlock_user(p, arg2, 0); - return ret; #endif case TARGET_NR_getcwd: if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0))) diff --git a/linux-user/strace.list b/linux-user/strace.list index c4ae70b485..a11ad3c3c7 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1025,9 +1025,6 @@ #ifdef TARGET_NR_prctl { TARGET_NR_prctl, "prctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pread64 -{ TARGET_NR_pread64, "pread64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_preadv { TARGET_NR_preadv, "preadv" , NULL, NULL, NULL }, #endif @@ -1055,9 +1052,6 @@ #ifdef TARGET_NR_putpmsg { TARGET_NR_putpmsg, "putpmsg" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pwrite64 -{ TARGET_NR_pwrite64, "pwrite64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_pwritev { TARGET_NR_pwritev, "pwritev" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164503 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4784436ili; Sun, 19 May 2019 13:48:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqynzTr3FD/DRI5HlBlnH/VYRiNUlyLbyFem5a4tcMdIg7epqCf/I5iywrf/g/tX80AmyhPq X-Received: by 2002:aa7:d6d3:: with SMTP id x19mr71188433edr.67.1558298899927; Sun, 19 May 2019 13:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298899; cv=none; d=google.com; s=arc-20160816; b=tdG9SXM2lao79mfQJPCwKjPzgUbtNN7v7YlsXRiPuGUR50N0USpOuwBMJId5mM5/MG tpBm8B6OUncSIQ8oSlgE9kuFAyKSeciNhK0V6g7URdFJslAVZiCgSTSH7QkiYyTiM0JS RTz8RbPQcfP0ThEIvLCYGlYEBD3XhgbmGxU7oYHtxRPJio/YO4L0ZLuRAmhG/SeATVL/ y9j2NOnPFNmWtgRR1+bMcvRZvjFdkc8MpSvH1PvhgnOZy9RGXyRMaoPzEUWJMGsl1QV+ Eccf50o6D/Coi8G5iHowxKMFTUWAgM5p3z/ajF1Aoaat5cJyCjlL1lAp1Bp1eaZ/BPY1 If7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7G+hJOBDRTLscZajbGHATg460taQH3Fs6lhNe9/8aV8=; b=BQROUHVCS/+iNwnI/nB2RvKFS1Kimbi7QYEm5zXI4T6cPa7/cZRBi9kGpjcElZTUr6 s+sQkUZWCNHCfk7wtjNyyAuPGkODIviPPZWEZcsABEOtWjxuXbrgV1h3EvoFLp2fYwF5 tjPkd376dKaqVBrDjIPq9mfHeYYn85XFPvMpljKZLDq1kdkXpfEF3M1ViWtougInXCmZ vwYFeQLUWp/fsBe0HRm9MWP7vO3ppJE7Z+TkcXSl3m4aLEJs4dKGBm7SMhK94Qzs3RIP bI7lGjQcUVvBRIQx3S6V9KPFLezp9zd1sMipVthAC8RjMPdD6wVK3YY2H+r8UOQduTru V0Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZLv0hkHv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d51si1508539edb.427.2019.05.19.13.48.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:48:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZLv0hkHv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSjC-0003N9-Om for patch@linaro.org; Sun, 19 May 2019 16:48:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZ2-0002w0-H5 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ1-0003eK-0b for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:48 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:34961) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ0-0003d3-PM for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:46 -0400 Received: by mail-pf1-x444.google.com with SMTP id t87so6174984pfa.2 for ; Sun, 19 May 2019 13:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7G+hJOBDRTLscZajbGHATg460taQH3Fs6lhNe9/8aV8=; b=ZLv0hkHvVmH6uPLmeGbxpepwZtnAVJ+3cY9c+igY4+aqt97tKh2qUSiPiknzzu8V2T WWJNvbAzkGexTwZpF50G7d8qX97ibfQOkH5wBXWhWfVCr1gApdDEFiWE01ey4NR3qXuD Pfn0ta+knoaKPoEtRuTZMj7gWekCrwGVFXQlKzjErCMEep67iNDve+1PYlzbXi9KIDrd cgnVxvmPKJRu/UOMAKEqaNeiNnpMQIceJrccdddKdcrqpjlfa9bGhs4XUgkzaVRMBgbj d8tMg1FgaeU1PoRXkokoL11EZjXZVEV90pE800FTCCWnqFejL7hWHrowNXI9QbYt9aK2 +gpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7G+hJOBDRTLscZajbGHATg460taQH3Fs6lhNe9/8aV8=; b=KilZTMJjPCjO+anpKgmeqAD4QOKaV8KCD7gmJ/PHxJubP4wynR8O1sZfTbuMWc09uF AF9c6b3xXzbYcUIYcx9aJkfhVFRp8HM1LCLdWNS6RXy3qh4II+STpGs4rUE89UsXIRu6 L2Pe1Ae/ly2MnVogVqU69Ipi53U89PYBOqt7nu4X+VjQLvVxxmXwt/YJMVk+dqxQTiGn EGhn9wVtAuonrLF9Q2bNMRG56XX+cZGqo0uwPUDSZNJfWAalGu+O+IiENYMFjKsppCdc n8w+1MnpyAS09pgnIECI4EtHhsUDlugoBTJR20krMJjD1iU52P3Id9wfiZvaiN/kXkeG DXMw== X-Gm-Message-State: APjAAAU02Jgo/xMvVr+E39rBaCDj6o6Ielb+3+FybT1r5dKMu7omS9B7 DvWfcNczXeox0iCPxjBkJk/MCJHpEQE= X-Received: by 2002:aa7:99dd:: with SMTP id v29mr77603622pfi.252.1558298264606; Sun, 19 May 2019 13:37:44 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:23 -0700 Message-Id: <20190519203726.20729-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v7 11/74] linux-user: Split out preadv, pwritev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++ linux-user/syscall-file.inc.c | 64 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 49 --------------------------- linux-user/strace.list | 6 ---- 4 files changed, 70 insertions(+), 55 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 027793d5d0..ae89be0e87 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -27,6 +27,12 @@ SYSCALL_DEF_FULL(pread64, .impl = impl_pread64, SYSCALL_DEF_FULL(pwrite64, .impl = impl_pwrite64, .args = args_pread64_pwrite64, .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); +SYSCALL_DEF_FULL(preadv, .impl = impl_preadv, + .args = args_preadv_pwritev, + .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); +SYSCALL_DEF_FULL(pwritev, .impl = impl_pwritev, + .args = args_preadv_pwritev, + .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); SYSCALL_DEF(read, ARG_DEC, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlink SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 43aa6eeeb8..61cfe2acb7 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -385,6 +385,70 @@ SYSCALL_IMPL(pwrite64) return ret; } +/* + * Both preadv and pwritev merge args 4/5 into a 64-bit offset. + * Moreover, the parts are *always* in little-endian order. + */ +#if TARGET_ABI_BITS == 32 +SYSCALL_ARGS(preadv_pwritev) +{ + /* We have already assigned out[0-2]. */ + abi_ulong lo = in[3], hi = in[4]; + out[3] = (((uint64_t)hi << (TARGET_ABI_BITS - 1)) << 1) | lo; + return def; +} +#else +#define args_preadv_pwritev NULL +#endif + +/* Perform the inverse operation for the host. */ +static inline void host_offset64_low_high(unsigned long *l, unsigned long *h, + uint64_t off) +{ + *l = off; + *h = (off >> (HOST_LONG_BITS - 1)) >> 1; +} + +SYSCALL_IMPL(preadv) +{ + int fd = arg1; + abi_ulong target_vec = arg2; + int count = arg3; + uint64_t off = arg4; + struct iovec *vec = lock_iovec(VERIFY_WRITE, target_vec, count, 0); + unsigned long lo, hi; + abi_long ret; + + if (vec == NULL) { + return -TARGET_EFAULT; + } + + host_offset64_low_high(&lo, &hi, off); + ret = get_errno(safe_preadv(fd, vec, count, lo, hi)); + unlock_iovec(vec, target_vec, count, 1); + return ret; +} + +SYSCALL_IMPL(pwritev) +{ + int fd = arg1; + abi_ulong target_vec = arg2; + int count = arg3; + uint64_t off = arg4; + struct iovec *vec = lock_iovec(VERIFY_READ, target_vec, count, 1); + unsigned long lo, hi; + abi_long ret; + + if (vec == NULL) { + return -TARGET_EFAULT; + } + + host_offset64_low_high(&lo, &hi, off); + ret = get_errno(safe_pwritev(fd, vec, count, lo, hi)); + unlock_iovec(vec, target_vec, count, 0); + return ret; +} + SYSCALL_IMPL(read) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f636fb8bb3..817c4a7296 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2437,23 +2437,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, return ret; } -/* Convert target low/high pair representing file offset into the host - * low/high pair. This function doesn't handle offsets bigger than 64 bits - * as the kernel doesn't handle them either. - */ -static void target_to_host_low_high(abi_ulong tlow, - abi_ulong thigh, - unsigned long *hlow, - unsigned long *hhigh) -{ - uint64_t off = tlow | - ((unsigned long long)thigh << TARGET_LONG_BITS / 2) << - TARGET_LONG_BITS / 2; - - *hlow = off; - *hhigh = (off >> HOST_LONG_BITS / 2) >> HOST_LONG_BITS / 2; -} - static struct iovec *lock_iovec(int type, abi_ulong target_addr, abi_ulong count, int copy) { @@ -9005,38 +8988,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* NOTE: the flock constant seems to be the same for every Linux platform */ return get_errno(safe_flock(arg1, arg2)); -#if defined(TARGET_NR_preadv) - case TARGET_NR_preadv: - { - struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); - if (vec != NULL) { - unsigned long low, high; - - target_to_host_low_high(arg4, arg5, &low, &high); - ret = get_errno(safe_preadv(arg1, vec, arg3, low, high)); - unlock_iovec(vec, arg2, arg3, 1); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; -#endif -#if defined(TARGET_NR_pwritev) - case TARGET_NR_pwritev: - { - struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); - if (vec != NULL) { - unsigned long low, high; - - target_to_host_low_high(arg4, arg5, &low, &high); - ret = get_errno(safe_pwritev(arg1, vec, arg3, low, high)); - unlock_iovec(vec, arg2, arg3, 0); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; -#endif case TARGET_NR_getsid: return get_errno(getsid(arg1)); #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */ diff --git a/linux-user/strace.list b/linux-user/strace.list index a11ad3c3c7..f326613934 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1025,9 +1025,6 @@ #ifdef TARGET_NR_prctl { TARGET_NR_prctl, "prctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_preadv -{ TARGET_NR_preadv, "preadv" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_prlimit64 { TARGET_NR_prlimit64, "prlimit64" , NULL, NULL, NULL }, #endif @@ -1052,9 +1049,6 @@ #ifdef TARGET_NR_putpmsg { TARGET_NR_putpmsg, "putpmsg" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pwritev -{ TARGET_NR_pwritev, "pwritev" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_query_module { TARGET_NR_query_module, "query_module" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164507 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4786519ili; Sun, 19 May 2019 13:51:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGGN2iIPjCRBBxWzzxIfmqxbtDpbmqeZRxmc9JFvBUoXhUHj/il5eip+IW/KOm219f1eVy X-Received: by 2002:a17:906:3955:: with SMTP id g21mr54939225eje.61.1558299092000; Sun, 19 May 2019 13:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299091; cv=none; d=google.com; s=arc-20160816; b=iu2tGPSEbeEPtNHBznTTexBCNROaqReG25TJBV2El2MBfdTk8QV0V7ub+vkEeX+qHb mFq/XojMKPyut3h8YDUuhlmNMr5xNDcHkmbHXRBYde6vnmRMrgnV8ukZzhJTBdGZla7m eTxEefOZ0tvGd/Kn0ybGU9Zm2YPt5H4t8ViUUqx31DpcFE2fEPTsumaxeHAq1qlgczdD vZBvwDxKqT+JIaO1rL5eGdRaV0Ef82i5Um0LoNbM1i0u/jefmo9sAy1djVfAsqR7XRYW npveJDm/ydcyCZlmRQU918HHEYeQIIWj332MeHldcRrIsiOEBqyBuIz2MAJ8HRM9HaW0 TG1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=oMFlfEqih7Sfj/vQATNw8M06mkjRkntlWcN2dDQKmHc=; b=qqdHKXxqzPoxcsEDZk2kG9gBpFDRTquQRRGSD4hhHK4gSTVcLeoJ3v2BZLztD6sbPD ckGNk9FedfMdUT9qj7y3Sp1qnTRyrRmbfY88R6AAIT8cbNccZa8qa5hlRyGQxy9L+Em5 gVliKkD8e9yT88F6BkMjSQS3xI0l4jfg2Hk+RamsMFXp1TmFLM8Ktvxiz6p7C0v1S+Ym qFNdSBg1q2zzJXXGS4wPVFhUy0onSylpc8zUSpZJje2HS9oqnTxV4eVQW9I88jJmY43F ly1ErprxE7RdCxg88prbDqM8QL3r/FdLMzRyeR50nIQ9fwhuRqOyILI346/T1w0acZFO s0uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E0uU6tyH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g20si668164edg.329.2019.05.19.13.51.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:51:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E0uU6tyH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSmI-0005pZ-RB for patch@linaro.org; Sun, 19 May 2019 16:51:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZ4-00032X-Ca for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ2-0003gB-JR for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:50 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:36050) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ2-0003fG-4u for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:48 -0400 Received: by mail-pg1-x543.google.com with SMTP id a3so5747808pgb.3 for ; Sun, 19 May 2019 13:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oMFlfEqih7Sfj/vQATNw8M06mkjRkntlWcN2dDQKmHc=; b=E0uU6tyHCgCKWSZLU5LvFSsaJUIx03ALgXp7QiGMVHAj1BpnCQzXTldbc4Yiwpni0z q/C3bhJCcxjojQMNzUitgZP04GZ40WsMTQk0h34YvWmnhxdMUUtEroZK/SwP5yBFjGy4 jUxItShfEtRrfI85qS7ZW4Ngqn76o+kfCXZh9ovsbaJqrPTskUUZS90j1nyRDMXIpI4L /MfWXEQoYguf160JYIqfRFQt3KGKHuBKtBlM+RAPnFaEsmBBmz6LMM5zb1nQf4Y59iqV FPOSDJvla8r3dtWjftZcDxKneQx0fjgI+vBQd1shL8+R7sr4T9tv3OYG2VdTvmh6Ou4d Txmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oMFlfEqih7Sfj/vQATNw8M06mkjRkntlWcN2dDQKmHc=; b=aMlO17uN7P0W9RtgCEVff1pD6umIYbjOAcJ91TSGSVkUBQvR1lgkHHYzt725QDcVdY qJHSNvmMpLiiftrM6tYIpDxUEyLIvp+B4Nr6V+BRJVrOYkETSHJQv6avJFtwCrdB2Akk hh3G1Scoqr+CV2O5z6ShAv4XoMn/DayusRYoMzwl6rGSAYlXwtnndx1nIOVWGx/VBz1x VI4TGFUjsuR+DBn/WB/DadDM1OSAnaUHpwnLS/KOsFu0/3FcRMfpmUgUJUFT2Ww3z5Br XTKvKqu0ARKePwEDPzVT84JhTrET/wP2ObCPWeCwL3oD18FfqyDWFvT4aO80RR9PT0Zy mJ8A== X-Gm-Message-State: APjAAAXwXfLb8ef7s+FEzGMH0WiV6FAKw/ujgzIGO8Tcrhu6GEhYQGOM RoA8fmboFPdV5jNfa1MSQEmojIUJoIM= X-Received: by 2002:a62:1b85:: with SMTP id b127mr47952138pfb.165.1558298265797; Sun, 19 May 2019 13:37:45 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:24 -0700 Message-Id: <20190519203726.20729-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v7 12/74] linux-user: Split out name_to_handle_at, open_by_handle_at X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All targets have these syscalls, so they need not be ifdefed. If we provide safe syscalls for the host, we can remove the configure test for this too. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 3 + linux-user/syscall.h | 1 + linux-user/strace.c | 5 +- linux-user/syscall-file.inc.c | 81 +++++++++++++++++++++++++++ linux-user/syscall.c | 102 ++-------------------------------- configure | 20 ------- linux-user/strace.list | 3 - 7 files changed, 93 insertions(+), 122 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index ae89be0e87..1fc89c1b08 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -17,10 +17,13 @@ */ SYSCALL_DEF(close, ARG_DEC); +SYSCALL_DEF(name_to_handle_at, + ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); #ifdef TARGET_NR_open SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif SYSCALL_DEF(openat, ARG_ATDIRFD, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); +SYSCALL_DEF(open_by_handle_at, ARG_DEC, ARG_PTR, ARG_OPENFLAG); SYSCALL_DEF_FULL(pread64, .impl = impl_pread64, .args = args_pread64_pwrite64, .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 43b5dc0684..83f602f8e7 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -57,6 +57,7 @@ typedef enum { /* These print as sets of flags. */ ARG_ATDIRFD, + ARG_ATFLAG, ARG_MODEFLAG, ARG_OPENFLAG, diff --git a/linux-user/strace.c b/linux-user/strace.c index 2f1c7e537f..e92b2c298e 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -780,7 +780,7 @@ UNUSED static struct flags access_flags[] = { FLAG_END, }; -UNUSED static struct flags at_file_flags[] = { +static struct flags const at_file_flags[] = { #ifdef AT_EACCESS FLAG_GENERIC(AT_EACCESS), #endif @@ -2693,6 +2693,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_ATDIRFD: len = add_atdirfd(b, rest, arg); break; + case ARG_ATFLAG: + len = add_flags(b, rest, at_file_flags, arg, false); + break; case ARG_MODEFLAG: len = add_flags(b, rest, mode_flags, arg, true); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 61cfe2acb7..dd44d5b804 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -323,6 +323,87 @@ SYSCALL_IMPL(openat) return do_openat(cpu_env, arg1, arg2, arg3, arg4); } +SYSCALL_IMPL(name_to_handle_at) +{ + struct file_handle *target_fh; + struct file_handle *fh; + int mid = 0; + abi_long ret; + char *name; + uint32_t size, total_size; + + if (get_user_s32(size, arg3)) { + return -TARGET_EFAULT; + } + total_size = sizeof(struct file_handle) + size; + target_fh = lock_user(VERIFY_WRITE, arg3, total_size, 0); + if (!target_fh) { + return -TARGET_EFAULT; + } + + name = lock_user_string(arg2); + if (!name) { + unlock_user(target_fh, arg3, 0); + return -TARGET_EFAULT; + } + + fh = g_malloc0(total_size); + fh->handle_bytes = size; + + ret = get_errno(safe_name_to_handle_at(arg1, path(name), fh, &mid, arg5)); + unlock_user(name, arg2, 0); + + /* + * man name_to_handle_at(2): + * Other than the use of the handle_bytes field, the caller should treat + * the file_handle structure as an opaque data type + */ + if (!is_error(ret)) { + memcpy(target_fh, fh, total_size); + target_fh->handle_bytes = tswap32(fh->handle_bytes); + target_fh->handle_type = tswap32(fh->handle_type); + g_free(fh); + unlock_user(target_fh, arg3, total_size); + + if (put_user_s32(mid, arg4)) { + return -TARGET_EFAULT; + } + } + return ret; +} + +SYSCALL_IMPL(open_by_handle_at) +{ + abi_long mount_fd = arg1; + abi_long handle = arg2; + int host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl); + struct file_handle *target_fh; + struct file_handle *fh; + unsigned int size, total_size; + abi_long ret; + + if (get_user_s32(size, handle)) { + return -TARGET_EFAULT; + } + total_size = sizeof(struct file_handle) + size; + target_fh = lock_user(VERIFY_READ, handle, total_size, 1); + if (!target_fh) { + return -TARGET_EFAULT; + } + + fh = g_memdup(target_fh, total_size); + fh->handle_bytes = size; + fh->handle_type = tswap32(target_fh->handle_type); + + ret = get_errno(safe_open_by_handle_at(mount_fd, fh, host_flags)); + + g_free(fh); + unlock_user(target_fh, handle, total_size); + + fd_trans_unregister(ret); + return ret; +} + /* * Both pread64 and pwrite64 merge args into a 64-bit offset, * but the input registers and ordering are target specific. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 817c4a7296..c49f8aebd2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -806,6 +806,10 @@ safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, len, unsigned *, prio, const struct timespec *, timeout) #endif +safe_syscall5(int, name_to_handle_at, int, dirfd, const char *, pathname, + struct file_handle *, handle, int *, mount_id, int, flags) +safe_syscall3(int, open_by_handle_at, int, mount_fd, + struct file_handle *, handle, int, flags) /* We do ioctl like this rather than via safe_syscall3 to preserve the * "third argument might be integer or pointer or not present" behaviour of * the libc function. @@ -6479,93 +6483,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, return -TARGET_ENOSYS; } } -#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) -static abi_long do_name_to_handle_at(abi_long dirfd, abi_long pathname, - abi_long handle, abi_long mount_id, - abi_long flags) -{ - struct file_handle *target_fh; - struct file_handle *fh; - int mid = 0; - abi_long ret; - char *name; - unsigned int size, total_size; - - if (get_user_s32(size, handle)) { - return -TARGET_EFAULT; - } - - name = lock_user_string(pathname); - if (!name) { - return -TARGET_EFAULT; - } - - total_size = sizeof(struct file_handle) + size; - target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0); - if (!target_fh) { - unlock_user(name, pathname, 0); - return -TARGET_EFAULT; - } - - fh = g_malloc0(total_size); - fh->handle_bytes = size; - - ret = get_errno(name_to_handle_at(dirfd, path(name), fh, &mid, flags)); - unlock_user(name, pathname, 0); - - /* man name_to_handle_at(2): - * Other than the use of the handle_bytes field, the caller should treat - * the file_handle structure as an opaque data type - */ - - memcpy(target_fh, fh, total_size); - target_fh->handle_bytes = tswap32(fh->handle_bytes); - target_fh->handle_type = tswap32(fh->handle_type); - g_free(fh); - unlock_user(target_fh, handle, total_size); - - if (put_user_s32(mid, mount_id)) { - return -TARGET_EFAULT; - } - - return ret; - -} -#endif - -#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) -static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle, - abi_long flags) -{ - struct file_handle *target_fh; - struct file_handle *fh; - unsigned int size, total_size; - abi_long ret; - - if (get_user_s32(size, handle)) { - return -TARGET_EFAULT; - } - - total_size = sizeof(struct file_handle) + size; - target_fh = lock_user(VERIFY_READ, handle, total_size, 1); - if (!target_fh) { - return -TARGET_EFAULT; - } - - fh = g_memdup(target_fh, total_size); - fh->handle_bytes = size; - fh->handle_type = tswap32(target_fh->handle_type); - - ret = get_errno(open_by_handle_at(mount_fd, fh, - target_to_host_bitmask(flags, fcntl_flags_tbl))); - - g_free(fh); - - unlock_user(target_fh, handle, total_size); - - return ret; -} -#endif #if defined(TARGET_NR_signalfd) || defined(TARGET_NR_signalfd4) @@ -6761,17 +6678,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, preexit_cleanup(cpu_env, arg1); _exit(arg1); return 0; /* avoid warning */ -#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) - case TARGET_NR_name_to_handle_at: - ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); - return ret; -#endif -#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) - case TARGET_NR_open_by_handle_at: - ret = do_open_by_handle_at(arg1, arg2, arg3); - fd_trans_unregister(ret); - return ret; -#endif case TARGET_NR_brk: return do_brk(arg1); #ifdef TARGET_NR_fork diff --git a/configure b/configure index d2fc346302..6573fcefcb 100755 --- a/configure +++ b/configure @@ -5243,22 +5243,6 @@ if test "$debug_stack_usage" = "yes"; then fi -########################################## -# check if we have open_by_handle_at - -open_by_handle_at=no -cat > $TMPC << EOF -#include -#if !defined(AT_EMPTY_PATH) -# error missing definition -#else -int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); } -#endif -EOF -if compile_prog "" "" ; then - open_by_handle_at=yes -fi - ######################################## # check if we have linux/magic.h @@ -7012,10 +6996,6 @@ if test "$crypto_afalg" = "yes" ; then echo "CONFIG_AF_ALG=y" >> $config_host_mak fi -if test "$open_by_handle_at" = "yes" ; then - echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak -fi - if test "$linux_magic_h" = "yes" ; then echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak fi diff --git a/linux-user/strace.list b/linux-user/strace.list index f326613934..bf239cb9a3 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -635,9 +635,6 @@ #ifdef TARGET_NR_munmap { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, #endif -#ifdef TARGET_NR_name_to_handle_at -{ TARGET_NR_name_to_handle_at, "name_to_handle_at" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_nanosleep { TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164521 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4795174ili; Sun, 19 May 2019 14:04:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPvOMtRNOwJ/9WsxNu0/VDVjt57qjHd7ID6ISo2sfOlJrUCZ9JOc8ITUlik8jEDKp9a3BN X-Received: by 2002:a50:b1e3:: with SMTP id n32mr70392398edd.55.1558299860690; Sun, 19 May 2019 14:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299860; cv=none; d=google.com; s=arc-20160816; b=REA+O37ORebeVVXjUaZSQSNtSmIGNAWtMox9EuXxyFuVgr1JVKEonfk1qEroGNiA95 m32SLKwZMFkSNLxQXSUryvRxR7IaGpzqKUqq+xGZyHLFh9nrVrf2+KE6Uy1SsmpQCUDg uQHLTFb8shKkzZ2xlqjNjWQUomT05mvH7GOiBNbc6UpldEyZImzERLi0xc+QnDoYPWQt +I10MCh1FLnH5ydyNf+J/Pu+T8ie42ovPdO49OC5e8r1y3cfR9irfmIbReHSmaUNswHb rhO2gSjVnKB6A58gEsTolkG6VKwMD/z2YvZUSKAKc9EYEphl2US6eLwZzKAqTnB/O/ZV qzWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=auz6sklL4M5LXs+Q33JnnlVdFEtL/kK5mScgKa9VDE4=; b=GnotiDCnBLv6a21QOWJ5vI23HvJrnF5H1jkBi+MQ3BUJiPI3mdI5dnrP69C0Tahx35 xd7g9lt0FTLX7xfT5J+kTspoSnV4A6RRfMw1wTyVG1PsZPdPHWFJUsdfWCza2CYxA2vV OXo3hUEC1FJaAMV4NfuRCnqKCXvVSH/JTwbrS+fhWZN095bq/eoWPCCI0TJGq0PeC1B+ 7vKuTZh6rkMO+CNzrIrbFYqNjt8yFkAx9xJIIC6LyLT93xcVaK7TMIrq67cGdbEQ6Tl+ MH/z2B/U/cYf0LvAq3Uu+FlInLn6wr/s1VePfhUIzQy6yVVJRRr9ij2/VrvOFeyIKLM2 v7zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tg50ALsX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k14si8117952edb.27.2019.05.19.14.04.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tg50ALsX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSyh-0000I5-9n for patch@linaro.org; Sun, 19 May 2019 17:04:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZ9-0003AI-N1 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ3-0003hJ-HQ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:55 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ3-0003gI-4H for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:49 -0400 Received: by mail-pf1-x442.google.com with SMTP id t87so6175001pfa.2 for ; Sun, 19 May 2019 13:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=auz6sklL4M5LXs+Q33JnnlVdFEtL/kK5mScgKa9VDE4=; b=tg50ALsXNqQQjAS8XjYfKA2FhMZbUDDNy/YPboc6EQal1lu4LAEko9pVy6vVcUHUYW 7QAExrod/bCki+tizOuT1zeCb2u1mnxEsMTaFgztsAkqz6MD1NpxVjBcvLsLXOlVHRI8 fI8pdT3vT10I3R/xaVZgQ13/l+Q9jFBAdM5QCbdPZ8AL2Q8s2JWfrob1tqkG+7pzhZIN zQWv8M37cpk2jo0NCqnmw5IxJatuWzXFZt/y5V04TvANiAb/xKfWNPRieXqTwfGcWCBf DxJjEacJ3fdSOoUo3JnEXCEkmJzTUI48OLkNT7bfSwNP2jWTj3AguxmW13E4yRYUDcrS vGxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=auz6sklL4M5LXs+Q33JnnlVdFEtL/kK5mScgKa9VDE4=; b=G0ygqT9uNdaLnveCZhWASVVd9jlAhQyt94PsXth9mcz6VhGsza9JeHgzNxtPBVplz9 l11MwsMB72qF4dGPGhUzG6dtWQ5zVEY3a55RhF3nvMkn9W4UqCctTpy0OgkQkSY7nyS7 rm/uvCiy2DotEvz4W6Gqa2bkYOnJ+f3ep/P5LtBUQdwwhDc9/XQj7ebEEEC9GPH/u4Lm IL9jxFb2g8N8UUvgExYLmDzlkJXgMygQf/10qmBtIYMOIscoNpDtklH7IlcKWvfNs8G/ fjJpxUQZbkX20ATXJt0ntfj6YEnBrE8Qb/PydMSEfE4OuUpStLsCvZlJo2iRPytwSb9d ouqA== X-Gm-Message-State: APjAAAVEA3fDNX8XzbXn3U/XHggpFW89AUs7t4DsNorMiVi7APxqntAs rHmOKHpT78e42I3vfK7mgjqIgyAx7Sw= X-Received: by 2002:a62:6456:: with SMTP id y83mr11075131pfb.71.1558298266906; Sun, 19 May 2019 13:37:46 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:25 -0700 Message-Id: <20190519203726.20729-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v7 13/74] linux-user: Split out ipc syscalls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Because of the ipc multiplex syscall, these must be done all at once. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 38 ++ linux-user/strace.c | 83 --- linux-user/syscall-ipc.inc.c | 1088 ++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 973 +----------------------------- linux-user/strace.list | 42 -- 5 files changed, 1129 insertions(+), 1095 deletions(-) create mode 100644 linux-user/syscall-ipc.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 1fc89c1b08..6d6349da01 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -17,6 +17,21 @@ */ SYSCALL_DEF(close, ARG_DEC); +#ifdef TARGET_NR_ipc +SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_msgctl) +SYSCALL_DEF(msgctl, ARG_DEC, ARG_DEC, ARG_PTR); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_msgget) +SYSCALL_DEF(msgget, ARG_DEC, ARG_DEC); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_msgrcv) +SYSCALL_DEF(msgrcv, ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC, ARG_HEX); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_msgsnd) +SYSCALL_DEF(msgsnd, ARG_DEC, ARG_PTR, ARG_DEC, ARG_HEX); +#endif SYSCALL_DEF(name_to_handle_at, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); #ifdef TARGET_NR_open @@ -44,5 +59,28 @@ SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); SYSCALL_DEF(readlinkat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_DEC); #endif SYSCALL_DEF(readv, ARG_DEC, ARG_PTR, ARG_DEC); +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) +SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semget) +SYSCALL_DEF(semget, ARG_DEC, ARG_DEC, ARG_HEX); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semop) +SYSCALL_DEF(semop, ARG_DEC, ARG_PTR, ARG_DEC); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmat) +SYSCALL_DEF_FULL(shmat, .impl = impl_shmat, + .print_ret = print_syscall_ptr_ret, + .arg_type = { ARG_DEC, ARG_PTR, ARG_HEX }); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmctl) +SYSCALL_DEF(shmctl, ARG_DEC, ARG_DEC, ARG_PTR); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmdt) +SYSCALL_DEF(shmdt, ARG_PTR); +#endif +#if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmget) +SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); +#endif SYSCALL_DEF(write, ARG_DEC, ARG_PTR, ARG_DEC); SYSCALL_DEF(writev, ARG_DEC, ARG_PTR, ARG_DEC); diff --git a/linux-user/strace.c b/linux-user/strace.c index e92b2c298e..e1c4859a95 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1,8 +1,4 @@ #include "qemu/osdep.h" -#include -#include -#include -#include #include #include #include @@ -74,54 +70,6 @@ UNUSED static void print_socket_protocol(int domain, int type, int protocol); /* * Utility functions */ -static void -print_ipc_cmd(int cmd) -{ -#define output_cmd(val) \ -if( cmd == val ) { \ - gemu_log(#val); \ - return; \ -} - - cmd &= 0xff; - - /* General IPC commands */ - output_cmd( IPC_RMID ); - output_cmd( IPC_SET ); - output_cmd( IPC_STAT ); - output_cmd( IPC_INFO ); - /* msgctl() commands */ - output_cmd( MSG_STAT ); - output_cmd( MSG_INFO ); - /* shmctl() commands */ - output_cmd( SHM_LOCK ); - output_cmd( SHM_UNLOCK ); - output_cmd( SHM_STAT ); - output_cmd( SHM_INFO ); - /* semctl() commands */ - output_cmd( GETPID ); - output_cmd( GETVAL ); - output_cmd( GETALL ); - output_cmd( GETNCNT ); - output_cmd( GETZCNT ); - output_cmd( SETVAL ); - output_cmd( SETALL ); - output_cmd( SEM_STAT ); - output_cmd( SEM_INFO ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - output_cmd( IPC_RMID ); - - /* Some value we don't recognize */ - gemu_log("%d",cmd); -} - static void print_signal(abi_ulong arg, int last) { @@ -620,18 +568,6 @@ print_newselect(const struct syscallname *name, } #endif -#ifdef TARGET_NR_semctl -static void -print_semctl(const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) -{ - gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2); - print_ipc_cmd(arg3); - gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); -} -#endif - static void print_execve(const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, @@ -664,25 +600,6 @@ print_execve(const struct syscallname *name, gemu_log("NULL})"); } -#ifdef TARGET_NR_ipc -static void -print_ipc(const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) -{ - switch(arg1) { - case IPCOP_semctl: - gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2); - print_ipc_cmd(arg3); - gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); - break; - default: - gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")", - name->name, arg1, arg2, arg3, arg4); - } -} -#endif - /* * Variants for the return value output function */ diff --git a/linux-user/syscall-ipc.inc.c b/linux-user/syscall-ipc.inc.c new file mode 100644 index 0000000000..26ee3be8bf --- /dev/null +++ b/linux-user/syscall-ipc.inc.c @@ -0,0 +1,1088 @@ +/* + * Linux ipc-related syscalls + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + + +#ifdef __NR_msgsnd +safe_syscall4(int, msgsnd, int, msgid, const void *, msgp, size_t, sz, + int, flags) +safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz, + long, msgtype, int, flags) +safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops, + unsigned, nsops, const struct timespec *, timeout) +#else +/* + * This host kernel architecture uses a single ipc syscall; fake up + * wrappers for the sub-operations to hide this implementation detail. + * Annoyingly we can't include linux/ipc.h to get the constant definitions + * for the call parameter because some structs in there conflict with the + * sys/ipc.h ones. So we just define them here, and rely on them being + * the same for all host architectures. + */ +#define Q_SEMTIMEDOP 4 +#define Q_MSGSND 11 +#define Q_MSGRCV 12 +#define Q_IPCCALL(VERSION, OP) ((VERSION) << 16 | (OP)) + +safe_syscall6(int, ipc, int, call, long, first, long, second, long, third, + void *, ptr, long, fifth) + +static int safe_msgsnd(int msgid, const void *msgp, size_t sz, int flags) +{ + return safe_ipc(Q_IPCCALL(0, Q_MSGSND), msgid, sz, flags, (void *)msgp, 0); +} + +static int safe_msgrcv(int msgid, void *msgp, size_t sz, long type, int flags) +{ + return safe_ipc(Q_IPCCALL(1, Q_MSGRCV), msgid, sz, flags, msgp, type); +} + +static int safe_semtimedop(int semid, struct sembuf *tsops, unsigned nsops, + const struct timespec *timeout) +{ + return safe_ipc(Q_IPCCALL(0, Q_SEMTIMEDOP), semid, nsops, 0, tsops, + (long)timeout); +} +#endif + +/* See comment above. */ +#define SEMOPM 500 + +#define N_SHM_REGIONS 32 + +static struct shm_region { + abi_ulong start; + abi_ulong size; + bool in_use; +} shm_regions[N_SHM_REGIONS]; + +#ifndef TARGET_SEMID64_DS +/* asm-generic version of this struct */ +struct target_semid64_ds { + struct target_ipc_perm sem_perm; + abi_ulong sem_otime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused1; +#endif + abi_ulong sem_ctime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused2; +#endif + abi_ulong sem_nsems; + abi_ulong __unused3; + abi_ulong __unused4; +}; +#endif + +static abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, + abi_ulong target_addr) +{ + struct target_ipc_perm *target_ip; + struct target_semid64_ds *target_sd; + + if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) { + return -TARGET_EFAULT; + } + target_ip = &target_sd->sem_perm; + host_ip->__key = tswap32(target_ip->__key); + host_ip->uid = tswap32(target_ip->uid); + host_ip->gid = tswap32(target_ip->gid); + host_ip->cuid = tswap32(target_ip->cuid); + host_ip->cgid = tswap32(target_ip->cgid); +#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_PPC) + host_ip->mode = tswap32(target_ip->mode); +#else + host_ip->mode = tswap16(target_ip->mode); +#endif +#if defined(TARGET_PPC) + host_ip->__seq = tswap32(target_ip->__seq); +#else + host_ip->__seq = tswap16(target_ip->__seq); +#endif + unlock_user_struct(target_sd, target_addr, 0); + return 0; +} + +static abi_long host_to_target_ipc_perm(abi_ulong target_addr, + struct ipc_perm *host_ip) +{ + struct target_ipc_perm *target_ip; + struct target_semid64_ds *target_sd; + + if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) { + return -TARGET_EFAULT; + } + target_ip = &target_sd->sem_perm; + target_ip->__key = tswap32(host_ip->__key); + target_ip->uid = tswap32(host_ip->uid); + target_ip->gid = tswap32(host_ip->gid); + target_ip->cuid = tswap32(host_ip->cuid); + target_ip->cgid = tswap32(host_ip->cgid); +#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_PPC) + target_ip->mode = tswap32(host_ip->mode); +#else + target_ip->mode = tswap16(host_ip->mode); +#endif +#if defined(TARGET_PPC) + target_ip->__seq = tswap32(host_ip->__seq); +#else + target_ip->__seq = tswap16(host_ip->__seq); +#endif + unlock_user_struct(target_sd, target_addr, 1); + return 0; +} + +static abi_long target_to_host_semid_ds(struct semid_ds *host_sd, + abi_ulong target_addr) +{ + struct target_semid64_ds *target_sd; + + if (target_to_host_ipc_perm(&host_sd->sem_perm, target_addr)) { + return -TARGET_EFAULT; + } + if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) { + return -TARGET_EFAULT; + } + host_sd->sem_nsems = tswapal(target_sd->sem_nsems); + host_sd->sem_otime = tswapal(target_sd->sem_otime); + host_sd->sem_ctime = tswapal(target_sd->sem_ctime); + unlock_user_struct(target_sd, target_addr, 0); + return 0; +} + +static abi_long host_to_target_semid_ds(abi_ulong target_addr, + struct semid_ds *host_sd) +{ + struct target_semid64_ds *target_sd; + + if (host_to_target_ipc_perm(target_addr, &host_sd->sem_perm)) { + return -TARGET_EFAULT; + } + if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) { + return -TARGET_EFAULT; + } + target_sd->sem_nsems = tswapal(host_sd->sem_nsems); + target_sd->sem_otime = tswapal(host_sd->sem_otime); + target_sd->sem_ctime = tswapal(host_sd->sem_ctime); + unlock_user_struct(target_sd, target_addr, 1); + return 0; +} + +struct target_seminfo { + int semmap; + int semmni; + int semmns; + int semmnu; + int semmsl; + int semopm; + int semume; + int semusz; + int semvmx; + int semaem; +}; + +static abi_long host_to_target_seminfo(abi_ulong target_addr, + struct seminfo *host_seminfo) +{ + struct target_seminfo *target_seminfo; + + if (!lock_user_struct(VERIFY_WRITE, target_seminfo, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_seminfo->semmap, &target_seminfo->semmap); + __put_user(host_seminfo->semmni, &target_seminfo->semmni); + __put_user(host_seminfo->semmns, &target_seminfo->semmns); + __put_user(host_seminfo->semmnu, &target_seminfo->semmnu); + __put_user(host_seminfo->semmsl, &target_seminfo->semmsl); + __put_user(host_seminfo->semopm, &target_seminfo->semopm); + __put_user(host_seminfo->semume, &target_seminfo->semume); + __put_user(host_seminfo->semusz, &target_seminfo->semusz); + __put_user(host_seminfo->semvmx, &target_seminfo->semvmx); + __put_user(host_seminfo->semaem, &target_seminfo->semaem); + unlock_user_struct(target_seminfo, target_addr, 1); + return 0; +} + +union semun { + int val; + struct semid_ds *buf; + unsigned short *array; + struct seminfo *__buf; +}; + +union target_semun { + int val; + abi_ulong buf; + abi_ulong array; + abi_ulong __buf; +}; + +static abi_long target_to_host_semarray(int semid, + unsigned short **host_array, + abi_ulong target_addr) +{ + int nsems; + unsigned short *array; + union semun semun; + struct semid_ds semid_ds; + int i, ret; + + semun.buf = &semid_ds; + + ret = semctl(semid, 0, IPC_STAT, semun); + if (ret == -1) { + return get_errno(ret); + } + + nsems = semid_ds.sem_nsems; + + *host_array = g_try_new(unsigned short, nsems); + if (!*host_array) { + return -TARGET_ENOMEM; + } + array = lock_user(VERIFY_READ, target_addr, + nsems * sizeof(unsigned short), 1); + if (!array) { + g_free(*host_array); + return -TARGET_EFAULT; + } + for (i = 0; i < nsems; i++) { + __get_user((*host_array)[i], &array[i]); + } + unlock_user(array, target_addr, 0); + + return 0; +} + +static abi_long host_to_target_semarray(int semid, abi_ulong target_addr, + unsigned short **host_array) +{ + int nsems; + unsigned short *array; + union semun semun; + struct semid_ds semid_ds; + int i, ret; + + semun.buf = &semid_ds; + + ret = semctl(semid, 0, IPC_STAT, semun); + if (ret == -1) { + return get_errno(ret); + } + + nsems = semid_ds.sem_nsems; + + array = lock_user(VERIFY_WRITE, target_addr, + nsems * sizeof(unsigned short), 0); + if (!array) { + return -TARGET_EFAULT; + } + for (i = 0; i < nsems; i++) { + __put_user((*host_array)[i], &array[i]); + } + g_free(*host_array); + unlock_user(array, target_addr, 1); + + return 0; +} + +struct target_sembuf { + unsigned short sem_num; + short sem_op; + short sem_flg; +}; + +static abi_long target_to_host_sembuf(struct sembuf *host_sembuf, + abi_ulong target_addr, + unsigned nsops) +{ + struct target_sembuf *target_sembuf; + int i; + + target_sembuf = lock_user(VERIFY_READ, target_addr, + nsops * sizeof(struct target_sembuf), 1); + if (!target_sembuf) { + return -TARGET_EFAULT; + } + for (i = 0; i < nsops; i++) { + __get_user(host_sembuf[i].sem_num, &target_sembuf[i].sem_num); + __get_user(host_sembuf[i].sem_op, &target_sembuf[i].sem_op); + __get_user(host_sembuf[i].sem_flg, &target_sembuf[i].sem_flg); + } + unlock_user(target_sembuf, target_addr, 0); + return 0; +} + +struct target_msqid_ds { + struct target_ipc_perm msg_perm; + abi_ulong msg_stime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused1; +#endif + abi_ulong msg_rtime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused2; +#endif + abi_ulong msg_ctime; +#if TARGET_ABI_BITS == 32 + abi_ulong __unused3; +#endif + abi_ulong __msg_cbytes; + abi_ulong msg_qnum; + abi_ulong msg_qbytes; + abi_ulong msg_lspid; + abi_ulong msg_lrpid; + abi_ulong __unused4; + abi_ulong __unused5; +}; + +static abi_long target_to_host_msqid_ds(struct msqid_ds *host_md, + abi_ulong target_addr) +{ + struct target_msqid_ds *target_md; + + if (target_to_host_ipc_perm(&host_md->msg_perm, target_addr)) { + return -TARGET_EFAULT; + } + if (!lock_user_struct(VERIFY_READ, target_md, target_addr, 1)) { + return -TARGET_EFAULT; + } + host_md->msg_stime = tswapal(target_md->msg_stime); + host_md->msg_rtime = tswapal(target_md->msg_rtime); + host_md->msg_ctime = tswapal(target_md->msg_ctime); + host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes); + host_md->msg_qnum = tswapal(target_md->msg_qnum); + host_md->msg_qbytes = tswapal(target_md->msg_qbytes); + host_md->msg_lspid = tswapal(target_md->msg_lspid); + host_md->msg_lrpid = tswapal(target_md->msg_lrpid); + unlock_user_struct(target_md, target_addr, 0); + return 0; +} + +static abi_long host_to_target_msqid_ds(abi_ulong target_addr, + struct msqid_ds *host_md) +{ + struct target_msqid_ds *target_md; + + if (host_to_target_ipc_perm(target_addr, &host_md->msg_perm)) { + return -TARGET_EFAULT; + } + if (!lock_user_struct(VERIFY_WRITE, target_md, target_addr, 0)) { + return -TARGET_EFAULT; + } + target_md->msg_stime = tswapal(host_md->msg_stime); + target_md->msg_rtime = tswapal(host_md->msg_rtime); + target_md->msg_ctime = tswapal(host_md->msg_ctime); + target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes); + target_md->msg_qnum = tswapal(host_md->msg_qnum); + target_md->msg_qbytes = tswapal(host_md->msg_qbytes); + target_md->msg_lspid = tswapal(host_md->msg_lspid); + target_md->msg_lrpid = tswapal(host_md->msg_lrpid); + unlock_user_struct(target_md, target_addr, 1); + return 0; +} + +struct target_msginfo { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + unsigned short int msgseg; +}; + +static abi_long host_to_target_msginfo(abi_ulong target_addr, + struct msginfo *host_msginfo) +{ + struct target_msginfo *target_msginfo; + + if (!lock_user_struct(VERIFY_WRITE, target_msginfo, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_msginfo->msgpool, &target_msginfo->msgpool); + __put_user(host_msginfo->msgmap, &target_msginfo->msgmap); + __put_user(host_msginfo->msgmax, &target_msginfo->msgmax); + __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb); + __put_user(host_msginfo->msgmni, &target_msginfo->msgmni); + __put_user(host_msginfo->msgssz, &target_msginfo->msgssz); + __put_user(host_msginfo->msgtql, &target_msginfo->msgtql); + __put_user(host_msginfo->msgseg, &target_msginfo->msgseg); + unlock_user_struct(target_msginfo, target_addr, 1); + return 0; +} + +struct target_msgbuf { + abi_long mtype; + char mtext[1]; +}; + +static abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd, + abi_ulong target_addr) +{ + struct target_shmid_ds *target_sd; + + if (target_to_host_ipc_perm(&host_sd->shm_perm, target_addr)) { + return -TARGET_EFAULT; + } + if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) { + return -TARGET_EFAULT; + } + __get_user(host_sd->shm_segsz, &target_sd->shm_segsz); + __get_user(host_sd->shm_atime, &target_sd->shm_atime); + __get_user(host_sd->shm_dtime, &target_sd->shm_dtime); + __get_user(host_sd->shm_ctime, &target_sd->shm_ctime); + __get_user(host_sd->shm_cpid, &target_sd->shm_cpid); + __get_user(host_sd->shm_lpid, &target_sd->shm_lpid); + __get_user(host_sd->shm_nattch, &target_sd->shm_nattch); + unlock_user_struct(target_sd, target_addr, 0); + return 0; +} + +static abi_long host_to_target_shmid_ds(abi_ulong target_addr, + struct shmid_ds *host_sd) +{ + struct target_shmid_ds *target_sd; + + if (host_to_target_ipc_perm(target_addr, &host_sd->shm_perm)) { + return -TARGET_EFAULT; + } + if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_sd->shm_segsz, &target_sd->shm_segsz); + __put_user(host_sd->shm_atime, &target_sd->shm_atime); + __put_user(host_sd->shm_dtime, &target_sd->shm_dtime); + __put_user(host_sd->shm_ctime, &target_sd->shm_ctime); + __put_user(host_sd->shm_cpid, &target_sd->shm_cpid); + __put_user(host_sd->shm_lpid, &target_sd->shm_lpid); + __put_user(host_sd->shm_nattch, &target_sd->shm_nattch); + unlock_user_struct(target_sd, target_addr, 1); + return 0; +} + +struct target_shminfo { + abi_ulong shmmax; + abi_ulong shmmin; + abi_ulong shmmni; + abi_ulong shmseg; + abi_ulong shmall; +}; + +static abi_long host_to_target_shminfo(abi_ulong target_addr, + struct shminfo *host_shminfo) +{ + struct target_shminfo *target_shminfo; + + if (!lock_user_struct(VERIFY_WRITE, target_shminfo, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_shminfo->shmmax, &target_shminfo->shmmax); + __put_user(host_shminfo->shmmin, &target_shminfo->shmmin); + __put_user(host_shminfo->shmmni, &target_shminfo->shmmni); + __put_user(host_shminfo->shmseg, &target_shminfo->shmseg); + __put_user(host_shminfo->shmall, &target_shminfo->shmall); + unlock_user_struct(target_shminfo, target_addr, 1); + return 0; +} + +struct target_shm_info { + int used_ids; + abi_ulong shm_tot; + abi_ulong shm_rss; + abi_ulong shm_swp; + abi_ulong swap_attempts; + abi_ulong swap_successes; +}; + +static abi_long host_to_target_shm_info(abi_ulong target_addr, + struct shm_info *host_shm_info) +{ + struct target_shm_info *target_shm_info; + + if (!lock_user_struct(VERIFY_WRITE, target_shm_info, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(host_shm_info->used_ids, &target_shm_info->used_ids); + __put_user(host_shm_info->shm_tot, &target_shm_info->shm_tot); + __put_user(host_shm_info->shm_rss, &target_shm_info->shm_rss); + __put_user(host_shm_info->shm_swp, &target_shm_info->shm_swp); + __put_user(host_shm_info->swap_attempts, + &target_shm_info->swap_attempts); + __put_user(host_shm_info->swap_successes, + &target_shm_info->swap_successes); + unlock_user_struct(target_shm_info, target_addr, 1); + return 0; +} + +#ifndef TARGET_FORCE_SHMLBA +/* + * For most architectures, SHMLBA is the same as the page size; + * some architectures have larger values, in which case they should + * define TARGET_FORCE_SHMLBA and provide a target_shmlba() function. + * This corresponds to the kernel arch code defining __ARCH_FORCE_SHMLBA + * and defining its own value for SHMLBA. + * + * The kernel also permits SHMLBA to be set by the architecture to a + * value larger than the page size without setting __ARCH_FORCE_SHMLBA; + * this means that addresses are rounded to the large size if + * SHM_RND is set but addresses not aligned to that size are not rejected + * as long as they are at least page-aligned. Since the only architecture + * which uses this is ia64 this code doesn't provide for that oddity. + */ +static abi_ulong target_shmlba(CPUArchState *cpu_env) +{ + return TARGET_PAGE_SIZE; +} +#endif + + +SYSCALL_IMPL(msgctl) +{ + abi_long msgid = arg1; + int cmd = arg2 & 0xff; + abi_ulong ptr = arg3; + struct msqid_ds dsarg; + struct msginfo msginfo; + abi_long ret; + + switch (cmd) { + case IPC_STAT: + case IPC_SET: + case MSG_STAT: + if (target_to_host_msqid_ds(&dsarg, ptr)) { + return -TARGET_EFAULT; + } + ret = get_errno(msgctl(msgid, cmd, &dsarg)); + if (!is_error(ret) && host_to_target_msqid_ds(ptr, &dsarg)) { + return -TARGET_EFAULT; + } + return ret; + + case IPC_RMID: + return get_errno(msgctl(msgid, cmd, NULL)); + + case IPC_INFO: + case MSG_INFO: + ret = get_errno(msgctl(msgid, cmd, (struct msqid_ds *)&msginfo)); + if (host_to_target_msginfo(ptr, &msginfo)) { + return -TARGET_EFAULT; + } + return ret; + + default: + return -TARGET_EINVAL; + } +} + +SYSCALL_IMPL(msgget) +{ + return get_errno(msgget(arg1, arg2)); +} + +SYSCALL_IMPL(msgrcv) +{ + int msqid = arg1; + abi_ulong msgp = arg2; + abi_long msgsz = arg3; + abi_long msgtyp = arg4; + int msgflg = arg5; + struct target_msgbuf *target_mb; + char *target_mtext; + struct msgbuf *host_mb; + abi_long ret = 0; + + if (msgsz < 0) { + return -TARGET_EINVAL; + } + if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0)) { + return -TARGET_EFAULT; + } + + host_mb = g_try_malloc(msgsz + sizeof(long)); + if (!host_mb) { + ret = -TARGET_ENOMEM; + goto end; + } + ret = get_errno(safe_msgrcv(msqid, host_mb, msgsz, msgtyp, msgflg)); + + if (ret > 0) { + abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong); + target_mtext = lock_user(VERIFY_WRITE, target_mtext_addr, ret, 0); + if (!target_mtext) { + ret = -TARGET_EFAULT; + goto end; + } + memcpy(target_mb->mtext, host_mb->mtext, ret); + unlock_user(target_mtext, target_mtext_addr, ret); + } + target_mb->mtype = tswapal(host_mb->mtype); + + end: + unlock_user_struct(target_mb, msgp, 1); + g_free(host_mb); + return ret; +} + +SYSCALL_IMPL(msgsnd) +{ + int msqid = arg1; + abi_ulong msgp = arg2; + abi_long msgsz = arg3; + int msgflg = arg4; + struct target_msgbuf *target_mb; + struct msgbuf *host_mb; + abi_long ret = 0; + + if (msgsz < 0) { + return -TARGET_EINVAL; + } + if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0)) { + return -TARGET_EFAULT; + } + host_mb = g_try_malloc(msgsz + sizeof(long)); + if (!host_mb) { + unlock_user_struct(target_mb, msgp, 0); + return -TARGET_ENOMEM; + } + + host_mb->mtype = (abi_long)tswapal(target_mb->mtype); + memcpy(host_mb->mtext, target_mb->mtext, msgsz); + ret = get_errno(safe_msgsnd(msqid, host_mb, msgsz, msgflg)); + + g_free(host_mb); + unlock_user_struct(target_mb, msgp, 0); + return ret; +} + +SYSCALL_IMPL(semctl) +{ + abi_long semid = arg1; + abi_long semnum = arg2; + int cmd = arg3 & 0xff; + abi_ulong target_arg = arg4; + union target_semun target_su = { .buf = target_arg }; + union semun arg; + struct semid_ds dsarg; + unsigned short *array = NULL; + struct seminfo seminfo; + abi_long ret, err; + + switch (cmd) { + case GETVAL: + case SETVAL: + /* + * In 64 bit cross-endian situations, we will erroneously pick up + * the wrong half of the union for the "val" element. To rectify + * this, the entire 8-byte structure is byteswapped, followed by + * a swap of the 4 byte val field. In other cases, the data is + * already in proper host byte order. + */ + if (sizeof(target_su.val) != sizeof(target_su.buf)) { + target_su.buf = tswapal(target_su.buf); + arg.val = tswap32(target_su.val); + } else { + arg.val = target_su.val; + } + return get_errno(semctl(semid, semnum, cmd, arg)); + + case GETALL: + case SETALL: + err = target_to_host_semarray(semid, &array, target_su.array); + if (err) { + return err; + } + arg.array = array; + ret = get_errno(semctl(semid, semnum, cmd, arg)); + if (!is_error(ret)) { + err = host_to_target_semarray(semid, target_su.array, &array); + if (err) { + return err; + } + } + return ret; + + case IPC_STAT: + case IPC_SET: + case SEM_STAT: + err = target_to_host_semid_ds(&dsarg, target_su.buf); + if (err) { + return err; + } + arg.buf = &dsarg; + ret = get_errno(semctl(semid, semnum, cmd, arg)); + if (!is_error(ret)) { + err = host_to_target_semid_ds(target_su.buf, &dsarg); + if (err) { + return err; + } + } + return ret; + + case IPC_INFO: + case SEM_INFO: + arg.__buf = &seminfo; + ret = get_errno(semctl(semid, semnum, cmd, arg)); + if (!is_error(ret)) { + err = host_to_target_seminfo(target_su.__buf, &seminfo); + if (err) { + return err; + } + } + return ret; + + case IPC_RMID: + case GETPID: + case GETNCNT: + case GETZCNT: + return get_errno(semctl(semid, semnum, cmd, NULL)); + + default: + return -TARGET_EINVAL; + } +} + +SYSCALL_IMPL(semget) +{ + return get_errno(semget(arg1, arg2, arg3)); +} + +SYSCALL_IMPL(semop) +{ + abi_long semid = arg1; + abi_ulong ptr = arg2; + abi_ulong nsops = arg3; + struct sembuf sops[SEMOPM]; + + if (nsops > SEMOPM) { + return -TARGET_E2BIG; + } + if (target_to_host_sembuf(sops, ptr, nsops)) { + return -TARGET_EFAULT; + } + return get_errno(safe_semtimedop(semid, sops, nsops, NULL)); +} + +SYSCALL_IMPL(shmat) +{ + int shmid = arg1; + abi_ulong shmaddr = arg2; + int shmflg = arg3; + abi_ulong raddr; + void *host_raddr; + struct shmid_ds shm_info; + int i, ret; + abi_ulong shmlba; + + /* Find out the length of the shared memory segment. */ + ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info)); + if (is_error(ret)) { + /* can't get length, bail out */ + return ret; + } + + /* Validate memory placement and alignment for the guest. */ + shmlba = target_shmlba(cpu_env); + if (shmaddr & (shmlba - 1)) { + if (shmflg & SHM_RND) { + shmaddr &= ~(shmlba - 1); + } else { + return -TARGET_EINVAL; + } + } + if (!guest_range_valid(shmaddr, shm_info.shm_segsz)) { + return -TARGET_EINVAL; + } + + mmap_lock(); + + if (shmaddr) { + host_raddr = shmat(shmid, (void *)g2h(shmaddr), shmflg); + } else { + /* In order to use the host shmat, we need to honor host SHMLBA. */ + abi_ulong mmap_start = mmap_find_vma(0, shm_info.shm_segsz, + MAX(SHMLBA, shmlba)); + if (mmap_start == -1) { + errno = ENOMEM; + host_raddr = (void *)-1; + } else { + host_raddr = shmat(shmid, g2h(mmap_start), shmflg | SHM_REMAP); + } + } + if (host_raddr == (void *)-1) { + mmap_unlock(); + return get_errno((intptr_t)host_raddr); + } + + raddr = h2g((uintptr_t)host_raddr); + page_set_flags(raddr, raddr + shm_info.shm_segsz, + PAGE_VALID | PAGE_READ | + (shmflg & SHM_RDONLY ? 0 : PAGE_WRITE)); + + for (i = 0; i < N_SHM_REGIONS; i++) { + if (!shm_regions[i].in_use) { + shm_regions[i].in_use = true; + shm_regions[i].start = raddr; + shm_regions[i].size = shm_info.shm_segsz; + break; + } + } + mmap_unlock(); + return raddr; +} + +SYSCALL_IMPL(shmctl) +{ + int shmid = arg1; + int cmd = arg2 & 0xff; + abi_ulong buf = arg3; + struct shmid_ds dsarg; + struct shminfo shminfo; + struct shm_info shm_info; + abi_long ret; + + switch (cmd) { + case IPC_STAT: + case IPC_SET: + case SHM_STAT: + if (target_to_host_shmid_ds(&dsarg, buf)) { + return -TARGET_EFAULT; + } + ret = get_errno(shmctl(shmid, cmd, &dsarg)); + if (!is_error(ret) && host_to_target_shmid_ds(buf, &dsarg)) { + return -TARGET_EFAULT; + } + return ret; + + case IPC_INFO: + ret = get_errno(shmctl(shmid, cmd, (struct shmid_ds *)&shminfo)); + if (!is_error(ret) && host_to_target_shminfo(buf, &shminfo)) { + return -TARGET_EFAULT; + } + return ret; + + case SHM_INFO: + ret = get_errno(shmctl(shmid, cmd, (struct shmid_ds *)&shm_info)); + if (!is_error(ret) && host_to_target_shm_info(buf, &shm_info)) { + return -TARGET_EFAULT; + } + return ret; + + case IPC_RMID: + case SHM_LOCK: + case SHM_UNLOCK: + return get_errno(shmctl(shmid, cmd, NULL)); + + default: + return -TARGET_EINVAL; + } +} + +SYSCALL_IMPL(shmdt) +{ + abi_ulong shmaddr = arg1; + abi_long ret; + int i; + + mmap_lock(); + + for (i = 0; i < N_SHM_REGIONS; ++i) { + if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { + shm_regions[i].in_use = false; + page_set_flags(shmaddr, shmaddr + shm_regions[i].size, 0); + break; + } + } + ret = get_errno(shmdt(g2h(shmaddr))); + + mmap_unlock(); + + return ret; +} + +SYSCALL_IMPL(shmget) +{ + return get_errno(shmget(arg1, arg2, arg3)); +} + +#ifdef TARGET_NR_ipc +/* + * This differs from normal shmat in returning the result via a pointer. + * Here we have shifted that pointer to arg4. + */ +SYSCALL_IMPL(ipc_shmat) +{ + abi_long ret = impl_shmat(cpu_env, arg1, arg2, arg3, 0, 0, 0); + + if (is_error(ret)) { + return ret; + } + if (put_user_ual(ret, arg4)) { + return -TARGET_EFAULT; + } + return 0; +} + +static const SyscallDef def_ipc_shmat = { + .name = "shmat", + .impl = impl_ipc_shmat, + .arg_type = { ARG_DEC, ARG_PTR, ARG_HEX, ARG_PTR }, +}; + +/* These get defined later via syscall-defs.h. */ +static const SyscallDef def_semop; +static const SyscallDef def_semget; +static const SyscallDef def_semctl; +static const SyscallDef def_msgget; +static const SyscallDef def_msgsnd; +static const SyscallDef def_msgctl; +static const SyscallDef def_msgrcv; +static const SyscallDef def_shmdt; +static const SyscallDef def_shmget; +static const SyscallDef def_shmctl; + +/* + * Demultiplex the IPC syscall and shuffle the arguments around + * into the "normal" ordering. + */ +SYSCALL_ARGS(ipc) +{ + int call = extract32(in[0], 0, 16); + int version = extract32(in[0], 16, 16); + abi_long first = in[1]; + abi_long second = in[2]; + abi_long third = in[3]; + abi_ulong ptr = in[4]; + abi_long fifth = in[5]; + abi_ulong atptr; + + /* IPC_* and SHM_* command values are the same on all linux platforms */ + switch (call) { + case IPCOP_semop: + out[0] = first; + out[1] = ptr; + out[2] = second; + return &def_semop; + + case IPCOP_semget: + out[0] = first; + out[1] = second; + out[2] = third; + return &def_semget; + + case IPCOP_semctl: + /* + * The semun argument to semctl is passed by value, + * so dereference the ptr argument. + */ + if (get_user_ual(atptr, ptr)) { + errno = EFAULT; + return NULL; + } + out[0] = first; + out[1] = second; + out[2] = third; + out[3] = atptr; + return &def_semctl; + + case IPCOP_msgget: + out[0] = first; + out[1] = second; + return &def_msgget; + + case IPCOP_msgsnd: + out[0] = first; + out[1] = ptr; + out[2] = second; + out[3] = third; + return &def_msgsnd; + + case IPCOP_msgctl: + out[0] = first; + out[1] = second; + out[2] = ptr; + return &def_msgctl; + + case IPCOP_msgrcv: + if (version == 0) { + struct target_ipc_kludge { + abi_long msgp; + abi_long msgtyp; + } *tmp; + + if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) { + errno = EFAULT; + return NULL; + } + out[0] = first; + out[1] = tswapal(tmp->msgp); + out[2] = second; + out[3] = tswapal(tmp->msgtyp); + out[4] = third; + unlock_user_struct(tmp, ptr, 0); + } else { + out[0] = first; + out[1] = ptr; + out[2] = second; + out[3] = fifth; + out[4] = third; + } + return &def_msgrcv; + + case IPCOP_shmat: + if (version == 1) { + errno = EINVAL; + return NULL; + } + out[0] = first; + out[1] = ptr; + out[2] = second; + out[3] = third; + return &def_ipc_shmat; + + case IPCOP_shmdt: + out[0] = ptr; + return &def_shmdt; + + case IPCOP_shmget: + out[0] = first; + out[1] = second; + out[2] = third; + return &def_shmget; + + case IPCOP_shmctl: + out[0] = first; + out[1] = second; + out[2] = ptr; + return &def_shmctl; + + default: + /* Invalid syscall. Continue to impl_ipc for logging. */ + return def; + } +} + +SYSCALL_IMPL(ipc) +{ + int call = extract32(arg1, 0, 16); + int version = extract32(arg1, 16, 16); + + gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); + return -TARGET_ENOSYS; +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c49f8aebd2..ca345ffb4c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -763,43 +763,6 @@ safe_syscall2(int, nanosleep, const struct timespec *, req, safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags, const struct timespec *, req, struct timespec *, rem) #endif -#ifdef __NR_msgsnd -safe_syscall4(int, msgsnd, int, msgid, const void *, msgp, size_t, sz, - int, flags) -safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz, - long, msgtype, int, flags) -safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops, - unsigned, nsops, const struct timespec *, timeout) -#else -/* This host kernel architecture uses a single ipc syscall; fake up - * wrappers for the sub-operations to hide this implementation detail. - * Annoyingly we can't include linux/ipc.h to get the constant definitions - * for the call parameter because some structs in there conflict with the - * sys/ipc.h ones. So we just define them here, and rely on them being - * the same for all host architectures. - */ -#define Q_SEMTIMEDOP 4 -#define Q_MSGSND 11 -#define Q_MSGRCV 12 -#define Q_IPCCALL(VERSION, OP) ((VERSION) << 16 | (OP)) - -safe_syscall6(int, ipc, int, call, long, first, long, second, long, third, - void *, ptr, long, fifth) -static int safe_msgsnd(int msgid, const void *msgp, size_t sz, int flags) -{ - return safe_ipc(Q_IPCCALL(0, Q_MSGSND), msgid, sz, flags, (void *)msgp, 0); -} -static int safe_msgrcv(int msgid, void *msgp, size_t sz, long type, int flags) -{ - return safe_ipc(Q_IPCCALL(1, Q_MSGRCV), msgid, sz, flags, msgp, type); -} -static int safe_semtimedop(int semid, struct sembuf *tsops, unsigned nsops, - const struct timespec *timeout) -{ - return safe_ipc(Q_IPCCALL(0, Q_SEMTIMEDOP), semid, nsops, 0, tsops, - (long)timeout); -} -#endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, size_t, len, unsigned, prio, const struct timespec *, timeout) @@ -3178,891 +3141,6 @@ static abi_long do_socketcall(int num, abi_ulong vptr) } #endif -#define N_SHM_REGIONS 32 - -static struct shm_region { - abi_ulong start; - abi_ulong size; - bool in_use; -} shm_regions[N_SHM_REGIONS]; - -#ifndef TARGET_SEMID64_DS -/* asm-generic version of this struct */ -struct target_semid64_ds -{ - struct target_ipc_perm sem_perm; - abi_ulong sem_otime; -#if TARGET_ABI_BITS == 32 - abi_ulong __unused1; -#endif - abi_ulong sem_ctime; -#if TARGET_ABI_BITS == 32 - abi_ulong __unused2; -#endif - abi_ulong sem_nsems; - abi_ulong __unused3; - abi_ulong __unused4; -}; -#endif - -static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, - abi_ulong target_addr) -{ - struct target_ipc_perm *target_ip; - struct target_semid64_ds *target_sd; - - if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) - return -TARGET_EFAULT; - target_ip = &(target_sd->sem_perm); - host_ip->__key = tswap32(target_ip->__key); - host_ip->uid = tswap32(target_ip->uid); - host_ip->gid = tswap32(target_ip->gid); - host_ip->cuid = tswap32(target_ip->cuid); - host_ip->cgid = tswap32(target_ip->cgid); -#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_PPC) - host_ip->mode = tswap32(target_ip->mode); -#else - host_ip->mode = tswap16(target_ip->mode); -#endif -#if defined(TARGET_PPC) - host_ip->__seq = tswap32(target_ip->__seq); -#else - host_ip->__seq = tswap16(target_ip->__seq); -#endif - unlock_user_struct(target_sd, target_addr, 0); - return 0; -} - -static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr, - struct ipc_perm *host_ip) -{ - struct target_ipc_perm *target_ip; - struct target_semid64_ds *target_sd; - - if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) - return -TARGET_EFAULT; - target_ip = &(target_sd->sem_perm); - target_ip->__key = tswap32(host_ip->__key); - target_ip->uid = tswap32(host_ip->uid); - target_ip->gid = tswap32(host_ip->gid); - target_ip->cuid = tswap32(host_ip->cuid); - target_ip->cgid = tswap32(host_ip->cgid); -#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_PPC) - target_ip->mode = tswap32(host_ip->mode); -#else - target_ip->mode = tswap16(host_ip->mode); -#endif -#if defined(TARGET_PPC) - target_ip->__seq = tswap32(host_ip->__seq); -#else - target_ip->__seq = tswap16(host_ip->__seq); -#endif - unlock_user_struct(target_sd, target_addr, 1); - return 0; -} - -static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd, - abi_ulong target_addr) -{ - struct target_semid64_ds *target_sd; - - if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) - return -TARGET_EFAULT; - if (target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr)) - return -TARGET_EFAULT; - host_sd->sem_nsems = tswapal(target_sd->sem_nsems); - host_sd->sem_otime = tswapal(target_sd->sem_otime); - host_sd->sem_ctime = tswapal(target_sd->sem_ctime); - unlock_user_struct(target_sd, target_addr, 0); - return 0; -} - -static inline abi_long host_to_target_semid_ds(abi_ulong target_addr, - struct semid_ds *host_sd) -{ - struct target_semid64_ds *target_sd; - - if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) - return -TARGET_EFAULT; - if (host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm))) - return -TARGET_EFAULT; - target_sd->sem_nsems = tswapal(host_sd->sem_nsems); - target_sd->sem_otime = tswapal(host_sd->sem_otime); - target_sd->sem_ctime = tswapal(host_sd->sem_ctime); - unlock_user_struct(target_sd, target_addr, 1); - return 0; -} - -struct target_seminfo { - int semmap; - int semmni; - int semmns; - int semmnu; - int semmsl; - int semopm; - int semume; - int semusz; - int semvmx; - int semaem; -}; - -static inline abi_long host_to_target_seminfo(abi_ulong target_addr, - struct seminfo *host_seminfo) -{ - struct target_seminfo *target_seminfo; - if (!lock_user_struct(VERIFY_WRITE, target_seminfo, target_addr, 0)) - return -TARGET_EFAULT; - __put_user(host_seminfo->semmap, &target_seminfo->semmap); - __put_user(host_seminfo->semmni, &target_seminfo->semmni); - __put_user(host_seminfo->semmns, &target_seminfo->semmns); - __put_user(host_seminfo->semmnu, &target_seminfo->semmnu); - __put_user(host_seminfo->semmsl, &target_seminfo->semmsl); - __put_user(host_seminfo->semopm, &target_seminfo->semopm); - __put_user(host_seminfo->semume, &target_seminfo->semume); - __put_user(host_seminfo->semusz, &target_seminfo->semusz); - __put_user(host_seminfo->semvmx, &target_seminfo->semvmx); - __put_user(host_seminfo->semaem, &target_seminfo->semaem); - unlock_user_struct(target_seminfo, target_addr, 1); - return 0; -} - -union semun { - int val; - struct semid_ds *buf; - unsigned short *array; - struct seminfo *__buf; -}; - -union target_semun { - int val; - abi_ulong buf; - abi_ulong array; - abi_ulong __buf; -}; - -static inline abi_long target_to_host_semarray(int semid, unsigned short **host_array, - abi_ulong target_addr) -{ - int nsems; - unsigned short *array; - union semun semun; - struct semid_ds semid_ds; - int i, ret; - - semun.buf = &semid_ds; - - ret = semctl(semid, 0, IPC_STAT, semun); - if (ret == -1) - return get_errno(ret); - - nsems = semid_ds.sem_nsems; - - *host_array = g_try_new(unsigned short, nsems); - if (!*host_array) { - return -TARGET_ENOMEM; - } - array = lock_user(VERIFY_READ, target_addr, - nsems*sizeof(unsigned short), 1); - if (!array) { - g_free(*host_array); - return -TARGET_EFAULT; - } - - for(i=0; imsg_perm),target_addr)) - return -TARGET_EFAULT; - host_md->msg_stime = tswapal(target_md->msg_stime); - host_md->msg_rtime = tswapal(target_md->msg_rtime); - host_md->msg_ctime = tswapal(target_md->msg_ctime); - host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes); - host_md->msg_qnum = tswapal(target_md->msg_qnum); - host_md->msg_qbytes = tswapal(target_md->msg_qbytes); - host_md->msg_lspid = tswapal(target_md->msg_lspid); - host_md->msg_lrpid = tswapal(target_md->msg_lrpid); - unlock_user_struct(target_md, target_addr, 0); - return 0; -} - -static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr, - struct msqid_ds *host_md) -{ - struct target_msqid_ds *target_md; - - if (!lock_user_struct(VERIFY_WRITE, target_md, target_addr, 0)) - return -TARGET_EFAULT; - if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm))) - return -TARGET_EFAULT; - target_md->msg_stime = tswapal(host_md->msg_stime); - target_md->msg_rtime = tswapal(host_md->msg_rtime); - target_md->msg_ctime = tswapal(host_md->msg_ctime); - target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes); - target_md->msg_qnum = tswapal(host_md->msg_qnum); - target_md->msg_qbytes = tswapal(host_md->msg_qbytes); - target_md->msg_lspid = tswapal(host_md->msg_lspid); - target_md->msg_lrpid = tswapal(host_md->msg_lrpid); - unlock_user_struct(target_md, target_addr, 1); - return 0; -} - -struct target_msginfo { - int msgpool; - int msgmap; - int msgmax; - int msgmnb; - int msgmni; - int msgssz; - int msgtql; - unsigned short int msgseg; -}; - -static inline abi_long host_to_target_msginfo(abi_ulong target_addr, - struct msginfo *host_msginfo) -{ - struct target_msginfo *target_msginfo; - if (!lock_user_struct(VERIFY_WRITE, target_msginfo, target_addr, 0)) - return -TARGET_EFAULT; - __put_user(host_msginfo->msgpool, &target_msginfo->msgpool); - __put_user(host_msginfo->msgmap, &target_msginfo->msgmap); - __put_user(host_msginfo->msgmax, &target_msginfo->msgmax); - __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb); - __put_user(host_msginfo->msgmni, &target_msginfo->msgmni); - __put_user(host_msginfo->msgssz, &target_msginfo->msgssz); - __put_user(host_msginfo->msgtql, &target_msginfo->msgtql); - __put_user(host_msginfo->msgseg, &target_msginfo->msgseg); - unlock_user_struct(target_msginfo, target_addr, 1); - return 0; -} - -static inline abi_long do_msgctl(int msgid, int cmd, abi_long ptr) -{ - struct msqid_ds dsarg; - struct msginfo msginfo; - abi_long ret = -TARGET_EINVAL; - - cmd &= 0xff; - - switch (cmd) { - case IPC_STAT: - case IPC_SET: - case MSG_STAT: - if (target_to_host_msqid_ds(&dsarg,ptr)) - return -TARGET_EFAULT; - ret = get_errno(msgctl(msgid, cmd, &dsarg)); - if (host_to_target_msqid_ds(ptr,&dsarg)) - return -TARGET_EFAULT; - break; - case IPC_RMID: - ret = get_errno(msgctl(msgid, cmd, NULL)); - break; - case IPC_INFO: - case MSG_INFO: - ret = get_errno(msgctl(msgid, cmd, (struct msqid_ds *)&msginfo)); - if (host_to_target_msginfo(ptr, &msginfo)) - return -TARGET_EFAULT; - break; - } - - return ret; -} - -struct target_msgbuf { - abi_long mtype; - char mtext[1]; -}; - -static inline abi_long do_msgsnd(int msqid, abi_long msgp, - ssize_t msgsz, int msgflg) -{ - struct target_msgbuf *target_mb; - struct msgbuf *host_mb; - abi_long ret = 0; - - if (msgsz < 0) { - return -TARGET_EINVAL; - } - - if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0)) - return -TARGET_EFAULT; - host_mb = g_try_malloc(msgsz + sizeof(long)); - if (!host_mb) { - unlock_user_struct(target_mb, msgp, 0); - return -TARGET_ENOMEM; - } - host_mb->mtype = (abi_long) tswapal(target_mb->mtype); - memcpy(host_mb->mtext, target_mb->mtext, msgsz); - ret = get_errno(safe_msgsnd(msqid, host_mb, msgsz, msgflg)); - g_free(host_mb); - unlock_user_struct(target_mb, msgp, 0); - - return ret; -} - -static inline abi_long do_msgrcv(int msqid, abi_long msgp, - ssize_t msgsz, abi_long msgtyp, - int msgflg) -{ - struct target_msgbuf *target_mb; - char *target_mtext; - struct msgbuf *host_mb; - abi_long ret = 0; - - if (msgsz < 0) { - return -TARGET_EINVAL; - } - - if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0)) - return -TARGET_EFAULT; - - host_mb = g_try_malloc(msgsz + sizeof(long)); - if (!host_mb) { - ret = -TARGET_ENOMEM; - goto end; - } - ret = get_errno(safe_msgrcv(msqid, host_mb, msgsz, msgtyp, msgflg)); - - if (ret > 0) { - abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong); - target_mtext = lock_user(VERIFY_WRITE, target_mtext_addr, ret, 0); - if (!target_mtext) { - ret = -TARGET_EFAULT; - goto end; - } - memcpy(target_mb->mtext, host_mb->mtext, ret); - unlock_user(target_mtext, target_mtext_addr, ret); - } - - target_mb->mtype = tswapal(host_mb->mtype); - -end: - if (target_mb) - unlock_user_struct(target_mb, msgp, 1); - g_free(host_mb); - return ret; -} - -static inline abi_long target_to_host_shmid_ds(struct shmid_ds *host_sd, - abi_ulong target_addr) -{ - struct target_shmid_ds *target_sd; - - if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) - return -TARGET_EFAULT; - if (target_to_host_ipc_perm(&(host_sd->shm_perm), target_addr)) - return -TARGET_EFAULT; - __get_user(host_sd->shm_segsz, &target_sd->shm_segsz); - __get_user(host_sd->shm_atime, &target_sd->shm_atime); - __get_user(host_sd->shm_dtime, &target_sd->shm_dtime); - __get_user(host_sd->shm_ctime, &target_sd->shm_ctime); - __get_user(host_sd->shm_cpid, &target_sd->shm_cpid); - __get_user(host_sd->shm_lpid, &target_sd->shm_lpid); - __get_user(host_sd->shm_nattch, &target_sd->shm_nattch); - unlock_user_struct(target_sd, target_addr, 0); - return 0; -} - -static inline abi_long host_to_target_shmid_ds(abi_ulong target_addr, - struct shmid_ds *host_sd) -{ - struct target_shmid_ds *target_sd; - - if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) - return -TARGET_EFAULT; - if (host_to_target_ipc_perm(target_addr, &(host_sd->shm_perm))) - return -TARGET_EFAULT; - __put_user(host_sd->shm_segsz, &target_sd->shm_segsz); - __put_user(host_sd->shm_atime, &target_sd->shm_atime); - __put_user(host_sd->shm_dtime, &target_sd->shm_dtime); - __put_user(host_sd->shm_ctime, &target_sd->shm_ctime); - __put_user(host_sd->shm_cpid, &target_sd->shm_cpid); - __put_user(host_sd->shm_lpid, &target_sd->shm_lpid); - __put_user(host_sd->shm_nattch, &target_sd->shm_nattch); - unlock_user_struct(target_sd, target_addr, 1); - return 0; -} - -struct target_shminfo { - abi_ulong shmmax; - abi_ulong shmmin; - abi_ulong shmmni; - abi_ulong shmseg; - abi_ulong shmall; -}; - -static inline abi_long host_to_target_shminfo(abi_ulong target_addr, - struct shminfo *host_shminfo) -{ - struct target_shminfo *target_shminfo; - if (!lock_user_struct(VERIFY_WRITE, target_shminfo, target_addr, 0)) - return -TARGET_EFAULT; - __put_user(host_shminfo->shmmax, &target_shminfo->shmmax); - __put_user(host_shminfo->shmmin, &target_shminfo->shmmin); - __put_user(host_shminfo->shmmni, &target_shminfo->shmmni); - __put_user(host_shminfo->shmseg, &target_shminfo->shmseg); - __put_user(host_shminfo->shmall, &target_shminfo->shmall); - unlock_user_struct(target_shminfo, target_addr, 1); - return 0; -} - -struct target_shm_info { - int used_ids; - abi_ulong shm_tot; - abi_ulong shm_rss; - abi_ulong shm_swp; - abi_ulong swap_attempts; - abi_ulong swap_successes; -}; - -static inline abi_long host_to_target_shm_info(abi_ulong target_addr, - struct shm_info *host_shm_info) -{ - struct target_shm_info *target_shm_info; - if (!lock_user_struct(VERIFY_WRITE, target_shm_info, target_addr, 0)) - return -TARGET_EFAULT; - __put_user(host_shm_info->used_ids, &target_shm_info->used_ids); - __put_user(host_shm_info->shm_tot, &target_shm_info->shm_tot); - __put_user(host_shm_info->shm_rss, &target_shm_info->shm_rss); - __put_user(host_shm_info->shm_swp, &target_shm_info->shm_swp); - __put_user(host_shm_info->swap_attempts, &target_shm_info->swap_attempts); - __put_user(host_shm_info->swap_successes, &target_shm_info->swap_successes); - unlock_user_struct(target_shm_info, target_addr, 1); - return 0; -} - -static inline abi_long do_shmctl(int shmid, int cmd, abi_long buf) -{ - struct shmid_ds dsarg; - struct shminfo shminfo; - struct shm_info shm_info; - abi_long ret = -TARGET_EINVAL; - - cmd &= 0xff; - - switch(cmd) { - case IPC_STAT: - case IPC_SET: - case SHM_STAT: - if (target_to_host_shmid_ds(&dsarg, buf)) - return -TARGET_EFAULT; - ret = get_errno(shmctl(shmid, cmd, &dsarg)); - if (host_to_target_shmid_ds(buf, &dsarg)) - return -TARGET_EFAULT; - break; - case IPC_INFO: - ret = get_errno(shmctl(shmid, cmd, (struct shmid_ds *)&shminfo)); - if (host_to_target_shminfo(buf, &shminfo)) - return -TARGET_EFAULT; - break; - case SHM_INFO: - ret = get_errno(shmctl(shmid, cmd, (struct shmid_ds *)&shm_info)); - if (host_to_target_shm_info(buf, &shm_info)) - return -TARGET_EFAULT; - break; - case IPC_RMID: - case SHM_LOCK: - case SHM_UNLOCK: - ret = get_errno(shmctl(shmid, cmd, NULL)); - break; - } - - return ret; -} - -#ifndef TARGET_FORCE_SHMLBA -/* For most architectures, SHMLBA is the same as the page size; - * some architectures have larger values, in which case they should - * define TARGET_FORCE_SHMLBA and provide a target_shmlba() function. - * This corresponds to the kernel arch code defining __ARCH_FORCE_SHMLBA - * and defining its own value for SHMLBA. - * - * The kernel also permits SHMLBA to be set by the architecture to a - * value larger than the page size without setting __ARCH_FORCE_SHMLBA; - * this means that addresses are rounded to the large size if - * SHM_RND is set but addresses not aligned to that size are not rejected - * as long as they are at least page-aligned. Since the only architecture - * which uses this is ia64 this code doesn't provide for that oddity. - */ -static inline abi_ulong target_shmlba(CPUArchState *cpu_env) -{ - return TARGET_PAGE_SIZE; -} -#endif - -static inline abi_ulong do_shmat(CPUArchState *cpu_env, - int shmid, abi_ulong shmaddr, int shmflg) -{ - abi_long raddr; - void *host_raddr; - struct shmid_ds shm_info; - int i,ret; - abi_ulong shmlba; - - /* find out the length of the shared memory segment */ - ret = get_errno(shmctl(shmid, IPC_STAT, &shm_info)); - if (is_error(ret)) { - /* can't get length, bail out */ - return ret; - } - - shmlba = target_shmlba(cpu_env); - - if (shmaddr & (shmlba - 1)) { - if (shmflg & SHM_RND) { - shmaddr &= ~(shmlba - 1); - } else { - return -TARGET_EINVAL; - } - } - if (!guest_range_valid(shmaddr, shm_info.shm_segsz)) { - return -TARGET_EINVAL; - } - - mmap_lock(); - - if (shmaddr) - host_raddr = shmat(shmid, (void *)g2h(shmaddr), shmflg); - else { - abi_ulong mmap_start; - - /* In order to use the host shmat, we need to honor host SHMLBA. */ - mmap_start = mmap_find_vma(0, shm_info.shm_segsz, MAX(SHMLBA, shmlba)); - - if (mmap_start == -1) { - errno = ENOMEM; - host_raddr = (void *)-1; - } else - host_raddr = shmat(shmid, g2h(mmap_start), shmflg | SHM_REMAP); - } - - if (host_raddr == (void *)-1) { - mmap_unlock(); - return get_errno((long)host_raddr); - } - raddr=h2g((unsigned long)host_raddr); - - page_set_flags(raddr, raddr + shm_info.shm_segsz, - PAGE_VALID | PAGE_READ | - ((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE)); - - for (i = 0; i < N_SHM_REGIONS; i++) { - if (!shm_regions[i].in_use) { - shm_regions[i].in_use = true; - shm_regions[i].start = raddr; - shm_regions[i].size = shm_info.shm_segsz; - break; - } - } - - mmap_unlock(); - return raddr; - -} - -static inline abi_long do_shmdt(abi_ulong shmaddr) -{ - int i; - abi_long rv; - - mmap_lock(); - - for (i = 0; i < N_SHM_REGIONS; ++i) { - if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { - shm_regions[i].in_use = false; - page_set_flags(shmaddr, shmaddr + shm_regions[i].size, 0); - break; - } - } - rv = get_errno(shmdt(g2h(shmaddr))); - - mmap_unlock(); - - return rv; -} - -#ifdef TARGET_NR_ipc -/* ??? This only works with linear mappings. */ -/* do_ipc() must return target values and target errnos. */ -static abi_long do_ipc(CPUArchState *cpu_env, - unsigned int call, abi_long first, - abi_long second, abi_long third, - abi_long ptr, abi_long fifth) -{ - int version; - abi_long ret = 0; - - version = call >> 16; - call &= 0xffff; - - switch (call) { - case IPCOP_semop: - ret = do_semop(first, ptr, second); - break; - - case IPCOP_semget: - ret = get_errno(semget(first, second, third)); - break; - - case IPCOP_semctl: { - /* The semun argument to semctl is passed by value, so dereference the - * ptr argument. */ - abi_ulong atptr; - get_user_ual(atptr, ptr); - ret = do_semctl(first, second, third, atptr); - break; - } - - case IPCOP_msgget: - ret = get_errno(msgget(first, second)); - break; - - case IPCOP_msgsnd: - ret = do_msgsnd(first, ptr, second, third); - break; - - case IPCOP_msgctl: - ret = do_msgctl(first, second, ptr); - break; - - case IPCOP_msgrcv: - switch (version) { - case 0: - { - struct target_ipc_kludge { - abi_long msgp; - abi_long msgtyp; - } *tmp; - - if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) { - ret = -TARGET_EFAULT; - break; - } - - ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third); - - unlock_user_struct(tmp, ptr, 0); - break; - } - default: - ret = do_msgrcv(first, ptr, second, fifth, third); - } - break; - - case IPCOP_shmat: - switch (version) { - default: - { - abi_ulong raddr; - raddr = do_shmat(cpu_env, first, ptr, second); - if (is_error(raddr)) - return get_errno(raddr); - if (put_user_ual(raddr, third)) - return -TARGET_EFAULT; - break; - } - case 1: - ret = -TARGET_EINVAL; - break; - } - break; - case IPCOP_shmdt: - ret = do_shmdt(ptr); - break; - - case IPCOP_shmget: - /* IPC_* flag values are the same on all linux platforms */ - ret = get_errno(shmget(first, second, third)); - break; - - /* IPC_* and SHM_* command values are the same on all linux platforms */ - case IPCOP_shmctl: - ret = do_shmctl(first, second, ptr); - break; - default: - gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); - ret = -TARGET_ENOSYS; - break; - } - return ret; -} -#endif - /* kernel structure types definitions */ #define STRUCT(name, ...) STRUCT_ ## name, @@ -8451,54 +7529,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } return ret; -#ifdef TARGET_NR_ipc - case TARGET_NR_ipc: - return do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); -#endif -#ifdef TARGET_NR_semget - case TARGET_NR_semget: - return get_errno(semget(arg1, arg2, arg3)); -#endif -#ifdef TARGET_NR_semop - case TARGET_NR_semop: - return do_semop(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_semctl - case TARGET_NR_semctl: - return do_semctl(arg1, arg2, arg3, arg4); -#endif -#ifdef TARGET_NR_msgctl - case TARGET_NR_msgctl: - return do_msgctl(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_msgget - case TARGET_NR_msgget: - return get_errno(msgget(arg1, arg2)); -#endif -#ifdef TARGET_NR_msgrcv - case TARGET_NR_msgrcv: - return do_msgrcv(arg1, arg2, arg3, arg4, arg5); -#endif -#ifdef TARGET_NR_msgsnd - case TARGET_NR_msgsnd: - return do_msgsnd(arg1, arg2, arg3, arg4); -#endif -#ifdef TARGET_NR_shmget - case TARGET_NR_shmget: - return get_errno(shmget(arg1, arg2, arg3)); -#endif -#ifdef TARGET_NR_shmctl - case TARGET_NR_shmctl: - return do_shmctl(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_shmat - case TARGET_NR_shmat: - return do_shmat(cpu_env, arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_shmdt - case TARGET_NR_shmdt: - return do_shmdt(arg1); -#endif case TARGET_NR_fsync: return get_errno(fsync(arg1)); case TARGET_NR_clone: @@ -11061,6 +10091,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int64_t arg5, int64_t arg6) #include "syscall-file.inc.c" +#include "syscall-ipc.inc.c" #undef SYSCALL_IMPL #undef SYSCALL_ARGS @@ -11094,6 +10125,7 @@ static const SyscallDef *syscall_table(int num) #define SYSCALL_DEF(NAME, ...) case TARGET_NR_##NAME: return &def_##NAME #define SYSCALL_DEF_ARGS(NAME, ...) SYSCALL_DEF(NAME) #define SYSCALL_DEF_FULL(NAME, ...) SYSCALL_DEF(NAME) +#define SYSCALL_TABLE switch (num) { #include "syscall-defs.h" @@ -11103,6 +10135,7 @@ static const SyscallDef *syscall_table(int num) #undef SYSCALL_DEF #undef SYSCALL_DEF_ARGS #undef SYSCALL_DEF_FULL +#undef SYSCALL_TABLE } abi_long do_syscall(void *cpu_env, int num, abi_long arg1, diff --git a/linux-user/strace.list b/linux-user/strace.list index bf239cb9a3..f99bd57c09 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -452,9 +452,6 @@ #ifdef TARGET_NR_io_submit { TARGET_NR_io_submit, "io_submit" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_ipc -{ TARGET_NR_ipc, "ipc" , NULL, print_ipc, NULL }, -#endif #ifdef TARGET_NR_kcmp { TARGET_NR_kcmp, "kcmp" , NULL, NULL, NULL }, #endif @@ -608,18 +605,6 @@ #ifdef TARGET_NR_mremap { TARGET_NR_mremap, "mremap" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_msgctl -{ TARGET_NR_msgctl, "msgctl" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_msgget -{ TARGET_NR_msgget, "msgget" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_msgrcv -{ TARGET_NR_msgrcv, "msgrcv" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_msgsnd -{ TARGET_NR_msgsnd, "msgsnd" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_msync { TARGET_NR_msync, "msync" , NULL, NULL, NULL }, #endif @@ -917,9 +902,6 @@ #ifdef TARGET_NR_osf_settimeofday { TARGET_NR_osf_settimeofday, "osf_settimeofday" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_osf_shmat -{ TARGET_NR_osf_shmat, "osf_shmat" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_osf_signal { TARGET_NR_osf_signal, "osf_signal" , NULL, NULL, NULL }, #endif @@ -1184,18 +1166,6 @@ #ifdef TARGET_NR_select { TARGET_NR_select, "select" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_semctl -{ TARGET_NR_semctl, "semctl" , NULL, print_semctl, NULL }, -#endif -#ifdef TARGET_NR_semget -{ TARGET_NR_semget, "semget" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_semop -{ TARGET_NR_semop, "semop" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_semtimedop -{ TARGET_NR_semtimedop, "semtimedop" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_send { TARGET_NR_send, "send" , NULL, NULL, NULL }, #endif @@ -1323,18 +1293,6 @@ #ifdef TARGET_NR_sgetmask { TARGET_NR_sgetmask, "sgetmask" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_shmat -{ TARGET_NR_shmat, "shmat" , NULL, NULL, print_syscall_ret_addr }, -#endif -#ifdef TARGET_NR_shmctl -{ TARGET_NR_shmctl, "shmctl" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_shmdt -{ TARGET_NR_shmdt, "shmdt" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_shmget -{ TARGET_NR_shmget, "shmget" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_shutdown { TARGET_NR_shutdown, "shutdown" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164504 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4785571ili; Sun, 19 May 2019 13:50:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5n4Yzl0GwXkuxk1PAYR2s16pZTYaRMDFk+ISBeZON6lyBUdOzpdXUx84GegliRCFiZ5zN X-Received: by 2002:a17:906:13cb:: with SMTP id g11mr50983549ejc.195.1558299004881; Sun, 19 May 2019 13:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299004; cv=none; d=google.com; s=arc-20160816; b=EmcbCiLTjMdQywJzl6htCG/8swkNu0ckBHhFzU6DgH/8YCg78s2qtkCVP/qUptB7Of Zv1mvC0pnuEr5QCIXmOxh26Yfk8+U2hwsaFRT6SQUje0QoPchj9nAE6OogBfXz/Mg0kC rK+/Db7fZb7XnKsYgccHxPgTazAliuP7B0BK+VJc0Ll09E9AFA0YMXRyvKoaX44C6lc3 DQKOWvqj9I9FvjFhf5B2iHPQPaCCes3Oy1Tc8X5zeq/eqAFIZCOy0cwyrKhNxgpxoOPO VnYO7F8HT2ATEf4cAMOXp3G972+upLUlaFl2nJy5/iyBAw5lcrvexw72BF7rzcj5BwVK rQvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=o4Cy9KpSXJVO+i5TmvjoE8Way2fcEusxZ0oBwBxLiAg=; b=PYAAW4Re8ilEsJ7COdzXTLHi8NqU5m8NIxXpuPqRXin4QlctSAaOHh3t52HPvasC4U 9TvFcXmkDXrmqvjzm1fnpzIvvZU1qMt/mQwafGjpQ0q9oFt3rhXSi+6rYXYCxpzyPr8/ KN/43dzrHNFUzY8iKS01gtv6yq6PGpv+tsCp/bkwghM3P5bfTw+0ma0cJvaV/9bHtZvZ ++AQy4Y9uuL2PP7HwcMz50OEmxN4aripSZxVXqHYiJ355vTmNwWnjoHMCkLqbmY8UrAu WLTs/299xh0HlhUC0HuBNDoHd9Uo/kIyvrEGmyuqGwcL8xrVb9o5/SI5nlfbSWmn14/l Sb+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F1xJvdIF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g20si4057124edc.146.2019.05.19.13.50.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F1xJvdIF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSkt-0004wQ-LA for patch@linaro.org; Sun, 19 May 2019 16:50:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZ6-00033w-3X for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ3-0003hS-Nm for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:52 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:39844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ3-0003gO-EI for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:49 -0400 Received: by mail-pl1-x642.google.com with SMTP id g9so5708907plm.6 for ; Sun, 19 May 2019 13:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o4Cy9KpSXJVO+i5TmvjoE8Way2fcEusxZ0oBwBxLiAg=; b=F1xJvdIFpvumBk/ySlZuqw0XRxRY6ZfNLveLW0AvHyJNvnL5W16xq+eDZX/bgy8piS ss5FHWYC2WeEsLR6NbKdRp/TncIXblzrgGxSlhHE1mcPdWMzb2pca7uc0g+EWKAgi3MG cKKQHJ5mIvCET3++Ep6E2zTKvG5tvNOA2mCdV9NJmuK/317ana0tvbe6SYEMIVD9DHzN lxnYtqvnjNGO4N/ehA9zbv/q2O55UNEL6UY9StW7uKKpH4pcV1EAq4wseZJgiTvdZ6Ux Wr4s4VM67vRO68v2g10r77NKZNLnk/rqA9cTCyq/rYucgIDjlAbsrmTg6iHdljfojZu2 Zv8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o4Cy9KpSXJVO+i5TmvjoE8Way2fcEusxZ0oBwBxLiAg=; b=WuAwVNtoUglNnw0YZrzS+X3TyW8yCOo1gLwKddrQYSH5+SJ+ehbVN+kwc1UKXT6veB mYBA5Sb2NVAAGxpU9hjEU6/fLOLfafVyr87DMwQuIr9/y3XalWs+WlPKtObGCxX1wex5 9gPg+bkR7IXfUfaPsBxyVkEJq9+WaRbJWRWnc/jnoEV5Uz1BkcV97BbYm3LymdRFSCkb 2MC+smIecbxLHnmURsBDF7HBC7VSm+r3rTkmKPVEQKHTwCP8NGNZYIRMK51Z8/mwSy8n iVd//Mnqm6dq3bfJPTtZJ/IWIopcEnDZfUXmA4YUpukzrzuqlBnLh33lCAYfAQ/soyVp WgcA== X-Gm-Message-State: APjAAAUeh11W7thSAdTTMdIZjFATrl4H/BdWHfoBLLJEixDK2qOze+b7 A+Ey9US0ID3MZOVqHzqcHLWe/5NBPok= X-Received: by 2002:a17:902:c85:: with SMTP id 5mr70134481plt.172.1558298267981; Sun, 19 May 2019 13:37:47 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:26 -0700 Message-Id: <20190519203726.20729-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 14/74] linux-user: Split out memory syscalls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes mmap, mmap2, munmap, mlock, mlockall, munlock, munlockall, mprotect, mremap, msync. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 24 ++++++ linux-user/syscall.h | 2 + linux-user/strace.c | 55 ++----------- linux-user/syscall-mem.inc.c | 154 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 119 +-------------------------- linux-user/strace.list | 33 -------- 6 files changed, 189 insertions(+), 198 deletions(-) create mode 100644 linux-user/syscall-mem.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 6d6349da01..88f433e998 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -20,6 +20,26 @@ SYSCALL_DEF(close, ARG_DEC); #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif +SYSCALL_DEF(mlock, ARG_PTR, ARG_DEC); +SYSCALL_DEF(mlockall, ARG_HEX); +#ifdef TARGET_NR_mmap +SYSCALL_DEF_FULL(mmap, .impl = impl_mmap, + .args = args_mmap, + .print_ret = print_syscall_ptr_ret, + .arg_type = { ARG_PTR, ARG_DEC, ARG_MMAPPROT, + ARG_MMAPFLAG, ARG_DEC, ARG_DEC }); +#endif +#ifdef TARGET_NR_mmap2 +SYSCALL_DEF_FULL(mmap2, .impl = impl_mmap, + .args = args_mmap2, + .print_ret = print_syscall_ptr_ret, + .arg_type = { ARG_PTR, ARG_DEC, ARG_MMAPPROT, + ARG_MMAPFLAG, ARG_DEC, ARG_DEC64 }); +#endif +SYSCALL_DEF(mprotect, ARG_PTR, ARG_DEC, ARG_MMAPPROT); +SYSCALL_DEF_FULL(mremap, .impl = impl_mremap, + .print_ret = print_syscall_ptr_ret, + .arg_type = { ARG_PTR, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR }); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_msgctl) SYSCALL_DEF(msgctl, ARG_DEC, ARG_DEC, ARG_PTR); #endif @@ -32,6 +52,10 @@ SYSCALL_DEF(msgrcv, ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC, ARG_HEX); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_msgsnd) SYSCALL_DEF(msgsnd, ARG_DEC, ARG_PTR, ARG_DEC, ARG_HEX); #endif +SYSCALL_DEF(msync, ARG_PTR, ARG_DEC, ARG_HEX); +SYSCALL_DEF(munlock, ARG_PTR, ARG_DEC); +SYSCALL_DEF(munlockall); +SYSCALL_DEF(munmap, ARG_PTR, ARG_DEC); SYSCALL_DEF(name_to_handle_at, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); #ifdef TARGET_NR_open diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 83f602f8e7..8175de4c31 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -58,6 +58,8 @@ typedef enum { /* These print as sets of flags. */ ARG_ATDIRFD, ARG_ATFLAG, + ARG_MMAPFLAG, + ARG_MMAPPROT, ARG_MODEFLAG, ARG_OPENFLAG, diff --git a/linux-user/strace.c b/linux-user/strace.c index e1c4859a95..a767227ac1 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -801,7 +801,7 @@ UNUSED static struct flags umount2_flags[] = { FLAG_END, }; -UNUSED static struct flags mmap_prot_flags[] = { +static struct flags const mmap_prot_flags[] = { FLAG_GENERIC(PROT_NONE), FLAG_GENERIC(PROT_EXEC), FLAG_GENERIC(PROT_READ), @@ -812,7 +812,7 @@ UNUSED static struct flags mmap_prot_flags[] = { FLAG_END, }; -UNUSED static struct flags mmap_flags[] = { +static struct flags const mmap_flags[] = { FLAG_TARGET(MAP_SHARED), FLAG_TARGET(MAP_PRIVATE), FLAG_TARGET(MAP_ANONYMOUS), @@ -2362,51 +2362,6 @@ print_utimensat(const struct syscallname *name, } #endif -#if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) -static void -print_mmap(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_pointer(arg0, 0); - print_raw_param("%d", arg1, 0); - print_flags(mmap_prot_flags, arg2, 0); - print_flags(mmap_flags, arg3, 0); - print_raw_param("%d", arg4, 0); - print_raw_param("%#x", arg5, 1); - print_syscall_epilogue(name); -} -#define print_mmap2 print_mmap -#endif - -#ifdef TARGET_NR_mprotect -static void -print_mprotect(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_pointer(arg0, 0); - print_raw_param("%d", arg1, 0); - print_flags(mmap_prot_flags, arg2, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_munmap -static void -print_munmap(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_pointer(arg0, 0); - print_raw_param("%d", arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_futex static void print_futex_op(abi_long tflag, int last) { @@ -2613,6 +2568,12 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_ATFLAG: len = add_flags(b, rest, at_file_flags, arg, false); break; + case ARG_MMAPFLAG: + len = add_flags(b, rest, mmap_flags, arg, false); + break; + case ARG_MMAPPROT: + len = add_flags(b, rest, mmap_prot_flags, arg, false); + break; case ARG_MODEFLAG: len = add_flags(b, rest, mode_flags, arg, true); break; diff --git a/linux-user/syscall-mem.inc.c b/linux-user/syscall-mem.inc.c new file mode 100644 index 0000000000..d2ce0cb8cc --- /dev/null +++ b/linux-user/syscall-mem.inc.c @@ -0,0 +1,154 @@ +/* + * Linux memory-related syscalls + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + + +static bitmask_transtbl const mmap_flags_tbl[] = { + { TARGET_MAP_SHARED, TARGET_MAP_SHARED, MAP_SHARED, MAP_SHARED }, + { TARGET_MAP_PRIVATE, TARGET_MAP_PRIVATE, MAP_PRIVATE, MAP_PRIVATE }, + { TARGET_MAP_FIXED, TARGET_MAP_FIXED, MAP_FIXED, MAP_FIXED }, + { TARGET_MAP_ANONYMOUS, TARGET_MAP_ANONYMOUS, + MAP_ANONYMOUS, MAP_ANONYMOUS }, + { TARGET_MAP_GROWSDOWN, TARGET_MAP_GROWSDOWN, + MAP_GROWSDOWN, MAP_GROWSDOWN }, + { TARGET_MAP_DENYWRITE, TARGET_MAP_DENYWRITE, + MAP_DENYWRITE, MAP_DENYWRITE }, + { TARGET_MAP_EXECUTABLE, TARGET_MAP_EXECUTABLE, + MAP_EXECUTABLE, MAP_EXECUTABLE }, + { TARGET_MAP_LOCKED, TARGET_MAP_LOCKED, MAP_LOCKED, MAP_LOCKED }, + { TARGET_MAP_NORESERVE, TARGET_MAP_NORESERVE, + MAP_NORESERVE, MAP_NORESERVE }, + { TARGET_MAP_HUGETLB, TARGET_MAP_HUGETLB, MAP_HUGETLB, MAP_HUGETLB }, + /* + * MAP_STACK had been ignored by the kernel for quite some time. + * Recognize it for the target insofar as we do not want to pass + * it through to the host. + */ + { TARGET_MAP_STACK, TARGET_MAP_STACK, 0, 0 }, + { 0, 0, 0, 0 } +}; + + +SYSCALL_IMPL(mlock) +{ + return get_errno(mlock(g2h(arg1), arg2)); +} + +SYSCALL_IMPL(mlockall) +{ + int host_flag = 0; + if (arg1 & TARGET_MLOCKALL_MCL_CURRENT) { + host_flag |= MCL_CURRENT; + } + if (arg1 & TARGET_MLOCKALL_MCL_FUTURE) { + host_flag |= MCL_FUTURE; + } + return get_errno(mlockall(host_flag)); +} + +#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \ + (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \ + defined(TARGET_M68K) || defined(TARGET_CRIS) || \ + defined(TARGET_MICROBLAZE) || defined(TARGET_S390X) +SYSCALL_ARGS(mmap) +{ + abi_ulong ptr = in[0]; + abi_long *v = lock_user(VERIFY_READ, ptr, 6 * sizeof(abi_long), 1); + if (v == NULL) { + errno = EFAULT; + return NULL; + } + out[0] = tswapal(v[0]); + out[1] = tswapal(v[1]); + out[2] = tswapal(v[2]); + out[3] = tswapal(v[3]); + out[4] = tswapal(v[4]); + out[5] = tswapal(v[5]); + unlock_user(v, ptr, 0); + return def; +} +#else +# define args_mmap NULL +#endif + +SYSCALL_IMPL(mmap) +{ + int host_flags = target_to_host_bitmask(arg4, mmap_flags_tbl); + return get_errno(target_mmap(arg1, arg2, arg3, host_flags, arg5, arg6)); +} + +#ifdef TARGET_NR_mmap2 +/* + * Define mmap2 in terms of mmap. + * !!! Note that there is a fundamental problem here in that + * target_mmap has an offset parameter that is abi_ulong + * and not off_t. This means that we cannot actually pass + * through a 64-bit file offset as intended. + */ + +#ifndef MMAP_SHIFT +# define MMAP_SHIFT 12 +#endif + +SYSCALL_ARGS(mmap2) +{ + /* We have already assigned out[0-4]. */ + out[5] = (uint64_t)(abi_ulong)in[5] << MMAP_SHIFT; + return def; +} +#endif + +SYSCALL_IMPL(mprotect) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + + /* Special hack to detect libc making the stack executable. */ + if ((arg3 & PROT_GROWSDOWN) + && arg1 >= ts->info->stack_limit + && arg1 <= ts->info->start_stack) { + arg3 &= ~PROT_GROWSDOWN; + arg2 = arg2 + arg1 - ts->info->stack_limit; + arg1 = ts->info->stack_limit; + } + return get_errno(target_mprotect(arg1, arg2, arg3)); +} + +SYSCALL_IMPL(mremap) +{ + return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); +} + +SYSCALL_IMPL(msync) +{ + return get_errno(msync(g2h(arg1), arg2, arg3)); +} + +SYSCALL_IMPL(munlock) +{ + return get_errno(munlock(g2h(arg1), arg2)); +} + +SYSCALL_IMPL(munlockall) +{ + return get_errno(munlockall()); +} + +SYSCALL_IMPL(munmap) +{ + return get_errno(target_munmap(arg1, arg2)); +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ca345ffb4c..876426dd9c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4183,29 +4183,6 @@ static const StructEntry struct_termios_def = { .align = { __alignof__(struct target_termios), __alignof__(struct host_termios) }, }; -static bitmask_transtbl mmap_flags_tbl[] = { - { TARGET_MAP_SHARED, TARGET_MAP_SHARED, MAP_SHARED, MAP_SHARED }, - { TARGET_MAP_PRIVATE, TARGET_MAP_PRIVATE, MAP_PRIVATE, MAP_PRIVATE }, - { TARGET_MAP_FIXED, TARGET_MAP_FIXED, MAP_FIXED, MAP_FIXED }, - { TARGET_MAP_ANONYMOUS, TARGET_MAP_ANONYMOUS, - MAP_ANONYMOUS, MAP_ANONYMOUS }, - { TARGET_MAP_GROWSDOWN, TARGET_MAP_GROWSDOWN, - MAP_GROWSDOWN, MAP_GROWSDOWN }, - { TARGET_MAP_DENYWRITE, TARGET_MAP_DENYWRITE, - MAP_DENYWRITE, MAP_DENYWRITE }, - { TARGET_MAP_EXECUTABLE, TARGET_MAP_EXECUTABLE, - MAP_EXECUTABLE, MAP_EXECUTABLE }, - { TARGET_MAP_LOCKED, TARGET_MAP_LOCKED, MAP_LOCKED, MAP_LOCKED }, - { TARGET_MAP_NORESERVE, TARGET_MAP_NORESERVE, - MAP_NORESERVE, MAP_NORESERVE }, - { TARGET_MAP_HUGETLB, TARGET_MAP_HUGETLB, MAP_HUGETLB, MAP_HUGETLB }, - /* MAP_STACK had been ignored by the kernel for quite some time. - Recognize it for the target insofar as we do not want to pass - it through to the host. */ - { TARGET_MAP_STACK, TARGET_MAP_STACK, 0, 0 }, - { 0, 0, 0, 0 } -}; - #if defined(TARGET_I386) /* NOTE: there is really one LDT for all the threads */ @@ -5428,21 +5405,6 @@ static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp, return 0; } -#if defined(TARGET_NR_mlockall) -static inline int target_to_host_mlockall_arg(int arg) -{ - int result = 0; - - if (arg & TARGET_MLOCKALL_MCL_CURRENT) { - result |= MCL_CURRENT; - } - if (arg & TARGET_MLOCKALL_MCL_FUTURE) { - result |= MCL_FUTURE; - } - return result; -} -#endif - #if (defined(TARGET_NR_stat64) || defined(TARGET_NR_lstat64) || \ defined(TARGET_NR_fstat64) || defined(TARGET_NR_fstatat64) || \ defined(TARGET_NR_newfstatat)) @@ -7052,86 +7014,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(reboot(arg1, arg2, arg3, NULL)); } return ret; -#ifdef TARGET_NR_mmap - case TARGET_NR_mmap: -#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \ - (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \ - defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \ - || defined(TARGET_S390X) - { - abi_ulong *v; - abi_ulong v1, v2, v3, v4, v5, v6; - if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1))) - return -TARGET_EFAULT; - v1 = tswapal(v[0]); - v2 = tswapal(v[1]); - v3 = tswapal(v[2]); - v4 = tswapal(v[3]); - v5 = tswapal(v[4]); - v6 = tswapal(v[5]); - unlock_user(v, arg1, 0); - ret = get_errno(target_mmap(v1, v2, v3, - target_to_host_bitmask(v4, mmap_flags_tbl), - v5, v6)); - } -#else - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, - arg6)); -#endif - return ret; -#endif -#ifdef TARGET_NR_mmap2 - case TARGET_NR_mmap2: -#ifndef MMAP_SHIFT -#define MMAP_SHIFT 12 -#endif - ret = target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, arg6 << MMAP_SHIFT); - return get_errno(ret); -#endif - case TARGET_NR_munmap: - return get_errno(target_munmap(arg1, arg2)); - case TARGET_NR_mprotect: - { - TaskState *ts = cpu->opaque; - /* Special hack to detect libc making the stack executable. */ - if ((arg3 & PROT_GROWSDOWN) - && arg1 >= ts->info->stack_limit - && arg1 <= ts->info->start_stack) { - arg3 &= ~PROT_GROWSDOWN; - arg2 = arg2 + arg1 - ts->info->stack_limit; - arg1 = ts->info->stack_limit; - } - } - return get_errno(target_mprotect(arg1, arg2, arg3)); -#ifdef TARGET_NR_mremap - case TARGET_NR_mremap: - return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); -#endif - /* ??? msync/mlock/munlock are broken for softmmu. */ -#ifdef TARGET_NR_msync - case TARGET_NR_msync: - return get_errno(msync(g2h(arg1), arg2, arg3)); -#endif -#ifdef TARGET_NR_mlock - case TARGET_NR_mlock: - return get_errno(mlock(g2h(arg1), arg2)); -#endif -#ifdef TARGET_NR_munlock - case TARGET_NR_munlock: - return get_errno(munlock(g2h(arg1), arg2)); -#endif -#ifdef TARGET_NR_mlockall - case TARGET_NR_mlockall: - return get_errno(mlockall(target_to_host_mlockall_arg(arg1))); -#endif -#ifdef TARGET_NR_munlockall - case TARGET_NR_munlockall: - return get_errno(munlockall()); -#endif #ifdef TARGET_NR_truncate case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) @@ -10092,6 +9974,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #include "syscall-file.inc.c" #include "syscall-ipc.inc.c" +#include "syscall-mem.inc.c" #undef SYSCALL_IMPL #undef SYSCALL_ARGS diff --git a/linux-user/strace.list b/linux-user/strace.list index f99bd57c09..cc0bb10a7a 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -554,21 +554,6 @@ #ifdef TARGET_NR_mknodat { TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL }, #endif -#ifdef TARGET_NR_mlock -{ TARGET_NR_mlock, "mlock" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_mlock2 -{ TARGET_NR_mlock2, "mlock2" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_mlockall -{ TARGET_NR_mlockall, "mlockall" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_mmap -{ TARGET_NR_mmap, "mmap" , NULL, print_mmap, print_syscall_ret_addr }, -#endif -#ifdef TARGET_NR_mmap2 -{ TARGET_NR_mmap2, "mmap2" , NULL, print_mmap2, print_syscall_ret_addr }, -#endif #ifdef TARGET_NR_modify_ldt { TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL }, #endif @@ -578,9 +563,6 @@ #ifdef TARGET_NR_move_pages { TARGET_NR_move_pages, "move_pages" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_mprotect -{ TARGET_NR_mprotect, "mprotect" , NULL, print_mprotect, NULL }, -#endif #ifdef TARGET_NR_mpx { TARGET_NR_mpx, "mpx" , NULL, NULL, NULL }, #endif @@ -602,24 +584,9 @@ #ifdef TARGET_NR_mq_unlink { TARGET_NR_mq_unlink, "mq_unlink" , NULL, print_mq_unlink, NULL }, #endif -#ifdef TARGET_NR_mremap -{ TARGET_NR_mremap, "mremap" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_msync -{ TARGET_NR_msync, "msync" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_multiplexer { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_munlock -{ TARGET_NR_munlock, "munlock" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_munlockall -{ TARGET_NR_munlockall, "munlockall" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_munmap -{ TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, -#endif #ifdef TARGET_NR_nanosleep { TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164498 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4781913ili; Sun, 19 May 2019 13:44:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxstxWYY6GPvoF+3kVi75XkZYeiryQuS8sHtAF4tLJXOZHuAQ0lQ9/ehkxFoCuFJRojnNTZ X-Received: by 2002:a17:906:8613:: with SMTP id o19mr31111514ejx.126.1558298668601; Sun, 19 May 2019 13:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298668; cv=none; d=google.com; s=arc-20160816; b=O3Bzv6DrxA7QKrErtf76msKXXr6wrVPFHHV51h4lDDoWvQVoH3BVPUjW/U4wNoZ+Yz Ier01nbaJ8PjwBpDSHG2Xzsaak0rcatGc6RBKmB9//EG8lDLnIiD78r8/BiyHQ6he2pG FZxhiPOfJQ2NKKefOM9WFW1+FHLSOxMnGPc+1kJrpOQbDIvxVTHDGAOs1B7DFtdiqMMm 7EvQhb6dbslj+n81l/U56f6icSUcuxwkinE+jS9Gn/avqrVSIabm8QRryTE3gyM4Yo31 ilomU7QkcIKwev+1p9hGfhkJNsLyUcWLu3PAhpoEy43WXbA7dCgA83kQ1p2r2NNbFOHp pH4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=VSlxea5X8kmlG4BCCYdaO6spDVy0J4IfrRmHvvWJsEo=; b=AL1LvW97FP5vw2/3Pl2lQ6ZbcK+q5mI7Yrrc23l5AJeE7sJ7Zldcfc5vgK3SkIVMra JxnjE5vCOUsFK0ImjnNrB12x+GerMosFJZ/QkzxtM+SUKQULoAahNEmDPUDbnMPs5I5m P85xp0XdNv8xsNXMS6XQej5lw6tagpRT7447QVPNs05ReyT1bKoAnF87VHXEvgbP6frp gY2azn3LWT2PMMCcM64n9TK+pDX/XPaA6va7FQZC2rIpFn91KUu83QRWcceVmaYMxziW YjMc1JMxv8LQa8rBbbC9O5JpNvbJtwa+//qCAjkZCPUBzDHHhLv9gDDEU9kKR4iDUDFr +pUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h9mbQQ3S; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m18si1150041edm.173.2019.05.19.13.44.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:44:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h9mbQQ3S; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSfT-0008Ln-De for patch@linaro.org; Sun, 19 May 2019 16:44:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZ6-000347-6c for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ4-0003id-PS for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:52 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:35573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ4-0003hq-JB for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:50 -0400 Received: by mail-pl1-x644.google.com with SMTP id p1so336283plo.2 for ; Sun, 19 May 2019 13:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VSlxea5X8kmlG4BCCYdaO6spDVy0J4IfrRmHvvWJsEo=; b=h9mbQQ3SGTfIiYm6DeVYwSPJhUaB8QQBVG94ifShCK+mh+hBW7yDCIxug4QxQNRwtE 5n4KFaTt2nNUgT6++NfshS0weturRSOcJGQp8c5UHxko9TmrdeEnLbayqooSdX4SPHRi sp2xjIfb3WInVj5vUBSOX7G1YZN8GwSAnaiXImnMHlyn1lyZh/sr1tNKIu7c6TM9Xbjc 8nIRGRtDOLxNoDcfUnaOcCIaEtAwZG7c5SRQBsWkDPFRIR6/EduXcaf8OOdzPP3XPvcc yIgjCScjNkpUWUutc88dU4HtEtp1p3JgdSZXdb47hjE7D+G3QyLVFlPVJOYWBoNGzmLp 5+uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VSlxea5X8kmlG4BCCYdaO6spDVy0J4IfrRmHvvWJsEo=; b=ZAh6P6iK1EGuuyYK8ccvnlYLRyAXHcAF615HReNxyLPQTEVsDoXFt7VaGtStiVRpfL g2aV86Q+3z3YZKTASBz0yBPHemEYiCQHJqcdTZJx58e5vFUeWXcUPByrL3qy76EEvlGI 7TYBP7lBbRTrO92WyUEYjs9Y0clCN7wGv/l2JZOMfmRbDFOSFXYKQEH0lfyFxIsGFF1z Ao0fjhithkkiN3RMKNQZE9BtodmZl/8yjXAhJPZKZVVkMEX2q/5SOtGgLoWlKU84t7B7 duHx5kdY7ajKzDp2lH0SMHBtMfBnTi6wUMoJMwwfURDcVW5zPgBB7c3XaJmBGrsf5Zme IiuQ== X-Gm-Message-State: APjAAAVyF6WRKgfPJpZLrJ7tWbBu3SqP+/JHi3xWH8Z62LCXaju/00jL nKBXpK+kXHbReqzq+SZHdBjsV5fT+fM= X-Received: by 2002:a17:902:74c6:: with SMTP id f6mr13664060plt.335.1558298269373; Sun, 19 May 2019 13:37:49 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:27 -0700 Message-Id: <20190519203726.20729-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v7 15/74] linux-user: Split out exit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-proc.inc.c | 61 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 38 +--------------------- 3 files changed, 63 insertions(+), 37 deletions(-) create mode 100644 linux-user/syscall-proc.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 88f433e998..88aa1a6bfd 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -17,6 +17,7 @@ */ SYSCALL_DEF(close, ARG_DEC); +SYSCALL_DEF(exit, ARG_DEC); #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c new file mode 100644 index 0000000000..96ad363c1a --- /dev/null +++ b/linux-user/syscall-proc.inc.c @@ -0,0 +1,61 @@ +/* + * Linux process related syscalls + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + + +SYSCALL_IMPL(exit) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + int status = arg1; + + /* + * In old applications this may be used to implement _exit(2). + * However in threaded applictions it is used for thread termination, + * and _exit_group is used for application termination. + * Do thread termination if we have more then one thread. + */ + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + + cpu_list_lock(); + + if (CPU_NEXT(first_cpu)) { + TaskState *ts; + + /* Remove the CPU from the list. */ + QTAILQ_REMOVE_RCU(&cpus, cpu, node); + + cpu_list_unlock(); + + ts = cpu->opaque; + if (ts->child_tidptr) { + put_user_u32(0, ts->child_tidptr); + sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX, + NULL, NULL, 0); + } + thread_cpu = NULL; + object_unref(OBJECT(cpu)); + g_free(ts); + rcu_unregister_thread(); + pthread_exit(NULL); + } + + cpu_list_unlock(); + preexit_cleanup(cpu_env, status); + _exit(status); +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 876426dd9c..c72d24aa76 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5681,43 +5681,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_exit: - /* In old applications this may be used to implement _exit(2). - However in threaded applictions it is used for thread termination, - and _exit_group is used for application termination. - Do thread termination if we have more then one thread. */ - - if (block_signals()) { - return -TARGET_ERESTARTSYS; - } - - cpu_list_lock(); - - if (CPU_NEXT(first_cpu)) { - TaskState *ts; - - /* Remove the CPU from the list. */ - QTAILQ_REMOVE_RCU(&cpus, cpu, node); - - cpu_list_unlock(); - - ts = cpu->opaque; - if (ts->child_tidptr) { - put_user_u32(0, ts->child_tidptr); - sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX, - NULL, NULL, 0); - } - thread_cpu = NULL; - object_unref(OBJECT(cpu)); - g_free(ts); - rcu_unregister_thread(); - pthread_exit(NULL); - } - - cpu_list_unlock(); - preexit_cleanup(cpu_env, arg1); - _exit(arg1); - return 0; /* avoid warning */ case TARGET_NR_brk: return do_brk(arg1); #ifdef TARGET_NR_fork @@ -9975,6 +9938,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #include "syscall-file.inc.c" #include "syscall-ipc.inc.c" #include "syscall-mem.inc.c" +#include "syscall-proc.inc.c" #undef SYSCALL_IMPL #undef SYSCALL_ARGS From patchwork Sun May 19 20:36:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164502 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4784409ili; Sun, 19 May 2019 13:48:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfvGdB3HyqoahoO/8MNRg666+ovQNsVv2p3afEwpHRMd0sbrvKctuYAMrycPeOQU+bm/61 X-Received: by 2002:a17:906:1fc4:: with SMTP id e4mr35925455ejt.81.1558298896783; Sun, 19 May 2019 13:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558298896; cv=none; d=google.com; s=arc-20160816; b=wgo4ujog0Dhkb1cWAehHIvcGs2TCvGyBSFCLQwDTXNpPOKh/h2rF/m80OvLa5S3nXz HQ70SKSbFTH3jKaCtW+0kgN8woPHWMJ+vOi5z440plRemjXX6SUabkuKIgrYjk4IaHLB csd2Wqoe4CxAcOGMWDiuBPB27ALNx5edRNDzFpsG5hsS0eygYGrmZg0FHi7OCIN1lh1J uS6DfhK4jjhtDlndlA+wgF/zrmMv5UyLiSxjTYu7NHwL7nmmUQZD+Yxv4sBEC5f5ndWM Cd55ZrQwwYZ0qYv4WWIkpK5JgTakaZisbe9PDEybTt6eJO3fcryHN7jgEPxIFAx55jjT qXeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=mCaCI2Aj5tC2IpfdxPu1UNH/KS+6aMoVb/BQvf6d4j4=; b=wY/n/OWy/0Qcm0TTqp/szntiqpthjwm4HOTmwOZQxf9/VmHl0ruIHEzv50vbOjNYWn MXC/wkIrRHief2S5g2cLr47y0n0qUf/MXpbvadu7wKlGf8nk64DgM8ZLxI81zFXhCpHy P2dwAijyxp2PpMQfq8DRVhuztsJl9iflpkaMUDyR6eg9c8YK4Ittv+PtUJI1Bs9jnjxs 3zfNJ78Ls63QHuA/ULd4nk0yFTOeEi4Tl5HKm5LMUeCGfLd0WB2IWe54MbvdZhh+gPXi ldKkdxx7fVKcOBFtFXPaaJFHbZh3JZ5uvn2BGkfEHSMO/ISZkCVS+GuP1gk2R52zDQy4 Gs+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Kmei6DvM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g8si1461858eje.360.2019.05.19.13.48.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Kmei6DvM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSj9-0003KS-JK for patch@linaro.org; Sun, 19 May 2019 16:48:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZ8-000395-AH for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ6-0003kf-CI for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:54 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ6-0003jY-42 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:52 -0400 Received: by mail-pl1-x642.google.com with SMTP id c5so5690537pll.11 for ; Sun, 19 May 2019 13:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mCaCI2Aj5tC2IpfdxPu1UNH/KS+6aMoVb/BQvf6d4j4=; b=Kmei6DvMOhI+sXk4Bjs7SeJuH3jJYoD7ED4pYajTKSF/tghvhB/LFLnN1MZNmgGdpW tTGnhJvRO37FaGg4tWGT0unzkfueIqkyngEiUQkeE6vbg2TjPh3+rdujhZeluv0KzlFP kxD8Pbw3LM6yagoniOknL9d+ZfidIikCyKFk3BJxHT/EDixK/GvFcLXUgykk9q2GwSxC UVoYdMtQoDlk3dUCYvbPZKRUXfcfA3mhOBtZWbpIX6aHBgxzBEEQzH1GAgbp6digMePk GDFeqfa34hXbV8YaifR8UHw/U6vtn2Twma/dnYxXYsji9jChZ3o3JXnlpZuyhBV3dtLz Vg+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mCaCI2Aj5tC2IpfdxPu1UNH/KS+6aMoVb/BQvf6d4j4=; b=sPrOEMa7SFglPf84Nch8QGqDyfvKmpOXG1a1PU/L3OukWYjrrhZQg/DQ0a4nWUor3m 76yHqtEiDplu2VeJeJnqiD7IhD/zDP2Ll9wBGSFmG7IZCGoW1nqVzg4sg1CJ0yryaEjx 5nXsCrIa/HlBtnbx1yIRpK/vmJSdos60hwoDXjW1jNdo0EuflyVuyZ8bxtz/jIqaceMt 1nPX8p/rmR3huxgBR7sZjkyAYlNtM/qd2TcphFxZPsXBcWurEkwOUbaZBHuN01N5G7dd UX7inOieZYXdzvaTEfzq32knUAjIE+v0EcDQng8Ear6oNiXdMUVqQLPCRj5ZhC6yateF OKew== X-Gm-Message-State: APjAAAVVUO/XJaS85ilSEn+rir/h7C7QuUo5VuY9I5/9a6dEF8HzktO4 Qoj8e0prXgC2XIXqbo3eQy+/wbSa9dA= X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr35897710plb.171.1558298270873; Sun, 19 May 2019 13:37:50 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:28 -0700 Message-Id: <20190519203726.20729-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 16/74] linux-user: Split out brk X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 3 ++ linux-user/strace.c | 35 -------------- linux-user/syscall-mem.inc.c | 90 ++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 93 ------------------------------------ linux-user/strace.list | 3 -- 5 files changed, 93 insertions(+), 131 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 88aa1a6bfd..c3ed22ff16 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -16,6 +16,9 @@ * along with this program; if not, see . */ +SYSCALL_DEF_FULL(brk, .impl = impl_brk, + .print_ret = print_syscall_ptr_ret, + .arg_type = { ARG_PTR }); SYSCALL_DEF(close, ARG_DEC); SYSCALL_DEF(exit, ARG_DEC); #ifdef TARGET_NR_ipc diff --git a/linux-user/strace.c b/linux-user/strace.c index a767227ac1..0a2c6764db 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -604,29 +604,6 @@ print_execve(const struct syscallname *name, * Variants for the return value output function */ -static void -print_syscall_ret_addr(const struct syscallname *name, abi_long ret) -{ - const char *errstr = NULL; - - if (ret < 0) { - errstr = target_strerror(-ret); - } - if (errstr) { - gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); - } else { - gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); - } -} - -#if 0 /* currently unused */ -static void -print_syscall_ret_raw(struct syscallname *name, abi_long ret) -{ - gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); -} -#endif - #ifdef TARGET_NR__newselect static void print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) @@ -1168,18 +1145,6 @@ print_access(const struct syscallname *name, } #endif -#ifdef TARGET_NR_brk -static void -print_brk(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_pointer(arg0, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_chdir static void print_chdir(const struct syscallname *name, diff --git a/linux-user/syscall-mem.inc.c b/linux-user/syscall-mem.inc.c index d2ce0cb8cc..17ba8e3d97 100644 --- a/linux-user/syscall-mem.inc.c +++ b/linux-user/syscall-mem.inc.c @@ -42,6 +42,96 @@ static bitmask_transtbl const mmap_flags_tbl[] = { { 0, 0, 0, 0 } }; +static abi_ulong target_brk; +static abi_ulong target_original_brk; +static abi_ulong brk_page; + +void target_set_brk(abi_ulong new_brk) +{ + target_original_brk = target_brk = HOST_PAGE_ALIGN(new_brk); + brk_page = HOST_PAGE_ALIGN(target_brk); +} + +/* do_brk() must return target values and target errnos. */ +abi_long do_brk(abi_ulong new_brk) +{ + abi_long mapped_addr; + abi_ulong new_alloc_size; + + if (!new_brk) { + return target_brk; + } + if (new_brk < target_original_brk) { + return target_brk; + } + + /* + * If the new brk is less than the highest page reserved to the + * target heap allocation, set it and we're almost done... + */ + if (new_brk <= brk_page) { + /* + * Heap contents are initialized to zero, + * as for anonymous mapped pages. + */ + if (new_brk > target_brk) { + memset(g2h(target_brk), 0, new_brk - target_brk); + } + target_brk = new_brk; + return target_brk; + } + + /* + * We need to allocate more memory after the brk... Note that + * we don't use MAP_FIXED because that will map over the top of + * any existing mapping (like the one with the host libc or qemu + * itself); instead we treat "mapped but at wrong address" as + * a failure and unmap again. + */ + new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page); + mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, 0, 0)); + + if (mapped_addr == brk_page) { + /* + * Heap contents are initialized to zero, as for anonymous + * mapped pages. Technically the new pages are already + * initialized to zero since they *are* anonymous mapped + * pages, however we have to take care with the contents that + * come from the remaining part of the previous page: it may + * contains garbage data due to a previous heap usage (grown + * then shrunken). + */ + memset(g2h(target_brk), 0, brk_page - target_brk); + + target_brk = new_brk; + brk_page = HOST_PAGE_ALIGN(target_brk); + return target_brk; + } else if (mapped_addr != -1) { + /* + * Mapped but at wrong address, meaning there wasn't actually + * enough space for this brk. + */ + target_munmap(mapped_addr, new_alloc_size); + mapped_addr = -1; + } + +#if defined(TARGET_ALPHA) + /* + * We (partially) emulate OSF/1 on Alpha, which requires we + * return a proper errno, not an unchanged brk value. + */ + return -TARGET_ENOMEM; +#endif + /* For everything else, return the previous break. */ + return target_brk; +} + +SYSCALL_IMPL(brk) +{ + return do_brk(arg1); +} SYSCALL_IMPL(mlock) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c72d24aa76..4c9953a7ab 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -820,97 +820,6 @@ static inline int host_to_target_sock_type(int host_type) return target_type; } -static abi_ulong target_brk; -static abi_ulong target_original_brk; -static abi_ulong brk_page; - -void target_set_brk(abi_ulong new_brk) -{ - target_original_brk = target_brk = HOST_PAGE_ALIGN(new_brk); - brk_page = HOST_PAGE_ALIGN(target_brk); -} - -//#define DEBUGF_BRK(message, args...) do { fprintf(stderr, (message), ## args); } while (0) -#define DEBUGF_BRK(message, args...) - -/* do_brk() must return target values and target errnos. */ -abi_long do_brk(abi_ulong new_brk) -{ - abi_long mapped_addr; - abi_ulong new_alloc_size; - - DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk); - - if (!new_brk) { - DEBUGF_BRK(TARGET_ABI_FMT_lx " (!new_brk)\n", target_brk); - return target_brk; - } - if (new_brk < target_original_brk) { - DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk < target_original_brk)\n", - target_brk); - return target_brk; - } - - /* If the new brk is less than the highest page reserved to the - * target heap allocation, set it and we're almost done... */ - if (new_brk <= brk_page) { - /* Heap contents are initialized to zero, as for anonymous - * mapped pages. */ - if (new_brk > target_brk) { - memset(g2h(target_brk), 0, new_brk - target_brk); - } - target_brk = new_brk; - DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk <= brk_page)\n", target_brk); - return target_brk; - } - - /* We need to allocate more memory after the brk... Note that - * we don't use MAP_FIXED because that will map over the top of - * any existing mapping (like the one with the host libc or qemu - * itself); instead we treat "mapped but at wrong address" as - * a failure and unmap again. - */ - new_alloc_size = HOST_PAGE_ALIGN(new_brk - brk_page); - mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size, - PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, 0, 0)); - - if (mapped_addr == brk_page) { - /* Heap contents are initialized to zero, as for anonymous - * mapped pages. Technically the new pages are already - * initialized to zero since they *are* anonymous mapped - * pages, however we have to take care with the contents that - * come from the remaining part of the previous page: it may - * contains garbage data due to a previous heap usage (grown - * then shrunken). */ - memset(g2h(target_brk), 0, brk_page - target_brk); - - target_brk = new_brk; - brk_page = HOST_PAGE_ALIGN(target_brk); - DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr == brk_page)\n", - target_brk); - return target_brk; - } else if (mapped_addr != -1) { - /* Mapped but at wrong address, meaning there wasn't actually - * enough space for this brk. - */ - target_munmap(mapped_addr, new_alloc_size); - mapped_addr = -1; - DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr != -1)\n", target_brk); - } - else { - DEBUGF_BRK(TARGET_ABI_FMT_lx " (otherwise)\n", target_brk); - } - -#if defined(TARGET_ALPHA) - /* We (partially) emulate OSF/1 on Alpha, which requires we - return a proper errno, not an unchanged brk value. */ - return -TARGET_ENOMEM; -#endif - /* For everything else, return the previous break. */ - return target_brk; -} - static inline abi_long copy_from_user_fdset(fd_set *fds, abi_ulong target_fds_addr, int n) @@ -5681,8 +5590,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_brk: - return do_brk(arg1); #ifdef TARGET_NR_fork case TARGET_NR_fork: return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); diff --git a/linux-user/strace.list b/linux-user/strace.list index cc0bb10a7a..aff6d1d73d 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -49,9 +49,6 @@ #ifdef TARGET_NR_break { TARGET_NR_break, "break" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_brk -{ TARGET_NR_brk, "brk" , NULL, print_brk, print_syscall_ret_addr }, -#endif #ifdef TARGET_NR_cachectl { TARGET_NR_cachectl, "cachectl" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164505 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4785982ili; Sun, 19 May 2019 13:50:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyRvoogvZaE+BIyXccQ56sWjAWtJebx/tHfv/l1r9RTUAtyovzRJYjtT/n7xUe1XbKZG7d X-Received: by 2002:aa7:c44e:: with SMTP id n14mr70873475edr.203.1558299039762; Sun, 19 May 2019 13:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299039; cv=none; d=google.com; s=arc-20160816; b=a913rhgQ+bcLNZGX527+WxYzZph8WYcJc4vfngL66sl52xkMxXnQTxTCJrLaWpZeNm i3+wv8FeJei7oPwJVIXVJxxO55K8xrSPeoxkrTuKzgqmTQbVGgdkHDm7vcIlcxLLc3lG 470RSO2cAuVeg4MxHaB/ZoD7sdO+J7kNM+nURaI4tO8dR7syzD3vT/ju5pHCCus0toAE CDjjRTcpPn5VxrzJsmZj6tt5QUkBVFg2xNp//skp9anEMoeTRoggVwIg4O25nzDaK9ju ebX2LUMIV+1IS/na8yMwCGu9Y/ce4km6tcibS2Y7v9hIfqEkIha4qWj5WOsBpwZKBi3I IVKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=GeKcB8ORGxpti1PxzjsIlQCW/aF1Bi0ns/PGPDEyR6E=; b=YvvhYJdksGupf+R+BdrtG/w4iTBqghRPYkwaQpJbfxohzUTUR5O6HmUmpSo4jB7M8j 1ePTEezsBzbh/N3TeCYEYvi0XStURBLBwFuuXFt/4BC46DXeWZLGRYfrtrg3MCOCZT0o VnSIusWDTR9GCFK4wpbiGXnuzRRdcrdfyn2kQ3UX50SLhxyyPkMo1C4XHykrf1H/ABPN bpBhcE8vHe9gAJpnu+7WyPSb0bHzrDNMZm2+4tPq4AiO9e6MHkPmeIWJWOLiqo59ldDE o5BLY/FNR5LHX1c7dzrDoeJsxhQIhdxqmo/7SzsVe1DAbOXoBLdB4L5hf7h8J9/tJakU W4ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j92yXq+7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b49si660538edd.222.2019.05.19.13.50.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:50:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j92yXq+7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSlS-00055k-F9 for patch@linaro.org; Sun, 19 May 2019 16:50:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZA-0003BM-VP for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ8-0003mt-9n for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:56 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:34651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ8-0003lk-0F for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:54 -0400 Received: by mail-pg1-x541.google.com with SMTP id c13so5747823pgt.1 for ; Sun, 19 May 2019 13:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GeKcB8ORGxpti1PxzjsIlQCW/aF1Bi0ns/PGPDEyR6E=; b=j92yXq+7FpToCWsunOJcSUVYTj0LBNI4AtXiBchZS+sPxaAoFyVQWQ6BP//+QsjE4N uXhHm0qau38fw3qjruOkX+x7lKsvTfAx+adSBvXKesSDYgL3TzETDFduujC6V/e9MMk2 YsyJJAAI3mClXpEiR/h5H3JhkplBQH0Ps8vCrjNQgeltIabmBmJRbq5L31OAQEPFpujm f9TsrriPIMNrxcCnAW8Isj4hZ0whIWqbMyA46bqxT2CtnXCmXp305bT2P1X9e5UC7Od8 V4hUurt8uSbDG3a2T5iZkAnFFHB2sgNV9KOD8q+NXJXVxeDh/a1bOeVVEEwGsU9GGYld ND/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GeKcB8ORGxpti1PxzjsIlQCW/aF1Bi0ns/PGPDEyR6E=; b=ZIeinpWJjTc+aod2faaaDgUKsTO0S3F3t+84Tphp7xls+vQVjI7o66i/viB6yBnYqg k3siQgPHNUmRFp7e0MXl/YDzTq0mVRkqOKXlf0xA6rbZq9fSUO/Lp4No2mjtf/unuLR1 eklkAe8LNXottAsosSoHE3JJuvPHBvIaxJ0r5BUBKSOPDQJNBkGiDdqvjW7g+Stre9a5 ykwFI84Xu0y1NNhFvQSFNC15973Ms+6Z22hVpEzqd+51bFJLDVKpfgLWy1GA/BRW4ZLs EwUlicGrxnBD0W/vsfYP/lW4xR6jhwwAwY3yliSi4DSEIcUsrnFrLeSd/ZWTuBeWnMSc C5QA== X-Gm-Message-State: APjAAAXfkPWgqVGrJOl48kuDw9ZkvRssZoPqK4eAYVTZoNu2w9nQQHdI q695jjoSRHeRNtyPjtMBQs+RUmq6uAs= X-Received: by 2002:a62:b40a:: with SMTP id h10mr68782323pfn.216.1558298272127; Sun, 19 May 2019 13:37:52 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:29 -0700 Message-Id: <20190519203726.20729-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v7 17/74] linux-user: Split out clone, fork, vfork X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename do_fork to do_clone, since that is what it does. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 8 ++ linux-user/syscall.h | 1 + linux-user/strace.c | 36 +---- linux-user/syscall-proc.inc.c | 259 ++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 220 ----------------------------- linux-user/strace.list | 9 -- 6 files changed, 272 insertions(+), 261 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index c3ed22ff16..6f6f77927b 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -19,8 +19,12 @@ SYSCALL_DEF_FULL(brk, .impl = impl_brk, .print_ret = print_syscall_ptr_ret, .arg_type = { ARG_PTR }); +SYSCALL_DEF_ARGS(clone, ARG_CLONEFLAG, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); SYSCALL_DEF(close, ARG_DEC); SYSCALL_DEF(exit, ARG_DEC); +#ifdef TARGET_NR_fork +SYSCALL_DEF(fork); +#endif #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif @@ -110,5 +114,9 @@ SYSCALL_DEF(shmdt, ARG_PTR); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmget) SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #endif +#ifdef TARGET_NR_vfork +/* Emulate vfork() with fork(). */ +SYSCALL_DEF_FULL(vfork, .impl = impl_fork); +#endif SYSCALL_DEF(write, ARG_DEC, ARG_PTR, ARG_DEC); SYSCALL_DEF(writev, ARG_DEC, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 8175de4c31..f75cd3ddd0 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -58,6 +58,7 @@ typedef enum { /* These print as sets of flags. */ ARG_ATDIRFD, ARG_ATFLAG, + ARG_CLONEFLAG, ARG_MMAPFLAG, ARG_MMAPPROT, ARG_MODEFLAG, diff --git a/linux-user/strace.c b/linux-user/strace.c index 0a2c6764db..842136e425 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -813,7 +813,7 @@ static struct flags const mmap_flags[] = { FLAG_END, }; -UNUSED static struct flags clone_flags[] = { +static struct flags const clone_flags[] = { FLAG_GENERIC(CLONE_VM), FLAG_GENERIC(CLONE_FS), FLAG_GENERIC(CLONE_FILES), @@ -1195,37 +1195,6 @@ print_clock_adjtime(const struct syscallname *name, } #endif -#ifdef TARGET_NR_clone -static void do_print_clone(unsigned int flags, abi_ulong newsp, - abi_ulong parent_tidptr, target_ulong newtls, - abi_ulong child_tidptr) -{ - print_flags(clone_flags, flags, 0); - print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0); - print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0); - print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0); - print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1); -} - -static void -print_clone(const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) -{ - print_syscall_prologue(name); -#if defined(TARGET_MICROBLAZE) - do_print_clone(arg1, arg2, arg4, arg6, arg5); -#elif defined(TARGET_CLONE_BACKWARDS) - do_print_clone(arg1, arg2, arg3, arg4, arg5); -#elif defined(TARGET_CLONE_BACKWARDS2) - do_print_clone(arg2, arg1, arg3, arg5, arg4); -#else - do_print_clone(arg1, arg2, arg3, arg5, arg4); -#endif - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_creat static void print_creat(const struct syscallname *name, @@ -2533,6 +2502,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_ATFLAG: len = add_flags(b, rest, at_file_flags, arg, false); break; + case ARG_CLONEFLAG: + len = add_flags(b, rest, clone_flags, arg, false); + break; case ARG_MMAPFLAG: len = add_flags(b, rest, mmap_flags, arg, false); break; diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 96ad363c1a..9eda2b2ca2 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -16,6 +16,258 @@ * along with this program; if not, see . */ +#ifndef CLONE_IO +#define CLONE_IO 0x80000000 /* Clone io context */ +#endif + +/* + * We can't directly call the host clone syscall, because this will + * badly confuse libc (breaking mutexes, for example). So we must + * divide clone flags into: + * * flag combinations that look like pthread_create() + * * flag combinations that look like fork() + * * flags we can implement within QEMU itself + * * flags we can't support and will return an error for + * + * For thread creation, all these flags must be present; for + * fork, none must be present. + */ +#define CLONE_THREAD_FLAGS \ + (CLONE_VM | CLONE_FS | CLONE_FILES | \ + CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM) + +/* + * These flags are ignored: + * CLONE_DETACHED is now ignored by the kernel; + * CLONE_IO is just an optimisation hint to the I/O scheduler + */ +#define CLONE_IGNORED_FLAGS \ + (CLONE_DETACHED | CLONE_IO) + +/* Flags for fork which we can implement within QEMU itself */ +#define CLONE_OPTIONAL_FORK_FLAGS \ + (CLONE_SETTLS | CLONE_PARENT_SETTID | \ + CLONE_CHILD_CLEARTID | CLONE_CHILD_SETTID) + +/* Flags for thread creation which we can implement within QEMU itself */ +#define CLONE_OPTIONAL_THREAD_FLAGS \ + (CLONE_SETTLS | CLONE_PARENT_SETTID | \ + CLONE_CHILD_CLEARTID | CLONE_CHILD_SETTID | CLONE_PARENT) + +#define CLONE_INVALID_FORK_FLAGS \ + (~(CSIGNAL | CLONE_OPTIONAL_FORK_FLAGS | CLONE_IGNORED_FLAGS)) + +#define CLONE_INVALID_THREAD_FLAGS \ + (~(CSIGNAL | CLONE_THREAD_FLAGS | CLONE_OPTIONAL_THREAD_FLAGS | \ + CLONE_IGNORED_FLAGS)) + +/* + * CLONE_VFORK is special cased early in do_fork(). The other flag bits + * have almost all been allocated. We cannot support any of + * CLONE_NEWNS, CLONE_NEWCGROUP, CLONE_NEWUTS, CLONE_NEWIPC, + * CLONE_NEWUSER, CLONE_NEWPID, CLONE_NEWNET, CLONE_PTRACE, CLONE_UNTRACED. + * The checks against the invalid thread masks above will catch these. + * (The one remaining unallocated bit is 0x1000 which used to be CLONE_PID.) + */ + +/** + * do_clone: + * Arguments as for clone(2), returns target errnos. + */ +static abi_long do_clone(CPUArchState *env, unsigned int flags, + abi_ulong newsp, abi_ulong parent_tidptr, + abi_ulong child_tidptr, target_ulong newtls) +{ + CPUState *cpu = ENV_GET_CPU(env); + abi_long ret; + TaskState *ts; + CPUState *new_cpu; + CPUArchState *new_env; + sigset_t sigmask; + + flags &= ~CLONE_IGNORED_FLAGS; + + /* Emulate vfork() with fork() */ + if (flags & CLONE_VFORK) { + flags &= ~(CLONE_VFORK | CLONE_VM); + } + + if (flags & CLONE_VM) { + /* If CLONE_VM, we consider it a new thread. */ + TaskState *parent_ts = (TaskState *)cpu->opaque; + new_thread_info info; + pthread_attr_t attr; + + if (((flags & CLONE_THREAD_FLAGS) != CLONE_THREAD_FLAGS) || + (flags & CLONE_INVALID_THREAD_FLAGS)) { + return -TARGET_EINVAL; + } + + ts = g_new0(TaskState, 1); + init_task_state(ts); + + /* Grab a mutex so that thread setup appears atomic. */ + pthread_mutex_lock(&clone_lock); + + /* Create a new CPU instance. */ + new_env = cpu_copy(env); + + /* Init regs that differ from the parent. */ + cpu_clone_regs_child(new_env, newsp); + cpu_clone_regs_parent(env); + new_cpu = ENV_GET_CPU(new_env); + new_cpu->opaque = ts; + ts->bprm = parent_ts->bprm; + ts->info = parent_ts->info; + ts->signal_mask = parent_ts->signal_mask; + + if (flags & CLONE_CHILD_CLEARTID) { + ts->child_tidptr = child_tidptr; + } + + if (flags & CLONE_SETTLS) { + cpu_set_tls(new_env, newtls); + } + + memset(&info, 0, sizeof(info)); + pthread_mutex_init(&info.mutex, NULL); + pthread_mutex_lock(&info.mutex); + pthread_cond_init(&info.cond, NULL); + info.env = new_env; + if (flags & CLONE_CHILD_SETTID) { + info.child_tidptr = child_tidptr; + } + if (flags & CLONE_PARENT_SETTID) { + info.parent_tidptr = parent_tidptr; + } + + ret = pthread_attr_init(&attr); + ret = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE); + ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + /* + * It is not safe to deliver signals until the child has finished + * initializing, so temporarily block all signals. + */ + sigfillset(&sigmask); + sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask); + + /* + * If this is our first additional thread, we need to ensure we + * generate code for parallel execution and flush old translations. + */ + if (!parallel_cpus) { + parallel_cpus = true; + tb_flush(cpu); + } + + ret = pthread_create(&info.thread, &attr, clone_func, &info); + /* TODO: Free new CPU state if thread creation failed. */ + + sigprocmask(SIG_SETMASK, &info.sigmask, NULL); + pthread_attr_destroy(&attr); + if (ret == 0) { + /* Wait for the child to initialize. */ + pthread_cond_wait(&info.cond, &info.mutex); + ret = info.tid; + } else { + ret = host_to_target_errno(ret); + } + pthread_mutex_unlock(&info.mutex); + pthread_cond_destroy(&info.cond); + pthread_mutex_destroy(&info.mutex); + pthread_mutex_unlock(&clone_lock); + } else { + /* If no CLONE_VM, we consider it a fork. */ + if (flags & CLONE_INVALID_FORK_FLAGS) { + return -TARGET_EINVAL; + } + + /* We can't support custom termination signals. */ + if ((flags & CSIGNAL) != TARGET_SIGCHLD) { + return -TARGET_EINVAL; + } + + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + + fork_start(); + ret = fork(); + if (ret == 0) { + /* Child Process. */ + cpu_clone_regs_child(env, newsp); + fork_end(1); + /* + * There is a race condition here. The parent process could + * theoretically read the TID in the child process before the + * child tid is set. This would require using either ptrace + * (not implemented) or having *_tidptr to point at a shared + * memory mapping. We can't repeat the spinlock hack used + * above because the child process gets its own copy of the lock. + */ + if (flags & CLONE_CHILD_SETTID) { + put_user_u32(sys_gettid(), child_tidptr); + } + if (flags & CLONE_PARENT_SETTID) { + put_user_u32(sys_gettid(), parent_tidptr); + } + ts = (TaskState *)cpu->opaque; + if (flags & CLONE_SETTLS) { + cpu_set_tls(env, newtls); + } + if (flags & CLONE_CHILD_CLEARTID) { + ts->child_tidptr = child_tidptr; + } + } else { + cpu_clone_regs_parent(env); + fork_end(0); + ret = get_errno(ret); + } + } + return ret; +} + +#if defined(TARGET_MICROBLAZE) || \ + defined(TARGET_CLONE_BACKWARDS) || \ + defined(TARGET_CLONE_BACKWARDS2) +SYSCALL_ARGS(clone) +{ + /* + * Linux manages to have three "standard" orderings for its + * arguments to clone(); the BACKWARDS and BACKWARDS2 defines + * match the kernel's CONFIG_CLONE_* settings. + * Microblaze is further special in that it uses a sixth + * implicit argument to clone for the TLS pointer. + * + * Standardize on the non-BACKWARDS ordering. + */ +# if defined(TARGET_MICROBLAZE) + /* We have already assigned out[0-1]. */ + out[2] = in[3]; + out[3] = in[4]; + out[4] = in[5]; +# elif defined(TARGET_CLONE_BACKWARDS) + /* We have already assigned out[0-2]. */ + out[3] = in[4]; + out[4] = in[3]; +# elif defined(TARGET_CLONE_BACKWARDS2) + /* We have already assigned out[2-4]. */ + out[0] = in[1]; + out[1] = in[0]; +# else +# error Missing case +# endif + return def; +} +#else +#define args_clone NULL +#endif + +SYSCALL_IMPL(clone) +{ + return do_clone(cpu_env, arg1, arg2, arg3, arg4, arg5); +} SYSCALL_IMPL(exit) { @@ -59,3 +311,10 @@ SYSCALL_IMPL(exit) preexit_cleanup(cpu_env, status); _exit(status); } + +#if defined(TARGET_NR_fork) || defined(TARGET_NR_vfork) +SYSCALL_IMPL(fork) +{ + return do_clone(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0); +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4c9953a7ab..26140ebb2f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -110,57 +110,6 @@ #include "fd-trans.h" #include "syscall.h" -#ifndef CLONE_IO -#define CLONE_IO 0x80000000 /* Clone io context */ -#endif - -/* We can't directly call the host clone syscall, because this will - * badly confuse libc (breaking mutexes, for example). So we must - * divide clone flags into: - * * flag combinations that look like pthread_create() - * * flag combinations that look like fork() - * * flags we can implement within QEMU itself - * * flags we can't support and will return an error for - */ -/* For thread creation, all these flags must be present; for - * fork, none must be present. - */ -#define CLONE_THREAD_FLAGS \ - (CLONE_VM | CLONE_FS | CLONE_FILES | \ - CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM) - -/* These flags are ignored: - * CLONE_DETACHED is now ignored by the kernel; - * CLONE_IO is just an optimisation hint to the I/O scheduler - */ -#define CLONE_IGNORED_FLAGS \ - (CLONE_DETACHED | CLONE_IO) - -/* Flags for fork which we can implement within QEMU itself */ -#define CLONE_OPTIONAL_FORK_FLAGS \ - (CLONE_SETTLS | CLONE_PARENT_SETTID | \ - CLONE_CHILD_CLEARTID | CLONE_CHILD_SETTID) - -/* Flags for thread creation which we can implement within QEMU itself */ -#define CLONE_OPTIONAL_THREAD_FLAGS \ - (CLONE_SETTLS | CLONE_PARENT_SETTID | \ - CLONE_CHILD_CLEARTID | CLONE_CHILD_SETTID | CLONE_PARENT) - -#define CLONE_INVALID_FORK_FLAGS \ - (~(CSIGNAL | CLONE_OPTIONAL_FORK_FLAGS | CLONE_IGNORED_FLAGS)) - -#define CLONE_INVALID_THREAD_FLAGS \ - (~(CSIGNAL | CLONE_THREAD_FLAGS | CLONE_OPTIONAL_THREAD_FLAGS | \ - CLONE_IGNORED_FLAGS)) - -/* CLONE_VFORK is special cased early in do_fork(). The other flag bits - * have almost all been allocated. We cannot support any of - * CLONE_NEWNS, CLONE_NEWCGROUP, CLONE_NEWUTS, CLONE_NEWIPC, - * CLONE_NEWUSER, CLONE_NEWPID, CLONE_NEWNET, CLONE_PTRACE, CLONE_UNTRACED. - * The checks against the invalid thread masks above will catch these. - * (The one remaining unallocated bit is 0x1000 which used to be CLONE_PID.) - */ - /* Define DEBUG_ERESTARTSYS to force every syscall to be restarted * once. This exercises the codepaths for restart. */ @@ -4450,148 +4399,6 @@ static void *clone_func(void *arg) return NULL; } -/* do_fork() Must return host values and target errnos (unlike most - do_*() functions). */ -static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, - abi_ulong parent_tidptr, target_ulong newtls, - abi_ulong child_tidptr) -{ - CPUState *cpu = ENV_GET_CPU(env); - int ret; - TaskState *ts; - CPUState *new_cpu; - CPUArchState *new_env; - sigset_t sigmask; - - flags &= ~CLONE_IGNORED_FLAGS; - - /* Emulate vfork() with fork() */ - if (flags & CLONE_VFORK) - flags &= ~(CLONE_VFORK | CLONE_VM); - - if (flags & CLONE_VM) { - TaskState *parent_ts = (TaskState *)cpu->opaque; - new_thread_info info; - pthread_attr_t attr; - - if (((flags & CLONE_THREAD_FLAGS) != CLONE_THREAD_FLAGS) || - (flags & CLONE_INVALID_THREAD_FLAGS)) { - return -TARGET_EINVAL; - } - - ts = g_new0(TaskState, 1); - init_task_state(ts); - - /* Grab a mutex so that thread setup appears atomic. */ - pthread_mutex_lock(&clone_lock); - - /* we create a new CPU instance. */ - new_env = cpu_copy(env); - /* Init regs that differ from the parent. */ - cpu_clone_regs_child(new_env, newsp); - cpu_clone_regs_parent(env); - new_cpu = ENV_GET_CPU(new_env); - new_cpu->opaque = ts; - ts->bprm = parent_ts->bprm; - ts->info = parent_ts->info; - ts->signal_mask = parent_ts->signal_mask; - - if (flags & CLONE_CHILD_CLEARTID) { - ts->child_tidptr = child_tidptr; - } - - if (flags & CLONE_SETTLS) { - cpu_set_tls (new_env, newtls); - } - - memset(&info, 0, sizeof(info)); - pthread_mutex_init(&info.mutex, NULL); - pthread_mutex_lock(&info.mutex); - pthread_cond_init(&info.cond, NULL); - info.env = new_env; - if (flags & CLONE_CHILD_SETTID) { - info.child_tidptr = child_tidptr; - } - if (flags & CLONE_PARENT_SETTID) { - info.parent_tidptr = parent_tidptr; - } - - ret = pthread_attr_init(&attr); - ret = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE); - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - /* It is not safe to deliver signals until the child has finished - initializing, so temporarily block all signals. */ - sigfillset(&sigmask); - sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask); - - /* If this is our first additional thread, we need to ensure we - * generate code for parallel execution and flush old translations. - */ - if (!parallel_cpus) { - parallel_cpus = true; - tb_flush(cpu); - } - - ret = pthread_create(&info.thread, &attr, clone_func, &info); - /* TODO: Free new CPU state if thread creation failed. */ - - sigprocmask(SIG_SETMASK, &info.sigmask, NULL); - pthread_attr_destroy(&attr); - if (ret == 0) { - /* Wait for the child to initialize. */ - pthread_cond_wait(&info.cond, &info.mutex); - ret = info.tid; - } else { - ret = -1; - } - pthread_mutex_unlock(&info.mutex); - pthread_cond_destroy(&info.cond); - pthread_mutex_destroy(&info.mutex); - pthread_mutex_unlock(&clone_lock); - } else { - /* if no CLONE_VM, we consider it is a fork */ - if (flags & CLONE_INVALID_FORK_FLAGS) { - return -TARGET_EINVAL; - } - - /* We can't support custom termination signals */ - if ((flags & CSIGNAL) != TARGET_SIGCHLD) { - return -TARGET_EINVAL; - } - - if (block_signals()) { - return -TARGET_ERESTARTSYS; - } - - fork_start(); - ret = fork(); - if (ret == 0) { - /* Child Process. */ - cpu_clone_regs_child(env, newsp); - fork_end(1); - /* There is a race condition here. The parent process could - theoretically read the TID in the child process before the child - tid is set. This would require using either ptrace - (not implemented) or having *_tidptr to point at a shared memory - mapping. We can't repeat the spinlock hack used above because - the child process gets its own copy of the lock. */ - if (flags & CLONE_CHILD_SETTID) - put_user_u32(sys_gettid(), child_tidptr); - if (flags & CLONE_PARENT_SETTID) - put_user_u32(sys_gettid(), parent_tidptr); - ts = (TaskState *)cpu->opaque; - if (flags & CLONE_SETTLS) - cpu_set_tls (env, newtls); - if (flags & CLONE_CHILD_CLEARTID) - ts->child_tidptr = child_tidptr; - } else { - cpu_clone_regs_parent(env); - fork_end(0); - } - } - return ret; -} - /* warning : doesn't handle linux specific flags... */ static int target_to_host_fcntl_cmd(int cmd) { @@ -5590,10 +5397,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_fork - case TARGET_NR_fork: - return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); -#endif #ifdef TARGET_NR_waitpid case TARGET_NR_waitpid: { @@ -7283,23 +7086,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fsync: return get_errno(fsync(arg1)); - case TARGET_NR_clone: - /* Linux manages to have three different orderings for its - * arguments to clone(); the BACKWARDS and BACKWARDS2 defines - * match the kernel's CONFIG_CLONE_* settings. - * Microblaze is further special in that it uses a sixth - * implicit argument to clone for the TLS pointer. - */ -#if defined(TARGET_MICROBLAZE) - ret = get_errno(do_fork(cpu_env, arg1, arg2, arg4, arg6, arg5)); -#elif defined(TARGET_CLONE_BACKWARDS) - ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); -#elif defined(TARGET_CLONE_BACKWARDS2) - ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4)); -#else - ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); -#endif - return ret; #ifdef __NR_exit_group /* new thread calls */ case TARGET_NR_exit_group: @@ -8170,12 +7956,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #endif #endif -#ifdef TARGET_NR_vfork - case TARGET_NR_vfork: - return get_errno(do_fork(cpu_env, - CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD, - 0, 0, 0, 0)); -#endif #ifdef TARGET_NR_ugetrlimit case TARGET_NR_ugetrlimit: { diff --git a/linux-user/strace.list b/linux-user/strace.list index aff6d1d73d..76d983a882 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -91,9 +91,6 @@ #ifdef TARGET_NR_clock_settime { TARGET_NR_clock_settime, "clock_settime" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_clone -{ TARGET_NR_clone, "clone" , NULL, print_clone, NULL }, -#endif #ifdef TARGET_NR_connect { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL }, #endif @@ -220,9 +217,6 @@ #ifdef TARGET_NR_flock { TARGET_NR_flock, "flock" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_fork -{ TARGET_NR_fork, "fork" , "%s()", NULL, NULL }, -#endif #ifdef TARGET_NR_fremovexattr { TARGET_NR_fremovexattr, "fremovexattr" , NULL, NULL, NULL }, #endif @@ -1485,9 +1479,6 @@ #ifdef TARGET_NR_utrap_install { TARGET_NR_utrap_install, "utrap_install" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_vfork -{ TARGET_NR_vfork, "vfork" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_vhangup { TARGET_NR_vhangup, "vhangup" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164506 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4786477ili; Sun, 19 May 2019 13:51:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwy4SExLjaUkU71ncWG2+5TNKsTwdUNeSDI/YdGTkxf1q6XYOu0R0VizUqXIs8tzX0hx+K X-Received: by 2002:a17:906:3955:: with SMTP id g21mr54939088eje.61.1558299088316; Sun, 19 May 2019 13:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299088; cv=none; d=google.com; s=arc-20160816; b=0jPxX9gGQvm5tUUforw0qtNuGKly84zdUor4U85PE+DTLrUEpbQbiuaxrsNTPc+JEP m342/kNLnAaXQG6jQMyIFjgJ8gmDiSNG16BJr1vA9NjH4dn/Iiu2t7Cv6RzqLtylRXIL YxqMEr3e7NACxINA1pQ/IuFTmG7LBCXuxKTDQ/4N13+UIIKED7AC8v3YttTn+a+nb2s/ xMHSRran5n6MIurKvT7zoUADL9QSEmueSzgvLV1G8AGnT2lZwPK8Vms9l7sDtJLYX9XK ChnK+iVJScVbIs6TYu32+cV8Z60B8L9w+gf8NN3EEr1nRYJfmnNovywgWkiQzo7iAR1g 0q2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=TKsC4B9qYWzPZIuweTYnPJXABDEFDxi0xaFzoRYmNLs=; b=GtKOhUaCfQopzS1nizLXO1ZbsHPyJBzPR/F9wLq6lUa8C6U63tl6WXz1IG3CcuH+RE pQIH8jDCTWKBFJ6j5F9ibDVIZhssNo0du2IuWjfUyn4FmK18N/bSfd5lNnsUjM7aMqnp weXZAjomOmY6EErU4fMsvwuxZ/FcjxoLXnCIAiaHzC+vxvYT7JHuUF9aczPFFJOBFqdB 4YaghDpdqqvQhed7oUW+SAPUc1Qdh6QgJTxYVZ/6f2WZ2Bw1jb5SCbIknhFcX4uu18r5 qUMqumzqBZYqVXB/kNLFytMIzgryz5Epc8iC0aUnxHlnfoYIsQQbNs3rH0AaxWvTo27k wQwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QEGzqTQg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c32si8373855eda.162.2019.05.19.13.51.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QEGzqTQg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSmF-0005mz-4N for patch@linaro.org; Sun, 19 May 2019 16:51:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZA-0003AT-6J for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZ8-0003nP-Nr for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:56 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:41972) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZ8-0003mZ-Gk for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:54 -0400 Received: by mail-pf1-x441.google.com with SMTP id q17so6155886pfq.8 for ; Sun, 19 May 2019 13:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TKsC4B9qYWzPZIuweTYnPJXABDEFDxi0xaFzoRYmNLs=; b=QEGzqTQgB0lQhcnAdwwRtHKJaLqFPQpn9L/wlIuumvZu9JoVG5Tql9UDF00cHto77b mgH4Ps2qOrrfjQo7EdYarpcGJPjugBWAIUvk+lxxxZAz0A8L2/I2pThd1bojPGDmBl+k SimJBBrLfAWIsC0kwf1bVB/Awu92Da78pDsZ8u9tebkmq4dyaJch//29c6P7pjOxl1om ZNJgLerKNwcHdueonc4cjH7g/chVmJN4KuKjz9GMkL/kF0w5YACrjqAp/plU7b1Lp0K6 ljS8Xb5rCB0nb+uT9dJZiEw9rjOOouA2Kncw2b9F4v4ldUMSXTKwDFLg/9vf+YH5uAx3 Lpkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TKsC4B9qYWzPZIuweTYnPJXABDEFDxi0xaFzoRYmNLs=; b=WUzClJnH++pcbjROB54H4jFOphqrXsYczfXm9jv555+MdtiLobYHJZT3OjqCKmWlkP +7bTVI3Xj0rDgvhuuRoU3MdZ7TOx4yoeV1t5K0l2fLV7esgYboIl3RZQEQ/c6pLtaH0h rxn5zJg1cSRncrfzrWvEr7kQGZqrbUtiytjXebe5H9ERZUmSRaQkW8TvOz7Brfs0mepk RChfwbPbobjc8WVW9qbsizsLaJ+weACQa3K7gxNT4zebW1vlsRggomlt/mhBCGkNoXxW wuZ5Lp52obdm3JZWcYyhWGJj/5GXe8xHLgBwwuk2QuyB0yyf0boHiZGPQ389Td/6PTn3 RZag== X-Gm-Message-State: APjAAAVZJGYLgtA3DmlahlviUwXyy+rtNa4DoBtfiPGDdTNFxXh9AK/V NDgAucl0CdslGbab6qiwLWgo23yPN5Q= X-Received: by 2002:a65:6559:: with SMTP id a25mr47361736pgw.33.1558298273296; Sun, 19 May 2019 13:37:53 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:30 -0700 Message-Id: <20190519203726.20729-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 18/74] linux-user: Split out wait4, waitid, waitpid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that waitid is universally provided and need not be conditional. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 5 ++ linux-user/syscall-proc.inc.c | 88 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 67 -------------------------- linux-user/strace.list | 9 ---- 4 files changed, 93 insertions(+), 76 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 6f6f77927b..a84050a318 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -118,5 +118,10 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); /* Emulate vfork() with fork(). */ SYSCALL_DEF_FULL(vfork, .impl = impl_fork); #endif +SYSCALL_DEF(wait4, ARG_DEC, ARG_PTR, ARG_HEX, ARG_PTR); +SYSCALL_DEF(waitid, ARG_HEX, ARG_DEC, ARG_PTR, ARG_HEX); +#ifdef TARGET_NR_waitpid +SYSCALL_DEF(waitpid, ARG_DEC, ARG_PTR, ARG_HEX); +#endif SYSCALL_DEF(write, ARG_DEC, ARG_PTR, ARG_DEC); SYSCALL_DEF(writev, ARG_DEC, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 9eda2b2ca2..7c647f36d7 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -318,3 +318,91 @@ SYSCALL_IMPL(fork) return do_clone(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0); } #endif + +/* + * Map host to target signal numbers for the wait family of syscalls. + * Assume all other status bits are the same. + */ +int host_to_target_waitstatus(int status) +{ + if (WIFSIGNALED(status)) { + return host_to_target_signal(WTERMSIG(status)) | (status & ~0x7f); + } + if (WIFSTOPPED(status)) { + return (host_to_target_signal(WSTOPSIG(status)) << 8) + | (status & 0xff); + } + return status; +} + +SYSCALL_IMPL(wait4) +{ + int status; + pid_t pid = arg1; + abi_ulong status_ptr = arg2; + int options = arg3; + abi_ulong target_rusage = arg4; + struct rusage rusage; + struct rusage *rusage_ptr = target_rusage ? &rusage : NULL; + abi_long ret; + + ret = get_errno(safe_wait4(pid, &status, options, rusage_ptr)); + if (!is_error(ret)) { + if (status_ptr && ret) { + status = host_to_target_waitstatus(status); + if (put_user_s32(status, status_ptr)) { + return -TARGET_EFAULT; + } + } + if (target_rusage) { + abi_long err = host_to_target_rusage(target_rusage, &rusage); + if (err) { + ret = err; + } + } + } + return ret; +} + +SYSCALL_IMPL(waitid) +{ + idtype_t idtype = arg1; + id_t id = arg2; + abi_ulong target_info = arg3; + int options = arg4; + siginfo_t info, *info_ptr = target_info ? &info : NULL; + abi_long ret; + + info.si_pid = 0; + ret = get_errno(safe_waitid(idtype, id, info_ptr, options, NULL)); + if (!is_error(ret) && target_info && info.si_pid != 0) { + target_siginfo_t *p = lock_user(VERIFY_WRITE, target_info, + sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, target_info, sizeof(target_siginfo_t)); + } + return ret; +} + +#ifdef TARGET_NR_waitpid +SYSCALL_IMPL(waitpid) +{ + pid_t pid = arg1; + abi_ulong target_status = arg2; + int options = arg3; + int status; + abi_long ret; + + ret = get_errno(safe_wait4(pid, &status, options, NULL)); + if (!is_error(ret) + && target_status + && ret + && put_user_s32(host_to_target_waitstatus(status), target_status)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 26140ebb2f..bdb0d45d9a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5271,20 +5271,6 @@ static abi_long do_signalfd4(int fd, abi_long mask, int flags) } #endif -/* Map host to target signal numbers for the wait family of syscalls. - Assume all other status bits are the same. */ -int host_to_target_waitstatus(int status) -{ - if (WIFSIGNALED(status)) { - return host_to_target_signal(WTERMSIG(status)) | (status & ~0x7f); - } - if (WIFSTOPPED(status)) { - return (host_to_target_signal(WSTOPSIG(status)) << 8) - | (status & 0xff); - } - return status; -} - #define TIMER_MAGIC 0x0caf0000 #define TIMER_MAGIC_MASK 0xffff0000 @@ -5397,32 +5383,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_waitpid - case TARGET_NR_waitpid: - { - int status; - ret = get_errno(safe_wait4(arg1, &status, arg3, 0)); - if (!is_error(ret) && arg2 && ret - && put_user_s32(host_to_target_waitstatus(status), arg2)) - return -TARGET_EFAULT; - } - return ret; -#endif -#ifdef TARGET_NR_waitid - case TARGET_NR_waitid: - { - siginfo_t info; - info.si_pid = 0; - ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL)); - if (!is_error(ret) && arg3 && info.si_pid != 0) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0))) - return -TARGET_EFAULT; - host_to_target_siginfo(p, &info); - unlock_user(p, arg3, sizeof(target_siginfo_t)); - } - } - return ret; -#endif #ifdef TARGET_NR_creat /* not on alpha */ case TARGET_NR_creat: if (!(p = lock_user_string(arg1))) @@ -7022,33 +6982,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 0); #endif - case TARGET_NR_wait4: - { - int status; - abi_long status_ptr = arg2; - struct rusage rusage, *rusage_ptr; - abi_ulong target_rusage = arg4; - abi_long rusage_err; - if (target_rusage) - rusage_ptr = &rusage; - else - rusage_ptr = NULL; - ret = get_errno(safe_wait4(arg1, &status, arg3, rusage_ptr)); - if (!is_error(ret)) { - if (status_ptr && ret) { - status = host_to_target_waitstatus(status); - if (put_user_s32(status, status_ptr)) - return -TARGET_EFAULT; - } - if (target_rusage) { - rusage_err = host_to_target_rusage(target_rusage, &rusage); - if (rusage_err) { - ret = rusage_err; - } - } - } - } - return ret; #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 76d983a882..759b35458e 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1494,15 +1494,6 @@ #ifdef TARGET_NR_vserver { TARGET_NR_vserver, "vserver" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_wait4 -{ TARGET_NR_wait4, "wait4" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_waitid -{ TARGET_NR_waitid, "waitid" , "%s(%#x,%d,%p,%#x)", NULL, NULL }, -#endif -#ifdef TARGET_NR_waitpid -{ TARGET_NR_waitpid, "waitpid" , "%s(%d,%p,%#x)", NULL, NULL }, -#endif #ifdef TARGET_NR_utimensat { TARGET_NR_utimensat, "utimensat", NULL, print_utimensat, NULL }, #endif From patchwork Sun May 19 20:36:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164510 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4788389ili; Sun, 19 May 2019 13:54:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqywpZDooKYdRVHjgefq24xPhCos/ME2kJo3wF9srFYOOsVAt2LHy2fcaLHSnEwZUdiYv1F2 X-Received: by 2002:a17:906:110c:: with SMTP id h12mr36036300eja.269.1558299277619; Sun, 19 May 2019 13:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299277; cv=none; d=google.com; s=arc-20160816; b=UyUlFxYtHxLD+iqMAl+IzGSTUamCADMupmzytxLg0SP98xMWSMaN3MKTNGH9gzP6lW re9sm6WCSULHEDrAQGGhYafiIG0zI7SnF1bo8EOJoIXsFdjKxeQSyuqFOV9KkTzFUVnv /GxNcpKBWf7jalUOYvNmLqQWWTgjhu5ve96pYGLzyMKmZ+GeMMg7US0LjKDruceQJqOs 84okUW25hTjQSuPl4pYKQ20P30H2R5UjU67cax1SsAF+QzwB8VxbreKRZmdlqWh2Cwn0 YamoBPpc6pthyMn3N217YBVIi6NM2N65vj2feut8SF6hXbqkDrZqaKftw38NsdRlr9oH Rw5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ivbPF9AA08UpYLCiKojYQPTAvKrugZNh3dcbIM2DPu8=; b=LAorZ5st7zT6RGhTedpQRjNBFKC9DystFKSSeZjR1TFTPd4LOZaSTcebOOYmDGL4XI yFzFxh80dFwGqWVD6Z1Uh713+3LWnj8BwuVUW3VADmGehra2jwvc+3eSO8jl9gy9bDtp 1ruLmynoxrj+hGsAPB58QoOKGqIpP3LhfwJstNKP8C8NsCOov2aGaBhMgLvQZZW5/KXU TQUwSva4ApcMTQ9FBy8uXeBveoGaNJneaVSTH2i7mw7JdVG9Vuo8EfBkk3YU9uL7Um0T lxtud7Ybgy9XsbfVdy6TacXA3gx+ZT1fJsaYgz5YfjGN2LI4aRAJ4MTDdooVwn7p13Uq bHpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SEGoWLAg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s4si5346833edm.64.2019.05.19.13.54.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SEGoWLAg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSpI-0008Mt-FM for patch@linaro.org; Sun, 19 May 2019 16:54:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZB-0003Be-9R for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZA-0003pH-Av for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:57 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:43808) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZA-0003oM-56 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:56 -0400 Received: by mail-pg1-x542.google.com with SMTP id t22so5725712pgi.10 for ; Sun, 19 May 2019 13:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ivbPF9AA08UpYLCiKojYQPTAvKrugZNh3dcbIM2DPu8=; b=SEGoWLAg+RZ4riZbIc9naxcWLRTzjediGWpq+QTz2q69v76H7vtAdmobl0AGbDZdoI MaGzazjNCp4ynnWbZItcjih5THmw/jn2+9wY8iLQ4YrqdfClw1SlkwkLAfPDhQbZ7v9L 88CrbuuuVAEo6g//NygY64sQOKlLLwnNIC+dw4gaLWju+cxxPq0sQqjW32LAL1qz78ca /X14LNquJlWDSmmHYJlU6uEwAC97etaUIJp8O8mZj3Gg3C4VCO2moZEPfZivYkSMg/It e8UsBBR2Vvmkq9FLGG63ndnoq6Bg431KBrwaYnmSo3p/WGQmoW6uNgKyWtcSsa0bEYUy G3sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ivbPF9AA08UpYLCiKojYQPTAvKrugZNh3dcbIM2DPu8=; b=Q0cp8bvm7KlfLfL1YaK42JC16p+KNZwPP1kJyhslKBoYy9vaQOpXCwWSGcsZ1iezeS EWqAMCX6BtK3f8YittEaxz8p+aoAanLsqfTI+V5wIy+4JaOP8p6MoDF/FzU0y4om7vqG K6QPvsWm10CmlVGgO6dJemm5b1xWqiWej+baBSRW0s5J9HMP3KxNGWhNiRsfoWictVa1 +4zwzUQR78W9ZtTgava4aqJsbzH38EXapoPC3ibh4gQEB3nPL+6I1dKqA4nkHvbXPGgn 3SNOslEjOtgJ68BZWgC9W9FH3DhNygBUhjYfRHaKcnXn35Z0PYc8j9gExv/1w1u0AG+m GcWw== X-Gm-Message-State: APjAAAUMHd+W/t2omA5JDvCRIgOKIhPlBGcQjlhd04fKfA2e9EPK3Z7B VBFBnGXRgyAE0fkLVIUmSpgJpR0YKsM= X-Received: by 2002:a62:d205:: with SMTP id c5mr75464414pfg.219.1558298274771; Sun, 19 May 2019 13:37:54 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:31 -0700 Message-Id: <20190519203726.20729-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v7 19/74] linux-user: Implement rusage argument to waitid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The kernel interface, which we are supposed to be implementing, takes a fifth argument: an rusage pointer akin to wait4. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 +- linux-user/syscall-proc.inc.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index a84050a318..f099d98fa3 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -119,7 +119,7 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); SYSCALL_DEF_FULL(vfork, .impl = impl_fork); #endif SYSCALL_DEF(wait4, ARG_DEC, ARG_PTR, ARG_HEX, ARG_PTR); -SYSCALL_DEF(waitid, ARG_HEX, ARG_DEC, ARG_PTR, ARG_HEX); +SYSCALL_DEF(waitid, ARG_HEX, ARG_DEC, ARG_PTR, ARG_HEX, ARG_PTR); #ifdef TARGET_NR_waitpid SYSCALL_DEF(waitpid, ARG_DEC, ARG_PTR, ARG_HEX); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 7c647f36d7..b7304b7a42 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -370,19 +370,30 @@ SYSCALL_IMPL(waitid) id_t id = arg2; abi_ulong target_info = arg3; int options = arg4; + abi_ulong target_rusage = arg5; siginfo_t info, *info_ptr = target_info ? &info : NULL; + struct rusage rusage; + struct rusage *rusage_ptr = target_rusage ? &rusage : NULL; abi_long ret; info.si_pid = 0; - ret = get_errno(safe_waitid(idtype, id, info_ptr, options, NULL)); - if (!is_error(ret) && target_info && info.si_pid != 0) { - target_siginfo_t *p = lock_user(VERIFY_WRITE, target_info, - sizeof(target_siginfo_t), 0); - if (!p) { - return -TARGET_EFAULT; + ret = get_errno(safe_waitid(idtype, id, info_ptr, options, rusage_ptr)); + if (!is_error(ret)) { + if (target_info && info.si_pid != 0) { + target_siginfo_t *p = lock_user(VERIFY_WRITE, target_info, + sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, target_info, sizeof(target_siginfo_t)); + } + if (target_rusage) { + abi_long err = host_to_target_rusage(target_rusage, &rusage); + if (err) { + ret = err; + } } - host_to_target_siginfo(p, &info); - unlock_user(p, target_info, sizeof(target_siginfo_t)); } return ret; } From patchwork Sun May 19 20:36:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164509 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4787965ili; Sun, 19 May 2019 13:53:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGPzL2cgACicucFeByCU3acUhQq6tgkpkj4iJBlMlbC4JT28GDi08CdDu2Mk7ilpvSPmh3 X-Received: by 2002:a50:b7bc:: with SMTP id h57mr55547827ede.77.1558299230353; Sun, 19 May 2019 13:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299230; cv=none; d=google.com; s=arc-20160816; b=mXY6XBGBFGmUm4lPqwwdcXMmTxfhuhZAol9Msjrfb3e37XU1UrD9OSU7tOxQaMjux6 nF3TwkFDEE0sKouNml2wevofGoBM/AXHqhOXjm5ejn8CvXZe6mb3Iedsjbecqt95ZcS9 pi+7hg/LStw8TwSbYZ0RoCBtA20cbJrlskwfUc4Bw9KzCBSTaU7+BaNxs7JFUsf0fMUk 1EqzfRlYAdnokt2UFCUWWxhsPKD7li7abqw3tHeHwTFKwCxCYMOdlKFSxuKDvcG49ehB 9KXax19V/jPVdXaB9V8U0vIlU0Lp6ucIuHRgnzsMe8agzNG7VOXoDkZQHU345X+Ncnuy XxHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=NM8YohXjNmh5aO/78Xnvs2un3+sKv0xFoH3Xe6VAfyY=; b=LvopWXFaJJwDv+dciN3NQedjpQfpHBdQcZpJfAwrUxrQg0UHshaRBzjw/+MylgdiIH 91qkx/AXHLG6H7TjlDg51WF+ALodLIv0mqAm9k+JUorURhsh0yoSz0EfzQTV7ZG9gZ7s k9NCmLfHcffhwQrycvK5/Y8ZvxWga+to43kBx35tXdQg6e3Awy6OjjgFopfFW3cONyoi LXlZWGFM1ua4QcflBOuA4PeadpbU8mavz83m/HvAY5/5cBkuvVgy9padxwk7s/1FuR8g 2h3b91kpV/B1uaVWvztHhimYzEPMHnxvwiGF2wAiXRsblGEe5v63dNQhUmwX+G9ucrch masw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jUuFL8+P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h17si3507720ejf.169.2019.05.19.13.53.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jUuFL8+P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSoX-0007lO-4u for patch@linaro.org; Sun, 19 May 2019 16:53:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZC-0003DB-Ab for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZB-0003qW-89 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:58 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:38179) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZB-0003pY-1A for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:57 -0400 Received: by mail-pg1-x543.google.com with SMTP id j26so5740758pgl.5 for ; Sun, 19 May 2019 13:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NM8YohXjNmh5aO/78Xnvs2un3+sKv0xFoH3Xe6VAfyY=; b=jUuFL8+PmCYyXNNWJMqmhoYeb3XOWwsea+DvhQ+2Px1BxVUrdCGROdI+MKDNF24Htn AXNk48XnhF0Y5fa5YZ6PBcLZ9JxlftTDpW+nszdOHE0O+FtR5/34W08QiDJZM9svpk1e g5QY3SFFoeYARGkXrgLVdxhcWC9GwhEZYeNiVeIzQ+uE/WeWM0UwmLpNFGuPZjMx/i5D AMrx1aMqPnV0u0G4wZtQkbeSyJgwaeKOFCtUFIjOMmNEkJwEoGry7aOPwfmubtNhhoZ/ n/Q66jMVqqCrhuAN640+/uFv6WSCvIatyh8nYjJVbPUiSAQvbIo1V5eHq06dOFhtNvHI iEsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NM8YohXjNmh5aO/78Xnvs2un3+sKv0xFoH3Xe6VAfyY=; b=f9HTqn4Whxt5gm7AFTRyYMNAx/cvy/fzajunX4WiR6oTmMlt/JG5x7gV8GJ5cgFQMV 46tOt6rmDvGubdnB1pg6MTdzt+ef7sAyjXf6u0J6d7iaq9VctmZ9fzsV+jbaK7r1yoYn JDaufWjztqPz+r3DvZDpuEydk4NVwUXeP3eoIf6Q71oIwkD2vrpbej582o/xSnVFCdvm CD5ACXsWQRxWqGyj+ApQMMwCKAShtIC74/Eaf0EoYmvcw849JPhueyKFnc/1gbGeuasx Wwgt8VPD3kR5owWDCoFZQn24Te2DpXdWQ5CWwNfiXbzT3xvLJizluZAtI0umPOskLonn cecA== X-Gm-Message-State: APjAAAU5b/7yJNesN76PlLwr2941MGmLewkMeybU7p2vK44ScN+ULttM pNA302QZpyoXkf638GqNNV3U9pEg45I= X-Received: by 2002:a63:d150:: with SMTP id c16mr71006064pgj.439.1558298275860; Sun, 19 May 2019 13:37:55 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:32 -0700 Message-Id: <20190519203726.20729-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v7 20/74] linux-user: Split out creat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 3 +++ linux-user/strace.c | 13 ------------- linux-user/syscall-file.inc.c | 16 ++++++++++++++++ linux-user/syscall.c | 9 --------- linux-user/strace.list | 3 --- 5 files changed, 19 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index f099d98fa3..de7a99f0c6 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -21,6 +21,9 @@ SYSCALL_DEF_FULL(brk, .impl = impl_brk, .arg_type = { ARG_PTR }); SYSCALL_DEF_ARGS(clone, ARG_CLONEFLAG, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); SYSCALL_DEF(close, ARG_DEC); +#ifdef TARGET_NR_creat +SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG); +#endif SYSCALL_DEF(exit, ARG_DEC); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); diff --git a/linux-user/strace.c b/linux-user/strace.c index 842136e425..640a80f32b 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1195,19 +1195,6 @@ print_clock_adjtime(const struct syscallname *name, } #endif -#ifdef TARGET_NR_creat -static void -print_creat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_file_mode(arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_execv static void print_execv(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index dd44d5b804..9b966ad627 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -24,6 +24,22 @@ SYSCALL_IMPL(close) return get_errno(close(fd)); } +#ifdef TARGET_NR_creat +SYSCALL_IMPL(creat) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(creat(p, arg2)); + fd_trans_unregister(ret); + unlock_user(p, arg1, 0); + return ret; +} +#endif + /* * Helpers for do_openat, manipulating /proc/self/foo. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bdb0d45d9a..491e1d7cfb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5383,15 +5383,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_creat /* not on alpha */ - case TARGET_NR_creat: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(creat(p, arg2)); - fd_trans_unregister(ret); - unlock_user(p, arg1, 0); - return ret; -#endif #ifdef TARGET_NR_link case TARGET_NR_link: { diff --git a/linux-user/strace.list b/linux-user/strace.list index 759b35458e..41f8f8d0d0 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -94,9 +94,6 @@ #ifdef TARGET_NR_connect { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL }, #endif -#ifdef TARGET_NR_creat -{ TARGET_NR_creat, "creat" , NULL, print_creat, NULL }, -#endif #ifdef TARGET_NR_create_module { TARGET_NR_create_module, "create_module" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164515 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4789952ili; Sun, 19 May 2019 13:57:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/JCiUsQxZeOnr1zZRkQ3PfAC/s0mAc0ZDohOMUFXIsq2RVs4hvRvv1YNtkfzCdWUKbOah X-Received: by 2002:a50:add7:: with SMTP id b23mr70580574edd.215.1558299455430; Sun, 19 May 2019 13:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299455; cv=none; d=google.com; s=arc-20160816; b=uU6DBHA6wJaBGEfey3+toIVfrGrxK2nXPYg4ihiZzBa40sGreT8ODUQ4BW52MT5oqQ G1NvFgIYAQmYe8LyOSrrHwM9axXoLhKo22TC8N/EhClILhbr/R+EK+ZnXR1m1f+HXgSt WRQfAsYpsFJsZpavKYsdAv68Y2vYT/qso4iQS93XDLwi/4E9mbPwqPQZ9RoBthK+yUyg Z3bUkwzINAAJ49dXku9Gajr9s4k/oe054N+zMaYkzWY8FbiaSVAMBkiT9PS4zFMRcspX HN6cPMfjtJITkEv1HLXuThfQNqpoEx/d+TGRjP9tya7TUQckOgy46Dna1b4QBoNLkBys t3Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=3+YujhkwUcm32OaJhXi3plbLKoShJGj44pRi7jq0BsI=; b=qJfW/rRCwn5mKl2o+4ejJwWXIbw5YV6ZXfW65mExQj+Bso4UrXmMEx0/9cFna8azIe 1Fadqjr4/09hVseQdt25zbTN2auvCL4OveUDGiwfIxQA3hFObwSCZfaK3ajLevlEvKRw szCM1KOYm11g2t4FjM8MNounjBljMAp5auZobEVs+1B3Lnj2umm/0DHxiLQ+S4sTEQBI dSo0aJ//pfNmAXEbDUqdL/eIKKGjNmivRfOwkmk8CiHV/u20YTCV50chMNk4LZOsl5At 1FzdQbCgBsB1LLkS7DqFbwmKHQjyKigK4ZLwplExrHwWbWgX+62APi9Z5QtFiAj3OAd5 GEaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=whhRNYqL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f29si12509058eda.310.2019.05.19.13.57.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:57:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=whhRNYqL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSsA-0002X1-8u for patch@linaro.org; Sun, 19 May 2019 16:57:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZD-0003Ie-Q0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZC-0003sB-Fo for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:59 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:46927) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZC-0003rG-9L for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:58 -0400 Received: by mail-pl1-x642.google.com with SMTP id r18so5698617pls.13 for ; Sun, 19 May 2019 13:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3+YujhkwUcm32OaJhXi3plbLKoShJGj44pRi7jq0BsI=; b=whhRNYqLCqx77nzPXcgF2akJz9cqL77znkgo40u5v7pMuGbyH4MZ7ZpSyyTvW7ffxn Gq8qIHPRfG86I9UdVpQXIEDmYPZXRAuhGUY+yUtlH8bQvvE/0h/XoLumLp12sw61GjtB U8XTDKJ52B7H00PR7p0gnqsuoPjgOulqgODL7d9jdh8LndwCqsiIuOjTNYLpsnmpNaeP 2hMknugMygzAtE8C4dveJMVKuTb812QfOKapbBh45D5+qOqtAZu4qxaI7yq7B3lwbYHk LCVXRE1tg/yPspaRCejZILgy9ORxtU3Djj84JSQDQAwdt3iaSWSwE7DPuk2V0ay2OLb0 hwGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3+YujhkwUcm32OaJhXi3plbLKoShJGj44pRi7jq0BsI=; b=Xc/YG95coRIDWIq5A+VO8kpZOWB9+ETQv9mmrPkF5xkmJ+K3mWrW0Do7wiw3XhxdJy ouSwgCUtBXt8Ar1JA3fzTgkGyRRDK55OJgrNRwBxZ2jqdHxRn2zmKmq1Z/Y6l10HBCSl WEbEXGG4Z4LliQW6G4FkopVItAtwbdx0R9rUsCz3lIuoJRxRZ6b19vRoiKPkizBSaKT5 yjjw4yTUidZbrhuYGXl4hxmJfgFsYpLGR9YIpsxrCQpiwHv3v5ztyNkck6+jbWgR8RmK 0gUmp74cuxnWLBPv9oBITknlACzEutlGXLwmFSBOi4tNnCZxUU1vJ+Fg3gHmSejg20dT mtcg== X-Gm-Message-State: APjAAAXw1sSEFThHilmbi8TrTsAL3z0XA6smh92a/LLpbgSE+9ygeYCf llaWoh/Tf2NZ8xewwVCElSeSPKl6jvE= X-Received: by 2002:a17:902:59c3:: with SMTP id d3mr1083084plj.273.1558298277044; Sun, 19 May 2019 13:37:57 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:33 -0700 Message-Id: <20190519203726.20729-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 21/74] linux-user: Split out link, linkat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that linkat is universally provided. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/strace.c | 29 ----------------------------- linux-user/syscall-file.inc.c | 28 ++++++++++++++++++++++++++++ linux-user/syscall.c | 32 -------------------------------- linux-user/strace.list | 6 ------ 5 files changed, 32 insertions(+), 67 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index de7a99f0c6..41dd887dbc 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -31,6 +31,10 @@ SYSCALL_DEF(fork); #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif +#ifdef TARGET_NR_link +SYSCALL_DEF(link, ARG_STR, ARG_STR); +#endif +SYSCALL_DEF(linkat, ARG_ATDIRFD, ARG_STR, ARG_ATDIRFD, ARG_STR, ARG_ATFLAG); SYSCALL_DEF(mlock, ARG_PTR, ARG_DEC); SYSCALL_DEF(mlockall, ARG_HEX); #ifdef TARGET_NR_mmap diff --git a/linux-user/strace.c b/linux-user/strace.c index 640a80f32b..feb8ec7c09 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1369,35 +1369,6 @@ print_futimesat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_link -static void -print_link(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_string(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_linkat -static void -print_linkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_at_dirfd(arg2, 0); - print_string(arg3, 0); - print_flags(at_file_flags, arg4, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR__llseek static void print__llseek(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 9b966ad627..440ff5ed14 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -40,6 +40,34 @@ SYSCALL_IMPL(creat) } #endif +static abi_long do_linkat(int olddirfd, abi_ulong target_oldpath, + int newdirfd, abi_ulong target_newpath, + int flags) +{ + char *oldpath = lock_user_string(target_oldpath); + char *newpath = lock_user_string(target_newpath); + abi_long ret = -TARGET_EFAULT; + + if (oldpath && newpath) { + ret = get_errno(linkat(olddirfd, oldpath, newdirfd, newpath, flags)); + } + unlock_user(oldpath, target_oldpath, 0); + unlock_user(newpath, target_newpath, 0); + return ret; +} + +#ifdef TARGET_NR_link +SYSCALL_IMPL(link) +{ + return do_linkat(AT_FDCWD, arg1, AT_FDCWD, arg2, 0); +} +#endif + +SYSCALL_IMPL(linkat) +{ + return do_linkat(arg1, arg2, arg3, arg4, arg5); +} + /* * Helpers for do_openat, manipulating /proc/self/foo. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 491e1d7cfb..865129df9e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5383,38 +5383,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_link - case TARGET_NR_link: - { - void * p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg2); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(link(p, p2)); - unlock_user(p2, arg2, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_linkat) - case TARGET_NR_linkat: - { - void * p2 = NULL; - if (!arg2 || !arg4) - return -TARGET_EFAULT; - p = lock_user_string(arg2); - p2 = lock_user_string(arg4); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(linkat(arg1, p, arg3, p2, arg5)); - unlock_user(p, arg2, 0); - unlock_user(p2, arg4, 0); - } - return ret; -#endif #ifdef TARGET_NR_unlink case TARGET_NR_unlink: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 41f8f8d0d0..f3c54cec69 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -461,12 +461,6 @@ #ifdef TARGET_NR_lgetxattr { TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_link -{ TARGET_NR_link, "link" , NULL, print_link, NULL }, -#endif -#ifdef TARGET_NR_linkat -{ TARGET_NR_linkat, "linkat" , NULL, print_linkat, NULL }, -#endif #ifdef TARGET_NR_Linux { TARGET_NR_Linux, "Linux" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164522 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4795558ili; Sun, 19 May 2019 14:04:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiVXUiupW1Sd/k3jZdZhmT5H7nTpCeQwOXcSIAELWucH6mdZLJDZUf+g8FCJiiXq8SOmAc X-Received: by 2002:a50:ce5b:: with SMTP id k27mr19246145edj.48.1558299889231; Sun, 19 May 2019 14:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299889; cv=none; d=google.com; s=arc-20160816; b=pENS1Sum0gnd3gqOLh0cY6gtzK4/qOAuVWgs9qE+gJN5//1aW7aYFlzvJUmqlu4jfb vhkqoQCPKWTW8KEh5bXv7Arg+L49WgoBhHTpKezvPquMIZ/gvjWO3kNdcCTXjn4lBB28 vNpDRycdhFIMySC2p5q5WnqhuR4v5WoL2nPSdyuWiGTRq4ckZf4jwDvLmv6qlYcgZh/L st3mEDzUSs4LWbl/0FzdHjYiWzPeaXN3FEaAnMmTVJ+KeMaA8KTtq5/BEHdfGXwgF9dj cNRIRKng9O23iAONF4ABN6bGaVt7avt0xZ4XBTpplQiV4kbD49y8nqkmJO6XFYbYjoAy RIgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=H4vQIA+B5PMSizbcnaZO+HK/zsI+Heqt+lO8dDvIHmE=; b=ho7eLjIF4x1WZKpccCiKyh0/GCUiUDwrvFKgtcxxxIBExTXRGoQ3Rl1UYpCYKQanfb 1UsCsOHyUz4uaT9JTh8FnizIzqhMsjD9NjMcoyriJi1bA75aw3x0oxuwi7UCP1h+Xe6Z F4TVSeTQbm8dD5lXgGtA4UR07v9DmR18pKXSTiS98aXQ/DrFk5n78/Q8B8ksbi/jCGHB ifgsmTs8gAS9VisbHQmWVXFjf3DNHyDInXm+yfuGcUAhF8BsPjvCZAtrXseIO1mbElwd 7d3ks5/lEPLsoOZbwgGvEyzlFF8lIVZXpYbfU8+mdQBfPXkE/rvTaLb6ASYLXOy1ObYg +yNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nACouiip; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o54si8687828edc.7.2019.05.19.14.04.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nACouiip; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSzA-0000Ni-3X for patch@linaro.org; Sun, 19 May 2019 17:04:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZF-0003JD-6b for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZD-0003uG-RA for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:01 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:36600) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZD-0003t0-IC for qemu-devel@nongnu.org; Sun, 19 May 2019 16:37:59 -0400 Received: by mail-pl1-x642.google.com with SMTP id d21so5723736plr.3 for ; Sun, 19 May 2019 13:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H4vQIA+B5PMSizbcnaZO+HK/zsI+Heqt+lO8dDvIHmE=; b=nACouiip8p+PlsU6WPVxFUhzvBWGxmsSE4WlYsnUrnPAJCG7bxnmI7C3A4X1p6kvHM /hu1V+GNRJqJb2i5vHj5DcwV+PkzRBNdYIdn2MJdHWaNue+fNEv3mXBY5lEVhhh+pFeZ wao1yG2zYRQAC/d+yh92oPHvegNRGVqO5Jrr9KBSCkdRnBOonXB3VHteftuN8i4qyQcK AKlvaNy9cwp5v1wuKzQBTfpwD0ULEDm8zY4k3xzPtlq8bAG7R0fdv+SjIU2jmejygj6i 2eHnRhRrwevU9pnUCK0JpVzUlOvd58UP888m+NoCCs7ELRQGRt9Wbtq6DpRX0g7qcDax Wvtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H4vQIA+B5PMSizbcnaZO+HK/zsI+Heqt+lO8dDvIHmE=; b=p+u0Eieu1BG8P8hOyXL5Fo7MQFDyv4ZAsT71ApyQO9949vZiQaqsgUcCXV7FtGSFLW YraHbOQznizbuyIjLf6hBVFJoYjph7nRXrSdp6C5zMdEBpb86Kz4GBkvs4N29eNSIQH7 8IPiBLpngauTdZJ9/GljJEOvHmw2mFp9gNEj2GGHmp07l+H/zeZ022Tf6fSJZxcXBsAP /YeqBn/M0VLpyS/5wXjpKpC7WYvuZL0Q64PbeF08dY3q+xE/Ve4wg5xm9nbGh+Jh6qx7 C6uRUn4xjX16K6zM+0GbuUfRKWdigdxpfSqCOwTMf+/6MwvjZZJKEKhiehqa19Dx3cjq znMw== X-Gm-Message-State: APjAAAWp5gyiWSs8Yv7FACqwrFk/icdj4K5xZlmZMxmLp3WvciMCIYrW c9VD5DNhKF7wWqIcQ8UqIpcJyJ3fvNo= X-Received: by 2002:a17:902:70c6:: with SMTP id l6mr54071306plt.84.1558298278338; Sun, 19 May 2019 13:37:58 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:34 -0700 Message-Id: <20190519203726.20729-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 22/74] linux-user: Split out unlink, unlinkat, rmdir X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that unlinkat is universally provided. Implement rmdir in terms of unlinkat. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 7 ++++++ linux-user/syscall.h | 1 + linux-user/strace.c | 43 ++++------------------------------- linux-user/syscall-file.inc.c | 32 ++++++++++++++++++++++++++ linux-user/syscall.c | 24 ------------------- linux-user/strace.list | 9 -------- 6 files changed, 44 insertions(+), 72 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 41dd887dbc..78d3f600eb 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -98,6 +98,9 @@ SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); SYSCALL_DEF(readlinkat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_DEC); #endif SYSCALL_DEF(readv, ARG_DEC, ARG_PTR, ARG_DEC); +#ifdef TARGET_NR_rmdir +SYSCALL_DEF(rmdir, ARG_STR); +#endif #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #endif @@ -121,6 +124,10 @@ SYSCALL_DEF(shmdt, ARG_PTR); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmget) SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #endif +#ifdef TARGET_NR_unlink +SYSCALL_DEF(unlink, ARG_STR); +#endif +SYSCALL_DEF(unlinkat, ARG_ATDIRFD, ARG_STR, ARG_UNLINKATFLAG); #ifdef TARGET_NR_vfork /* Emulate vfork() with fork(). */ SYSCALL_DEF_FULL(vfork, .impl = impl_fork); diff --git a/linux-user/syscall.h b/linux-user/syscall.h index f75cd3ddd0..bdc4d653c4 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -63,6 +63,7 @@ typedef enum { ARG_MMAPPROT, ARG_MODEFLAG, ARG_OPENFLAG, + ARG_UNLINKATFLAG, /* These are interpreted as pointers. */ ARG_PTR, diff --git a/linux-user/strace.c b/linux-user/strace.c index feb8ec7c09..9ac0b859da 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -684,7 +684,7 @@ static struct flags const at_file_flags[] = { FLAG_END, }; -UNUSED static struct flags unlinkat_flags[] = { +static struct flags const unlinkat_flags[] = { #ifdef AT_REMOVEDIR FLAG_GENERIC(AT_REMOVEDIR), #endif @@ -1810,18 +1810,6 @@ print_mkdirat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_rmdir -static void -print_rmdir(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_rt_sigaction static void print_rt_sigaction(const struct syscallname *name, @@ -2187,32 +2175,6 @@ print_umount2(const struct syscallname *name, } #endif -#ifdef TARGET_NR_unlink -static void -print_unlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_unlinkat -static void -print_unlinkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_flags(unlinkat_flags, arg2, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_utime static void print_utime(const struct syscallname *name, @@ -2475,6 +2437,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_OPENFLAG: len = add_open_flags(b, rest, arg); break; + case ARG_UNLINKATFLAG: + len = add_flags(b, rest, unlinkat_flags, arg, true); + break; case ARG_PTR: len = add_pointer(b, rest, arg); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 440ff5ed14..5acd8ecc10 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -662,6 +662,38 @@ SYSCALL_IMPL(readlinkat) } #endif +static abi_long do_unlinkat(int dirfd, abi_ulong target_path, int flags) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(unlinkat(dirfd, p, flags)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_unlink +SYSCALL_IMPL(unlink) +{ + return do_unlinkat(AT_FDCWD, arg1, 0); +} +#endif + +#ifdef TARGET_NR_rmdir +SYSCALL_IMPL(rmdir) +{ + return do_unlinkat(AT_FDCWD, arg1, AT_REMOVEDIR); +} +#endif + +SYSCALL_IMPL(unlinkat) +{ + return do_unlinkat(arg1, arg2, arg3); +} + SYSCALL_IMPL(write) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 865129df9e..53e108b614 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5383,22 +5383,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_unlink - case TARGET_NR_unlink: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(unlink(p)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_unlinkat) - case TARGET_NR_unlinkat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(unlinkat(arg1, p, arg3)); - unlock_user(p, arg2, 0); - return ret; -#endif case TARGET_NR_execve: { char **argp, **envp; @@ -5790,14 +5774,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(mkdirat(arg1, p, arg3)); unlock_user(p, arg2, 0); return ret; -#endif -#ifdef TARGET_NR_rmdir - case TARGET_NR_rmdir: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(rmdir(p)); - unlock_user(p, arg1, 0); - return ret; #endif case TARGET_NR_dup: ret = get_errno(dup(arg1)); diff --git a/linux-user/strace.list b/linux-user/strace.list index f3c54cec69..f08ddaddac 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -527,9 +527,6 @@ #ifdef TARGET_NR_mkdirat { TARGET_NR_mkdirat, "mkdirat" , NULL, print_mkdirat, NULL }, #endif -#ifdef TARGET_NR_rmdir -{ TARGET_NR_rmdir, "rmdir" , NULL, print_rmdir, NULL }, -#endif #ifdef TARGET_NR_mknod { TARGET_NR_mknod, "mknod" , NULL, print_mknod, NULL }, #endif @@ -1425,12 +1422,6 @@ #ifdef TARGET_NR_uname { TARGET_NR_uname, "uname" , "%s(%p)", NULL, NULL }, #endif -#ifdef TARGET_NR_unlink -{ TARGET_NR_unlink, "unlink" , NULL, print_unlink, NULL }, -#endif -#ifdef TARGET_NR_unlinkat -{ TARGET_NR_unlinkat, "unlinkat" , NULL, print_unlinkat, NULL }, -#endif #ifdef TARGET_NR_unshare { TARGET_NR_unshare, "unshare" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164512 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4789498ili; Sun, 19 May 2019 13:56:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqweT+tNhKumvYoyYuMrfXY86D8D7JPNSIP5w7ZHqUwqQ837dDmBUrfTQfyLV5ctJ3o/WW19 X-Received: by 2002:a17:906:b20f:: with SMTP id p15mr44300977ejz.63.1558299407160; Sun, 19 May 2019 13:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299407; cv=none; d=google.com; s=arc-20160816; b=dxWOdXWxQXZExPPZp/tthAqsq+Eh8XidFoxiLpptRFgA3AdkZ38w0CtMZm/Tm55E0D 8jAfq8flMt8Gb9JaotjY1vz3MEUB68Ij5rdXCVmQQ4Yhl+eO4vJiMooXsiiGIgS8NKD8 12mQ1NAdIAdvt4UhaTziwv6+NgDNxhLznq5D6Nx13TMtwvG5TNZSD0NpAZf8wgwu8adO ELhIPuNioilhil6GjiFM7RSXs0CID0KgKL0jfrk4K+QbqEekn0AKv0fT6A086PId/xCC lO6RB5tYwdfOPoiAMb1F3m3OjOtTz0YJPtz3bCJf2jQsRReF6tLKWamJ+H/BD6u6j6Xg NeXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=FtdYKl9zJgpOHr5aJ0qnR6xTcabKx8Fz/s3C+R4+JHc=; b=OBSjtHGpFctMtneCprLLciJN9uATyJQSdhZHJjdo+Y0/Jyi25kiY5zJxku7Mb+mYd2 9UCPJYRbBSxalRmZhSPLIkAFeJ0dXTBZVKCu7JY1LgYEXqwP5mVo7IiEsNPk7chy6zPt 8GFmC0TiBICfZ3vRb/dDID122oPHLJ8Ia+xa/eH5gfa4KIsg1hjZOU72nv8pthcpCASs MkAylShENtoJDBVj4DJGUtB/XegNJTXObDjpRQjgsSlxJS3i1N5lyMZuDXPqNXhIryDh vA1W3nraLQRDwYUJrBD13/299MHBJZUGjawIGRtXAtMuDJaOSJh0ofHA08B19sMstpx0 /skA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lc7yjcyl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i26si7387582ejc.361.2019.05.19.13.56.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:56:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lc7yjcyl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSrN-0001mm-V8 for patch@linaro.org; Sun, 19 May 2019 16:56:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZG-0003LS-If for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZF-0003vs-0e for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:02 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:45099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZE-0003uw-OF for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:00 -0400 Received: by mail-pl1-x643.google.com with SMTP id a5so5687509pls.12 for ; Sun, 19 May 2019 13:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FtdYKl9zJgpOHr5aJ0qnR6xTcabKx8Fz/s3C+R4+JHc=; b=lc7yjcylh2ktAOsBbrksTXSHofdMS8y1fJpErjwgKKALi4DoeDrZFdwiJLtnRwogqq uzKXHDiNWlSDk9jmcN4Jbnlmq2TJGB61+m5EkYbqFsrUxBFSqsOr51y+kiJ7hqMmLRmT SaiiZuAySvjyr+deD3lpveSxGvx/0e6BXfarRBo6ABOIiIcCDUCBqHE30kwcB3PUgJo7 zCmrpG1pFr8y8USr19n0hFqanfYdEJgN0LKvTx50QeaZSODE4cN8PWWgKNku2WD3R+zd zO/7jYK+qJm8k6HfPTxSAuSYqIYmHaFCKgwstAhMtS1EHkXUppOuuWfcqM9ES2F6lCxi cH9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FtdYKl9zJgpOHr5aJ0qnR6xTcabKx8Fz/s3C+R4+JHc=; b=cqThUV6YuUowWv3ccn2kPvqkPbecRhT/KcGdnopNrsVUUMT/N+oJyp+j4/a1AE26Zh 0vkmZxZg/EuOdz6/jlL8E21RdZUMXbgtaCwq9Y1QplNF+h5rrjr+ohxIrswhOLcU4Gle UKFihEVOj5uyW2DhzEpFw3WmoWqInvh11rlCQ/z7A3KCzLGe7JoxadCkxHpK01aiDWd2 nQN0Q/lRcoPz18aEYyI3z2sOy65muho79YTQz05uqFxtwdzqKwqY37oXgzbgAW2Oq1Jk tBWGvPTGsw6H/YIUzyQs8tnka5EmKahFNIjblnBAJwHOb8jH9hJ9wNy3hCq7AkhUdnjU pOvA== X-Gm-Message-State: APjAAAVFfYxnQufVgbyd/F1AGyBVrDFGYym2lbduK8MqlJVu7PFQdyZ+ vx8N3lpZV8izEivIz0K77r98DvU2DWE= X-Received: by 2002:a17:902:b941:: with SMTP id h1mr13225338pls.289.1558298279505; Sun, 19 May 2019 13:37:59 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:35 -0700 Message-Id: <20190519203726.20729-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v7 23/74] linux-user: Split out execve X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/strace.c | 32 ---------- linux-user/syscall-proc.inc.c | 110 ++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 97 ------------------------------ linux-user/strace.list | 3 - 5 files changed, 111 insertions(+), 132 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 78d3f600eb..58fef48666 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -25,6 +25,7 @@ SYSCALL_DEF(close, ARG_DEC); SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG); #endif SYSCALL_DEF(exit, ARG_DEC); +SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 9ac0b859da..9d6c765715 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -568,38 +568,6 @@ print_newselect(const struct syscallname *name, } #endif -static void -print_execve(const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) -{ - abi_ulong arg_ptr_addr; - char *s; - - if (!(s = lock_user_string(arg1))) - return; - gemu_log("%s(\"%s\",{", name->name, s); - unlock_user(s, arg1, 0); - - for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { - abi_ulong *arg_ptr, arg_addr; - - arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); - if (!arg_ptr) - return; - arg_addr = tswapal(*arg_ptr); - unlock_user(arg_ptr, arg_ptr_addr, 0); - if (!arg_addr) - break; - if ((s = lock_user_string(arg_addr))) { - gemu_log("\"%s\",", s); - unlock_user(s, arg_addr, 0); - } - } - - gemu_log("NULL})"); -} - /* * Variants for the return value output function */ diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index b7304b7a42..66ad768551 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -269,6 +269,116 @@ SYSCALL_IMPL(clone) return do_clone(cpu_env, arg1, arg2, arg3, arg4, arg5); } +SYSCALL_IMPL(execve) +{ + char **argp, **envp; + int argc, envc; + abi_ulong gp; + abi_ulong guest_path = arg1; + abi_ulong guest_argp = arg2; + abi_ulong guest_envp = arg3; + abi_ulong addr; + char **q, *p; + int total_size = 0; + abi_long ret = -TARGET_EFAULT; + + argc = 0; + for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + goto execve_nofree; + } + if (!addr) { + break; + } + argc++; + } + envc = 0; + for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { + if (get_user_ual(addr, gp)) { + goto execve_nofree; + } + if (!addr) { + break; + } + envc++; + } + + argp = g_new0(char *, argc + 1); + envp = g_new0(char *, envc + 1); + + for (gp = guest_argp, q = argp; gp; gp += sizeof(abi_ulong), q++) { + char *this_q; + + if (get_user_ual(addr, gp)) { + goto execve_free; + } + if (!addr) { + break; + } + this_q = lock_user_string(addr); + if (!this_q) { + goto execve_free; + } + *q = this_q; + total_size += strlen(this_q) + 1; + } + + for (gp = guest_envp, q = envp; gp; gp += sizeof(abi_ulong), q++) { + char *this_q; + + if (get_user_ual(addr, gp)) { + goto execve_free; + } + if (!addr) { + break; + } + this_q = lock_user_string(addr); + if (!this_q) { + goto execve_free; + } + *q = this_q; + total_size += strlen(this_q) + 1; + } + + p = lock_user_string(guest_path); + if (!p) { + goto execve_free; + } + + /* + * Although execve() is not an interruptible syscall it is + * a special case where we must use the safe_syscall wrapper: + * if we allow a signal to happen before we make the host + * syscall then we will 'lose' it, because at the point of + * execve the process leaves QEMU's control. So we use the + * safe syscall wrapper to ensure that we either take the + * signal as a guest signal, or else it does not happen + * before the execve completes and makes it the other + * program's problem. + */ + ret = get_errno(safe_execve(p, argp, envp)); + unlock_user(p, guest_path, 0); + + execve_free: + for (gp = guest_argp, q = argp; *q; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + for (gp = guest_envp, q = envp; *q; gp += sizeof(abi_ulong), q++) { + if (get_user_ual(addr, gp) || !addr) { + break; + } + unlock_user(*q, addr, 0); + } + g_free(argp); + g_free(envp); + + execve_nofree: + return ret; +} + SYSCALL_IMPL(exit) { CPUState *cpu = ENV_GET_CPU(cpu_env); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 53e108b614..a00df1162f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5383,103 +5383,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_execve: - { - char **argp, **envp; - int argc, envc; - abi_ulong gp; - abi_ulong guest_argp; - abi_ulong guest_envp; - abi_ulong addr; - char **q; - int total_size = 0; - - argc = 0; - guest_argp = arg2; - for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { - if (get_user_ual(addr, gp)) - return -TARGET_EFAULT; - if (!addr) - break; - argc++; - } - envc = 0; - guest_envp = arg3; - for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { - if (get_user_ual(addr, gp)) - return -TARGET_EFAULT; - if (!addr) - break; - envc++; - } - - argp = g_new0(char *, argc + 1); - envp = g_new0(char *, envc + 1); - - for (gp = guest_argp, q = argp; gp; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp)) - goto execve_efault; - if (!addr) - break; - if (!(*q = lock_user_string(addr))) - goto execve_efault; - total_size += strlen(*q) + 1; - } - *q = NULL; - - for (gp = guest_envp, q = envp; gp; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp)) - goto execve_efault; - if (!addr) - break; - if (!(*q = lock_user_string(addr))) - goto execve_efault; - total_size += strlen(*q) + 1; - } - *q = NULL; - - if (!(p = lock_user_string(arg1))) - goto execve_efault; - /* Although execve() is not an interruptible syscall it is - * a special case where we must use the safe_syscall wrapper: - * if we allow a signal to happen before we make the host - * syscall then we will 'lose' it, because at the point of - * execve the process leaves QEMU's control. So we use the - * safe syscall wrapper to ensure that we either take the - * signal as a guest signal, or else it does not happen - * before the execve completes and makes it the other - * program's problem. - */ - ret = get_errno(safe_execve(p, argp, envp)); - unlock_user(p, arg1, 0); - - goto execve_end; - - execve_efault: - ret = -TARGET_EFAULT; - - execve_end: - for (gp = guest_argp, q = argp; *q; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp) - || !addr) - break; - unlock_user(*q, addr, 0); - } - for (gp = guest_envp, q = envp; *q; - gp += sizeof(abi_ulong), q++) { - if (get_user_ual(addr, gp) - || !addr) - break; - unlock_user(*q, addr, 0); - } - - g_free(argp); - g_free(envp); - } - return ret; case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; diff --git a/linux-user/strace.list b/linux-user/strace.list index f08ddaddac..39e5c5b1aa 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -139,9 +139,6 @@ #ifdef TARGET_NR_execv { TARGET_NR_execv, "execv" , NULL, print_execv, NULL }, #endif -#ifdef TARGET_NR_execve -{ TARGET_NR_execve, "execve" , NULL, print_execve, NULL }, -#endif #ifdef TARGET_NR_execveat { TARGET_NR_execveat, "execveat" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164511 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4789355ili; Sun, 19 May 2019 13:56:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVLs930JIkj1d4wjVAarm+9ta/bjspsLgvBwh9NRckbySjsUh47AscZGpPiqPF5SxnfNGW X-Received: by 2002:a17:906:c4f:: with SMTP id t15mr12703038ejf.190.1558299390653; Sun, 19 May 2019 13:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299390; cv=none; d=google.com; s=arc-20160816; b=aV/5Jff8bDvCpTI7NJssqUkNfsKiBdC9ra5bdBpV9L8z76c8HPBi8VE6snPjI/vUED nk/20WDWUmvalVnYd5JxxdsFQfo3lInRWE0wRIzcsXahcsJ8TFrLN1EWYWgtHrprmyJY vBI5JVWsQrLHY7dy1H4OkJthuoXcJ0wBrTu1baUz1Sqz4ND67kLpQG1jhEwgJED0iwJL 9zEogRKYv+TyL4K5orCJWGLFNyWK3axyS+FLeUjFiw3B/dZi/qGaDaWB3F5TNX3iScFr SMeojwgv61jR0GytPwoAa4ItXpVRRU+5J1ccaytZx9VfQ9ppMKSTV41pLK9FhuaI3CN3 E1Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=CUstonr/slKQsOp95jk6g1WJFMbRRVPH2v9t0llMUoM=; b=H/Ah7KmrHp4VhpEbAOEA9IQFi23qc5CsYvzr/s5T4SYsZRKx+WUmLqJMYjIbduEBc7 aPwM5qKqBnze5za0Jzh8r/WZq1AwHt7vVOV++Jv4hdRPSZgDv9lQx/urQCECZ/hRupOZ X2tgEPmWlem4QDBbeZmPmuwrntele/02XtUasT93jMIKWboYnc0fc/7ECf8YsLqPmK5X NhlT4RZZ+L4e19L/HEvNLhgzrxBqI5zlzGkgd103A1CNCf6tuL6jUZnQCEQpGUyUkESl VvtNcCRYEqkcEgX95oFrxyav3EW1PoYJmtHEyRlbGAIYTH2HFL5/qKdPnEV4TZP461rw kohA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gztWdzs8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n5si3100619ejc.359.2019.05.19.13.56.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gztWdzs8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSr7-0001sT-Hn for patch@linaro.org; Sun, 19 May 2019 16:56:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZH-0003MX-Mo for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZG-0003xg-Jq for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:03 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:45523) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZG-0003wx-D8 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:02 -0400 Received: by mail-pg1-x542.google.com with SMTP id i21so5720909pgi.12 for ; Sun, 19 May 2019 13:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CUstonr/slKQsOp95jk6g1WJFMbRRVPH2v9t0llMUoM=; b=gztWdzs8chvklwyvFRigzSUIlJ58+409oA0pFmMX6kvHD9UoGLi2aYp4xSZ/QLsCT/ i5zUc8HPJWhG/PYEU6ecEV5qVWGkWb9pbEC5/cEDUD7ZOm4u4YuFAX229/1RZSJzXlN4 0GTMknJR+PtwwAnChPiQHqeT0Xs6g5tadTlFrvpPk/gvRDjv0c3FQnaKNrIXllJbI4ez Tr/8g7PLp8/nH1AKxCC95sYOPwiouWzUjTnxleY2DHDoa2zsgC9iFzkMmI2EesYmKWU8 5udxp5Mrm2YpXNK3LNlTIPtzv5cOlfGq8nohVMkQ8oM0rrp5fsjVRaO0Qt/Dvl92AO2r 3T1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CUstonr/slKQsOp95jk6g1WJFMbRRVPH2v9t0llMUoM=; b=RiFXru9AUxYSzsxWT8S9aZDK8eru46tGarQW8GY0uMhLNBB+m9iY12Gz2oqrc9aCOq wU2DfyE7ULReTQ30Vc6YSfwYeqckNSpLcYmKu5hjfvDfpon6CErd/BfC7FP/jlw7D+0C YmKoGSbGrzOefrbXI2w8WowAuTwZyso0kTlZDPG+mBgUaMYMV2AhytqkCrsbO/S6nodR CM/maWuUj4SvXahaP+AJ3hDbzUDH0IFwQo8OeeQvYfQa0zkAcgwulrcEpTVd5PO48eV/ Uh06xRNuwuI36YRotM3lilCVJ6VtbXVJnNYLeUCQ1sQuzYMN5nuAzKaoQiyR4PAsVVDR Yssw== X-Gm-Message-State: APjAAAUTdpwAVxoS5+QEMaUm3vdcWfZnT/9WK835ehJfAH50Jkd5Sbal L2D29lzdXQ9KKFlG8ENrvjytQfBsw4A= X-Received: by 2002:a63:4c15:: with SMTP id z21mr27665675pga.395.1558298281198; Sun, 19 May 2019 13:38:01 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.37.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:37:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:36 -0700 Message-Id: <20190519203726.20729-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v7 24/74] linux-user: Implement execveat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A trivial extension to our current execve implementation to support the new(ish) syscall. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-proc.inc.c | 19 ++++++++++++++----- linux-user/syscall.c | 3 ++- linux-user/strace.list | 3 --- 4 files changed, 17 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 58fef48666..392bd1579c 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -26,6 +26,7 @@ SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG); #endif SYSCALL_DEF(exit, ARG_DEC); SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); +SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 66ad768551..fd114d1f03 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -269,14 +269,13 @@ SYSCALL_IMPL(clone) return do_clone(cpu_env, arg1, arg2, arg3, arg4, arg5); } -SYSCALL_IMPL(execve) +static abi_long do_execveat(int dirfd, abi_ulong guest_path, + abi_ulong guest_argp, abi_ulong guest_envp, + int flags) { char **argp, **envp; int argc, envc; abi_ulong gp; - abi_ulong guest_path = arg1; - abi_ulong guest_argp = arg2; - abi_ulong guest_envp = arg3; abi_ulong addr; char **q, *p; int total_size = 0; @@ -356,7 +355,7 @@ SYSCALL_IMPL(execve) * before the execve completes and makes it the other * program's problem. */ - ret = get_errno(safe_execve(p, argp, envp)); + ret = get_errno(safe_execveat(dirfd, p, argp, envp, flags)); unlock_user(p, guest_path, 0); execve_free: @@ -379,6 +378,16 @@ SYSCALL_IMPL(execve) return ret; } +SYSCALL_IMPL(execve) +{ + return do_execveat(AT_FDCWD, arg1, arg2, arg3, 0); +} + +SYSCALL_IMPL(execveat) +{ + return do_execveat(arg1, arg2, arg3, arg4, arg5); +} + SYSCALL_IMPL(exit) { CPUState *cpu = ENV_GET_CPU(cpu_env); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a00df1162f..affcd81273 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -672,7 +672,8 @@ safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \ struct rusage *, rusage) safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \ int, options, struct rusage *, rusage) -safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp) +safe_syscall5(int, execveat, int, dirfd, const char *, filename, + char **, argv, char **, envp, int, flags) safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \ fd_set *, exceptfds, struct timespec *, timeout, void *, sig) safe_syscall5(int, ppoll, struct pollfd *, ufds, unsigned int, nfds, diff --git a/linux-user/strace.list b/linux-user/strace.list index 39e5c5b1aa..c6bb475728 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -139,9 +139,6 @@ #ifdef TARGET_NR_execv { TARGET_NR_execv, "execv" , NULL, print_execv, NULL }, #endif -#ifdef TARGET_NR_execveat -{ TARGET_NR_execveat, "execveat" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_exec_with_loader { TARGET_NR_exec_with_loader, "exec_with_loader" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164517 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4791237ili; Sun, 19 May 2019 13:59:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMzH5xo3zL5bRlL6lxsyuGXC0xBC3Qv15dz47W4ZBVRlvF6A4kXeNICsJqtzEGVcMNA+aZ X-Received: by 2002:a50:9441:: with SMTP id q1mr71195808eda.101.1558299586259; Sun, 19 May 2019 13:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299586; cv=none; d=google.com; s=arc-20160816; b=G58nk4+jBdkKUWVYXh4SVJJSywr1DrepoNDMAfn3WdzqPkL6Um9nXFCno0fTmJ+mZF WdaG/v7w9P4mrrZRfOfuI0issZfywY3WokJqg3EHm0aAtSp9AlQx+RLRdUhOpBR8DsBW aMDVP6g1HS3wL8Ry7bIRERyMuPZaQ9+AkyZz9BBzvGnMfBUW6DAkB61vLAxddzJHlPsG Qa287tUdA+fcfkQb+Y81lrLhAb20WxWf5Tt33+RDoPoX3kNUtG0AKGiY3b8n5ZRy83Xf vszrWiu2swlpos3AQyqM4HI+cNB/4mqVjoC4welYI0SzK+pAdyVEa8gfpF0KHP3AQNxR SgbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=F+fKej9fPmaDrSPzKASFQtBx9UbES7Ex48WVScqi++Y=; b=Js0AbkGXEDdd8oO/f9oW0C8WStKm5hhnNvnBLScUG4S79JNvqRptFHTrXklTEHHcYl OWxFcz8OBdkuayrELkEn8dlYB0j/0IyCkJdoRNSm22csnd7R1MsW0BNW3WeVtVNvnpzM RpVlSyVp/QPwwkGcswUaQr9bHesIZNrYawFI782fH1mq/ZXXBWGBt2QjcZhhKFSA7xE7 vMrruVFCHSqEG0rD5oUfgkMubeexdWx2uNDVUPjyIJ98r21SH5e0FqLASkKv31s2u9C8 qGDKec7IEQCZWljaAMdtdhOGx41pM/xWcnwqq42+0Pt6FGGy16o9ZRGfZUUUUnvepDcN ruSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AyIGZgac; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k17si3408694ejs.208.2019.05.19.13.59.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:59:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AyIGZgac; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSuH-0004FF-6w for patch@linaro.org; Sun, 19 May 2019 16:59:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZI-0003No-Ro for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZH-0003z2-Os for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:04 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:42916) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZH-0003y7-IH for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:03 -0400 Received: by mail-pf1-x443.google.com with SMTP id 13so6157230pfw.9 for ; Sun, 19 May 2019 13:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F+fKej9fPmaDrSPzKASFQtBx9UbES7Ex48WVScqi++Y=; b=AyIGZgacVo1RSvmJgHsjrxMNdHL0qO6O7OQoHEIjI6sQOu1zg1i8IuMjvWUDjcCCGO yW/1kZUtgIhqnnlF5WbemkE/r0epfOs0FbhBW8lbtEA6aK42VKZOHGlhBVUnu8CLCUoJ Di/UinbDRth9n8uSqEMu4N+9OxNqet3+w9pns9w5KdAXGJQOGwd0xtvU/6CFhkvhSrWT Bpi7hvMEI2Zb3QdWZko78kSNgewVZENWmqhwNRTe+c3wUj1I3B7tusF4XA6opr1xTpbO shNs8SmS7BN5Oihg0fqJsLQ4PNtI1LSJm4yTHg0qOhji1sDU4gyqvpQhIA6q0MUh6CC6 T4yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F+fKej9fPmaDrSPzKASFQtBx9UbES7Ex48WVScqi++Y=; b=Ry2QXvOqb6LQl2ZWr6omxRW9LiE/5rrVTRNJfRdFtdAcDDdiN//1CBrozlq5IikZpL zlhnLsJalazoBbX1geDvTxBgFaMrrNstohyxFnabe0MA9La23Cg37ehEur+MdwS7WnmP YPjDL/KUSCOOUHwP7qD44iZBe6bq60wqz7KmUR3qbOIfwBVmKeLb2KQ/dfqM+yXayb2d 8Ll5OaojnuWXuTmCu6y6aJA6iNGSps0urjh4VHh6TdfQM3lvq59wy9kJpRAIF6LTqFJF qUUZjLmTnpdzMWRDNHSQ6tlANO6DfEAHm0NobkNrcE+uuSMFvf24icAlKRMVzIGeYn5w 888w== X-Gm-Message-State: APjAAAVQOY94pO0utIt/w07+A8ZWa/7l6CUDWUzbJiPCUW/PB0xMek/p Azo9Z3HxgBUMzdcwx+3GoEAzXTlHLtI= X-Received: by 2002:a63:d354:: with SMTP id u20mr22999650pgi.129.1558298282395; Sun, 19 May 2019 13:38:02 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:37 -0700 Message-Id: <20190519203726.20729-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v7 25/74] linux-user: Split out chdir X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that chdir is universally provided. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/strace.c | 12 ------------ linux-user/syscall-file.inc.c | 14 ++++++++++++++ linux-user/syscall.c | 6 ------ linux-user/strace.list | 3 --- 5 files changed, 15 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 392bd1579c..3fad9d51f0 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -19,6 +19,7 @@ SYSCALL_DEF_FULL(brk, .impl = impl_brk, .print_ret = print_syscall_ptr_ret, .arg_type = { ARG_PTR }); +SYSCALL_DEF(chdir, ARG_STR); SYSCALL_DEF_ARGS(clone, ARG_CLONEFLAG, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); SYSCALL_DEF(close, ARG_DEC); #ifdef TARGET_NR_creat diff --git a/linux-user/strace.c b/linux-user/strace.c index 9d6c765715..b234274034 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1113,18 +1113,6 @@ print_access(const struct syscallname *name, } #endif -#ifdef TARGET_NR_chdir -static void -print_chdir(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_chroot static void print_chroot(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 5acd8ecc10..76637fe71b 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -16,6 +16,20 @@ * along with this program; if not, see . */ +SYSCALL_IMPL(chdir) +{ + abi_ulong target_path = arg1; + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chdir(p)); + unlock_user(p, target_path, 0); + return ret; +} + SYSCALL_IMPL(close) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index affcd81273..0bf5901014 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5384,12 +5384,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_chdir: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chdir(p)); - unlock_user(p, arg1, 0); - return ret; #ifdef TARGET_NR_time case TARGET_NR_time: { diff --git a/linux-user/strace.list b/linux-user/strace.list index c6bb475728..3f79159b63 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -61,9 +61,6 @@ #ifdef TARGET_NR_capset { TARGET_NR_capset, "capset" , "%s(%p,%p)", NULL, NULL }, #endif -#ifdef TARGET_NR_chdir -{ TARGET_NR_chdir, "chdir" , NULL, print_chdir, NULL }, -#endif #ifdef TARGET_NR_chmod { TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL }, #endif From patchwork Sun May 19 20:36:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164527 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4797954ili; Sun, 19 May 2019 14:07:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEobvFMacVlzQ6DHBdpYDhTqg36rOAFHB5QGYPozQEBDHIjC3CGTRLbrLP3X8QmeLGKjOm X-Received: by 2002:a50:90dd:: with SMTP id d29mr70974814eda.127.1558300058734; Sun, 19 May 2019 14:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300058; cv=none; d=google.com; s=arc-20160816; b=hOtX4q61jIIJsC1fqu/xEGUKX/9bmojC6rR17LxFQFeSdmUJJamR6tGUNCHCfEL9vO uaR5iIKXFT6sb7dMufr7QM3H+xJ+jhl4RHbW75Mb7C2zPCkNgGXJjUGWjXp5gv6wCwpD bZ1Sn6hhK6ZmQRY+5QpFfxVw7gBoi/v1yKGE5QfTVA4O/AW9mnZ2m48QiIPDZaAq0RSv gbZw3NpdtgO4NE1vMneFudLh/ghAVo3GgJDTdnWWTaWd2hNGCh3HgM9qmj1zhYH6yiiN 67K395l9ij7OD1pIHGQ2ZunXdzDmNg3XQmxQ/jCRwDX5msnf7S/PCEEvfjt+h4NoKMSe 2LJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=D7GWj/lXqLo0o5VRDqbo6Uitm8MC1Kjd/6DUhBjIuPo=; b=Q9+ySWYzc5kD5kPQTXE8SR1L96VLtr0o6/HpBgf3OXMGllt7hAURGMe9IZzLQMJqnv DShcI+N1WxwXJCDVKr4//l6jiNgP+ulBy8NF8uKmusAJ1iyOr3DYi0x0zzKxuhBkAukl 7C6mfLxVY6q0l2z9DbpFy9NOPvaGeGjh2t2TH1vrqDUDe5hdVoB/3FT3l/X8HRJbAeEH kO+jbkQHt4EyremoDXQkFcfWpLxRkuqAQyeYMCQiXApB06oDgul2ToUMTgSLQogc2A6j JqOtxBUSu83f0xLZYyQDygDVmXBHRgu1GQ/DJa+cV5BNT5BmG2KGgu+dpufbxxVq5dU0 ygow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TZDbAixz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t4si2252671eda.280.2019.05.19.14.07.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:07:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TZDbAixz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST1t-0003BH-JY for patch@linaro.org; Sun, 19 May 2019 17:07:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZK-0003Pi-Ip for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZJ-00041B-Dh for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:06 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:34264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZJ-00040H-76 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:05 -0400 Received: by mail-pf1-x444.google.com with SMTP id n19so6182715pfa.1 for ; Sun, 19 May 2019 13:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D7GWj/lXqLo0o5VRDqbo6Uitm8MC1Kjd/6DUhBjIuPo=; b=TZDbAixztVBkqw7lKtMXBgrdRBWHWKYzgjNlobC63Oyqzic4+0AFnhNHmPqTg0KqVp tAhqpbYNlYIuYy+dkurt+px0Z9k5E9Dye+MomeyFA3GZLE8W1Rs4gy+a02aldCXc7oRe hwTsgckJAro6rmOLrFYRSm6+pdwbNafgu0hmn8VuqXFFJKXLqffUNfT6tJ/YhGFWrKrR faLcJM4auzgxvMTSUken3DqYxhMLgwlcU21+PRB8VAyImXQGG5G8SxK9cP3jClrLogD+ ESJopDhEHrIykxXwmLjjM5j9gK35EeESvDhLcv+BuK6bEuiRJGlE8Q0XSM4NAh+5cg7Y iTDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D7GWj/lXqLo0o5VRDqbo6Uitm8MC1Kjd/6DUhBjIuPo=; b=MY189kc+NencyN0i6fCyOgHXA34PSKkVO4nv0dWRllwcG80ynSCyWf50RLuEvDk3cG l38IE/5cRGgj7myanzPIFlw41BWmiIe3HaPbiUZzDt5WkqYklFkzFPKkl+0raLSQHUJw ZhvJyR/9GiSMzWRuQoJkML6+lsE2kqN5XXKAFG+O/TtS1iW5SC+TdOxR92ljBXT2G0ym Zoe7cqMqp4L5X/6FLIBx1976Ndr1o1qa8NWDIe9EpOy1/TkrQMc+9nN/xoAJvc917ez2 0VyV+2DD2kCsyT5GcJH5SHU50L0A0ChSMFQXyaaoG8WdLaB4qiHgIK45h7eeiLiCaH1I yxOg== X-Gm-Message-State: APjAAAUhZDQB84bymJOie0ciC+j+xXXyDCaxDo8VJiECCD36JfkK5qEh sz0MnmwHCUcPQ1a6duUPKJn4jveYPmY= X-Received: by 2002:aa7:951c:: with SMTP id b28mr57475214pfp.99.1558298283888; Sun, 19 May 2019 13:38:03 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:38 -0700 Message-Id: <20190519203726.20729-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v7 26/74] linux-user: Split out time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 3 +++ linux-user/syscall-time.inc.c | 32 ++++++++++++++++++++++++++++++++ linux-user/syscall.c | 13 +------------ linux-user/strace.list | 3 --- 4 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 linux-user/syscall-time.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 3fad9d51f0..9950b73e76 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -127,6 +127,9 @@ SYSCALL_DEF(shmdt, ARG_PTR); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmget) SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #endif +#ifdef TARGET_NR_time +SYSCALL_DEF(time, ARG_PTR); +#endif #ifdef TARGET_NR_unlink SYSCALL_DEF(unlink, ARG_STR); #endif diff --git a/linux-user/syscall-time.inc.c b/linux-user/syscall-time.inc.c new file mode 100644 index 0000000000..14fec88e47 --- /dev/null +++ b/linux-user/syscall-time.inc.c @@ -0,0 +1,32 @@ +/* + * Linux time related syscalls + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifdef TARGET_NR_time +SYSCALL_IMPL(time) +{ + time_t host_time; + abi_long ret = get_errno(time(&host_time)); + + if (!is_error(ret) + && arg1 + && put_user_sal(host_time, arg1)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0bf5901014..ea89734706 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5384,18 +5384,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_time - case TARGET_NR_time: - { - time_t host_time; - ret = get_errno(time(&host_time)); - if (!is_error(ret) - && arg1 - && put_user_sal(host_time, arg1)) - return -TARGET_EFAULT; - } - return ret; -#endif #ifdef TARGET_NR_mknod case TARGET_NR_mknod: if (!(p = lock_user_string(arg1))) @@ -9392,6 +9380,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #include "syscall-ipc.inc.c" #include "syscall-mem.inc.c" #include "syscall-proc.inc.c" +#include "syscall-time.inc.c" #undef SYSCALL_IMPL #undef SYSCALL_ARGS diff --git a/linux-user/strace.list b/linux-user/strace.list index 3f79159b63..95706a696b 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1350,9 +1350,6 @@ #ifdef TARGET_NR_tgkill { TARGET_NR_tgkill, "tgkill" , NULL, print_tgkill, NULL }, #endif -#ifdef TARGET_NR_time -{ TARGET_NR_time, "time" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_timer_create { TARGET_NR_timer_create, "timer_create" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164525 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4796666ili; Sun, 19 May 2019 14:06:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsHn6OvtyLlFUg6kT2TmGAqSApkAtSyv5/ifPILuX+d66Soofud11uToZQIjoF+0i/EBE7 X-Received: by 2002:a50:c315:: with SMTP id a21mr70634940edb.158.1558299967291; Sun, 19 May 2019 14:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299967; cv=none; d=google.com; s=arc-20160816; b=ER6nSqYhz85NYeHuCAUFOSVsPOlTJCQ3X0ThboAMywRe8AvLDnBjDj0J/PRg2pXBhl cWdEDJc5CYml6V4Ihd0aW7N1m7LdF6N9HXI/PxHNmYvJyfB5Fb3ir8MlKNgZEbEV+dEc ZxF9bY3Ar5L6J9zbkzJGCMOte+72U4Jrtj82fIMhVqeZpNvm6Qb/kLUp1vzLDd+sCtqB 4aEOia7dZsBHmHXqNUt8b//dFK7WS9yxycEa7Wj1NE+nqlsdlSk48eRw97/vJk6zXeg9 s2xwi1c8Gr6UQZILCstQ9ZDy5yvWSr9SLelMmbeLhpIXfsr4iR48NxMIqPxTJuLedxld edmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=fRvp/VN2Xlfqmt4nKVHNXMxYTCjiSrkuQdi+a73ymGo=; b=GJ1LBdfIWQIOTpBLXECOEZezcnrm2Hk3OxhXb3Lyttkw6T44ShlxY4g6iIV//y3MRm NqiAjbbB3DQ/e3HbhAR8OEeDsehwytk0ohxGg/yjRLG5cjvKbAibP4GmxjZeAgfjv4r5 BNmQT8Tj9wWlJmKMfqwY837M7WaD7NE7zr+EeSElx+eqHAMQq6ZeWZe7nk74mO0wd7Va EV4zL+KiDEPkknmFvKlAR1KeGvXiNw2EmXn1UtkYYM13Rw50i1yxk7++owQ87OGYlCYl Q7Mywt9JkZS95FlA/jrg40fw/5V6js6KfOFWqvazPZevHR0MNbmiIhl/SH/ZZWlSsZIM 2Ejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=saXIpHPF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g38si6825396edg.96.2019.05.19.14.06.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=saXIpHPF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST0Q-0001pU-6K for patch@linaro.org; Sun, 19 May 2019 17:06:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZL-0003TC-WA for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZK-00042Z-P9 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:07 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44491) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZK-00041r-J9 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:06 -0400 Received: by mail-pf1-x444.google.com with SMTP id g9so6148914pfo.11 for ; Sun, 19 May 2019 13:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fRvp/VN2Xlfqmt4nKVHNXMxYTCjiSrkuQdi+a73ymGo=; b=saXIpHPF2AKzen0wYa8bg8Wg7/NPOHshxt0TUVYcXLf1To1FkBuGZ6HTgamFMDGvci PQfF4jY9aPDPL0kHQQmMpl2PVOM7GzNd6zFE9UZbU39JGbvey/AcgVIJhKP9+gMqZiLJ XeR3QA4lXotuv92ui6yEKoYuXScDTKgClGo/V+TzRLUeRXAAte/l6PLTr8koly2Mf5vf 3/3xZmzyZWc4n42ET7VZrW/2tUs25C6ereWlDFq9Bg8c+JMKGfRtt4wm/3EI+0ijuetT ETL632AGiMr0Nadu52EBg87eLH3cfmjH4431/z3/8dQGB9LCQSKVx6AEpIDpWIp05yUI b4+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fRvp/VN2Xlfqmt4nKVHNXMxYTCjiSrkuQdi+a73ymGo=; b=Xif5altTVZ9E5QcvKpeKpXo9JluiBYe63tLvbYVJtvpBmyZZfMX2oTtyFEGmVrFaRm ITL0mjiygw0CXifXsltZHK9K7GnNaSP4/JJq7CJ4UIJcH1clgh4/Ozhh/mKtjY2AUTwX nq/SsovkWC+0TuvgbsJDfcC0htYIfHb66PL4JaVSS5GwtberqAzgXCEqvW8mImljTmYy M46fgEL6tahyR7aHxaR34Ml4iWwCjjv2DqzrIBdRFtp0dCJM/qmFGUcDXBTSz274ClWv bHagwlTKvfAr2tM8/Df+UUn7NZQN0gTSrsg65Zopmepj5NRsaMJSM5bY0nxXAPWnihrN qw6g== X-Gm-Message-State: APjAAAUDfgM46Y+gBbY0O21Vuby7Zp6T/icyHVjxyLs6OmDHX+Xhwe8e LLl2Xs15z6H0sVr8QRqX6XnRCzUrptE= X-Received: by 2002:a62:38cc:: with SMTP id f195mr76083842pfa.15.1558298285319; Sun, 19 May 2019 13:38:05 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:39 -0700 Message-Id: <20190519203726.20729-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v7 27/74] linux-user: Split out mknod, mknodat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that mknodat is universally provided. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/strace.c | 39 ----------------------------------- linux-user/syscall-file.inc.c | 26 +++++++++++++++++++++++ linux-user/syscall.c | 16 -------------- linux-user/strace.list | 6 ------ 5 files changed, 30 insertions(+), 61 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 9950b73e76..b5951e6911 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -38,6 +38,10 @@ SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); SYSCALL_DEF(link, ARG_STR, ARG_STR); #endif SYSCALL_DEF(linkat, ARG_ATDIRFD, ARG_STR, ARG_ATDIRFD, ARG_STR, ARG_ATFLAG); +#ifdef TARGET_NR_mknod +SYSCALL_DEF(mknod, ARG_STR, ARG_MODEFLAG, ARG_HEX); +#endif +SYSCALL_DEF(mknodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG, ARG_HEX); SYSCALL_DEF(mlock, ARG_PTR, ARG_DEC); SYSCALL_DEF(mlockall, ARG_HEX); #ifdef TARGET_NR_mmap diff --git a/linux-user/strace.c b/linux-user/strace.c index b234274034..c70c06d965 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1923,45 +1923,6 @@ print_syslog(const struct syscallname *name, } #endif -#ifdef TARGET_NR_mknod -static void -print_mknod(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); - - print_syscall_prologue(name); - print_string(arg0, 0); - print_file_mode(arg1, (hasdev == 0)); - if (hasdev) { - print_raw_param("makedev(%d", major(arg2), 0); - print_raw_param("%d)", minor(arg2), 1); - } - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_mknodat -static void -print_mknodat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); - - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_file_mode(arg2, (hasdev == 0)); - if (hasdev) { - print_raw_param("makedev(%d", major(arg3), 0); - print_raw_param("%d)", minor(arg3), 1); - } - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_mq_open static void print_mq_open(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 76637fe71b..3adb629124 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -82,6 +82,32 @@ SYSCALL_IMPL(linkat) return do_linkat(arg1, arg2, arg3, arg4, arg5); } +static abi_long do_mknodat(int dirfd, abi_ulong target_path, + mode_t mode, dev_t dev) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknodat(dirfd, p, mode, dev)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_mknod +SYSCALL_IMPL(mknod) +{ + return do_mknodat(AT_FDCWD, arg1, arg2, arg3); +} +#endif + +SYSCALL_IMPL(mknodat) +{ + return do_mknodat(arg1, arg2, arg3, arg4); +} + /* * Helpers for do_openat, manipulating /proc/self/foo. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ea89734706..18163f558c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5384,22 +5384,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_mknod - case TARGET_NR_mknod: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(mknod(p, arg2, arg3)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_mknodat) - case TARGET_NR_mknodat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(mknodat(arg1, p, arg3, arg4)); - unlock_user(p, arg2, 0); - return ret; -#endif #ifdef TARGET_NR_chmod case TARGET_NR_chmod: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 95706a696b..f56d9acf76 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -518,12 +518,6 @@ #ifdef TARGET_NR_mkdirat { TARGET_NR_mkdirat, "mkdirat" , NULL, print_mkdirat, NULL }, #endif -#ifdef TARGET_NR_mknod -{ TARGET_NR_mknod, "mknod" , NULL, print_mknod, NULL }, -#endif -#ifdef TARGET_NR_mknodat -{ TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL }, -#endif #ifdef TARGET_NR_modify_ldt { TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164514 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4789716ili; Sun, 19 May 2019 13:57:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVSnC2UveK8p8UGKkISHEUPV3aJnx817uHRgKBVVT+tN3xnvRDUM9JV2pjVZZPT1WEkp8M X-Received: by 2002:a17:906:5ad4:: with SMTP id x20mr10055032ejs.225.1558299429659; Sun, 19 May 2019 13:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299429; cv=none; d=google.com; s=arc-20160816; b=j3lHP8CoYRIFGlYhBhdAojq7g+jNG9UgqqK7API2uRvRjucHL25s/j47fMoZTmYl9R zciQJQD0QrHv1EalLL4akTHhBsQJ3majSyQtbzVtSUwkkR8spITuo2G7k6N52YBDJ6/V L5qy9fIukVuwO2/WQBKbVVG1xTUH0R58Jxz5e9r0uDLMcBS1CvPTvbA+vs4yn9CwQ9uG xHydjFrk111vYOnV9KrYdbs96pKKpf+bTXo2UpcBlY2Nyyfvl8BKmr5iOv+H5FzOwyYm ALoifkxZoAdaJfr2S1EK/2B1AcSms66E9JQIl63bdPfay1Gaf+9v2S7WEoFE2260sCUP JatA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=1sQg+P8lShstSTQHyJ7jNTozkqlGpcD4AM3YYr8dTII=; b=zZH6LBs9iRYixQQkD//bbm7u0eoS7RHvnFtyJOSWBVCfYvUsHKrb2GksRCU5tGclqm y36rtL2gRNnpaH8Pa++6esLcHtaC7v7YaMI112qsbaZoyoEe8i8y9zUFIbX4lVEVrP4i Kd8FY9k0aXPTuoddZoZCOpDaysAkFvj9Rkjy/CWsHEY6gfQA5T8qj01ldPq0CYHq+7xt sg8TkVqqgnnSvp+wRx+QraeaFXKAenDgUY3WxXUGk5hhhc6yfwXRisMCFEh8jx//2z0X poQKqKbvLHyb2pRRy1yASOYYvetlpajnn5xZZld3AY79qwMtj6Cg7v+OEB9xg/hhQEbu Qlqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vAxbTJLT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p28si2674684edc.405.2019.05.19.13.57.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:57:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vAxbTJLT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSrk-0002Tg-Fo for patch@linaro.org; Sun, 19 May 2019 16:57:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZN-0003UN-2v for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZL-00043d-RG for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:09 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:41408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZL-000431-Je for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:07 -0400 Received: by mail-pl1-x642.google.com with SMTP id f12so5707086plt.8 for ; Sun, 19 May 2019 13:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1sQg+P8lShstSTQHyJ7jNTozkqlGpcD4AM3YYr8dTII=; b=vAxbTJLT9BXhkiEJCEGyKGl8j7CT9eSVY5wjTULP9AeeXtBs84F7LZPWXrSokxv9p/ D2eFuMuL4jViPFYIvjUyLxxImxybgijNJjWy5ECOlnL/0J0AjEFMbxuKByEWPz9Ndluh Ec04vZjE98kXYnS9KochhkEfOuhTOKjX8381fFT4754W7YiUxxNymHf2/YbRnTZU4AXd b5C+AkbBIsKf2vHsUMDKyksJ/0g1O2JGifvxJLFTfPxJYAYVcBBA3q/87zkR2GIV14Oo xuPDf7JxctcGG9LV9KGEG+fa7cDacPzCj0aYBZfXapz17BQ2ekVB5BkDTy7ZR1KJNxgd 0g3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1sQg+P8lShstSTQHyJ7jNTozkqlGpcD4AM3YYr8dTII=; b=Z+u+HNIIERViHwoD0uPnf9PFKvHpc6GlHwAkhJRcQ5CTBdhqpy6U7Nt3ROxb+bRGuZ 0rwVWgGN74tuJcdwAONh4VbzzsMWLYlZqf7KllDMy2b//+10ErApR5Gndv/ko036x+C1 Hj8iER5Wiuj11q54vPXT97A+YYz2BS7M5tAfAWxvPEGsY9b04FiO5LY+FoG+UH2eflJV VmWzkzcBYBf+W8fuWNFkUo+9c3DT0hg+vbf/hmBaSuj3zr/HFWk/PMBhYfCOJY0Bbjm0 PXz6X2aoUFiogX2ITeObXhZSQqhvaoTDAlqV0owjHWiiPOuE8ECRyccAVT4bDWP29bA1 wizA== X-Gm-Message-State: APjAAAU9+L9azPtyRFHGuN1eQeNxQDYiWLvg2nleXjBU2kyiDZR6MuEK WKu0HKf7JMzAYTOjCuApLNSCENfyxtE= X-Received: by 2002:a17:902:bd95:: with SMTP id q21mr35435241pls.159.1558298286396; Sun, 19 May 2019 13:38:06 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:40 -0700 Message-Id: <20190519203726.20729-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 28/74] linux-user: Split out chmod, fchmod, fchmodat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that fchmodat is universally provided. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 5 +++++ linux-user/strace.c | 28 ---------------------------- linux-user/syscall-file.inc.c | 30 ++++++++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 9 --------- 5 files changed, 35 insertions(+), 55 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index b5951e6911..3ddf8aa0e3 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -20,6 +20,9 @@ SYSCALL_DEF_FULL(brk, .impl = impl_brk, .print_ret = print_syscall_ptr_ret, .arg_type = { ARG_PTR }); SYSCALL_DEF(chdir, ARG_STR); +#ifdef TARGET_NR_chmod +SYSCALL_DEF(chmod, ARG_STR, ARG_MODEFLAG); +#endif SYSCALL_DEF_ARGS(clone, ARG_CLONEFLAG, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); SYSCALL_DEF(close, ARG_DEC); #ifdef TARGET_NR_creat @@ -28,6 +31,8 @@ SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG); SYSCALL_DEF(exit, ARG_DEC); SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); +SYSCALL_DEF(fchmod, ARG_DEC, ARG_MODEFLAG); +SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index c70c06d965..4771badeb5 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1125,19 +1125,6 @@ print_chroot(const struct syscallname *name, } #endif -#ifdef TARGET_NR_chmod -static void -print_chmod(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_file_mode(arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, @@ -1179,21 +1166,6 @@ print_faccessat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_fchmodat -static void -print_fchmodat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_file_mode(arg2, 0); - print_flags(at_file_flags, arg3, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_fchownat static void print_fchownat(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 3adb629124..fb64d5bd1d 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -30,6 +30,26 @@ SYSCALL_IMPL(chdir) return ret; } +static abi_long do_fchmodat(int dirfd, abi_ulong target_path, mode_t mode) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(fchmodat(dirfd, p, mode, 0)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_chmod +SYSCALL_IMPL(chmod) +{ + return do_fchmodat(AT_FDCWD, arg1, arg2); +} +#endif + SYSCALL_IMPL(close) { int fd = arg1; @@ -54,6 +74,16 @@ SYSCALL_IMPL(creat) } #endif +SYSCALL_IMPL(fchmod) +{ + return get_errno(fchmod(arg1, arg2)); +} + +SYSCALL_IMPL(fchmodat) +{ + return do_fchmodat(arg1, arg2, arg3); +} + static abi_long do_linkat(int olddirfd, abi_ulong target_oldpath, int newdirfd, abi_ulong target_newpath, int flags) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 18163f558c..3c0de73aa4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5384,14 +5384,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_chmod - case TARGET_NR_chmod: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chmod(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif #ifdef TARGET_NR_lseek case TARGET_NR_lseek: return get_errno(lseek(arg1, arg2, arg3)); @@ -6463,16 +6455,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_ftruncate case TARGET_NR_ftruncate: return get_errno(ftruncate(arg1, arg2)); -#endif - case TARGET_NR_fchmod: - return get_errno(fchmod(arg1, arg2)); -#if defined(TARGET_NR_fchmodat) - case TARGET_NR_fchmodat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(fchmodat(arg1, p, arg3, 0)); - unlock_user(p, arg2, 0); - return ret; #endif case TARGET_NR_getpriority: /* Note that negative values are valid for getpriority, so we must diff --git a/linux-user/strace.list b/linux-user/strace.list index f56d9acf76..0906aba812 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -61,9 +61,6 @@ #ifdef TARGET_NR_capset { TARGET_NR_capset, "capset" , "%s(%p,%p)", NULL, NULL }, #endif -#ifdef TARGET_NR_chmod -{ TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL }, -#endif #ifdef TARGET_NR_chown { TARGET_NR_chown, "chown" , NULL, NULL, NULL }, #endif @@ -169,12 +166,6 @@ #ifdef TARGET_NR_fchdir { TARGET_NR_fchdir, "fchdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_fchmod -{ TARGET_NR_fchmod, "fchmod" , "%s(%d,%#o)", NULL, NULL }, -#endif -#ifdef TARGET_NR_fchmodat -{ TARGET_NR_fchmodat, "fchmodat" , NULL, print_fchmodat, NULL }, -#endif #ifdef TARGET_NR_fchown { TARGET_NR_fchown, "fchown" , "%s(%d,%d,%d)", NULL, NULL }, #endif From patchwork Sun May 19 20:36:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164535 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4802371ili; Sun, 19 May 2019 14:13:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHWEd/Q2YukagizAFma9Z4PCBzbOoYzivHIVEBwzCZ1msFCptnJe6I+oU9V+GhKOiHSto7 X-Received: by 2002:a50:d791:: with SMTP id w17mr71048847edi.223.1558300420705; Sun, 19 May 2019 14:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300420; cv=none; d=google.com; s=arc-20160816; b=Tr5RjWSYRlqNSndXidfPTy+BK1uhfyBk0i5S8rqdfLUkV3bW9tug5vppdTgUTbRX69 r3iyIyaQgaTDZX+Sihxt/kqulJcQiHR/LB+Wfhsik9GbdezNw5Xo/7mWTtBVO3ewe95t nObt3poBxsO8zeWpn9qs6+0GopNEtf2v78ZWYZKdVRQiyh7dR8lKkEm2npM9xmM9guD6 XSROcT/sO36hc1szLpLP2QpZhfAZbVS5cE+2HwmlshqU35HdFC3G5IEG3tIm7E89t+x9 uGlvKyVh6h4LOS6aJC2fA50CxiFMeq0XnY6W4auy4TT7QRKP73NZ6MS1IxphZSqWNK/m A5NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Fr+Y83wJgizEP7CnBu6nXSORIZtVsEotOiuWEaOuuHQ=; b=TjwPqn9ZTUFWpP5NymI3NA+o3Dg5grhjnBUKsnnsj3cl1XM4gh5hx7dd6LarL+QL6T ahC6FuGuny4sYdqKA42a0Z4odBo012dIkhhC/NnrXRcJiUV/kEAxPnUXe02EFAsnn/3J QnLdsMuYpeIfd1qYZems59yj6hv3vqmAideJqhZkXcYUciLaFonmUgfizW38QWK+A7mY 4XSexeAR4kk+aAr83nYIQqdNcKqr/t97Gc5qptWVJVoOV9fMLBTk1ftIGX1+UFIQHibv Hl0ur1GgR52FCgjzhi4jxBQzhi9ajXxX6FKYdeJKKUyRgFyYFgMdk/10w/keWA6AuGz9 bvrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DN+SZarK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f43si11405721ede.324.2019.05.19.14.13.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:13:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DN+SZarK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST7j-0000Yp-Ed for patch@linaro.org; Sun, 19 May 2019 17:13:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZP-0003Uz-Ps for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZM-00044x-Vb for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:11 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:33534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZM-00044C-Mh for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:08 -0400 Received: by mail-pl1-x644.google.com with SMTP id y3so5734937plp.0 for ; Sun, 19 May 2019 13:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fr+Y83wJgizEP7CnBu6nXSORIZtVsEotOiuWEaOuuHQ=; b=DN+SZarK91Y4XHtFwUYdxqzhozTXefEyZ2fINNxGFOWw/Ggjwa4GgCqEt63vBTYfsd cqD1+5SXiGEJAng1nBCQ7X7aiu61iXl084tiqNjpXAELKKm24NkMZFMQjPFBE7tHI4vi mJWXUknNq5hsFdYuDSbX2RvJbjpgijNogsYGPJRAb1+kys7NgKQjOIOm7BKeW/NnXDAD RAuoo4m66u9xSCVpA5TB2mP0Dm17bjFJJ3fdycSTAliwt4PK8kZXXXJvhB7os7MShrll 1S4mOHAqXJaRSyUzHXgG2cj31JCighBlEvZaOWMd698U1dakntjF2wff7Q/WLv7oY4q1 fwKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Fr+Y83wJgizEP7CnBu6nXSORIZtVsEotOiuWEaOuuHQ=; b=ul9NCu0OOKOEt4aMikvoXXmuhFxiNssfurfFybevS+IcHPdlTbDWiWG5MtnDaa/8u5 fjPjkYqKq+eWKJ6h1cbkI5tckMhMxMO5TRsoLKsjdHbf1IGHhzH12ukHK5r/E5Ni4YGc h137jCN/NAG2RkDjRNqpufvTTqv2HndsGAUbjvuojMKekDbR9Bi56QUHmZoxD8hRvJu3 oCCT4Coc16+i0xQt+qcFu/rUXalrhzU5h2fPp/yZ8bZUEQ5yTMKaBHOtG4NRDLc/fCLU AO5XL4dCIKQmUWiJxywMmMydD3TfSXdTYtGJztCkB21GM/uwfpyaFKPH8OPZ+Se2MJBR 53Cg== X-Gm-Message-State: APjAAAVu+nRfgBH+jMocVM3e2W7Zgyi/IHXv9MMqdAqOhOGrS7Me659d 6Q/iqc8p7L7H6Ka06Cr84oFD/2pvh7c= X-Received: by 2002:a17:902:15c5:: with SMTP id a5mr72386863plh.39.1558298287474; Sun, 19 May 2019 13:38:07 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:41 -0700 Message-Id: <20190519203726.20729-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v7 29/74] linux-user: Split out lseek, llseek X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Canonicalise the target syscall name on llseek (new kernels) instead of _llseek (old kernels). Always use host lseek(3) rather than attempting to use the host llseek(2). Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++++ linux-user/syscall.h | 1 + linux-user/strace.c | 39 +++++++++++++++-------------------- linux-user/syscall-file.inc.c | 36 ++++++++++++++++++++++++++++++++ linux-user/syscall.c | 32 ++-------------------------- linux-user/strace.list | 6 ------ 6 files changed, 62 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 3ddf8aa0e3..3453e7afdf 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -43,6 +43,12 @@ SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); SYSCALL_DEF(link, ARG_STR, ARG_STR); #endif SYSCALL_DEF(linkat, ARG_ATDIRFD, ARG_STR, ARG_ATDIRFD, ARG_STR, ARG_ATFLAG); +#ifdef TARGET_NR_lseek +SYSCALL_DEF(lseek, ARG_DEC, ARG_DEC, ARG_LSEEKWHENCE); +#endif +#ifdef TARGET_NR_llseek +SYSCALL_DEF_ARGS(llseek, ARG_DEC, ARG_DEC, ARG_PTR, ARG_LSEEKWHENCE); +#endif #ifdef TARGET_NR_mknod SYSCALL_DEF(mknod, ARG_STR, ARG_MODEFLAG, ARG_HEX); #endif diff --git a/linux-user/syscall.h b/linux-user/syscall.h index bdc4d653c4..c16c0a3f1e 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -64,6 +64,7 @@ typedef enum { ARG_MODEFLAG, ARG_OPENFLAG, ARG_UNLINKATFLAG, + ARG_LSEEKWHENCE, /* These are interpreted as pointers. */ ARG_PTR, diff --git a/linux-user/strace.c b/linux-user/strace.c index 4771badeb5..a4d7b397b4 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -934,6 +934,20 @@ print_open_flags(abi_long flags, int last) gemu_log("%s%s", buf, get_comma(last)); } +static int add_lseek_whence(char *buf, int size, int whence) +{ + switch (whence) { + case SEEK_SET: + return snprintf(buf, size, "SEEK_SET"); + case SEEK_CUR: + return snprintf(buf, size, "SEEK_CUR"); + case SEEK_END: + return snprintf(buf, size, "SEEK_END"); + default: + return snprintf(buf, size, "%#x", whence); + } +} + static void print_syscall_prologue(const struct syscallname *sc) { @@ -1297,28 +1311,6 @@ print_futimesat(const struct syscallname *name, } #endif -#ifdef TARGET_NR__llseek -static void -print__llseek(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - const char *whence = "UNKNOWN"; - print_syscall_prologue(name); - print_raw_param("%d", arg0, 0); - print_raw_param("%ld", arg1, 0); - print_raw_param("%ld", arg2, 0); - print_pointer(arg3, 0); - switch(arg4) { - case SEEK_SET: whence = "SEEK_SET"; break; - case SEEK_CUR: whence = "SEEK_CUR"; break; - case SEEK_END: whence = "SEEK_END"; break; - } - gemu_log("%s",whence); - print_syscall_epilogue(name); -} -#endif - #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, @@ -2329,6 +2321,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_UNLINKATFLAG: len = add_flags(b, rest, unlinkat_flags, arg, true); break; + case ARG_LSEEKWHENCE: + len = add_lseek_whence(b, rest, arg); + break; case ARG_PTR: len = add_pointer(b, rest, arg); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index fb64d5bd1d..e267adec1e 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -112,6 +112,42 @@ SYSCALL_IMPL(linkat) return do_linkat(arg1, arg2, arg3, arg4, arg5); } +#ifdef TARGET_NR_lseek +SYSCALL_IMPL(lseek) +{ + return get_errno(lseek(arg1, arg2, arg3)); +} +#endif + +#ifdef TARGET_NR_llseek +SYSCALL_ARGS(llseek) +{ + /* The parts for offset are *always* in big-endian order. */ + abi_ulong lo = in[2], hi = in[1]; + out[1] = (((uint64_t)hi << (TARGET_ABI_BITS - 1)) << 1) | lo; + out[2] = in[3]; + out[3] = in[4]; + return def; +} + +SYSCALL_IMPL(llseek) +{ + int fd = arg1; + int64_t offset = arg2; + abi_ulong target_res = arg3; + int whence = arg4; + + off_t res = lseek(fd, offset, whence); + + if (res == -1) { + return get_errno(-1); + } else if (put_user_s64(res, target_res)) { + return -TARGET_EFAULT; + } + return 0; +} +#endif + static abi_long do_mknodat(int dirfd, abi_ulong target_path, mode_t mode, dev_t dev) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3c0de73aa4..9eff91d67e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -192,8 +192,8 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #endif /* Newer kernel ports have llseek() instead of _llseek() */ -#if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek) -#define TARGET_NR__llseek TARGET_NR_llseek +#if !defined(TARGET_NR_llseek) && defined(TARGET_NR__llseek) +#define TARGET_NR_llseek TARGET_NR__llseek #endif #define __NR_sys_gettid __NR_gettid @@ -217,10 +217,6 @@ _syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count) (defined(TARGET_NR_getdents64) && defined(__NR_getdents64)) _syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count); #endif -#if defined(TARGET_NR__llseek) && defined(__NR_llseek) -_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, - loff_t *, res, uint, wh); -#endif _syscall3(int, sys_rt_sigqueueinfo, pid_t, pid, int, sig, siginfo_t *, uinfo) _syscall4(int, sys_rt_tgsigqueueinfo, pid_t, pid, pid_t, tid, int, sig, siginfo_t *, uinfo) @@ -5384,10 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_lseek - case TARGET_NR_lseek: - return get_errno(lseek(arg1, arg2, arg3)); -#endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_getxpid: @@ -6886,26 +6878,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(fchdir(arg1)); case TARGET_NR_personality: return get_errno(personality(arg1)); -#ifdef TARGET_NR__llseek /* Not on alpha */ - case TARGET_NR__llseek: - { - int64_t res; -#if !defined(__NR_llseek) - res = lseek(arg1, ((uint64_t)arg2 << 32) | (abi_ulong)arg3, arg5); - if (res == -1) { - ret = get_errno(res); - } else { - ret = 0; - } -#else - ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); -#endif - if ((ret == 0) && put_user_s64(res, arg4)) { - return -TARGET_EFAULT; - } - } - return ret; -#endif #ifdef TARGET_NR_getdents case TARGET_NR_getdents: #ifdef EMULATE_GETDENTS_WITH_GETDENTS diff --git a/linux-user/strace.list b/linux-user/strace.list index 0906aba812..fb37c72a1f 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -455,9 +455,6 @@ #ifdef TARGET_NR_llistxattr { TARGET_NR_llistxattr, "llistxattr" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR__llseek -{ TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL }, -#endif #ifdef TARGET_NR_lock { TARGET_NR_lock, "lock" , NULL, NULL, NULL }, #endif @@ -467,9 +464,6 @@ #ifdef TARGET_NR_lremovexattr { TARGET_NR_lremovexattr, "lremovexattr" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_lseek -{ TARGET_NR_lseek, "lseek" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_lsetxattr { TARGET_NR_lsetxattr, "lsetxattr" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164513 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4789648ili; Sun, 19 May 2019 13:57:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZlqT3CauB+/ppu1IhQpWRJgxTOH3wl27oZ0M2B5UnTDjAKEIV+KILlt3ko2OR5DwMB4+h X-Received: by 2002:a50:9405:: with SMTP id p5mr71417392eda.111.1558299422777; Sun, 19 May 2019 13:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299422; cv=none; d=google.com; s=arc-20160816; b=roAA4YPLA6QK97O69rwte63w/uaUsB0TisYIg/i6JCmnYxwVeIyZZLIYLf4kR/x+VN D4zagapW5+d3EolqxAWqOYpvQKQzsEpw6SB6DOiMBLxZ1y8x0wVSN8NB2murFJVuUwkC 9N0rT/k3+QaBoLHi0GmUi62CalCdpB1zz9uNiIRwWK/87hdslw2cifsAqyAk9JZc1mdH 3njXJJc2kunddaxPcBzkheeardW+Gf4r49IDEoprkG6m01sfWRwlxnkdDLMLsixgXkVl pF38eHztOsrP9h3t5mvt6qVTissRU4CEn9BHfE+GPeJYnJUREmwgV68zvw1igvnF4zG1 BaLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=O0n99AE5tNLgI5sw9XY04BuwTLwo+9pblzvHaGIq2Io=; b=jQsgaQbmtduzwUJXAPvwh9lDeSiN/PYZqb3LQ4tBH4c2NOtfreFyxZn88m+ePgQzUU LLr5XX96058uWJ3zZh38EMBZn2Xt9nagRZhQcQDpkBiGmHCAPb7DldOS3mdfXnxusi8+ KpqHHH+vrcA6uDLnz5tFN3+6x2uGzkgbEKwYhjz+hze4vsBOAe2s7TuSkcxkW+cpE8MF ESHcqd7BLWu08vEFs0fu0HfqZUcNyBCXu821XpSf0RT10SpdeZ3Up8/Uf78I2Jw2UxpW rGHdp1TdtO56eeEjT6cCeM81lxutLixl2+I71qd/H6NB11JOPorRRAQJglpGuj3BKc+q CoKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KDyaYmLe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b11si11395354eda.406.2019.05.19.13.57.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KDyaYmLe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSrd-00022M-Ke for patch@linaro.org; Sun, 19 May 2019 16:57:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZP-0003Ux-Pq for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZO-00046X-1n for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:11 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:35574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZN-00045Z-SC for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:09 -0400 Received: by mail-pl1-x642.google.com with SMTP id p1so336469plo.2 for ; Sun, 19 May 2019 13:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O0n99AE5tNLgI5sw9XY04BuwTLwo+9pblzvHaGIq2Io=; b=KDyaYmLeMB/Lq790sWs17F/wY9hB5NqTGzlcS7bVGZbIg9MYUjVb989BAFRRIFW/we FyYXn+8izZQ2c1QP+wPD5EuEqSRxDh5rSnU/PY6POtKptC8mcGG5oLDMXZVkJTZfMR1Q p8gTcpdONvb2iL+uttUKRnUNEF/dlc+1SJ/reitNFLIj5kYHatkF2mCh0yE1DB/yg+Xa PkLzJ+rQAqdrqpDTCPt/nYLFQ5RmmzcYJK9qp/CLXuamq2FMN+iBk+fQT/B7PZqaxlK7 T9s/DAGhjrQdRcaycjSDVv1wO1yj9xd1TMdxkvJbY8qSKTSVAaosenku+0EE0RXFRcX/ mDpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O0n99AE5tNLgI5sw9XY04BuwTLwo+9pblzvHaGIq2Io=; b=qpWZeMGg6WyGW9pK1zxejP110y9n7ig8E6Qowny99wL58dhKc9dIxYRTk1Bti6fWeh NghTvFzQ2039S+IClIYzUDN4esPuKlAu2dbTUu5uMcYABDY5f8FInMeOrirrfLFu1cUW U432Wnkgn2G0PAlNSsf4TGrSvQvQaQr3zt+qFaa4k6ru/LuhahixElQxApMAmNwU+p+u VaS63saTdqxPnB2wMcoR51BsUdywUa4xBRrCUXJoPm4GQkTLQIvKTSW1Y2yg/mXjbMrF +vkd0eC+pEsP4Tvq4uYcSkQOLwrxvOBRj5yWqBEvVjMYy7lQMARr23Blav1Rhyw0y+Uc 30Iw== X-Gm-Message-State: APjAAAWf+eZuxuYz7RF5vcdSAT7xO1qJshHTtaNbxlxn5SwKzjbAZT1D rWV1wrOnTxfemfYboCiUJR2f5s4uu18= X-Received: by 2002:a17:902:7617:: with SMTP id k23mr28206500pll.175.1558298288656; Sun, 19 May 2019 13:38:08 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:42 -0700 Message-Id: <20190519203726.20729-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 30/74] linux-user: Split out getpid, getppid, getxpid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 9 +++++++++ linux-user/syscall-proc.inc.c | 23 +++++++++++++++++++++++ linux-user/syscall.c | 14 -------------- linux-user/strace.list | 9 --------- 4 files changed, 32 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 3453e7afdf..d163bbf409 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -36,6 +36,15 @@ SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif +#ifdef TARGET_NR_getpid +SYSCALL_DEF(getpid); +#endif +#ifdef TARGET_NR_getppid +SYSCALL_DEF(getppid); +#endif +#ifdef TARGET_NR_getxpid +SYSCALL_DEF(getxpid); +#endif #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index fd114d1f03..4d8d385b38 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -438,6 +438,29 @@ SYSCALL_IMPL(fork) } #endif +#ifdef TARGET_NR_getpid +SYSCALL_IMPL(getpid) +{ + return getpid(); +} +#endif + +#ifdef TARGET_NR_getppid +SYSCALL_IMPL(getppid) +{ + return getppid(); +} +#endif + +#ifdef TARGET_NR_getxpid +SYSCALL_IMPL(getxpid) +{ + /* Alpha specific */ + cpu_env->ir[IR_A4] = getppid(); + return getpid(); +} +#endif + /* * Map host to target signal numbers for the wait family of syscalls. * Assume all other status bits are the same. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9eff91d67e..29ea56deee 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,16 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) - /* Alpha specific */ - case TARGET_NR_getxpid: - ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid(); - return get_errno(getpid()); -#endif -#ifdef TARGET_NR_getpid - case TARGET_NR_getpid: - return get_errno(getpid()); -#endif case TARGET_NR_mount: { /* need to look at the data field */ @@ -5721,10 +5711,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } #endif -#ifdef TARGET_NR_getppid /* not on alpha */ - case TARGET_NR_getppid: - return get_errno(getppid()); -#endif #ifdef TARGET_NR_getpgrp case TARGET_NR_getpgrp: return get_errno(getpgrp()); diff --git a/linux-user/strace.list b/linux-user/strace.list index fb37c72a1f..3e898ea307 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -298,15 +298,9 @@ #ifdef TARGET_NR_getpgrp { TARGET_NR_getpgrp, "getpgrp" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getpid -{ TARGET_NR_getpid, "getpid" , "%s()", NULL, NULL }, -#endif #ifdef TARGET_NR_getpmsg { TARGET_NR_getpmsg, "getpmsg" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getppid -{ TARGET_NR_getppid, "getppid" , "%s()", NULL, NULL }, -#endif #ifdef TARGET_NR_getpriority { TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL }, #endif @@ -365,9 +359,6 @@ #ifdef TARGET_NR_getxgid { TARGET_NR_getxgid, "getxgid" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getxpid -{ TARGET_NR_getxpid, "getxpid" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_getxuid { TARGET_NR_getxuid, "getxuid" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164518 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4791445ili; Sun, 19 May 2019 14:00:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/FUv0UaqvBcQI8UGkAfKl+pF4efkg5qPj/Ps/ydIOPN3cpg89pFQPeFHVUU2Eeg1/nglN X-Received: by 2002:aa7:c403:: with SMTP id j3mr36800636edq.144.1558299602135; Sun, 19 May 2019 14:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299602; cv=none; d=google.com; s=arc-20160816; b=amJqY7xZ9JR9Uj6VR90OevNykWJRJMedLxqS4W7sWBKzNXigVIkn0+uwTvIr+XY5eh GJpM2r9DzthcU7VfGQd5sfjHV6v1oZgHG6rpAO6djOkrHiY0A8X5/4Q3DZmLVE7998Qh IUSy5ElyVFcxWtTsXyv9g66Z0X/Tisq8vmWicI2zrf6+JTYZXG8cOjv5ORDYTe/Y8IKZ BtPbEfhslDflDc4cz89ubyQ24g7BwSxU8kN05yGG++C9p6n+v7cYc+TU3qjSakN9YUai TX6dFxlNEL8r0xWakJII4r2Ed4EWu7w16VZG2u7dDgPV6Ny8AbrNWTcse+xv1wVxdUqa C0rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=9Z3useuzztxYfCeDiCfuyQXw+fak2amXB2su9Sfs8mg=; b=Omtv+n6HWWC5Bfxc2oKcFiDY7Z7A4drkEFyK13HDnEUMF3fdz9CjzNeRLUbJmN+xdR bfFJxgReod56ejdLZvbMDOixN53/ykyyablbOi6aoHCXocLdCKRfbT+LoJFuQVyQJNL/ CcEEIoffwLUfUzr+albkI8HuSYdub3IIzJngHFhFTggTU8Pz4O51rxJxsVgrJ1AUW43u rt5kV7MnWyNu6AyvjHfWyien2gGAKZCHYmwuhBOS0iLVJ2szkG4UQryt6sD8SY8UwbiB uaZQHpOaRKPNARZdFnVdHtul6VqlcCmI73JUGMLk57gJNTFG9mO+IngKTsH4TSK9/uew 0gRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mPZtMxnC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v23si12146698edc.331.2019.05.19.14.00.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:00:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mPZtMxnC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSuW-0004Vg-TN for patch@linaro.org; Sun, 19 May 2019 17:00:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZT-0003X3-HG for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZQ-00049X-HK for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:14 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:35575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZP-000471-QR for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:11 -0400 Received: by mail-pl1-x643.google.com with SMTP id p1so336479plo.2 for ; Sun, 19 May 2019 13:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9Z3useuzztxYfCeDiCfuyQXw+fak2amXB2su9Sfs8mg=; b=mPZtMxnCs5H13UhWV/nYpwBKyqzbAKant19NkKg2wWlvfuMcwP0JO88J1xRoHKCvY2 tPwW38EU9gWuMhioCd4UXG8tkAKYkMAa7W0OwCa0N+ZvP2j9a/6F5HihPR7+1FaLx8JD dCnUWGzOywUKHnVXY3zikG0Z44XdaZl6DADVI0eoaW1nsz9gvITMMKP1ATgpY5oEzKkw gRRDVxC8iRuirAkeVdE4WENwgLWbFsacL+zeK4nmGz6qFvyDyE5tqoL6U966QZrvWa25 9ygk7nJgylfEZWKysXG9m1IgQbo1HFFxzOgn3Sabgnoe9Qn7lithEC8jei8uEt6G9O6Y vq9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9Z3useuzztxYfCeDiCfuyQXw+fak2amXB2su9Sfs8mg=; b=QMEB2YICtTkuunfm5fw19Foh3Op+HDdCyRqNwRtmE9L+LJybRDmcL9EA18N0oy2O7N B/vB9Ob/TlIXb1bZtIk+AzRPtuKfP5DfjECA43SwVJ5NdfBlmfeVgRwGfHj0gTiLtrXn TdMfauTMtTsAaZqhjEOyAmTcu/WY3h4dIxkLD7gj++wKQZAeAT065xStvWHiPmAKIMq2 5XLNdb3iCzxIDYQ8yo2c+BZ3fejm1iPVnQxe52zDaZKDAgdoxEINXVvi+EjFXXVWti96 KInMDgEgBqJ7tQ5XoKOrLJRvE0/DS3zMNp+0uxq+O8WLPRat46HWp/sAO/ZX/6iN0eJc g/kw== X-Gm-Message-State: APjAAAXsNRSV77yNW9V89AOfIqiWzBgRQqzdQ2L1Rro7qgMbVN904NrB /AkPxjvkyq1S39HqzrghP45YIknsPbY= X-Received: by 2002:a17:902:e409:: with SMTP id ci9mr61761083plb.103.1558298289784; Sun, 19 May 2019 13:38:09 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:43 -0700 Message-Id: <20190519203726.20729-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v7 31/74] linux-user: Split out mount X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall.h | 1 + linux-user/strace.c | 21 +++---------- linux-user/syscall-file.inc.c | 48 ++++++++++++++++++++++++++++++ linux-user/syscall.c | 55 ----------------------------------- linux-user/strace.list | 3 -- 6 files changed, 54 insertions(+), 75 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index d163bbf409..2b331c6a6d 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -78,6 +78,7 @@ SYSCALL_DEF_FULL(mmap2, .impl = impl_mmap, .arg_type = { ARG_PTR, ARG_DEC, ARG_MMAPPROT, ARG_MMAPFLAG, ARG_DEC, ARG_DEC64 }); #endif +SYSCALL_DEF(mount, ARG_STR, ARG_STR, ARG_STR, ARG_MOUNTFLAG, ARG_PTR); SYSCALL_DEF(mprotect, ARG_PTR, ARG_DEC, ARG_MMAPPROT); SYSCALL_DEF_FULL(mremap, .impl = impl_mremap, .print_ret = print_syscall_ptr_ret, diff --git a/linux-user/syscall.h b/linux-user/syscall.h index c16c0a3f1e..35dd3e5fa3 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -62,6 +62,7 @@ typedef enum { ARG_MMAPFLAG, ARG_MMAPPROT, ARG_MODEFLAG, + ARG_MOUNTFLAG, ARG_OPENFLAG, ARG_UNLINKATFLAG, ARG_LSEEKWHENCE, diff --git a/linux-user/strace.c b/linux-user/strace.c index a4d7b397b4..a99ab46b97 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -708,7 +708,7 @@ static struct flags const open_flags[] = { FLAG_END, }; -UNUSED static struct flags mount_flags[] = { +static struct flags const mount_flags[] = { #ifdef MS_BIND FLAG_GENERIC(MS_BIND), #endif @@ -2015,22 +2015,6 @@ print_symlinkat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_mount -static void -print_mount(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_string(arg1, 0); - print_string(arg2, 0); - print_flags(mount_flags, arg3, 0); - print_pointer(arg4, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_umount static void print_umount(const struct syscallname *name, @@ -2315,6 +2299,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_MODEFLAG: len = add_flags(b, rest, mode_flags, arg, true); break; + case ARG_MOUNTFLAG: + len = add_flags(b, rest, mount_flags, arg, true); + break; case ARG_OPENFLAG: len = add_open_flags(b, rest, arg); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index e267adec1e..4fc12512c2 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -174,6 +174,54 @@ SYSCALL_IMPL(mknodat) return do_mknodat(arg1, arg2, arg3, arg4); } +SYSCALL_IMPL(mount) +{ + abi_ulong target_src = arg1; + abi_ulong target_tgt = arg2; + abi_ulong target_fst = arg3; + abi_ulong mountflags = arg4; + abi_ulong target_data = arg5; + char *p_src = NULL, *p_tgt = NULL, *p_fst = NULL, *p_data = NULL; + abi_long ret = -TARGET_EFAULT; + + if (target_src) { + p_src = lock_user_string(target_src); + if (!p_src) { + goto exit0; + } + } + + p_tgt = lock_user_string(target_tgt); + if (!p_tgt) { + goto exit1; + } + + if (target_fst) { + p_fst = lock_user_string(target_fst); + if (!p_fst) { + goto exit2; + } + } + + /* + * FIXME - arg5 should be locked, but it isn't clear how to + * do that since it's not guaranteed to be a NULL-terminated + * string. + */ + if (target_data) { + p_data = g2h(target_data); + } + ret = get_errno(mount(p_src, p_tgt, p_fst, mountflags, p_data)); + + unlock_user(p_fst, target_fst, 0); + exit2: + unlock_user(p_tgt, target_tgt, 0); + exit1: + unlock_user(p_src, target_src, 0); + exit0: + return ret; +} + /* * Helpers for do_openat, manipulating /proc/self/foo. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 29ea56deee..c826c65317 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,61 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_mount: - { - /* need to look at the data field */ - void *p2, *p3; - - if (arg1) { - p = lock_user_string(arg1); - if (!p) { - return -TARGET_EFAULT; - } - } else { - p = NULL; - } - - p2 = lock_user_string(arg2); - if (!p2) { - if (arg1) { - unlock_user(p, arg1, 0); - } - return -TARGET_EFAULT; - } - - if (arg3) { - p3 = lock_user_string(arg3); - if (!p3) { - if (arg1) { - unlock_user(p, arg1, 0); - } - unlock_user(p2, arg2, 0); - return -TARGET_EFAULT; - } - } else { - p3 = NULL; - } - - /* FIXME - arg5 should be locked, but it isn't clear how to - * do that since it's not guaranteed to be a NULL-terminated - * string. - */ - if (!arg5) { - ret = mount(p, p2, p3, (unsigned long)arg4, NULL); - } else { - ret = mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)); - } - ret = get_errno(ret); - - if (arg1) { - unlock_user(p, arg1, 0); - } - unlock_user(p2, arg2, 0); - if (arg3) { - unlock_user(p3, arg3, 0); - } - } - return ret; #ifdef TARGET_NR_umount case TARGET_NR_umount: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 3e898ea307..9b4024d94f 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -497,9 +497,6 @@ #ifdef TARGET_NR_modify_ldt { TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_mount -{ TARGET_NR_mount, "mount" , NULL, print_mount, NULL }, -#endif #ifdef TARGET_NR_move_pages { TARGET_NR_move_pages, "move_pages" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164520 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4794110ili; Sun, 19 May 2019 14:02:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoSo+TMsWZLh2MSXNJW51GyyTU5zrzjQbM09lb7ymihPv6mSNkA9AN/S9i5BYJZfGwvRIC X-Received: by 2002:a50:8682:: with SMTP id r2mr70018607eda.106.1558299776230; Sun, 19 May 2019 14:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299776; cv=none; d=google.com; s=arc-20160816; b=nxedtasrhfY5mSqCZwQgFn7cIXBw1M8ssK7kLNYhjcRut61md5k/O0xDyiVO0KStcn 1GZ0XwPysNTXqiIGFxlyE38Go/ltVK6GOiGOS10NOXyO/lp6qN9fyGrGsKDJTEhBD/Ne o2UwthTHqH39OxKYG8P9O1UTNQ66sZ3AaGkxO3yOxvkIVkSDKVyW7W9nCTubiWSeIwQv VxDfjmYKc9tqx//NX4nx7FyOAtAbRRqJJqMNo+Z+H8Ct4iZY6gVkrdSsLHmTtCjZORJ+ WjsSr7Pa9RrVYYdV4PaAZobL+dwQEBgXVHC+Mg+j48bseYJ478IYPgRvw4wzOh7D4a+c rO9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=FcVdmu4jJhr5SxGI0pZ6zduAqhixd7w4CsRDiK5ssJ4=; b=0vNOWQ3iFX2CYjjlYg9cfZQIaM4f8aBu4AycVb1gFLOFIvOREuph/U5ZFj0RMM6XQF PwY5bL0U+Dp6PnT0a7oFu7riqKPzlZIYCsnUz6CjxJjnyKihWor4g/NwbCFp2BSLjVu5 fc0joXcQ2Js7xzcLQsqbdjFMePtD7BRVEf+/ylLVv+//WRlQRVLjvSbGkeZiL8ivt4eI 2U8wha18D+hGvvvmy9aV/q8uyEaayd88qrFbC2VoFck+Fs4Vo5TkpHhC84AyBlWX8qeV Wt2eU0Cd+jrbewr8yS62usLTZHnRQLdJQ9PI/y4JnIgjheijOSolrd+PW9k24+EW0o1V Hk8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NBW1rsds; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r21si6955333ejn.154.2019.05.19.14.02.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:02:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NBW1rsds; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSxL-0007M1-48 for patch@linaro.org; Sun, 19 May 2019 17:02:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZX-0003X6-9y for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZV-0004G0-Cp for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:19 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:37617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZR-00048V-Ln for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:14 -0400 Received: by mail-pl1-x641.google.com with SMTP id p15so5718925pll.4 for ; Sun, 19 May 2019 13:38:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FcVdmu4jJhr5SxGI0pZ6zduAqhixd7w4CsRDiK5ssJ4=; b=NBW1rsdsAeQKQIkAPkswlg4vV1I2Kbo3HgNVFCXApRyVXSWDtkETS0tSGyGyDszXR8 if1vF1uhZlttD332RE0c7rukzIPQWMUKRP0jg0c+qxnwJ8E3o9T57lK9aAMhPaI6YXYk 6QfWm4U1YyEMdt3Mhvom0Qqh1fcgxGHpBJkOtyIzS9wtzBrg0y4DXS8ws2yetw2z0fLZ eFBtBn+59JWJ5RYYswooOvP2qAfe1Z/EIAG3kaB7wuZy6ETBsdU0rs1QYfb591exX9vZ BXx/D22pLlA/Zffd8DdPGI4zIw+d1YgMIUSnDQe9IjUX8KY9PjPBzTAE7oy/2p/PnX/+ MI4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FcVdmu4jJhr5SxGI0pZ6zduAqhixd7w4CsRDiK5ssJ4=; b=rG/++Ko6a9HrEGm0g7wXseI9/iBD/odUnKRMrydU6/R9tV7et9LNYxTWQwDW4MB+Ut pDQrWrBoPIBfMRuhnNRklPt2f61OGR0fYt9QI6d7fuvQ+2oHU11yhOAYXmpgv+sCfW/t +byJGo2gVpfQQOpJi8d1tyWcl6BQ71lp32za0PB2KvuTjj+8KH0Y11JNkNp71cv2ZGUM b+HwIXMnsWfaWjNrf07QzX+eHVvu1i8Zamtmjkh12tV6mnWKS7YS4OKnPmOhIwK1qd5G lAeFkftKseMU/MIptFO8lgE3vWE5Bx623nQ/aLdZhpCst+ZyLflPV3pCoyTWfzSx1wXT Hx9g== X-Gm-Message-State: APjAAAVzsCszWrY9Sk1ms56VktlVukBHMacqiJqrVLQ+CJqjvxzUfi/3 v/ZDX7XutkUnS+vw7WFh0UfzeKC/Tc8= X-Received: by 2002:a17:902:e00a:: with SMTP id ca10mr73329060plb.18.1558298290948; Sun, 19 May 2019 13:38:10 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:44 -0700 Message-Id: <20190519203726.20729-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 32/74] linux-user: Split out umount, umount2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that umount2 is unconditionally available. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall.h | 1 + linux-user/strace.c | 30 ++++-------------------------- linux-user/syscall-file.inc.c | 25 +++++++++++++++++++++++++ linux-user/syscall.c | 16 ---------------- linux-user/strace.list | 6 ------ 6 files changed, 34 insertions(+), 48 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 2b331c6a6d..0d8da0c6d6 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -155,6 +155,10 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #ifdef TARGET_NR_time SYSCALL_DEF(time, ARG_PTR); #endif +#ifdef TARGET_NR_umount +SYSCALL_DEF(umount, ARG_STR); +#endif +SYSCALL_DEF(umount2, ARG_STR, ARG_UMOUNTFLAG); #ifdef TARGET_NR_unlink SYSCALL_DEF(unlink, ARG_STR); #endif diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 35dd3e5fa3..3c936b648a 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -64,6 +64,7 @@ typedef enum { ARG_MODEFLAG, ARG_MOUNTFLAG, ARG_OPENFLAG, + ARG_UMOUNTFLAG, ARG_UNLINKATFLAG, ARG_LSEEKWHENCE, diff --git a/linux-user/strace.c b/linux-user/strace.c index a99ab46b97..278d235ae6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -733,7 +733,7 @@ static struct flags const mount_flags[] = { FLAG_END, }; -UNUSED static struct flags umount2_flags[] = { +static struct flags const umount2_flags[] = { #ifdef MNT_FORCE FLAG_GENERIC(MNT_FORCE), #endif @@ -2015,31 +2015,6 @@ print_symlinkat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_umount -static void -print_umount(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_umount2 -static void -print_umount2(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_flags(umount2_flags, arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_utime static void print_utime(const struct syscallname *name, @@ -2305,6 +2280,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_OPENFLAG: len = add_open_flags(b, rest, arg); break; + case ARG_UMOUNTFLAG: + len = add_flags(b, rest, umount2_flags, arg, false); + break; case ARG_UNLINKATFLAG: len = add_flags(b, rest, unlinkat_flags, arg, true); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 4fc12512c2..345b4cb421 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -816,6 +816,31 @@ SYSCALL_IMPL(readlinkat) } #endif +static abi_long do_umount2(abi_ulong target_path, int flags) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(umount2(p, flags)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_umount +SYSCALL_IMPL(umount) +{ + return do_umount2(arg1, 0); +} +#endif + +SYSCALL_IMPL(umount2) +{ + return do_umount2(arg1, arg2); +} + static abi_long do_unlinkat(int dirfd, abi_ulong target_path, int flags) { char *p = lock_user_string(target_path); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c826c65317..f3e03f535d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,14 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_umount - case TARGET_NR_umount: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(umount(p)); - unlock_user(p, arg1, 0); - return ret; -#endif #ifdef TARGET_NR_stime /* not on alpha */ case TARGET_NR_stime: { @@ -5608,14 +5600,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); } return ret; -#ifdef TARGET_NR_umount2 - case TARGET_NR_umount2: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(umount2(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_ioctl: return do_ioctl(arg1, arg2, arg3); #ifdef TARGET_NR_fcntl diff --git a/linux-user/strace.list b/linux-user/strace.list index 9b4024d94f..973a4c9209 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1368,12 +1368,6 @@ #ifdef TARGET_NR_umask { TARGET_NR_umask, "umask" , "%s(%#o)", NULL, NULL }, #endif -#ifdef TARGET_NR_umount -{ TARGET_NR_umount, "umount" , NULL, print_umount, NULL }, -#endif -#ifdef TARGET_NR_umount2 -{ TARGET_NR_umount2, "umount2" , NULL, print_umount2, NULL }, -#endif #ifdef TARGET_NR_uname { TARGET_NR_uname, "uname" , "%s(%p)", NULL, NULL }, #endif From patchwork Sun May 19 20:36:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164536 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4802685ili; Sun, 19 May 2019 14:14:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqydysp60PqkBPsI6frCxYLQw4RG2nHpAVp9xEPe3G2va+Z2qGJvo0aNIzY9lm9M1O95MVb7 X-Received: by 2002:a17:906:7b58:: with SMTP id n24mr55657724ejo.224.1558300445863; Sun, 19 May 2019 14:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300445; cv=none; d=google.com; s=arc-20160816; b=K5qE3J07JCCBM4qemPvBfRJH9Mpr0JrbkvNg4p63RtD9sfdt6M/o8MYHEYXiypHH3H BRF9ZA9GictwsiQIfjDccK0dh/qhjCXcInJAT9CL7tGsSiysBskUrqxbhtCDeZr13Vp3 SygDTXtaSX0DM88BQS8idV3gf2wmku5GXvFPy4ekvUXzh+YwS5vVbur1iOhbNCC1L2va 8AH2FiHFkP/BC+jO3eqDulQq0g2uKkuY+dDZjP6DyAN2h5elUyNRb3dfSH3H7IzMawIa GSVCjtSxBgk+hN1M+wsk9tSzHmrGjOOQdMPMfFLX7aYA6/FKy7Nhv8VRpGtDfQGUJqFL rXMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+9S8A+10b/scYDuW511dsngcQtz7czOu50I+GmgaCmA=; b=pc3mogd5t2rh1SOGkHJjJDpd43Q8qDZhbqZtOKWv8HfWVNCHgZuTK31+lpgaSRKM4g 9evHqDe7HDdsxilMxeUXozJfB5yxs+pvfb07o0k5IIQx9BFFh0uOq5X8CBXy4Tz2eeQj pawt0oZxMCrpuMka8IL36TQWjceSnhrmzmWbC+bVOZcbweP7wdJxuUgOYMlK3zmnDj7K C+86KdRo4a8AD8msJESpKArz+/6mx1Ev3W0MFzutHs4SknpW7NckYNh41fiGTdvn0Kcj xyX2OW3yc/DerppHDVu7PoCam/vX9gvGZv0VvFNP1M8iTXTsWZ4Gtb2j8kxZZFjXk/9w c+mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YO4yH7DU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w31si1943515eda.349.2019.05.19.14.14.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YO4yH7DU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST88-0000db-P7 for patch@linaro.org; Sun, 19 May 2019 17:14:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZX-0003X5-9b for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZV-0004GD-Ej for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:19 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:36602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZS-00049v-MS for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:15 -0400 Received: by mail-pl1-x642.google.com with SMTP id d21so5723866plr.3 for ; Sun, 19 May 2019 13:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+9S8A+10b/scYDuW511dsngcQtz7czOu50I+GmgaCmA=; b=YO4yH7DU920V0heupxU9QywCSVUahP0gLIg7yLjjMPtbyThCfZU8jFR412OquWGB1o mWMCzJCXEGzqo2g5woL+FAc9Cqt9Y22wJKtEu6Sb3p8/Du+FwbQpOKHxowxmyH7ArVNm QIT3yYDNRJ1J3nB1MGdm9Jd55YAdAt6pnuXT/ZK63meevKYeEmKHXJf4WyObb34NRFoL V3/hUUX1HF7k2JjzRCiNk5fjxpl6gzFuPE7swOTOuUP6oFKwU0t7Vk9+S2j7LANRMWoa JaM6Flp4wSqrPZyCFNUpIfaixcUoP3gZGdunaU1PLQ8qzwdor49EOvJxI6O46vPhod4t jY6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+9S8A+10b/scYDuW511dsngcQtz7czOu50I+GmgaCmA=; b=tLCuBPSZitNurlMwOTzpkUzDe3QL71Z3K8nDgxiT068TkmFf9uXglheUkHJgmVf9ib dWCntov0p6vIoXKxiwfi0kzTaOtOx41oZMJF9jrJTegdH5XgIaUI3oXOwZgiZrFeIUdR j70aFs5D436DRenR9Szyiogxk/wdhuitl0fwKxoO2sJmA6+jFROWaBazR6F4EOLisxFa MS5OT6zBAo9CzTbCENSv800kpJhAJ274zusw0mbcTgyz6IFBPyult9qyYFxWZq12IWWw eJi6aaioDMxk4q4GhL/agxzk7FlW2H5G5vuOwOwpoutjBQVeSYx/IiDkvmsiyGVGg+Tt hvaw== X-Gm-Message-State: APjAAAU1f+W4rAWw0v6qjBDKwb0KziCGnCN5cDyOBwnWxj+wRD5IyO6B jd97q+FMExxXGtcEkFWBluv3YnQHpTU= X-Received: by 2002:a17:902:8b8a:: with SMTP id ay10mr63346806plb.74.1558298292191; Sun, 19 May 2019 13:38:12 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:45 -0700 Message-Id: <20190519203726.20729-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 33/74] linux-user: Split out stime X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 3 +++ linux-user/syscall-time.inc.c | 12 ++++++++++++ linux-user/syscall.c | 9 --------- linux-user/strace.list | 3 --- 4 files changed, 15 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 0d8da0c6d6..6ca82af397 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -152,6 +152,9 @@ SYSCALL_DEF(shmdt, ARG_PTR); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmget) SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #endif +#ifdef TARGET_NR_stime +SYSCALL_DEF(stime, ARG_PTR); +#endif #ifdef TARGET_NR_time SYSCALL_DEF(time, ARG_PTR); #endif diff --git a/linux-user/syscall-time.inc.c b/linux-user/syscall-time.inc.c index 14fec88e47..d1fb72bde0 100644 --- a/linux-user/syscall-time.inc.c +++ b/linux-user/syscall-time.inc.c @@ -16,6 +16,18 @@ * along with this program; if not, see . */ +#ifdef TARGET_NR_stime +SYSCALL_IMPL(stime) +{ + time_t host_time; + + if (get_user_sal(host_time, arg1)) { + return -TARGET_EFAULT; + } + return get_errno(stime(&host_time)); +} +#endif + #ifdef TARGET_NR_time SYSCALL_IMPL(time) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f3e03f535d..ae56ecbbc7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,15 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_stime /* not on alpha */ - case TARGET_NR_stime: - { - time_t host_time; - if (get_user_sal(host_time, arg1)) - return -TARGET_EFAULT; - return get_errno(stime(&host_time)); - } -#endif #ifdef TARGET_NR_alarm /* not on alpha */ case TARGET_NR_alarm: return alarm(arg1); diff --git a/linux-user/strace.list b/linux-user/strace.list index 973a4c9209..d0646b9424 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1254,9 +1254,6 @@ #ifdef TARGET_NR_statfs64 { TARGET_NR_statfs64, "statfs64" , NULL, print_statfs64, NULL }, #endif -#ifdef TARGET_NR_stime -{ TARGET_NR_stime, "stime" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_streams1 { TARGET_NR_streams1, "streams1" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164526 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4797112ili; Sun, 19 May 2019 14:06:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqw33Ul7EpZ8z0DePdrfQRzxIsBpe0sYyEebdZKYiF5DJIDusS57fWx4G+9aSViAcr6QC6sP X-Received: by 2002:a17:906:1b57:: with SMTP id p23mr40819256ejg.24.1558299994248; Sun, 19 May 2019 14:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299994; cv=none; d=google.com; s=arc-20160816; b=p1bpHO1dn0Ln2HJ+zi7Yc6SGKLseDyao4i+mXDDuENTFdiBmpkWLCanS5eYA5FB8So 4CbB7frpQufgntd2E90HPm2m6YKlxxa8QecK5q89NH6MBWF5CZPA7QLvehvIJxrPwKt8 pxW+HuXG8zgaZnMvpjO7mdRePPUY8QcGcPWPv01tg7jZkbTYEw8NX6bws8E9ra4hSPAW 5lisYgoS6Zs/GQTt+l1PzROptadPbMeciqXG6PnGMVvIwU++D2dEPSKqA2Om8zcECoyC lhgGqs+fxSex6459wt82/7qHoBx5JpvXIsIz5PzHQ8A4MP7tyHQcgZBDnZ4dVR6Fl4tV Tu3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zGbVnBZ7x7Ulj+gsvlvNaeMFujeF8l5vm6cHIrbAA7c=; b=OQtSvXGCsiaD8uQGPFWt356YXD+QJGMrtgXY0ED3EiQXMMLZfwp0G5svc5Zkd+Bsb+ 19VymCoouqN+d2YCT3ntQlb7DzRbzp/yxOa56FMznZr81fVOxihd8Upz9UwsIETcCa3J 9Rx1N0PF0VeGC8PdfyMSQpTZjOlHTh3OrMfoTcaRe6034PnehmKmnI3Wmc9IPvPh/O5/ wfwykPaj6OQ/nJcRUHLZGfSrhRrOcRByxcrYc2J2SYj20v5Kd6lVbWsv2UpkE5hGPB1c aUQhTuI6T1DSXnoDqqMzmCGYdlmJBfWFL6i50tbgLrHflSMKaP1RU/EAFzsDXbrZESg+ l22A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=u4vBdPKi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m35si1157015edd.142.2019.05.19.14.06.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:06:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=u4vBdPKi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST0r-0001wa-1x for patch@linaro.org; Sun, 19 May 2019 17:06:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZb-0003b4-33 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZX-0004I8-9k for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:21 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34960) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZT-0004BC-Ho for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:17 -0400 Received: by mail-pf1-x441.google.com with SMTP id t87so6175238pfa.2 for ; Sun, 19 May 2019 13:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zGbVnBZ7x7Ulj+gsvlvNaeMFujeF8l5vm6cHIrbAA7c=; b=u4vBdPKixyBIqFlT8YlHC5VIlOngyb5q7cjyC+o8gfIuqzEG8w2crdWj/NDd3DRc+M 6ng+lrb0c1+8G+UaVeWUjmF85CB2VEF33yuSUKX17+VOaPEC0c6hThwZF9Qk2b7Bs7bn eVXY9iBg3685j6UGcpSU/KzYQweyjjdW4DP9J8hXhxyuJyTuFueMvUgt6zt1mNHg01Eo 08EQgG4nO/6hqBZP/AOvV4cUfCC4Ar3b6w6KAOyFxOQ3Coj7KjrXUa1v7pPPbFAuMcvE 7Vsx/dRxl9RMs3bSutzkMN8fFWWPYHjVjNjXhim7DwgfLeAPm/TIPUPlHUeK6mrrMDHV MJFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zGbVnBZ7x7Ulj+gsvlvNaeMFujeF8l5vm6cHIrbAA7c=; b=GXwdLJ7tmH9UUdim/9sB0PNv8DJe6oeYHeOxo9a30zF2i0YkGIF+8qy/CXa1Ky7OdK zKbk+gwrmw3SeavcnjYS3wGTIshZLeZGFd7pHoPJ5pauTOJLMNCU7cx1498Ih036PJsT yB7E70VyDNsKIWYCb/5iLA1vh2zCftNV/i0KKU7UeOeuwXym4AK1G7IPBDiYIQdxSPZw yNVBhboUu87NjToSioGrAAbS2ShMQG9JMVXUYHrjWET8jSnxOKTfjzgYig42RZNcD+R6 BvE9kzElIrxJHBOJjO3AUqt7uPQo4xlAXD70PyfYt/wXrnyMgtBjHQknSuYmTCqWqLp+ TDFA== X-Gm-Message-State: APjAAAU3tU/RJMSgs7m1bCBFKgW6xvwP+2FGjG6amX09F56c92y4ct7d Hq/UXPaCOag36r+4yyzUkWlf0Hy3F7I= X-Received: by 2002:a63:6ac1:: with SMTP id f184mr72583935pgc.25.1558298293401; Sun, 19 May 2019 13:38:13 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:46 -0700 Message-Id: <20190519203726.20729-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 34/74] linux-user: Split out alarm, pause X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++++ linux-user/syscall-sig.inc.c | 36 ++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 12 +----------- linux-user/strace.list | 6 ------ 4 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 linux-user/syscall-sig.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 6ca82af397..9d0dd7457b 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -16,6 +16,9 @@ * along with this program; if not, see . */ +#ifdef TARGET_NR_alarm +SYSCALL_DEF(alarm, ARG_DEC); +#endif SYSCALL_DEF_FULL(brk, .impl = impl_brk, .print_ret = print_syscall_ptr_ret, .arg_type = { ARG_PTR }); @@ -106,6 +109,9 @@ SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif SYSCALL_DEF(openat, ARG_ATDIRFD, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); SYSCALL_DEF(open_by_handle_at, ARG_DEC, ARG_PTR, ARG_OPENFLAG); +#ifdef TARGET_NR_pause +SYSCALL_DEF(pause); +#endif SYSCALL_DEF_FULL(pread64, .impl = impl_pread64, .args = args_pread64_pwrite64, .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c new file mode 100644 index 0000000000..f4e43eb00e --- /dev/null +++ b/linux-user/syscall-sig.inc.c @@ -0,0 +1,36 @@ +/* + * Linux signal related syscalls + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifdef TARGET_NR_alarm +SYSCALL_IMPL(alarm) +{ + return alarm(arg1); +} +#endif + +#ifdef TARGET_NR_pause +SYSCALL_IMPL(pause) +{ + if (!block_signals()) { + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + sigsuspend(&ts->signal_mask); + } + return -TARGET_EINTR; +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ae56ecbbc7..96e77ea38f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,17 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_alarm /* not on alpha */ - case TARGET_NR_alarm: - return alarm(arg1); -#endif -#ifdef TARGET_NR_pause /* not on alpha */ - case TARGET_NR_pause: - if (!block_signals()) { - sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); - } - return -TARGET_EINTR; -#endif #ifdef TARGET_NR_utime case TARGET_NR_utime: { @@ -9224,6 +9213,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #include "syscall-ipc.inc.c" #include "syscall-mem.inc.c" #include "syscall-proc.inc.c" +#include "syscall-sig.inc.c" #include "syscall-time.inc.c" #undef SYSCALL_IMPL diff --git a/linux-user/strace.list b/linux-user/strace.list index d0646b9424..2a65457c76 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -25,9 +25,6 @@ #ifdef TARGET_NR_afs_syscall { TARGET_NR_afs_syscall, "afs_syscall" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_alarm -{ TARGET_NR_alarm, "alarm" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_aplib { TARGET_NR_aplib, "aplib" , NULL, NULL, NULL }, #endif @@ -872,9 +869,6 @@ #ifdef TARGET_NR_osf_waitid { TARGET_NR_osf_waitid, "osf_waitid" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pause -{ TARGET_NR_pause, "pause" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_pciconfig_iobase { TARGET_NR_pciconfig_iobase, "pciconfig_iobase" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164516 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4790018ili; Sun, 19 May 2019 13:57:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEk8DlIODulN+5A58bClXPoD9jylktl8Mp9+QZU65Py00bEHokeiQoBmHNGSrC3XXg+j1g X-Received: by 2002:a50:95b0:: with SMTP id w45mr71953723eda.221.1558299461651; Sun, 19 May 2019 13:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299461; cv=none; d=google.com; s=arc-20160816; b=0A8YVKcLUD90se9D3WyI7MNSQm3GGAubciRBK6lx21qcHKC/rxy6RG2EoCwwFDP0zW 8luAmQO6460yl73OB8x7EbK3wkb23N8ibWnLdI6BZAP85ekNGcUeksst3ZayWK45uT2y cSLZWZiuqXKUzmeZSWlcXDZjsYcSZm6qkE5R7IT+0kTY0aMXNjSM3Wc7pjl56jAjtyr+ b2ftszGPr0TCIA3fLXRhdYyC7WzzkqyW2gipBo9eQUZfkmiQi54aX2UsNwGeO8kKpkFb QDUbQ3SiOBwuqfn6yk4Ie3h8t+tkLhhwFLaBhOj5OurdlI5tafLLkABEHh1NQ3N+vz8k TSTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=sa+0LXisYlSy7hSoDzn8UpDJzstJJhbCNrudoztrV7E=; b=xrwUl27MzLJ09Un0f0uavbWREQJmKh75j7Dq4PODLy5WY7e66DshwSGLbNolO5LNC9 fH2lF/mnOgRj8dKwCI6oPez79IhApJqgdsKp+gxGi8yDXyOq8HLCbN2F626SZXB+v1UE O42g5GycEBkzBFSrToNgzYpNdCFJVAw9wrrrhhESnTsc05JLA+8SJ3HB1tE1E44+5vCQ yZimyTm7hgqdg/dr9jHJambxFTRqaOffk/7THw+JXCWAg6bMI/vASLQq5kiiZWOUz2m2 h2zk9Walsiqpakv3CngIRdjcehkXE1yXt6MumwRaGntGkhRvWcuV60HvhCAR44s0ZOPS QZjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="LEkc0h/Q"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y5si1176656edd.371.2019.05.19.13.57.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:57:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="LEkc0h/Q"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSsG-0002aC-EU for patch@linaro.org; Sun, 19 May 2019 16:57:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZc-0003cV-CZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZX-0004IY-Cv for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:23 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:44713) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZV-0004DQ-EZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:19 -0400 Received: by mail-pg1-x543.google.com with SMTP id z16so5723961pgv.11 for ; Sun, 19 May 2019 13:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sa+0LXisYlSy7hSoDzn8UpDJzstJJhbCNrudoztrV7E=; b=LEkc0h/QBHXlunyBD5L1PGRREg/PpgacaQCnfm6Pb2aEp74rXBRynD4UHPCxhSyEbB Dp87VmOwvYQ5mAT2BiRevBudd7xG8a0TKIQje/zopsn9ujWGqV8tHZ2+/X1GsFcSVmcT gDeAzwCNLxrqsDnD01gMKYTTwSGtvX9vTwvzrZ+fktzTY2SC8EoPLehdwdu6O7RDr7x3 4ywgsAHCfjSpZn096jVLVB6aXwG8Mw3744d6ATUjXHSH92t3Liip+DkjhNMeP/ub62NF E0X3NiyUr3MDLTiuzKroE2qTlDFqrO3r9Wt8pezLMidFjGkIgcDNtw/6++Uax30FvRf9 QZNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sa+0LXisYlSy7hSoDzn8UpDJzstJJhbCNrudoztrV7E=; b=SRAHsCASa5RiuaqYmfeZ02zaT/8tX9uK+5XrzX6o5i5cwSJPx7T4Pe44ppVlU1H1F6 eo9TsX+f2FkpObhS78JIAFOu/e2dXq4NyBZO23nsUQjoEETGgj3SdNTOivQQday4PvC6 gxpoQ5dMidBeUtJ2zUIyOV+f4SMTm6+nkAlyjrqJTggpXCbbtYKFvj5WGumThPIksod/ hU994HHMoce8bmnPvkE74AXGUnv48ya593q7lHBPyqGsFLdeOCnVpTRiAL/YftOfzRnh vkcvlzZ0A4Ko9b2UXI99I1k5Ft9rKNWJqqAp9Q5+Fnxl9XJnT3+XpSDNB8Ks4cKneDRR aP7g== X-Gm-Message-State: APjAAAXw5OV+7gQHtnmcu2YgsyZJkEofOiuG2IJl7yVnQR/RPkJFahil pRpcIKmyVenzXEEtVaGwzzp+/aEM8Q4= X-Received: by 2002:a65:5cca:: with SMTP id b10mr71647708pgt.444.1558298294442; Sun, 19 May 2019 13:38:14 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:47 -0700 Message-Id: <20190519203726.20729-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH v7 35/74] linux-user: Split out utime, utimes, futimesat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 9 ++++ linux-user/strace.c | 41 --------------- linux-user/syscall-file.inc.c | 95 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 63 ----------------------- linux-user/strace.list | 9 ---- 5 files changed, 104 insertions(+), 113 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 9d0dd7457b..2767e335d8 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -36,6 +36,9 @@ SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); SYSCALL_DEF(fchmod, ARG_DEC, ARG_MODEFLAG); SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); +#ifdef TARGET_NR_futimesat +SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR); +#endif #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif @@ -172,6 +175,12 @@ SYSCALL_DEF(umount2, ARG_STR, ARG_UMOUNTFLAG); SYSCALL_DEF(unlink, ARG_STR); #endif SYSCALL_DEF(unlinkat, ARG_ATDIRFD, ARG_STR, ARG_UNLINKATFLAG); +#ifdef TARGET_NR_utime +SYSCALL_DEF(utime, ARG_STR, ARG_PTR); +#endif +#ifdef TARGET_NR_utimes +SYSCALL_DEF(utimes, ARG_STR, ARG_PTR); +#endif #ifdef TARGET_NR_vfork /* Emulate vfork() with fork(). */ SYSCALL_DEF_FULL(vfork, .impl = impl_fork); diff --git a/linux-user/strace.c b/linux-user/strace.c index 278d235ae6..3a7a5c30ec 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1296,21 +1296,6 @@ print_fcntl(const struct syscallname *name, #endif -#ifdef TARGET_NR_futimesat -static void -print_futimesat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_timeval(arg2, 0); - print_timeval(arg2 + sizeof (struct target_timeval), 1); - print_syscall_epilogue(name); -} -#endif - #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, @@ -2015,32 +2000,6 @@ print_symlinkat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_utime -static void -print_utime(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_pointer(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_utimes -static void -print_utimes(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_pointer(arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_utimensat static void print_utimensat(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 345b4cb421..42e5cd2dc1 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -84,6 +84,38 @@ SYSCALL_IMPL(fchmodat) return do_fchmodat(arg1, arg2, arg3); } +#ifdef TARGET_NR_futimesat +SYSCALL_IMPL(futimesat) +{ + int dirfd = arg1; + abi_ulong target_path = arg2; + abi_ulong target_tv = arg3; + struct timeval *tvp, tv[2]; + char *p; + abi_long ret; + + if (target_tv) { + if (copy_from_user_timeval(&tv[0], target_tv) + || copy_from_user_timeval(&tv[1], + target_tv + + sizeof(struct target_timeval))) { + return -TARGET_EFAULT; + } + tvp = tv; + } else { + tvp = NULL; + } + + p = lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(futimesat(dirfd, path(p), tvp)); + unlock_user(p, target_path, 0); + return ret; +} +#endif + static abi_long do_linkat(int olddirfd, abi_ulong target_oldpath, int newdirfd, abi_ulong target_newpath, int flags) @@ -873,6 +905,69 @@ SYSCALL_IMPL(unlinkat) return do_unlinkat(arg1, arg2, arg3); } +#ifdef TARGET_NR_utime +SYSCALL_IMPL(utime) +{ + abi_ulong target_path = arg1; + abi_ulong target_times = arg2; + struct utimbuf tbuf, *host_tbuf; + struct target_utimbuf *target_tbuf; + char *p; + abi_long ret; + + if (target_times) { + if (!lock_user_struct(VERIFY_READ, target_tbuf, target_times, 1)) { + return -TARGET_EFAULT; + } + tbuf.actime = tswapal(target_tbuf->actime); + tbuf.modtime = tswapal(target_tbuf->modtime); + unlock_user_struct(target_tbuf, arg2, 0); + host_tbuf = &tbuf; + } else { + host_tbuf = NULL; + } + + p = lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utime(p, host_tbuf)); + unlock_user(p, target_path, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_utimes +SYSCALL_IMPL(utimes) +{ + abi_ulong target_path = arg1; + abi_ulong target_tv = arg2; + struct timeval *tvp, tv[2]; + char *p; + abi_long ret; + + if (target_tv) { + if (copy_from_user_timeval(&tv[0], target_tv) + || copy_from_user_timeval(&tv[1], + target_tv + + sizeof(struct target_timeval))) { + return -TARGET_EFAULT; + } + tvp = tv; + } else { + tvp = NULL; + } + + p = lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utimes(p, tvp)); + unlock_user(p, target_path, 0); + return ret; +} +#endif + SYSCALL_IMPL(write) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 96e77ea38f..f66acbf27c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,69 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_utime - case TARGET_NR_utime: - { - struct utimbuf tbuf, *host_tbuf; - struct target_utimbuf *target_tbuf; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) - return -TARGET_EFAULT; - tbuf.actime = tswapal(target_tbuf->actime); - tbuf.modtime = tswapal(target_tbuf->modtime); - unlock_user_struct(target_tbuf, arg2, 0); - host_tbuf = &tbuf; - } else { - host_tbuf = NULL; - } - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(utime(p, host_tbuf)); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#ifdef TARGET_NR_utimes - case TARGET_NR_utimes: - { - struct timeval *tvp, tv[2]; - if (arg2) { - if (copy_from_user_timeval(&tv[0], arg2) - || copy_from_user_timeval(&tv[1], - arg2 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - tvp = tv; - } else { - tvp = NULL; - } - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(utimes(p, tvp)); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_futimesat) - case TARGET_NR_futimesat: - { - struct timeval *tvp, tv[2]; - if (arg3) { - if (copy_from_user_timeval(&tv[0], arg3) - || copy_from_user_timeval(&tv[1], - arg3 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - tvp = tv; - } else { - tvp = NULL; - } - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(futimesat(arg1, path(p), tvp)); - unlock_user(p, arg2, 0); - } - return ret; -#endif #ifdef TARGET_NR_access case TARGET_NR_access: if (!(p = lock_user_string(arg1))) { diff --git a/linux-user/strace.list b/linux-user/strace.list index 2a65457c76..3f92224b55 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -226,9 +226,6 @@ #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL }, #endif -#ifdef TARGET_NR_futimesat -{ TARGET_NR_futimesat, "futimesat" , NULL, print_futimesat, NULL }, -#endif #ifdef TARGET_NR_getcpu { TARGET_NR_getcpu, "getcpu" , "%s(%p,%d)", NULL, NULL }, #endif @@ -1392,12 +1389,6 @@ #ifdef TARGET_NR_ustat { TARGET_NR_ustat, "ustat" , "%s(%#x,%p)", NULL, NULL }, #endif -#ifdef TARGET_NR_utime -{ TARGET_NR_utime, "utime" , NULL, print_utime, NULL }, -#endif -#ifdef TARGET_NR_utimes -{ TARGET_NR_utimes, "utimes" , NULL, print_utimes, NULL }, -#endif #ifdef TARGET_NR_utrap_install { TARGET_NR_utrap_install, "utrap_install" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164531 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4800873ili; Sun, 19 May 2019 14:11:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqztGHNYCCXn9Oi+gxD9/pLmY6JCQgmX2bZ7YTaam4R27UodMng2VKJbiPWsxLTwh97PH4Uk X-Received: by 2002:a17:906:9145:: with SMTP id y5mr11557725ejw.206.1558300298121; Sun, 19 May 2019 14:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300298; cv=none; d=google.com; s=arc-20160816; b=YW59EThK22ONqbUH7ARnIWkZFCJlguCVjctDurO68qr5f4eE3mehQvUtHXILA/tQtA y/6mixn4UOf7WuTjER39rSNLHHxVxrOJrmTiQn4//diyVLx1BA5XE600oDsAOMT4YMBZ bJJ78OcsVbqc5Rts7T0xqQK4S6saz0pS+Y9WD19TWjtvbDaQQT+N1mRqkai89HCfiSte bwzsdCJp5fIWJo/kYSF82SLv0451AyS6QYRHX6zagGMFiRn46QAaYHBpJW2T39vKSMoP KiAfTwbTxXf4bSiTfmSBOz37Q0m5YLwHfDTXqaEcP6KUa3jAPyjlyPDS2PdHRB+HxnkU oV6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=RSrci5Zj8IDwkVKyxa0LFWqGkMUNuHHhltz/gMocb2g=; b=k2Qbdc/iXv4vySIF/XgFTQ9ulalGFg7ZMGTwk4B6vDVLZGhKQXRpaVk5UME9mI6nyJ vPSeo5aKnAvJYMoyc1z5tHzppplD9n3dOrK2mNVldtndhMSzxuA0KxniB+5lISYA4WPI oc8jjqZKbkzvBFCyJIRbeRaeZ58DpcLkSBkYJsXQvshCUTCm1tI0STcNjQdgZdIsC3I/ 7AAePSHdvVXqnJ5f/PnG91Uy4S3mQYDw6dNMQ2vymuyv+NbqTjSo47M71M6xXcUWLYpG Pgl1izljvcXicb8+S8EypvjlqY0m0xvMOHfD5l+p/eR8zLt8EcnbQ9xXv+D4vWD+1BSh 56bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jDdO0zc2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z18si1516721ejx.36.2019.05.19.14.11.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:11:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jDdO0zc2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST5l-0007HG-0Y for patch@linaro.org; Sun, 19 May 2019 17:11:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZc-0003cU-CZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZZ-0004Kt-92 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:23 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZX-0004F6-9f for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:20 -0400 Received: by mail-pl1-x641.google.com with SMTP id a5so5687657pls.12 for ; Sun, 19 May 2019 13:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RSrci5Zj8IDwkVKyxa0LFWqGkMUNuHHhltz/gMocb2g=; b=jDdO0zc2XOPVrgHNM7q3palvQ30e3PDzRDXcePaLqRdKym7cLd/LjwZG688coSBiDH uhPpWTjODsh5mhOWQBcN4VnB+PnRHeE/zGifzcRVu0yIOk5t2DAsX6UNFUtKqWVnBI0e 1umbfEqqJnQ1FdgLO/wH3NC60ltA6G2HX3yeHsdQoDq3vjgriqgHJIG9DsE5istdSWKg KvT2nm0jxrN7+OKsHkN+uzIn6IEivAqeS1imme5WHtTaM18gkB+QUDF/4t6RzP2J814f l30i1GJRYTzQPvmOW12bA2y8C9tn953vOADKHtdurdxHBqDE2FSsTn4J0AWKzOagBDu5 OGnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RSrci5Zj8IDwkVKyxa0LFWqGkMUNuHHhltz/gMocb2g=; b=S8qtEUhfE0CyhO+ja31G+a9sHtc1wkgjQaEjae/Gf6WvBXAufMhoj2S6SkuksvfgLz j95DNW6ALLXy0M0h8gWI+fnz2ic0zMvT6pkxCEW0W++JSRKFbLnX6i41I9BHnuCdDEz1 xE+XvpQS0bqEs5fjKjQrDxM3mIUV2M9wTHPMEkUrp02jZowciU+zGIq0U5bkFrd4CQ07 Jr5rDnhO84Tqmhd8LZhzRBGEfGWTTqqC+YAtJ0iUCLG73c685HTY4BHDGWMRSezOvX2w cAMGMxXcRRGo73iBta0R1sO+2FK63EF42Pfo5IFOgmgJJ8SBkGwB3B7ThJHtPK8zapjJ yaBQ== X-Gm-Message-State: APjAAAUSiNeMLCWCnpuHzqdQE5VCEf1m+RLXDzsqASNV60vbKhEcQFgw fdPY1jexUkR9aTJhXDI7OgF9tYQpmco= X-Received: by 2002:a17:902:4e:: with SMTP id 72mr19186217pla.80.1558298295592; Sun, 19 May 2019 13:38:15 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:48 -0700 Message-Id: <20190519203726.20729-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 36/74] linux-user: Split out access, faccessat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that faccessat is unconditionally available. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall.h | 1 + linux-user/strace.c | 33 ++++----------------------------- linux-user/syscall-file.inc.c | 25 +++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 6 ------ 6 files changed, 34 insertions(+), 53 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 2767e335d8..39e3ae3c21 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -16,6 +16,9 @@ * along with this program; if not, see . */ +#ifdef TARGET_NR_access +SYSCALL_DEF(access, ARG_STR, ARG_ACCESSFLAG); +#endif #ifdef TARGET_NR_alarm SYSCALL_DEF(alarm, ARG_DEC); #endif @@ -34,6 +37,7 @@ SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG); SYSCALL_DEF(exit, ARG_DEC); SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); +SYSCALL_DEF(faccessat, ARG_ATDIRFD, ARG_STR, ARG_ACCESSFLAG); SYSCALL_DEF(fchmod, ARG_DEC, ARG_MODEFLAG); SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); #ifdef TARGET_NR_futimesat diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 3c936b648a..84a52b2d9a 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -57,6 +57,7 @@ typedef enum { /* These print as sets of flags. */ ARG_ATDIRFD, + ARG_ACCESSFLAG, ARG_ATFLAG, ARG_CLONEFLAG, ARG_MMAPFLAG, diff --git a/linux-user/strace.c b/linux-user/strace.c index 3a7a5c30ec..c42abc2f08 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -634,7 +634,7 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) gemu_log("\n"); } -UNUSED static struct flags access_flags[] = { +static struct flags const access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), FLAG_GENERIC(W_OK), @@ -1114,19 +1114,6 @@ print_accept(const struct syscallname *name, } #endif -#ifdef TARGET_NR_access -static void -print_access(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_flags(access_flags, arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_chroot static void print_chroot(const struct syscallname *name, @@ -1165,21 +1152,6 @@ print_execv(const struct syscallname *name, } #endif -#ifdef TARGET_NR_faccessat -static void -print_faccessat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_flags(access_flags, arg2, 0); - print_flags(at_file_flags, arg3, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_fchownat static void print_fchownat(const struct syscallname *name, @@ -2218,6 +2190,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_ATDIRFD: len = add_atdirfd(b, rest, arg); break; + case ARG_ACCESSFLAG: + len = add_flags(b, rest, access_flags, arg, false); + break; case ARG_ATFLAG: len = add_flags(b, rest, at_file_flags, arg, false); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 42e5cd2dc1..5e276d13bc 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -16,6 +16,26 @@ * along with this program; if not, see . */ +static abi_long do_faccessat(int dirfd, abi_ulong target_path, int mode) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(faccessat(dirfd, p, mode, 0)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_access +SYSCALL_IMPL(access) +{ + return do_faccessat(AT_FDCWD, arg1, arg2); +} +#endif + SYSCALL_IMPL(chdir) { abi_ulong target_path = arg1; @@ -74,6 +94,11 @@ SYSCALL_IMPL(creat) } #endif +SYSCALL_IMPL(faccessat) +{ + return do_faccessat(arg1, arg2, arg3); +} + SYSCALL_IMPL(fchmod) { return get_errno(fchmod(arg1, arg2)); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f66acbf27c..b5ade974a7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,24 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_access - case TARGET_NR_access: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(access(path(p), arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) - case TARGET_NR_faccessat: - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(faccessat(arg1, p, arg3, 0)); - unlock_user(p, arg2, 0); - return ret; -#endif #ifdef TARGET_NR_nice /* not on alpha */ case TARGET_NR_nice: return get_errno(nice(arg1)); diff --git a/linux-user/strace.list b/linux-user/strace.list index 3f92224b55..80b9220e89 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -9,9 +9,6 @@ #ifdef TARGET_NR_accept4 { TARGET_NR_accept4, "accept4" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_access -{ TARGET_NR_access, "access" , NULL, print_access, NULL }, -#endif #ifdef TARGET_NR_acct { TARGET_NR_acct, "acct" , NULL, NULL, NULL }, #endif @@ -142,9 +139,6 @@ #ifdef TARGET_NR_exit_group { TARGET_NR_exit_group, "exit_group" , "%s(%d)\n", NULL, NULL }, #endif -#ifdef TARGET_NR_faccessat -{ TARGET_NR_faccessat, "faccessat" , NULL, print_faccessat, NULL }, -#endif #ifdef TARGET_NR_fadvise64 { TARGET_NR_fadvise64, "fadvise64" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164523 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4796399ili; Sun, 19 May 2019 14:05:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkFQnyU23gWoL356OfO5ZRmg64AZwwcwYd/Hy16sA6DsSLHq46TRgJudHz0LlkGTVbKSM/ X-Received: by 2002:a50:aef6:: with SMTP id f51mr71252211edd.225.1558299949204; Sun, 19 May 2019 14:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299949; cv=none; d=google.com; s=arc-20160816; b=M7Foo2jLVA421CC4cUVv8dLGLvZjRwkao9sFtJEHubtd8Hp5idfmoQSmNEC8cQFVmV /Un9drfukUEfrxPXFfS6doYRwre4gN0jSy5LVTUh4+V6PxEQwrkLiaKCAVxCZIrsF2YH Z/dBcbcY03bSnMzUrY16fzBPJtqKH/MFtjhYwx2TZEMlX+PUbm6wtC4rB23FS4isoe6G Ryg9w1uneSCaOTaLwkHA2dfc5XTiEFS19jZsMi3bRBMISr1GRbsrR0T/7Nz9QA/JB6cZ YW24EEjJdeGL348zMrgZ68efKFFyLYCZGJ8VZeNvqrmyWtjpodGUQowzOGo7OexCC0/p KazA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Fe7E5QRFjEHLy1d+AjizcpNZcZxNIdj6eQS1u8xiwio=; b=aA+zTR1ZFUHIs7+brIliqsmAMEveIhjTrFy2Y2C9Bzq3jUGuWirU1LO3csgjUD9RL5 wPBIPK2kLrSOvn2ccgE8aX8zYLL0b93frZkqE0rECyKPxcNQfEEq8nKlUSw03i2nq35v JXSK79U84QhtaB4M3qLEO6PgPnV9d0GCqbaB8qy65i4o+C6mLeA1QeUZ2p4Nzep/shGO TjgyBhbXAzd4xAqG//MDEfpwVhjWqdRizQH0UMXDSe0pqQwCLE41ZQsxNjidWOi5eYwn X3Uij91gbXj0o9xNNOLkWw1rZsuoAkrDAu8SA4IPeYxntfci6LCI9FVxOEay/dOWsDAy TeIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JxCQ5vv6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x26si9713359edm.106.2019.05.19.14.05.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:05:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JxCQ5vv6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST08-0001BC-5N for patch@linaro.org; Sun, 19 May 2019 17:05:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZc-0003cT-CP for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZZ-0004Ky-9G for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:23 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:46928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZX-0004GK-Aj for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:20 -0400 Received: by mail-pl1-x642.google.com with SMTP id r18so5698795pls.13 for ; Sun, 19 May 2019 13:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fe7E5QRFjEHLy1d+AjizcpNZcZxNIdj6eQS1u8xiwio=; b=JxCQ5vv6JneusoOCcHuWwJwAtEJ75qJqIWbtzgPlH9Eh4Ffz5r0hXmE2pKPnd1vDGO DnE1Y4qjWIDJZ8vCdmyDiA3taIhIG8YaixMXkqx94v9TwUJVprG33zKRgIKCOeDkhIVq X+Om79IvXcBrEkf43Eyj/ox8oOoQ0eJG1sSfX4z3L9YJyba1Bfu/+pT+kI67x2Gi3WOf 0rZqs8K8wPtvEESqtoa9iS4lxH1wRr+gjO/p6pfJ7xn7kvoEBpdSIGaFq/wO4WNiFKr1 TBmEIjUv722dVTlClRhpgm+1eETvmK0wo2o28jxmd+PL4DCEnVeXGj/JRVs6OIsgd9FP sN2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Fe7E5QRFjEHLy1d+AjizcpNZcZxNIdj6eQS1u8xiwio=; b=fGEmgQkroXS2M/3578ctTTv/YOQBGtGxkrsjiP5inkKmEiCOuBeeVYd/UhbsRTTKSK GinBazdhLFnWpgc1HCylkEE4XzoBecLbElu5FgrrWGN/LK0qgxZMBLt3bQ+wGuZyrZVz 2vITs8lTD9ZEuo9A2rq3kGHbApCZhM+K/NU8LhT7uJOY0LCf5W6CEIfU9bjNhGiw/EX/ BIb73JrzzX16HHuKCz4ms18apiBO5oi6o/AHDaU66n6UW+EimVUGqwP4q+/R5slvssRX hgM2WPd4Gn/0OKEKVox5Nk47wIidaeq0pfl/Fh6wRZQXoI/kMkSZCp6DULNN0E+MCZfS s4Pw== X-Gm-Message-State: APjAAAXMhovQ7LtsvNT3+tgMZaf013Y8d1EwoCk9CeqBhqJV0z4JuY33 N1hfUF6jfkCiUpw/Fcrla5Be6EkrE6k= X-Received: by 2002:a17:902:bd46:: with SMTP id b6mr10558681plx.173.1558298296924; Sun, 19 May 2019 13:38:16 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:49 -0700 Message-Id: <20190519203726.20729-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 37/74] linux-user: Split out nice X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 3 +++ linux-user/syscall-proc.inc.c | 7 +++++++ linux-user/syscall.c | 4 ---- linux-user/strace.list | 3 --- 4 files changed, 10 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 39e3ae3c21..860754aaca 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -111,6 +111,9 @@ SYSCALL_DEF(munlockall); SYSCALL_DEF(munmap, ARG_PTR, ARG_DEC); SYSCALL_DEF(name_to_handle_at, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); +#ifdef TARGET_NR_nice +SYSCALL_DEF(nice, ARG_DEC); +#endif #ifdef TARGET_NR_open SYSCALL_DEF(open, ARG_STR, ARG_OPENFLAG, ARG_MODEFLAG); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 4d8d385b38..e29c2ede25 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -461,6 +461,13 @@ SYSCALL_IMPL(getxpid) } #endif +#ifdef TARGET_NR_nice +SYSCALL_IMPL(nice) +{ + return get_errno(nice(arg1)); +} +#endif + /* * Map host to target signal numbers for the wait family of syscalls. * Assume all other status bits are the same. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b5ade974a7..6d30e8ff2f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,10 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_nice /* not on alpha */ - case TARGET_NR_nice: - return get_errno(nice(arg1)); -#endif case TARGET_NR_sync: sync(); return 0; diff --git a/linux-user/strace.list b/linux-user/strace.list index 80b9220e89..3161546afc 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -527,9 +527,6 @@ #ifdef TARGET_NR_nfsservctl { TARGET_NR_nfsservctl, "nfsservctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_nice -{ TARGET_NR_nice, "nice" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_old_adjtimex { TARGET_NR_old_adjtimex, "old_adjtimex" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164519 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4792134ili; Sun, 19 May 2019 14:00:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOLZUwz/q96C722z1FZ1P9RoLEfzzRqUzDlHYnRnbJ5T7eqnuUSbrtvNBcWcuLQJOqMgW7 X-Received: by 2002:a50:9025:: with SMTP id b34mr71499864eda.145.1558299641507; Sun, 19 May 2019 14:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299641; cv=none; d=google.com; s=arc-20160816; b=uWPYr7PIjahMK1cjWHZoR9i1k0Zm8CpBNy+JbulEeQNrRLbQmSARs06PkVluez9suH ruTskYrZN1TZ5FUssMHZ70VfR9CL7MEYazkvzJhutjtVpSRAxw6TZLS7ZvDjx3emd1Sv 9b/2IR5EGHRuIRVqJhy3wb0Q1+KjP2M9XDv99FxpNd5k/n1MtL2l0xi7zB5j4Gt3howf tYglgFSfVCQkxUZCTkKB+I7Ys1funOLuIg1KrtEOG2mwrywenl553CWAd7Cv385fcPDq HLa4QlMAb2mgB3FNE3b7f6mywL2bbBwFaMbWrdw4B3aLtLwFFAxEwJ9HrHTQNxpLLjAU ptGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=trhc0Rc4LDpLHBX/8qxpTfKaIrV8kdNRhDojH/u1TVk=; b=0HbR3v18BJ4IR4ms2qPD0VFC8LGsVuITdhfHS8izkxHGFDZUjdxXbnSWpmk1WHNLwA Ay5KCYnEtpYIF2MRBBkEg7xq5a+Fi31cpYCNrMmVIY/gUXRfqj1p3WwpUMFSquEAfyN6 h4zO98kxTgBd/ufm0k1piCONU1DCdZ2SSmfOLW9YrZvMP6bGidBPtpZsTv5Zqd7IH0kY fRibRLclrD9MTaEURQd0nikEfQfX1+osRI1RMMOvllcuYRhK6TqjWGjz/e6WUGRkKpdC WD1ep7V5VR/UmIAi2Cb+1pCyCHBVNhyIPNC79Yh5nbZIdsxVzRVFIyocPRhnXwfwGyaj vo+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VcrrAraR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t45si11754027eda.235.2019.05.19.14.00.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:00:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VcrrAraR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSvA-00056s-FN for patch@linaro.org; Sun, 19 May 2019 17:00:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZe-0003eR-CE for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004P4-1T for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZZ-0004He-7N for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:23 -0400 Received: by mail-pf1-x441.google.com with SMTP id g3so6171662pfi.4 for ; Sun, 19 May 2019 13:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=trhc0Rc4LDpLHBX/8qxpTfKaIrV8kdNRhDojH/u1TVk=; b=VcrrAraR3P2FH/TyydTN4gf6E4HL1lu8TIAS/7Mfkdzh/z9NZK0sA3XGseQhRyAA49 Ey4Pr9FJa5//qsilaJ0hI2O7uNITkYxutxP3x2SIah5gCZuxQeBsr0ZWXFnd5eJNKrGQ takqHHTh/tdqUWu8L4TAusVtB3bUTNT89F1kOzFbAbSJWkJEv+/6kXlBoW/dLvpQDIz4 K7DUhFUwpgZpzFkOs/wzOchMC4wj+iytwdiEICeY/DiEJSrVDSkxdmnhJ/ebgXlR++wR zcARnZSYAJZNbN4sRfaRwgJGyExFOJGMJpytcTl75zpYahzn3bie6Gzicem/DfiUpgzS /KNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=trhc0Rc4LDpLHBX/8qxpTfKaIrV8kdNRhDojH/u1TVk=; b=nWfkZYs0OSfe2NJKuorfY/otK9SL56bQprnm8fwPwvmXvffPM8mhpRs2MoZuY882Bz zIZw/AI0EfcXESNGW7NTbaB+LM/sb68dnUHKZY+2kriwgj2Iwcc5VcSCYpJqS0ScEfWB /YtdFH5pMLo7Wxt4y28B58Y/5q1Ss24o/4U1Eb7WH/ghGXdHBEyKocJ3l2HmGpWZWPv+ WkzFb0durPic9Nwtvj7jaw5ZhtfRA4a8kNoj/+Jv7tMTwil/KZTO7hrODNGPWH990nUR uBd4JYde0PK2SHgrYw5WoXILBUb0t/tIZJX7UNXR+Ey+a8l6DeXAN4+8hrapNwtJajmH T/LQ== X-Gm-Message-State: APjAAAUaRoIo1OdXXGZzN0QrEMHiScVx5H0Zqck1ZjCsjYrIJHZpoC1H iSA1k29InSKAq5lOUM06lXsvwFmvl5g= X-Received: by 2002:a63:2124:: with SMTP id h36mr70764891pgh.186.1558298298098; Sun, 19 May 2019 13:38:18 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:50 -0700 Message-Id: <20190519203726.20729-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 38/74] linux-user: Split out sync, syncfs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that syncfs is universally available. If !CONFIG_SYNCFS, provide our own syscall replacement. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-file.inc.c | 11 +++++++++++ linux-user/syscall.c | 20 ++++++++++++-------- linux-user/strace.list | 6 ------ 4 files changed, 25 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 860754aaca..497fbdba66 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -171,6 +171,8 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #ifdef TARGET_NR_stime SYSCALL_DEF(stime, ARG_PTR); #endif +SYSCALL_DEF(sync); +SYSCALL_DEF(syncfs, ARG_DEC); #ifdef TARGET_NR_time SYSCALL_DEF(time, ARG_PTR); #endif diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 5e276d13bc..9f3cf7221a 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -873,6 +873,17 @@ SYSCALL_IMPL(readlinkat) } #endif +SYSCALL_IMPL(sync) +{ + sync(); + return 0; +} + +SYSCALL_IMPL(syncfs) +{ + return get_errno(syncfs(arg1)); +} + static abi_long do_umount2(abi_ulong target_path, int flags) { char *p = lock_user_string(target_path); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6d30e8ff2f..d612dade23 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -199,6 +199,15 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_gettid __NR_gettid _syscall0(int, sys_gettid) +/* + * These definitions produce an ENOSYS from the host kernel. + * Performing a bogus syscall is easier than boilerplating + * the replacement functions here in C. + */ +#ifndef __NR_syncfs +#define __NR_syncfs -1 +#endif + /* For the 64-bit guest on 32-bit host case we must emulate * getdents using getdents64, because otherwise the host * might hand us back more dirent records than we can fit @@ -254,11 +263,13 @@ _syscall3(int, ioprio_set, int, which, int, who, int, ioprio) #if defined(TARGET_NR_getrandom) && defined(__NR_getrandom) _syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags) #endif - #if defined(TARGET_NR_kcmp) && defined(__NR_kcmp) _syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type, unsigned long, idx1, unsigned long, idx2) #endif +#ifndef CONFIG_SYNCFS +_syscall1(int, syncfs, int, fd) +#endif static bitmask_transtbl fcntl_flags_tbl[] = { { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, @@ -5380,13 +5391,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_sync: - sync(); - return 0; -#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) - case TARGET_NR_syncfs: - return get_errno(syncfs(arg1)); -#endif case TARGET_NR_kill: return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); #ifdef TARGET_NR_rename diff --git a/linux-user/strace.list b/linux-user/strace.list index 3161546afc..749bdce638 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1260,12 +1260,6 @@ #ifdef TARGET_NR_symlinkat { TARGET_NR_symlinkat, "symlinkat", NULL, print_symlinkat, NULL }, #endif -#ifdef TARGET_NR_sync -{ TARGET_NR_sync, "sync" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_syncfs -{ TARGET_NR_syncfs, "syncfs" , "%s(%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_syscall { TARGET_NR_syscall, "syscall" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164546 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4807833ili; Sun, 19 May 2019 14:21:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHEJWvda8e4+LTctk+mrqthA4GjpdpPx/TnkGYG3UrvJEM/vZijSjL4rnAKWPWz3cgck8N X-Received: by 2002:a50:8e81:: with SMTP id w1mr71150078edw.271.1558300905421; Sun, 19 May 2019 14:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300905; cv=none; d=google.com; s=arc-20160816; b=UBvVX6zc4sU8C52VbuL/UK74OSIOHL7+j6F47IC6J0QCS7nM5ImnQ6yf+hqS7k1SwV ugw/uJC2QC/QN4041Gu6TGKwxpK78glFXiTD6c3N1/wGk3aGD/6wdKTEuN4aILSgxYRa L5Edc6t+tL+9r4b9xna0TnIViXzK8MSGSP9UNS5oF0Pi8pQ28/d/br1Db61lb3HhnSy0 VKtcuoEHBtX3XBpeZqNfseu1jJTxaoY2fWP75CJvebjDaBY1OWyKR7FAtQ7IoSutb7u0 Zr2UQy9JNaYT9WhlVsnWMMn36tTNGqW4t/guLX+F8Zqvik+l9T45X5xefIBneDpqABtL Am9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eI/OxnXRIKB57lBoz21sGaC914M6dhfbjsRtukHRXg0=; b=ecfo/nroQSRZw0g8erasCwRKRD1Nphjjf8TtX6+eobiIFDOMojAztZm+fiw+5rQUUq Ob7EpWs5hAeKsX5BnYmd/kDL+4twmYhANPYdvApzARwHAENWSbzZm2VJBcNHRkSI92HR fB3uwBlJV+bCa5BPpNBYyY6RF7/2BExIhQMP7PEOoo3rLb2Wc3rH+MTWHhIK8LXXrogC uRt4KqrRjl4m6KIJkoZ7yOAn31ZtKvidjdg00kT1PQXvU3Yak9M5hwyVOzLWhDfsefmN roAGyuf7EFYGhpXcjbWRC8yaAYgUTxF7bPsPf9nQyDg1hLdQGrtIwQivOxzCxF2BiIaB KHHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Fp+vjFA7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d13si1569869ejp.365.2019.05.19.14.21.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:21:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Fp+vjFA7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTFY-0007rJ-7c for patch@linaro.org; Sun, 19 May 2019 17:21:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZe-0003ej-TX for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004Pc-D0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:36604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZd-0004JI-22 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:25 -0400 Received: by mail-pl1-x644.google.com with SMTP id d21so5723921plr.3 for ; Sun, 19 May 2019 13:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eI/OxnXRIKB57lBoz21sGaC914M6dhfbjsRtukHRXg0=; b=Fp+vjFA70/upaz/6v2na2w+I8bC7wlOghToH3FGqz/d874uotH+AiOsNFA4+tHKtFV eoe5hEx4sHdWvma1nP8tbhUYVqb39Biyr/xVPd8NKBRXUb1Tw6EdV+AxPY4EPfTgVNYC 1mswB1X1rarKbQ9VLXR/0LW00Qfj1zVL95a0taHxPxAdzw3fHQxpIyhRFYPLzLD1cViq fp8MT9/W4cCReJbMkM47GB67FNYJemeG2v4Gu3mRehMlReFVqQa/aS2MEGBop/ONpGDl PCHhXn8lNClJqPKP7hzoE4/JUEP9dpGZ5/4EZZo+P31q35Hm5JZqyJbpCVj6Q/yXCXmg 9dGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eI/OxnXRIKB57lBoz21sGaC914M6dhfbjsRtukHRXg0=; b=d/Ho9aQNRJDA2RIAw/r/T/Swj0yWslp7FgGh7eIYy+/HfOpXadOvuVJ+2MhU2sStzO u37KBERPdW1a5/mFhuso9jFm5Cmok7z7a+2Y11qnP1VAcXel4Of8tKDGG7zrzohexs+s toBr07Ld28lGl03uUoRkWzCx/ZRAxBLEoTiUYtA4+24UWvL+Ky3nTXINHvObCgw5WsYL T2+ZtnR6Ihbn4c4uQr6haHErJJ0iF3AU8RUyo9zwo5xXcYWlXXxvLIG+QphogE9kMdwb LSsoTPxCrZNmIlLsob5J5yVTUJgm3DMA9qRAb/Z2zI9HLFTTbdoAo4mtVYchodhag8nj EfIA== X-Gm-Message-State: APjAAAXMxs8dqnf/hB2vgY5hluW31Twko5RZ3Lw+mTAVu2pwTK7Wjq9b YPRhOz81r7MvwQdhvN7ZDW/GUg5bz2s= X-Received: by 2002:a17:902:9691:: with SMTP id n17mr9590191plp.283.1558298299282; Sun, 19 May 2019 13:38:19 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:51 -0700 Message-Id: <20190519203726.20729-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v7 39/74] linux-user: Split out kill X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall.h | 7 +++- linux-user/strace.c | 76 ++++++++++++++++++------------------ linux-user/syscall-sig.inc.c | 5 +++ linux-user/syscall.c | 2 - linux-user/strace.list | 3 -- 6 files changed, 48 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 497fbdba66..c672b5ad99 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -58,6 +58,7 @@ SYSCALL_DEF(getxpid); #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif +SYSCALL_DEF(kill, ARG_DEC, ARG_SIGNAL); #ifdef TARGET_NR_link SYSCALL_DEF(link, ARG_STR, ARG_STR); #endif diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 84a52b2d9a..642fb6dccb 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -55,8 +55,12 @@ typedef enum { ARG_HEX, ARG_OCT, - /* These print as sets of flags. */ + /* These numbers are interpreted. */ ARG_ATDIRFD, + ARG_SIGNAL, + ARG_LSEEKWHENCE, + + /* These print as sets of flags. */ ARG_ACCESSFLAG, ARG_ATFLAG, ARG_CLONEFLAG, @@ -67,7 +71,6 @@ typedef enum { ARG_OPENFLAG, ARG_UMOUNTFLAG, ARG_UNLINKATFLAG, - ARG_LSEEKWHENCE, /* These are interpreted as pointers. */ ARG_PTR, diff --git a/linux-user/strace.c b/linux-user/strace.c index c42abc2f08..01a5c210fa 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -70,35 +70,43 @@ UNUSED static void print_socket_protocol(int domain, int type, int protocol); /* * Utility functions */ +static int +add_signal(char *buf, int size, int sig) +{ + static const char * const signals[] = { + [TARGET_SIGHUP] = "SIGHUP", + [TARGET_SIGINT] = "SIGINT", + [TARGET_SIGQUIT] = "SIGQUIT", + [TARGET_SIGILL] = "SIGILL", + [TARGET_SIGABRT] = "SIGABRT", + [TARGET_SIGFPE] = "SIGFPE", + [TARGET_SIGKILL] = "SIGKILL", + [TARGET_SIGSEGV] = "SIGSEGV", + [TARGET_SIGPIPE] = "SIGPIPE", + [TARGET_SIGALRM] = "SIGALRM", + [TARGET_SIGTERM] = "SIGTERM", + [TARGET_SIGUSR1] = "SIGUSR1", + [TARGET_SIGUSR2] = "SIGUSR2", + [TARGET_SIGCHLD] = "SIGCHLD", + [TARGET_SIGCONT] = "SIGCONT", + [TARGET_SIGSTOP] = "SIGSTOP", + [TARGET_SIGTTIN] = "SIGTTIN", + [TARGET_SIGTTOU] = "SIGTTOU", + }; + + if (sig >= 0 && sig < ARRAY_SIZE(signals) && signals[sig]) { + return snprintf(buf, size, "%s", signals[sig]); + } else { + return snprintf(buf, size, "%d", sig); + } +} + static void print_signal(abi_ulong arg, int last) { - const char *signal_name = NULL; - switch(arg) { - case TARGET_SIGHUP: signal_name = "SIGHUP"; break; - case TARGET_SIGINT: signal_name = "SIGINT"; break; - case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break; - case TARGET_SIGILL: signal_name = "SIGILL"; break; - case TARGET_SIGABRT: signal_name = "SIGABRT"; break; - case TARGET_SIGFPE: signal_name = "SIGFPE"; break; - case TARGET_SIGKILL: signal_name = "SIGKILL"; break; - case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break; - case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break; - case TARGET_SIGALRM: signal_name = "SIGALRM"; break; - case TARGET_SIGTERM: signal_name = "SIGTERM"; break; - case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break; - case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break; - case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break; - case TARGET_SIGCONT: signal_name = "SIGCONT"; break; - case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break; - case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break; - case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break; - } - if (signal_name == NULL) { - print_raw_param("%ld", arg, last); - return; - } - gemu_log("%s%s", signal_name, get_comma(last)); + char buf[16]; + add_signal(buf, sizeof(buf), arg); + gemu_log("%s%s", buf, get_comma(last)); } static void print_si_code(int arg) @@ -2044,19 +2052,6 @@ print_futex(const struct syscallname *name, } #endif -#ifdef TARGET_NR_kill -static void -print_kill(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_raw_param("%d", arg0, 0); - print_signal(arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_tkill static void print_tkill(const struct syscallname *name, @@ -2190,6 +2185,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_ATDIRFD: len = add_atdirfd(b, rest, arg); break; + case ARG_SIGNAL: + len = add_signal(b, rest, arg); + break; case ARG_ACCESSFLAG: len = add_flags(b, rest, access_flags, arg, false); break; diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index f4e43eb00e..a4fbcc567d 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -23,6 +23,11 @@ SYSCALL_IMPL(alarm) } #endif +SYSCALL_IMPL(kill) +{ + return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); +} + #ifdef TARGET_NR_pause SYSCALL_IMPL(pause) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d612dade23..3fe770890c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5391,8 +5391,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_kill: - return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); #ifdef TARGET_NR_rename case TARGET_NR_rename: { diff --git a/linux-user/strace.list b/linux-user/strace.list index 749bdce638..07e5f7c518 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -410,9 +410,6 @@ #ifdef TARGET_NR_keyctl { TARGET_NR_keyctl, "keyctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_kill -{ TARGET_NR_kill, "kill", NULL, print_kill, NULL }, -#endif #ifdef TARGET_NR_lchown { TARGET_NR_lchown, "lchown" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164524 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4796479ili; Sun, 19 May 2019 14:05:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaZWEPI5AefcHJQnZEEqK5lyDBrG5z+4BtVOnj+24Pg6NdJ6UFwXje46aw/gyCYW9puzhl X-Received: by 2002:a50:8877:: with SMTP id c52mr71176770edc.253.1558299955203; Sun, 19 May 2019 14:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299955; cv=none; d=google.com; s=arc-20160816; b=b0gAOV2Kwf8oBQDpB3LwR5F4VpEvJo/oFwFOZu0Nn+Q4GldIrB4ztMle8RqSZtdxgf LkPTNSwMJ9VFJegQi37sO7OxBYfbFBj9wc6kbXzUZvHkG6UlE/d8vFmhj7tHAvXmA0CL HbDN38oEELDQBB1SMcgw7MtEMyVJRjT4FLxgeT7CpNWD32tI5VFLoUivs/IqH/NqC/ob NjAzv5i1Cgz6MPq0Kt+QLNvVTEz9k22KS73RN01UuVX6Ar2mYZTJUzQ9e2EjH4WUdlKH UAx/jbDniKGJcCb4NA4VPFs3ibPrBAGfqGsonqQmca7L/FvqsnY/3hYb6mg+qB9XmwnR jFsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=MZ4xTXHoRnqxjbKzyUEkFjQQbSbYuTgwnyU38LEY1MU=; b=ltIeQ8p7mEDrWbO/ICwtEu6pT2nNWd5fAvHPko4cm998ozSi3E0TibLOzpFgmBIJ+4 N4OvraCW+1m7hKJ9Wj7Zjxg1L1QPY++DklvG7wTcdyE5Mz9dd6dlujAlwsaFBtEhGDXZ A2Q3J7PIGfuAuJqph7WfaUG13Jur4srV9aYfDtirI6akEd03N4Z8u4m6JLh2Qri66cSu Ew3LfIgMTYrkUmzCHeE1ShdtHZK5VLiv+eYu+ozz+inAOjj34g2tLMNcZvr2urtHx/D4 3/S1NN0fDQhsDTUkrNTU2hqku70wIEWra9lQZhXSknkvxQ6LXDWOiBuc4OBRNjrxEivw v46w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jzueuHJi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p38si3860185edc.348.2019.05.19.14.05.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jzueuHJi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST0E-0001ep-2j for patch@linaro.org; Sun, 19 May 2019 17:05:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZf-0003fD-Is for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004Pw-IC for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:27 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:39847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZd-0004Kj-7H for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:25 -0400 Received: by mail-pl1-x642.google.com with SMTP id g9so5709210plm.6 for ; Sun, 19 May 2019 13:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MZ4xTXHoRnqxjbKzyUEkFjQQbSbYuTgwnyU38LEY1MU=; b=jzueuHJih53MA65QrNMqcmuShPK8bfIscnDjn98SrMNKFRBaG66E6Wv8nseh/UiCH0 Rc4r985n1zXgVQN7RER0C+GI6nU74Ol7UFOXvqkGkEHXx8aylIljtPGYt1ecc2HgAV6I XnBHTnln+h9kPUsQbPtwxI3KknAAIF141R0mizaBlCwRSqQOqTjn/TZlhspqEQ+G7qCP p1LfBJfNIf67dk0kNz84mwpWUSxW4+CEK/6BugaRzBxozECjHDN6jRs3o7NBm1LoHfCK EsZp6KkusZBriWnFYo5vV8HR+H5+AMkGDT1BRSsPzVAdcaUytGM+jKKpY1lCrw11Btbq bfdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MZ4xTXHoRnqxjbKzyUEkFjQQbSbYuTgwnyU38LEY1MU=; b=i6PYpOI5AFVYm5BT7yTmr6V92O3uLhVyw8ufyDK4RwJipEjEFtc20eOOkP62PIRXYL 3rjy7QHKfSNhxqkBkYbrZ093qixasP3vyID2cuEWvoPIOOyLpFOTf7vL3lELeCXYxo/f hbHQ+xW9xj9TQqeu57cCwtur7Ne+jh0+vATjL7/ihGlsZbXMsMW4M1UW1LIEtUgsGY/9 6zMV1bFtnnje02xKk5RqRXVeqnEDA/Hm/VMak7JlGTuAqVpizyPlmoZO1k0Xw9zyjvAB Hmgy+PchgkS5nS+5fTDK2wKH7naVgRQM6rr1BVxTIvqwhq8l6ShA3OwDqNA9IMbfVyY0 iWuA== X-Gm-Message-State: APjAAAUZ1w3vNB5y4vTWvzUbm7uM+gZLI2Vq/wJ+mT8cR37l3W9eTIBF S+jTqTHXNK4nrHn08VmWDQ8mTkE+deM= X-Received: by 2002:a17:902:201:: with SMTP id 1mr26872192plc.263.1558298300365; Sun, 19 May 2019 13:38:20 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:52 -0700 Message-Id: <20190519203726.20729-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 40/74] linux-user: Split out rename, renameat, renameat2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that renameat2 is universally available for guests. Merge sys_renameat2 into the new do_renameat2 helper. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 8 +++++ linux-user/syscall.h | 1 + linux-user/strace.c | 39 ++++++--------------- linux-user/syscall-file.inc.c | 45 ++++++++++++++++++++++++ linux-user/syscall.c | 64 ----------------------------------- linux-user/strace.list | 9 ----- 6 files changed, 65 insertions(+), 101 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index c672b5ad99..0ed01aa100 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -142,6 +142,14 @@ SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlinkat SYSCALL_DEF(readlinkat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_DEC); #endif +#ifdef TARGET_NR_rename +SYSCALL_DEF(rename, ARG_STR, ARG_STR); +#endif +#ifdef TARGET_NR_renameat +SYSCALL_DEF(renameat, ARG_ATDIRFD, ARG_STR, ARG_ATDIRFD, ARG_STR); +#endif +SYSCALL_DEF(renameat2, ARG_ATDIRFD, ARG_STR, + ARG_ATDIRFD, ARG_STR, ARG_RENAMEFLAG); SYSCALL_DEF(readv, ARG_DEC, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_rmdir SYSCALL_DEF(rmdir, ARG_STR); diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 642fb6dccb..7b197840f5 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -69,6 +69,7 @@ typedef enum { ARG_MODEFLAG, ARG_MOUNTFLAG, ARG_OPENFLAG, + ARG_RENAMEFLAG, ARG_UMOUNTFLAG, ARG_UNLINKATFLAG, diff --git a/linux-user/strace.c b/linux-user/strace.c index 01a5c210fa..8f871b30ae 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "qemu.h" #include "syscall.h" @@ -741,6 +742,13 @@ static struct flags const mount_flags[] = { FLAG_END, }; +static struct flags const renameat2_flags[] = { + FLAG_GENERIC(RENAME_EXCHANGE), + FLAG_GENERIC(RENAME_NOREPLACE), + FLAG_GENERIC(RENAME_WHITEOUT), + FLAG_END, +}; + static struct flags const umount2_flags[] = { #ifdef MNT_FORCE FLAG_GENERIC(MNT_FORCE), @@ -1899,34 +1907,6 @@ print_fstatat64(const struct syscallname *name, #define print_newfstatat print_fstatat64 #endif -#ifdef TARGET_NR_rename -static void -print_rename(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_string(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_renameat -static void -print_renameat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_at_dirfd(arg2, 0); - print_string(arg3, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_statfs static void print_statfs(const struct syscallname *name, @@ -2212,6 +2192,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_OPENFLAG: len = add_open_flags(b, rest, arg); break; + case ARG_RENAMEFLAG: + len = add_flags(b, rest, renameat2_flags, arg, false); + break; case ARG_UMOUNTFLAG: len = add_flags(b, rest, umount2_flags, arg, false); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 9f3cf7221a..18553f055e 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -873,6 +873,51 @@ SYSCALL_IMPL(readlinkat) } #endif +static abi_long do_renameat2(int oldfd, abi_ulong target_oldpath, + int newfd, abi_ulong target_newpath, + unsigned int flags) +{ + char *p_old = lock_user_string(target_oldpath); + char *p_new = lock_user_string(target_newpath); + abi_long ret = -TARGET_EFAULT; + + if (p_old && p_new) { + if (flags == 0) { + ret = renameat(oldfd, p_old, newfd, p_new); + } else { +#ifdef __NR_renameat2 + ret = syscall(__NR_renameat2, oldfd, p_old, newfd, p_new, flags); +#else + errno = ENOSYS; + ret = -1; +#endif + } + ret = get_errno(ret); + } + unlock_user(p_old, target_oldpath, 0); + unlock_user(p_new, target_newpath, 0); + return ret; +} + +#ifdef TARGET_NR_rename +SYSCALL_IMPL(rename) +{ + return do_renameat2(AT_FDCWD, arg1, AT_FDCWD, arg2, 0); +} +#endif + +#ifdef TARGET_NR_renameat +SYSCALL_IMPL(renameat) +{ + return do_renameat2(arg1, arg2, arg3, arg4, 0); +} +#endif + +SYSCALL_IMPL(renameat2) +{ + return do_renameat2(arg1, arg2, arg3, arg4, arg5); +} + SYSCALL_IMPL(sync) { sync(); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3fe770890c..d8f6da63cc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -331,24 +331,6 @@ static int sys_utimensat(int dirfd, const char *pathname, #endif #endif /* TARGET_NR_utimensat */ -#ifdef TARGET_NR_renameat2 -#if defined(__NR_renameat2) -#define __NR_sys_renameat2 __NR_renameat2 -_syscall5(int, sys_renameat2, int, oldfd, const char *, old, int, newfd, - const char *, new, unsigned int, flags) -#else -static int sys_renameat2(int oldfd, const char *old, - int newfd, const char *new, int flags) -{ - if (flags == 0) { - return renameat(oldfd, old, newfd, new); - } - errno = ENOSYS; - return -1; -} -#endif -#endif /* TARGET_NR_renameat2 */ - #ifdef CONFIG_INOTIFY #include @@ -5391,52 +5373,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_rename - case TARGET_NR_rename: - { - void *p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg2); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(rename(p, p2)); - unlock_user(p2, arg2, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_renameat) - case TARGET_NR_renameat: - { - void *p2; - p = lock_user_string(arg2); - p2 = lock_user_string(arg4); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(renameat(arg1, p, arg3, p2)); - unlock_user(p2, arg4, 0); - unlock_user(p, arg2, 0); - } - return ret; -#endif -#if defined(TARGET_NR_renameat2) - case TARGET_NR_renameat2: - { - void *p2; - p = lock_user_string(arg2); - p2 = lock_user_string(arg4); - if (!p || !p2) { - ret = -TARGET_EFAULT; - } else { - ret = get_errno(sys_renameat2(arg1, p, arg3, p2, arg5)); - } - unlock_user(p2, arg4, 0); - unlock_user(p, arg2, 0); - } - return ret; -#endif #ifdef TARGET_NR_mkdir case TARGET_NR_mkdir: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 07e5f7c518..3b002a0500 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -944,15 +944,6 @@ #ifdef TARGET_NR_removexattr { TARGET_NR_removexattr, "removexattr" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rename -{ TARGET_NR_rename, "rename" , NULL, print_rename, NULL }, -#endif -#ifdef TARGET_NR_renameat -{ TARGET_NR_renameat, "renameat" , NULL, print_renameat, NULL }, -#endif -#ifdef TARGET_NR_renameat2 -{ TARGET_NR_renameat2, "renameat2" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_request_key { TARGET_NR_request_key, "request_key" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164528 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4798570ili; Sun, 19 May 2019 14:08:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwX+7BythRvZoL4RNvKj7o7kafUpQ/RFy+aMRHyQpWTxgAaW9Rk4keYblUAznZMso9mb5a7 X-Received: by 2002:a17:906:f84a:: with SMTP id ks10mr38253931ejb.65.1558300110912; Sun, 19 May 2019 14:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300110; cv=none; d=google.com; s=arc-20160816; b=F9uwPlbzd14IGNLAobES+iObsNkpEcTfDivuEOTAE4oNbVZ6ptQ1aSsr/ucW4xpiu7 lzvh85u4kX/0hogxncIuAxuLSVVj9AZalpvqrjhNSTsY2Vx4SRPuHVKq+fRdSxnmYEaC 4ibrsn0kN8e1SiKNE50LemwLLVCT85VPFl9PqrfI39IBc2KR9yPI61Oh9nOoNRW2NUbs rWGvwfQZBX7UWabEplF9xOhEm00K+mpWaF/o5TS5EX+uDCSsgfSqi5k4zCni43WuSiTp LTw0PUaBLU9zfsUQF92nXamgov2oGJNVRi3XPmfyaoyCrAEZ6f9IBuNXa/fxbAx1wZzs cVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=sj59YrDaOii9L6seogQrj9UiCSK4yTlGx0hQSWmkpdA=; b=liZ9rByhgqzUTtxZuSlpPD8Bh7XQYFK4q/DeRooW4OKw7Tgv1esNkbV2xshq2ULp3N /p7xqfUBN+Ei8L0cMNsf3LxtPrcRsbt8WeyhYfy2shzCIx22REyMdi/VzTEOSvn3TXh1 x0k3eESp3D3vrWt266CP0dIpsiQjiEG8Y0d6byNF7IRox2K79JvLdqPozP4unlTFQN55 jHjgZtkMTnN0YHhk6PF3nFVTy4StGuxU7tjcjTRu1JJymUrQZS0BY5m/Qnp4AAd/OX89 DK6Fm3LZcsk8asEAd9yC44OS5SGk+xpB8m/KvtZVtq5Qyyx3qsv+ZdKP7dV1+nRNsYYU 0lcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Rd5loNac; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o16si9646800ejg.38.2019.05.19.14.08.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:08:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Rd5loNac; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST2j-0003vV-Kb for patch@linaro.org; Sun, 19 May 2019 17:08:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZe-0003ei-Tf for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004Pq-Hs for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:46948) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZd-0004ML-8j for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:25 -0400 Received: by mail-pg1-x542.google.com with SMTP id t187so5715973pgb.13 for ; Sun, 19 May 2019 13:38:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sj59YrDaOii9L6seogQrj9UiCSK4yTlGx0hQSWmkpdA=; b=Rd5loNaceU2JTZWTz70p9BYyr9D2BAwEvrsapMfTqsgfsZKpr5wxUiiXPuVDNBb6/e pB7CEE8j/eg6Bhun1IbPfPP3mh2Hmbp3VVy144bY4T9ewk0czfDhbi65i5soJ0JAslvM trLfSE7+adcc2u9WGpJHJEJ7uLVMbi0RJDgAWTd3XSUGsNnM5gAoJrFRHusnx2laWzQq sbV1S1Ry5ntpOm7MMxSOKHacVR9FO44AC9XGabpeWw3kMwReunuvqk1+kWWGGARrTIQr zITZ/W/b/iK8dtWWI/FYxPLukLOX8DzejL+1fsE8v01sYRQ68dolq+uCrQ6unzcnlfdE Q+FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sj59YrDaOii9L6seogQrj9UiCSK4yTlGx0hQSWmkpdA=; b=ImbxxclGwugF19YrC3g1qXNcojN8cDKoigZ0ufBBnH+HXpheSzQ8OemNq1AolqgVdO /MWc1CZJIkwxIq53oMLk18GBni6cSJOR/3FbVon3G4IgpgVHN28VSJ2VJ2Kw1WftQIRn vZvQjXyKC+AX8pG5TZxr/RRZhtRoRmjeO6Ld0iOx99VS+fXLYOMznb+GZi9DygrwAVtx G2Pbjyc3SiDt++3owBE2vsDrC3RcG7QwWqypkWXSoq5RIrIzhJD42IJ35YsSaMQ6RZ56 k7HCIV3mbhaqPBtWHVBrHor1oLojYgvJmSLieSqw6RVQC/D9MHXccIfZOPSMecaBB45/ trNg== X-Gm-Message-State: APjAAAUvnwUMfCxvYlndl9FvzL7N3nIDCLXA5hXNxztTUM6FoErTEte6 +Lg5kCnyQKEr7BnNNs7wyHe+s4WvGMI= X-Received: by 2002:a63:fb02:: with SMTP id o2mr70159867pgh.357.1558298301857; Sun, 19 May 2019 13:38:21 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:53 -0700 Message-Id: <20190519203726.20729-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v7 41/74] linux-user: Split out mkdir, mkdirat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that mkdirat is universally available. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/strace.c | 27 --------------------------- linux-user/syscall-file.inc.c | 25 +++++++++++++++++++++++++ linux-user/syscall.c | 16 ---------------- linux-user/strace.list | 6 ------ 5 files changed, 29 insertions(+), 49 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 0ed01aa100..8b6d8f75ff 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -69,6 +69,10 @@ SYSCALL_DEF(lseek, ARG_DEC, ARG_DEC, ARG_LSEEKWHENCE); #ifdef TARGET_NR_llseek SYSCALL_DEF_ARGS(llseek, ARG_DEC, ARG_DEC, ARG_PTR, ARG_LSEEKWHENCE); #endif +#ifdef TARGET_NR_mkdir +SYSCALL_DEF(mkdir, ARG_STR, ARG_MODEFLAG); +#endif +SYSCALL_DEF(mkdirat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); #ifdef TARGET_NR_mknod SYSCALL_DEF(mknod, ARG_STR, ARG_MODEFLAG, ARG_HEX); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 8f871b30ae..2b31998dbd 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1676,33 +1676,6 @@ print_fstat(const struct syscallname *name, #define print_fstat64 print_fstat #endif -#ifdef TARGET_NR_mkdir -static void -print_mkdir(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_file_mode(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_mkdirat -static void -print_mkdirat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_file_mode(arg2, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_rt_sigaction static void print_rt_sigaction(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 18553f055e..5ed8b78c79 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -205,6 +205,31 @@ SYSCALL_IMPL(llseek) } #endif +static abi_long do_mkdirat(int dirfd, abi_ulong target_path, mode_t mode) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdirat(dirfd, p, mode)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_mkdir +SYSCALL_IMPL(mkdir) +{ + return do_mkdirat(AT_FDCWD, arg1, arg2); +} +#endif + +SYSCALL_IMPL(mkdirat) +{ + return do_mkdirat(arg1, arg2, arg3); +} + static abi_long do_mknodat(int dirfd, abi_ulong target_path, mode_t mode, dev_t dev) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d8f6da63cc..0d6a9b7a6c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5373,22 +5373,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_mkdir - case TARGET_NR_mkdir: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(mkdir(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_mkdirat) - case TARGET_NR_mkdirat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(mkdirat(arg1, p, arg3)); - unlock_user(p, arg2, 0); - return ret; -#endif case TARGET_NR_dup: ret = get_errno(dup(arg1)); if (ret >= 0) { diff --git a/linux-user/strace.list b/linux-user/strace.list index 3b002a0500..cdbc59bffd 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -473,12 +473,6 @@ #ifdef TARGET_NR_mincore { TARGET_NR_mincore, "mincore" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_mkdir -{ TARGET_NR_mkdir, "mkdir" , NULL, print_mkdir, NULL }, -#endif -#ifdef TARGET_NR_mkdirat -{ TARGET_NR_mkdirat, "mkdirat" , NULL, print_mkdirat, NULL }, -#endif #ifdef TARGET_NR_modify_ldt { TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164541 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4806106ili; Sun, 19 May 2019 14:19:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqw74J8A4Pd3buPXmKXGIuxDLFCn5Ry/hvZJQHi6Hcu7WfnrbWvLFncOkNcSRwANNDLnvuUu X-Received: by 2002:a50:ce5b:: with SMTP id k27mr19291055edj.48.1558300746155; Sun, 19 May 2019 14:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300746; cv=none; d=google.com; s=arc-20160816; b=D2CRHaTNIREUMHRYNHzzwFq6Xl6w9gMXiMC9NuJcl99oruyu/H2ylY2fO6SEtLD6ZJ /R6DdIYMyT0JWNSLSuH6VFaaDjFnwDGB+tuVdnPnk4A+nM3UwjVsXvp0n6DYjztIld4z 3p2iw8bhzzD11OfnC2BZUsG6IcVYsZqaexeroBwtbXjUw+fVOG+fQiUIl+qjrTSmRBoR TkoduY77bbwYwSbOk5CI0UJxRrX/2NHNaoL+z4g31gTw5eENdHUnpJ2p+UUYFpgJjP0J S/BLJ/DHNlo5BUWh+8D6jCWVpsBnOCVjujv7VaZSVVGaTOAbUIR45CHo0uqin2bS6QPp oHfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=tO0MYq1BfTpb+Rq4mEcLzQaoCNhvveoe+wDeU1tkEl4=; b=d7QHa9iGGUBcmAZny/kv7IgsDIK6tBVahUH3Xg9QVzE3EAgHACGpeYhaA5FvogoeGQ 5PiuW5OwefzWKRMw4SwZBi/Qlxq/R9WNDGf8lxjwi/z254LgfjgScbYkGgJbY5aRQzNw CmuYh5xgpsS7cQMb/TMHLH998H+2KqG6PKXPWggHb06UQtvSTOUbS0nt9KOsto6wJoNb zXH7Kh7bmcH+qYiQFGsD2eHfcRjzivdaChVARTTd6wQ7gXfdfQQkFtOErY6QDPzJEeFv +o+nPvGzm/Mg2N3t35ii4WIc4SMNMYiMCRWdhga5kJ4w3ILD0A6Al4ijzAfaS3V1/AD0 ecwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JchIpMmG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g38si6844792edg.96.2019.05.19.14.19.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:19:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JchIpMmG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTCy-0005QS-Ug for patch@linaro.org; Sun, 19 May 2019 17:19:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZf-0003et-AW for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004QM-OO for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:27 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34263) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZd-0004NW-Fj for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:25 -0400 Received: by mail-pf1-x441.google.com with SMTP id n19so6182901pfa.1 for ; Sun, 19 May 2019 13:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tO0MYq1BfTpb+Rq4mEcLzQaoCNhvveoe+wDeU1tkEl4=; b=JchIpMmGQzlbAZh0Xr/Y31cWysRgPDnxvatEZVGc5KkGSEl2yUXMqvnEs+txrnxyC+ KdzXK7cQVKuDZlXiLAOET5jWNVefAscgas8GkF3SP98bTlJlHJkbW8jUo3VaZdlE+SML E9FIS1LLNZiA3vQIF8fgyLbkV+7TA5ahQj7mshVzGARXKUbu3RR7YwHlMkJdhSXXvJ9L MccM4nuagbwuR3YzpzvYXhZiqTliEIQ6E+sqwEZT2JnKrPGrRn9Xgz0yfHyDNvbFJu4A 4/Nl72R2oeUROVd81jfY+/73eYzYdN4tXSs23Lw+BxFayExackAZTKl+OoGyWOVDox// 7tOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tO0MYq1BfTpb+Rq4mEcLzQaoCNhvveoe+wDeU1tkEl4=; b=QYvrQfURLoO/nM9+W9L0yGVBl9VtTxGFplBQwstuJMbG/vi7RXWNjpTWl9C4NGQk9z NWPPDAX2RPa1sN7+MxplUXJSGdT/vT1klibujI3y5cDjASIGeVJnNJmE9qNjKYqVuGqx jt+RYt6DteFfV4LS+UApfsKIkmRFDtwoPkk9LNGy5W0pkVdAT9mfGdiT9hyjBXplbuxR hoY3dPsFMmZUhkGMZhGZc4lJ6BnkGEw4Dr0/KLn3yYoEAgSQh33XJi3eYxZN2m4TNb2h MvjBWJp8/6RlMrO+D+D5OZvS6YbVzfwmxVHeM2q3x7zfDJxKD86+f99Khkrl+sLdNehB JEbw== X-Gm-Message-State: APjAAAWKzRuKxRpz8Z/yCXy3p62U3PqC9usSXHZV4sokW8m0R59/tvK5 e8/BlbihOL3RqbmuzV9yWR+Uun7XivQ= X-Received: by 2002:a65:5c89:: with SMTP id a9mr71874534pgt.334.1558298303006; Sun, 19 May 2019 13:38:23 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:54 -0700 Message-Id: <20190519203726.20729-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 42/74] linux-user: Split out dup, dup2, dup3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that dup3 is universally available for guests. Implement host support with syscall when !CONFIG_DUP3. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 5 +++++ linux-user/syscall-file.inc.c | 42 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 33 +++------------------------ linux-user/strace.list | 6 ----- 4 files changed, 50 insertions(+), 36 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 8b6d8f75ff..062adddd75 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -34,6 +34,11 @@ SYSCALL_DEF(close, ARG_DEC); #ifdef TARGET_NR_creat SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG); #endif +SYSCALL_DEF(dup, ARG_DEC); +#ifdef TARGET_NR_dup2 +SYSCALL_DEF(dup2, ARG_DEC, ARG_DEC); +#endif +SYSCALL_DEF(dup3, ARG_DEC, ARG_DEC, ARG_OPENFLAG); SYSCALL_DEF(exit, ARG_DEC); SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 5ed8b78c79..7d97dd1ec1 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -94,6 +94,48 @@ SYSCALL_IMPL(creat) } #endif +SYSCALL_IMPL(dup) +{ + abi_long ret = get_errno(dup(arg1)); + if (ret >= 0) { + fd_trans_dup(arg1, ret); + } + return ret; +} + +#ifdef TARGET_NR_dup2 +SYSCALL_IMPL(dup2) +{ + abi_long ret = get_errno(dup2(arg1, arg2)); + if (ret >= 0) { + fd_trans_dup(arg1, arg2); + } + return ret; +} +#endif + +SYSCALL_IMPL(dup3) +{ + int ofd = arg1; + int nfd = arg2; + int host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl); + abi_long ret; + +#ifdef CONFIG_DUP3 + ret = dup3(ofd, nfd, host_flags); +#else + if (host_flags == 0) { + if (ofd == nfd) { + return -TARGET_EINVAL; + } + ret = dup2(ofd, nfd); + } else { + ret = syscall(__NR_dup3, ofd, nfd, host_flags); + } +#endif + return get_errno(ret); +} + SYSCALL_IMPL(faccessat) { return do_faccessat(arg1, arg2, arg3); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0d6a9b7a6c..bab9a57ee0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -204,6 +204,9 @@ _syscall0(int, sys_gettid) * Performing a bogus syscall is easier than boilerplating * the replacement functions here in C. */ +#ifndef __NR_dup3 +#define __NR_dup3 -1 +#endif #ifndef __NR_syncfs #define __NR_syncfs -1 #endif @@ -5373,12 +5376,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_dup: - ret = get_errno(dup(arg1)); - if (ret >= 0) { - fd_trans_dup(arg1, ret); - } - return ret; #ifdef TARGET_NR_pipe case TARGET_NR_pipe: return do_pipe(cpu_env, arg1, 0, 0); @@ -5433,30 +5430,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); return ret; -#ifdef TARGET_NR_dup2 - case TARGET_NR_dup2: - ret = get_errno(dup2(arg1, arg2)); - if (ret >= 0) { - fd_trans_dup(arg1, arg2); - } - return ret; -#endif -#if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3) - case TARGET_NR_dup3: - { - int host_flags; - - if ((arg3 & ~TARGET_O_CLOEXEC) != 0) { - return -EINVAL; - } - host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl); - ret = get_errno(dup3(arg1, arg2, host_flags)); - if (ret >= 0) { - fd_trans_dup(arg1, arg2); - } - return ret; - } -#endif #ifdef TARGET_NR_getpgrp case TARGET_NR_getpgrp: return get_errno(getpgrp()); diff --git a/linux-user/strace.list b/linux-user/strace.list index cdbc59bffd..2f78f4685b 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -91,12 +91,6 @@ #ifdef TARGET_NR_dipc { TARGET_NR_dipc, "dipc" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_dup -{ TARGET_NR_dup, "dup" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_dup2 -{ TARGET_NR_dup2, "dup2" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_epoll_create { TARGET_NR_epoll_create, "epoll_create" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164549 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4808866ili; Sun, 19 May 2019 14:23:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9lHtRXXMxMRBDg6yS0MV07NN9UajDQ4wiOp/K+SSCqT35kQI6ngXQD77NuWCNDkiLo9ok X-Received: by 2002:a50:ba6e:: with SMTP id 43mr70538843eds.201.1558300991400; Sun, 19 May 2019 14:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300991; cv=none; d=google.com; s=arc-20160816; b=Yy2CqDdOomPXCQA0KusEhW6fT+X/72zgghIccWrovqcj8Nqt+hDZzBF2K0EfHDYKeL rxfoPfcRL1h1bHYJX0eml6ljVYZOnV7HB6QviCr2S1VEAeHL1Fe/rodBUW5v9T8DZfjx /VY5bX+sM4g3RaOvRaRyt2O9zm5SNHvUunpgxSm45OQ/BniiglbGoq5I3sqlbX8/EG+T Zk833+Y/tMAKtKzi92nEp8dV9oE0qZH+AWOOWZc5dNw+dES2UbGvLB8yPkqqKESiUuti bMHEcnCo0sskMnRnEcvVcUZ83IWUeECqiyu35uiujv/tCulwo+MJJWFJwuDo6Rt19F9c Pf4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=i/scOGMWF8bWzvx8tsNwoDLjnfeTL/fRVFk/GWGzfuQ=; b=g+A+/K6KJKUr5zeLv2EUosoUJHHTmLSlgIyfOihXB97WC36QmdKtDEdRloq8kLmVuV 3aT3HZKSBT+D8kox938uxllmc4h/77yrFEb/UFJeeRONDQA6jw9HK2EvkHFiW6Ibu97L 3SmOws32yc+w4Rm4FXmiGJ4Ea7qRJKgLzl5kpj/JvurdqAT5V0rQ8aiPMYn6CZ7Criei kz+rYlmFlYTNInSFo2fT6NPSuNuL7hP3p/qs8G/u0ivnKWWnMizAsyDponS7zWYxwuc6 hJpLK1OsudCmE/W6TTdmcGB5LZpLdnGzB4nkhGKPodRAUIJBJfjCvqih5XwajgpPFzBX vmAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pU3oRYKP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t57si6535353edb.108.2019.05.19.14.23.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pU3oRYKP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTGw-0000Kt-7Y for patch@linaro.org; Sun, 19 May 2019 17:23:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZg-0003fo-7C for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZd-0004Qa-Ou for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:28 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44237) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZd-0004Ot-Ha for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:25 -0400 Received: by mail-pl1-x642.google.com with SMTP id c5so5690839pll.11 for ; Sun, 19 May 2019 13:38:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i/scOGMWF8bWzvx8tsNwoDLjnfeTL/fRVFk/GWGzfuQ=; b=pU3oRYKPv6Id6hInOj/s4iOl45/+lVmFh+PQartwsUjaWX2vuzFP34vb8/uBdLzgku 73Xbz8VsHqpXchVfaFQ87uX4l1p2DwgkHWKiE/IhVKNlMnj79l3/epXn0WqxBSPczVHx 2y3hynA6b0U5cv0B4J451Gf2/u4ynkQI4w5+yCm0uAIRK6JgWum8QnMbyhtJGh0w8/+h G0ZMAemoCJCZw2egRWO8jUWTnNIO5su9YcK+tFJUndAYRhUqqzne0il1Afh6UZOj9F0f DWXArxVIYKTaHDO6eeXCEkQlQ+12J2WgyGQwogWmOJBOVYHxbR91i/Mwh9afzGkfZODH G2cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i/scOGMWF8bWzvx8tsNwoDLjnfeTL/fRVFk/GWGzfuQ=; b=W8YB98bG2U6dE6uP1I5IBFGp1a8HguFboP0owmj4dcT2W371vqg8jXqx85PrRGWRAy 5B4AoS7FhtMwws4GnyvtqphF/Cy1NZZUDfxs8IaBUaPKI3qtCLV3Fb7qB+gNo5BDm1FL /cZzl6DZuXo2LHxMeUJ1B539RbKjJKCmb5NUKF2iL3DEziOhp6nmwMngjn4WzGz21FdE DYRhhOOpafzjcAkX4xrxBWQN0wnXZg8brf4iriI8U9/RfLRApxNPeKvHhGez7eUXWEBD I73U7Y9cl/74DfvSSyB1/MxGEU4+3EGlixD8vIsywuDkWG9uJE53NTKfq9VwxO5SR2Ue E8UQ== X-Gm-Message-State: APjAAAX640OGdpVf1L063KZp1bi1hUyb2KsHG9uxfhACPXUt7w9tpgNs l8i6gZrnnghog/3c0hcYafPVQaWkeGU= X-Received: by 2002:a17:902:4203:: with SMTP id g3mr53196000pld.288.1558298304197; Sun, 19 May 2019 13:38:24 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:55 -0700 Message-Id: <20190519203726.20729-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 43/74] linux-user: Split out pipe, pipe2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that pipe2 is universally available for guests. Implement host support with syscall when !CONFIG_PIPE2. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 10 ++++++ linux-user/syscall-file.inc.c | 51 +++++++++++++++++++++++++++ linux-user/syscall.c | 65 +++++++---------------------------- linux-user/strace.list | 6 ---- 4 files changed, 74 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 062adddd75..bd3301a72f 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -132,6 +132,16 @@ SYSCALL_DEF(open_by_handle_at, ARG_DEC, ARG_PTR, ARG_OPENFLAG); #ifdef TARGET_NR_pause SYSCALL_DEF(pause); #endif +#ifdef TARGET_NR_pipe +# if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || \ + defined(TARGET_SH4) || defined(TARGET_SPARC) +/* ??? We have no way for strace to display the second returned fd. */ +SYSCALL_DEF(pipe); +# else +SYSCALL_DEF(pipe, ARG_PTR); +# endif +#endif +SYSCALL_DEF(pipe2, ARG_PTR, ARG_OPENFLAG); SYSCALL_DEF_FULL(pread64, .impl = impl_pread64, .args = args_pread64_pwrite64, .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 7d97dd1ec1..5bd9eaa002 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -726,6 +726,57 @@ SYSCALL_IMPL(open_by_handle_at) return ret; } +static abi_long do_pipe(CPUArchState *cpu_env, abi_ulong target_fds, + int target_flags, bool is_pipe2) +{ + int host_flags = target_to_host_bitmask(target_flags, fcntl_flags_tbl); + int host_fds[2]; + abi_long ret; + + ret = pipe2(host_fds, host_flags); + if (is_error(ret)) { + return get_errno(ret); + } + + /* + * Several targets have special calling conventions for the original + * pipe syscall, but didn't replicate this into the pipe2 syscall. + */ + if (!is_pipe2) { +#if defined(TARGET_ALPHA) + cpu_env->ir[IR_A4] = host_fds[1]; + return host_fds[0]; +#elif defined(TARGET_MIPS) + cpu_env->active_tc.gpr[3] = host_fds[1]; + return host_fds[0]; +#elif defined(TARGET_SH4) + cpu_env->gregs[1] = host_fds[1]; + return host_fds[0]; +#elif defined(TARGET_SPARC) + cpu_env->regwptr[1] = host_fds[1]; + return host_fds[0]; +#endif + } + + if (put_user_s32(host_fds[0], target_fds) + || put_user_s32(host_fds[1], target_fds + 4)) { + return -TARGET_EFAULT; + } + return 0; +} + +#ifdef TARGET_NR_pipe +SYSCALL_IMPL(pipe) +{ + return do_pipe(cpu_env, arg1, 0, false); +} +#endif + +SYSCALL_IMPL(pipe2) +{ + return do_pipe(cpu_env, arg1, arg2, true); +} + /* * Both pread64 and pwrite64 merge args into a 64-bit offset, * but the input registers and ordering are target specific. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bab9a57ee0..cda1f8a205 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -207,6 +207,9 @@ _syscall0(int, sys_gettid) #ifndef __NR_dup3 #define __NR_dup3 -1 #endif +#ifndef __NR_pipe2 +#define __NR_pipe2 -1 +#endif #ifndef __NR_syncfs #define __NR_syncfs -1 #endif @@ -273,6 +276,16 @@ _syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type, #ifndef CONFIG_SYNCFS _syscall1(int, syncfs, int, fd) #endif +#ifndef CONFIG_PIPE2 +static int pipe2(int *fds, int flags) +{ + if (flags) { + return syscall(__NR_pipe2, fds, flags); + } else { + return pipe(fds); + } +} +#endif static bitmask_transtbl fcntl_flags_tbl[] = { { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, @@ -1124,49 +1137,6 @@ static abi_long do_old_select(abi_ulong arg1) #endif #endif -static abi_long do_pipe2(int host_pipe[], int flags) -{ -#ifdef CONFIG_PIPE2 - return pipe2(host_pipe, flags); -#else - return -ENOSYS; -#endif -} - -static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, - int flags, int is_pipe2) -{ - int host_pipe[2]; - abi_long ret; - ret = flags ? do_pipe2(host_pipe, flags) : pipe(host_pipe); - - if (is_error(ret)) - return get_errno(ret); - - /* Several targets have special calling conventions for the original - pipe syscall, but didn't replicate this into the pipe2 syscall. */ - if (!is_pipe2) { -#if defined(TARGET_ALPHA) - ((CPUAlphaState *)cpu_env)->ir[IR_A4] = host_pipe[1]; - return host_pipe[0]; -#elif defined(TARGET_MIPS) - ((CPUMIPSState*)cpu_env)->active_tc.gpr[3] = host_pipe[1]; - return host_pipe[0]; -#elif defined(TARGET_SH4) - ((CPUSH4State*)cpu_env)->gregs[1] = host_pipe[1]; - return host_pipe[0]; -#elif defined(TARGET_SPARC) - ((CPUSPARCState*)cpu_env)->regwptr[1] = host_pipe[1]; - return host_pipe[0]; -#endif - } - - if (put_user_s32(host_pipe[0], pipedes) - || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) - return -TARGET_EFAULT; - return get_errno(ret); -} - static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn, abi_ulong target_addr, socklen_t len) @@ -5376,15 +5346,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_pipe - case TARGET_NR_pipe: - return do_pipe(cpu_env, arg1, 0, 0); -#endif -#ifdef TARGET_NR_pipe2 - case TARGET_NR_pipe2: - return do_pipe(cpu_env, arg1, - target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); -#endif case TARGET_NR_times: { struct target_tms *tmsp; diff --git a/linux-user/strace.list b/linux-user/strace.list index 2f78f4685b..a1c3dd98e0 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -860,9 +860,6 @@ #ifdef TARGET_NR_personality { TARGET_NR_personality, "personality" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pipe -{ TARGET_NR_pipe, "pipe" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_pivot_root { TARGET_NR_pivot_root, "pivot_root" , NULL, NULL, NULL }, #endif @@ -1377,9 +1374,6 @@ #ifdef TARGET_NR_sync_file_range2 { TARGET_NR_sync_file_range2, "sync_file_range2", NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pipe2 -{ TARGET_NR_pipe2, "pipe2", NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_atomic_cmpxchg_32 { TARGET_NR_atomic_cmpxchg_32, "atomic_cmpxchg_32", NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164529 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4798743ili; Sun, 19 May 2019 14:08:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbC4Ih20FtB425nkqblvYNZ8uyXsF5WCaBgK1bkDrrToDKnwCqdCzD1VjqirCaHxWhKk1+ X-Received: by 2002:a50:ce06:: with SMTP id y6mr71621606edi.160.1558300126344; Sun, 19 May 2019 14:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300126; cv=none; d=google.com; s=arc-20160816; b=vFqURfYWMEKDMq3CUu7Cl3NOb1zr+c/QSXg5RfKsE/cO0NZdCYu09LGpk0zRiKGK9U NQaZHBjhl8yp10GU7dChyfp2ByrxPo5MHGO/uyKrh4pJXUfiLG51Zi66zjQaN1eIB+CK ziaVPMfxeXs2u4m1fYaMcg0dCPk+qVZJIJedfJapdb/J3dz4bI0nk169dmK8GROLCkIb KuKxzFM3286duEJCBFOAjsRbSApuB4S0pWioyCA0EHIX5LZp/moTePeVSZ/iZ1OHMmgJ X4Gdz3mZce0BFFzVV+aF14QiyoX45P9aAU+bcY8BSLJgCRA0y1V9IRAJpveWIarKzVcf kZgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=hCKl3WsFFB8I9SyuErlgjzDySDbodc+1SphzTaA0mp0=; b=lt0EAQT/WoDvq8heozr4PeewlfZy1myX6tm0ZWVQS6GRdM+RR/lIvjo1Fv0z0sZKso TZD95BwFfzVBCUJkJ1hZF1gWADTs3ExU4uM4kPjcyaexfOs75UhoCpoQIlJ+ateqb9Wz z8Xz00+zLneEJvHmG2H9Vs05Vucvr2x5LFtrm4iWp7Rrd/hRoSEJApk9VonBm9tfG8vr fpKtnyGN91H8egCcmqhfmkFhXZxTiWBUAeBNnvQg6AHuvir/5j6K/XqfJRKPNQbEWsHz RV/FxBfKgNdlcyG/6dbDDkRq89bg6Yglj+Axnger9cpM1wBJMQeo2oGvilRjLrQmwM+F Chyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IBCN5yrd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g6si11883317edg.190.2019.05.19.14.08.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:08:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IBCN5yrd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST2z-0004O9-4W for patch@linaro.org; Sun, 19 May 2019 17:08:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZg-0003gT-QI for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZe-0004Sg-P8 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:28 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZe-0004R4-HU for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: by mail-pl1-x641.google.com with SMTP id f12so5707249plt.8 for ; Sun, 19 May 2019 13:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hCKl3WsFFB8I9SyuErlgjzDySDbodc+1SphzTaA0mp0=; b=IBCN5yrde7jbvLtsr8VkhNSO50Hr38sFL8xFDuu0FVnf2s6cIEXyIBnmK9UlbEud3L iUjQ/MuneVRfAdmbcV+9WDNHoDuZTH9QWqJYqPygkULjpzD2R9oSpnzFlJVgyYgD1/rh veE9EY5y/IopR81L8oPkbPRjK62wHs4fe1K0O0N8CgVZZHkYohMHm6nAPtdlPJE0EtA8 ZgTI4NzJ5jo5nAF2Xa6c5X4dXc9SXdIqPJM+9UOrKSyEADTXLS6hsdxT/LVr9wj+uifZ H4mqwUU3zme7MaRpHWEC+R/tu8FMfmxrKT+1xtkqO7L0vzlqEAejHPlrC97u7b1ErZow EiIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hCKl3WsFFB8I9SyuErlgjzDySDbodc+1SphzTaA0mp0=; b=BG0W6Ru4eLaU8o89lw4KryrvcejqfmrNjPhugdovEzz8v1SVCq40vldiE+ulWRCE1V lDtK6Z6bki6/YQWq9FX4uQtMrgw/3jhxso4uhUyxH7Fog1gxWfYq7OnP5BMVvZUF9saY quGgHzNJk0k3ySKybtsmLIoSJN0Yp9H6TDnWKMjdLO4VA0LAXiMfFVm0zj/Aa2bU8GCS jhgqPJ6YwerD66qrVHZUbqbVsUKBZwa9Nkyg1ZDUJfxiSbkJjSZ1v3junx+jnsW9HIec dUdPykjDWhiwJW9YZfwdhjF0ABxV03eoca4uqWXWqtb3SuhIGwQ36D6gcsagI77ktXPS QeNQ== X-Gm-Message-State: APjAAAV9PwbNWiSFKzFdB5/bt6HUH196KUKDDe8BoQfWkha1kES2Avj1 gHWa+jb6qPo278Oq6EReWjfD8aAlXoE= X-Received: by 2002:a17:902:6bc8:: with SMTP id m8mr70316262plt.227.1558298305264; Sun, 19 May 2019 13:38:25 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:56 -0700 Message-Id: <20190519203726.20729-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 44/74] linux-user: Split out times X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-proc.inc.c | 25 +++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 3 --- 4 files changed, 26 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index bd3301a72f..25d5aaccd1 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -204,6 +204,7 @@ SYSCALL_DEF(syncfs, ARG_DEC); #ifdef TARGET_NR_time SYSCALL_DEF(time, ARG_PTR); #endif +SYSCALL_DEF(times, ARG_PTR); #ifdef TARGET_NR_umount SYSCALL_DEF(umount, ARG_STR); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index e29c2ede25..517f84e139 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -468,6 +468,31 @@ SYSCALL_IMPL(nice) } #endif +SYSCALL_IMPL(times) +{ + abi_ulong target_buf = arg1; + struct tms tms; + abi_long ret; + + ret = get_errno(times(&tms)); + if (target_buf) { + struct target_tms *tmsp = lock_user(VERIFY_WRITE, target_buf, + sizeof(struct target_tms), 0); + if (!tmsp) { + return -TARGET_EFAULT; + } + tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); + tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); + tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); + tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); + unlock_user(tmsp, target_buf, sizeof(struct target_tms)); + } + if (!is_error(ret)) { + ret = host_to_target_clock_t(ret); + } + return ret; +} + /* * Map host to target signal numbers for the wait family of syscalls. * Assume all other status bits are the same. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cda1f8a205..cdca0dbe4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5346,24 +5346,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_times: - { - struct target_tms *tmsp; - struct tms tms; - ret = get_errno(times(&tms)); - if (arg1) { - tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); - if (!tmsp) - return -TARGET_EFAULT; - tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); - tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); - tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); - tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); - } - if (!is_error(ret)) - ret = host_to_target_clock_t(ret); - } - return ret; case TARGET_NR_acct: if (arg1 == 0) { ret = get_errno(acct(NULL)); diff --git a/linux-user/strace.list b/linux-user/strace.list index a1c3dd98e0..85e3de87d8 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1290,9 +1290,6 @@ #ifdef TARGET_NR_timerfd_settime { TARGET_NR_timerfd_settime, "timerfd_settime" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_times -{ TARGET_NR_times, "times" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_tkill { TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL }, #endif From patchwork Sun May 19 20:36:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164534 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4802215ili; Sun, 19 May 2019 14:13:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTDihQOEPQ8MWzwJAl74G1NeFOA/4rwEHl4aCT8PyZDNuzqOrN/XxgbtLAHQ6BYiWriokM X-Received: by 2002:a17:906:7d16:: with SMTP id u22mr36190469ejo.85.1558300408614; Sun, 19 May 2019 14:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300408; cv=none; d=google.com; s=arc-20160816; b=Byc6lSleuqklI8j1Yoo4drbF8SoqNlVPy1Z/OQznuSZLKtJjpLVFDkFB4IUeheu2dF vqeoMPWfJf4rpMdM29q+JCF1sy+fzRVMH97iQEv5XvkbAmLU5m3M/waWk4Y06VIheuMz qx0XqY7fuZHnNA2vNjYTead14fvr4psdoSPZHWKQ/VLer3KCs2hhVDEQ7W0Qciru8UXy G6p1usxptQ5rUsS+aNUIdWfR1Dbcoil0iCdoA7ufpTuv/fk2Zrz++SlQ2N45WMcy04i5 Q+x9LW++zNaIjwjOtKhJV/wLi80m8cOpyAahopNdx/ep8vzYTPBI/RXlyAgin+3qFOVH UfnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zxww4ylhQcPO6FqWBn/qpIs5WYaAwpNI1B5WcIoosKI=; b=KNTWxhCVXFyE8h74MGR1YYsMb3sNJtwTQK8+OG5J1tkrmzTMqfnFiyM5DnmFONiIl+ B5xx6cDMGstA+PruswvXcfF1GdBYlBKksWMXBmh4W8xui4KJGfZxPGUnfkKNgPWuOF/H +Xyz9Oc2CoTprtk0Wb0Jf1t/j+WyY+UHCmzVPJiYoA6KZvhxdKgSdZTf1RTTpSpaX2Up azJ1IRBdNQh85KKdRWU/p1wNNnMuPeRAR+Qnk5Rjml1/XkKw7vz/SDWL5AOkMeRxq0lI uNHhifncnXQtO6fFOZHprfOhhJDzUDsC+7fB81cC2copO2ItB+Ir/0HSM61i/jR6cj0K pboQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Tln0sEur; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i26si7408281ejc.361.2019.05.19.14.13.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Tln0sEur; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST7X-0000Of-Fi for patch@linaro.org; Sun, 19 May 2019 17:13:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZh-0003hL-I5 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZg-0004Ve-7E for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:29 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:37308) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZf-0004Tp-U8 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:28 -0400 Received: by mail-pg1-x541.google.com with SMTP id n27so3140019pgm.4 for ; Sun, 19 May 2019 13:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zxww4ylhQcPO6FqWBn/qpIs5WYaAwpNI1B5WcIoosKI=; b=Tln0sEurgF+JnTziJnpUITbTY8QogpEjvYOfZlbhDzbziVqwoDEtegx/uwT8JmZPQx l14/qnDJ8G0SHw4O7VVXnyu1AHjaAiDq1Wprdh7oGUWZOn0noAitgN62lAlBl6wly1gd 5vAwwGtWjXJWPQ1U4T05RrzG4cXOcnvQE2KKGx7l7nRDGCI0ffATzqvMYnHuSYgYUl9n P6SpkjVT4toExsxO9boPA0wEP//7eAwaQ9VosA88ciaDiFdBplZhJ9TlsUgFpYaEA/Sm 64uARjnQtGPoLlQsqZACfoTwoaUVh6wthoxcLtWzx2PjK02ayN1YZwmD7WEMatwkUcLG TsIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zxww4ylhQcPO6FqWBn/qpIs5WYaAwpNI1B5WcIoosKI=; b=j1wjiWOEphBkKvTaDQeq4XY8Gi9aeftAKx8yQ12Mcq2vRxvli0lQToaAQaeob8IYhJ X0+uTm9KLpUU2utOPcbBvFzN7rmJARzCSlW6gI61bMnRmZeLYjih64wLFAfEggs4uUZ9 pqjegLeb3U/1oi0NQuRnhtTdKLrpyYunKgY0DMuo95Lh7jpM4/qstEXKH1Suu6KY6zoB w9vhZveJBHRarfSliCSxbDz1c63bBoHSuktXxSydyVzuJv1Ik/dKsmXnnsl/AJPtxsna MJ1szd/OLsqrQfSaLq/tNoDCtqlSX9g3Ap4QPO8Rc6wh9HT7Lv8bGXBSyuMdlz8WS29A 3NHw== X-Gm-Message-State: APjAAAUVjDaoC1DdMvnB/vAfZ77SyPXZgAdaGe9acaF+Z2VHVfURR7af hHepJFmgmQYwkqeKDhYQ/tvOYb3tdO0= X-Received: by 2002:a63:5726:: with SMTP id l38mr10616007pgb.344.1558298306631; Sun, 19 May 2019 13:38:26 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:57 -0700 Message-Id: <20190519203726.20729-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v7 45/74] linux-user: Split out acct X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-file.inc.c | 18 ++++++++++++++++++ linux-user/syscall.c | 11 ----------- linux-user/strace.list | 3 --- 4 files changed, 19 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 25d5aaccd1..f8f280f376 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -19,6 +19,7 @@ #ifdef TARGET_NR_access SYSCALL_DEF(access, ARG_STR, ARG_ACCESSFLAG); #endif +SYSCALL_DEF(acct, ARG_STR); #ifdef TARGET_NR_alarm SYSCALL_DEF(alarm, ARG_DEC); #endif diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 5bd9eaa002..4080ab250e 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -36,6 +36,24 @@ SYSCALL_IMPL(access) } #endif +SYSCALL_IMPL(acct) +{ + abi_ulong target_path = arg1; + abi_long ret; + + if (target_path == 0) { + ret = get_errno(acct(NULL)); + } else { + char *p = lock_user_string(target_path); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(acct(path(p))); + unlock_user(p, target_path, 0); + } + return ret; +} + SYSCALL_IMPL(chdir) { abi_ulong target_path = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cdca0dbe4f..5343486a58 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5346,17 +5346,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_acct: - if (arg1 == 0) { - ret = get_errno(acct(NULL)); - } else { - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(acct(path(p))); - unlock_user(p, arg1, 0); - } - return ret; case TARGET_NR_ioctl: return do_ioctl(arg1, arg2, arg3); #ifdef TARGET_NR_fcntl diff --git a/linux-user/strace.list b/linux-user/strace.list index 85e3de87d8..ce5e02975b 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -9,9 +9,6 @@ #ifdef TARGET_NR_accept4 { TARGET_NR_accept4, "accept4" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_acct -{ TARGET_NR_acct, "acct" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_add_key { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:36:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164530 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4799070ili; Sun, 19 May 2019 14:09:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqytQMvMe3cePYyXbSvhqhf8g2F1TFObHRhREkCH7txC5edsS3Mg+2YunTz9suJZNtOBfrAm X-Received: by 2002:a05:6402:16d2:: with SMTP id r18mr71164774edx.261.1558300152135; Sun, 19 May 2019 14:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300152; cv=none; d=google.com; s=arc-20160816; b=VH1xr7Vf0ItkKtAXqU3CCDxcz5alYzIJZcIDk2Z1heKN77EBki6in8AfFveZVbOk+v ve1EhaDSvqCUDxdKB5qwyA0Mit+giukubW0R5RkdH+bZ6YLa53LI3rqEFuIgeEL4TdCQ RmulgIknIBRS1jsHnPPP//GIYKJAT7Z98iMzd/aPggOi3Pp/1firDPB/mC90qiQZf1TQ CU0+Mh/+c7WDSkUt9H0HnoHXFNGGy49SBDMWVudNb+/MnNXjxb4OnCQ/d4hxahLYArAF a4XivuxRdGdkmBGdppGFknIr6RsuF/YFkTmJlQaD0YaoNeUhFpoyQGKv0J9Vv6FGMnk7 MTtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AI0qmlYjgj5NtbNVWKgQPuyo9CkZotUm28Hs9oy8FWY=; b=rVVQazGsq/FcNKiL1QwrAeL6qLh+eI4BVpAUMkoKApV8y+YoB0QzeQY7Q2xCfkwuG5 d2PC0YeRXYobLT7E6I9MSQuITfC7EI+lcbr2cBrRU6eb0CWbuirIGK4LLxcB14FjHfeg Ahcc6lXsY1BuJasvxtJUC0+3JJ6EYFX/R5CWxLSJp83wGQCLnavVJU9QeCUMyBX9Ra+2 3kM5W8IpSLz4zN6EPxo6shBAn7AbrCjntu5yuJFHXqykNpfpZoNKOm78D4SONSL2dx1q ZTcEaMRbVAZxybo0iN2lK48NidQMVMK8glyz1IIzw9s1h8TWdpg/wN1vKYmFeOI3398v 7hng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WDiAzAWB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j15si9790264ejz.123.2019.05.19.14.09.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WDiAzAWB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST3O-0004T2-Uc for patch@linaro.org; Sun, 19 May 2019 17:09:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZi-0003ie-Qj for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZh-0004X3-BL for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:30 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44713) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZh-0004W5-1T for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:29 -0400 Received: by mail-pg1-x542.google.com with SMTP id z16so5724088pgv.11 for ; Sun, 19 May 2019 13:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AI0qmlYjgj5NtbNVWKgQPuyo9CkZotUm28Hs9oy8FWY=; b=WDiAzAWBoYrx+T/f1r514LVxPvjELJd8UIHCR8Cr8GWYn5WVntha55DkeNUQE2z2we MUbkuYQJaFCBtmdTgMwFMXQ2X7B90J1yR5s6SH7Wi1RUTybLjBW8goKWVwx8bYaWYgue /GwLb2E3sSQaxM54uduTRpK2wCApQob7Bzz0+mZ7aLegGqB1TlZrif2klOcWj536pjxb b+D6ziPYs4LyMAdkfXVWP0/82RHPlVtj/fLTMHroupF0IE3Ee4jez40ZB7A0e2EsGN4R iQPYXqjqlvNjUcVV4iMz7yYqHtvjCBO9mmOj/024MkRRBcjR+gYroI/d0urevPElf53n LH9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AI0qmlYjgj5NtbNVWKgQPuyo9CkZotUm28Hs9oy8FWY=; b=D0YHcSGPTEDdcxVmrbhUlY3vjmj/oLB2ZtoNWE4iJdVtBjuAZU9ONv0Yyi93glDK/R Z/x6HJdhPo4Gf8UKQX4+nQf2wycJZrc+hyDiHVgE4O7MbxwG2TqAbb5d8vNVJxMEu0rr VjB6mF/y9Lsp8Vma2Z8ic3ZxuvYzg1Hrz2aNt9Ig48Hvx+cFhHT4aJHufaIE/WSPLVAB xDTpYkjyCVHUhdBBC54nYf1V9EDck05bg2HQxAjWvYUIH3WM0ge3pgmwol6irkZrsi7x kvKGXsmetBif8uP0hwVH3TxH7UHjD7Z7HbHA0wYjpWa+HXeFUB3aJUUiPksEZTjTAkPp GhSg== X-Gm-Message-State: APjAAAUVjXgH6Tkd+/kYVlnglU54KfpwoOfzZwwkghmG75tksGBogSqV RbAfDyXSpwLJfn12DCr4Hi1EUBBoDDI= X-Received: by 2002:a63:4346:: with SMTP id q67mr71033800pga.241.1558298307785; Sun, 19 May 2019 13:38:27 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:58 -0700 Message-Id: <20190519203726.20729-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v7 46/74] linux-user: Move syscall_init to the end X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" No functional change. This will aid moving everything related to ioctls to a separate file. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 113 +++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 52 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5343486a58..d0e76c392e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4831,58 +4831,6 @@ _syscall1(int, sys_setgid, gid_t, gid) _syscall3(int, sys_setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) _syscall3(int, sys_setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) -void syscall_init(void) -{ - IOCTLEntry *ie; - const argtype *arg_type; - int size; - int i; - - thunk_init(STRUCT_MAX); - -#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def); -#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def); -#include "syscall_types.h" -#undef STRUCT -#undef STRUCT_SPECIAL - - /* Build target_to_host_errno_table[] table from - * host_to_target_errno_table[]. */ - for (i = 0; i < ERRNO_TABLE_SIZE; i++) { - target_to_host_errno_table[host_to_target_errno_table[i]] = i; - } - - /* we patch the ioctl size if necessary. We rely on the fact that - no ioctl has all the bits at '1' in the size field */ - ie = ioctl_entries; - while (ie->target_cmd != 0) { - if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == - TARGET_IOC_SIZEMASK) { - arg_type = ie->arg_type; - if (arg_type[0] != TYPE_PTR) { - fprintf(stderr, "cannot patch size for ioctl 0x%x\n", - ie->target_cmd); - exit(1); - } - arg_type++; - size = thunk_type_size(arg_type, 0); - ie->target_cmd = (ie->target_cmd & - ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) | - (size << TARGET_IOC_SIZESHIFT); - } - - /* automatic consistency check if same arch */ -#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \ - (defined(__x86_64__) && defined(TARGET_X86_64)) - if (unlikely(ie->target_cmd != ie->host_cmd)) { - fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n", - ie->name, ie->target_cmd, ie->host_cmd); - } -#endif - ie++; - } -} - static inline uint64_t target_offset64(abi_ulong word0, abi_ulong word1) { #if TARGET_ABI_BITS == 64 @@ -9072,3 +9020,64 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, trace_guest_user_syscall_ret(cpu, num, ret); return ret; } + +void syscall_init(void) +{ + IOCTLEntry *ie; + const argtype *arg_type; + int size; + int i; + + thunk_init(STRUCT_MAX); + +#define STRUCT(name, ...) \ + thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def); +#define STRUCT_SPECIAL(name) \ + thunk_register_struct_direct(STRUCT_ ## name, #name, \ + &struct_ ## name ## _def); + +#include "syscall_types.h" + +#undef STRUCT +#undef STRUCT_SPECIAL + + /* + * Build target_to_host_errno_table[] table from + * host_to_target_errno_table[]. + */ + for (i = 0; i < ERRNO_TABLE_SIZE; i++) { + target_to_host_errno_table[host_to_target_errno_table[i]] = i; + } + + /* + * We patch the ioctl size if necessary. We rely on the fact that + * no ioctl has all the bits at '1' in the size field. + */ + ie = ioctl_entries; + while (ie->target_cmd != 0) { + if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == + TARGET_IOC_SIZEMASK) { + arg_type = ie->arg_type; + if (arg_type[0] != TYPE_PTR) { + fprintf(stderr, "cannot patch size for ioctl 0x%x\n", + ie->target_cmd); + exit(1); + } + arg_type++; + size = thunk_type_size(arg_type, 0); + ie->target_cmd = (ie->target_cmd & + ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) | + (size << TARGET_IOC_SIZESHIFT); + } + + /* automatic consistency check if same arch */ +#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \ + (defined(__x86_64__) && defined(TARGET_X86_64)) + if (unlikely(ie->target_cmd != ie->host_cmd)) { + fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n", + ie->name, ie->target_cmd, ie->host_cmd); + } +#endif + ie++; + } +} From patchwork Sun May 19 20:36:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164540 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4805100ili; Sun, 19 May 2019 14:17:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeqY2hHOcKPsphulI19plxXZYr2S0Vf27CffR03vWGdKnB+hhf209UfWam2veQn9nJgDbm X-Received: by 2002:a17:906:a3d7:: with SMTP id ca23mr23496658ejb.23.1558300644550; Sun, 19 May 2019 14:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300644; cv=none; d=google.com; s=arc-20160816; b=ea6LodJyJSlaA+hxz6CFClOC6rDR+jt8CHdmeR9NYpFOiu/76QgMI8ZjerA/2Ds8Dr Tnvpk/5rv5mhrvv4kEK1OkpNdSxhT4MK761TWlWkdUN4LAUyoXQyXQHhk2/BHWokbZKG p4OhmAxjE67wgG9KdZcpIAw3kuY6ZuXak6LJ3KUO6U59lq3KaPzW9KmTZQdytGEFcHgo Z8o6cpFn5HvhMuWJFbZUEbdZu2Xbxpzixko9ZG05irdwcdLGgwpsggGrUl9MXdcxEKbx WcpUG90RWRbkA79xy7E8qJn1hUWk5Rx70Eu6uQUzoOxX1rzsKD38R4glVwJ9qJP81xZG m4WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=iP3/CNN5zTtN5TgGZJCg5VKq0GbEgLMrSCvjo5Au37s=; b=0ksH+T12ySxPZb9dtuyDuDeQeBzW50yYnEgzHcycwQz3AO0wq5iN7FDBLRnFIx8ZGD LbrN2eTbB3hHwc277WaD82W8tzUP/0t6mIVIGA642q9jbRob9+smFvrqtOFVJDrSUC/l mBhHTxqhtg2PJI4x/jdkmz0VtemWyHGu20fMfjak6xXZth5uxdpBsiaTcmMwqHGXxXni S0bJJlbuE/on1cwbTYDmE9kr+hsMAsVCjyBtLVzrh8OGuYXxBp7C/OH9FhLrpRly9NZR eMWcPKtdt/S4ojdxl6kwvXaTipZ6TuGOa/k4pFDNmSrLVRJcC3d/a9dpikjuis9JfSq5 ovuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mqleqw9b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b56si600234edc.450.2019.05.19.14.17.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:17:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mqleqw9b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTBL-0003th-4j for patch@linaro.org; Sun, 19 May 2019 17:17:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZo-0003oH-9E for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZj-0004ZI-8i for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:36 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:41411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZi-0004Y7-Pl for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:31 -0400 Received: by mail-pl1-x644.google.com with SMTP id f12so5707270plt.8 for ; Sun, 19 May 2019 13:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iP3/CNN5zTtN5TgGZJCg5VKq0GbEgLMrSCvjo5Au37s=; b=mqleqw9bxzXB15Ae63IyBO9zF5opmZmA1z4kVjIK9dGIKhmLSoVZKDAO1mtnV6oPRD 14SF+B7uGpOsUaMMIK7X79xzEBFVO1gfm0H/TH5z6r+zaef6yTznVmdmWK62gbmPLuF/ YGIiuKbnv8acUuWxnDKNQpRCMBdcZcfgEAlxWEkkJet43pWRC3/zvYm28ND6LDlhGQyN BqiDwguu6TLOdhAiho+4TR4nnFqWFYmM6RI7zKcusblY7ZPXk7jwPCQ1xBOr3j95uB0e CXn7CJZ+3ZtIHhLpLKbCDpjvfqkhJJPBMayrXcJ1bJHy/kHU//0nHXRugKzCxWnL72Sc 0C6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iP3/CNN5zTtN5TgGZJCg5VKq0GbEgLMrSCvjo5Au37s=; b=ocoQaeE923u9+tDL6isIRxJI85ELpsz7lxhVGp/dPbViiZbI4Kdn6fS5rM96VEIKbs 5h3A1Q9aI+zZg/aDc17HNb8iVNKkYco3sACaWo2nv5fYikeGgiDvV2pKeFyXjNPpOz9T ogs2NuEyUHlQGXB96ctgpEtw5t5F69P4QRn+WnS898PjDAdswKPK/R7H+wX6nO6mXtYX ND2di5OxG1f2F8Pf906Y4PVqO4G5Is1gbG/cN/75Ac1rIsQ6116yFsAT+nrTsSmsNeM/ AZIhK/1mOdaMwzkcqQc/fDmm5ejMIqVF2CiyuPGq2qRbJ+h/f74j9MkzPUZ3VBREqJ/4 LTmg== X-Gm-Message-State: APjAAAWnDIM4uRaz5pOO1vuSreu/0Fs+vxNKm3K94AStifD2XaPqkpXo 3LJneOWpr1fN+N8uqNRt/1zlluRZ4G0= X-Received: by 2002:a17:902:74c6:: with SMTP id f6mr13666125plt.335.1558298308905; Sun, 19 May 2019 13:38:28 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:59 -0700 Message-Id: <20190519203726.20729-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH v7 47/74] linux-user: Split out ioctl X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- v7: Do not accidentally change type of "cmd". --- linux-user/syscall-defs.h | 1 + linux-user/syscall-ioctl.inc.c | 873 +++++++++++++++++++++++++++++++++ linux-user/syscall.c | 852 +------------------------------- linux-user/strace.list | 3 - 4 files changed, 875 insertions(+), 854 deletions(-) create mode 100644 linux-user/syscall-ioctl.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index f8f280f376..f58b9745a4 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -61,6 +61,7 @@ SYSCALL_DEF(getppid); #ifdef TARGET_NR_getxpid SYSCALL_DEF(getxpid); #endif +SYSCALL_DEF(ioctl, ARG_DEC, ARG_HEX); #ifdef TARGET_NR_ipc SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX); #endif diff --git a/linux-user/syscall-ioctl.inc.c b/linux-user/syscall-ioctl.inc.c new file mode 100644 index 0000000000..be3f0b4b92 --- /dev/null +++ b/linux-user/syscall-ioctl.inc.c @@ -0,0 +1,873 @@ +/* + * Linux ioctl syscall implementation + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +typedef struct IOCTLEntry IOCTLEntry; + +typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg); + +struct IOCTLEntry { + int target_cmd; + unsigned int host_cmd; + const char *name; + int access; + do_ioctl_fn *do_ioctl; + const argtype arg_type[5]; +}; + +#define IOC_R 0x0001 +#define IOC_W 0x0002 +#define IOC_RW (IOC_R | IOC_W) + +#define MAX_STRUCT_SIZE 4096 + +#ifdef CONFIG_FIEMAP +/* + * So fiemap access checks don't overflow on 32 bit systems. + * This is very slightly smaller than the limit imposed by + * the underlying kernel. + */ +#define FIEMAP_MAX_EXTENTS ((UINT_MAX - sizeof(struct fiemap)) \ + / sizeof(struct fiemap_extent)) + +static abi_long do_ioctl_fs_ioc_fiemap(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + /* + * The parameter for this ioctl is a struct fiemap followed + * by an array of struct fiemap_extent whose size is set + * in fiemap->fm_extent_count. The array is filled in by the + * ioctl. + */ + int target_size_in, target_size_out; + struct fiemap *fm; + const argtype *arg_type = ie->arg_type; + const argtype extent_arg_type[] = { MK_STRUCT(STRUCT_fiemap_extent) }; + void *argptr, *p; + abi_long ret; + int i, extent_size = thunk_type_size(extent_arg_type, 0); + uint32_t outbufsz; + int free_fm = 0; + + assert(arg_type[0] == TYPE_PTR); + assert(ie->access == IOC_RW); + arg_type++; + target_size_in = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg, target_size_in, 1); + if (!argptr) { + return -TARGET_EFAULT; + } + thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + fm = (struct fiemap *)buf_temp; + if (fm->fm_extent_count > FIEMAP_MAX_EXTENTS) { + return -TARGET_EINVAL; + } + + outbufsz = sizeof(*fm) + sizeof(struct fiemap_extent) * fm->fm_extent_count; + + if (outbufsz > MAX_STRUCT_SIZE) { + /* + * We can't fit all the extents into the fixed size buffer. + * Allocate one that is large enough and use it instead. + */ + fm = g_try_malloc(outbufsz); + if (!fm) { + return -TARGET_ENOMEM; + } + memcpy(fm, buf_temp, sizeof(struct fiemap)); + free_fm = 1; + } + ret = get_errno(safe_ioctl(fd, ie->host_cmd, fm)); + if (!is_error(ret)) { + target_size_out = target_size_in; + /* + * An extent_count of 0 means we were only counting the extents + * so there are no structs to copy + */ + if (fm->fm_extent_count != 0) { + target_size_out += fm->fm_mapped_extents * extent_size; + } + argptr = lock_user(VERIFY_WRITE, arg, target_size_out, 0); + if (!argptr) { + ret = -TARGET_EFAULT; + } else { + /* Convert the struct fiemap */ + thunk_convert(argptr, fm, arg_type, THUNK_TARGET); + if (fm->fm_extent_count != 0) { + p = argptr + target_size_in; + /* ...and then all the struct fiemap_extents */ + for (i = 0; i < fm->fm_mapped_extents; i++) { + thunk_convert(p, &fm->fm_extents[i], extent_arg_type, + THUNK_TARGET); + p += extent_size; + } + } + unlock_user(argptr, arg, target_size_out); + } + } + if (free_fm) { + g_free(fm); + } + return ret; +} +#endif + +static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + const argtype *arg_type = ie->arg_type; + int target_size; + void *argptr; + int ret; + struct ifconf *host_ifconf; + uint32_t outbufsz; + const argtype ifreq_arg_type[] = { MK_STRUCT(STRUCT_sockaddr_ifreq) }; + int target_ifreq_size; + int nb_ifreq; + int free_buf = 0; + int i; + int target_ifc_len; + abi_long target_ifc_buf; + int host_ifc_len; + char *host_ifc_buf; + + assert(arg_type[0] == TYPE_PTR); + assert(ie->access == IOC_RW); + + arg_type++; + target_size = thunk_type_size(arg_type, 0); + + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + return -TARGET_EFAULT; + } + thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + + host_ifconf = (struct ifconf *)(unsigned long)buf_temp; + target_ifc_len = host_ifconf->ifc_len; + target_ifc_buf = (abi_long)(unsigned long)host_ifconf->ifc_buf; + + target_ifreq_size = thunk_type_size(ifreq_arg_type, 0); + nb_ifreq = target_ifc_len / target_ifreq_size; + host_ifc_len = nb_ifreq * sizeof(struct ifreq); + + outbufsz = sizeof(*host_ifconf) + host_ifc_len; + if (outbufsz > MAX_STRUCT_SIZE) { + /* + * We can't fit all the extents into the fixed size buffer. + * Allocate one that is large enough and use it instead. + */ + host_ifconf = malloc(outbufsz); + if (!host_ifconf) { + return -TARGET_ENOMEM; + } + memcpy(host_ifconf, buf_temp, sizeof(*host_ifconf)); + free_buf = 1; + } + host_ifc_buf = (char *)host_ifconf + sizeof(*host_ifconf); + + host_ifconf->ifc_len = host_ifc_len; + host_ifconf->ifc_buf = host_ifc_buf; + + ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_ifconf)); + if (!is_error(ret)) { + /* convert host ifc_len to target ifc_len */ + + nb_ifreq = host_ifconf->ifc_len / sizeof(struct ifreq); + target_ifc_len = nb_ifreq * target_ifreq_size; + host_ifconf->ifc_len = target_ifc_len; + + /* restore target ifc_buf */ + + host_ifconf->ifc_buf = (char *)(unsigned long)target_ifc_buf; + + /* copy struct ifconf to target user */ + + argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); + if (!argptr) { + return -TARGET_EFAULT; + } + thunk_convert(argptr, host_ifconf, arg_type, THUNK_TARGET); + unlock_user(argptr, arg, target_size); + + /* copy ifreq[] to target user */ + + argptr = lock_user(VERIFY_WRITE, target_ifc_buf, target_ifc_len, 0); + for (i = 0; i < nb_ifreq ; i++) { + thunk_convert(argptr + i * target_ifreq_size, + host_ifc_buf + i * sizeof(struct ifreq), + ifreq_arg_type, THUNK_TARGET); + } + unlock_user(argptr, target_ifc_buf, target_ifc_len); + } + + if (free_buf) { + free(host_ifconf); + } + + return ret; +} + +#if defined(CONFIG_USBFS) +#if HOST_LONG_BITS > 64 +#error USBDEVFS thunks do not support >64 bit hosts yet. +#endif +struct live_urb { + uint64_t target_urb_adr; + uint64_t target_buf_adr; + char *target_buf_ptr; + struct usbdevfs_urb host_urb; +}; + +static GHashTable *usbdevfs_urb_hashtable(void) +{ + static GHashTable *urb_hashtable; + + if (!urb_hashtable) { + urb_hashtable = g_hash_table_new(g_int64_hash, g_int64_equal); + } + return urb_hashtable; +} + +static void urb_hashtable_insert(struct live_urb *urb) +{ + GHashTable *urb_hashtable = usbdevfs_urb_hashtable(); + g_hash_table_insert(urb_hashtable, urb, urb); +} + +static struct live_urb *urb_hashtable_lookup(uint64_t target_urb_adr) +{ + GHashTable *urb_hashtable = usbdevfs_urb_hashtable(); + return g_hash_table_lookup(urb_hashtable, &target_urb_adr); +} + +static void urb_hashtable_remove(struct live_urb *urb) +{ + GHashTable *urb_hashtable = usbdevfs_urb_hashtable(); + g_hash_table_remove(urb_hashtable, urb); +} + +static abi_long +do_ioctl_usbdevfs_reapurb(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + const argtype usbfsurb_arg_type[] = { MK_STRUCT(STRUCT_usbdevfs_urb) }; + const argtype ptrvoid_arg_type[] = { TYPE_PTRVOID, 0, 0 }; + struct live_urb *lurb; + void *argptr; + uint64_t hurb; + int target_size; + uintptr_t target_urb_adr; + abi_long ret; + + target_size = thunk_type_size(usbfsurb_arg_type, THUNK_TARGET); + + memset(buf_temp, 0, sizeof(uint64_t)); + ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); + if (is_error(ret)) { + return ret; + } + + memcpy(&hurb, buf_temp, sizeof(uint64_t)); + lurb = (void *)((uintptr_t)hurb - offsetof(struct live_urb, host_urb)); + if (!lurb->target_urb_adr) { + return -TARGET_EFAULT; + } + urb_hashtable_remove(lurb); + unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, + lurb->host_urb.buffer_length); + lurb->target_buf_ptr = NULL; + + /* restore the guest buffer pointer */ + lurb->host_urb.buffer = (void *)(uintptr_t)lurb->target_buf_adr; + + /* update the guest urb struct */ + argptr = lock_user(VERIFY_WRITE, lurb->target_urb_adr, target_size, 0); + if (!argptr) { + g_free(lurb); + return -TARGET_EFAULT; + } + thunk_convert(argptr, &lurb->host_urb, usbfsurb_arg_type, THUNK_TARGET); + unlock_user(argptr, lurb->target_urb_adr, target_size); + + target_size = thunk_type_size(ptrvoid_arg_type, THUNK_TARGET); + /* write back the urb handle */ + argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); + if (!argptr) { + g_free(lurb); + return -TARGET_EFAULT; + } + + /* GHashTable uses 64-bit keys but thunk_convert expects uintptr_t */ + target_urb_adr = lurb->target_urb_adr; + thunk_convert(argptr, &target_urb_adr, ptrvoid_arg_type, THUNK_TARGET); + unlock_user(argptr, arg, target_size); + + g_free(lurb); + return ret; +} + +static abi_long +do_ioctl_usbdevfs_discardurb(const IOCTLEntry *ie, + uint8_t *buf_temp __attribute__((unused)), + int fd, int cmd, abi_long arg) +{ + struct live_urb *lurb; + + /* map target address back to host URB with metadata. */ + lurb = urb_hashtable_lookup(arg); + if (!lurb) { + return -TARGET_EFAULT; + } + return get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); +} + +static abi_long +do_ioctl_usbdevfs_submiturb(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + const argtype *arg_type = ie->arg_type; + int target_size; + abi_long ret; + void *argptr; + int rw_dir; + struct live_urb *lurb; + + /* + * each submitted URB needs to map to a unique ID for the + * kernel, and that unique ID needs to be a pointer to + * host memory. hence, we need to malloc for each URB. + * isochronous transfers have a variable length struct. + */ + arg_type++; + target_size = thunk_type_size(arg_type, THUNK_TARGET); + + /* construct host copy of urb and metadata */ + lurb = g_try_malloc0(sizeof(struct live_urb)); + if (!lurb) { + return -TARGET_ENOMEM; + } + + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + g_free(lurb); + return -TARGET_EFAULT; + } + thunk_convert(&lurb->host_urb, argptr, arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + + lurb->target_urb_adr = arg; + lurb->target_buf_adr = (uintptr_t)lurb->host_urb.buffer; + + /* buffer space used depends on endpoint type so lock the entire buffer */ + /* control type urbs should check the buffer contents for true direction */ + rw_dir = lurb->host_urb.endpoint & USB_DIR_IN ? VERIFY_WRITE : VERIFY_READ; + lurb->target_buf_ptr = lock_user(rw_dir, lurb->target_buf_adr, + lurb->host_urb.buffer_length, 1); + if (lurb->target_buf_ptr == NULL) { + g_free(lurb); + return -TARGET_EFAULT; + } + + /* update buffer pointer in host copy */ + lurb->host_urb.buffer = lurb->target_buf_ptr; + + ret = get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); + if (is_error(ret)) { + unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, 0); + g_free(lurb); + } else { + urb_hashtable_insert(lurb); + } + + return ret; +} +#endif /* CONFIG_USBFS */ + +static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, + int cmd, abi_long arg) +{ + void *argptr; + struct dm_ioctl *host_dm; + abi_long guest_data; + uint32_t guest_data_size; + int target_size; + const argtype *arg_type = ie->arg_type; + abi_long ret; + void *big_buf = NULL; + char *host_data; + + arg_type++; + target_size = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + ret = -TARGET_EFAULT; + goto out; + } + thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + + /* buf_temp is too small, so fetch things into a bigger buffer */ + big_buf = g_malloc0(((struct dm_ioctl *)buf_temp)->data_size * 2); + memcpy(big_buf, buf_temp, target_size); + buf_temp = big_buf; + host_dm = big_buf; + + guest_data = arg + host_dm->data_start; + if ((guest_data - arg) < 0) { + ret = -TARGET_EINVAL; + goto out; + } + guest_data_size = host_dm->data_size - host_dm->data_start; + host_data = (char *)host_dm + host_dm->data_start; + + argptr = lock_user(VERIFY_READ, guest_data, guest_data_size, 1); + if (!argptr) { + ret = -TARGET_EFAULT; + goto out; + } + + switch (ie->host_cmd) { + case DM_REMOVE_ALL: + case DM_LIST_DEVICES: + case DM_DEV_CREATE: + case DM_DEV_REMOVE: + case DM_DEV_SUSPEND: + case DM_DEV_STATUS: + case DM_DEV_WAIT: + case DM_TABLE_STATUS: + case DM_TABLE_CLEAR: + case DM_TABLE_DEPS: + case DM_LIST_VERSIONS: + /* no input data */ + break; + case DM_DEV_RENAME: + case DM_DEV_SET_GEOMETRY: + /* data contains only strings */ + memcpy(host_data, argptr, guest_data_size); + break; + case DM_TARGET_MSG: + memcpy(host_data, argptr, guest_data_size); + *(uint64_t *)host_data = tswap64(*(uint64_t *)argptr); + break; + case DM_TABLE_LOAD: + { + void *gspec = argptr; + void *cur_data = host_data; + const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) }; + int spec_size = thunk_type_size(arg_type, 0); + int i; + + for (i = 0; i < host_dm->target_count; i++) { + struct dm_target_spec *spec = cur_data; + uint32_t next; + int slen; + + thunk_convert(spec, gspec, arg_type, THUNK_HOST); + slen = strlen((char *)gspec + spec_size) + 1; + next = spec->next; + spec->next = sizeof(*spec) + slen; + strcpy((char *)&spec[1], gspec + spec_size); + gspec += next; + cur_data += spec->next; + } + break; + } + default: + ret = -TARGET_EINVAL; + unlock_user(argptr, guest_data, 0); + goto out; + } + unlock_user(argptr, guest_data, 0); + + ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); + if (!is_error(ret)) { + guest_data = arg + host_dm->data_start; + guest_data_size = host_dm->data_size - host_dm->data_start; + argptr = lock_user(VERIFY_WRITE, guest_data, guest_data_size, 0); + switch (ie->host_cmd) { + case DM_REMOVE_ALL: + case DM_DEV_CREATE: + case DM_DEV_REMOVE: + case DM_DEV_RENAME: + case DM_DEV_SUSPEND: + case DM_DEV_STATUS: + case DM_TABLE_LOAD: + case DM_TABLE_CLEAR: + case DM_TARGET_MSG: + case DM_DEV_SET_GEOMETRY: + /* no return data */ + break; + case DM_LIST_DEVICES: + { + struct dm_name_list *nl = (void *)host_dm + host_dm->data_start; + uint32_t remaining_data = guest_data_size; + void *cur_data = argptr; + const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) }; + int nl_size = 12; /* can't use thunk_size due to alignment */ + + while (1) { + uint32_t next = nl->next; + if (next) { + nl->next = nl_size + (strlen(nl->name) + 1); + } + if (remaining_data < nl->next) { + host_dm->flags |= DM_BUFFER_FULL_FLAG; + break; + } + thunk_convert(cur_data, nl, arg_type, THUNK_TARGET); + strcpy(cur_data + nl_size, nl->name); + cur_data += nl->next; + remaining_data -= nl->next; + if (!next) { + break; + } + nl = (void *)nl + next; + } + break; + } + case DM_DEV_WAIT: + case DM_TABLE_STATUS: + { + struct dm_target_spec *spec + = (void *)host_dm + host_dm->data_start; + void *cur_data = argptr; + const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) }; + int spec_size = thunk_type_size(arg_type, 0); + int i; + + for (i = 0; i < host_dm->target_count; i++) { + uint32_t next = spec->next; + int slen = strlen((char *)&spec[1]) + 1; + spec->next = (cur_data - argptr) + spec_size + slen; + if (guest_data_size < spec->next) { + host_dm->flags |= DM_BUFFER_FULL_FLAG; + break; + } + thunk_convert(cur_data, spec, arg_type, THUNK_TARGET); + strcpy(cur_data + spec_size, (char *)&spec[1]); + cur_data = argptr + spec->next; + spec = (void *)host_dm + host_dm->data_start + next; + } + break; + } + case DM_TABLE_DEPS: + { + void *hdata = (void *)host_dm + host_dm->data_start; + int count = *(uint32_t *)hdata; + uint64_t *hdev = hdata + 8; + uint64_t *gdev = argptr + 8; + int i; + + *(uint32_t *)argptr = tswap32(count); + for (i = 0; i < count; i++) { + *gdev = tswap64(*hdev); + gdev++; + hdev++; + } + break; + } + case DM_LIST_VERSIONS: + { + struct dm_target_versions *vers + = (void *)host_dm + host_dm->data_start; + uint32_t remaining_data = guest_data_size; + void *cur_data = argptr; + const argtype arg_type[] + = { MK_STRUCT(STRUCT_dm_target_versions) }; + int vers_size = thunk_type_size(arg_type, 0); + + while (1) { + uint32_t next = vers->next; + if (next) { + vers->next = vers_size + strlen(vers->name) + 1; + } + if (remaining_data < vers->next) { + host_dm->flags |= DM_BUFFER_FULL_FLAG; + break; + } + thunk_convert(cur_data, vers, arg_type, THUNK_TARGET); + strcpy(cur_data + vers_size, vers->name); + cur_data += vers->next; + remaining_data -= vers->next; + if (!next) { + break; + } + vers = (void *)vers + next; + } + break; + } + default: + unlock_user(argptr, guest_data, 0); + ret = -TARGET_EINVAL; + goto out; + } + unlock_user(argptr, guest_data, guest_data_size); + + argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); + if (!argptr) { + ret = -TARGET_EFAULT; + goto out; + } + thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET); + unlock_user(argptr, arg, target_size); + } +out: + g_free(big_buf); + return ret; +} + +static abi_long do_ioctl_blkpg(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, + int cmd, abi_long arg) +{ + void *argptr; + int target_size; + const argtype *arg_type = ie->arg_type; + const argtype part_arg_type[] = { MK_STRUCT(STRUCT_blkpg_partition) }; + abi_long ret; + struct blkpg_ioctl_arg *host_blkpg = (void *)buf_temp; + struct blkpg_partition host_part; + + /* Read and convert blkpg */ + arg_type++; + target_size = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + ret = -TARGET_EFAULT; + goto out; + } + thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + + switch (host_blkpg->op) { + case BLKPG_ADD_PARTITION: + case BLKPG_DEL_PARTITION: + /* payload is struct blkpg_partition */ + break; + default: + /* Unknown opcode */ + ret = -TARGET_EINVAL; + goto out; + } + + /* Read and convert blkpg->data */ + arg = (abi_long)(uintptr_t)host_blkpg->data; + target_size = thunk_type_size(part_arg_type, 0); + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + ret = -TARGET_EFAULT; + goto out; + } + thunk_convert(&host_part, argptr, part_arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + + /* Swizzle the data pointer to our local copy and call! */ + host_blkpg->data = &host_part; + ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_blkpg)); + +out: + return ret; +} + +static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + const argtype *arg_type = ie->arg_type; + const StructEntry *se; + const argtype *field_types; + const int *dst_offsets, *src_offsets; + int target_size; + void *argptr; + abi_ulong *target_rt_dev_ptr = NULL; + unsigned long *host_rt_dev_ptr = NULL; + abi_long ret; + int i; + + assert(ie->access == IOC_W); + assert(*arg_type == TYPE_PTR); + arg_type++; + assert(*arg_type == TYPE_STRUCT); + target_size = thunk_type_size(arg_type, 0); + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + return -TARGET_EFAULT; + } + arg_type++; + assert(*arg_type == (int)STRUCT_rtentry); + se = struct_entries + *arg_type++; + assert(se->convert[0] == NULL); + /* convert struct here to be able to catch rt_dev string */ + field_types = se->field_types; + dst_offsets = se->field_offsets[THUNK_HOST]; + src_offsets = se->field_offsets[THUNK_TARGET]; + for (i = 0; i < se->nb_fields; i++) { + if (dst_offsets[i] == offsetof(struct rtentry, rt_dev)) { + assert(*field_types == TYPE_PTRVOID); + target_rt_dev_ptr = (abi_ulong *)(argptr + src_offsets[i]); + host_rt_dev_ptr = (unsigned long *)(buf_temp + dst_offsets[i]); + if (*target_rt_dev_ptr != 0) { + *host_rt_dev_ptr = (unsigned long)lock_user_string( + tswapal(*target_rt_dev_ptr)); + if (!*host_rt_dev_ptr) { + unlock_user(argptr, arg, 0); + return -TARGET_EFAULT; + } + } else { + *host_rt_dev_ptr = 0; + } + field_types++; + continue; + } + field_types = thunk_convert(buf_temp + dst_offsets[i], + argptr + src_offsets[i], + field_types, THUNK_HOST); + } + unlock_user(argptr, arg, 0); + + ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); + if (*host_rt_dev_ptr != 0) { + unlock_user((void *)*host_rt_dev_ptr, + *target_rt_dev_ptr, 0); + } + return ret; +} + +static abi_long do_ioctl_kdsigaccept(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + int sig = target_to_host_signal(arg); + return get_errno(safe_ioctl(fd, ie->host_cmd, sig)); +} + +#ifdef TIOCGPTPEER +static abi_long do_ioctl_tiocgptpeer(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, int cmd, abi_long arg) +{ + int flags = target_to_host_bitmask(arg, fcntl_flags_tbl); + return get_errno(safe_ioctl(fd, ie->host_cmd, flags)); +} +#endif + +static IOCTLEntry ioctl_entries[] = { +#define IOCTL(cmd, access, ...) \ + { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, +#define IOCTL_SPECIAL(cmd, access, dofn, ...) \ + { TARGET_ ## cmd, cmd, #cmd, access, dofn, { __VA_ARGS__ } }, +#define IOCTL_IGNORE(cmd) \ + { TARGET_ ## cmd, 0, #cmd }, +#include "ioctls.h" + { 0, 0, }, +}; + +/* ??? Implement proper locking for ioctls. */ +SYSCALL_IMPL(ioctl) +{ + int fd = arg1; + int cmd = arg2; + abi_ulong arg = arg3; + const IOCTLEntry *ie; + const argtype *arg_type; + abi_long ret; + uint8_t buf_temp[MAX_STRUCT_SIZE]; + int target_size; + void *argptr; + + for (ie = ioctl_entries; ; ie++) { + if (ie->target_cmd == 0) { + gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd); + return -TARGET_ENOSYS; + } + if (ie->target_cmd == cmd) { + break; + } + } + + arg_type = ie->arg_type; + if (ie->do_ioctl) { + return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); + } else if (!ie->host_cmd) { + /* + * Some architectures define BSD ioctls in their headers + * that are not implemented in Linux. + */ + return -TARGET_ENOSYS; + } + + switch (arg_type[0]) { + case TYPE_NULL: + /* no argument */ + ret = get_errno(safe_ioctl(fd, ie->host_cmd)); + break; + case TYPE_PTRVOID: + case TYPE_INT: + ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); + break; + case TYPE_PTR: + arg_type++; + target_size = thunk_type_size(arg_type, 0); + switch (ie->access) { + case IOC_R: + ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); + if (!is_error(ret)) { + argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); + if (!argptr) { + return -TARGET_EFAULT; + } + thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET); + unlock_user(argptr, arg, target_size); + } + break; + case IOC_W: + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + return -TARGET_EFAULT; + } + thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); + break; + default: + case IOC_RW: + argptr = lock_user(VERIFY_READ, arg, target_size, 1); + if (!argptr) { + return -TARGET_EFAULT; + } + thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); + unlock_user(argptr, arg, 0); + ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); + if (!is_error(ret)) { + argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); + if (!argptr) { + return -TARGET_EFAULT; + } + thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET); + unlock_user(argptr, arg, target_size); + } + break; + } + break; + default: + gemu_log("Unsupported ioctl type: cmd=0x%04lx type=%d\n", + (long)cmd, arg_type[0]); + ret = -TARGET_ENOSYS; + break; + } + return ret; +} diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d0e76c392e..8f90affe2f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2979,855 +2979,6 @@ STRUCT_MAX #undef STRUCT #undef STRUCT_SPECIAL -typedef struct IOCTLEntry IOCTLEntry; - -typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg); - -struct IOCTLEntry { - int target_cmd; - unsigned int host_cmd; - const char *name; - int access; - do_ioctl_fn *do_ioctl; - const argtype arg_type[5]; -}; - -#define IOC_R 0x0001 -#define IOC_W 0x0002 -#define IOC_RW (IOC_R | IOC_W) - -#define MAX_STRUCT_SIZE 4096 - -#ifdef CONFIG_FIEMAP -/* So fiemap access checks don't overflow on 32 bit systems. - * This is very slightly smaller than the limit imposed by - * the underlying kernel. - */ -#define FIEMAP_MAX_EXTENTS ((UINT_MAX - sizeof(struct fiemap)) \ - / sizeof(struct fiemap_extent)) - -static abi_long do_ioctl_fs_ioc_fiemap(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg) -{ - /* The parameter for this ioctl is a struct fiemap followed - * by an array of struct fiemap_extent whose size is set - * in fiemap->fm_extent_count. The array is filled in by the - * ioctl. - */ - int target_size_in, target_size_out; - struct fiemap *fm; - const argtype *arg_type = ie->arg_type; - const argtype extent_arg_type[] = { MK_STRUCT(STRUCT_fiemap_extent) }; - void *argptr, *p; - abi_long ret; - int i, extent_size = thunk_type_size(extent_arg_type, 0); - uint32_t outbufsz; - int free_fm = 0; - - assert(arg_type[0] == TYPE_PTR); - assert(ie->access == IOC_RW); - arg_type++; - target_size_in = thunk_type_size(arg_type, 0); - argptr = lock_user(VERIFY_READ, arg, target_size_in, 1); - if (!argptr) { - return -TARGET_EFAULT; - } - thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - fm = (struct fiemap *)buf_temp; - if (fm->fm_extent_count > FIEMAP_MAX_EXTENTS) { - return -TARGET_EINVAL; - } - - outbufsz = sizeof (*fm) + - (sizeof(struct fiemap_extent) * fm->fm_extent_count); - - if (outbufsz > MAX_STRUCT_SIZE) { - /* We can't fit all the extents into the fixed size buffer. - * Allocate one that is large enough and use it instead. - */ - fm = g_try_malloc(outbufsz); - if (!fm) { - return -TARGET_ENOMEM; - } - memcpy(fm, buf_temp, sizeof(struct fiemap)); - free_fm = 1; - } - ret = get_errno(safe_ioctl(fd, ie->host_cmd, fm)); - if (!is_error(ret)) { - target_size_out = target_size_in; - /* An extent_count of 0 means we were only counting the extents - * so there are no structs to copy - */ - if (fm->fm_extent_count != 0) { - target_size_out += fm->fm_mapped_extents * extent_size; - } - argptr = lock_user(VERIFY_WRITE, arg, target_size_out, 0); - if (!argptr) { - ret = -TARGET_EFAULT; - } else { - /* Convert the struct fiemap */ - thunk_convert(argptr, fm, arg_type, THUNK_TARGET); - if (fm->fm_extent_count != 0) { - p = argptr + target_size_in; - /* ...and then all the struct fiemap_extents */ - for (i = 0; i < fm->fm_mapped_extents; i++) { - thunk_convert(p, &fm->fm_extents[i], extent_arg_type, - THUNK_TARGET); - p += extent_size; - } - } - unlock_user(argptr, arg, target_size_out); - } - } - if (free_fm) { - g_free(fm); - } - return ret; -} -#endif - -static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg) -{ - const argtype *arg_type = ie->arg_type; - int target_size; - void *argptr; - int ret; - struct ifconf *host_ifconf; - uint32_t outbufsz; - const argtype ifreq_arg_type[] = { MK_STRUCT(STRUCT_sockaddr_ifreq) }; - int target_ifreq_size; - int nb_ifreq; - int free_buf = 0; - int i; - int target_ifc_len; - abi_long target_ifc_buf; - int host_ifc_len; - char *host_ifc_buf; - - assert(arg_type[0] == TYPE_PTR); - assert(ie->access == IOC_RW); - - arg_type++; - target_size = thunk_type_size(arg_type, 0); - - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) - return -TARGET_EFAULT; - thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - - host_ifconf = (struct ifconf *)(unsigned long)buf_temp; - target_ifc_buf = (abi_long)(unsigned long)host_ifconf->ifc_buf; - target_ifreq_size = thunk_type_size(ifreq_arg_type, 0); - - if (target_ifc_buf != 0) { - target_ifc_len = host_ifconf->ifc_len; - nb_ifreq = target_ifc_len / target_ifreq_size; - host_ifc_len = nb_ifreq * sizeof(struct ifreq); - - outbufsz = sizeof(*host_ifconf) + host_ifc_len; - if (outbufsz > MAX_STRUCT_SIZE) { - /* - * We can't fit all the extents into the fixed size buffer. - * Allocate one that is large enough and use it instead. - */ - host_ifconf = malloc(outbufsz); - if (!host_ifconf) { - return -TARGET_ENOMEM; - } - memcpy(host_ifconf, buf_temp, sizeof(*host_ifconf)); - free_buf = 1; - } - host_ifc_buf = (char *)host_ifconf + sizeof(*host_ifconf); - - host_ifconf->ifc_len = host_ifc_len; - } else { - host_ifc_buf = NULL; - } - host_ifconf->ifc_buf = host_ifc_buf; - - ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_ifconf)); - if (!is_error(ret)) { - /* convert host ifc_len to target ifc_len */ - - nb_ifreq = host_ifconf->ifc_len / sizeof(struct ifreq); - target_ifc_len = nb_ifreq * target_ifreq_size; - host_ifconf->ifc_len = target_ifc_len; - - /* restore target ifc_buf */ - - host_ifconf->ifc_buf = (char *)(unsigned long)target_ifc_buf; - - /* copy struct ifconf to target user */ - - argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); - if (!argptr) - return -TARGET_EFAULT; - thunk_convert(argptr, host_ifconf, arg_type, THUNK_TARGET); - unlock_user(argptr, arg, target_size); - - if (target_ifc_buf != 0) { - /* copy ifreq[] to target user */ - argptr = lock_user(VERIFY_WRITE, target_ifc_buf, target_ifc_len, 0); - for (i = 0; i < nb_ifreq ; i++) { - thunk_convert(argptr + i * target_ifreq_size, - host_ifc_buf + i * sizeof(struct ifreq), - ifreq_arg_type, THUNK_TARGET); - } - unlock_user(argptr, target_ifc_buf, target_ifc_len); - } - } - - if (free_buf) { - free(host_ifconf); - } - - return ret; -} - -#if defined(CONFIG_USBFS) -#if HOST_LONG_BITS > 64 -#error USBDEVFS thunks do not support >64 bit hosts yet. -#endif -struct live_urb { - uint64_t target_urb_adr; - uint64_t target_buf_adr; - char *target_buf_ptr; - struct usbdevfs_urb host_urb; -}; - -static GHashTable *usbdevfs_urb_hashtable(void) -{ - static GHashTable *urb_hashtable; - - if (!urb_hashtable) { - urb_hashtable = g_hash_table_new(g_int64_hash, g_int64_equal); - } - return urb_hashtable; -} - -static void urb_hashtable_insert(struct live_urb *urb) -{ - GHashTable *urb_hashtable = usbdevfs_urb_hashtable(); - g_hash_table_insert(urb_hashtable, urb, urb); -} - -static struct live_urb *urb_hashtable_lookup(uint64_t target_urb_adr) -{ - GHashTable *urb_hashtable = usbdevfs_urb_hashtable(); - return g_hash_table_lookup(urb_hashtable, &target_urb_adr); -} - -static void urb_hashtable_remove(struct live_urb *urb) -{ - GHashTable *urb_hashtable = usbdevfs_urb_hashtable(); - g_hash_table_remove(urb_hashtable, urb); -} - -static abi_long -do_ioctl_usbdevfs_reapurb(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg) -{ - const argtype usbfsurb_arg_type[] = { MK_STRUCT(STRUCT_usbdevfs_urb) }; - const argtype ptrvoid_arg_type[] = { TYPE_PTRVOID, 0, 0 }; - struct live_urb *lurb; - void *argptr; - uint64_t hurb; - int target_size; - uintptr_t target_urb_adr; - abi_long ret; - - target_size = thunk_type_size(usbfsurb_arg_type, THUNK_TARGET); - - memset(buf_temp, 0, sizeof(uint64_t)); - ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - if (is_error(ret)) { - return ret; - } - - memcpy(&hurb, buf_temp, sizeof(uint64_t)); - lurb = (void *)((uintptr_t)hurb - offsetof(struct live_urb, host_urb)); - if (!lurb->target_urb_adr) { - return -TARGET_EFAULT; - } - urb_hashtable_remove(lurb); - unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, - lurb->host_urb.buffer_length); - lurb->target_buf_ptr = NULL; - - /* restore the guest buffer pointer */ - lurb->host_urb.buffer = (void *)(uintptr_t)lurb->target_buf_adr; - - /* update the guest urb struct */ - argptr = lock_user(VERIFY_WRITE, lurb->target_urb_adr, target_size, 0); - if (!argptr) { - g_free(lurb); - return -TARGET_EFAULT; - } - thunk_convert(argptr, &lurb->host_urb, usbfsurb_arg_type, THUNK_TARGET); - unlock_user(argptr, lurb->target_urb_adr, target_size); - - target_size = thunk_type_size(ptrvoid_arg_type, THUNK_TARGET); - /* write back the urb handle */ - argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); - if (!argptr) { - g_free(lurb); - return -TARGET_EFAULT; - } - - /* GHashTable uses 64-bit keys but thunk_convert expects uintptr_t */ - target_urb_adr = lurb->target_urb_adr; - thunk_convert(argptr, &target_urb_adr, ptrvoid_arg_type, THUNK_TARGET); - unlock_user(argptr, arg, target_size); - - g_free(lurb); - return ret; -} - -static abi_long -do_ioctl_usbdevfs_discardurb(const IOCTLEntry *ie, - uint8_t *buf_temp __attribute__((unused)), - int fd, int cmd, abi_long arg) -{ - struct live_urb *lurb; - - /* map target address back to host URB with metadata. */ - lurb = urb_hashtable_lookup(arg); - if (!lurb) { - return -TARGET_EFAULT; - } - return get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); -} - -static abi_long -do_ioctl_usbdevfs_submiturb(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg) -{ - const argtype *arg_type = ie->arg_type; - int target_size; - abi_long ret; - void *argptr; - int rw_dir; - struct live_urb *lurb; - - /* - * each submitted URB needs to map to a unique ID for the - * kernel, and that unique ID needs to be a pointer to - * host memory. hence, we need to malloc for each URB. - * isochronous transfers have a variable length struct. - */ - arg_type++; - target_size = thunk_type_size(arg_type, THUNK_TARGET); - - /* construct host copy of urb and metadata */ - lurb = g_try_malloc0(sizeof(struct live_urb)); - if (!lurb) { - return -TARGET_ENOMEM; - } - - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) { - g_free(lurb); - return -TARGET_EFAULT; - } - thunk_convert(&lurb->host_urb, argptr, arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - - lurb->target_urb_adr = arg; - lurb->target_buf_adr = (uintptr_t)lurb->host_urb.buffer; - - /* buffer space used depends on endpoint type so lock the entire buffer */ - /* control type urbs should check the buffer contents for true direction */ - rw_dir = lurb->host_urb.endpoint & USB_DIR_IN ? VERIFY_WRITE : VERIFY_READ; - lurb->target_buf_ptr = lock_user(rw_dir, lurb->target_buf_adr, - lurb->host_urb.buffer_length, 1); - if (lurb->target_buf_ptr == NULL) { - g_free(lurb); - return -TARGET_EFAULT; - } - - /* update buffer pointer in host copy */ - lurb->host_urb.buffer = lurb->target_buf_ptr; - - ret = get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); - if (is_error(ret)) { - unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, 0); - g_free(lurb); - } else { - urb_hashtable_insert(lurb); - } - - return ret; -} -#endif /* CONFIG_USBFS */ - -static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, - int cmd, abi_long arg) -{ - void *argptr; - struct dm_ioctl *host_dm; - abi_long guest_data; - uint32_t guest_data_size; - int target_size; - const argtype *arg_type = ie->arg_type; - abi_long ret; - void *big_buf = NULL; - char *host_data; - - arg_type++; - target_size = thunk_type_size(arg_type, 0); - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) { - ret = -TARGET_EFAULT; - goto out; - } - thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - - /* buf_temp is too small, so fetch things into a bigger buffer */ - big_buf = g_malloc0(((struct dm_ioctl*)buf_temp)->data_size * 2); - memcpy(big_buf, buf_temp, target_size); - buf_temp = big_buf; - host_dm = big_buf; - - guest_data = arg + host_dm->data_start; - if ((guest_data - arg) < 0) { - ret = -TARGET_EINVAL; - goto out; - } - guest_data_size = host_dm->data_size - host_dm->data_start; - host_data = (char*)host_dm + host_dm->data_start; - - argptr = lock_user(VERIFY_READ, guest_data, guest_data_size, 1); - if (!argptr) { - ret = -TARGET_EFAULT; - goto out; - } - - switch (ie->host_cmd) { - case DM_REMOVE_ALL: - case DM_LIST_DEVICES: - case DM_DEV_CREATE: - case DM_DEV_REMOVE: - case DM_DEV_SUSPEND: - case DM_DEV_STATUS: - case DM_DEV_WAIT: - case DM_TABLE_STATUS: - case DM_TABLE_CLEAR: - case DM_TABLE_DEPS: - case DM_LIST_VERSIONS: - /* no input data */ - break; - case DM_DEV_RENAME: - case DM_DEV_SET_GEOMETRY: - /* data contains only strings */ - memcpy(host_data, argptr, guest_data_size); - break; - case DM_TARGET_MSG: - memcpy(host_data, argptr, guest_data_size); - *(uint64_t*)host_data = tswap64(*(uint64_t*)argptr); - break; - case DM_TABLE_LOAD: - { - void *gspec = argptr; - void *cur_data = host_data; - const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) }; - int spec_size = thunk_type_size(arg_type, 0); - int i; - - for (i = 0; i < host_dm->target_count; i++) { - struct dm_target_spec *spec = cur_data; - uint32_t next; - int slen; - - thunk_convert(spec, gspec, arg_type, THUNK_HOST); - slen = strlen((char*)gspec + spec_size) + 1; - next = spec->next; - spec->next = sizeof(*spec) + slen; - strcpy((char*)&spec[1], gspec + spec_size); - gspec += next; - cur_data += spec->next; - } - break; - } - default: - ret = -TARGET_EINVAL; - unlock_user(argptr, guest_data, 0); - goto out; - } - unlock_user(argptr, guest_data, 0); - - ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - if (!is_error(ret)) { - guest_data = arg + host_dm->data_start; - guest_data_size = host_dm->data_size - host_dm->data_start; - argptr = lock_user(VERIFY_WRITE, guest_data, guest_data_size, 0); - switch (ie->host_cmd) { - case DM_REMOVE_ALL: - case DM_DEV_CREATE: - case DM_DEV_REMOVE: - case DM_DEV_RENAME: - case DM_DEV_SUSPEND: - case DM_DEV_STATUS: - case DM_TABLE_LOAD: - case DM_TABLE_CLEAR: - case DM_TARGET_MSG: - case DM_DEV_SET_GEOMETRY: - /* no return data */ - break; - case DM_LIST_DEVICES: - { - struct dm_name_list *nl = (void*)host_dm + host_dm->data_start; - uint32_t remaining_data = guest_data_size; - void *cur_data = argptr; - const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_name_list) }; - int nl_size = 12; /* can't use thunk_size due to alignment */ - - while (1) { - uint32_t next = nl->next; - if (next) { - nl->next = nl_size + (strlen(nl->name) + 1); - } - if (remaining_data < nl->next) { - host_dm->flags |= DM_BUFFER_FULL_FLAG; - break; - } - thunk_convert(cur_data, nl, arg_type, THUNK_TARGET); - strcpy(cur_data + nl_size, nl->name); - cur_data += nl->next; - remaining_data -= nl->next; - if (!next) { - break; - } - nl = (void*)nl + next; - } - break; - } - case DM_DEV_WAIT: - case DM_TABLE_STATUS: - { - struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start; - void *cur_data = argptr; - const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_spec) }; - int spec_size = thunk_type_size(arg_type, 0); - int i; - - for (i = 0; i < host_dm->target_count; i++) { - uint32_t next = spec->next; - int slen = strlen((char*)&spec[1]) + 1; - spec->next = (cur_data - argptr) + spec_size + slen; - if (guest_data_size < spec->next) { - host_dm->flags |= DM_BUFFER_FULL_FLAG; - break; - } - thunk_convert(cur_data, spec, arg_type, THUNK_TARGET); - strcpy(cur_data + spec_size, (char*)&spec[1]); - cur_data = argptr + spec->next; - spec = (void*)host_dm + host_dm->data_start + next; - } - break; - } - case DM_TABLE_DEPS: - { - void *hdata = (void*)host_dm + host_dm->data_start; - int count = *(uint32_t*)hdata; - uint64_t *hdev = hdata + 8; - uint64_t *gdev = argptr + 8; - int i; - - *(uint32_t*)argptr = tswap32(count); - for (i = 0; i < count; i++) { - *gdev = tswap64(*hdev); - gdev++; - hdev++; - } - break; - } - case DM_LIST_VERSIONS: - { - struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start; - uint32_t remaining_data = guest_data_size; - void *cur_data = argptr; - const argtype arg_type[] = { MK_STRUCT(STRUCT_dm_target_versions) }; - int vers_size = thunk_type_size(arg_type, 0); - - while (1) { - uint32_t next = vers->next; - if (next) { - vers->next = vers_size + (strlen(vers->name) + 1); - } - if (remaining_data < vers->next) { - host_dm->flags |= DM_BUFFER_FULL_FLAG; - break; - } - thunk_convert(cur_data, vers, arg_type, THUNK_TARGET); - strcpy(cur_data + vers_size, vers->name); - cur_data += vers->next; - remaining_data -= vers->next; - if (!next) { - break; - } - vers = (void*)vers + next; - } - break; - } - default: - unlock_user(argptr, guest_data, 0); - ret = -TARGET_EINVAL; - goto out; - } - unlock_user(argptr, guest_data, guest_data_size); - - argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); - if (!argptr) { - ret = -TARGET_EFAULT; - goto out; - } - thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET); - unlock_user(argptr, arg, target_size); - } -out: - g_free(big_buf); - return ret; -} - -static abi_long do_ioctl_blkpg(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, - int cmd, abi_long arg) -{ - void *argptr; - int target_size; - const argtype *arg_type = ie->arg_type; - const argtype part_arg_type[] = { MK_STRUCT(STRUCT_blkpg_partition) }; - abi_long ret; - - struct blkpg_ioctl_arg *host_blkpg = (void*)buf_temp; - struct blkpg_partition host_part; - - /* Read and convert blkpg */ - arg_type++; - target_size = thunk_type_size(arg_type, 0); - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) { - ret = -TARGET_EFAULT; - goto out; - } - thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - - switch (host_blkpg->op) { - case BLKPG_ADD_PARTITION: - case BLKPG_DEL_PARTITION: - /* payload is struct blkpg_partition */ - break; - default: - /* Unknown opcode */ - ret = -TARGET_EINVAL; - goto out; - } - - /* Read and convert blkpg->data */ - arg = (abi_long)(uintptr_t)host_blkpg->data; - target_size = thunk_type_size(part_arg_type, 0); - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) { - ret = -TARGET_EFAULT; - goto out; - } - thunk_convert(&host_part, argptr, part_arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - - /* Swizzle the data pointer to our local copy and call! */ - host_blkpg->data = &host_part; - ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_blkpg)); - -out: - return ret; -} - -static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg) -{ - const argtype *arg_type = ie->arg_type; - const StructEntry *se; - const argtype *field_types; - const int *dst_offsets, *src_offsets; - int target_size; - void *argptr; - abi_ulong *target_rt_dev_ptr = NULL; - unsigned long *host_rt_dev_ptr = NULL; - abi_long ret; - int i; - - assert(ie->access == IOC_W); - assert(*arg_type == TYPE_PTR); - arg_type++; - assert(*arg_type == TYPE_STRUCT); - target_size = thunk_type_size(arg_type, 0); - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) { - return -TARGET_EFAULT; - } - arg_type++; - assert(*arg_type == (int)STRUCT_rtentry); - se = struct_entries + *arg_type++; - assert(se->convert[0] == NULL); - /* convert struct here to be able to catch rt_dev string */ - field_types = se->field_types; - dst_offsets = se->field_offsets[THUNK_HOST]; - src_offsets = se->field_offsets[THUNK_TARGET]; - for (i = 0; i < se->nb_fields; i++) { - if (dst_offsets[i] == offsetof(struct rtentry, rt_dev)) { - assert(*field_types == TYPE_PTRVOID); - target_rt_dev_ptr = (abi_ulong *)(argptr + src_offsets[i]); - host_rt_dev_ptr = (unsigned long *)(buf_temp + dst_offsets[i]); - if (*target_rt_dev_ptr != 0) { - *host_rt_dev_ptr = (unsigned long)lock_user_string( - tswapal(*target_rt_dev_ptr)); - if (!*host_rt_dev_ptr) { - unlock_user(argptr, arg, 0); - return -TARGET_EFAULT; - } - } else { - *host_rt_dev_ptr = 0; - } - field_types++; - continue; - } - field_types = thunk_convert(buf_temp + dst_offsets[i], - argptr + src_offsets[i], - field_types, THUNK_HOST); - } - unlock_user(argptr, arg, 0); - - ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - - assert(host_rt_dev_ptr != NULL); - assert(target_rt_dev_ptr != NULL); - if (*host_rt_dev_ptr != 0) { - unlock_user((void *)*host_rt_dev_ptr, - *target_rt_dev_ptr, 0); - } - return ret; -} - -static abi_long do_ioctl_kdsigaccept(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg) -{ - int sig = target_to_host_signal(arg); - return get_errno(safe_ioctl(fd, ie->host_cmd, sig)); -} - -#ifdef TIOCGPTPEER -static abi_long do_ioctl_tiocgptpeer(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, int cmd, abi_long arg) -{ - int flags = target_to_host_bitmask(arg, fcntl_flags_tbl); - return get_errno(safe_ioctl(fd, ie->host_cmd, flags)); -} -#endif - -static IOCTLEntry ioctl_entries[] = { -#define IOCTL(cmd, access, ...) \ - { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, -#define IOCTL_SPECIAL(cmd, access, dofn, ...) \ - { TARGET_ ## cmd, cmd, #cmd, access, dofn, { __VA_ARGS__ } }, -#define IOCTL_IGNORE(cmd) \ - { TARGET_ ## cmd, 0, #cmd }, -#include "ioctls.h" - { 0, 0, }, -}; - -/* ??? Implement proper locking for ioctls. */ -/* do_ioctl() Must return target values and target errnos. */ -static abi_long do_ioctl(int fd, int cmd, abi_long arg) -{ - const IOCTLEntry *ie; - const argtype *arg_type; - abi_long ret; - uint8_t buf_temp[MAX_STRUCT_SIZE]; - int target_size; - void *argptr; - - ie = ioctl_entries; - for(;;) { - if (ie->target_cmd == 0) { - gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd); - return -TARGET_ENOSYS; - } - if (ie->target_cmd == cmd) - break; - ie++; - } - arg_type = ie->arg_type; - if (ie->do_ioctl) { - return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); - } else if (!ie->host_cmd) { - /* Some architectures define BSD ioctls in their headers - that are not implemented in Linux. */ - return -TARGET_ENOSYS; - } - - switch(arg_type[0]) { - case TYPE_NULL: - /* no argument */ - ret = get_errno(safe_ioctl(fd, ie->host_cmd)); - break; - case TYPE_PTRVOID: - case TYPE_INT: - ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); - break; - case TYPE_PTR: - arg_type++; - target_size = thunk_type_size(arg_type, 0); - switch(ie->access) { - case IOC_R: - ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - if (!is_error(ret)) { - argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); - if (!argptr) - return -TARGET_EFAULT; - thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET); - unlock_user(argptr, arg, target_size); - } - break; - case IOC_W: - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) - return -TARGET_EFAULT; - thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - break; - default: - case IOC_RW: - argptr = lock_user(VERIFY_READ, arg, target_size, 1); - if (!argptr) - return -TARGET_EFAULT; - thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST); - unlock_user(argptr, arg, 0); - ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); - if (!is_error(ret)) { - argptr = lock_user(VERIFY_WRITE, arg, target_size, 0); - if (!argptr) - return -TARGET_EFAULT; - thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET); - unlock_user(argptr, arg, target_size); - } - break; - } - break; - default: - gemu_log("Unsupported ioctl type: cmd=0x%04lx type=%d\n", - (long)cmd, arg_type[0]); - ret = -TARGET_ENOSYS; - break; - } - return ret; -} - static const bitmask_transtbl iflag_tbl[] = { { TARGET_IGNBRK, TARGET_IGNBRK, IGNBRK, IGNBRK }, { TARGET_BRKINT, TARGET_BRKINT, BRKINT, BRKINT }, @@ -5294,8 +4445,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_ioctl: - return do_ioctl(arg1, arg2, arg3); #ifdef TARGET_NR_fcntl case TARGET_NR_fcntl: return do_fcntl(arg1, arg2, arg3); @@ -8900,6 +8049,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int64_t arg5, int64_t arg6) #include "syscall-file.inc.c" +#include "syscall-ioctl.inc.c" #include "syscall-ipc.inc.c" #include "syscall-mem.inc.c" #include "syscall-proc.inc.c" diff --git a/linux-user/strace.list b/linux-user/strace.list index ce5e02975b..efc64cd29f 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -365,9 +365,6 @@ #ifdef TARGET_NR_io_cancel { TARGET_NR_io_cancel, "io_cancel" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_ioctl -{ TARGET_NR_ioctl, "ioctl" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_io_destroy { TARGET_NR_io_destroy, "io_destroy" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164553 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4810694ili; Sun, 19 May 2019 14:25:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVIvS+LGMqy0TANPAo6XDVAChfQtXd6krR829CLqxtAYLqYu+skTxwZngqssJh28LMltuX X-Received: by 2002:a50:8163:: with SMTP id 90mr72432761edc.208.1558301150521; Sun, 19 May 2019 14:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301150; cv=none; d=google.com; s=arc-20160816; b=XcLuU3yHe1tP6/yodS53tMhhtg+5IX2w1gZ40bQvcuJYOKI/aDnbc1SfW0jcegG6j1 udsyGBjFxgtRPkKbrHqIXeXYMUoEhfg8zJ7d7MqFgy0NyCwqflPgUmzR+M/aWxOthV66 T93fZ7oaKXh7N1PL4AO0dTadwV/RZLU6jKkDGV/wOLAo9mabW4RrXGezmKArUvvtXZuU XroXwQCWJ5WmyvPCx3JGtlsPYVOXQW3rT2eef/MNlkX7h65VT/VGf+iG7MzeqSYYirwn KUyhMe38tKBywc1+xnVmOyXsX4AkBBH59Bifrzjba5p07MeO09OEOpl/9dhqgx3ZcHoK /09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=OfeoJQTtaaK+fPbdLfxvz94gE9h/4wGKMQdWOeJxa7o=; b=yrQyVc6egWkSwBJkQejxqB3czaarIca71LW60+sm13H0mlF5vAndMdIDMknDIEHs/g VTEq8bM5dX/HH1W2hO31RCwFZVeUSoYiT6B/SdKRQxJhZFOgkjNq1UhaDJ480hzVAWzy raghaQiVr4hsp0E9BrJere9wlzRd6Gyl75Kc6O4Eul1YX5xLEUC4uVHEsWYzFTGYFDEi YqmxSasgK4zdqOLsyZi/KRlR0Ay5P28Zjlhn7LPswfeLBXgm+X7k2tU5xk7+vfpq396H cmksUt7thUytnltojX8DnN2dQN4tSfSEK40phzAX22DTFcF3hUpPWmgEJE/X3uhJGh02 MiMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sPeEIANb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d15si569829edb.84.2019.05.19.14.25.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sPeEIANb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTJV-0002nb-En for patch@linaro.org; Sun, 19 May 2019 17:25:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZk-0003kD-5D for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZj-0004ZO-AB for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:32 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:36052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZj-0004YN-2D for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:31 -0400 Received: by mail-pg1-x542.google.com with SMTP id a3so5748173pgb.3 for ; Sun, 19 May 2019 13:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OfeoJQTtaaK+fPbdLfxvz94gE9h/4wGKMQdWOeJxa7o=; b=sPeEIANbnrlgFVXYdGYc7ADETYF1JqEBXSg3MaLO1/2o1TFntMnojX27kpBoZZ0gbi BSrF1n2tEQ+0yhucLw6GH0mRAl1waOF9Cq2eRw2MDz5RLTxdI8HZUAGJk9+d4c1+0t9z w8u4MkDvj9E7lia3E3lFOY2urYQrqQPHj/mzQL484aSqCN6fyKk4S+YhVFOjof+ukLRZ McSUwzu/O2I8HUkMBEYGp2GAsWGoH0nFgG9iqSAzkDKFjWWtEpnrKJ3KF1jRZb7kh5gb eZzBWwCqG2/4dR5p+cPu4mMdHBc4Ap5Y+xz7xTx2k0Dl/6welJA1vVsB7YkavwAILplN Ndgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OfeoJQTtaaK+fPbdLfxvz94gE9h/4wGKMQdWOeJxa7o=; b=Ej8FlvOXY7/vYz5bUHM/iF2dg02ytiLTHxqsyIfQlXzBYguSQ+7qz5prTKU8gTiWFa xuRbWAaM9EjOayyq7P7r9CQlk9d9e0xdjsWf96yuortLHTNB1enYmwRosMU1bo/nA1fc v6UBrZnmVBMllbSdgYqp8gJGK/OL04MHv7ALeDuAK5wEINdm2zZnXIcjNrkjbHi22rh9 v/sFGU32I/ishYlZNnJiTpVlhzfkqT2zcHKbHWGru1rWQH3BIB05pKWaSvMpDz9t9iF9 fJBJs9f9HK/WZsvBm7HuidLYAGXlx0UuD/jvdFE2b03JnL6T8mD0+gkPP64MiLmeG392 2M0w== X-Gm-Message-State: APjAAAWJKpFG1oCsO/nWLkEagguwPB+Zh/mdC4I+H2/+4wxkT29rexPX d+n1hstQRT6vwiF4KKFEfQLTYCWWaTM= X-Received: by 2002:a63:1a03:: with SMTP id a3mr72009716pga.412.1558298309801; Sun, 19 May 2019 13:38:29 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:00 -0700 Message-Id: <20190519203726.20729-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v7 48/74] linux-user: Fix types in ioctl logging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no need to cast "int" to "long"; just use the correct format in the first place. Signed-off-by: Richard Henderson --- linux-user/syscall-ioctl.inc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-ioctl.inc.c b/linux-user/syscall-ioctl.inc.c index be3f0b4b92..15d87b9663 100644 --- a/linux-user/syscall-ioctl.inc.c +++ b/linux-user/syscall-ioctl.inc.c @@ -791,7 +791,7 @@ SYSCALL_IMPL(ioctl) for (ie = ioctl_entries; ; ie++) { if (ie->target_cmd == 0) { - gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd); + gemu_log("Unsupported ioctl: cmd=0x%04x\n", cmd); return -TARGET_ENOSYS; } if (ie->target_cmd == cmd) { @@ -864,8 +864,8 @@ SYSCALL_IMPL(ioctl) } break; default: - gemu_log("Unsupported ioctl type: cmd=0x%04lx type=%d\n", - (long)cmd, arg_type[0]); + gemu_log("Unsupported ioctl type: cmd=0x%04x type=%d\n", + cmd, arg_type[0]); ret = -TARGET_ENOSYS; break; } From patchwork Sun May 19 20:37:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164538 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4804169ili; Sun, 19 May 2019 14:16:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMxlGwHjKMCGRo6/ug1g0roOQ1dHigEuJFHbr9G/R4u39yP6nnPPe6f+qb+6m6YWShAwzi X-Received: by 2002:a17:906:b741:: with SMTP id fx1mr3206408ejb.45.1558300564997; Sun, 19 May 2019 14:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300564; cv=none; d=google.com; s=arc-20160816; b=YjFG7QNKt5Am0Alzfc57tSRjurFsbRDX4sRtAWNtL4xJ8QsHvyZwCLp8Gd7X6hzCQO 3A9X6FjRvniY3LAIp7owGRuzldhfMq2oZNs83bMTqJVLUM1ewjY8tJJcBdLwG2goG6RD uh8hX8yqupWirB67Tc3W1GBPYQ6AIjRU7a2WpgZpiV7nWcBzoOd5NcQRmBbzTJClNAO8 oMZdvU8901BhKiIAnAOOiwcWvWVBZHkD4APhXQ+UYVYtUpx7AeiZy8XmPOL9+ptZIw0W KXEuGRHBE1Td9+hLrFluQ6fYZ8rb8NM6gziXJogne9IV8O3y8Tb1Ng6r+gxFpPriAoYD JQUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=gMLsvL1jnb8FN6BVtc8z8p85LWUNX5tvXcqS5qNVubg=; b=nf0HhpUMyDVsEeYQVj2D4QR4d/UthjRGVizpWuK6rjeM/M8rqBDszZU8dodEDKjU3s 6Uxfm4Rw203/eD1bqkZBpPeoKmJKX+iquXt1sLlfDPq23/BgvIAEeanMZ9xNvrt01mtx UgJ8D7rwmgrmDXFOUXoC+0KDvxP3HoZaL8bpTa2t6Nhyn44fEjWdTvcEASWPKsNq/abA PgLVnG4rWMHSuHlO3TBVvl56dBLK0/Oo1dWLbJhDcBFaH27kkXXHZT4CZUJwtZVbbYgF NpbNSOyMLbU98q2RDSCKuml3u7v6mS5Q2jGqDjPMicd6uKUFtQKWVWBIqEsgezKwtTqz Hayg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="H/24O4J2"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w13si1777423ejj.196.2019.05.19.14.16.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:16:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="H/24O4J2"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTA3-0002l5-Tv for patch@linaro.org; Sun, 19 May 2019 17:16:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZl-0003ky-43 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZk-0004aU-7h for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:33 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:34655) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZk-0004Ze-23 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:32 -0400 Received: by mail-pg1-x542.google.com with SMTP id c13so5748150pgt.1 for ; Sun, 19 May 2019 13:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gMLsvL1jnb8FN6BVtc8z8p85LWUNX5tvXcqS5qNVubg=; b=H/24O4J2CtVeAW2bEmUi0Fq2daN8ycHshgm6J7xFzJ7+9qMyu9O9tLWXf3NtBSU9yd NsY59B95gfilKGxFAFHZliRhsqeBgw2nEGcatkoqFdD/DTfXeodTIAZIqJgqO2pMY5cB XEnqsbq1Q5zgWvyGN/sy/MKFc0OlfX9RzGDBH4Y41oPOXORWb0/efAvqoZqbBzGXGY4q i5MhimEObeT8gBBvfH16W7cbJJUmkvrYEueemJdx95zuWXTyPfZzhTB5I9r+CUpOAGzN v8zPUNAxDG1/jKY0tTeusQXXa4Z55b4M6pFABIyrIJAeEjUOIOI67dvzuhnfS29+j6Ta D6Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gMLsvL1jnb8FN6BVtc8z8p85LWUNX5tvXcqS5qNVubg=; b=bJLbH4K5mEAo+KEp7hiwjai00NY7Df9gQNt0Ci4eXuQKs15yZFXXuEzWza2LFY5zc+ q0u4/KYMlZPd4O8yZDfDHFKAcR9O3wmHES7mRPB5kYNCE7nwtwegROVX36AnKbn6GiSf MrmkV5gluHTLd3YX2cGjqSqgQuQKULOUIhY7M2FjwBB1OgqvhsSApbhsmkq85G1lQneI ILGi07VpJV8sZWaINEboWXogU7ZywIlDIWMtWDvZWOmQB/s2DX2wiRSLE8mNlNZ5J1d6 LNJYOp5HLaAGW/Nq5bOKVVVM6m/WmguH/p93JhzTSAFnszYGfAUYzNuB3zzBtLznq7aA szrA== X-Gm-Message-State: APjAAAVKSApRYxdc46gEW4/dzL4eeSoXr7FvgARlhEUUuppwvfvUQyjj INR2itbXC10Pd240TU53pajAzY0hkgo= X-Received: by 2002:a63:d045:: with SMTP id s5mr8723728pgi.199.1558298310842; Sun, 19 May 2019 13:38:30 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:01 -0700 Message-Id: <20190519203726.20729-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v7 49/74] linux-user: Remove sentinel from ioctl_entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Iterate based on the size of the array instead. Signed-off-by: Richard Henderson --- linux-user/syscall-ioctl.inc.c | 14 +++++++------- linux-user/syscall.c | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-ioctl.inc.c b/linux-user/syscall-ioctl.inc.c index 15d87b9663..fc7df62017 100644 --- a/linux-user/syscall-ioctl.inc.c +++ b/linux-user/syscall-ioctl.inc.c @@ -773,7 +773,6 @@ static IOCTLEntry ioctl_entries[] = { #define IOCTL_IGNORE(cmd) \ { TARGET_ ## cmd, 0, #cmd }, #include "ioctls.h" - { 0, 0, }, }; /* ??? Implement proper locking for ioctls. */ @@ -789,16 +788,17 @@ SYSCALL_IMPL(ioctl) int target_size; void *argptr; - for (ie = ioctl_entries; ; ie++) { - if (ie->target_cmd == 0) { - gemu_log("Unsupported ioctl: cmd=0x%04x\n", cmd); - return -TARGET_ENOSYS; - } + for (ie = ioctl_entries; + ie < ioctl_entries + ARRAY_SIZE(ioctl_entries); + ie++) { if (ie->target_cmd == cmd) { - break; + goto found; } } + gemu_log("Unsupported ioctl: cmd=0x%04x\n", cmd); + return -TARGET_ENOSYS; + found: arg_type = ie->arg_type; if (ie->do_ioctl) { return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8f90affe2f..5871d3e711 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8173,7 +8173,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, void syscall_init(void) { - IOCTLEntry *ie; const argtype *arg_type; int size; int i; @@ -8203,8 +8202,8 @@ void syscall_init(void) * We patch the ioctl size if necessary. We rely on the fact that * no ioctl has all the bits at '1' in the size field. */ - ie = ioctl_entries; - while (ie->target_cmd != 0) { + for (i = 0; i < ARRAY_SIZE(ioctl_entries); i++) { + IOCTLEntry *ie = &ioctl_entries[i]; if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == TARGET_IOC_SIZEMASK) { arg_type = ie->arg_type; @@ -8228,6 +8227,5 @@ void syscall_init(void) ie->name, ie->target_cmd, ie->host_cmd); } #endif - ie++; } } From patchwork Sun May 19 20:37:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164533 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4801144ili; Sun, 19 May 2019 14:12:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsOUJb60t+Tfqp1x8LJJ2c/5x4RTcoDeamc1ysyCBSRfsZ8Ez0fnXIeV3SZKUp8k/6AnKE X-Received: by 2002:aa7:d1d1:: with SMTP id g17mr72472899edp.19.1558300325262; Sun, 19 May 2019 14:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300325; cv=none; d=google.com; s=arc-20160816; b=1KXz8ZhLbNUM1RShLAncbWSz3lKrBwFhp2IRM0XPqPs2DAvCU5UAHmnJVOUt3ZJZLX BrVdAa3aWJG/jZ7IiwrXLTHJvhrcTirrFgZffYR9ZqsxktDdspjYSZlYD5Wo35Y0nffU gsAM1BAKTedrikgpPhdHzki1Er0BM4EJxQx2zykTzClsc3jTIw+cIHaGmxRWR8ppJXuB W7i91hyY60BIf+c6DCq3D0r1cKzbO3ADY5eMLjjMIfNc7R1Ypu1omF8ZbuOav3BNRUWy Eu/ANH1f/0+4Wa/v6Opo0KXqH/xEDuNHtuUg5+uWIlux3j9QQOKgFu8AHy/966miRwL6 P5Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eI/KXLTeyrTJ11b57PtRyAzuENF86hpTnzEthpS7ZMU=; b=DklwO1B5vuECf+zSp16IJzPIHiQpICAUr8ScvNJhayDpnS0BAclmEGGHvvwJ7ztCj5 BxqsEXrQgBdG0a6OL08BlikUS8d4L2ZQfxW2mr1UQa5HoK+hUd53cNVHtcrAwhnq6CL9 Kxa+CImYEjjTBPEZdpz9WPpVGB5y/tQc7Aeqh3FeOkvyWgHDlgDdM9OMBa8wAnK6q0Ag KBaElv+EHkEZD1gJP97/4zTAdF2uHCGg+nI9+FuPzQDe8GJ3xAL4ct2J59CUkphUnsNx qroUUW5kWABD3+bBwe4Y2M85wcxt/XPb9T4fn0RSG4npWlnHzcc3du9zmmbLCGy6djyZ 91NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LVHq3gzL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gr23si2745057ejb.188.2019.05.19.14.12.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:12:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LVHq3gzL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST6C-0007M7-1x for patch@linaro.org; Sun, 19 May 2019 17:12:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZo-0003oM-Aj for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZl-0004cE-QM for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:36 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:35575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZl-0004bI-H1 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:33 -0400 Received: by mail-pl1-x641.google.com with SMTP id p1so336660plo.2 for ; Sun, 19 May 2019 13:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eI/KXLTeyrTJ11b57PtRyAzuENF86hpTnzEthpS7ZMU=; b=LVHq3gzL7T6nq08NBGyiK7jj/CMP7oRPLB8kcKYQLSzaCna94KiTQOgmCe3gb5FyaY v185tzlZmOiTzVKDV4kh0gNYQhPK5Nf9YnxHv+uTzEyrIAmX9Sy2ITzIDGBTS1ls0tDT dvCMibCX2RAqfj1zXaB970fiykEjbazbPxPqqrHL1SmnNh6+e/g9B+tGLbt2buTZw+7d kZceQ+1hHD5yVNyEsMthkmthQAM5QYtIdGI1qBfxRThGUUGZQzUfBoblQjYLGab+t8CP xo3O+vfRKgZCFcZ5iAJUOoSn+CXCE0DQ6TC/f5qfjPRvsZCzKX9nS1oWLJdKpFy919f+ /NZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eI/KXLTeyrTJ11b57PtRyAzuENF86hpTnzEthpS7ZMU=; b=R/1YQuotoGzAG5do+OGbnfolMUtTjhMykd7Dz0LyHaL8xxHlbvnCW//l/5LvV4u/zc irnvetfVLW2X/wSO3sZvLqxpy0j9xxmCVnHWewDsN6w7gztIWmvvb8zciMPRLQWjxgZ8 M7JtiU3qvPjDu2vwbhOXVmF11Gbz/q9N0n4KCTm7vlJqS734atj2ly5jws/0HNkN2EL2 aQul86GY3L8cZmYQfKcoLK/DJny0Zu5UhQ+JpOOR0eialvEcBh55z5zUPJJiOwj5oWiF d74Oat6LJDps8mBaDS/FZRYQX87GkNmsnx2XNG6v8oJuf3FKOLDQuijfxJzZ+ofYFFPi HyXg== X-Gm-Message-State: APjAAAV3OIw0jU7PLOv58hmAEYBQprWsQz4KRo0ANFY8skx9rheS7Rwj meXjC3/YM8U4Wiu5yZxg9R/JrblHFS4= X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr35899892plb.171.1558298312041; Sun, 19 May 2019 13:38:32 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:02 -0700 Message-Id: <20190519203726.20729-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 50/74] linux-user: Split out fcntl, fcntl64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Preserving strace functionality is tricky with this one. Rearrange to lookup structures that contain the data for both execution and strace for each command. Do not allow lookup of 64-bit fcntl commands from 32-bit fcntl. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 + linux-user/strace.c | 100 ---------- linux-user/syscall-fcntl.inc.c | 322 +++++++++++++++++++++++++++++++++ linux-user/syscall.c | 256 +------------------------- linux-user/strace.list | 6 - 5 files changed, 329 insertions(+), 361 deletions(-) create mode 100644 linux-user/syscall-fcntl.inc.c -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index f58b9745a4..5cf39f2bb9 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -46,6 +46,12 @@ SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); SYSCALL_DEF(faccessat, ARG_ATDIRFD, ARG_STR, ARG_ACCESSFLAG); SYSCALL_DEF(fchmod, ARG_DEC, ARG_MODEFLAG); SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); +#ifdef TARGET_NR_fcntl +SYSCALL_DEF_FULL(fcntl, .impl = impl_fcntl, .print = print_fcntl); +#endif +#if TARGET_ABI_BITS == 32 +SYSCALL_DEF_FULL(fcntl64, .impl = impl_fcntl64, .print = print_fcntl64); +#endif #ifdef TARGET_NR_futimesat SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 2b31998dbd..560284b3c3 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1184,106 +1184,6 @@ print_fchownat(const struct syscallname *name, } #endif -#if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) -static void -print_fcntl(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_raw_param("%d", arg0, 0); - switch(arg1) { - case TARGET_F_DUPFD: - gemu_log("F_DUPFD,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); - break; - case TARGET_F_GETFD: - gemu_log("F_GETFD"); - break; - case TARGET_F_SETFD: - gemu_log("F_SETFD,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); - break; - case TARGET_F_GETFL: - gemu_log("F_GETFL"); - break; - case TARGET_F_SETFL: - gemu_log("F_SETFL,"); - print_open_flags(arg2, 1); - break; - case TARGET_F_GETLK: - gemu_log("F_GETLK,"); - print_pointer(arg2, 1); - break; - case TARGET_F_SETLK: - gemu_log("F_SETLK,"); - print_pointer(arg2, 1); - break; - case TARGET_F_SETLKW: - gemu_log("F_SETLKW,"); - print_pointer(arg2, 1); - break; - case TARGET_F_GETOWN: - gemu_log("F_GETOWN"); - break; - case TARGET_F_SETOWN: - gemu_log("F_SETOWN,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); - break; - case TARGET_F_GETSIG: - gemu_log("F_GETSIG"); - break; - case TARGET_F_SETSIG: - gemu_log("F_SETSIG,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); - break; -#if TARGET_ABI_BITS == 32 - case TARGET_F_GETLK64: - gemu_log("F_GETLK64,"); - print_pointer(arg2, 1); - break; - case TARGET_F_SETLK64: - gemu_log("F_SETLK64,"); - print_pointer(arg2, 1); - break; - case TARGET_F_SETLKW64: - gemu_log("F_SETLKW64,"); - print_pointer(arg2, 1); - break; -#endif - case TARGET_F_SETLEASE: - gemu_log("F_SETLEASE,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); - break; - case TARGET_F_GETLEASE: - gemu_log("F_GETLEASE"); - break; - case TARGET_F_SETPIPE_SZ: - gemu_log("F_SETPIPE_SZ,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); - break; - case TARGET_F_GETPIPE_SZ: - gemu_log("F_GETPIPE_SZ"); - break; - case TARGET_F_DUPFD_CLOEXEC: - gemu_log("F_DUPFD_CLOEXEC,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); - break; - case TARGET_F_NOTIFY: - gemu_log("F_NOTIFY,"); - print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); - break; - default: - print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); - print_pointer(arg2, 1); - break; - } - print_syscall_epilogue(name); -} -#define print_fcntl64 print_fcntl -#endif - - #if defined(TARGET_NR_socket) static void print_socket(const struct syscallname *name, diff --git a/linux-user/syscall-fcntl.inc.c b/linux-user/syscall-fcntl.inc.c new file mode 100644 index 0000000000..768682bd17 --- /dev/null +++ b/linux-user/syscall-fcntl.inc.c @@ -0,0 +1,322 @@ +/* + * Linux fcntl syscall implementation + * Copyright (c) 2003 Fabrice Bellard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +typedef struct FcntlEntry FcntlEntry; + +typedef abi_long FcntlFn(int fd, int host_cmd, abi_long arg); + +struct FcntlEntry { + const char *name; + FcntlFn *host_fn; + int host_cmd; + SyscallArgType arg_type; +}; + +static abi_long do_fcntl_int(int fd, int host_cmd, abi_long arg) +{ + return get_errno(safe_fcntl(fd, host_cmd, arg)); +} + +static abi_long do_fcntl_getfl(int fd, int host_cmd, abi_long arg) +{ + abi_long ret = get_errno(safe_fcntl(fd, host_cmd)); + if (!is_error(ret)) { + ret = host_to_target_bitmask(ret, fcntl_flags_tbl); + } + return ret; +} + +static abi_long do_fcntl_setfl(int fd, int host_cmd, abi_long arg) +{ + return get_errno(safe_fcntl(fd, host_cmd, + target_to_host_bitmask(arg, fcntl_flags_tbl))); +} + +static abi_long do_fcntl_getlk_1(int fd, int host_cmd, abi_long arg, + from_flock64_fn *copy_from, + to_flock64_fn *copy_to) +{ + struct flock64 fl64; + abi_long ret; + + ret = copy_from(&fl64, arg); + if (ret == 0) { + ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); + if (ret == 0) { + ret = copy_to(arg, &fl64); + } + } + return ret; +} + +static abi_long do_fcntl_setlk_1(int fd, int host_cmd, abi_long arg, + from_flock64_fn *copy_from) +{ + struct flock64 fl64; + abi_long ret; + + ret = copy_from(&fl64, arg); + if (ret == 0) { + ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); + } + return ret; +} + +static abi_long do_fcntl_getlk(int fd, int cmd, abi_long arg) +{ + return do_fcntl_getlk_1(fd, cmd, arg, + copy_from_user_flock, + copy_to_user_flock); +} + +static abi_long do_fcntl_setlk(int fd, int cmd, abi_long arg) +{ + return do_fcntl_setlk_1(fd, cmd, arg, copy_from_user_flock); +} + +static abi_long do_fcntl_getlk64(int fd, int cmd, abi_long arg) +{ + return do_fcntl_getlk_1(fd, cmd, arg, + copy_from_user_flock64, + copy_to_user_flock64); +} + +static abi_long do_fcntl_setlk64(int fd, int cmd, abi_long arg) +{ + return do_fcntl_setlk_1(fd, cmd, arg, copy_from_user_flock64); +} + +#if defined(TARGET_ARM) && TARGET_ABI_BITS == 32 +static abi_long do_fcntl_oabi_getlk64(int fd, int cmd, abi_long arg) +{ + return do_fcntl_getlk_1(fd, cmd, arg, + copy_from_user_oabi_flock64, + copy_to_user_oabi_flock64); +} + +static abi_long do_fcntl_oabi_setlk64(int fd, int cmd, abi_long arg) +{ + return do_fcntl_setlk_1(fd, cmd, arg, copy_from_user_oabi_flock64); +} +#endif /* TARGET_ARM */ + +#ifdef F_GETOWN_EX +static abi_long do_fcntl_getown_ex(int fd, int cmd, abi_long arg) +{ + struct f_owner_ex fox; + abi_long ret = get_errno(safe_fcntl(fd, cmd, &fox)); + + if (!is_error(ret)) { + struct target_f_owner_ex *target_fox; + if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0)) { + return -TARGET_EFAULT; + } + target_fox->type = tswap32(fox.type); + target_fox->pid = tswap32(fox.pid); + unlock_user_struct(target_fox, arg, 1); + } + return ret; +} + +static abi_long do_fcntl_setown_ex(int fd, int cmd, abi_long arg) +{ + struct target_f_owner_ex *target_fox; + struct f_owner_ex fox; + + if (!lock_user_struct(VERIFY_READ, target_fox, arg, 1)) { + return -TARGET_EFAULT; + } + fox.type = tswap32(target_fox->type); + fox.pid = tswap32(target_fox->pid); + unlock_user_struct(target_fox, arg, 0); + return get_errno(safe_fcntl(fd, cmd, &fox)); +} +#endif /* F_GETOWN_EX */ + +static const FcntlEntry *target_fcntl_cmd(int cmd, int is_64) +{ +#define CMD2(T, H, A, FN) \ + case TARGET_##T: do { \ + static const FcntlEntry ent_##T = { \ + .name = #T, .host_cmd = H, .host_fn = FN, .arg_type = A \ + }; \ + return &ent_##T; \ + } while(0) + +#define CMD1(T, A, FN) \ + case TARGET_##T: do { \ + static const FcntlEntry ent_##T = { \ + .name = #T, .host_cmd = T, .host_fn = FN, .arg_type = A \ + }; \ + return &ent_##T; \ + } while(0) + +#if TARGET_ABI_BITS == 64 +# ifdef __powerpc64__ +/* + * On PPC64, glibc headers has the F_*LK* defined to 12, 13 and 14 and + * is not supported by kernel. The glibc fcntl call actually adjusts + * them to 5, 6 and 7 before making the syscall(). Since we make the + * syscall directly, adjust to what is supported by the kernel. + */ +# define HOST_CMD_ADJ64(C) (C - (F_GETLK64 - 5)) +# else +# define HOST_CMD_ADJ64(C) C +# endif +# define CMD64(T, FN) \ + case TARGET_##T: do { \ + static const FcntlEntry ent_##T = { \ + .name = #T, .host_cmd = HOST_CMD_ADJ64(T), \ + .host_fn = do_fcntl_##FN, .arg_type = ARG_PTR \ + }; \ + return &ent_##T; \ + } while(0) +#elif defined(TARGET_ARM) +# define CMD64(T, FN) \ + case TARGET_##T: do { \ + if (!is_64) { \ + return NULL; \ + } else if (is_64 > 0) { \ + static const FcntlEntry ent_##T = { \ + .name = #T, .host_cmd = T, \ + .host_fn = do_fcntl_##FN, .arg_type = ARG_PTR \ + }; \ + return &ent_##T; \ + } else { \ + static const FcntlEntry ent_oabi_##T = { \ + .name = #T, .host_cmd = T, \ + .host_fn = do_fcntl_oabi_##FN, .arg_type = ARG_PTR \ + }; \ + return &ent_oabi_##T; \ + } \ + } while (0) +#else +# define CMD64(T, FN) \ + case TARGET_##T: do { \ + static const FcntlEntry ent_##T = { \ + .name = #T, .host_cmd = T, \ + .host_fn = do_fcntl_##FN, .arg_type = ARG_PTR \ + }; \ + return is_64 ? &ent_##T : NULL; \ + } while (0) +#endif + + switch (cmd) { + CMD1(F_DUPFD, ARG_DEC, do_fcntl_int); + CMD1(F_GETFD, ARG_NONE, do_fcntl_int); + CMD1(F_SETFD, ARG_DEC, do_fcntl_int); + CMD1(F_GETFL, ARG_NONE, do_fcntl_getfl); + CMD1(F_SETFL, ARG_DEC, do_fcntl_setfl); + + CMD2(F_GETLK, F_GETLK64, ARG_PTR, do_fcntl_getlk); + CMD2(F_SETLK, F_SETLK64, ARG_PTR, do_fcntl_setlk); + CMD2(F_SETLKW, F_SETLKW64, ARG_PTR, do_fcntl_setlk); + + CMD1(F_GETOWN, ARG_NONE, do_fcntl_int); + CMD1(F_SETOWN, ARG_DEC, do_fcntl_int); + CMD1(F_GETSIG, ARG_NONE, do_fcntl_int); + CMD1(F_SETSIG, ARG_DEC, do_fcntl_int); + + CMD64(F_GETLK64, getlk64); + CMD64(F_SETLK64, setlk64); + CMD64(F_SETLKW64, setlk64); + + CMD1(F_GETLEASE, ARG_NONE, do_fcntl_int); + CMD1(F_SETLEASE, ARG_DEC, do_fcntl_int); +#ifdef F_DUPFD_CLOEXEC + CMD1(F_DUPFD_CLOEXEC, ARG_DEC, do_fcntl_int); +#endif + CMD1(F_NOTIFY, ARG_DEC, do_fcntl_int); +#ifdef F_GETOWN_EX + CMD1(F_GETOWN_EX, ARG_PTR, do_fcntl_getown_ex); + CMD1(F_SETOWN_EX, ARG_PTR, do_fcntl_setown_ex); +#endif +#ifdef F_SETPIPE_SZ + CMD1(F_SETPIPE_SZ, ARG_DEC, do_fcntl_int); + CMD1(F_GETPIPE_SZ, ARG_DEC, do_fcntl_int); +#endif + } + return NULL; + +#undef CMD1 +#undef CMD2 +#undef CMD64 +#undef HOST_CMD_ADJ64 +} + +static abi_long do_fcntl(int fd, int target_cmd, abi_ulong arg, int is_64) +{ + const FcntlEntry *ent = target_fcntl_cmd(target_cmd, is_64); + + if (ent == NULL) { + return -TARGET_EINVAL; + } + return ent->host_fn(fd, ent->host_cmd, arg); +} + +static void do_print_fcntl(const SyscallDef *def, int fd, int target_cmd, + abi_ulong arg, int is_64) +{ + const FcntlEntry *ent = target_fcntl_cmd(target_cmd, is_64); + + switch (ent->arg_type) { + case ARG_NONE: + gemu_log("%d %s(%d,%s)", getpid(), def->name, fd, ent->name); + break; + case ARG_DEC: + gemu_log("%d %s(%d,%s," TARGET_ABI_FMT_ld ")", + getpid(), def->name, fd, ent->name, arg); + break; + case ARG_PTR: + gemu_log("%d %s(%d,%s,0x" TARGET_ABI_FMT_lx ")", + getpid(), def->name, fd, ent->name, arg); + break; + default: + g_assert_not_reached(); + } +} + +#ifdef TARGET_NR_fcntl +SYSCALL_IMPL(fcntl) +{ + return do_fcntl(arg1, arg2, arg3, 0); +} + +static void print_fcntl(const SyscallDef *def, int64_t in[6]) +{ + return do_print_fcntl(def, in[0], in[1], in[2], 0); +} +#endif + +#if TARGET_ABI_BITS == 32 +SYSCALL_IMPL(fcntl64) +{ + int is_64 = 1; +#ifdef TARGET_ARM + if (!cpu_env->eabi) { + is_64 = -1; + } +#endif + return do_fcntl(arg1, arg2, arg3, is_64); +} + +static void print_fcntl64(const SyscallDef *def, int64_t in[6]) +{ + return do_print_fcntl(def, in[0], in[1], in[2], 1); +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5871d3e711..45fe05ac78 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3513,102 +3513,6 @@ static void *clone_func(void *arg) return NULL; } -/* warning : doesn't handle linux specific flags... */ -static int target_to_host_fcntl_cmd(int cmd) -{ - int ret; - - switch(cmd) { - case TARGET_F_DUPFD: - case TARGET_F_GETFD: - case TARGET_F_SETFD: - case TARGET_F_GETFL: - case TARGET_F_SETFL: - ret = cmd; - break; - case TARGET_F_GETLK: - ret = F_GETLK64; - break; - case TARGET_F_SETLK: - ret = F_SETLK64; - break; - case TARGET_F_SETLKW: - ret = F_SETLKW64; - break; - case TARGET_F_GETOWN: - ret = F_GETOWN; - break; - case TARGET_F_SETOWN: - ret = F_SETOWN; - break; - case TARGET_F_GETSIG: - ret = F_GETSIG; - break; - case TARGET_F_SETSIG: - ret = F_SETSIG; - break; -#if TARGET_ABI_BITS == 32 - case TARGET_F_GETLK64: - ret = F_GETLK64; - break; - case TARGET_F_SETLK64: - ret = F_SETLK64; - break; - case TARGET_F_SETLKW64: - ret = F_SETLKW64; - break; -#endif - case TARGET_F_SETLEASE: - ret = F_SETLEASE; - break; - case TARGET_F_GETLEASE: - ret = F_GETLEASE; - break; -#ifdef F_DUPFD_CLOEXEC - case TARGET_F_DUPFD_CLOEXEC: - ret = F_DUPFD_CLOEXEC; - break; -#endif - case TARGET_F_NOTIFY: - ret = F_NOTIFY; - break; -#ifdef F_GETOWN_EX - case TARGET_F_GETOWN_EX: - ret = F_GETOWN_EX; - break; -#endif -#ifdef F_SETOWN_EX - case TARGET_F_SETOWN_EX: - ret = F_SETOWN_EX; - break; -#endif -#ifdef F_SETPIPE_SZ - case TARGET_F_SETPIPE_SZ: - ret = F_SETPIPE_SZ; - break; - case TARGET_F_GETPIPE_SZ: - ret = F_GETPIPE_SZ; - break; -#endif - default: - ret = -TARGET_EINVAL; - break; - } - -#if defined(__powerpc64__) - /* On PPC64, glibc headers has the F_*LK* defined to 12, 13 and 14 and - * is not supported by kernel. The glibc fcntl call actually adjusts - * them to 5, 6 and 7 before making the syscall(). Since we make the - * syscall directly, adjust to what is supported by the kernel. - */ - if (ret >= F_GETLK64 && ret <= F_SETLKW64) { - ret -= F_GETLK64 - 5; - } -#endif - - return ret; -} - #define FLOCK_TRANSTBL \ switch (type) { \ TRANSTBL_CONVERT(F_RDLCK); \ @@ -3774,114 +3678,6 @@ static inline abi_long copy_to_user_flock64(abi_ulong target_flock_addr, return 0; } -static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) -{ - struct flock64 fl64; -#ifdef F_GETOWN_EX - struct f_owner_ex fox; - struct target_f_owner_ex *target_fox; -#endif - abi_long ret; - int host_cmd = target_to_host_fcntl_cmd(cmd); - - if (host_cmd == -TARGET_EINVAL) - return host_cmd; - - switch(cmd) { - case TARGET_F_GETLK: - ret = copy_from_user_flock(&fl64, arg); - if (ret) { - return ret; - } - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); - if (ret == 0) { - ret = copy_to_user_flock(arg, &fl64); - } - break; - - case TARGET_F_SETLK: - case TARGET_F_SETLKW: - ret = copy_from_user_flock(&fl64, arg); - if (ret) { - return ret; - } - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); - break; - - case TARGET_F_GETLK64: - ret = copy_from_user_flock64(&fl64, arg); - if (ret) { - return ret; - } - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); - if (ret == 0) { - ret = copy_to_user_flock64(arg, &fl64); - } - break; - case TARGET_F_SETLK64: - case TARGET_F_SETLKW64: - ret = copy_from_user_flock64(&fl64, arg); - if (ret) { - return ret; - } - ret = get_errno(safe_fcntl(fd, host_cmd, &fl64)); - break; - - case TARGET_F_GETFL: - ret = get_errno(safe_fcntl(fd, host_cmd, arg)); - if (ret >= 0) { - ret = host_to_target_bitmask(ret, fcntl_flags_tbl); - } - break; - - case TARGET_F_SETFL: - ret = get_errno(safe_fcntl(fd, host_cmd, - target_to_host_bitmask(arg, - fcntl_flags_tbl))); - break; - -#ifdef F_GETOWN_EX - case TARGET_F_GETOWN_EX: - ret = get_errno(safe_fcntl(fd, host_cmd, &fox)); - if (ret >= 0) { - if (!lock_user_struct(VERIFY_WRITE, target_fox, arg, 0)) - return -TARGET_EFAULT; - target_fox->type = tswap32(fox.type); - target_fox->pid = tswap32(fox.pid); - unlock_user_struct(target_fox, arg, 1); - } - break; -#endif - -#ifdef F_SETOWN_EX - case TARGET_F_SETOWN_EX: - if (!lock_user_struct(VERIFY_READ, target_fox, arg, 1)) - return -TARGET_EFAULT; - fox.type = tswap32(target_fox->type); - fox.pid = tswap32(target_fox->pid); - unlock_user_struct(target_fox, arg, 0); - ret = get_errno(safe_fcntl(fd, host_cmd, &fox)); - break; -#endif - - case TARGET_F_SETOWN: - case TARGET_F_GETOWN: - case TARGET_F_SETSIG: - case TARGET_F_GETSIG: - case TARGET_F_SETLEASE: - case TARGET_F_GETLEASE: - case TARGET_F_SETPIPE_SZ: - case TARGET_F_GETPIPE_SZ: - ret = get_errno(safe_fcntl(fd, host_cmd, arg)); - break; - - default: - ret = get_errno(safe_fcntl(fd, cmd, arg)); - break; - } - return ret; -} - #ifdef USE_UID16 static inline int high2lowuid(int uid) @@ -4445,10 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_fcntl - case TARGET_NR_fcntl: - return do_fcntl(arg1, arg2, arg3); -#endif case TARGET_NR_setpgid: return get_errno(setpgid(arg1, arg2)); case TARGET_NR_umask: @@ -7015,53 +6807,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, This is a hint, so ignoring and returning success is ok. */ return 0; #endif -#if TARGET_ABI_BITS == 32 - case TARGET_NR_fcntl64: - { - int cmd; - struct flock64 fl; - from_flock64_fn *copyfrom = copy_from_user_flock64; - to_flock64_fn *copyto = copy_to_user_flock64; - -#ifdef TARGET_ARM - if (!((CPUARMState *)cpu_env)->eabi) { - copyfrom = copy_from_user_oabi_flock64; - copyto = copy_to_user_oabi_flock64; - } -#endif - - cmd = target_to_host_fcntl_cmd(arg2); - if (cmd == -TARGET_EINVAL) { - return cmd; - } - - switch(arg2) { - case TARGET_F_GETLK64: - ret = copyfrom(&fl, arg3); - if (ret) { - break; - } - ret = get_errno(safe_fcntl(arg1, cmd, &fl)); - if (ret == 0) { - ret = copyto(arg3, &fl); - } - break; - - case TARGET_F_SETLK64: - case TARGET_F_SETLKW64: - ret = copyfrom(&fl, arg3); - if (ret) { - break; - } - ret = get_errno(safe_fcntl(arg1, cmd, &fl)); - break; - default: - ret = do_fcntl(arg1, arg2, arg3); - break; - } - return ret; - } -#endif #ifdef TARGET_NR_cacheflush case TARGET_NR_cacheflush: /* self-modifying code is handled automatically, so nothing needed */ @@ -8048,6 +7793,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int64_t arg2, int64_t arg3, int64_t arg4, \ int64_t arg5, int64_t arg6) +#include "syscall-fcntl.inc.c" #include "syscall-file.inc.c" #include "syscall-ioctl.inc.c" #include "syscall-ipc.inc.c" diff --git a/linux-user/strace.list b/linux-user/strace.list index efc64cd29f..68e202ca15 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -157,12 +157,6 @@ #ifdef TARGET_NR_fchownat { TARGET_NR_fchownat, "fchownat" , NULL, print_fchownat, NULL }, #endif -#ifdef TARGET_NR_fcntl -{ TARGET_NR_fcntl, "fcntl" , NULL, print_fcntl, NULL }, -#endif -#ifdef TARGET_NR_fcntl64 -{ TARGET_NR_fcntl64, "fcntl64" , NULL, print_fcntl64, NULL }, -#endif #ifdef TARGET_NR_fdatasync { TARGET_NR_fdatasync, "fdatasync" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164556 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4812412ili; Sun, 19 May 2019 14:28:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPDP2Kbe2nWNJrei8iPX92TurXzk0MjN0V7YNtIKXWievrzZAbh7zVdtYfAPItFn0cWDS6 X-Received: by 2002:a17:906:c4f:: with SMTP id t15mr12787519ejf.190.1558301306740; Sun, 19 May 2019 14:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301306; cv=none; d=google.com; s=arc-20160816; b=fQedoaPfw4DSt1UmnZBgPtdDpI8ITuz+c0l+tXc23eN+H1YiXygsjcuuUAlK0oYMLi qyQltgllFo6X7yyvhDgF7HcA9kzlFRXudCGHsm81EHV+NOfoE4i16jb0o60z3c9+yF7N z2Vemha2rDL3cF8AGK3Z1VTSKKlEpCibm7SfWhY6cI/FYp0E0jMc/lFe2i1z0JxvYErM Mudep3Ou06p/BQfP3UCQopGaZmMODzRN+jhqIZDk4G7auEVvk0ucrKDvor8Rc3kLkYUl 1T4NHQgoVklHMN8jXdqodgA0LOxmXVsIXow8i3xAh4VvsqnYhRXW6Iw+nuS5wnv0x21M dDkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=15I+Dq5Rg7507HNEwiC18Z0vUWpngHfr2VdrwlZdjRg=; b=w+uqgOWj7x0GLw6d50co9hhh6KhDByfNqeeiEy7sbuw1rRkeYxTxpRsErmULTmqbeP eVyHQO7ncKEqnc8SoDUbgj5p/rgH+RA7Jl5KqvavjOG2lCifSLGJ7a1SN4EUtSa4n6lr H2QUQ72yHqufSmIxIbtuKdprD+Djsl3gc3Y7Agj1EaMiJ2SP86Q2o04H0JeMRGccrv1T Yp7ha4htfkUrMgveTDOBbodQeqktuMiRC5/2PMhBMWcAkfVwtUQ3dqTFQkdVWFeHEBXd rVg6PSmBIVBZQxqqN4u8S6NrgHm2F4PdZoGKX+15c1Sj1zWd97HSQTW+/PiNY8P109Df 3MEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e92Pq6GS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o26si591786eja.316.2019.05.19.14.28.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:28:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e92Pq6GS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTM1-00055X-Ll for patch@linaro.org; Sun, 19 May 2019 17:28:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZn-0003nx-TY for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZm-0004dC-OX for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:35 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:34963) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZm-0004cc-Ix for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:34 -0400 Received: by mail-pf1-x442.google.com with SMTP id t87so6175430pfa.2 for ; Sun, 19 May 2019 13:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=15I+Dq5Rg7507HNEwiC18Z0vUWpngHfr2VdrwlZdjRg=; b=e92Pq6GScDIB/U3McwgwB4NOwZ33hkNI/s+n+3qt06GaxocxfmeeVfdlvCxbf68HZz NE+q3UkNzPh59OnF7sG8wVyoyIhLmaU8y5N6mwHktBV+vMEvIOvHjGmZN1l0We1rP0uk BlZQa9N6psUTe+RGiY8SOkFGK60r09PjJj9Ka/DjaptVYsyLLXfVdQY70oR18PwN/zGT cSzzs1YZOhEcXhCViOhMWkGQJWcvVvMan5pLpyAo2jU26N/jlATImui5GWzHVMlzYRst D+3qPiQNocrrq4JY9FNaFd1Stvw2YrUSSQkQOePrxKtXZjSe0I+cPjEfSWc4Ak5Fd6uW nODw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=15I+Dq5Rg7507HNEwiC18Z0vUWpngHfr2VdrwlZdjRg=; b=X+gg0I57HnJxUqocJd75TpSHFUk0nb/RuPJQBl70WsuZr2o2VVtaf0l3WVdbZELuQM QIKWRZ6fFDxunzByZjj2IvR6ciNirJgO7QksdtY/XowXnvldSMO8dohoZPU74XH7dzed D7CiCZtctp5K/UPQGaqSDdKHrqOmbaBdLiajR+Rn+yQLFYWvuzQl1C7HI5GDKV5dtu0r K3EYCZoe8A0H88WrU8dCMXTbUtnf87mZ0FZW1AacfOC0g/uKnuhDFKbpmTCLtKk6A9Qf KRuh1TDt7U5DKdtmm38o3vhuRTUdcUEV2ex3+elp7vsoAKld8KhxzHlBFIXw7mWx6Hk1 nkSg== X-Gm-Message-State: APjAAAWKHuYmUr6VYZ6WKr13aq26HXBuCN50rreaLd6QY7Hzo0VcrU3h 7dqFETWsxO6yb1e8zCYTxDisEG9xdN8= X-Received: by 2002:aa7:860a:: with SMTP id p10mr58741919pfn.214.1558298313395; Sun, 19 May 2019 13:38:33 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:03 -0700 Message-Id: <20190519203726.20729-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v7 51/74] linux-user: Split out setpgid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-proc.inc.c | 5 +++++ linux-user/syscall.c | 2 -- linux-user/strace.list | 3 --- 4 files changed, 6 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 5cf39f2bb9..6de7b84351 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -187,6 +187,7 @@ SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semget) SYSCALL_DEF(semget, ARG_DEC, ARG_DEC, ARG_HEX); #endif +SYSCALL_DEF(setpgid, ARG_DEC, ARG_DEC); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semop) SYSCALL_DEF(semop, ARG_DEC, ARG_PTR, ARG_DEC); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 517f84e139..5bd27d1d4b 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -468,6 +468,11 @@ SYSCALL_IMPL(nice) } #endif +SYSCALL_IMPL(setpgid) +{ + return get_errno(setpgid(arg1, arg2)); +} + SYSCALL_IMPL(times) { abi_ulong target_buf = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 45fe05ac78..dcb35e1228 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,8 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_setpgid: - return get_errno(setpgid(arg1, arg2)); case TARGET_NR_umask: return get_errno(umask(arg1)); case TARGET_NR_chroot: diff --git a/linux-user/strace.list b/linux-user/strace.list index 68e202ca15..4a527b0c65 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1073,9 +1073,6 @@ #ifdef TARGET_NR_setns { TARGET_NR_setns, "setns" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_setpgid -{ TARGET_NR_setpgid, "setpgid" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_setpgrp { TARGET_NR_setpgrp, "setpgrp" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164532 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4801023ili; Sun, 19 May 2019 14:11:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqz30Nxkl+UMDSS7f2maXDf/7j1H0zPTpIZ4JXhpgXikbgPXEZO7/Qec931Sxw6Kg44CW4rj X-Received: by 2002:a17:906:61c3:: with SMTP id t3mr37009120ejl.273.1558300313573; Sun, 19 May 2019 14:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300313; cv=none; d=google.com; s=arc-20160816; b=l5NeGu/yYcxzwvMlMxNSA1qWEZgCtMNGQ0KRKNj4SR4npyLUBIXYTAbrALmcvYqSGF hY8ggDuQ7i9oeDU+meUff4jrnmnrC6vFdZqzr38ilj8SGqeFBipUPCmLDGOV6Y0/mVf3 Qsojw3F6rBbx4QNl7OZrwHMkkkcldssZSNHTMpZxd8Yb/7cO3SNvupefAeKjBy8a4Ctl dVSaODFcTuisscvASvD328eGmHxxmjaTGOwRSFjYGVock0Xl8F++5HjdpJSL6mCRRXnU B8SVDxPIFySWq0geytYL+OqJq7khZWxGAmWq0/go8vs2Uwr6Y/mtWamSLfjS8zQ7xgTq W9Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=oFRsgmqF2zgcYNLWzzaBWoMP1N3UdMw/D2eCjGA4dbU=; b=UvD+CAcGddKc7IrxXTGW24gdJJIfsP3w1CT/iyfWwygFRQZDUb7fTzWe5yCKYnCDPC /inHw/ID+Mm4KBwAT/AlFwZHhYugjmWJQ+TBzhtudRzSTVGHkTxkd6Y5j3641JMmz6YJ o+X4RXUjtbW28w31H0uJhY5DBqKB1paB0eyJPBvN06L84ZND5ylqP3yIe3MG6C7KnYfr jJW3Wn0atH1xmMqXy95/4MDknvCpq0m1JF4fldvnnNyHeOwmftpSg+quk2yusz6GFnCS qUIQb44trHhxphv5h5gY/5gQvuP4/+5Jyc2w4NNsAwUKb5ZikkWQCFpxnr1F2rcl0HrY gPMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HRJ6Ux3g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h27si2321398ejc.202.2019.05.19.14.11.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:11:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HRJ6Ux3g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST60-0007DT-Gd for patch@linaro.org; Sun, 19 May 2019 17:11:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZo-0003op-SP for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZn-0004ee-TD for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:36 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:44492) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZn-0004dm-NT for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:35 -0400 Received: by mail-pf1-x443.google.com with SMTP id g9so6149183pfo.11 for ; Sun, 19 May 2019 13:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oFRsgmqF2zgcYNLWzzaBWoMP1N3UdMw/D2eCjGA4dbU=; b=HRJ6Ux3gg5LIul/AE9nq+zSXlQfOw3QbDX5D8Hwrps9d0CKvLXGTQPUh0lqD3TPzhA KkzrSWknpFoS0uA9nfTnWoOZP5+2rLxnusQMl44kXg8Y8ffsQVBI/JM1LwtL4qAQltaP UAcn/OA3cM7r10zYsPTUtgM0jP+u8TI/tpSbREMYvsBc3oJw057s4rjnfHaNFgikYsHN /lOSfQghorpWtHNEC+G7G+J8ri/2cQTZweGxZaksBrIwc5UWiRC1S+3DX8mh+jk7p05b 0nhF24eYBwnG3qapea/k3jhzs8PSflrUVSM5nlXVbrZ00vt6P+gPmt/1pPU4/dl8+Lt7 +j4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oFRsgmqF2zgcYNLWzzaBWoMP1N3UdMw/D2eCjGA4dbU=; b=Tcy6i261W/Z+aJFBtf6GH51lGfVICEeZhjFeevUmZYNCT6oR+8bAjeejyqC1wMC1wB AUDCNooxJFMH4xVevqvlTsay7hC16mM++eztPYkug7Er7/MJszB7UcDtkaSuaBRyZx20 OrWIIUdU7+Xips09S3a2qPwBBvc9wKe/4UfvSvVs7LHq1iIjUL3X/EwWRwESxpEruR0W YwBXMvcLEtxcQAIrWNlSg/T8gS4N7bul+WT6hAFo7ghFGa/QRJ2502suo7kE1TIm+G3Z zGFaeMTCEGo4YclKfVJxyoLM726mGo/7DksPC9XijygG+Z/MnfIWui/MEwAowiqI1lki SNog== X-Gm-Message-State: APjAAAXWcQrG2qhKk8jDe/eqToxs0HcXz9xRNGh8vKHuim7zhpMcJNri KdYxxFcG7yhKfDUcQIm8IEpgsQ00pqw= X-Received: by 2002:a62:4d04:: with SMTP id a4mr4173256pfb.177.1558298314536; Sun, 19 May 2019 13:38:34 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:04 -0700 Message-Id: <20190519203726.20729-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v7 52/74] linux-user: Split out umask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-file.inc.c | 5 +++++ linux-user/syscall.c | 2 -- linux-user/strace.list | 3 --- 4 files changed, 6 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 6de7b84351..b6538350a3 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -214,6 +214,7 @@ SYSCALL_DEF(syncfs, ARG_DEC); SYSCALL_DEF(time, ARG_PTR); #endif SYSCALL_DEF(times, ARG_PTR); +SYSCALL_DEF(umask, ARG_OCT); #ifdef TARGET_NR_umount SYSCALL_DEF(umount, ARG_STR); #endif diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 4080ab250e..cbde6d906f 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -1117,6 +1117,11 @@ SYSCALL_IMPL(rmdir) } #endif +SYSCALL_IMPL(umask) +{ + return get_errno(umask(arg1)); +} + SYSCALL_IMPL(unlinkat) { return do_unlinkat(arg1, arg2, arg3); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dcb35e1228..419edceab2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,8 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_umask: - return get_errno(umask(arg1)); case TARGET_NR_chroot: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; diff --git a/linux-user/strace.list b/linux-user/strace.list index 4a527b0c65..61d22ad16b 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1293,9 +1293,6 @@ #ifdef TARGET_NR_ulimit { TARGET_NR_ulimit, "ulimit" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_umask -{ TARGET_NR_umask, "umask" , "%s(%#o)", NULL, NULL }, -#endif #ifdef TARGET_NR_uname { TARGET_NR_uname, "uname" , "%s(%p)", NULL, NULL }, #endif From patchwork Sun May 19 20:37:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164539 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4804516ili; Sun, 19 May 2019 14:16:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqH9aahNtxBU/eMXFsWg7jGqfucYPQGsWdXs0J6yUyEl8a8bKH3FLKTU6z4cmGZB2E5F3+ X-Received: by 2002:a17:906:b2d3:: with SMTP id cf19mr13224392ejb.10.1558300590860; Sun, 19 May 2019 14:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300590; cv=none; d=google.com; s=arc-20160816; b=qAcJD9B84VYSWg0ddc6mn/R6Vdjws3WvhQ3XAw6baFBpWqUZ+JfBfvydOo9p2wRV+M 0kA5Pkmq3XvdU5x0RXxGZon9JYSOE1HAa2hs7bjkBf8Rhfholtw0COVs5dS3kQqfaSas TFJG8iaq9f2VjdXhdaLN5U4OpTJwP2GhCVozSXo38NjLFZm3DrRlWmWfLLYGlO1uFRdo uPT7nZv/d+hVQyH04RHGpqB1QGYEeYFDX4MzOYp/m85FRQLChJEwwd5BKoAzc3EiS4qn jiAh3kYUZDHuSQfNoinj2oaZFWcNBIe7wBHZrmKMHlFQGKsZUCGBmTqabEUosJbPZk/b tOFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7L7bsUhZiRxWJXbYkbn2Jh3ZaH0xfMhZkbZE3Jd/+Dw=; b=WURRh+srKu1sVh8jpl/l36HvgPkUfvgn9Kxm1nW4ESsY9E48567PVorx/Lae7ZcrvF NXHOXEbOZRB5T2b393TZTnF91WF57L8dNcmWqW6GGalSKKq4WLR7egN3Plm6XVkmpM/O ZpLlttVuGiarsiz24F43hM2M6kMGn5+LuzEiel7XyfjWTKl/taXs1jRececXhnAIPQLA vqyJkA8lceEatgiSc0VPNUbWKltAFteqJrMRW0pPIh0UWtZnvt3G6hZc0dSa8vMnhoL2 oIOpY534jv5hsWAA+FteITZVb+5FXqOUj1irc4MNqXzyLBzSfMNt4+r42TKckm1H3c9G UrTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Sh/K3TeN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6si9945847edu.147.2019.05.19.14.16.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Sh/K3TeN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTAT-0002uy-PG for patch@linaro.org; Sun, 19 May 2019 17:16:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZq-0003pv-12 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZo-0004gH-VR for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:37 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:44240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZo-0004fA-Ot for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:36 -0400 Received: by mail-pl1-x643.google.com with SMTP id c5so5690934pll.11 for ; Sun, 19 May 2019 13:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7L7bsUhZiRxWJXbYkbn2Jh3ZaH0xfMhZkbZE3Jd/+Dw=; b=Sh/K3TeNlrzQweyPs5RsuWLIuhsyEjrp8RDmgd0ctRv5apJNlUDqc3U+eYEtcPr4lf K350UkXahxGVZIEJPVx1hjBBh+OUn0clBfjwW+3cLw8/8w0bGbb0VqlcRl/+BwwEGpai A8NgRzav+1LoPLKRnTRFCOqEShack4gUCdS19Fy/PItScn2fDCDNvsE3aY3A3LX9ZqKV 1gSBM5YR+HCmoBxHiPCFqTvm487Y4UrFHT4+2IY56RIN7YtZrVWFHSViOnqtoaa7XN3n 6IGtOqATAkcyVhhXB5H6vqcBGbGLzIjoU5fw9B92ckhMouLcb4CU2tTqQyoMsnzvocXq RYFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7L7bsUhZiRxWJXbYkbn2Jh3ZaH0xfMhZkbZE3Jd/+Dw=; b=N7y7UJ9BsGBelNGj50g6CwBKGK2Vsqy9Z2bPVO0l7QSAvYy53dxb+NhGqS0zhgHbRL S1W+2HO6dT3HUrlJJ+Yi0D91+tT7+FgMFwJ9KeZ/aj7RBiIPt8yeZG0nT/vyxK2TRNKD ryQuNiDjkCiIGBNomKoo7HQVufEww4KbMgKkW41veRyUw0MvYSeOrIrnrHSqBEabzx0F 6LNcVZaDB14twxS48mQZ41uV/Ice1m0+3UJ6MbO7skpxSWWUs5bvKrM4J6pVKAMI/YAE 0X+yG929hUbjCP/fP4c2wImPR80TwDxB6hRGK5sGTAZfwGCJhq2cpC8bmEmfua4dtOsl Gryg== X-Gm-Message-State: APjAAAXlVM3epFQcX/Mo86JGlXhmq9Ghgac/LaSoqj4R+iLDUimeATPy 1bXksEvrmVIQnhK/HVksi7Aebvu+jzs= X-Received: by 2002:a17:902:59c3:: with SMTP id d3mr1085000plj.273.1558298315567; Sun, 19 May 2019 13:38:35 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:05 -0700 Message-Id: <20190519203726.20729-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v7 53/74] linux-user: Split out chroot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/strace.c | 12 ------------ linux-user/syscall-file.inc.c | 13 +++++++++++++ linux-user/syscall.c | 6 ------ linux-user/strace.list | 3 --- 5 files changed, 14 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index b6538350a3..b93ca1f78a 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -30,6 +30,7 @@ SYSCALL_DEF(chdir, ARG_STR); #ifdef TARGET_NR_chmod SYSCALL_DEF(chmod, ARG_STR, ARG_MODEFLAG); #endif +SYSCALL_DEF(chroot, ARG_STR); SYSCALL_DEF_ARGS(clone, ARG_CLONEFLAG, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); SYSCALL_DEF(close, ARG_DEC); #ifdef TARGET_NR_creat diff --git a/linux-user/strace.c b/linux-user/strace.c index 560284b3c3..787bf41307 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1130,18 +1130,6 @@ print_accept(const struct syscallname *name, } #endif -#ifdef TARGET_NR_chroot -static void -print_chroot(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index cbde6d906f..6e730e3152 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -88,6 +88,19 @@ SYSCALL_IMPL(chmod) } #endif +SYSCALL_IMPL(chroot) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chroot(p)); + unlock_user(p, arg1, 0); + return ret; +} + SYSCALL_IMPL(close) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 419edceab2..255765aaa7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,12 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_chroot: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chroot(p)); - unlock_user(p, arg1, 0); - return ret; #ifdef TARGET_NR_getpgrp case TARGET_NR_getpgrp: return get_errno(getpgrp()); diff --git a/linux-user/strace.list b/linux-user/strace.list index 61d22ad16b..7679e844b6 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -58,9 +58,6 @@ #ifdef TARGET_NR_chown32 { TARGET_NR_chown32, "chown32" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_chroot -{ TARGET_NR_chroot, "chroot" , NULL, print_chroot, NULL }, -#endif #ifdef TARGET_NR_clock_adjtime { TARGET_NR_clock_adjtime, "clock_adjtime" , NULL, print_clock_adjtime, NULL }, #endif From patchwork Sun May 19 20:37:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164542 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4806375ili; Sun, 19 May 2019 14:19:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0QDxiCBEp4KwWK3Klig51xB7wkbXiFNklKXglQ5prToBPTwIgS+cc6c4e4gmnDkfUCyfn X-Received: by 2002:a17:906:2785:: with SMTP id j5mr55255496ejc.94.1558300770594; Sun, 19 May 2019 14:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300770; cv=none; d=google.com; s=arc-20160816; b=kH+bZ3Ya6NpBJafBiYtdLV6lhv0LNfM8Rzhh8kwYd2O3To6ci+wlXM7tpcfy4PyCg7 /+HB2SLffOJvt2iqQAg77gI9eDGR5yL5501yGPWNCjYmGavVwvNKaCVpl4yt7w0evaWq ThGYLIYkk94XIaT+imIdJacIdTuY3sUUwDcOqNYCdZ08c4FUGkRgQN77U14MKcgKDXSp msIwWGaF1XjxV1nXNr0iM2DFptlYuvOftrmwJYec1T83QGRBfcgTYs4/1nQVGy4Wrw2c +lOM9vN4e59adUEzoDr5LX5QS/I0VIKFkvoBncmUASj13TW78jkqB/2aPNU1Y4vFpygG otEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=MSnLx4TEMgAogxZCRA6zSvqXurn3uaPFvTU6tGKAUTY=; b=jK9CVKx6e65/31i2mRxzCOEOCcS+SelHz0Qp6G5uaww7jZXmo7iNMACqmWtye+7qcg d1u9idcVexGtvcWQpdeTz6ZJbHH1qC3WlAJ4XrsK+E8DZqHAYRwTgzORExbH5uRoFkCy snxYyErf7XDkecTIsIcGMVpR7axPTdfe4Kk9QwwV5MsuX1pYyR6HAUq1zFfFtGFgK80l n50c1emPX79mmEhw8YU1dksX2EB5+zKZW473TL1f6oppTF6O4hc1Sv6XwtrxLPOiL6hS V7wOJjFu7tOE1yu9UByi9DgH+CakhP7Wq/oSj1mHjgXF3EU1J/AzaPVgggLKNQk1Cl3S 9l4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yOdEk4RB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g11si3042368edc.317.2019.05.19.14.19.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:19:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yOdEk4RB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTDN-0005oF-GI for patch@linaro.org; Sun, 19 May 2019 17:19:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZr-0003rA-57 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZq-0004hg-1f for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:39 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:41410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZp-0004gf-QO for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:37 -0400 Received: by mail-pl1-x642.google.com with SMTP id f12so5707321plt.8 for ; Sun, 19 May 2019 13:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MSnLx4TEMgAogxZCRA6zSvqXurn3uaPFvTU6tGKAUTY=; b=yOdEk4RBWdpJRxv5GrOS2C+3ELsjxW6DTlLQXge1/VAhTA2M30GV6M0ZwzyotMj/T9 8DraWkYKjUgJ16N9+SME7qtxLqrIlsWYBhcszL9x10kpqMLDuUOQ6x9xKk55IVwCVPgA YAxA1jQkHnikbkRcAtYJrGhIZ27Jmu4tTfdYurD8qkBlwFejOM8JlC6J5LQC7Z6x1gdn RUJ9go/PemRQ1Q3AstEEXA8DRLLh8AOW+1tYHOjlZ0191WMfX814acBPWv1EZZDkpKLC WF5S4mXRbKA+3dk6q6Pwyga0vQhLiegklfTLanzvpU6LqwBE0K8TDMmW3Vhpd3Nliep9 KZVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MSnLx4TEMgAogxZCRA6zSvqXurn3uaPFvTU6tGKAUTY=; b=dWg1bxegxo8MwwGHVxeimbCS850pNAg8bmYYqb/kZsht+6DHptdT77Xi2//5UmiUZe GhwSeArOr9zURXb+GlwZ135Uuiou4cBuVwV8cRsO5oY9WKW1uYDb7inmkYbQu9oXKsCU 1xpSdhPQnHsJzfVYmBqIjouEAIM/Yl62a/d7hzp897PtvdKcXJegI3hQ5Lf86MFOy0Jf ympUtjZE4fcjUl/KJzV+rxXDYpi+5oNhI6uVkdwI99G4Az+Mc83KxSxAZubjDgEnSvVB xZLxb5lUS+P0dfhcZuypJgeZlgnftYKj0k05/v/Sg3vkaWzJYA+ef0psrFMLAk20FcmZ 7wHQ== X-Gm-Message-State: APjAAAVwjhN8FmxdZA1UYO7+qcej1F3yjEAJG7YWs+v0d64wBi70UNSP NIpsWpu6GkKidByqxngOrNQi7lBx1D8= X-Received: by 2002:a17:902:70c6:: with SMTP id l6mr54073267plt.84.1558298316633; Sun, 19 May 2019 13:38:36 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:06 -0700 Message-Id: <20190519203726.20729-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 54/74] linux-user: Split out getpgid, getpgrp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall-proc.inc.c | 12 ++++++++++++ linux-user/syscall.c | 6 ------ linux-user/strace.list | 6 ------ 4 files changed, 16 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index b93ca1f78a..2ade9ec749 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -59,6 +59,10 @@ SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif +SYSCALL_DEF(getpgid, ARG_DEC); +#ifdef TARGET_NR_getpgrp +SYSCALL_DEF(getpgrp); +#endif #ifdef TARGET_NR_getpid SYSCALL_DEF(getpid); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 5bd27d1d4b..39de5b7863 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -438,6 +438,18 @@ SYSCALL_IMPL(fork) } #endif +SYSCALL_IMPL(getpgid) +{ + return get_errno(getpgid(arg1)); +} + +#ifdef TARGET_NR_getpgrp +SYSCALL_IMPL(getpgrp) +{ + return get_errno(getpgrp()); +} +#endif + #ifdef TARGET_NR_getpid SYSCALL_IMPL(getpid) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 255765aaa7..75989a01bf 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,10 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getpgrp - case TARGET_NR_getpgrp: - return get_errno(getpgrp()); -#endif case TARGET_NR_setsid: return get_errno(setsid()); #ifdef TARGET_NR_sigaction @@ -5388,8 +5384,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif - case TARGET_NR_getpgid: - return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: return get_errno(fchdir(arg1)); case TARGET_NR_personality: diff --git a/linux-user/strace.list b/linux-user/strace.list index 7679e844b6..d283c924a7 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -262,12 +262,6 @@ #ifdef TARGET_NR_getpeername { TARGET_NR_getpeername, "getpeername" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getpgid -{ TARGET_NR_getpgid, "getpgid" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_getpgrp -{ TARGET_NR_getpgrp, "getpgrp" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_getpmsg { TARGET_NR_getpmsg, "getpmsg" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164537 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4802981ili; Sun, 19 May 2019 14:14:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7C6A3dwVPVW1SJ5eic78NAO5/q9uwNlifaJ1kHinB9v07G5M//kplBVC20ft2PeE0sUWY X-Received: by 2002:a05:6402:78f:: with SMTP id d15mr19616396edy.189.1558300472741; Sun, 19 May 2019 14:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300472; cv=none; d=google.com; s=arc-20160816; b=u1ynGDDmkLVYSX1vPkjbaZbZupK2Hk63Enr92xUaNuSCDroF/WN9uyvXCKzHWfwCJE wZqTP13Yl4H2wtXxQZArLlQvWyJprYy1m0hbUC7lwnvAjxUL62uoysaGIkoR+39N03xV Jiq5TUqmiTSwgIHVFCJAymfUBGHkVPfIAWQX6EaMzrJpWuB1G9Tc05cqXab7Y9hF1Rdn Cb7vNI5dzPiHAKm60FS6CFetkyUxZI1O3BOL0qb8jw+dlfRwrLAfrgfNo0pQCKx2+121 Sp3Pqqb6S9lYwJvMUJiBivTtEu5GjMFCu+5H5Xs3lF14K8RHmWUt/7Ho13Tn+nif/Vt0 hz6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ttWxbzBbz5ihBAO0dy5RNz6XPVqQZ5W6pS6uncyoUTw=; b=yifqPW3X8rXFVUQLfcE6PkwBTPPpmTpZBngH14GCgexrDFNBAK0QGHwhmuS168nucl AHq3VQJpBO8mjuNVRt8tUufCysedomkFYso/20aWXInMTP2k94haDo/2oltEJGd/Y51g xCbUCBtyaey+Ew1OnLFdxBJWNX5IsqCxxpb29jSQYDmPaYke6noSS5UuWDfQ6lKWeScw 7FxzPKUkV7CvSljeV92wpk+4gIpQynXeQHj2cpBiyfJ6pn8PTHfM+oRLwWhcBGwSuddz V1pDy8L53Dx8QiL8w9aMNel39Y5Rytzi2nvJmtgo38PyIPLRF54v//E1Won7UgO0KPB9 gOyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ceaU80lF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w27si4171996eje.284.2019.05.19.14.14.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:14:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ceaU80lF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST8Z-00013D-If for patch@linaro.org; Sun, 19 May 2019 17:14:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZs-0003rB-AF for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZr-0004iz-5w for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:40 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZq-0004i4-V6 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:39 -0400 Received: by mail-pg1-x544.google.com with SMTP id 145so5730522pgg.9 for ; Sun, 19 May 2019 13:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ttWxbzBbz5ihBAO0dy5RNz6XPVqQZ5W6pS6uncyoUTw=; b=ceaU80lFl0hNLo3mamAAuO33hhZrmGbtyI7ycPbYg50IMB1ddBC4BHTkQ00WvE1pW+ qFdLzn5KItuiHl30u+GRqXYe7xaZhA4aI8yMyLyh1MRP+yTG3KXXqLR6LEBhcRNj+Wza cfL4hD3ql9eSVgmhDPwZMpsHGpN+lv2WTFlUYF4uazb+C+lWTAuWg+tXH6hcSCtKsRSc +DUL44+j1eREW2mmqeOizZFkht7KJs8ND+6MQK3Qa+OYMOhWkKE3ZOdM0GTGd0Km+olw tFJbI6eTrYtiqNNUSsYw8kycgw76MjTMNORCpWkQG8/uvatR9lFGTr08bqaMzmBYdFdp XcGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ttWxbzBbz5ihBAO0dy5RNz6XPVqQZ5W6pS6uncyoUTw=; b=DRJKQKBQXh5jDF65mjlI3LLX7D25OUD/BMCLwJ4hRvRjwiSimyx1eke2NLIRXFnabB tC11R9A8mhjJixuDh8+7yYFV30PUD9sBZqvnjvj10zkdWnuNL/V2P5o+9H5LPHeGUoDF rlR+BlpvFhMmxWXoTG2c2WaSKNkGHXA23FSTteu9LqVYcK/1nF1djuXDCQqU7oAtlarM Nvz69BAfPlzOFhhV9/GVkFbbZUySVnHoknp8WFwsh0D9TWaVExx0TllAatunvQwgYJON 3TkTAfpc6gKz7j31JjZlbg2ui90DWjfQTxmpM+VrWwncgkOvG36lFNnu4cqoxv2l0nZE smSg== X-Gm-Message-State: APjAAAVBSOJ6lk85Qsoeiu0Zc1Nk/VhY1NiPSbQhbWzSq5MHH79LZlhm Lvrfp4x1EaNLuiVQpTQH7hn+uqA8gxA= X-Received: by 2002:a65:6559:: with SMTP id a25mr47363983pgw.33.1558298317681; Sun, 19 May 2019 13:38:37 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:07 -0700 Message-Id: <20190519203726.20729-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v7 55/74] linux-user: Split out getsid, setsid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-proc.inc.c | 10 ++++++++++ linux-user/syscall.c | 4 ---- linux-user/strace.list | 6 ------ 4 files changed, 12 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 2ade9ec749..cd2c127c41 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -69,6 +69,7 @@ SYSCALL_DEF(getpid); #ifdef TARGET_NR_getppid SYSCALL_DEF(getppid); #endif +SYSCALL_DEF(getsid, ARG_DEC); #ifdef TARGET_NR_getxpid SYSCALL_DEF(getxpid); #endif @@ -193,6 +194,7 @@ SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); SYSCALL_DEF(semget, ARG_DEC, ARG_DEC, ARG_HEX); #endif SYSCALL_DEF(setpgid, ARG_DEC, ARG_DEC); +SYSCALL_DEF(setsid); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semop) SYSCALL_DEF(semop, ARG_DEC, ARG_PTR, ARG_DEC); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 39de5b7863..567df54581 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -464,6 +464,11 @@ SYSCALL_IMPL(getppid) } #endif +SYSCALL_IMPL(getsid) +{ + return get_errno(getsid(arg1)); +} + #ifdef TARGET_NR_getxpid SYSCALL_IMPL(getxpid) { @@ -485,6 +490,11 @@ SYSCALL_IMPL(setpgid) return get_errno(setpgid(arg1, arg2)); } +SYSCALL_IMPL(setsid) +{ + return get_errno(setsid()); +} + SYSCALL_IMPL(times) { abi_ulong target_buf = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 75989a01bf..0e9f4fd5ae 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,8 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_setsid: - return get_errno(setsid()); #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { @@ -5664,8 +5662,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* NOTE: the flock constant seems to be the same for every Linux platform */ return get_errno(safe_flock(arg1, arg2)); - case TARGET_NR_getsid: - return get_errno(getsid(arg1)); #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */ case TARGET_NR_fdatasync: return get_errno(fdatasync(arg1)); diff --git a/linux-user/strace.list b/linux-user/strace.list index d283c924a7..bf87a6d4cb 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -292,9 +292,6 @@ #ifdef TARGET_NR_getrusage { TARGET_NR_getrusage, "getrusage" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getsid -{ TARGET_NR_getsid, "getsid" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_getsockname { TARGET_NR_getsockname, "getsockname" , NULL, NULL, NULL }, #endif @@ -1100,9 +1097,6 @@ #ifdef TARGET_NR_set_robust_list { TARGET_NR_set_robust_list, "set_robust_list" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_setsid -{ TARGET_NR_setsid, "setsid" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_setsockopt { TARGET_NR_setsockopt, "setsockopt" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164545 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4807689ili; Sun, 19 May 2019 14:21:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8BOrS5w0xvzxkudTzI4IKf0mkuGbSJJadbLVIB0R943/yuZLfxAptdMYEfUpTaoxis5B0 X-Received: by 2002:a50:8dcd:: with SMTP id s13mr70416006edh.247.1558300892672; Sun, 19 May 2019 14:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300892; cv=none; d=google.com; s=arc-20160816; b=lOunFBHImushgYj3Z8IICTXVgBmuiiZCm+Pcq2bmuQU4Uv9uZcxy6EmFp37mOGgG5q PcsqNrpuoq6i6Tng5hM/MLs0DdK2BszVgTtEi+7u2SJ2kNuOjqECsmJQOq0mwG+hc4df S18ZglCHZmoGM/QrnAYdXrso8uGZL39TLw8H12iAxqndFvYEEsMw/0fWzxDJCx7YKQhR HQl9wV7Y9PbuawpDMzHKHjBlKfcvwF9IyP9HhAdmUVr3mPnCqUmtyASEXC6+dDZSefIi OHuYPfMgUFxL9LMo/0JoOpIFt4l3jDzFvBuibTAsc9nKnCyAiZ7r5OoprvHAKS6AALFl cnwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=/YpVT18mqqIFScwHIfb0mWiE7uIJJMrlMlrDVbB4UPM=; b=ur7wKsrFk4j79+Yj6cHSfItBNBY2eVK//AXYuqyqhiRAaaEAIIPkUSWxk6yiIEuRye 61mhNC8F5ZTwWtKwKDHwywm/SSJJg9INnbtVNTgIw2R28V7VYjN9AxIyaj/4SpavR7kA nTyVRkiseChl6i/3BGmmCVnTdHz6UdUYZRzuhlRWmcJVy2sKby2GEBmWy6v+mAicq2lS 5g9EOspYzVNq1RLQ9pbu2R/4jHcvJqL0WGZRX7ZuaGNqxpvhPNToU2WFkLhoi9KF5WdL FTXhcjoKHhUZuTb/mNr/EPlMzVinDCEr7Vlva6tl6H2lJ41TJQhbQ3s1Ost3gtCN6Clt 3jdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hblhk9WW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c33si1902769eda.149.2019.05.19.14.21.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:21:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hblhk9WW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTFL-0007gB-F3 for patch@linaro.org; Sun, 19 May 2019 17:21:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZu-0003rC-1r for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZs-0004kT-Aa for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:43443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZs-0004jf-1c for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:40 -0400 Received: by mail-pl1-x642.google.com with SMTP id gn7so1547889plb.10 for ; Sun, 19 May 2019 13:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/YpVT18mqqIFScwHIfb0mWiE7uIJJMrlMlrDVbB4UPM=; b=hblhk9WWpYxInAWKvveMiaezmyFzVaIhAak7rOQ7Bk1MuxPbXAUsifr203RUG1K0RZ 3mTJtHa61Pv1PxNbtQz6nEV/uhX/EqSkTtB1PSlbdxbqd5lPQSSFsfHgEs8eLS01tWAJ 1HmbEjCdkniopLuUnkMV+5UvTUpUIfFusEW2b9vBlRgXy+TlwwaAqns37uMEobp5MkNp i1b7gVYW/DE+R1+8tHEXsqyn4rPbWceir9IviNeiHXtc4fgn/wKXGELeSnIDrGTcGCcx Wq2e8HeINqGmVUknQzBzZRMzm5goqgvHKAH2itNkmM/JTPY9RWRtAGcA3s1PMXOhTXxD zhug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/YpVT18mqqIFScwHIfb0mWiE7uIJJMrlMlrDVbB4UPM=; b=DBiLs47SKVJTArHloHJST/v7gGg3MQiZ+NMALHqKiaL9uQhDaaAa06jImLsAlJOZtQ NDgHks5MuvS7xZe7tVgDNpsOTtZewryUyUu4NochWQmpWdZA+V1KvMjRyQD1512SQo2Y cFU3CLOAQuA/tg20LQrF1+ohYovQXXH/e18eQqpVzAxfJ5eWNh5WKIJW65qAduqD1lmK kyDN96jPnSz5OktHMI/lEkNTMuaS/Ej06C8sN5/AV5A0cb8Ur9sxfxfWHLrNPkCkKRyJ p6gZkLsgwzvO8lEn5Fbfr4/L9pXTOVutA45hoBiVBxHzJt7F044hqWhAJD+baqc0w1+V HkxQ== X-Gm-Message-State: APjAAAXp6SYGXiLy3CjMDcsn9fsbBgDZiH+NZU6/abJEOpPHig94rCcc UDMCDxhipt/EzrdJhgfH9RLDM5E7zqQ= X-Received: by 2002:a17:902:b941:: with SMTP id h1mr13227358pls.289.1558298318825; Sun, 19 May 2019 13:38:38 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:08 -0700 Message-Id: <20190519203726.20729-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 56/74] linux-user: Split out sigaction, rt_sigaction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 10 ++ linux-user/strace.c | 14 --- linux-user/syscall-sig.inc.c | 172 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 160 -------------------------------- linux-user/strace.list | 6 -- 5 files changed, 182 insertions(+), 180 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index cd2c127c41..b62bffeb68 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -187,6 +187,13 @@ SYSCALL_DEF(readv, ARG_DEC, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_rmdir SYSCALL_DEF(rmdir, ARG_STR); #endif +#if defined(TARGET_ALPHA) +SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC, ARG_PTR); +#elif defined(TARGET_SPARC) +SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_PTR, ARG_DEC); +#else +SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC); +#endif #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #endif @@ -212,6 +219,9 @@ SYSCALL_DEF(shmdt, ARG_PTR); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_shmget) SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #endif +#ifdef TARGET_NR_sigaction +SYSCALL_DEF(sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR); +#endif #ifdef TARGET_NR_stime SYSCALL_DEF(stime, ARG_PTR); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 787bf41307..83dd755c73 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1564,20 +1564,6 @@ print_fstat(const struct syscallname *name, #define print_fstat64 print_fstat #endif -#ifdef TARGET_NR_rt_sigaction -static void -print_rt_sigaction(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_signal(arg0, 0); - print_pointer(arg1, 0); - print_pointer(arg2, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_rt_sigprocmask static void print_rt_sigprocmask(const struct syscallname *name, diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index a4fbcc567d..918d58878f 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -39,3 +39,175 @@ SYSCALL_IMPL(pause) return -TARGET_EINTR; } #endif + +SYSCALL_IMPL(rt_sigaction) +{ + abi_long ret; +#if defined(TARGET_ALPHA) + /* + * For Alpha and SPARC this is a 5 argument syscall, with + * a 'restorer' parameter which must be copied into the + * sa_restorer field of the sigaction struct. + * For Alpha that 'restorer' is arg5; for SPARC it is arg4, + * and arg5 is the sigsetsize. + * Alpha also has a separate rt_sigaction struct that it uses + * here; SPARC uses the usual sigaction struct. + */ + struct target_rt_sigaction *rt_act; + struct target_sigaction act, oact, *pact = NULL; + + if (arg4 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + if (arg2) { + if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = rt_act->_sa_handler; + act.sa_mask = rt_act->sa_mask; + act.sa_flags = rt_act->sa_flags; + act.sa_restorer = arg5; + unlock_user_struct(rt_act, arg2, 0); + pact = &act; + } + ret = get_errno(do_sigaction(arg1, pact, &oact)); + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) { + return -TARGET_EFAULT; + } + rt_act->_sa_handler = oact._sa_handler; + rt_act->sa_mask = oact.sa_mask; + rt_act->sa_flags = oact.sa_flags; + unlock_user_struct(rt_act, arg3, 1); + } +#else +# ifdef TARGET_SPARC + target_ulong restorer = arg4; + target_ulong sigsetsize = arg5; +# else + target_ulong sigsetsize = arg4; +# endif + struct target_sigaction act, oact, *pact = NULL; + + if (sigsetsize != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + if (arg2) { + if (!lock_user_struct(VERIFY_READ, pact, arg2, 1)) { + return -TARGET_EFAULT; + } + act = *pact; + unlock_user_struct(pact, arg2, 0); +# ifdef TARGET_ARCH_HAS_KA_RESTORER + act.ka_restorer = restorer; +# endif + pact = &act; + } + + ret = get_errno(do_sigaction(arg1, pact, &oact)); + + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, pact, arg3, 0)) { + return -TARGET_EFAULT; + } + *pact = oact; + unlock_user_struct(pact, arg3, 1); + } +#endif + return ret; +} + +#ifdef TARGET_NR_sigaction +SYSCALL_IMPL(sigaction) +{ + abi_long ret; +#if defined(TARGET_ALPHA) + struct target_sigaction act, oact, *pact = NULL; + struct target_old_sigaction *old_act; + + if (arg2) { + if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = old_act->_sa_handler; + target_siginitset(&act.sa_mask, old_act->sa_mask); + act.sa_flags = old_act->sa_flags; + act.sa_restorer = 0; + unlock_user_struct(old_act, arg2, 0); + pact = &act; + } + + ret = get_errno(do_sigaction(arg1, pact, &oact)); + + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) { + return -TARGET_EFAULT; + } + old_act->_sa_handler = oact._sa_handler; + old_act->sa_mask = oact.sa_mask.sig[0]; + old_act->sa_flags = oact.sa_flags; + unlock_user_struct(old_act, arg3, 1); + } +#elif defined(TARGET_MIPS) + struct target_sigaction act, oact, *pact = NULL, *old_act; + + if (arg2) { + if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = old_act->_sa_handler; + target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); + act.sa_flags = old_act->sa_flags; + unlock_user_struct(old_act, arg2, 0); + pact = &act; + } + + ret = get_errno(do_sigaction(arg1, pact, &oact)); + + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) { + return -TARGET_EFAULT; + } + old_act->_sa_handler = oact._sa_handler; + old_act->sa_flags = oact.sa_flags; + old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; + old_act->sa_mask.sig[1] = 0; + old_act->sa_mask.sig[2] = 0; + old_act->sa_mask.sig[3] = 0; + unlock_user_struct(old_act, arg3, 1); + } +#else + struct target_old_sigaction *old_act; + struct target_sigaction act, oact, *pact = NULL; + + if (arg2) { + if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) { + return -TARGET_EFAULT; + } + act._sa_handler = old_act->_sa_handler; + target_siginitset(&act.sa_mask, old_act->sa_mask); + act.sa_flags = old_act->sa_flags; + act.sa_restorer = old_act->sa_restorer; +#ifdef TARGET_ARCH_HAS_KA_RESTORER + act.ka_restorer = 0; +#endif + unlock_user_struct(old_act, arg2, 0); + pact = &act; + } + + ret = get_errno(do_sigaction(arg1, pact, &oact)); + + if (!is_error(ret) && arg3) { + if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) { + return -TARGET_EFAULT; + } + old_act->_sa_handler = oact._sa_handler; + old_act->sa_mask = oact.sa_mask.sig[0]; + old_act->sa_flags = oact.sa_flags; + old_act->sa_restorer = oact.sa_restorer; + unlock_user_struct(old_act, arg3, 1); + } +#endif + return ret; +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0e9f4fd5ae..3ef1bfb4ec 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,166 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_sigaction - case TARGET_NR_sigaction: - { -#if defined(TARGET_ALPHA) - struct target_sigaction act, oact, *pact = 0; - struct target_old_sigaction *old_act; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = old_act->_sa_handler; - target_siginitset(&act.sa_mask, old_act->sa_mask); - act.sa_flags = old_act->sa_flags; - act.sa_restorer = 0; - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } - ret = get_errno(do_sigaction(arg1, pact, &oact)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - return -TARGET_EFAULT; - old_act->_sa_handler = oact._sa_handler; - old_act->sa_mask = oact.sa_mask.sig[0]; - old_act->sa_flags = oact.sa_flags; - unlock_user_struct(old_act, arg3, 1); - } -#elif defined(TARGET_MIPS) - struct target_sigaction act, oact, *pact, *old_act; - - if (arg2) { - if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = old_act->_sa_handler; - target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); - act.sa_flags = old_act->sa_flags; - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } else { - pact = NULL; - } - - ret = get_errno(do_sigaction(arg1, pact, &oact)); - - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - return -TARGET_EFAULT; - old_act->_sa_handler = oact._sa_handler; - old_act->sa_flags = oact.sa_flags; - old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; - old_act->sa_mask.sig[1] = 0; - old_act->sa_mask.sig[2] = 0; - old_act->sa_mask.sig[3] = 0; - unlock_user_struct(old_act, arg3, 1); - } -#else - struct target_old_sigaction *old_act; - struct target_sigaction act, oact, *pact; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = old_act->_sa_handler; - target_siginitset(&act.sa_mask, old_act->sa_mask); - act.sa_flags = old_act->sa_flags; - act.sa_restorer = old_act->sa_restorer; -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act.ka_restorer = 0; -#endif - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } else { - pact = NULL; - } - ret = get_errno(do_sigaction(arg1, pact, &oact)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - return -TARGET_EFAULT; - old_act->_sa_handler = oact._sa_handler; - old_act->sa_mask = oact.sa_mask.sig[0]; - old_act->sa_flags = oact.sa_flags; - old_act->sa_restorer = oact.sa_restorer; - unlock_user_struct(old_act, arg3, 1); - } -#endif - } - return ret; -#endif - case TARGET_NR_rt_sigaction: - { -#if defined(TARGET_ALPHA) - /* For Alpha and SPARC this is a 5 argument syscall, with - * a 'restorer' parameter which must be copied into the - * sa_restorer field of the sigaction struct. - * For Alpha that 'restorer' is arg5; for SPARC it is arg4, - * and arg5 is the sigsetsize. - * Alpha also has a separate rt_sigaction struct that it uses - * here; SPARC uses the usual sigaction struct. - */ - struct target_rt_sigaction *rt_act; - struct target_sigaction act, oact, *pact = 0; - - if (arg4 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (arg2) { - if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = rt_act->_sa_handler; - act.sa_mask = rt_act->sa_mask; - act.sa_flags = rt_act->sa_flags; - act.sa_restorer = arg5; - unlock_user_struct(rt_act, arg2, 0); - pact = &act; - } - ret = get_errno(do_sigaction(arg1, pact, &oact)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) - return -TARGET_EFAULT; - rt_act->_sa_handler = oact._sa_handler; - rt_act->sa_mask = oact.sa_mask; - rt_act->sa_flags = oact.sa_flags; - unlock_user_struct(rt_act, arg3, 1); - } -#else -#ifdef TARGET_SPARC - target_ulong restorer = arg4; - target_ulong sigsetsize = arg5; -#else - target_ulong sigsetsize = arg4; -#endif - struct target_sigaction *act; - struct target_sigaction *oact; - - if (sigsetsize != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (arg2) { - if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { - return -TARGET_EFAULT; - } -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act->ka_restorer = restorer; -#endif - } else { - act = NULL; - } - if (arg3) { - if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { - ret = -TARGET_EFAULT; - goto rt_sigaction_fail; - } - } else - oact = NULL; - ret = get_errno(do_sigaction(arg1, act, oact)); - rt_sigaction_fail: - if (act) - unlock_user_struct(act, arg2, 0); - if (oact) - unlock_user_struct(oact, arg3, 1); -#endif - } - return ret; #ifdef TARGET_NR_sgetmask /* not on alpha */ case TARGET_NR_sgetmask: { diff --git a/linux-user/strace.list b/linux-user/strace.list index bf87a6d4cb..20a71adc21 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -926,9 +926,6 @@ #ifdef TARGET_NR_rmdir { TARGET_NR_rmdir, "rmdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_sigaction -{ TARGET_NR_rt_sigaction, "rt_sigaction" , NULL, print_rt_sigaction, NULL }, -#endif #ifdef TARGET_NR_rt_sigpending { TARGET_NR_rt_sigpending, "rt_sigpending" , NULL, NULL, NULL }, #endif @@ -1125,9 +1122,6 @@ #ifdef TARGET_NR_shutdown { TARGET_NR_shutdown, "shutdown" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sigaction -{ TARGET_NR_sigaction, "sigaction" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sigaltstack { TARGET_NR_sigaltstack, "sigaltstack" , "%s(%p,%p)", NULL, NULL }, #endif From patchwork Sun May 19 20:37:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164547 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4808102ili; Sun, 19 May 2019 14:22:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxC3LrJrRtLp/AJUiT3xmt7A59LbUOxFw0haLqHcHGLCBNdL0vH/GRxxarEZuiRwT13XDyu X-Received: by 2002:a17:906:1303:: with SMTP id w3mr3611639ejb.196.1558300926528; Sun, 19 May 2019 14:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300926; cv=none; d=google.com; s=arc-20160816; b=m/oHjxPF/5qTDFMpnmVb8CIBnjbj1rCbmd1lEhAGDCHprXfHbaeH3fTJkJ/guz+jq3 4a/45wRRRwfWbVx8kEGbdo75WYroICLAY9BCAV8zuOv6Vb9Tv/6r/3mM707Lbg0RuCZY 7+m25h6qvCOfxcWvk0lHv5S7iI2D3tzL7J+YBHGQzXnuwkrWHnHs1ufU/LU9hkovBWfT JKJNF6+03kE4/hMNCy98quhUhFPeqJ8xXreIhBcpwq/lBHr9EYqlRsBuSSG6PSYnZ8+l 7a9z6t461/RW2qt4CJz3yFpDeToRjeOaZBliFZb2Sbw4TI5jAQ2Izp9rTxrlQSYfKc0n KEHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ZHIm//oI2ZITpFYguBWDThC46F/4JpJyOJc3fr98jRM=; b=jc63YP6DIKnBCQ+5KLKlw7FQcxWrlbWdcXYEGXKdLqEUQwUO1bOvYpX/R8fsKEKi5I OaPIdACIhJgoGVK40xKN9e3AZMEyT9/Wdxe7neGDPYUivngJE8yt6bSrVEW8bsXOLFI7 tXsbroVWbXK0+xv8z+5xjOed9qQRD/KpM3IO0eVl3LdWsPNqAZk3gUUWGCAxBOz6JYe7 jdoajj2R/0q7puZFzd1SqoSrjt4KVuAqcW0aTSbFTw43QwgziipaeMAtnKNBVoFaOhLQ 9EL/Zxshh8e28yqIAF3BPSu4nbwbaMaBkKzm91/C7dXXG5hE8aK7t9lYJlbb1g6kPa9W GcBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=V1H717ql; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o52si11948282edc.421.2019.05.19.14.22.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=V1H717ql; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTFt-00089w-Gc for patch@linaro.org; Sun, 19 May 2019 17:22:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZu-0003rD-Fo for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZt-0004lf-CO for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:37919) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZt-0004kr-5Q for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:41 -0400 Received: by mail-pl1-x643.google.com with SMTP id f97so5703959plb.5 for ; Sun, 19 May 2019 13:38:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZHIm//oI2ZITpFYguBWDThC46F/4JpJyOJc3fr98jRM=; b=V1H717qlgfK0j7xr/K+RYpqiyrSw3a5X8rIJyQvsx4ZKaPMHgXjq2nC/xJxbdghty1 b7140T3IvFhmX24cDwTJv2PBAs9jxLzXpHM4W/IeuE8FenUsUM8YTEtGyTc2KI82fPNg zEte2582fTIdNkjIKMkYXquxIvy3aFPyLTkEA/2BbZwyW7aQULkezQTzVO/dS16RU9Hk 1jxPPc8GeJnECeD8Y8BhYQeJKG0fUbXOQBNvbc3KS5qwDsRlhgpOyLEQuxRm6KTi5bJA /8UOTuM61dkVC1XROCMI1ZhZx5SZ8lmi6fFzwhDFgr7pYt2/41ASQEsC/ANYFawBVgFi xX8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZHIm//oI2ZITpFYguBWDThC46F/4JpJyOJc3fr98jRM=; b=lqutc3OBXGPbuP2PR5mvJAS8J3t1Bd7dP+FLn/p9T2KhOiZ96CvohUeDCe+JAD9jGt RHxYCmSYYpa+DeKDU9fQV2T1kWI6sLDbkeRfl4aa1CbtrgbHMezcAgy3OxyN2nsm25sP pbKdE25/o3+JLkJUjgvUzrxdRiH+8sYzHq5qeEBElViEBMGc2CGWeZkd+Sy++TNBNw+b pqKuJszXI9JIStXuqmWSmuHNwu05ePoi2FMV9wdsuz0NxuPUpEhexIJvSeTmnmjiOnWv O2YrZav6iYZaaE35vVOyTT5eBK+TUJ/9pN7n786unfoKtPKTDKQYjAdMAWIFcoAKCUBf Kfng== X-Gm-Message-State: APjAAAWNHG6XXlcrimC7AWnfmtMKixslPcsmnIomcm7IE7vu/91N27qZ QkGm3vZXI76yMxNHCNuDcN+ruCogNcc= X-Received: by 2002:a17:902:bd95:: with SMTP id q21mr35436912pls.159.1558298319969; Sun, 19 May 2019 13:38:39 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:09 -0700 Message-Id: <20190519203726.20729-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v7 57/74] linux-user: Split out sgetmask, ssetmask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++++ linux-user/syscall-sig.inc.c | 32 ++++++++++++++++++++++++++++++++ linux-user/syscall.c | 27 --------------------------- linux-user/strace.list | 6 ------ 4 files changed, 38 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index b62bffeb68..99532f75b2 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -222,6 +222,12 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #ifdef TARGET_NR_sigaction SYSCALL_DEF(sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR); #endif +#ifdef TARGET_NR_sgetmask +SYSCALL_DEF(sgetmask); +#endif +#ifdef TARGET_NR_ssetmask +SYSCALL_DEF(ssetmask, ARG_HEX); +#endif #ifdef TARGET_NR_stime SYSCALL_DEF(stime, ARG_PTR); #endif diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index 918d58878f..f50ed16b74 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -211,3 +211,35 @@ SYSCALL_IMPL(sigaction) return ret; } #endif + +#ifdef TARGET_NR_sgetmask +SYSCALL_IMPL(sgetmask) +{ + sigset_t cur_set; + abi_ulong target_set; + abi_long ret = do_sigprocmask(0, NULL, &cur_set); + + if (!ret) { + host_to_target_old_sigset(&target_set, &cur_set); + ret = target_set; + } + return ret; +} +#endif + +#ifdef TARGET_NR_ssetmask +SYSCALL_IMPL(ssetmask) +{ + sigset_t set, oset; + abi_ulong target_set = arg1; + abi_long ret; + + target_to_host_old_sigset(&set, &target_set); + ret = do_sigprocmask(SIG_SETMASK, &set, &oset); + if (!ret) { + host_to_target_old_sigset(&target_set, &oset); + ret = target_set; + } + return ret; +} +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3ef1bfb4ec..7bd410bcf0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,33 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_sgetmask /* not on alpha */ - case TARGET_NR_sgetmask: - { - sigset_t cur_set; - abi_ulong target_set; - ret = do_sigprocmask(0, NULL, &cur_set); - if (!ret) { - host_to_target_old_sigset(&target_set, &cur_set); - ret = target_set; - } - } - return ret; -#endif -#ifdef TARGET_NR_ssetmask /* not on alpha */ - case TARGET_NR_ssetmask: - { - sigset_t set, oset; - abi_ulong target_set = arg1; - target_to_host_old_sigset(&set, &target_set); - ret = do_sigprocmask(SIG_SETMASK, &set, &oset); - if (!ret) { - host_to_target_old_sigset(&target_set, &oset); - ret = target_set; - } - } - return ret; -#endif #ifdef TARGET_NR_sigprocmask case TARGET_NR_sigprocmask: { diff --git a/linux-user/strace.list b/linux-user/strace.list index 20a71adc21..3cad68e081 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1116,9 +1116,6 @@ #ifdef TARGET_NR_setxattr { TARGET_NR_setxattr, "setxattr" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sgetmask -{ TARGET_NR_sgetmask, "sgetmask" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_shutdown { TARGET_NR_shutdown, "shutdown" , NULL, NULL, NULL }, #endif @@ -1158,9 +1155,6 @@ #ifdef TARGET_NR_splice { TARGET_NR_splice, "splice" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_ssetmask -{ TARGET_NR_ssetmask, "ssetmask" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_stat { TARGET_NR_stat, "stat" , NULL, print_stat, NULL }, #endif From patchwork Sun May 19 20:37:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164559 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4814069ili; Sun, 19 May 2019 14:30:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFTBjxivCbhZBSBCzSi3lF2GVuvMyjTWriNMA4toeUymxOOXO/8NBl5fjfOfuMGWZjgsN5 X-Received: by 2002:a50:c31a:: with SMTP id a26mr72354810edb.289.1558301459519; Sun, 19 May 2019 14:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301459; cv=none; d=google.com; s=arc-20160816; b=t8OEBFIE5XTce+UP7jQefSKO2Z6r4q1uOL1qYK0lP6IFBnbh4ERSPVH3lsElq0T3pM +q3stBE0fCmWiqVpq2m8QW5uaGYV+gZWG9FhajtHG8Z674b7M/es16kL+dDkM9U+q3cL YPz9pwr1ynP1TH0Z7KjSr37xNNzALgQtB7xlYuQ3iLXKG16bLNC+JyOJaVYSXge11FL+ mcTUpjsUVc9lhfq1YxUdAb1w+n9QbOG/Db40k0t63FJpppgVSdKh+lEjN2sHpiKEE0c2 iDenmaR3/RuPFr06SCbHWLrkX8+arIztR36dX1TuSAcs84SguydSOiMbAryR1wvm+Z5z OivQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eD3ERAgN2Y5dS3+RsjRbX33QhXWDkyWUDS3x/SCrsg8=; b=1IY9AfcsmeBy77Yd+OPk3RE79Rqgs0nizlzMF7zXcqrdqy6uFhJiNtYYvlNIfaIDX3 nUMrX0xwP0tnm3heGWSx1Qv8GIK9rFqIDO9YKao+An0TdO4x018/p35YzMfDdGiKAT0D q47vdxUIKXCAFNiLM+ZevLnxjInKNTjQkcYOl8Rcjmdc+ZAhJeCHcTSL6HNCdlTtySuW /AOUMAEEpD+UiBpBd1ET96DdzWnmuI2N0tLzw2qDFtN4UfvMyJLQC8byuhuI94vwjSkk CZlgeDPQFCJBJs9BLeYq4Nnt/PO5aeMXCJyayuZXZ8iMzNAU69UG+xffdxCH04jPdsL7 VoiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hUrq3AIP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h21si1250642edj.446.2019.05.19.14.30.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hUrq3AIP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTOU-0007T8-C5 for patch@linaro.org; Sun, 19 May 2019 17:30:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZw-0003tT-8s for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZu-0004nJ-Oa for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:44 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:42365) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZu-0004mR-GS for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:42 -0400 Received: by mail-pg1-x541.google.com with SMTP id 145so5730546pgg.9 for ; Sun, 19 May 2019 13:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eD3ERAgN2Y5dS3+RsjRbX33QhXWDkyWUDS3x/SCrsg8=; b=hUrq3AIPxwR1z9E8UTuLi1JhZDec7hoB2OnfvhChro7DkS6v1PNKGntVyMnwXh/hiU 5jtbvr7jUG1kb40D6gdB+fknv2jwd5jabqHIrmSDf3JKNntnbjenKXBRKa8r/9NEG5B0 Mw5m6e7nHH6dhGKtO0IYyGo3F1mX+k6sH65THR+taomf2zVtofNttX0qqtxkVAlbItti 2gCI+x0Dn7oGhGiVF+LXZfBjcS3JRyy7kjBpl6/vM7Oz7koaJ2FDAR099qpJQ0kRv+Xf BguZCtPvgox66804ZNNOweMQ6f/zPi2G04oj5U15h9XRR0HRLGJ/b4B4MLdjLrzB6Eql ZidA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eD3ERAgN2Y5dS3+RsjRbX33QhXWDkyWUDS3x/SCrsg8=; b=pR3/nabuX23DWV6eZJt1cEkVtz3RkDT9Gj4MCZoscpKpIByht9T07NYgV/i/7MuuXi 8vbbFYXbSyux9cJHaWiYBr3J4p1FrTRq6mv4po81zDR6VxMMIi2Gh8ni/GHmYOa8kt/c JuEOjy0+MKx2nm0tKC8n0MZUiNT+iQsHNquiQvQAn7LG125EtTmeI0WofFyMpbqb/qkR qN/A/AxONsQ13D4PHMxSjMlv28DxnlGmkUIXKBZP9BBieJch7RibE0J2+w9EInQlL0lW GhgHXB0M/CNO5rlccFt+E+HuPG3SE0JYQpFoBBKiUo8C/Vq1w6LERWJTogKF/faAcrA4 ai2g== X-Gm-Message-State: APjAAAUXmhei0GkgxkaDsdHzoXWpMSnK5mx1MNUOSeQUeidsvnalXvaz GNApqOZMA7yithRRS7lvkQw3ZVDGXNY= X-Received: by 2002:aa7:8c1a:: with SMTP id c26mr75650225pfd.25.1558298321226; Sun, 19 May 2019 13:38:41 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:10 -0700 Message-Id: <20190519203726.20729-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v7 58/74] linux-user: Split out sigprocmask, rt_sigprocmask X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++ linux-user/syscall.h | 1 + linux-user/strace.c | 44 +++++++------ linux-user/syscall-sig.inc.c | 123 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 109 ------------------------------- linux-user/strace.list | 6 -- 6 files changed, 154 insertions(+), 135 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 99532f75b2..ef77f60524 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -194,6 +194,7 @@ SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_PTR, ARG_DEC); #else SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC); #endif +SYSCALL_DEF(rt_sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR, ARG_DEC); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #endif @@ -222,6 +223,11 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #ifdef TARGET_NR_sigaction SYSCALL_DEF(sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR); #endif +#if defined(TARGET_ALPHA) +SYSCALL_DEF(sigprocmask, ARG_SIGPROCMASKHOW, ARG_HEX); +#elif defined(TARGET_NR_sigprocmask) +SYSCALL_DEF(sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR); +#endif #ifdef TARGET_NR_sgetmask SYSCALL_DEF(sgetmask); #endif diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 7b197840f5..cf9f3e5e55 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -59,6 +59,7 @@ typedef enum { ARG_ATDIRFD, ARG_SIGNAL, ARG_LSEEKWHENCE, + ARG_SIGPROCMASKHOW, /* These print as sets of flags. */ ARG_ACCESSFLAG, diff --git a/linux-user/strace.c b/linux-user/strace.c index 83dd755c73..886663af2e 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -102,6 +102,27 @@ add_signal(char *buf, int size, int sig) } } +static int +add_sigprocmaskhow(char *buf, int size, int how) +{ + const char *str; + + switch (how) { + case TARGET_SIG_BLOCK: + str = "SIG_BLOCK"; + break; + case TARGET_SIG_UNBLOCK: + str = "SIG_UNBLOCK"; + break; + case TARGET_SIG_SETMASK: + str = "SIG_SETMASK"; + break; + default: + return snprintf(buf, size, "%d", how); + } + return snprintf(buf, size, "%s", str); +} + static void print_signal(abi_ulong arg, int last) { @@ -1564,26 +1585,6 @@ print_fstat(const struct syscallname *name, #define print_fstat64 print_fstat #endif -#ifdef TARGET_NR_rt_sigprocmask -static void -print_rt_sigprocmask(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - const char *how = "UNKNOWN"; - print_syscall_prologue(name); - switch(arg0) { - case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; - case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; - case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; - } - gemu_log("%s,",how); - print_pointer(arg1, 0); - print_pointer(arg2, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_rt_sigqueueinfo static void print_rt_sigqueueinfo(const struct syscallname *name, @@ -2015,6 +2016,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_SIGNAL: len = add_signal(b, rest, arg); break; + case ARG_SIGPROCMASKHOW: + len = add_sigprocmaskhow(b, rest, arg); + break; case ARG_ACCESSFLAG: len = add_flags(b, rest, access_flags, arg, false); break; diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index f50ed16b74..8a6518bdaa 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -117,6 +117,53 @@ SYSCALL_IMPL(rt_sigaction) return ret; } +SYSCALL_IMPL(rt_sigprocmask) +{ + int how = 0; + sigset_t set, oldset, *set_ptr = NULL; + abi_long ret; + void *p; + + if (arg4 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + + if (arg2) { + switch (arg1) { + case TARGET_SIG_BLOCK: + how = SIG_BLOCK; + break; + case TARGET_SIG_UNBLOCK: + how = SIG_UNBLOCK; + break; + case TARGET_SIG_SETMASK: + how = SIG_SETMASK; + break; + default: + return -TARGET_EINVAL; + } + p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, p); + unlock_user(p, arg2, 0); + set_ptr = &set; + } + + ret = do_sigprocmask(how, set_ptr, &oldset); + + if (!is_error(ret) && arg3) { + p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_sigset(p, &oldset); + unlock_user(p, arg3, sizeof(target_sigset_t)); + } + return ret; +} + #ifdef TARGET_NR_sigaction SYSCALL_IMPL(sigaction) { @@ -212,6 +259,82 @@ SYSCALL_IMPL(sigaction) } #endif +#ifdef TARGET_NR_sigprocmask +SYSCALL_IMPL(sigprocmask) +{ +#if defined(TARGET_ALPHA) + sigset_t set, oldset; + abi_ulong mask; + int how; + abi_long ret; + + switch (arg1) { + case TARGET_SIG_BLOCK: + how = SIG_BLOCK; + break; + case TARGET_SIG_UNBLOCK: + how = SIG_UNBLOCK; + break; + case TARGET_SIG_SETMASK: + how = SIG_SETMASK; + break; + default: + return -TARGET_EINVAL; + } + mask = arg2; + target_to_host_old_sigset(&set, &mask); + + ret = do_sigprocmask(how, &set, &oldset); + + if (!is_error(ret)) { + host_to_target_old_sigset(&mask, &oldset); + ret = mask; + ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; /* force no error */ + } +#else + sigset_t set, oldset, *set_ptr = NULL; + int how = 0; + abi_long ret; + void *p; + + if (arg2) { + switch (arg1) { + case TARGET_SIG_BLOCK: + how = SIG_BLOCK; + break; + case TARGET_SIG_UNBLOCK: + how = SIG_UNBLOCK; + break; + case TARGET_SIG_SETMASK: + how = SIG_SETMASK; + break; + default: + return -TARGET_EINVAL; + } + p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_old_sigset(&set, p); + unlock_user(p, arg2, 0); + set_ptr = &set; + } + + ret = do_sigprocmask(how, set_ptr, &oldset); + + if (!is_error(ret) && arg3) { + p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_old_sigset(p, &oldset); + unlock_user(p, arg3, sizeof(target_sigset_t)); + } +#endif + return ret; +} +#endif + #ifdef TARGET_NR_sgetmask SYSCALL_IMPL(sgetmask) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7bd410bcf0..11bbdfade4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,115 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_sigprocmask - case TARGET_NR_sigprocmask: - { -#if defined(TARGET_ALPHA) - sigset_t set, oldset; - abi_ulong mask; - int how; - - switch (arg1) { - case TARGET_SIG_BLOCK: - how = SIG_BLOCK; - break; - case TARGET_SIG_UNBLOCK: - how = SIG_UNBLOCK; - break; - case TARGET_SIG_SETMASK: - how = SIG_SETMASK; - break; - default: - return -TARGET_EINVAL; - } - mask = arg2; - target_to_host_old_sigset(&set, &mask); - - ret = do_sigprocmask(how, &set, &oldset); - if (!is_error(ret)) { - host_to_target_old_sigset(&mask, &oldset); - ret = mask; - ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; /* force no error */ - } -#else - sigset_t set, oldset, *set_ptr; - int how; - - if (arg2) { - switch (arg1) { - case TARGET_SIG_BLOCK: - how = SIG_BLOCK; - break; - case TARGET_SIG_UNBLOCK: - how = SIG_UNBLOCK; - break; - case TARGET_SIG_SETMASK: - how = SIG_SETMASK; - break; - default: - return -TARGET_EINVAL; - } - if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_old_sigset(&set, p); - unlock_user(p, arg2, 0); - set_ptr = &set; - } else { - how = 0; - set_ptr = NULL; - } - ret = do_sigprocmask(how, set_ptr, &oldset); - if (!is_error(ret) && arg3) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_old_sigset(p, &oldset); - unlock_user(p, arg3, sizeof(target_sigset_t)); - } -#endif - } - return ret; -#endif - case TARGET_NR_rt_sigprocmask: - { - int how = arg1; - sigset_t set, oldset, *set_ptr; - - if (arg4 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - - if (arg2) { - switch(how) { - case TARGET_SIG_BLOCK: - how = SIG_BLOCK; - break; - case TARGET_SIG_UNBLOCK: - how = SIG_UNBLOCK; - break; - case TARGET_SIG_SETMASK: - how = SIG_SETMASK; - break; - default: - return -TARGET_EINVAL; - } - if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_sigset(&set, p); - unlock_user(p, arg2, 0); - set_ptr = &set; - } else { - how = 0; - set_ptr = NULL; - } - ret = do_sigprocmask(how, set_ptr, &oldset); - if (!is_error(ret) && arg3) { - if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_sigset(p, &oldset); - unlock_user(p, arg3, sizeof(target_sigset_t)); - } - } - return ret; #ifdef TARGET_NR_sigpending case TARGET_NR_sigpending: { diff --git a/linux-user/strace.list b/linux-user/strace.list index 3cad68e081..7157876302 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -929,9 +929,6 @@ #ifdef TARGET_NR_rt_sigpending { TARGET_NR_rt_sigpending, "rt_sigpending" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_sigprocmask -{ TARGET_NR_rt_sigprocmask, "rt_sigprocmask" , NULL, print_rt_sigprocmask, NULL }, -#endif #ifdef TARGET_NR_rt_sigqueueinfo { TARGET_NR_rt_sigqueueinfo, "rt_sigqueueinfo" , NULL, print_rt_sigqueueinfo, NULL }, #endif @@ -1134,9 +1131,6 @@ #ifdef TARGET_NR_sigpending { TARGET_NR_sigpending, "sigpending" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sigprocmask -{ TARGET_NR_sigprocmask, "sigprocmask" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sigreturn { TARGET_NR_sigreturn, "sigreturn" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164543 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4806831ili; Sun, 19 May 2019 14:20:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqy97qWVwRFGaZEqlNY2jG55EiHIbuy8D8ASwGnx/QYhyED6lbjUW8g+v17nUviSwUuU/MsU X-Received: by 2002:a17:906:4e87:: with SMTP id v7mr49642776eju.150.1558300811842; Sun, 19 May 2019 14:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300811; cv=none; d=google.com; s=arc-20160816; b=J3F/zrrYv2bOAWSzP8ncM5D2608M2E9riHLftVVhrQsgB/puW6skZYePzQijw1i9Iq HlZoycQuR7krZFUDwzFQPO3Qtbin+BLf1ELrtacEfgMOweuz9X6izw4FpELhdxI2CQWw fNcdZoL5EOXS19y6fkYeIZV7UgNcGqZ9iCeW7XqwshXKCu5a+OGMwFqlAcB7XOpo6foD zCOVlchOy0fxsVSTVYeCJexMQfr7A4EUf+kL6aV9y1kfK7+Xve5TP8839AGCVzfZH0fO CCtTPJ533QyDVMfbMNsQ+9AJAMOdcFWj6f+69wSQHwkasoglYgqHwaLvMGEf/VBogYuM YYAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ECmaTCfEAMemyN6xkmuxaTzKq2RyHXzLJFeHp0RKqwc=; b=MssGGM7Z7OherikAISET87VHnXACB/wa4RranDnvN6aLN8k2h8G1KF9HobUYDYoDiZ ZacrgwmDHhlI/q+I4zFBVRVIdlsnIluZ6jvaPQFe6p814apozO5GmcKTp/x2FGdPjOAC FzZ9UStJXp3iQRiOLhz1NA5mrsEGO0FA9KGV8nbZ00BX/r7vcJTBMaW7Zhep+prjoSFc Ka6ir3vi5L8BfmdOeL3t2WWmC1IOcdUCmBO8fPOFgxoI+ZvYP6rAUt4t+fyrwk1m0jbR JXyfKmIHoQOAuio46gr3w7qnn78OoiTdiqjjfB5qDK49hnYEMRDjLYSReENHjPtgGs3B VEEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=q7VaexYd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z10si10866142edc.287.2019.05.19.14.20.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=q7VaexYd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTE2-0006PQ-Kn for patch@linaro.org; Sun, 19 May 2019 17:20:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZx-0003uD-2f for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZv-0004og-Rs for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:45 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:40703) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZv-0004np-Lt for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:43 -0400 Received: by mail-pf1-x442.google.com with SMTP id u17so6164928pfn.7 for ; Sun, 19 May 2019 13:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ECmaTCfEAMemyN6xkmuxaTzKq2RyHXzLJFeHp0RKqwc=; b=q7VaexYd+7If+cN2hjhaFwAKNkcPwnI0/CufIkGx5LDTc1sAzpKs8XJ+C2gfl+pADo JelSOM/p0qBipRdZdeO8FnD7I0Sfl3uduomlcO7xgAptqH+93GIaC/UY2EJNEQc+nc0s ais6vaUpRo6PhKvkeLIFBtto7go/wo9GoFnd6J9DGCxP5iImwhOJyGnDu6ejYdAIFbrN penQZzl50WLzHt8qszsFQlmrQR4zaiVTsSvbZ19cqsNgKTJ4g4URjeYojzVbsL5N5z1s CQ88qFOKGuCeArEIMLxAOInDYdHZi6GvDbbGSSsn5bA0Q+bXkk9RFs4HITNHasWJSwUK oboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ECmaTCfEAMemyN6xkmuxaTzKq2RyHXzLJFeHp0RKqwc=; b=CxvpAYh6jRdUMUSlpLRl0tZ4GS3AIe18vjkFeRlidFzlKM5lGMzXe6/ShrpH/7KKV1 VgBSCU0nX2k+4NujshiXqSJcIYy81ao56IjP/s0i4+mxpsk+87boHS1d0m7wZkmNfERz NGqDZdtRvwN3kfZGtY3Vet0hk7tDLtD1zZ0mqrBUB+iRahqrSdYqO0YS91ycysu72zBY 2EuTfE9T5GzciKSrcM4NIsJCVjZ68EdN5cIvdkJYP4ben/+b3zWwtnEFFixFAwF3VGip 5SahACBbFaRl47BGdzYT+byGpET30rfHYUWnR+/kbD+VaaqEvB4u5PyK3jpPCCvWmdfk qKRA== X-Gm-Message-State: APjAAAUtuwL7c1YkIn2FhUTEbx4cTn0JdIUXlUYa9fFxtFC2psShbrq/ W0oYfpDi4HgkWMWzEf4AbE0MZ0tdESk= X-Received: by 2002:a62:5487:: with SMTP id i129mr75484904pfb.68.1558298322438; Sun, 19 May 2019 13:38:42 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:11 -0700 Message-Id: <20190519203726.20729-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v7 59/74] linux-user: Split out sigpending, rt_sigpending X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall-sig.inc.c | 45 ++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 36 ----------------------------- linux-user/strace.list | 6 ----- 4 files changed, 49 insertions(+), 42 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index ef77f60524..83a69246d0 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -194,6 +194,7 @@ SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_PTR, ARG_DEC); #else SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC); #endif +SYSCALL_DEF(rt_sigpending, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR, ARG_DEC); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); @@ -223,6 +224,9 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX); #ifdef TARGET_NR_sigaction SYSCALL_DEF(sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR); #endif +#ifdef TARGET_NR_sigpending +SYSCALL_DEF(sigpending, ARG_PTR); +#endif #if defined(TARGET_ALPHA) SYSCALL_DEF(sigprocmask, ARG_SIGPROCMASKHOW, ARG_HEX); #elif defined(TARGET_NR_sigprocmask) diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index 8a6518bdaa..fe717a5121 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -117,6 +117,33 @@ SYSCALL_IMPL(rt_sigaction) return ret; } +SYSCALL_IMPL(rt_sigpending) +{ + sigset_t set; + abi_long ret; + + /* + * Yes, this check is >, not != like most. We follow the kernel's + * logic and it does it like this because it implements + * NR_sigpending through the same code path, and in that case + * the old_sigset_t is smaller in size. + */ + if (arg2 > sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + + ret = get_errno(sigpending(&set)); + if (!is_error(ret)) { + void *p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_sigset(p, &set); + unlock_user(p, arg1, sizeof(target_sigset_t)); + } + return ret; +} + SYSCALL_IMPL(rt_sigprocmask) { int how = 0; @@ -259,6 +286,24 @@ SYSCALL_IMPL(sigaction) } #endif +#ifdef TARGET_NR_sigpending +SYSCALL_IMPL(sigpending) +{ + sigset_t set; + abi_long ret = get_errno(sigpending(&set)); + + if (!is_error(ret)) { + void *p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_old_sigset(p, &set); + unlock_user(p, arg1, sizeof(target_sigset_t)); + } + return ret; +} +#endif + #ifdef TARGET_NR_sigprocmask SYSCALL_IMPL(sigprocmask) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 11bbdfade4..7dda237c95 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4241,42 +4241,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_sigpending - case TARGET_NR_sigpending: - { - sigset_t set; - ret = get_errno(sigpending(&set)); - if (!is_error(ret)) { - if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_old_sigset(p, &set); - unlock_user(p, arg1, sizeof(target_sigset_t)); - } - } - return ret; -#endif - case TARGET_NR_rt_sigpending: - { - sigset_t set; - - /* Yes, this check is >, not != like most. We follow the kernel's - * logic and it does it like this because it implements - * NR_sigpending through the same code path, and in that case - * the old_sigset_t is smaller in size. - */ - if (arg2 > sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - - ret = get_errno(sigpending(&set)); - if (!is_error(ret)) { - if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) - return -TARGET_EFAULT; - host_to_target_sigset(p, &set); - unlock_user(p, arg1, sizeof(target_sigset_t)); - } - } - return ret; #ifdef TARGET_NR_sigsuspend case TARGET_NR_sigsuspend: { diff --git a/linux-user/strace.list b/linux-user/strace.list index 7157876302..978e47bf0e 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -926,9 +926,6 @@ #ifdef TARGET_NR_rmdir { TARGET_NR_rmdir, "rmdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_sigpending -{ TARGET_NR_rt_sigpending, "rt_sigpending" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_rt_sigqueueinfo { TARGET_NR_rt_sigqueueinfo, "rt_sigqueueinfo" , NULL, print_rt_sigqueueinfo, NULL }, #endif @@ -1128,9 +1125,6 @@ #ifdef TARGET_NR_signalfd4 { TARGET_NR_signalfd4, "signalfd4" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sigpending -{ TARGET_NR_sigpending, "sigpending" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sigreturn { TARGET_NR_sigreturn, "sigreturn" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164548 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4808448ili; Sun, 19 May 2019 14:22:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+6vpY6oWStzlRkBhczGLIgPVir+snOSj7NEaOD4t/GBMf8EVkmIL8/L+b4kTUeSGEjdol X-Received: by 2002:a17:906:371b:: with SMTP id d27mr38694824ejc.80.1558300956719; Sun, 19 May 2019 14:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300956; cv=none; d=google.com; s=arc-20160816; b=sOOVfzaRh4Lj9wtGCAKJ2p4UTeNx/ggWGlxHx9oukuudqU3etdMv9hNYyZzUiBjRCQ iQHu3CYTb0AGFiJUnvYzvqVGm8MTmFfMPNCMi1rfh98J/y/+TMCcFCq/ZyID+iLNf0uF 6XXsg03K5QU2k8MB65OL+6TLJhvXVwNXPUkkRrKmKMbjgVJLKQB1e1tl3ng3YazaykVu KGy1em6Ny8wstr58MX+FapH8BidqKRx9k6GPKIz7bKVVgpqtvqVkNxFv0M5BGRpnOpZR 6UAFcpxqgP1I4SUCcVCCKBQVaPCG+XoYiPDbHrs9/tPQFD1uaXDWhH+PuTzUvcdqon1/ cuTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=76+mjrN9dH89H5/Svkq5qWa063W+g+MfoJgRAxm+Ooc=; b=Ql40HBMARL288+yER+QpX1fvtZnxvPn7u7ZJzk6pnOi5MxDg5GJyu438FZf7/xFgfl MlZ9b7iMO3zi0VI5LdpAsAXym3Msfxyy8MbL6lTLOpz/L5dR/M6TO8PZN5Z5rBJaYPfa PmqxNYHpg00vweKeIO1s5HZt+saYAdkHGsBCwDR5rYUIPDUHw5Nn6b6Top0G1KEgmImi zLQ3rRFLzpJuC4AsXwVCqkdheghLEt9kT98c4Tph/s5Gik+Eyyk/kFteRay1ByiW6vdG 37nZk6ThYHiIjNJBLIE9UujRpEp0n1ZHhLYx2ED0OzI+1z6NMjVP0ZEajFpkpB5fsz1G nftg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Edxlms5o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e22si5083119eda.365.2019.05.19.14.22.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:22:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Edxlms5o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTGN-0008I9-Hv for patch@linaro.org; Sun, 19 May 2019 17:22:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZy-0003vO-C3 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZx-0004q8-3g for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:46 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:35287) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZw-0004pR-T1 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:45 -0400 Received: by mail-pg1-x544.google.com with SMTP id t1so4322877pgc.2 for ; Sun, 19 May 2019 13:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=76+mjrN9dH89H5/Svkq5qWa063W+g+MfoJgRAxm+Ooc=; b=Edxlms5o54PZXlEF5kPdWDXQ4iTGf95k5hqzTjWT+BcEys4GQDYYRXX6bDuMS/HkUZ rW08V+EwLSK6Z+sh1Fe05z1zYUErudvuhAAB4ecpPuMou4bY98ZbO0oIjjvNDtE7lqyP boenIk/yvjt379MUEK6C3N0uBsy1hgAcUMIUbJxjFfTtQMqG/pZsaamaFoi/btMTjY4V NYDQxmIonrxBBgLe79B9vTnhP5j1yssVtfS3JyvBGOSHpYXJbnqrzywyRivvJjb9Azhr 7ofNQP9aVjO5ksoXar31E0uj9jpvG4/cpDjaiSb8FF0Xe12daTPvnJkG9+R114+e+Lq9 0Zow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=76+mjrN9dH89H5/Svkq5qWa063W+g+MfoJgRAxm+Ooc=; b=Kw7AkimgssylYhsfuIdqpQZbC1Hu2CqeoJCoyhcsjOJckc4qLurFzxonuZ3Ck3CYl3 fH9BWN6qhebIMIgP6izLNCsblp/07zw+6Pnf507ocKMpwNkovy6QYxg0alwHPLHhEpAv wsRL8RsUOWW1rPCQVDdIDh4086eSWwBTIOkyApDXd6iO+XSngcyqFDbOmCswQiquJQe1 bnEApqpd3ymbDSwhdRey6T9Y3gfb6oYF6vryjWt9z5nfLAJPiaMR9JXzaHNQ0ChvNuhP uHFhdGACwLmWnomyyIFTQA/OS4y9V9MCd+GcBUQhlJ4monkBnh/FgJWXEkgRsvUX50Iz H1Vg== X-Gm-Message-State: APjAAAUGDH9Telk523lYL4nv8kI/NODrrDsmYUQzCEKHt6ZXP2OaywOc K1SpEmTESaQMcbgTgFs+tjiiX6FRXdY= X-Received: by 2002:a63:d150:: with SMTP id c16mr71008417pgj.439.1558298323712; Sun, 19 May 2019 13:38:43 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:12 -0700 Message-Id: <20190519203726.20729-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v7 60/74] linux-user: Split out sigsuspend, rt_sigsuspend X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 +++++ linux-user/syscall-sig.inc.c | 51 ++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 42 ++--------------------------- linux-user/strace.list | 6 ----- 4 files changed, 59 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 83a69246d0..2b930f5599 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -196,6 +196,7 @@ SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC); #endif SYSCALL_DEF(rt_sigpending, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR, ARG_DEC); +SYSCALL_DEF(rt_sigsuspend, ARG_PTR, ARG_DEC); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #endif @@ -232,6 +233,11 @@ SYSCALL_DEF(sigprocmask, ARG_SIGPROCMASKHOW, ARG_HEX); #elif defined(TARGET_NR_sigprocmask) SYSCALL_DEF(sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR); #endif +#if defined(TARGET_ALPHA) +SYSCALL_DEF(sigsuspend, ARG_HEX); +#elif defined(TARGET_NR_sigsuspend) +SYSCALL_DEF(sigsuspend, ARG_PTR); +#endif #ifdef TARGET_NR_sgetmask SYSCALL_DEF(sgetmask); #endif diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index fe717a5121..23ea14e2a6 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -191,6 +191,30 @@ SYSCALL_IMPL(rt_sigprocmask) return ret; } +SYSCALL_IMPL(rt_sigsuspend) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + abi_long ret; + void *p; + + if (arg2 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&ts->sigsuspend_mask, p); + unlock_user(p, arg1, 0); + + ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, SIGSET_T_SIZE)); + if (ret != -TARGET_ERESTARTSYS) { + ts->in_sigsuspend = 1; + } + return ret; +} + #ifdef TARGET_NR_sigaction SYSCALL_IMPL(sigaction) { @@ -380,6 +404,33 @@ SYSCALL_IMPL(sigprocmask) } #endif +#ifdef TARGET_NR_sigsuspend +SYSCALL_IMPL(sigsuspend) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + abi_long ret; + +#if defined(TARGET_ALPHA) + abi_ulong mask = arg1; + target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); +#else + void *p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_old_sigset(&ts->sigsuspend_mask, p); + unlock_user(p, arg1, 0); +#endif + + ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, SIGSET_T_SIZE)); + if (ret != -TARGET_ERESTARTSYS) { + ts->in_sigsuspend = 1; + } + return ret; +} +#endif + #ifdef TARGET_NR_sgetmask SYSCALL_IMPL(sgetmask) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7dda237c95..00f4ba8753 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4227,7 +4227,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { - CPUState *cpu = ENV_GET_CPU(cpu_env); abi_long ret; #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) \ || defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) \ @@ -4241,45 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_sigsuspend - case TARGET_NR_sigsuspend: - { - TaskState *ts = cpu->opaque; -#if defined(TARGET_ALPHA) - abi_ulong mask = arg1; - target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); -#else - if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_old_sigset(&ts->sigsuspend_mask, p); - unlock_user(p, arg1, 0); -#endif - ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, - SIGSET_T_SIZE)); - if (ret != -TARGET_ERESTARTSYS) { - ts->in_sigsuspend = 1; - } - } - return ret; -#endif - case TARGET_NR_rt_sigsuspend: - { - TaskState *ts = cpu->opaque; - - if (arg2 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_sigset(&ts->sigsuspend_mask, p); - unlock_user(p, arg1, 0); - ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, - SIGSET_T_SIZE)); - if (ret != -TARGET_ERESTARTSYS) { - ts->in_sigsuspend = 1; - } - } - return ret; case TARGET_NR_rt_sigtimedwait: { sigset_t set; @@ -6659,6 +6619,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return do_set_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { + CPUState *cpu = ENV_GET_CPU(cpu_env); TaskState *ts = cpu->opaque; ts->tp_value = arg1; return 0; @@ -6673,6 +6634,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return do_get_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { + CPUState *cpu = ENV_GET_CPU(cpu_env); TaskState *ts = cpu->opaque; return ts->tp_value; } diff --git a/linux-user/strace.list b/linux-user/strace.list index 978e47bf0e..26df8b25cd 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -932,9 +932,6 @@ #ifdef TARGET_NR_rt_sigreturn { TARGET_NR_rt_sigreturn, "rt_sigreturn" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_sigsuspend -{ TARGET_NR_rt_sigsuspend, "rt_sigsuspend" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_rt_sigtimedwait { TARGET_NR_rt_sigtimedwait, "rt_sigtimedwait" , NULL, NULL, NULL }, #endif @@ -1128,9 +1125,6 @@ #ifdef TARGET_NR_sigreturn { TARGET_NR_sigreturn, "sigreturn" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sigsuspend -{ TARGET_NR_sigsuspend, "sigsuspend" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_socket { TARGET_NR_socket, "socket" , NULL, print_socket, NULL }, #endif From patchwork Sun May 19 20:37:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164551 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4810279ili; Sun, 19 May 2019 14:25:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMg/btF7Q8QnbyyoTMz0zcG9Lkk6TjorzwcuVIzC9WAJyKb2FkUy9RhTpSKyVMwHZzi83a X-Received: by 2002:a17:906:2cd1:: with SMTP id r17mr55510823ejr.101.1558301113203; Sun, 19 May 2019 14:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301113; cv=none; d=google.com; s=arc-20160816; b=hBAF1/gYou1O2vj3MHBYbvq+ohqhHE278z68JkvfRFCimBWlEivtZb5gMijQqDi6xJ vVUfmaWPb7mR6H3RT84zKSSvLn5HSZDCvGuQbevUhJqLRwv2UpUGRK2v27FF+e+7MgaL h+YIusNoQtYWL6iHHoC6cE/O7XZ/yDNb4A8yuzfnS8FDorgEm4jUAh/aXt+fRWwD8ln4 3KCzWzaOq7/kMjzkrz2lI5Ee7u3wmId8gs45+QOdXPVH79C6b+oiqtZbOX0KLvHeRMiu V5YWZKNdhqNGBMi2ceXdlc3jawTOghLtbAHjWXm6TTcSXbRSAuYMxQj/AXvXtJt1FSlH qmkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Y5HxahaYaY6QYC1uo4aAY7RPOmMGvLOX7tv8PUypEZk=; b=iOTh1+sUmH0Z1fPP+rGUJqbj3Kp5Dhw8YnXnCMQQbVMt5ywoQGFp3j354MW0WhYE+3 1MSA8PCBJEW8oJHORfdM13aFNscdloyMzIwySBedgrW1gw2UGJ2tOkbMPO+KPVscvLIY wr/e1CQtBw2Bt29nsJL8Ylf9XKCa3b6uh6qjRK6w3cR/EJjWGl/y2lZqOb7/mejhkYoM xtrcK+VH+ytkoe+RCigm0cmPe5GFH2TfCqOkf6jlSIh2UXY8nAJ5YH2uhTLPH+YAJ49/ zw04QbyyHGlw/NLjUzWCn7HzcLTbXIaGGvRX3Jyl/tOALmoIcFSFTkED6LCUQ8KK5R80 TmXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DoYXlx3P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w4si539619eju.53.2019.05.19.14.25.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:25:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DoYXlx3P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTIu-0002Ut-1D for patch@linaro.org; Sun, 19 May 2019 17:25:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZz-0003vo-8Y for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZy-0004rK-4v for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:47 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:38181) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZx-0004qY-V9 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:46 -0400 Received: by mail-pg1-x541.google.com with SMTP id j26so5741184pgl.5 for ; Sun, 19 May 2019 13:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y5HxahaYaY6QYC1uo4aAY7RPOmMGvLOX7tv8PUypEZk=; b=DoYXlx3PoHm8K+tZgACald1wGeogE569sqfxk9pncSL5eWSgZiCOOAfBTZUTBk7KuF 05qBqU1l1+cXBY7RkbZ3GSsZgV/jWVTMILzW3HDstXMXcaRdU+sljGNESKbrz8T91oJN RqDb+1eozWltuCG0t8tjjiM8nOZO8jBVL+vqe86sCTwjkc6TorTRvlV1IVNCXzMVLuec yXZ7pM1qHmQoeTnurS3HNCXlqIuYrdcTy9zfSb81RJvh85FApQbIaCf5NYdNIY1i4zuM P3LW+i1k+52A1bOFnU/9mygqWT9fz4wMoytl5uxThSeXiuPltdpQjfAcKQFjPefsI2FM XolA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Y5HxahaYaY6QYC1uo4aAY7RPOmMGvLOX7tv8PUypEZk=; b=p6rTunQPXRxfQkVlcagCD/xHYB45UWkXrA2RXuAZw3/b3jDFjpFtzL95p8dzKhC59v 5Js0XH5B3r6/0V7bPZSP3KwsF4B3iNB0wS3c0KWYSSi9MxD/BzSGCK1GlqfepmvLrsfV ueuv8BN0P8dD7Q8sDSb9BkJJMFI6pfLcFnCzP5aC77uNRUqTGA4SPMzMrIe7NmdWvMbG yZ/S2jEodZVctvQXDatqfoIXNmD8rfXqmBUiv6CM/jATvsg5lfQUE0c9SB4YzJoowRbU kIdfBgJwkRgB54Nb518NCuhYyOiVxe6Fp3A+AuDOGn65L+O1eKaDv3L15SYGR7MvOhfQ 8TBQ== X-Gm-Message-State: APjAAAX9qBBYQARh0cPUnmASYtpG76OcTg/VL+3NYkjsRqYcNlZ7oab6 P1uizuKFwQ7CZoMNpWE7dODbHap+LZE= X-Received: by 2002:a62:117:: with SMTP id 23mr47169063pfb.156.1558298324723; Sun, 19 May 2019 13:38:44 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:13 -0700 Message-Id: <20190519203726.20729-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v7 61/74] linux-user: Split out rt_sigtimedwait X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-sig.inc.c | 37 ++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 36 ----------------------------------- linux-user/strace.list | 3 --- 4 files changed, 38 insertions(+), 39 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 2b930f5599..24289ed413 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -197,6 +197,7 @@ SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigpending, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigsuspend, ARG_PTR, ARG_DEC); +SYSCALL_DEF(rt_sigtimedwait, ARG_PTR, ARG_PTR, ARG_PTR, ARG_DEC); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #endif diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index 23ea14e2a6..5f2c0ba499 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -215,6 +215,43 @@ SYSCALL_IMPL(rt_sigsuspend) return ret; } +SYSCALL_IMPL(rt_sigtimedwait) +{ + sigset_t set; + struct timespec uts, *puts = NULL; + siginfo_t uinfo; + abi_long ret; + void *p; + + if (arg4 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, p); + unlock_user(p, arg1, 0); + if (arg3) { + puts = &uts; + target_to_host_timespec(puts, arg3); + } + + ret = get_errno(safe_rt_sigtimedwait(&set, &uinfo, puts, SIGSET_T_SIZE)); + if (!is_error(ret)) { + if (arg2) { + p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &uinfo); + unlock_user(p, arg2, sizeof(target_siginfo_t)); + } + ret = host_to_target_signal(ret); + } + return ret; +} + #ifdef TARGET_NR_sigaction SYSCALL_IMPL(sigaction) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 00f4ba8753..8a05d3e32a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4240,42 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_rt_sigtimedwait: - { - sigset_t set; - struct timespec uts, *puts; - siginfo_t uinfo; - - if (arg4 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - - if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - return -TARGET_EFAULT; - target_to_host_sigset(&set, p); - unlock_user(p, arg1, 0); - if (arg3) { - puts = &uts; - target_to_host_timespec(puts, arg3); - } else { - puts = NULL; - } - ret = get_errno(safe_rt_sigtimedwait(&set, &uinfo, puts, - SIGSET_T_SIZE)); - if (!is_error(ret)) { - if (arg2) { - p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), - 0); - if (!p) { - return -TARGET_EFAULT; - } - host_to_target_siginfo(p, &uinfo); - unlock_user(p, arg2, sizeof(target_siginfo_t)); - } - ret = host_to_target_signal(ret); - } - } - return ret; case TARGET_NR_rt_sigqueueinfo: { siginfo_t uinfo; diff --git a/linux-user/strace.list b/linux-user/strace.list index 26df8b25cd..0b2c057673 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -932,9 +932,6 @@ #ifdef TARGET_NR_rt_sigreturn { TARGET_NR_rt_sigreturn, "rt_sigreturn" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_sigtimedwait -{ TARGET_NR_rt_sigtimedwait, "rt_sigtimedwait" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_rt_tgsigqueueinfo { TARGET_NR_rt_tgsigqueueinfo, "rt_tgsigqueueinfo" , NULL, print_rt_tgsigqueueinfo, NULL }, #endif From patchwork Sun May 19 20:37:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164552 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4810582ili; Sun, 19 May 2019 14:25:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4eFTpMGbBzaXF+qIfvIQELHo2bh2MeFrz/wAKwUC96lI0On9UuXKoM+rIYh8hQWSpFArc X-Received: by 2002:a50:b835:: with SMTP id j50mr70653501ede.63.1558301140740; Sun, 19 May 2019 14:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301140; cv=none; d=google.com; s=arc-20160816; b=gm7E8UWju2U7AznQlCEpDx0pcsZGvRSMhrcmzazA3eigKVcexF8M8GPth6eroGujI7 0JmyX8bM2Wcuh7JTOfqplA4PTDISMyXBmuOoOTwGt15+KzdWkNPjFGVPIyFtM0tYw0IY doJJnwXkev991peMZRyVHNpXxnEgj/YYVClrGS8moIeCsEOSEJghP6bHZk0f/gG28zml QmvOWS9h67XTw/jaB/Pj+QuH6gyzlC9Puzhbc/fwdARLbU7bxBFVAPiFo7JZuJ0Q7eq+ CC70f9w75zJnrn3tIVOkdgO0yyghkfpCKD1/J8gNsKzo7Y+EtMMe6CErHd9GYCAoIQ3A nEoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=H+hAO3lCLGHX0woDMYAcESGWkiYaW7BEOcuLvxL4WTY=; b=rmJ6Mi35ZQeYQaFRujeYj+tcLiyF7nWFcIPNIF+mBE/OPFT5TZvHIw3cw2aWV4vPaj rcLkHscLzuJidz0mSaVC5a8pY3gDzF/DnJVtzKF39ypdTGcZtXubAbdLDhwcTRE33mu5 Ye/IpfsnnXnZyRqW2ixSlyLrEZbfSFAO4oZo6tnt1Vgi5ji4DPdga/U2MxxKscq7t1E5 bOH3WOXJgUDSScMdE8tZ6QNHj7b6YcT6zcQqS7lPcjxtDzW1m4uH3xG6woqLa7rYnKiH Urh6LIwmSBmL6WvyBwzSg6/PJhTtmL/zd0mMds/aWmam0c/NLDznkI0R6IVx4ev6teiN jtGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QeJ25agB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l22si13905275edd.449.2019.05.19.14.25.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:25:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QeJ25agB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTJL-0002aT-En for patch@linaro.org; Sun, 19 May 2019 17:25:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa0-0003xH-W7 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZz-0004t4-F0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:48 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:34965) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZz-0004s4-7E for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:47 -0400 Received: by mail-pf1-x443.google.com with SMTP id t87so6175534pfa.2 for ; Sun, 19 May 2019 13:38:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H+hAO3lCLGHX0woDMYAcESGWkiYaW7BEOcuLvxL4WTY=; b=QeJ25agBxzK7WHQT5PUY2JNCKaE7N/t8OMwnVfB4Jz6xK/ME4pC8V7B+D/HErzmbZY AGaHXD0ea/A6XBxMFg+EDYe2ch5M2bBVtCARpqGJ4Xg0UN2WSNw+Tup3xHGl0K6on85+ KKTUezVm26GhujnhMNxL6hA57SLHUQzFTjceowQ6j+RNGE7A0gsJY+pwjQQ7KWoM3NAX spssYvD4E25qQcv3RCwq4n+L/sCTsJOdMD0jwCAlVxNz3Ab5/EBUqopTSV1IJnu1YFEC opIvh7R8FasIff62tnB2jcVPBgeqHHN96YCMYOoUfwkqL3huV3GOjUYwbn01B/mheNFh fDiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H+hAO3lCLGHX0woDMYAcESGWkiYaW7BEOcuLvxL4WTY=; b=X/znZy22DLmxwck6GuvPqOpznXC8bLFETfzzIxddoTdhxV9hwPgEe9qHJw4ZpU6Mgm L0cBRW+UKduUj8PcYGnqA26RuCRxOGMCLLUxQXhm/5KkLfAz/5u7KxJEDj8uKMSNg+2x Y6xVUlDrfxMvIWvUod+Gleq0kIWrXB3dQw2MXL3zy1yzSbfcZvnfPdPAemDPEHFcwzfe TAt2r3DmJei8I2mSC8353zIsG9IpGBr04COmi7OUBtqQDWna3500JS03HTCY4PTSVEaz IUks2qs0UIIdNpA6zzQl2NswmCs/xS09a9WHRRzogxe1ig7p+woYtmhLPVw/Gjrosz+Y k08Q== X-Gm-Message-State: APjAAAVFQUgmW1dbSd+2Ey8dkVgyM4icV7HwBMsBhIIrt583OOAX4qrx 6610ESCGCISiPIZLy4ytSvIA0a3hVKg= X-Received: by 2002:a63:d354:: with SMTP id u20mr23001764pgi.129.1558298325924; Sun, 19 May 2019 13:38:45 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:14 -0700 Message-Id: <20190519203726.20729-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v7 62/74] linux-user: Split out rt_sigqueueinfo, rt_tgsigqueueinfo X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This does drop the (questionable) siginfo_t printing. But since we already do not handle more important things in this area like sigset_t, this does not feel a loss. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 + linux-user/strace.c | 138 ----------------------------------- linux-user/syscall-sig.inc.c | 30 ++++++++ linux-user/syscall.c | 26 ------- linux-user/strace.list | 6 -- 5 files changed, 32 insertions(+), 170 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 24289ed413..11851535e1 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -196,8 +196,10 @@ SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC); #endif SYSCALL_DEF(rt_sigpending, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR, ARG_DEC); +SYSCALL_DEF(rt_sigqueueinfo, ARG_DEC, ARG_SIGNAL, ARG_PTR); SYSCALL_DEF(rt_sigsuspend, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigtimedwait, ARG_PTR, ARG_PTR, ARG_PTR, ARG_DEC); +SYSCALL_DEF(rt_tgsigqueueinfo, ARG_DEC, ARG_DEC, ARG_SIGNAL, ARG_PTR); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 886663af2e..2e70a3910c 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -167,93 +167,6 @@ static void print_si_code(int arg) gemu_log("%s", codename); } -static void get_target_siginfo(target_siginfo_t *tinfo, - const target_siginfo_t *info) -{ - abi_ulong sival_ptr; - - int sig; - int si_errno; - int si_code; - int si_type; - - __get_user(sig, &info->si_signo); - __get_user(si_errno, &tinfo->si_errno); - __get_user(si_code, &info->si_code); - - tinfo->si_signo = sig; - tinfo->si_errno = si_errno; - tinfo->si_code = si_code; - - /* Ensure we don't leak random junk to the guest later */ - memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad)); - - /* This is awkward, because we have to use a combination of - * the si_code and si_signo to figure out which of the union's - * members are valid. (Within the host kernel it is always possible - * to tell, but the kernel carefully avoids giving userspace the - * high 16 bits of si_code, so we don't have the information to - * do this the easy way...) We therefore make our best guess, - * bearing in mind that a guest can spoof most of the si_codes - * via rt_sigqueueinfo() if it likes. - * - * Once we have made our guess, we record it in the top 16 bits of - * the si_code, so that print_siginfo() later can use it. - * print_siginfo() will strip these top bits out before printing - * the si_code. - */ - - switch (si_code) { - case SI_USER: - case SI_TKILL: - case SI_KERNEL: - /* Sent via kill(), tkill() or tgkill(), or direct from the kernel. - * These are the only unspoofable si_code values. - */ - __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid); - __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid); - si_type = QEMU_SI_KILL; - break; - default: - /* Everything else is spoofable. Make best guess based on signal */ - switch (sig) { - case TARGET_SIGCHLD: - __get_user(tinfo->_sifields._sigchld._pid, - &info->_sifields._sigchld._pid); - __get_user(tinfo->_sifields._sigchld._uid, - &info->_sifields._sigchld._uid); - __get_user(tinfo->_sifields._sigchld._status, - &info->_sifields._sigchld._status); - __get_user(tinfo->_sifields._sigchld._utime, - &info->_sifields._sigchld._utime); - __get_user(tinfo->_sifields._sigchld._stime, - &info->_sifields._sigchld._stime); - si_type = QEMU_SI_CHLD; - break; - case TARGET_SIGIO: - __get_user(tinfo->_sifields._sigpoll._band, - &info->_sifields._sigpoll._band); - __get_user(tinfo->_sifields._sigpoll._fd, - &info->_sifields._sigpoll._fd); - si_type = QEMU_SI_POLL; - break; - default: - /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */ - __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid); - __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid); - /* XXX: potential problem if 64 bit */ - __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr); - tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr; - - si_type = QEMU_SI_RT; - break; - } - break; - } - - tinfo->si_code = deposit32(si_code, 16, 16, si_type); -} - static void print_siginfo(const target_siginfo_t *tinfo) { /* Print a target_siginfo_t in the format desired for printing @@ -1585,57 +1498,6 @@ print_fstat(const struct syscallname *name, #define print_fstat64 print_fstat #endif -#ifdef TARGET_NR_rt_sigqueueinfo -static void -print_rt_sigqueueinfo(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - void *p; - target_siginfo_t uinfo; - - print_syscall_prologue(name); - print_raw_param("%d", arg0, 0); - print_signal(arg1, 0); - p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); - if (p) { - get_target_siginfo(&uinfo, p); - print_siginfo(&uinfo); - - unlock_user(p, arg2, 0); - } else { - print_pointer(arg2, 1); - } - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_rt_tgsigqueueinfo -static void -print_rt_tgsigqueueinfo(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - void *p; - target_siginfo_t uinfo; - - print_syscall_prologue(name); - print_raw_param("%d", arg0, 0); - print_raw_param("%d", arg1, 0); - print_signal(arg2, 0); - p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); - if (p) { - get_target_siginfo(&uinfo, p); - print_siginfo(&uinfo); - - unlock_user(p, arg3, 0); - } else { - print_pointer(arg3, 1); - } - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_syslog static void print_syslog_action(abi_ulong arg, int last) diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index 5f2c0ba499..774346838b 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -191,6 +191,21 @@ SYSCALL_IMPL(rt_sigprocmask) return ret; } +SYSCALL_IMPL(rt_sigqueueinfo) +{ + siginfo_t uinfo; + void *p; + + p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_siginfo(&uinfo, p); + unlock_user(p, arg3, 0); + + return get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); +} + SYSCALL_IMPL(rt_sigsuspend) { CPUState *cpu = ENV_GET_CPU(cpu_env); @@ -252,6 +267,21 @@ SYSCALL_IMPL(rt_sigtimedwait) return ret; } +SYSCALL_IMPL(rt_tgsigqueueinfo) +{ + siginfo_t uinfo; + void *p; + + p = lock_user(VERIFY_READ, arg4, sizeof(target_siginfo_t), 1); + if (!p) { + return -TARGET_EFAULT; + } + target_to_host_siginfo(&uinfo, p); + unlock_user(p, arg4, 0); + + return get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo)); +} + #ifdef TARGET_NR_sigaction SYSCALL_IMPL(sigaction) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8a05d3e32a..e489d12103 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4240,32 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_rt_sigqueueinfo: - { - siginfo_t uinfo; - - p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); - if (!p) { - return -TARGET_EFAULT; - } - target_to_host_siginfo(&uinfo, p); - unlock_user(p, arg3, 0); - ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); - } - return ret; - case TARGET_NR_rt_tgsigqueueinfo: - { - siginfo_t uinfo; - - p = lock_user(VERIFY_READ, arg4, sizeof(target_siginfo_t), 1); - if (!p) { - return -TARGET_EFAULT; - } - target_to_host_siginfo(&uinfo, p); - unlock_user(p, arg4, 0); - ret = get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo)); - } - return ret; #ifdef TARGET_NR_sigreturn case TARGET_NR_sigreturn: if (block_signals()) { diff --git a/linux-user/strace.list b/linux-user/strace.list index 0b2c057673..57445a8d81 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -926,15 +926,9 @@ #ifdef TARGET_NR_rmdir { TARGET_NR_rmdir, "rmdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_sigqueueinfo -{ TARGET_NR_rt_sigqueueinfo, "rt_sigqueueinfo" , NULL, print_rt_sigqueueinfo, NULL }, -#endif #ifdef TARGET_NR_rt_sigreturn { TARGET_NR_rt_sigreturn, "rt_sigreturn" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_tgsigqueueinfo -{ TARGET_NR_rt_tgsigqueueinfo, "rt_tgsigqueueinfo" , NULL, print_rt_tgsigqueueinfo, NULL }, -#endif #ifdef TARGET_NR_sched_getaffinity { TARGET_NR_sched_getaffinity, "sched_getaffinity" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164557 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4813631ili; Sun, 19 May 2019 14:30:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoSMnLe5r90awOMxm1Wzukg6RECJSJWApcpQ7Fgs1dd0DCjX7IjaQv9XiHUo+aHvcYn8NP X-Received: by 2002:a17:907:2084:: with SMTP id pv4mr3493177ejb.116.1558301429151; Sun, 19 May 2019 14:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301429; cv=none; d=google.com; s=arc-20160816; b=tM2w3D3B2Z0edNjYGDyzPAADudAIjTWDic689yHlmPNHO6VesThP3/DeC8IZVzb44F 6lO4EV6YW76NaDmHRkbLWNuq18oeV/fCrhLEvlzN+oqUc3gJbuN3EbQyDawJzezkWjfv O2d31JkfHhVBnffW1tYW1LdDcgCRSS01fhzxHvVCSWS/VhoW1z7/tb+0d3Mlq9XVMgDd CM2F5KUOscKeSUefnkdqqISeV3jjSqJhzmEP82f7IIdiJ/GKIVdIXQsHPdLxKnQgUY7u VGpDjSRgYjNt1M/a1V1g4mfDbFQlcZ0QkE0RHmeWds3JJYnf7NFokB55Wbb8xc0NvFMV SUDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=nKLZCrlKSTO+R1LDAJ7MTC0/n6ttp1lefRgjBzvM1II=; b=PsUG4n9S3Y7UHlMXOwEV/nvlMzqYzpDBu8pVKUbS7rNk4rvCMvOKXukxo2sZlOH5jt 1czhUskDczoX+Y70+oY/JfSHF9nXVC3Qa+S89wC+h3pAnIFhuAJzjGVZNrVZLO8EDOO5 a9K4yLHaznS9W7Z89kuRM6RN8IUzu0skrLwG4jn88NxOQABTfvTFEgwT1b+PxMZuBw2e wXU94jr7cO8MsfsBPGGUqNojumudaTCzIMMGOTwJlyYTqcEEk5HG8Rg/hb5xE0/yH3X9 4+vmTCqb3fZ8gro7To9CZnaakN2tPwplvuAtYVIVTeqPiis9snZ9kwc0Qr8nbW7jALus wjEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=brmejX2y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z58si424000edd.244.2019.05.19.14.30.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:30:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=brmejX2y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTO0-0007JS-2D for patch@linaro.org; Sun, 19 May 2019 17:30:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa1-0003xz-QC for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa0-0004ub-Lo for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:49 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:34651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa0-0004to-EG for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:48 -0400 Received: by mail-pl1-x642.google.com with SMTP id w7so5728149plz.1 for ; Sun, 19 May 2019 13:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nKLZCrlKSTO+R1LDAJ7MTC0/n6ttp1lefRgjBzvM1II=; b=brmejX2yIcPNjbKuVHCqV8AiCa1JJMdtPGr20MMLPBmCbCH8F8nnPJLHfbogkaawYS 5MWYoLGmRdwxv176WTA+TIj0WRt7ds8eDGCjowF36zkM3oTIhPG3UX5RHX75QmX9g0Bj 6M/v8WVOfulZJHBQ3O4Ni3A/c7faz1hQuBBJxe2CWZqUR2RsUGvTiCdCspP44hAuJPXJ UuiP0ArLKSf57V3ghQKN5nnGFHdcqtHuVz9I/3+VSeeim6MKiAFQ18nIZ2o7OMaOS9mW KH5iNAtVlaiVKV5Pa3XDzdIVwYIYTC1HGLWmt8otn3ZeyoyLyHeAYmcBNRWQXUdkuWkD Rl4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nKLZCrlKSTO+R1LDAJ7MTC0/n6ttp1lefRgjBzvM1II=; b=VYF5SPZW3eA+olqHHN5qPYjtbo0NHq4eNBh5e7U3Wx+dkXB9x+1kusPmsALi1Gh5zi LFVjGi9bpn1wXCfAi381Mx+O5MPywFtD7jYHSjXbh6K6hH1ItkmQ4OHHF3gohT2X4YwQ QwloM/C50HRC7OiWoonVnMP4+tTgtmVOR1OiVfskmBjhAptsfPAkt3ZQH67uA/j6u9PJ FB55phQ+uQS+jkkjTJkSjOwLq4aLnB59YXF6Sbrg3cQCUxEY3OopYdMLey44X0bNbg7I ixXXf37Dzry4Ph8GIoQLqKGxYryM+SC1LufJMzCHsze03HIlqK2KUMqCiCoJ2vY9z0o2 ByjA== X-Gm-Message-State: APjAAAW70IJ/xRNSiC+Zp2zcY6Y+afgs/cupL6GVyuoGBKyu+ZYIO1u3 Lz8ykUumjDzUShHqOSBRafWToesiFNg= X-Received: by 2002:a17:902:6b8b:: with SMTP id p11mr70527578plk.225.1558298327154; Sun, 19 May 2019 13:38:47 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:15 -0700 Message-Id: <20190519203726.20729-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH v7 63/74] linux-user: Split out sigreturn, rt_sigreturn X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall-sig.inc.c | 18 ++++++++++++++++++ linux-user/syscall.c | 12 ------------ linux-user/strace.list | 6 ------ 4 files changed, 22 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 11851535e1..77d750f66f 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -197,6 +197,7 @@ SYSCALL_DEF(rt_sigaction, ARG_SIGNAL, ARG_PTR, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigpending, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigqueueinfo, ARG_DEC, ARG_SIGNAL, ARG_PTR); +SYSCALL_DEF(rt_sigreturn); SYSCALL_DEF(rt_sigsuspend, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigtimedwait, ARG_PTR, ARG_PTR, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_tgsigqueueinfo, ARG_DEC, ARG_DEC, ARG_SIGNAL, ARG_PTR); @@ -236,6 +237,9 @@ SYSCALL_DEF(sigprocmask, ARG_SIGPROCMASKHOW, ARG_HEX); #elif defined(TARGET_NR_sigprocmask) SYSCALL_DEF(sigprocmask, ARG_SIGPROCMASKHOW, ARG_PTR, ARG_PTR); #endif +#ifdef TARGET_NR_sigreturn +SYSCALL_DEF(sigreturn); +#endif #if defined(TARGET_ALPHA) SYSCALL_DEF(sigsuspend, ARG_HEX); #elif defined(TARGET_NR_sigsuspend) diff --git a/linux-user/syscall-sig.inc.c b/linux-user/syscall-sig.inc.c index 774346838b..d5c0ccdcc3 100644 --- a/linux-user/syscall-sig.inc.c +++ b/linux-user/syscall-sig.inc.c @@ -206,6 +206,14 @@ SYSCALL_IMPL(rt_sigqueueinfo) return get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); } +SYSCALL_IMPL(rt_sigreturn) +{ + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + return do_rt_sigreturn(cpu_env); +} + SYSCALL_IMPL(rt_sigsuspend) { CPUState *cpu = ENV_GET_CPU(cpu_env); @@ -471,6 +479,16 @@ SYSCALL_IMPL(sigprocmask) } #endif +#ifdef TARGET_NR_sigreturn +SYSCALL_IMPL(sigreturn) +{ + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + return do_sigreturn(cpu_env); +} +#endif + #ifdef TARGET_NR_sigsuspend SYSCALL_IMPL(sigsuspend) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e489d12103..b8b18ac1de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4240,18 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_sigreturn - case TARGET_NR_sigreturn: - if (block_signals()) { - return -TARGET_ERESTARTSYS; - } - return do_sigreturn(cpu_env); -#endif - case TARGET_NR_rt_sigreturn: - if (block_signals()) { - return -TARGET_ERESTARTSYS; - } - return do_rt_sigreturn(cpu_env); case TARGET_NR_sethostname: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; diff --git a/linux-user/strace.list b/linux-user/strace.list index 57445a8d81..b1c2f7851e 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -926,9 +926,6 @@ #ifdef TARGET_NR_rmdir { TARGET_NR_rmdir, "rmdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_rt_sigreturn -{ TARGET_NR_rt_sigreturn, "rt_sigreturn" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sched_getaffinity { TARGET_NR_sched_getaffinity, "sched_getaffinity" , NULL, NULL, NULL }, #endif @@ -1113,9 +1110,6 @@ #ifdef TARGET_NR_signalfd4 { TARGET_NR_signalfd4, "signalfd4" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sigreturn -{ TARGET_NR_sigreturn, "sigreturn" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_socket { TARGET_NR_socket, "socket" , NULL, print_socket, NULL }, #endif From patchwork Sun May 19 20:37:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164560 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4815602ili; Sun, 19 May 2019 14:32:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvOeZfDvpQ8OKNPlZ5+UZKh4v/s8aSKtARgY7vx8BZ1TS/aVgJ+CH77eR9xdaXwaLRq1Ir X-Received: by 2002:a17:906:1ec2:: with SMTP id m2mr52957234ejj.47.1558301570942; Sun, 19 May 2019 14:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301570; cv=none; d=google.com; s=arc-20160816; b=us0j/2M9fl3RgM0ayKhQqPQE08bMEF5yzU8VRwnqBMV5aD/bTBDmeC00w1ZNfw7IpS S8bYMD7m8DGM2vWaNRrXzcD4aX6gR/46za8r0j6SPQpNzabUqp4YvPaM9GWruMtJIDni tF5I2x6U2a52CVtDklk2N7FG36EyQgPFWL7aV5X4txW3Z5GVqzF+GN2vYgTd6l4hf8cb 2Iz+cLrcx+6uiUUxPDeiUpVK5XQL14nxYVrIO9R3RwDWZVxVib5JPQgQGEPncx7Zn8Zd XveGB4yyOOxhV4MWnBLUR7V5Kaip1NnKf5K/TyWV3M0wj4boUbVIjcvmG6PM66w3jrNx /1Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=+4pgGcHqpI/1ayoviAyV/bToyhUBomMihY7gyQ1lsgY=; b=AESgXsatTf/ddcSTPSHm4ZKCKsJ/F0n0bAZoOsy6fyWDxBo/aoeTTkBpLr6FN4TBWj 5qSPBqxsdVZrKm5HFh3HofViS7ilkeBpRK+3p1Dj61+nUHIVmaHabwQC6jpGlqZuQICR CGghcH+J9SmvbYdH/m354KZepYtp4CeXqEFMFM6ujgSBeyPGJyV46V8fO8VuMaulz1PE ATdNwBCROJ1MxzeIsHAvghSxuJDYPBitwySIEhQYpoAb+/Ssgi168JuctfhCCHwTplFO 2GvW/XVbA9y5lDC4WcEUfvHnITCObN8FKVW/tdlpxfkr9tuByLGkd46gj8iXc8S9wF32 eOpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="yNOh/qnB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x12si1503398eda.175.2019.05.19.14.32.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="yNOh/qnB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTQH-0000ln-Pj for patch@linaro.org; Sun, 19 May 2019 17:32:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa3-0003zR-5a for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa1-0004w6-Rg for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:51 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:32992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa1-0004vH-HJ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:49 -0400 Received: by mail-pf1-x442.google.com with SMTP id z28so6189151pfk.0 for ; Sun, 19 May 2019 13:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+4pgGcHqpI/1ayoviAyV/bToyhUBomMihY7gyQ1lsgY=; b=yNOh/qnBcfc5fIBsPkbMKp0aWj5JMGBfKFKQuWBaSZTKRjfxkpgNhxvNaDzlLjCYqs TBrqkqUE3q6+xcHx14kx7BGthawXJrn7hA6SwtgdfUST9H87q10uzV7pgPHZy5xoBmmT njOXPTa/zL8C2VlkoQLT1vPUn1nfwFF67WuZJy8lPiVxL2/aAZlYNpvW5sKBCYrBTFoP 3UX52KZDgSlYFnIGePYlIvDdzCAm8d1porwbeQENJQxcYceAIlqQxH1GAGMdlFVaL4DX mu1/gDeY8HF0lX2dupdU/NoxBswx5V5zRU/b70NHoKPMb1f6fYv+k2p/X8i/W189OSV8 FtMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+4pgGcHqpI/1ayoviAyV/bToyhUBomMihY7gyQ1lsgY=; b=EkKP9tFDzIMKcPTOMkMn3YrKn5NCj9LZBsDIWBaIEXsVbAM7m7dDNeDHBhFwDnE9d6 U/7D1qkKygAI7azu3yJ3UdwXAo3kjG5dskyMMhITJKP9dJvd9LX3jZeHFReHK0dnZdI0 xvZ2xVPw+f7qyvWs7BgvdrC2bIRpNapJkzZBcmWOIfe+qUdE6AAPtfZKF1s6nDuDVFvC 5eb38mh+uChI8gaHyG7ae3Pk4pKoWeqIPcYprpxJf1ZODv8XJnm5EUB3Aup5VY+n0qnm FotfYPh8pR/thmm6NMsgpLRADP4aokVaisT/F0VLOJmZJzSmsgnKqXbStHwXgUMcXCgf tAuw== X-Gm-Message-State: APjAAAV0yZh26cL2FLaRrBmJhBneTXzNWUR2zC7dgWWo/MVBF+O7jgtn F+ysKiJuRGrTWCen//gmYZDvp045ZYU= X-Received: by 2002:a63:6a4a:: with SMTP id f71mr70548969pgc.44.1558298328375; Sun, 19 May 2019 13:38:48 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:16 -0700 Message-Id: <20190519203726.20729-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v7 64/74] linux-user: Split out gethostname, sethostname X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall-proc.inc.c | 28 ++++++++++++++++++++++++++++ linux-user/syscall.c | 19 ------------------- linux-user/strace.list | 6 ------ 4 files changed, 32 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 77d750f66f..3ba697fd53 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -59,6 +59,9 @@ SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif +#ifdef TARGET_NR_gethostname +SYSCALL_DEF(gethostname, ARG_PTR, ARG_DEC); +#endif SYSCALL_DEF(getpgid, ARG_DEC); #ifdef TARGET_NR_getpgrp SYSCALL_DEF(getpgrp); @@ -207,6 +210,7 @@ SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semget) SYSCALL_DEF(semget, ARG_DEC, ARG_DEC, ARG_HEX); #endif +SYSCALL_DEF(sethostname, ARG_STR); SYSCALL_DEF(setpgid, ARG_DEC, ARG_DEC); SYSCALL_DEF(setsid); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semop) diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 567df54581..b1a801fb62 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -438,6 +438,21 @@ SYSCALL_IMPL(fork) } #endif +#ifdef TARGET_NR_gethostname +SYSCALL_IMPL(gethostname) +{ + char *name = lock_user(VERIFY_WRITE, arg1, arg2, 0); + abi_long ret; + + if (!name) { + return -TARGET_EFAULT; + } + ret = get_errno(gethostname(name, arg2)); + unlock_user(name, arg1, arg2); + return ret; +} +#endif + SYSCALL_IMPL(getpgid) { return get_errno(getpgid(arg1)); @@ -485,6 +500,19 @@ SYSCALL_IMPL(nice) } #endif +SYSCALL_IMPL(sethostname) +{ + void *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(sethostname(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + SYSCALL_IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b8b18ac1de..6dd4196647 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4240,12 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_sethostname: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(sethostname(p, arg2)); - unlock_user(p, arg1, 0); - return ret; #ifdef TARGET_NR_setrlimit case TARGET_NR_setrlimit: { @@ -7078,19 +7072,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } #endif -#ifdef TARGET_NR_gethostname - case TARGET_NR_gethostname: - { - char *name = lock_user(VERIFY_WRITE, arg1, arg2, 0); - if (name) { - ret = get_errno(gethostname(name, arg2)); - unlock_user(name, arg1, arg2); - } else { - ret = -TARGET_EFAULT; - } - return ret; - } -#endif #ifdef TARGET_NR_atomic_cmpxchg_32 case TARGET_NR_atomic_cmpxchg_32: { diff --git a/linux-user/strace.list b/linux-user/strace.list index b1c2f7851e..361ceec853 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -244,9 +244,6 @@ #ifdef TARGET_NR_getgroups32 { TARGET_NR_getgroups32, "getgroups32" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_gethostname -{ TARGET_NR_gethostname, "gethostname" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_getitimer { TARGET_NR_getitimer, "getitimer" , NULL, NULL, NULL }, #endif @@ -1025,9 +1022,6 @@ #ifdef TARGET_NR_sethae { TARGET_NR_sethae, "sethae" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sethostname -{ TARGET_NR_sethostname, "sethostname" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_setitimer { TARGET_NR_setitimer, "setitimer" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164544 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4807089ili; Sun, 19 May 2019 14:20:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSZP68bNgmD2QmPK0i4JI2nmvs0g5SW/QLYSWfFl3UWJh8n47LiN1dcjRVCsdWhxN46ab4 X-Received: by 2002:a17:906:3713:: with SMTP id d19mr48607301ejc.194.1558300837399; Sun, 19 May 2019 14:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300837; cv=none; d=google.com; s=arc-20160816; b=SG/xCAbMVUbm6YkDw91EtFu3bJYxwitwZa59i/oWBD5jGbGqeA54C+/TkeQqPHDf3e I0Msioy2CthoGzRRIj/7bvsg0eMO347FhDylGz9WfLIlpN+pSCMVeXwPQrIJvPvAtApg hJXL40pou3eib/Kzgd/OhhfbIeyVVvLrXBeGT9674Vypd9VhHym84eoeHEObftINaRmS QyPMeoDW7vYeVVXYv+wN6h3jWgrwK9IxvfAHTCC8WGfPJ0bPjXiAZZzcuO4o06vqarjl YXm2mZC/xP1pi+kZlAyP6I5qOa9dIKXxs4IC/GPJB55XDbdy5tJ/xr222sKlhNulBoak rZ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=C4XNH+VeEXaL+6UuHWZfoss3TaaEPTbmJNRx30bs8d0=; b=pprlfIcuIKs7nnP04CN47dtbI0OaGGJIl0+VJeFd4C576YtvuGdOO+maBQRMct9RrS sygGsuXq5jUjT3/YpfZrPlEhleRR89sdbeutPZJ8aoXyhKMAx5UkQab8uiqDBAMD5gCJ t4v/LbNYU9yf1lJ/fQC0pW3gY2I3ycIpCFlZsyGw5CC7dTL6G24gzbtD4TOMJxhHSKgQ 9SM6JydR34AiirM2+Cyh66HY77d4BsEtSf+3Vfw/m6eX2D9gLJsLfeFEWK7dVaYoaBbl dV9szLGnIUMtlMkXLk7nV5jC3bOe1/l4oEj5YpA1dx1646Z3XNoMy2EvfBud3RP8X/+9 oZHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HlkoJCcc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s30si12599920eda.229.2019.05.19.14.20.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:20:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HlkoJCcc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTES-0006Yw-8G for patch@linaro.org; Sun, 19 May 2019 17:20:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa4-00040f-C0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa3-0004xw-26 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:52 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:38314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa2-0004wx-S0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:51 -0400 Received: by mail-pf1-x442.google.com with SMTP id b76so6171951pfb.5 for ; Sun, 19 May 2019 13:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C4XNH+VeEXaL+6UuHWZfoss3TaaEPTbmJNRx30bs8d0=; b=HlkoJCccjOovpX7qB2H7RM3LLddUnfOgcGNq2r9L7iv7jBhxc4TCfALr2Y0kJQhGLi pjcI4vJFA9mvNMBTOvit2RyzS3Qob7XGGdTKwnpXLhQsYKZuy2M8pSLa62n1RTdKIkTT WaDGdYAdlGBkk2KOioZ3lOcaJgThBANn7WM6StZ5btJKz13q24nHkg/2GdC/bf/wnDCP QMgong0Msl/4hTc/Kpebl7C42rDwkBQVNyY7PWmT5no5HqK77UY1Fqg8XK5vtg/HOuzL aJCZ7pLozOS3xLbkRONCiDyhwfbtSSauoLIDJA3mDU59PBr+kr0zgCkQSGyKaTQH7UX1 RgpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C4XNH+VeEXaL+6UuHWZfoss3TaaEPTbmJNRx30bs8d0=; b=NkVmQrVicfGwbqRlEoBJ01vRuIVLNcHYebUZO7946E7xpqtjLf9RgQZxosLX1LxD5P 45y/htrNSTQWbSJZ8vB5tpSXDUCO0oWoi+ZelHgRJxgVfIKqoJ2ONnL7H76cJna08yxj M0qPqbV6SzJX4GcFWOm5tWlXM3U+qWZSQD7EGC1zcHPx2dcgOYL4grsiGErwXrr2Quc8 su53dwQ7/bfSEnIhQl1/SjuSqa+eBkvh6J1RWaNqR41gLwx73ik8bnHm9IKUg6oQY5dM hXpV/KxOvScIjCPWX/xbUBnxcW93QS/IlHKBCZzclIa489zaDixDqfeLeGde1z8qMZrQ nMYg== X-Gm-Message-State: APjAAAW19lCwXShHSmc01ASaKEk3YyIVYLCmJhWpXZ+ekX6R59EREg44 62U84PEnQiXwOEjfxnx91IExM+85k+k= X-Received: by 2002:a63:5659:: with SMTP id g25mr72010606pgm.59.1558298329635; Sun, 19 May 2019 13:38:49 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:17 -0700 Message-Id: <20190519203726.20729-66-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v7 65/74] linux-user: Split out getrlimit, setrlimit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 6 ++++ linux-user/syscall-proc.inc.c | 52 +++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 46 ------------------------------- linux-user/strace.list | 6 ---- 4 files changed, 58 insertions(+), 52 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 3ba697fd53..34426a2e23 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -72,6 +72,9 @@ SYSCALL_DEF(getpid); #ifdef TARGET_NR_getppid SYSCALL_DEF(getppid); #endif +#ifdef TARGET_NR_getrlimit +SYSCALL_DEF(getrlimit, ARG_DEC, ARG_PTR); +#endif SYSCALL_DEF(getsid, ARG_DEC); #ifdef TARGET_NR_getxpid SYSCALL_DEF(getxpid); @@ -212,6 +215,9 @@ SYSCALL_DEF(semget, ARG_DEC, ARG_DEC, ARG_HEX); #endif SYSCALL_DEF(sethostname, ARG_STR); SYSCALL_DEF(setpgid, ARG_DEC, ARG_DEC); +#ifdef TARGET_NR_setrlimit +SYSCALL_DEF(setrlimit, ARG_DEC, ARG_PTR); +#endif SYSCALL_DEF(setsid); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semop) SYSCALL_DEF(semop, ARG_DEC, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index b1a801fb62..1238b08191 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -479,6 +479,26 @@ SYSCALL_IMPL(getppid) } #endif +#ifdef TARGET_NR_getrlimit +SYSCALL_IMPL(getrlimit) +{ + int resource = target_to_host_resource(arg1); + struct target_rlimit *target_rlim; + struct rlimit rlim; + abi_long ret; + + ret = get_errno(getrlimit(resource, &rlim)); + if (!is_error(ret)) { + if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) { + return -TARGET_EFAULT; + } + target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); + target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); + unlock_user_struct(target_rlim, arg2, 1); + } + return ret; +} +#endif SYSCALL_IMPL(getsid) { return get_errno(getsid(arg1)); @@ -518,6 +538,38 @@ SYSCALL_IMPL(setpgid) return get_errno(setpgid(arg1, arg2)); } +#ifdef TARGET_NR_setrlimit +SYSCALL_IMPL(setrlimit) +{ + int resource = target_to_host_resource(arg1); + struct target_rlimit *target_rlim; + struct rlimit rlim; + + if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1)) { + return -TARGET_EFAULT; + } + rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur); + rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max); + unlock_user_struct(target_rlim, arg2, 0); + + /* + * If we just passed through resource limit settings for memory then + * they would also apply to QEMU's own allocations, and QEMU will + * crash or hang or die if its allocations fail. Ideally we would + * track the guest allocations in QEMU and apply the limits ourselves. + * For now, just tell the guest the call succeeded but don't actually + * limit anything. + */ + if (resource != RLIMIT_AS && + resource != RLIMIT_DATA && + resource != RLIMIT_STACK) { + return get_errno(setrlimit(resource, &rlim)); + } else { + return 0; + } +} +#endif + SYSCALL_IMPL(setsid) { return get_errno(setsid()); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6dd4196647..401450b0e3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4240,52 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_setrlimit - case TARGET_NR_setrlimit: - { - int resource = target_to_host_resource(arg1); - struct target_rlimit *target_rlim; - struct rlimit rlim; - if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1)) - return -TARGET_EFAULT; - rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur); - rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max); - unlock_user_struct(target_rlim, arg2, 0); - /* - * If we just passed through resource limit settings for memory then - * they would also apply to QEMU's own allocations, and QEMU will - * crash or hang or die if its allocations fail. Ideally we would - * track the guest allocations in QEMU and apply the limits ourselves. - * For now, just tell the guest the call succeeded but don't actually - * limit anything. - */ - if (resource != RLIMIT_AS && - resource != RLIMIT_DATA && - resource != RLIMIT_STACK) { - return get_errno(setrlimit(resource, &rlim)); - } else { - return 0; - } - } -#endif -#ifdef TARGET_NR_getrlimit - case TARGET_NR_getrlimit: - { - int resource = target_to_host_resource(arg1); - struct target_rlimit *target_rlim; - struct rlimit rlim; - - ret = get_errno(getrlimit(resource, &rlim)); - if (!is_error(ret)) { - if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) - return -TARGET_EFAULT; - target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); - target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); - unlock_user_struct(target_rlim, arg2, 1); - } - } - return ret; -#endif case TARGET_NR_getrusage: { struct rusage rusage; diff --git a/linux-user/strace.list b/linux-user/strace.list index 361ceec853..711ad9c0aa 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -280,9 +280,6 @@ #ifdef TARGET_NR_getresuid32 { TARGET_NR_getresuid32, "getresuid32" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getrlimit -{ TARGET_NR_getrlimit, "getrlimit" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_get_robust_list { TARGET_NR_get_robust_list, "get_robust_list" , NULL, NULL, NULL }, #endif @@ -1061,9 +1058,6 @@ #ifdef TARGET_NR_setreuid32 { TARGET_NR_setreuid32, "setreuid32" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_setrlimit -{ TARGET_NR_setrlimit, "setrlimit" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_set_robust_list { TARGET_NR_set_robust_list, "set_robust_list" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164550 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4808886ili; Sun, 19 May 2019 14:23:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxI4Z0Z254Q/eMqO+fynBiiGySU09MQE3W4PZrjmDZhfdPvhW8k+6Dct9mXPLWSl4KqJChi X-Received: by 2002:a17:906:1545:: with SMTP id c5mr55816835ejd.135.1558300992854; Sun, 19 May 2019 14:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300992; cv=none; d=google.com; s=arc-20160816; b=U/yKCxzCLytJELEp8EyPEqzovGtMpQpyi3PQ2v50svnbC6DmLU7NCtb6iOFqIpoY6F rvHH3F5MuldhNr3/t/LSW709ZsQuoe71TT/fgKPgsPPxCuWv/i5ucxOUsnmBh8/pGtCW KzIA6O5846bDFadrK2wCA+iFl9KX14tkMMIoglH26/1VuBa3bA0E3cQF8+GydBfzdyYP ZweBy/YDywLblr1haxrh/SoJ3LqxKmRiIjO8gFyMn0DJGVX8Qoh86z19584FuT8vWqBl WUT2KWUiSvIMGTLGu3QjiiXBRkgXCgBL+TnZNE1UZdhleSl9qhSoPHJt+aUbQQR7Msc+ iWZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=bykKUGCflVir5L1X693JNtqoexPRstJK20ieV2db78g=; b=WHxmLgkf+WFAPIR6BwgZrghvKZPWJX4/makbUEEnobXkldwRjhDEfVHSpiDY+SnshZ 0rP1qlqUgVRgMgoenbkBodmCNJajQAoGrFKWALvoNDc56duRN72C9liuzcYCrqQMM848 FtW2241+FpnRYIZ3STgixuoD0PV29May3Q8fBP/ydaEmPmkYLg892ZZcwEHWzgT5LrMr tPi2/zjuusYccVGPQOQ789RFtE09afm2ilb8EpqChP6OKbBbpP77MX12NgqYd8T1Aw9y 5qm9gK8rXj5vbXJYFzf9vsSafdG5KAqOGnnbd/dHXxgzh5pt1aggYvDsbl+u/jCIwZMi 6r/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DiXkK1HU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h15si4168841eda.399.2019.05.19.14.23.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:23:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DiXkK1HU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTGx-0000M5-Nc for patch@linaro.org; Sun, 19 May 2019 17:23:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa5-00041U-5E for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa4-0004zA-7B for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:53 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:46929) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa4-0004yQ-1X for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:52 -0400 Received: by mail-pl1-x641.google.com with SMTP id r18so5699095pls.13 for ; Sun, 19 May 2019 13:38:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bykKUGCflVir5L1X693JNtqoexPRstJK20ieV2db78g=; b=DiXkK1HULs1qZQr6XHCdONJlFdr4Z6wp5i2+/yVPGm4ltSd06UxUbj88jhjOY5yS6r 6b1sM7jbMixUzHUW+5NthhDJvTSJF03KlzWTOlbK5InvaNLIA1fkm+yjQ7/gQeSL0fML 8h+ErZgLWozYoGlaBs6ASRdFSZ6btkE6gs1zJM80kehykFEi+tug1yeRWaU7yv+xflof B6ubZwuKSNswz4iTYBcGz7phNibpZautwa8NQAJuZSPjrXLKHUxSnM9YLMXR3JDP2ogz oezydmOdVFGjkpUf40jWHnaE0Z8wJ7C/0nOTKVVQj/zdEBN2yPWLnnXAhuUJhA95KRga uZ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bykKUGCflVir5L1X693JNtqoexPRstJK20ieV2db78g=; b=j1z1MskPmqtoE442rE1OhoQDl4l/o+D4Ew48E355XrAljMbcDSH0RYqTAO3cuJWuQ8 cMfvblFtvvBJWWdseZvBPDPZxT+5UFFQQvi7YURV/pyaXjdFZPfg/gFsCtmNUhuw3AdT xbmTz8CT/Rai9NWE0iIQIXM0FnNcGiK/UdzLJCVBOdIj7D7QjilH235HPEynF4on7/4q xXJwrchVTpU5/a1uZvLkU8wbAXW0rAcuMX2HWZyD3QfZxx+AFQazd1XE6UPjGpEKm0du bjiAB27I6+HnNOn/+G/vyMiwZf/TB4ROdmhhgL7iyLBK6dXUiHRWcCff2ACScgs8WMTh gz0Q== X-Gm-Message-State: APjAAAUf7+DETbkHq9X8c8ykwM1EWIgJIdcG4P9oq5NCt81IaAGvXsLh 79/+9Le4T78QZm4hukD6c+8UXKDAXh0= X-Received: by 2002:a17:902:7617:: with SMTP id k23mr28208583pll.175.1558298330853; Sun, 19 May 2019 13:38:50 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:18 -0700 Message-Id: <20190519203726.20729-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 66/74] linux-user: Split out getrusage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-proc.inc.c | 12 ++++++++++++ linux-user/syscall.c | 9 --------- linux-user/strace.list | 3 --- 4 files changed, 13 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 34426a2e23..446175af84 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -75,6 +75,7 @@ SYSCALL_DEF(getppid); #ifdef TARGET_NR_getrlimit SYSCALL_DEF(getrlimit, ARG_DEC, ARG_PTR); #endif +SYSCALL_DEF(getrusage, ARG_DEC, ARG_PTR); SYSCALL_DEF(getsid, ARG_DEC); #ifdef TARGET_NR_getxpid SYSCALL_DEF(getxpid); diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 1238b08191..bf9e278bf0 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -499,6 +499,18 @@ SYSCALL_IMPL(getrlimit) return ret; } #endif + +SYSCALL_IMPL(getrusage) +{ + struct rusage rusage; + abi_long ret = get_errno(getrusage(arg1, &rusage)); + + if (!is_error(ret)) { + ret = host_to_target_rusage(arg2, &rusage); + } + return ret; +} + SYSCALL_IMPL(getsid) { return get_errno(getsid(arg1)); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 401450b0e3..5fe52c775d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4240,15 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_getrusage: - { - struct rusage rusage; - ret = get_errno(getrusage(arg1, &rusage)); - if (!is_error(ret)) { - ret = host_to_target_rusage(arg2, &rusage); - } - } - return ret; case TARGET_NR_gettimeofday: { struct timeval tv; diff --git a/linux-user/strace.list b/linux-user/strace.list index 711ad9c0aa..00a32bc616 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -283,9 +283,6 @@ #ifdef TARGET_NR_get_robust_list { TARGET_NR_get_robust_list, "get_robust_list" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getrusage -{ TARGET_NR_getrusage, "getrusage" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_getsockname { TARGET_NR_getsockname, "getsockname" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164554 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4810698ili; Sun, 19 May 2019 14:25:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFlQAtBLA4QtLqDDODhZO4uoNZ1W4BF4NxQYmkKJEN9NfcJFRHfoO2pkdCksnIAUrcfWR9 X-Received: by 2002:aa7:d6d3:: with SMTP id x19mr71308959edr.67.1558301150830; Sun, 19 May 2019 14:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301150; cv=none; d=google.com; s=arc-20160816; b=z+UxzSf7QDyb/SPKDj7RdOPIS8vm8NX8fK4rUIVj7UK1qZkrHdgI2/dNrvV1HQrrhz X1HHRJ40cq7PJKX7BIjxL3/Qf/00lBVNLOdSwNaAQQSSgnCxhHePF/b7S2pJeF34fwq3 enrPXdvCYXzpwpe0625RL3a5vzB648EqiUETXaG9b+RC70frPI1VY2MqUsA1Xt2FFfyo Ohmq/KbFl8fEguUxrAfyTId6KXYL6qLx1PxzZa6IByW0LOTgWxUJGzswqEEnRLvKnZft T5/0+KUWbB/MueytkSbeK883FBVtSKbf/CASMq+kvKGMuUcVb8PZy4l9NnGw7+qYUgZf Zing== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=aU9d9lkpIFkrBaZRLnqRF/xt/eULyJKQva2sHtEVO2Y=; b=vx1xItEAxYhhkx4HGaJbNaNz/okhkwZMrB5t+tHKZXvre9FnHUJNfSbiJW8cbjwyMe xH+nY1CB54fsZM2cHohYzYfNXlTicWFDdg/N7YzFZQ7U7Sj/D98Z1pmcIBbAcUcHmkoa lHUyFZv/WBffcdTxLW6QBDlP6Ckj2JAivTQz9RyoErJAoFEqwAO3fyoPKKcQDHNTagKn O7yufAzQUz84LMbzH69ZN0wz67HwUauyqHwfgZA9HJP99cDlHnfM9nE3kZ0WDDBLZNOx 46/o1/bZ9hSX2psK/YnrYR9M10sd7CbKDkO0wxY4hWt2wpA2WH5o16HJZSRJGoPdaVe5 nwSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Wyiyg66m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id os28si756982ejb.124.2019.05.19.14.25.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Wyiyg66m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTJV-0002or-IO for patch@linaro.org; Sun, 19 May 2019 17:25:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa6-00043I-PW for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa5-00050k-La for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:54 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:43849) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa5-0004zu-Fl for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:53 -0400 Received: by mail-pf1-x441.google.com with SMTP id c6so6150984pfa.10 for ; Sun, 19 May 2019 13:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aU9d9lkpIFkrBaZRLnqRF/xt/eULyJKQva2sHtEVO2Y=; b=Wyiyg66mNE27W+tMaD3QGbxM7UM/xGOPeWqBMI2iw8v8/TM3SiNv2LyrY6PucPGRPn nTXLOyc6CPNeeg/zdB4Br3Q/tmlsS9mccTrAgBpNcye/HHfi0l5TZwXp+5uCBSFJd2xM IrCJrgIEpTgdoR1W9+0GFZRoDTuI09wDdIHJ9DtBEh8JvqELkA21k7IgkF/VYxFw+yKa JRLkxnt1zrdXAEi8FuY2M2oWbsOWo1xLjZ+yqPZXw8Wn7dCdQdS8Gx+E+TKo8huuQ3ci Uiz56Xp3/bSIiEOYhAYc9g45vFxCZteZkydvKb8QnIt+7kfCkAxiefDFzC7ZOFhw7vCp LcyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aU9d9lkpIFkrBaZRLnqRF/xt/eULyJKQva2sHtEVO2Y=; b=YnFUYpEHkqFbc/jXdkEBSYEEWVz6FoMGH8oJTyPh0Rx+YOz0vUQnQ0BPhqQsW6VWsd HG/XQ5OjTlV2nEmNGJ4CFtScD74n1sYppBd11LHEH904/tHPQfR0NXxyDYMXVpkEGuMR pkdawOiv8Rk+BTsf0wV1UmcEIoGjjbqa3IKuGXoog4ppK14wnzu3CiA2L6kSXbK7gZHn uRokgKi5l/CakCBYMDw1uEGdlGkNIqpZrHGlJIHTjEB3SDmFQVJkxex1Bv+32qB87y0e VrCP3srtGa4MR8LNbHs40RsR0qaXLi/oKVkGR2ckImJ0FMS80QiX1pzZgxDY2E3BtNcM khpw== X-Gm-Message-State: APjAAAVH0706r+GBJh3Pijzjl7eCpl7c3bL1rIjXVRaYfqMEAfWJ5Mku DVLZV6XbNmTR/CiWPyx59Wamgea6FjI= X-Received: by 2002:a63:2d6:: with SMTP id 205mr70853544pgc.114.1558298332183; Sun, 19 May 2019 13:38:52 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:19 -0700 Message-Id: <20190519203726.20729-68-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 67/74] linux-user: Split out gettimeofday, settimeofday X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-time.inc.c | 33 +++++++++++++++++++++++++++++++++ linux-user/syscall.c | 31 ------------------------------- linux-user/strace.list | 6 ------ 4 files changed, 35 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 446175af84..d109754c5f 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -77,6 +77,7 @@ SYSCALL_DEF(getrlimit, ARG_DEC, ARG_PTR); #endif SYSCALL_DEF(getrusage, ARG_DEC, ARG_PTR); SYSCALL_DEF(getsid, ARG_DEC); +SYSCALL_DEF(gettimeofday, ARG_PTR); #ifdef TARGET_NR_getxpid SYSCALL_DEF(getxpid); #endif @@ -220,6 +221,7 @@ SYSCALL_DEF(setpgid, ARG_DEC, ARG_DEC); SYSCALL_DEF(setrlimit, ARG_DEC, ARG_PTR); #endif SYSCALL_DEF(setsid); +SYSCALL_DEF(settimeofday, ARG_PTR, ARG_PTR); #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semop) SYSCALL_DEF(semop, ARG_DEC, ARG_PTR, ARG_DEC); #endif diff --git a/linux-user/syscall-time.inc.c b/linux-user/syscall-time.inc.c index d1fb72bde0..1308af64ac 100644 --- a/linux-user/syscall-time.inc.c +++ b/linux-user/syscall-time.inc.c @@ -16,6 +16,39 @@ * along with this program; if not, see . */ +SYSCALL_IMPL(gettimeofday) +{ + struct timeval tv; + abi_long ret = get_errno(gettimeofday(&tv, NULL)); + + if (!is_error(ret) && copy_to_user_timeval(arg1, &tv)) { + return -TARGET_EFAULT; + } + return ret; +} + +SYSCALL_IMPL(settimeofday) +{ + struct timeval tv, *ptv = NULL; + struct timezone tz, *ptz = NULL; + + if (arg1) { + if (copy_from_user_timeval(&tv, arg1)) { + return -TARGET_EFAULT; + } + ptv = &tv; + } + + if (arg2) { + if (copy_from_user_timezone(&tz, arg2)) { + return -TARGET_EFAULT; + } + ptz = &tz; + } + + return get_errno(settimeofday(ptv, ptz)); +} + #ifdef TARGET_NR_stime SYSCALL_IMPL(stime) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5fe52c775d..b8bc44364d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4240,37 +4240,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_gettimeofday: - { - struct timeval tv; - ret = get_errno(gettimeofday(&tv, NULL)); - if (!is_error(ret)) { - if (copy_to_user_timeval(arg1, &tv)) - return -TARGET_EFAULT; - } - } - return ret; - case TARGET_NR_settimeofday: - { - struct timeval tv, *ptv = NULL; - struct timezone tz, *ptz = NULL; - - if (arg1) { - if (copy_from_user_timeval(&tv, arg1)) { - return -TARGET_EFAULT; - } - ptv = &tv; - } - - if (arg2) { - if (copy_from_user_timezone(&tz, arg2)) { - return -TARGET_EFAULT; - } - ptz = &tz; - } - - return get_errno(settimeofday(ptv, ptz)); - } #if defined(TARGET_NR_select) case TARGET_NR_select: #if defined(TARGET_WANT_NI_OLD_SELECT) diff --git a/linux-user/strace.list b/linux-user/strace.list index 00a32bc616..635b952d2f 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -296,9 +296,6 @@ #ifdef TARGET_NR_gettid { TARGET_NR_gettid, "gettid" , "%s()", NULL, NULL }, #endif -#ifdef TARGET_NR_gettimeofday -{ TARGET_NR_gettimeofday, "gettimeofday" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_getuid { TARGET_NR_getuid, "getuid" , "%s()", NULL, NULL }, #endif @@ -1068,9 +1065,6 @@ #ifdef TARGET_NR_set_tid_address { TARGET_NR_set_tid_address, "set_tid_address" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_settimeofday -{ TARGET_NR_settimeofday, "settimeofday" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_setuid { TARGET_NR_setuid, "setuid" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164562 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4815922ili; Sun, 19 May 2019 14:33:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvkiXa2Z+F1VjVyoVKolTfgdwXRzvjYQwuI48GvmunF+UyCdUTaZXgVkhPMivnlj/ppCu5 X-Received: by 2002:a17:906:2518:: with SMTP id i24mr44132176ejb.169.1558301601097; Sun, 19 May 2019 14:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301601; cv=none; d=google.com; s=arc-20160816; b=UqgWELutX61RngtNGCj94dAwCXRHn9hqovCSmNj1i/6w0Ab0zokS1GBq5fcm9QaKKC RD3gsDwLQeYGk3lwiNcuVezE9I1Cr+FOugYKVf5meJ6rH2a32EO2+irWV34w9sGMPLpT zvZktlv/CUQneBNz91yUja951OY6Bz6YXpS/Ww2oibrh042Qxl4Ehvf2DJrbJKj9fU36 t9FqtD5SOR49jr7Ic6XDnjB+kHL9r4D0FAhQ7TCKhfPmrW13DNpMoulS/wr04gjOijFD W5Vle+N5o4NyaT+7s/BrnJsrQ4dtuxemfCOI042RUxF/BRsQEBf86SLalpXtA+EY7tWs iRGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=o7AFcCu8y5gdO0mRc0XjobU0Yr+t3Strmr55hIlxmiM=; b=kSxJ/e28YLvnty+Dzbhgk7QQ+fn88WzwuYSHmB11AKSC0dvt2jbqwZNQZ8MeefOmKr AfTWq8TcG07YNQz0y2l2DbK7HuTjVG44wR6roLvS5pKffyzIe2CCyT5ylQ14ZOLj/fM5 5/6rXWkmV9MvDkhvQ80MZqE7wwDny+VtmVBmspCNe6C48ffKPsGwugpJSd9UlbybEoWX JzSNya7u38t9dRpCHrlNNWc8lLuU8rv4qaHbubJ9JRC0ikDmrPUVFP73UOZErnFqgUQ/ mYDsYd6Jd59I8HXUdJoykoOqOhhtqQviEaZoEYtrcttI8ZyG/VaCNzWqAjIFt+2538+N Piyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lpvANjtS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k6si300371ejc.204.2019.05.19.14.33.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:33:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lpvANjtS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTQl-0000uH-Uo for patch@linaro.org; Sun, 19 May 2019 17:33:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa8-000451-EZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa6-00052U-PZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:56 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:39719) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa6-00051F-H0 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:54 -0400 Received: by mail-pf1-x444.google.com with SMTP id z26so6167808pfg.6 for ; Sun, 19 May 2019 13:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o7AFcCu8y5gdO0mRc0XjobU0Yr+t3Strmr55hIlxmiM=; b=lpvANjtSI7lKnu/+zJ6QveUZsZDVZlSbyv1cZsxjnyq+A6/wQJlbnJ9YU7g4qE3S8b XJ8+pDOjwBKTB291OqqeetSnOEaT0knmxQoRD7OxbeBIheMu61VLTS1CAPXgSg0aUVMA cQ1roKveUKIoWkTiqbtQkOflcLxyKTJXVsje/acHiARS73SkNRE9jpUPq9+n5dvgLsLP Iopw41bEK5mzpaGI2ghNGp5ONBy3JQcKsSGjzW5u9s/hOvLJLAcx/9b7RsZ60vnYlwSs 3X9DNgDlwu9GUlfX0bCZZ4PHiugfsVeiLCtDNEb87FtmlbytV9c9fz7N12MUJ3z7ugL/ uDxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o7AFcCu8y5gdO0mRc0XjobU0Yr+t3Strmr55hIlxmiM=; b=Ki5g+51HSIJ9Q+bwQx7DH3ixIHlHRcFwaPlbNg7d0udg/EzSg594Lx/ZKVaLo2UFvw kBx7Aw5Ch0gx1zVqvp5q1sCsfvv1Dm9Ue7C0mBnDOjFGWGB8Wke6obXgyKuH+TEwjH5I lyrckssfESjlE7Gy1ErmgOgyfqiJRo2Pf/kX6vbCP03ksu5LEC285KOhOb7wlvqbCF+l p+MMruggJPi4HxJ2YqfWeIYw5bKTyqMU/WxaNWOHDL+lMvjCLcJRxGi2shPiXEjUz1Uy Y/LJxDoPDvsHbkBwgEcz/5P6gmz9WoBZ6WCfvv+NE7oNoD4+FC+XlM5I+TEoJiB2XCMm j0nQ== X-Gm-Message-State: APjAAAVcQ/8YUYP+M8yQais+xVkdLlz8kJmIOUMrk+Bc/OLzozZit1ef +qf6a1hujL8iU9MHe4ObkZBEgUOPOr8= X-Received: by 2002:a62:d044:: with SMTP id p65mr55694443pfg.37.1558298333214; Sun, 19 May 2019 13:38:53 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:20 -0700 Message-Id: <20190519203726.20729-69-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v7 68/74] linux-user: Split out select, _newselect X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This removes the printing of the fdset outputs. It's hard to see how this could have been reliable in a multi-threaded program, saving syscall arguments to global variables. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 11 ++++ linux-user/strace.c | 80 ------------------------- linux-user/syscall-file.inc.c | 91 ++++++++++++++++++++++++++++ linux-user/syscall.c | 110 ++++------------------------------ linux-user/strace.list | 6 -- 5 files changed, 112 insertions(+), 186 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index d109754c5f..01143414c7 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -143,6 +143,10 @@ SYSCALL_DEF(munlockall); SYSCALL_DEF(munmap, ARG_PTR, ARG_DEC); SYSCALL_DEF(name_to_handle_at, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); +#ifdef TARGET_NR__newselect +SYSCALL_DEF_FULL(_newselect, .impl = impl_select, + .arg_type = { ARG_DEC, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR }); +#endif #ifdef TARGET_NR_nice SYSCALL_DEF(nice, ARG_DEC); #endif @@ -209,6 +213,13 @@ SYSCALL_DEF(rt_sigreturn); SYSCALL_DEF(rt_sigsuspend, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_sigtimedwait, ARG_PTR, ARG_PTR, ARG_PTR, ARG_DEC); SYSCALL_DEF(rt_tgsigqueueinfo, ARG_DEC, ARG_DEC, ARG_SIGNAL, ARG_PTR); +#ifdef TARGET_NR_select +# if defined(TARGET_WANT_NI_OLD_SELECT) +SYSCALL_DEF_NOSYS(select); +# else +SYSCALL_DEF_ARGS(select, ARG_DEC, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); +# endif +#endif #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semctl) SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 2e70a3910c..669eca7fa6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -384,34 +384,6 @@ print_socket_protocol(int domain, int type, int protocol) } -#ifdef TARGET_NR__newselect -static void -print_fdset(int n, abi_ulong target_fds_addr) -{ - int i; - - gemu_log("["); - if( target_fds_addr ) { - abi_long *target_fds; - - target_fds = lock_user(VERIFY_READ, - target_fds_addr, - sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), - 1); - - if (!target_fds) - return; - - for (i=n; i>=0; i--) { - if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) - gemu_log("%d,", i ); - } - unlock_user(target_fds, target_fds_addr, 0); - } - gemu_log("]"); -} -#endif - #ifdef TARGET_NR_clock_adjtime /* IDs of the various system clocks */ #define TARGET_CLOCK_REALTIME 0 @@ -479,58 +451,6 @@ print_clockid(int clockid, int last) * Sysycall specific output functions */ -/* select */ -#ifdef TARGET_NR__newselect -static long newselect_arg1 = 0; -static long newselect_arg2 = 0; -static long newselect_arg3 = 0; -static long newselect_arg4 = 0; -static long newselect_arg5 = 0; - -static void -print_newselect(const struct syscallname *name, - abi_long arg1, abi_long arg2, abi_long arg3, - abi_long arg4, abi_long arg5, abi_long arg6) -{ - gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); - print_fdset(arg1, arg2); - gemu_log(","); - print_fdset(arg1, arg3); - gemu_log(","); - print_fdset(arg1, arg4); - gemu_log(","); - print_timeval(arg5, 1); - gemu_log(")"); - - /* save for use in the return output function below */ - newselect_arg1=arg1; - newselect_arg2=arg2; - newselect_arg3=arg3; - newselect_arg4=arg4; - newselect_arg5=arg5; -} -#endif - -/* - * Variants for the return value output function - */ - -#ifdef TARGET_NR__newselect -static void -print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) -{ - gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); - print_fdset(newselect_arg1,newselect_arg2); - gemu_log(","); - print_fdset(newselect_arg1,newselect_arg3); - gemu_log(","); - print_fdset(newselect_arg1,newselect_arg4); - gemu_log(","); - print_timeval(newselect_arg5, 1); - gemu_log(")\n"); -} -#endif - /* special meanings of adjtimex()' non-negative return values */ #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */ #define TARGET_TIME_INS 1 /* insert leap second */ diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 6e730e3152..1d66dc3323 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -1067,6 +1067,97 @@ SYSCALL_IMPL(renameat2) return do_renameat2(arg1, arg2, arg3, arg4, arg5); } +#if defined(TARGET_NR_select) && defined(TARGET_WANT_OLD_SYS_SELECT) +SYSCALL_ARGS(select) +{ + struct target_sel_arg_struct *sel; + abi_ulong inp, outp, exp, tvp; + abi_long nsel; + + if (!lock_user_struct(VERIFY_READ, sel, in[0], 1)) { + errno = EFAULT; + return NULL; + } + nsel = tswapal(sel->n); + inp = tswapal(sel->inp); + outp = tswapal(sel->outp); + exp = tswapal(sel->exp); + tvp = tswapal(sel->tvp); + unlock_user_struct(sel, in[0], 0); + + out[0] = nsel; + out[1] = inp; + out[2] = outp; + out[3] = exp; + out[4] = tvp; + return def; +} +#else +# define args_select NULL +#endif + +#if (defined(TARGET_NR_select) && !defined(TARGET_WANT_NI_OLD_SELECT)) \ + || defined(TARGET_NR__newselect) +SYSCALL_IMPL(select) +{ + int n = arg1; + abi_ulong rfd_addr = arg2; + abi_ulong wfd_addr = arg3; + abi_ulong efd_addr = arg4; + abi_ulong target_tv_addr = arg5; + fd_set rfds, wfds, efds; + fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; + struct timeval tv; + struct timespec ts, *ts_ptr = NULL; + abi_long ret; + + ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); + if (ret) { + return ret; + } + ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); + if (ret) { + return ret; + } + ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); + if (ret) { + return ret; + } + + if (target_tv_addr) { + if (copy_from_user_timeval(&tv, target_tv_addr)) + return -TARGET_EFAULT; + ts.tv_sec = tv.tv_sec; + ts.tv_nsec = tv.tv_usec * 1000; + ts_ptr = &ts; + } + + ret = get_errno(safe_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, + ts_ptr, NULL)); + + if (!is_error(ret)) { + if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) { + return -TARGET_EFAULT; + } + if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) { + return -TARGET_EFAULT; + } + if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) { + return -TARGET_EFAULT; + } + if (target_tv_addr) { + tv.tv_sec = ts.tv_sec; + tv.tv_usec = ts.tv_nsec / 1000; + if (copy_to_user_timeval(target_tv_addr, &tv)) { + return -TARGET_EFAULT; + } + } + } + + return ret; +} +#endif + SYSCALL_IMPL(sync) { sync(); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b8bc44364d..2c8d74a450 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1055,88 +1055,6 @@ static inline abi_long copy_to_user_mq_attr(abi_ulong target_mq_attr_addr, } #endif -#if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) -/* do_select() must return target values and target errnos. */ -static abi_long do_select(int n, - abi_ulong rfd_addr, abi_ulong wfd_addr, - abi_ulong efd_addr, abi_ulong target_tv_addr) -{ - fd_set rfds, wfds, efds; - fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; - struct timeval tv; - struct timespec ts, *ts_ptr; - abi_long ret; - - ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); - if (ret) { - return ret; - } - ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); - if (ret) { - return ret; - } - ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); - if (ret) { - return ret; - } - - if (target_tv_addr) { - if (copy_from_user_timeval(&tv, target_tv_addr)) - return -TARGET_EFAULT; - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec * 1000; - ts_ptr = &ts; - } else { - ts_ptr = NULL; - } - - ret = get_errno(safe_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, - ts_ptr, NULL)); - - if (!is_error(ret)) { - if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) - return -TARGET_EFAULT; - if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) - return -TARGET_EFAULT; - if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) - return -TARGET_EFAULT; - - if (target_tv_addr) { - tv.tv_sec = ts.tv_sec; - tv.tv_usec = ts.tv_nsec / 1000; - if (copy_to_user_timeval(target_tv_addr, &tv)) { - return -TARGET_EFAULT; - } - } - } - - return ret; -} - -#if defined(TARGET_WANT_OLD_SYS_SELECT) -static abi_long do_old_select(abi_ulong arg1) -{ - struct target_sel_arg_struct *sel; - abi_ulong inp, outp, exp, tvp; - long nsel; - - if (!lock_user_struct(VERIFY_READ, sel, arg1, 1)) { - return -TARGET_EFAULT; - } - - nsel = tswapal(sel->n); - inp = tswapal(sel->inp); - outp = tswapal(sel->outp); - exp = tswapal(sel->exp); - tvp = tswapal(sel->tvp); - - unlock_user_struct(sel, arg1, 0); - - return do_select(nsel, inp, outp, exp, tvp); -} -#endif -#endif - static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn, abi_ulong target_addr, socklen_t len) @@ -4240,20 +4158,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_select) - case TARGET_NR_select: -#if defined(TARGET_WANT_NI_OLD_SELECT) - /* some architectures used to have old_select here - * but now ENOSYS it. - */ - ret = -TARGET_ENOSYS; -#elif defined(TARGET_WANT_OLD_SYS_SELECT) - ret = do_old_select(arg1); -#else - ret = do_select(arg1, arg2, arg3, arg4, arg5); -#endif - return ret; -#endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: { @@ -5007,10 +4911,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif /* TARGET_NR_getdents64 */ -#if defined(TARGET_NR__newselect) - case TARGET_NR__newselect: - return do_select(arg1, arg2, arg3, arg4, arg5); -#endif #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) # ifdef TARGET_NR_poll case TARGET_NR_poll: @@ -7233,6 +7133,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #include "syscall-sig.inc.c" #include "syscall-time.inc.c" +static SyscallImplFn impl_enosys __attribute__((unused)); +SYSCALL_IMPL(enosys) +{ + return -TARGET_ENOSYS; +} + #undef SYSCALL_IMPL #undef SYSCALL_ARGS @@ -7254,6 +7160,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, SYSCALL_DEF_FULL(NAME, .impl = impl_##NAME, .args = args_##NAME, \ .arg_type = { __VA_ARGS__ }) +/* Emit a definition that always produces ENOSYS without logging. */ +#define SYSCALL_DEF_NOSYS(NAME) \ + SYSCALL_DEF_FULL(NAME, .impl = impl_enosys) + #include "syscall-defs.h" #undef SYSCALL_DEF diff --git a/linux-user/strace.list b/linux-user/strace.list index 635b952d2f..297180d94f 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -470,9 +470,6 @@ #ifdef TARGET_NR_newfstatat { TARGET_NR_newfstatat, "newfstatat" , NULL, print_newfstatat, NULL }, #endif -#ifdef TARGET_NR__newselect -{ TARGET_NR__newselect, "_newselect" , NULL, print_newselect, print_syscall_ret_newselect }, -#endif #ifdef TARGET_NR_nfsservctl { TARGET_NR_nfsservctl, "nfsservctl" , NULL, NULL, NULL }, #endif @@ -962,9 +959,6 @@ #ifdef TARGET_NR_security { TARGET_NR_security, "security" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_select -{ TARGET_NR_select, "select" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_send { TARGET_NR_send, "send" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164563 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4816439ili; Sun, 19 May 2019 14:34:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0t6EbgNBnvb9H3WrIsUBx/b9EbdLWGJphTuR827iiz22ORlRUI5zfRJCZbFcCPWZ11iHP X-Received: by 2002:a50:8903:: with SMTP id e3mr69728971ede.11.1558301650671; Sun, 19 May 2019 14:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301650; cv=none; d=google.com; s=arc-20160816; b=LBOpEqMe3hp1JBMOBaQpmbEErFGa42uSUnXxXsVO0aMrc3L52T3J1YF9Mo8wafLIMM 8ckxQyK/puIxGS21LtN74r54ngTf4X6AuMILUN9q45g0b75GtDhMVp/hYfz7X7cIc11g dowocVMXiv49oQa9DBMalEDv9v6LkY0EJ5DyiH9Hh/p/UMsn8Y2PBHh4RCYCchOdR506 M2x/TWE/GCPvU/nRpxAc0pS9ZXlBBkrnLZjt/VEGTaxpvmT0xKouendU5bKLBDFhPr8A LgweLdxFtVDJvQ0LNwNd2p53pE52iSiwzPddot4ExsiO+3YPdrPvuDHwwjll4PV0Bjj5 E0ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=OxzuqNW/UFIgrfGQ+3fG4I/RITK819AGJzrnscRZcbA=; b=ZvFomg3vd2Hazb2Gwds20IxSuzuwSN+7SJJurzaEOdcuGd0zMnmrN7JcH0aMA+8c3r Z/3rkmOUxoNFuGushNgzKe6oMQdSDIMK2zhjGQxzME7o9QzyAWEloBmV9EfC7lMMS27o gexQCfZZM5OjSyHuACPxW00a0rM+yVVCi8vWoffGeYQLDbyGpJSFdeZNov3OZoXKATV4 eEfPYzXCdfnTpGjExnNpL81iXMUacR6UZp+mmNobdfEMN421z29s+IPyIFe81bVIMF6A poY281X9oWxjkVXY+cmMpTswIX21wSuMUq+Hu1z1Up/ZG66vjRTg0Uo4lj5c6WlflXpx 7u0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I8gqlqku; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n21si12337596edn.393.2019.05.19.14.34.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:34:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I8gqlqku; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTRZ-0001TW-FP for patch@linaro.org; Sun, 19 May 2019 17:34:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSa9-000464-7u for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa7-00053u-V8 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:57 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:32993) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa7-00053D-Mr for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:55 -0400 Received: by mail-pf1-x443.google.com with SMTP id z28so6189204pfk.0 for ; Sun, 19 May 2019 13:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OxzuqNW/UFIgrfGQ+3fG4I/RITK819AGJzrnscRZcbA=; b=I8gqlqkuGq0N6crXd3nyY2kU5jfyEDab7KvBndm9AouProIG005uLWbKDgldeojNuy xV9jwzOtUvS6HgJP+st5Dvs6lVuQIhwY3j75LcCgqtxO+yQPA0srcltvknFkUBw8qml1 nLXVVQN7NilIZRk2oK+JliyKclsb+s7sODvdDFPl9ycq6N6GwTRC/rUU4kXW3sWsb3gM CwHXhkYoJkL3QbAniRCjKs4FBm9GCMuaaA5upIpjeP2rbuetsi9NV3Xr+EhTIhiHZd6a G4/i9dZ7sILCyufM1VmrLpjgFth45cQrBEekOLEnRbd5GkScZ5hI1p0gVYvUPYKfXhOW ccZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OxzuqNW/UFIgrfGQ+3fG4I/RITK819AGJzrnscRZcbA=; b=nqU0Rdjq8fGELluz3fv7hLujknN6V9sIKc/EeAfftxcl1TVPDI1+BW1GrikEN+XRgZ VQPgzBKTRudoU4RPpOKEBUxJ3ECFXnEdhyCMhDSNVO/yXq3lXSuG8h+REai0TygY3Ojs MLzz6SFRPl3cgzVs98lXGxyty6nFkZ19KoUcDFXhDQdfQHDkB9hymL6/HaKEcMdBo2hQ w/FUIGm3SXG2CEqWdc5nxd02pHJn81B+1l7xWtrjmXdWixeQGhRKhjHQcvG/4yLmo4eK Jb6MPAq2yD07f8jsEcYS+jywq/rua0LLEhMOPeQMjoqtzhZaXvuwtHJF2zc+KCtG3Jto NP0g== X-Gm-Message-State: APjAAAXfNSNIMcVUm/4oB/aTVyGtgqQWO+LJiFtkuS7XmOLScvBrf03X twnGWr2LlgivRI8X+ParVnpAqmRBZGE= X-Received: by 2002:a62:4281:: with SMTP id h1mr76217177pfd.162.1558298334457; Sun, 19 May 2019 13:38:54 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:21 -0700 Message-Id: <20190519203726.20729-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v7 69/74] linux-user: Split out pselect6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-file.inc.c | 96 +++++++++++++++++++++++++++++++ linux-user/syscall.c | 103 ---------------------------------- linux-user/strace.list | 3 - 4 files changed, 97 insertions(+), 106 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 01143414c7..c179f69d9f 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -180,6 +180,7 @@ SYSCALL_DEF_FULL(preadv, .impl = impl_preadv, SYSCALL_DEF_FULL(pwritev, .impl = impl_pwritev, .args = args_preadv_pwritev, .arg_type = { ARG_DEC, ARG_PTR, ARG_DEC, ARG_DEC64 }); +SYSCALL_DEF(pselect6, ARG_DEC, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); SYSCALL_DEF(read, ARG_DEC, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlink SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 1d66dc3323..0a25d39d28 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -934,6 +934,102 @@ SYSCALL_IMPL(pwritev) return ret; } +SYSCALL_IMPL(pselect6) +{ + abi_long n = arg1; + abi_ulong rfd_addr = arg2; + abi_ulong wfd_addr = arg3; + abi_ulong efd_addr = arg4; + abi_ulong ts_addr = arg5; + fd_set rfds, wfds, efds; + fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; + struct timespec ts, *ts_ptr = NULL; + abi_long ret; + + /* + * The 6th arg is actually two args smashed together, and since + * we are using safe_syscall, we must handle this ourselves. + */ + sigset_t set; + struct { + sigset_t *set; + size_t size; + } sig, *sig_ptr = NULL; + + abi_ulong arg_sigset, arg_sigsize, *arg7; + target_sigset_t *target_sigset; + + ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); + if (ret) { + return ret; + } + ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); + if (ret) { + return ret; + } + ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); + if (ret) { + return ret; + } + + if (ts_addr) { + if (target_to_host_timespec(&ts, ts_addr)) { + return -TARGET_EFAULT; + } + ts_ptr = &ts; + } + + /* Extract the two packed args for the sigset */ + if (arg6) { + sig_ptr = &sig; + sig.size = SIGSET_T_SIZE; + + arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); + if (!arg7) { + return -TARGET_EFAULT; + } + arg_sigset = tswapal(arg7[0]); + arg_sigsize = tswapal(arg7[1]); + unlock_user(arg7, arg6, 0); + + if (arg_sigset) { + sig.set = &set; + if (arg_sigsize != sizeof(*target_sigset)) { + /* Like the kernel, we enforce correct size sigsets */ + return -TARGET_EINVAL; + } + target_sigset = lock_user(VERIFY_READ, arg_sigset, + sizeof(*target_sigset), 1); + if (!target_sigset) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, target_sigset); + unlock_user(target_sigset, arg_sigset, 0); + } else { + sig.set = NULL; + } + } + + ret = get_errno(safe_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, + ts_ptr, sig_ptr)); + + if (!is_error(ret)) { + if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) { + return -TARGET_EFAULT; + } + if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) { + return -TARGET_EFAULT; + } + if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) { + return -TARGET_EFAULT; + } + if (ts_addr && host_to_target_timespec(ts_addr, &ts)) { + return -TARGET_EFAULT; + } + } + return ret; +} + SYSCALL_IMPL(read) { int fd = arg1; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2c8d74a450..6355fd62d8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4158,109 +4158,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_pselect6 - case TARGET_NR_pselect6: - { - abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; - fd_set rfds, wfds, efds; - fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; - struct timespec ts, *ts_ptr; - - /* - * The 6th arg is actually two args smashed together, - * so we cannot use the C library. - */ - sigset_t set; - struct { - sigset_t *set; - size_t size; - } sig, *sig_ptr; - - abi_ulong arg_sigset, arg_sigsize, *arg7; - target_sigset_t *target_sigset; - - n = arg1; - rfd_addr = arg2; - wfd_addr = arg3; - efd_addr = arg4; - ts_addr = arg5; - - ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); - if (ret) { - return ret; - } - ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); - if (ret) { - return ret; - } - ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); - if (ret) { - return ret; - } - - /* - * This takes a timespec, and not a timeval, so we cannot - * use the do_select() helper ... - */ - if (ts_addr) { - if (target_to_host_timespec(&ts, ts_addr)) { - return -TARGET_EFAULT; - } - ts_ptr = &ts; - } else { - ts_ptr = NULL; - } - - /* Extract the two packed args for the sigset */ - if (arg6) { - sig_ptr = &sig; - sig.size = SIGSET_T_SIZE; - - arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); - if (!arg7) { - return -TARGET_EFAULT; - } - arg_sigset = tswapal(arg7[0]); - arg_sigsize = tswapal(arg7[1]); - unlock_user(arg7, arg6, 0); - - if (arg_sigset) { - sig.set = &set; - if (arg_sigsize != sizeof(*target_sigset)) { - /* Like the kernel, we enforce correct size sigsets */ - return -TARGET_EINVAL; - } - target_sigset = lock_user(VERIFY_READ, arg_sigset, - sizeof(*target_sigset), 1); - if (!target_sigset) { - return -TARGET_EFAULT; - } - target_to_host_sigset(&set, target_sigset); - unlock_user(target_sigset, arg_sigset, 0); - } else { - sig.set = NULL; - } - } else { - sig_ptr = NULL; - } - - ret = get_errno(safe_pselect6(n, rfds_ptr, wfds_ptr, efds_ptr, - ts_ptr, sig_ptr)); - - if (!is_error(ret)) { - if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) - return -TARGET_EFAULT; - if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) - return -TARGET_EFAULT; - if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) - return -TARGET_EFAULT; - - if (ts_addr && host_to_target_timespec(ts_addr, &ts)) - return -TARGET_EFAULT; - } - } - return ret; -#endif #ifdef TARGET_NR_symlink case TARGET_NR_symlink: { diff --git a/linux-user/strace.list b/linux-user/strace.list index 297180d94f..1bb9224b5e 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -848,9 +848,6 @@ #ifdef TARGET_NR_profil { TARGET_NR_profil, "profil" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pselect6 -{ TARGET_NR_pselect6, "pselect6" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_ptrace { TARGET_NR_ptrace, "ptrace" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164555 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4811774ili; Sun, 19 May 2019 14:27:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsdZ7UrZNJe0+VrPffqdr4I7rY3tU+EQrPHJ6nAZIzFDg7e3wa/PkWG1LzhoG+8nHRnsOB X-Received: by 2002:a50:d791:: with SMTP id w17mr71090078edi.223.1558301247875; Sun, 19 May 2019 14:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301247; cv=none; d=google.com; s=arc-20160816; b=sFzpJ1wFPIqevKXIL2/oaSfyHWfA/6Hk/EfJ0j4O+MKjumxL2QOxSUTfjFVoYAXGEu P59KQoYVuiKjksbNFJOLUBxSjCHL0guMOBA9u8Iu7bFGesO5NxkV9IRQJyfq19iK7ICp LRoOt9GiO33gEYOaMwh5SJmuoPadTID1zfWErtwxgL2FyV5LqmBmyoIXHbdZzx8L/HHC ssqZCCi6nigeakWq40dw06bCOvPP99oJuKnPdzLupoHPDCiUMUgeyTzoSjgR9kifq/8x S5+3i+q5cfj3IhcjZt/ci4WJuVx/zTibBXr9BKzS9nXXRevxRWTLI8wY+JY6ORc3veT5 /pEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=uYnsHq9/MDxU+MhAeWsJGfGuVRcPuHSPILqSnflq808=; b=01WACL172u/Mk5FusQIyfWmmMO+kaDPMTctxRH5RxTrPUQzwPFnan+lEffUaqsNCCx 1a+u4/rgZ125QEr7GWnZ2pE+jD893j5q3c719ctWGqavnzc4Dum1pvgmMQO/EjcvSIQr Y4wUZhHWwd+dO1MufG4uKMgS4wzYSBiKIB4gyFTmMM9R2mzKQCBKRlbywrDSGFt11cWL ZpASZdTmbvEvDloGxOBREBp8nIT+Q4SabskW4YKqDRXhWQMXqrDM8Dw/uCbpHeRPm8oB iqTjurpjpCZGRflRwL37poUaR+lHPV1YR2ECGHlQTUewPaA1guy/1+KgyjdFbL9SNHBl gUtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Zyt1ejbO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g40si5206066eda.344.2019.05.19.14.27.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:27:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Zyt1ejbO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTL4-0004Xc-Lm for patch@linaro.org; Sun, 19 May 2019 17:27:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSaA-000470-3A for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSa8-00054w-US for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:58 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37552) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa8-00054H-OA for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:56 -0400 Received: by mail-pf1-x441.google.com with SMTP id g3so6171976pfi.4 for ; Sun, 19 May 2019 13:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uYnsHq9/MDxU+MhAeWsJGfGuVRcPuHSPILqSnflq808=; b=Zyt1ejbOQKCVf+XkZU0o42hrxBobvNvTQ5mQdNaqW8Z7iXyO8kgx8f55V6lr4b9tp8 dFcwC+paPo2Agj1uHZ6Bwdp+X21fNY9b5fSZKIGI3prnirUeVqwZFqx2L9BHux6OhyKs r5/S1/gMGxYO9PMTRgCLahsMbOtFD0Kl3OduRsVU3rARg+dKPboZrvPS3sxQJsJU9NfT R2s4P0um+Z1SE8vKLOQf0ynfTpo4HtvPjPBXfHxg+q2dgGV5iIBBbqwbmr4U1Riiv6tF gQMnwJo5ajOpVUFqoBvkWjp/Smmjd8w5bDWafbCll4HOmuH0n9Lo+kv6zUJKu7/Euw/T orbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uYnsHq9/MDxU+MhAeWsJGfGuVRcPuHSPILqSnflq808=; b=eIah9cSOUCQaF8m29ZyH7kB8n1dtoKwFe8V4ffS7BDP498vkPZG8OdwvCgnSKCg8WM 2rQxaqPvyJzQaGVrPnwm9O6UkIZSelBPStgTVZ1w95DORRBHuyr31QnNwLwzNwefpF0A 1FVDg6r4ixnGI4KRAaw4pmJ1UIcPsH/ITnGWTZufNv+rj1zehJC2RB+5m1I1E6p/tk/F DGM21esxUmcZVzHKQatxDIy4oFG6UJaxNXo3epCCXZg4mjN7gdDnJQMD3VlX7EOd+5Xg r9nq9erUpr5T8HzgctvOLvvprzmtTcCUIEcA60sfYqoZ4WWbNXg9N/xfn1h7Bd/O6QjM F6lQ== X-Gm-Message-State: APjAAAVraEhEjyT4vXUrz8/SSuSRP04hUbPW3QbCgBNUDHoejDeQTFpn HAdrcruKB5LPfaS2yqhUO/IRvkpGZdY= X-Received: by 2002:a63:6ac1:: with SMTP id f184mr72586068pgc.25.1558298335548; Sun, 19 May 2019 13:38:55 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:22 -0700 Message-Id: <20190519203726.20729-71-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v7 70/74] linux-user: Split out symlink, symlinkat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/strace.c | 27 --------------------------- linux-user/syscall-file.inc.c | 28 ++++++++++++++++++++++++++++ linux-user/syscall.c | 30 ------------------------------ linux-user/strace.list | 6 ------ 5 files changed, 32 insertions(+), 63 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index c179f69d9f..5625c268c3 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -279,6 +279,10 @@ SYSCALL_DEF(ssetmask, ARG_HEX); #ifdef TARGET_NR_stime SYSCALL_DEF(stime, ARG_PTR); #endif +#ifdef TARGET_NR_symlink +SYSCALL_DEF(symlink, ARG_STR, ARG_STR); +#endif +SYSCALL_DEF(symlinkat, ARG_STR, ARG_ATDIRFD, ARG_STR); SYSCALL_DEF(sync); SYSCALL_DEF(syncfs, ARG_DEC); #ifdef TARGET_NR_time diff --git a/linux-user/strace.c b/linux-user/strace.c index 669eca7fa6..97755458d3 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1563,33 +1563,6 @@ print_statfs64(const struct syscallname *name, } #endif -#ifdef TARGET_NR_symlink -static void -print_symlink(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_string(arg1, 1); - print_syscall_epilogue(name); -} -#endif - -#ifdef TARGET_NR_symlinkat -static void -print_symlinkat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_at_dirfd(arg1, 0); - print_string(arg2, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_utimensat static void print_utimensat(const struct syscallname *name, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 0a25d39d28..e3749f0fb4 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -1254,6 +1254,34 @@ SYSCALL_IMPL(select) } #endif +static abi_long do_symlinkat(abi_ulong guest_target, int dirfd, + abi_ulong guest_path) +{ + char *target = lock_user_string(guest_target); + char *path = lock_user_string(guest_path); + abi_long ret = -TARGET_EFAULT; + + if (target && path) { + ret = get_errno(symlinkat(target, dirfd, path)); + } + unlock_user(path, guest_path, 0); + unlock_user(target, guest_target, 0); + + return ret; +} + +#ifdef TARGET_NR_symlink +SYSCALL_IMPL(symlink) +{ + return do_symlinkat(arg1, AT_FDCWD, arg2); +} +#endif + +SYSCALL_IMPL(symlinkat) +{ + return do_symlinkat(arg1, arg2, arg3); +} + SYSCALL_IMPL(sync) { sync(); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6355fd62d8..fccf9ee184 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4158,36 +4158,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_symlink - case TARGET_NR_symlink: - { - void *p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg2); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(symlink(p, p2)); - unlock_user(p2, arg2, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif -#if defined(TARGET_NR_symlinkat) - case TARGET_NR_symlinkat: - { - void *p2; - p = lock_user_string(arg1); - p2 = lock_user_string(arg3); - if (!p || !p2) - ret = -TARGET_EFAULT; - else - ret = get_errno(symlinkat(p, arg2, p2)); - unlock_user(p2, arg3, 0); - unlock_user(p, arg1, 0); - } - return ret; -#endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 1bb9224b5e..d9db80335d 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1122,12 +1122,6 @@ #ifdef TARGET_NR_swapon { TARGET_NR_swapon, "swapon" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_symlink -{ TARGET_NR_symlink, "symlink" , NULL, print_symlink, NULL }, -#endif -#ifdef TARGET_NR_symlinkat -{ TARGET_NR_symlinkat, "symlinkat", NULL, print_symlinkat, NULL }, -#endif #ifdef TARGET_NR_syscall { TARGET_NR_syscall, "syscall" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164558 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4813736ili; Sun, 19 May 2019 14:30:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu50WiptaOgWgdXlM69XMTSJygBQwdl6yvISic+ll1KyV8hrxNRHqUhcZZ9bO8bd3OVYH0 X-Received: by 2002:a17:906:4e87:: with SMTP id v7mr49666231eju.150.1558301436580; Sun, 19 May 2019 14:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301436; cv=none; d=google.com; s=arc-20160816; b=zcDAWAbfuJCFF0iBF9ORrlpgxdxjjTWDB7f0bJd/f4EkHSbDHrQEgP29eQpl9g/y3M 0RxXvUjnKDse5zhPS+5UchbTekN5+NaHk3ercBM3FqDOl53UG3hg5mMYU5bhTTQrSgjL HTypQgl0plYupvsZ55kqgKyFJpr08+0OeeAyODYcPzNIjJbTbrsX5/VuWx9W/KELY8L4 7HUADIceprA6DAq/wLqVPytFs0VS4fIi5eKPzSXiytwEY88uvXMAqteKZj+igFThUl9v HUkotH46qKk9kDNYw9OJcRiFJPYIa+81WyqSjVxLsG1i2QcDR3SGP6cfaJ2ZUKjcPnPY jnMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AwkKxT6hgxGUbnCawP7ML0rY671AUDoxnoeEokerBT8=; b=cPDHa3QRaMcF8ar/lhFD1pQ3UpeIvfCUSh01is//V77VI53z30jiZ7s8fnC/PeTkPA gVsAFGp4s8Tva9j7QlT5T59qSqew4GoSSuQ2dcvyXAUiuG675+Ux7iLq28aCN4RlXI7H gx5PO3V/DT/QxScL6O4Hcnz3IMnPsoli1riBakYpjrz8cPnW5a3heXERX3Zbbr1p/3oj N0yI4iaPEc7EnKmNCriU9rwFb6EJhcBDzmva0wMbhInd75kdUIaS1hhSSWskmrk15YTI P8eZNMpfTsU4JMFQhe5oDAyNe/6478eKSfPb6HJ0wdVAWT/gVh+s+P9gMUBjqWIGE6P/ pQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=geyLX6mR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c44si10929627ede.137.2019.05.19.14.30.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:30:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=geyLX6mR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTO7-0007Po-GW for patch@linaro.org; Sun, 19 May 2019 17:30:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSaB-000483-5N for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSaA-00056K-42 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:59 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:44494) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSa9-00055d-Tl for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:58 -0400 Received: by mail-pf1-x443.google.com with SMTP id g9so6149356pfo.11 for ; Sun, 19 May 2019 13:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AwkKxT6hgxGUbnCawP7ML0rY671AUDoxnoeEokerBT8=; b=geyLX6mRxlcwdztvehOJoVihDXVuFrvzPKzOHjfE52+WR6W5LXbZRhSZovgXDjj/s5 Rpv+56ZNUtlwmLfAdrPaEm5bdgDCVZlGvkJ7JRGMm5oi7Ooo/SEG2AmC6vbTtrSWU2U1 KHY83aLr+EU0NC/utnT2IFq204cIyERYQ6zXj6X6G6seqxqccTZ5mEPbmR1n8fvQ+eDj J/41cojmPZvLot3lmXnjgEBe7eVoj74cioFSiaD3RRQlWwE+Riqr3ZFzv6GCt+U5VupW 7s0elB2xOG6RvI0p/YlV04Z2Y8hT1yJBL9lKTfElXE8v3237rFFMXSOYO+CcdOPM0uFr wfKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AwkKxT6hgxGUbnCawP7ML0rY671AUDoxnoeEokerBT8=; b=Z7eFkQUVLutE06d2qjGsb3fQTHebo05mu9Ef6Y4xAdCjp2wRGi03iCZQFrDjv0quup O3zG97xhEdRU3kZYgUO46KFEUmPJFB40vrsJLR8KHbG1YKU/Ta/hXVeO0R4UlxdjVe5O LzRM0tMjryoLDObY8x7v6PS9/gnLx74YFkOtFHwdCa8qxxnjH1XgwNt7VVgmYX+LbAvI hIBrU1/hPYWa3PjxbUsCPTL+M5IqrnL8BQXXQCt6jaDw1URB0FPC7MuHHTNsBoduby9l 3z8j/pKvZlgfAzIqLemcK+AKaCw3L3wmbii9IiV6ji+7J5sR+/JlmYYuDn7nJXYsYWFB eCfw== X-Gm-Message-State: APjAAAWQ2vqkhNVPTvKrC5MscUvIeGQlvJS0/YISzCMyA6NPMqBfrnUz sw8om7sRw49MN2eI8g4p1eewhVIDkMU= X-Received: by 2002:a65:5cca:: with SMTP id b10mr71649844pgt.444.1558298336768; Sun, 19 May 2019 13:38:56 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:23 -0700 Message-Id: <20190519203726.20729-72-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PATCH v7 71/74] linux-user: Split out swapon, swapoff X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-file.inc.c | 26 ++++++++++++++++++++++++++ linux-user/syscall.c | 16 ---------------- linux-user/strace.list | 6 ------ 4 files changed, 28 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 5625c268c3..34e799d206 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -279,6 +279,8 @@ SYSCALL_DEF(ssetmask, ARG_HEX); #ifdef TARGET_NR_stime SYSCALL_DEF(stime, ARG_PTR); #endif +SYSCALL_DEF(swapoff, ARG_STR); +SYSCALL_DEF(swapon, ARG_STR, ARG_HEX); #ifdef TARGET_NR_symlink SYSCALL_DEF(symlink, ARG_STR, ARG_STR); #endif diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index e3749f0fb4..bdf42ad437 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -1254,6 +1254,32 @@ SYSCALL_IMPL(select) } #endif +SYSCALL_IMPL(swapoff) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(swapoff(p)); + unlock_user(p, arg1, 0); + return ret; +} + +SYSCALL_IMPL(swapon) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(swapon(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + static abi_long do_symlinkat(abi_ulong guest_target, int dirfd, abi_ulong guest_path) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fccf9ee184..ead2e5c2b8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4158,14 +4158,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_swapon - case TARGET_NR_swapon: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(swapon(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_reboot: if (arg3 == LINUX_REBOOT_CMD_RESTART2) { /* arg4 must be ignored in all other cases */ @@ -4503,14 +4495,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_syscall: return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, arg6, arg7, arg8, 0); -#endif -#ifdef TARGET_NR_swapoff - case TARGET_NR_swapoff: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(swapoff(p)); - unlock_user(p, arg1, 0); - return ret; #endif case TARGET_NR_sysinfo: { diff --git a/linux-user/strace.list b/linux-user/strace.list index d9db80335d..3d2e398439 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1116,12 +1116,6 @@ #ifdef TARGET_NR_swapcontext { TARGET_NR_swapcontext, "swapcontext" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_swapoff -{ TARGET_NR_swapoff, "swapoff" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_swapon -{ TARGET_NR_swapon, "swapon" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_syscall { TARGET_NR_syscall, "syscall" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164564 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4818106ili; Sun, 19 May 2019 14:36:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqz81pQOzY6001T6gH89Al03qui5TYz/T70ApQ3evpDDE/BlRp003eJaSZFfrvZ93A2sgo41 X-Received: by 2002:a17:906:31d4:: with SMTP id f20mr13732247ejf.275.1558301798129; Sun, 19 May 2019 14:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301798; cv=none; d=google.com; s=arc-20160816; b=PkEynBlhmreRTayZa5TOPsdwzuaDoIfUqEsSD1sJTaVLxFF9+ey2qMJMBDOOO71gi6 fFv7QSx4s0Q+47Rv4DFNb70C1e64CnYduKwwbYqUpImZgrWBO6qnKUXezG5pWRogerH3 hpGjlqP0ldqT7yVCvuv48sKoZIXK/aY8PftArm73TzQxELIRFPWxXn9ZXyZK9muuNyY4 OiUkqZ3ukpNKB2Tja2F1JiDVMBZDWy+E8fsgoAPWtpY/1UjBOvzTJfHbXaaKt46I2lVU 9OeoKAWnNYqNexH368v0oInZ7bZWrwTse7PzLQdB+g6D/3iYPaV+42bSQ/o/LSvwEV8r WQjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=fHCmInnpNa2F4K91jX190NfL9NDB7tdazRZM5/cuyRM=; b=ZnWKPfaYQqKHSR+mJLTbL+aNQfW0diZOTGXLewglXR+Kpm50lrJJL2XwdQkNlgBao8 15Rs6DuZtwprnkpkpKhu2qTdNNoI2xKFfKJM3HijbdqdhSpR137MJhZKnCeAnv637UnW EFwUyKOcI6/RtbcQ2CdL+bVi0MuL/m98fUQQ0SS3UPy49rQ21IMj8HdPzJv+Fg8nXqzB pAmZ5K366NoOFlo45uI4dH3TZFl1R3vwhL8EQ0NmcVgKDVmM5r1fJ1IW3MH8BBP1Kt31 eHeIYxaD58K5d4d3QPOcYB5bU5wFjavPI3dvWvsEhpiQQBZ1yjUtEIL81SLKeeEtaZL7 7H7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sTKWJdqs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h11si10747260edb.126.2019.05.19.14.36.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:36:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sTKWJdqs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:54024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTTx-0003LE-3C for patch@linaro.org; Sun, 19 May 2019 17:36:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSaC-00049G-Ch for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSaB-00058F-Cm for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:00 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:38185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSaB-00057F-6n for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:59 -0400 Received: by mail-pg1-x544.google.com with SMTP id j26so5741282pgl.5 for ; Sun, 19 May 2019 13:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fHCmInnpNa2F4K91jX190NfL9NDB7tdazRZM5/cuyRM=; b=sTKWJdqst8ArJHRiRxt07TQwIJU6RCXBO228h/fitWQRQV+gAWRLw3XhJUQFXbt3OO EDh2ENMmYnXniUJJiSmTmPll/n5NHAa/GA+ZwCcsA/Ifhpx9W+f1AvCG9hz1NdUd+a1L e8GAFapdATIWLxV3+lUTI8X4WN2qs14xRnJ6TMxsbyd3UTQA3Xgb0nbHF8nIRhisImh8 kUZNpS2NOoctyHTVHXuSGff1miHNnutSWM/8yHMOdUdp7/nLJWNh2o3NtyJV7CppKxNL VaaBMCwSwAKiQvSXUkIw5gMtxYqRhTIxXLtFpHVd01+nbxWxYtWvUBspZwzGIB3olzKa oebw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fHCmInnpNa2F4K91jX190NfL9NDB7tdazRZM5/cuyRM=; b=Kzj+cFPwwQpSoYfOpkveRmQiI3wY74CqcZWen0edC8JOnKqastfGT4o9Gq3qqw6MrF Y6IsEFDHq8G/WYkL3xNqa9vevOMNn+O2VHq726llD5HzjvITD+XKkVTlYQwkIhGO0Tt4 m8lw2j3OXcGHUtATJnbD/FoywHeivUQAKh7DnWBIo87VNvYbs617yqJqN9WilA0R0jRP BSmjhZvaO6xsoNOl2xyX7ll8e7dSkCnVjI5TnJ4O7md6L4/jTE2YVuzDEx+3pyYfvtqE cKMsAZiOs6HzfoXebKu9fQg7IMaFA7NVFsHiXKUF2kdm7j/3OKwbqtkdtQ2szStIlWRq 3Rrg== X-Gm-Message-State: APjAAAUHJFmcJ77GaHV6PqXhvjeZWRCuAo3pMQrJNtAYAXB0NwJ4uIDe QZmL0iWiEYDhkAc8AgH09P51LOX6bmQ= X-Received: by 2002:a65:52c3:: with SMTP id z3mr18674927pgp.56.1558298338013; Sun, 19 May 2019 13:38:58 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:24 -0700 Message-Id: <20190519203726.20729-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v7 72/74] linux-user: Split out reboot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 1 + linux-user/syscall-proc.inc.c | 18 ++++++++++++++++++ linux-user/syscall.c | 13 ------------- linux-user/strace.list | 3 --- 4 files changed, 19 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 34e799d206..67c908448d 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -188,6 +188,7 @@ SYSCALL_DEF(readlink, ARG_STR, ARG_PTR, ARG_DEC); #ifdef TARGET_NR_readlinkat SYSCALL_DEF(readlinkat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_DEC); #endif +SYSCALL_DEF(reboot, ARG_HEX, ARG_HEX, ARG_DEC, ARG_PTR); #ifdef TARGET_NR_rename SYSCALL_DEF(rename, ARG_STR, ARG_STR); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index bf9e278bf0..408e96a834 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -532,6 +532,24 @@ SYSCALL_IMPL(nice) } #endif +SYSCALL_IMPL(reboot) +{ + abi_long ret; + + if (arg3 == LINUX_REBOOT_CMD_RESTART2) { + /* arg4 must be ignored in all other cases */ + char *p = lock_user_string(arg4); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(reboot(arg1, arg2, arg3, p)); + unlock_user(p, arg4, 0); + } else { + ret = get_errno(reboot(arg1, arg2, arg3, NULL)); + } + return ret; +} + SYSCALL_IMPL(sethostname) { void *p = lock_user_string(arg1); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ead2e5c2b8..80e8b360a9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4158,19 +4158,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_reboot: - if (arg3 == LINUX_REBOOT_CMD_RESTART2) { - /* arg4 must be ignored in all other cases */ - p = lock_user_string(arg4); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(reboot(arg1, arg2, arg3, p)); - unlock_user(p, arg4, 0); - } else { - ret = get_errno(reboot(arg1, arg2, arg3, NULL)); - } - return ret; #ifdef TARGET_NR_truncate case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) diff --git a/linux-user/strace.list b/linux-user/strace.list index 3d2e398439..3326541f17 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -866,9 +866,6 @@ #ifdef TARGET_NR_readdir { TARGET_NR_readdir, "readdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_reboot -{ TARGET_NR_reboot, "reboot" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_recv { TARGET_NR_recv, "recv" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164561 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4815664ili; Sun, 19 May 2019 14:32:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5xLyE6yCalT2ex/AvKLpnsi+oUXL7hXZsO1YutGoJaQpsfsqF4eaHKbVyVWtO+ojOIlHE X-Received: by 2002:a17:906:1315:: with SMTP id w21mr19760941ejb.193.1558301576686; Sun, 19 May 2019 14:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301576; cv=none; d=google.com; s=arc-20160816; b=YiswpN5eGylpd50eoDbBYLcNdC2acj9b9XomrFB01uunEsVHQu1dd1k5Fp7wkDj86F I/4v6UyevhH5G59QGAfJ1T5kNw2gnYK15gpAFjQeLNDq6tSTxpV6K/vuN+cVhyUKlCrj SY8ojVYHCSWR4OdutDJXNyX8eLcZ9egAMP8LwI7PrpI6y8bD+d1ffMPsX2fhNNyelqi8 kbVnz+jOsw4zO0+t7j5iUTk84JhIXDdtX53KmAQ+XOapengToBhTbDfIMg8xUIcgAC+Z jcJMd87utvOZB5mQiFyfuXaKIrNdwemX2LMrFjEcpytGj6pCZhE2QAtFs+uDQplHCFEM tgUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=81B5oVWex5Gu+YUrZz7czpuJcnBNioLb7beqWXgK+Ug=; b=J07H28hJTczvyuyoSnPqS4lNd0eHTEjngLytpnQbNdcP/1+LTjD5NJCPLCBOjq8UCp PlBlvH11C/GZzcEUGbjknlxjOMg6Dy6kr8c63J7IWeJv2IfmroDCINIxm3AaT2rXKT31 p0q4TOaOWbYEO1Mh5EzVTprlo79jR2a4HlUwr5Xwl83cRpvpEgVM3gFvi3p3Q3hiVzC7 2FoOn3EPoZLGgrh45Qfd1OY2/qb22Ejp4stxvj3/3uNQHaa2WM54buWXDf5ou/67N7Eo /GYpjSz1cnxuAulkk/YMEKn7owAFDZ1XMAohw+rPQRwwXjr1bRov7dtwxcg7ndpU6z1W FQFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MW276PEe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r16si104119ejj.69.2019.05.19.14.32.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:32:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MW276PEe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTQN-0000qR-Gq for patch@linaro.org; Sun, 19 May 2019 17:32:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSaD-0004Ab-Sd for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSaC-00059o-L2 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:01 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:34659) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSaC-00058x-EW for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:00 -0400 Received: by mail-pg1-x544.google.com with SMTP id c13so5748377pgt.1 for ; Sun, 19 May 2019 13:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=81B5oVWex5Gu+YUrZz7czpuJcnBNioLb7beqWXgK+Ug=; b=MW276PEeOF33ylNFozQxdOOz4TXNh6y0F6sLo8pPFZpkVOf33zi0mx3NAOsdQbdU3+ 7uho8rBFL2KXgpj5fqeWy7CVguXwrPipVelVHIcoKAg+4WL/hjTuDwIBvjKTZ4Q0+ZKX vNYAiXFY+DOKMHCHwESEySq3ZdqaICyfZBhy29W/aa1xUQAV9wpw40srFj2paVYrZf7/ y7x9Cs5PBJtN9MBzlbeWV8qJTcu1j0IMXl2wR5qtS4oc7CNPOnRnOD3muDf2RL/3+TvB 8WkIrnTB1Lx5zaf9Wlljd9AmFWYrw5Pdn6H4RGZd47sn6T2dJDDApZyveZUlYBIrmduo 73Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=81B5oVWex5Gu+YUrZz7czpuJcnBNioLb7beqWXgK+Ug=; b=Eud5Ar/3PYTi++pMudBeCJnx3ZVyE4BCun9M4vo5E8HhOtKiiJ168IyC5bnHSGOK3a c5mLU6R2IdOpWli2L1kNghnCE1YiGqSZhw+K4/9+kfsN6Et+bRPpzfAvLcS6MWoCra1R QBTZgquNws2PmjoOqNicb/kLqNEAmm+ABlkmoC4VqM2PfKNxo8KBKqo5ZJM0vOzAXFJ5 T3nrBmbDpV6dvfNIuIiXYmeAf7pmO20+bL5eW3jFCOq+gXIUAtNkThsob3bDgDNmGjfP QARoQ758KciYx1DbhaWDXTocpo1FB9uPpVvfoedgZFDpluEgcYTzlwiNFeyGeEUOwdUC oW8w== X-Gm-Message-State: APjAAAVQozMJ5yO9qMG7VrExIoKOgszP4SM3GYH9wdMlZB3/XD7qvTWY Xh3qbrHpagXmZ6c1Cpnd1gVpUH8xr+E= X-Received: by 2002:a63:374b:: with SMTP id g11mr15575741pgn.421.1558298339261; Sun, 19 May 2019 13:38:59 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:25 -0700 Message-Id: <20190519203726.20729-74-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v7 73/74] linux-user: Split out truncate, truncate64, ftruncate, ftruncate64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 16 +++++++++++++++ linux-user/syscall-file.inc.c | 32 +++++++++++++++++++++++++++++ linux-user/syscall.c | 38 ----------------------------------- linux-user/strace.list | 12 ----------- 4 files changed, 48 insertions(+), 50 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 67c908448d..8b2d95d19e 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -59,6 +59,14 @@ SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif +#ifdef TARGET_NR_ftruncate +SYSCALL_DEF(ftruncate, ARG_DEC, ARG_DEC); +#endif +#ifdef TARGET_NR_ftruncate64 +SYSCALL_DEF_FULL(ftruncate64, .impl = impl_ftruncate, + .args = args_ftruncate64_truncate64, + .arg_type = { ARG_DEC, ARG_DEC64 }); +#endif #ifdef TARGET_NR_gethostname SYSCALL_DEF(gethostname, ARG_PTR, ARG_DEC); #endif @@ -292,6 +300,14 @@ SYSCALL_DEF(syncfs, ARG_DEC); SYSCALL_DEF(time, ARG_PTR); #endif SYSCALL_DEF(times, ARG_PTR); +#ifdef TARGET_NR_truncate +SYSCALL_DEF(truncate, ARG_STR, ARG_DEC); +#endif +#ifdef TARGET_NR_truncate64 +SYSCALL_DEF_FULL(truncate64, .impl = impl_truncate, + .args = args_ftruncate64_truncate64, + .arg_type = { ARG_STR, ARG_DEC64 }); +#endif SYSCALL_DEF(umask, ARG_OCT); #ifdef TARGET_NR_umount SYSCALL_DEF(umount, ARG_STR); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index bdf42ad437..7697cb304a 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -182,6 +182,25 @@ SYSCALL_IMPL(fchmodat) return do_fchmodat(arg1, arg2, arg3); } +#ifdef TARGET_NR_ftruncate64 +# if TARGET_ABI_BITS == 32 +SYSCALL_ARGS(ftruncate64_truncate64) +{ + /* We have already assigned out[0]. */ + int off = regpairs_aligned(cpu_env, TARGET_NR_ftruncate64); + out[1] = target_offset64(in[1 + off], in[2 + off]); + return def; +} +# else +# define args_ftruncate64_truncate64 NULL +# endif +#endif + +SYSCALL_IMPL(ftruncate) +{ + return get_errno(ftruncate(arg1, arg2)); +} + #ifdef TARGET_NR_futimesat SYSCALL_IMPL(futimesat) { @@ -1319,6 +1338,19 @@ SYSCALL_IMPL(syncfs) return get_errno(syncfs(arg1)); } +SYSCALL_IMPL(truncate) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(truncate(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + static abi_long do_umount2(abi_ulong target_path, int flags) { char *p = lock_user_string(target_path); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 80e8b360a9..1b1d44bf32 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3721,20 +3721,6 @@ static inline abi_long target_truncate64(void *cpu_env, const char *arg1, } #endif -#ifdef TARGET_NR_ftruncate64 -static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, - abi_long arg2, - abi_long arg3, - abi_long arg4) -{ - if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { - arg2 = arg3; - arg3 = arg4; - } - return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); -} -#endif - static inline abi_long target_to_host_timespec(struct timespec *host_ts, abi_ulong target_addr) { @@ -4158,18 +4144,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_truncate - case TARGET_NR_truncate: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(truncate(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_ftruncate - case TARGET_NR_ftruncate: - return get_errno(ftruncate(arg1, arg2)); -#endif case TARGET_NR_getpriority: /* Note that negative values are valid for getpriority, so we must differentiate based on errno settings. */ @@ -5371,18 +5345,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } #endif -#ifdef TARGET_NR_truncate64 - case TARGET_NR_truncate64: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_ftruncate64 - case TARGET_NR_ftruncate64: - return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); -#endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: if (!(p = lock_user_string(arg1))) { diff --git a/linux-user/strace.list b/linux-user/strace.list index 3326541f17..55b617239c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -193,12 +193,6 @@ #ifdef TARGET_NR_ftime { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_ftruncate -{ TARGET_NR_ftruncate, "ftruncate" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_ftruncate64 -{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL }, #endif @@ -1173,12 +1167,6 @@ #ifdef TARGET_NR_tkill { TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL }, #endif -#ifdef TARGET_NR_truncate -{ TARGET_NR_truncate, "truncate" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_truncate64 -{ TARGET_NR_truncate64, "truncate64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_tuxcall { TARGET_NR_tuxcall, "tuxcall" , NULL, NULL, NULL }, #endif From patchwork Sun May 19 20:37:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164565 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4819324ili; Sun, 19 May 2019 14:38:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzmokdHuD22xTxpoilOKMmt0oypQK/aopXhR40oe7NTrNF+LkMGgoVHYIbdOgyH4aySq/z X-Received: by 2002:a17:906:4594:: with SMTP id t20mr30716337ejq.223.1558301899137; Sun, 19 May 2019 14:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301899; cv=none; d=google.com; s=arc-20160816; b=GuJN/fRR3FeLPJ7PZauLLoLRRmirf59aulDoVHICJNIfKtCE4UXde9LejmvRKq6Jsg at9524xOAVKwoTAtdmMix37vEWLxYERV7hJDyaeaoLQyGWyO0On+uZ4r8xTLOHFIuoex PytPudnJJK+rtmPU0jUzzp94AQ43FO0NL5mnVYRKDQJ3wqriOGthhPamav5PJmaFV7cA mkoDwg4OFM7t28ZutxhD5raMCmD00TrEjD1AExH2vVcFsUjMB/KL0psXCWZnvLud5CSJ S6VDVEKjrDfCD5VktMqyuiUKxR0X/+Z26276DtaL7wmHs6Ru8H9OyMha0iUlqDW5Oyo3 HTWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=EjoYPrl44jrQeXa6UK02T5QS4VIgYMGR1w3phRnmDY0=; b=j9p8ghTnpsDye+vRZJoB1NT7+WtqAkgfhIGdQRw4PdEXUI+2l5tbmxAnukHAH5WhxH f/a66Q3dhSDDTAiZgSooVdYuyhcV8jg1Lphts74vAUojFcnFyd6+0+YjHyngZw8b7VQv X06/slqTOi7EvVFRctwaxs3jGOftRW7l01QWxwwVL2r8n+wpj8YqlT0g8zleWaVOxWlq FwST2zav61f6oqHwMRY64DMHwnelcjzW+krRY/y+QZ2IL0zTGco06BRbg+EWv2/6+0NG kokjSRfD59bYs6Sdqigp9HzRFN4kpZ2zYEPGvDeuOGubsJQsK//PLfZvUmyI76c2bMKm +M2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=z5F6WQF5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z54si6131492edb.367.2019.05.19.14.38.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:38:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=z5F6WQF5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:54050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTVa-0004PZ-3o for patch@linaro.org; Sun, 19 May 2019 17:38:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSaE-0004BD-Q1 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSaD-0005Av-Ld for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:02 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:38183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSaD-0005AS-FZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:01 -0400 Received: by mail-pg1-x541.google.com with SMTP id j26so5741300pgl.5 for ; Sun, 19 May 2019 13:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EjoYPrl44jrQeXa6UK02T5QS4VIgYMGR1w3phRnmDY0=; b=z5F6WQF52rpJo3PQhy2+twbWWJQFDoZoEePUHYzj82TmKnjvzvY5uXYPkFCbsuEr07 HjfI5nNwOrnbdyELuTn3C59hgaV9BZtN8XtBmp3vzq7XPBwCr6KO1we6KNf2gBww9wmZ yUcFH6KgkzN+qhIt1Rvz13Ese9e4L0Ai/1SJUamSkRzYOqxG1xE300HxH6VNdAkgVbRX sTpU8GlNq/J9/Rk3Ns2+kby1AiO5Z4kTvnCdEK3gp0zMRwAwL2owtrXZ658Nbu1XfIpv zcsdgoDBh4yiXc5PBn9S5KIw+l9ff/y0hXOUHOwPdRTESnx0V8ckvrtLspf1lxNcfoVx K/IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EjoYPrl44jrQeXa6UK02T5QS4VIgYMGR1w3phRnmDY0=; b=dI4xfd8Nx1rSEjdAP8pklXWylPlaHXnsfu5GDc01SEd/4wtWaQkLPZpeBHgoJbWqf4 HRSC7M7SNtYgNuSL7pynjYhApB5v+d6uufXUST9GEuRELv4GnmiSTN9Nb3tFVq5R65Dv WNQcGYvZYB5eO9yJgVBTQWkCgjIq/O7W484l8mH3FIBoVqfq5V9uW9I0HPOkYUN2VmOz qQimN/b6pUkqoa4ZR/1FJeP7bUn1uXOYA19XoIWA4nwU9ml0B+nfwzDJLEfLw0BE7cW3 YTS7qWIG5WnFBYwuorbyKNXMw5Wey5imz0YII8vltfemWI2Fs2wDEhU+FsB/4W0A2bAz WZXw== X-Gm-Message-State: APjAAAUPoSg01a3b1HhA1AB5qfM3ZWqZ6/ujOrmEuoc5lNZGSYzCTEsG VKwINVxMRsJx06E+jiHm43YZFrHfrxI= X-Received: by 2002:a65:5c89:: with SMTP id a9mr71876407pgt.334.1558298340290; Sun, 19 May 2019 13:39:00 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:26 -0700 Message-Id: <20190519203726.20729-75-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v7 74/74] linux-user: Split out getpriority, setpriority X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 2 ++ linux-user/syscall-proc.inc.c | 28 ++++++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 6 ------ 4 files changed, 30 insertions(+), 24 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 8b2d95d19e..3b45250977 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -80,6 +80,7 @@ SYSCALL_DEF(getpid); #ifdef TARGET_NR_getppid SYSCALL_DEF(getppid); #endif +SYSCALL_DEF(getpriority, ARG_DEC, ARG_DEC); #ifdef TARGET_NR_getrlimit SYSCALL_DEF(getrlimit, ARG_DEC, ARG_PTR); #endif @@ -238,6 +239,7 @@ SYSCALL_DEF(semget, ARG_DEC, ARG_DEC, ARG_HEX); #endif SYSCALL_DEF(sethostname, ARG_STR); SYSCALL_DEF(setpgid, ARG_DEC, ARG_DEC); +SYSCALL_DEF(setpriority, ARG_DEC, ARG_DEC, ARG_DEC); #ifdef TARGET_NR_setrlimit SYSCALL_DEF(setrlimit, ARG_DEC, ARG_PTR); #endif diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c index 408e96a834..e85151cc2e 100644 --- a/linux-user/syscall-proc.inc.c +++ b/linux-user/syscall-proc.inc.c @@ -479,6 +479,29 @@ SYSCALL_IMPL(getppid) } #endif +SYSCALL_IMPL(getpriority) +{ + abi_long ret; + + /* + * Note that negative values are valid for getpriority, so we must + * differentiate based on errno settings. + */ + errno = 0; + ret = getpriority(arg1, arg2); + if (ret == -1 && errno != 0) { + return -host_to_target_errno(errno); + } +#ifdef TARGET_ALPHA + /* Return value is the unbiased priority. Signal no error. */ + ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; +#else + /* Return value is a biased priority to avoid negative numbers. */ + ret = 20 - ret; +#endif + return ret; +} + #ifdef TARGET_NR_getrlimit SYSCALL_IMPL(getrlimit) { @@ -568,6 +591,11 @@ SYSCALL_IMPL(setpgid) return get_errno(setpgid(arg1, arg2)); } +SYSCALL_IMPL(setpriority) +{ + return get_errno(setpriority(arg1, arg2, arg3)); +} + #ifdef TARGET_NR_setrlimit SYSCALL_IMPL(setrlimit) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1b1d44bf32..6e7cccbdd5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4144,24 +4144,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_getpriority: - /* Note that negative values are valid for getpriority, so we must - differentiate based on errno settings. */ - errno = 0; - ret = getpriority(arg1, arg2); - if (ret == -1 && errno != 0) { - return -host_to_target_errno(errno); - } -#ifdef TARGET_ALPHA - /* Return value is the unbiased priority. Signal no error. */ - ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; -#else - /* Return value is a biased priority to avoid negative numbers. */ - ret = 20 - ret; -#endif - return ret; - case TARGET_NR_setpriority: - return get_errno(setpriority(arg1, arg2, arg3)); #ifdef TARGET_NR_statfs case TARGET_NR_statfs: if (!(p = lock_user_string(arg1))) { diff --git a/linux-user/strace.list b/linux-user/strace.list index 55b617239c..a0d2b3f9c5 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -256,9 +256,6 @@ #ifdef TARGET_NR_getpmsg { TARGET_NR_getpmsg, "getpmsg" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_getpriority -{ TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL }, -#endif #ifdef TARGET_NR_getrandom { TARGET_NR_getrandom, "getrandom", NULL, NULL, NULL }, #endif @@ -1007,9 +1004,6 @@ #ifdef TARGET_NR_setpgrp { TARGET_NR_setpgrp, "setpgrp" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_setpriority -{ TARGET_NR_setpriority, "setpriority" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_setregid { TARGET_NR_setregid, "setregid" , NULL, NULL, NULL }, #endif