From patchwork Fri Jan 18 21:31: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: 156094 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3759428jaa; Fri, 18 Jan 2019 14:14:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN6BzYlrQpw0PB1m5e3Aj0D8L0gtgnB1yuSdWA5DtYpMf3QEasPoVzbyMNJ31qAFf/8pad64 X-Received: by 2002:a1c:7306:: with SMTP id d6mr16350434wmb.98.1547849670386; Fri, 18 Jan 2019 14:14:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547849670; cv=none; d=google.com; s=arc-20160816; b=VfGZr52Q1A/gaIuCsxTfaZzobGTOl+DLn/iibmbAulQLOGmYuXtJe4jX8ATK4QR2UQ IgzKHsEtXawneDk8k68dYdb5xf5NANq17aFOC21hSHCQ8DxaIRL62l9Og18qLvzS4sMq yVNTrFaNHNrFUvzq7mK7a4lsJOzC6rkjP87rdSxm+aobpDqBfjnz1vh1BQ+qzzQE7H/O HoTPfafqo6eVS8wNAX63TGAhoQI+wTTSqa1re9/rmavTEZao7Z7Ozjdw9N6U7K3NeI9b vZDWFeITXPqZc1HUhTx4orqdh5dFnoDSTFAzJ4FGrjRFscWLa/JQznaWRuLoJW4NCDr4 PCiQ== 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=LiKNsrT5K+9huwcDKVj3zEFjQudVZx9YMALKhLtpl5w=; b=cK6Wh/dJrL+0gPzbHSRdjg3/WNw+GV0akzeFV/LjYaf/U48iAmfHNbM7V6cEW7sJgo i++5iI1fm/Lco8dvTlSuqOz37IEy+qGlBtxOfNh4esJZznwDn9JSYD9XSDjtgXHrGg0G c+YsXO2DXp7NXu6gYlYbDtDwPXx6vxrwejpLwAavcv9Y8E1Q3PlQsC7aE6KoTY1ernT7 NL8mCmsOOWn8phDciqn2PvgSwSOKDHp0oLWrxwEYSrJXRJ3UPHRheMuyb+BGEZbCdZ/g LXpEZ5hSZ7MJccI6uJinc9nIEfIDcrmwk1SkXsF7BNl+0+ArDnJhz/Yx1QB3FxzWvY8W S9sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RHAjRVMB; 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 r10si56602296wrl.456.2019.01.18.14.14.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 14:14:30 -0800 (PST) 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=RHAjRVMB; 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]:48016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkcPF-0005Zg-Aw for patch@linaro.org; Fri, 18 Jan 2019 17:14:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkblA-0005hV-N3 for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbl8-0005S4-Rz for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:04 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:36456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbl8-0005Qc-3b for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:02 -0500 Received: by mail-pl1-x644.google.com with SMTP id g9so6895762plo.3 for ; Fri, 18 Jan 2019 13:33:01 -0800 (PST) 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=LiKNsrT5K+9huwcDKVj3zEFjQudVZx9YMALKhLtpl5w=; b=RHAjRVMBKgQJXcwTC0TVoBIiWj027k7NrfalQK+Q5xRKydsxVZZh7AmnDHuQPZtMM0 bgcbUXA1Bn5yJX2gLQRnGBZ4f8CaPIwqXxFTjo6Q4Hgh00lpa0Z8MspSbBdldvtZUu8N 5Kugw9QI3Ae6atT6iUBHLB8MU8PDAWaeWZoVw= 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=LiKNsrT5K+9huwcDKVj3zEFjQudVZx9YMALKhLtpl5w=; b=F6rWIhhGFLjqI2pdYUS1ytmEA0gZrA+Zl9w6kDfw0Svis/11M1yhlpuaQlLu+TGmeP /vcNQBMbStPysXRiaqlCT44qR2F84uv14n3DiLCAtzg6C33i+RvFXDvbIqMujSwgpHog bIUz9Wu787HAVixzJ8vYZo82Tk0ezgIp1ux/shE9jpBuwzu5CjSmZnj7QSWqRWVvC5MO osckWImh5NJfY9rJDgpCgteYTagahALzkX0rtEg5fney/8DvUgreIZzspR8ygsKxJnWn oSAl2g2NmMmEoWnLxdFKypH9ohO+CcUTeF1taxEi24jU9pSyTU8B/gTRzXCGbVMfBpmi RuVw== X-Gm-Message-State: AJcUukdNELWX6NvcHp4CIy8H+HfIxLLVQjphgYq5D8hSC3LkevPi0/t8 vyxssl0+OiLUD3xv+U5XnOVH+rCWUmI= X-Received: by 2002:a17:902:c5:: with SMTP id a63mr21030958pla.267.1547847180676; Fri, 18 Jan 2019 13:33:00 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.32.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:33:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:13 +1100 Message-Id: <20190118213122.22865-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-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 v6 40/49] 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.2 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 da2cc30f82..ec36fcf2c2 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) @@ -2032,19 +2040,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, @@ -2178,6 +2173,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 6668e4ada8..fef955ce66 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5338,8 +5338,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 56f25c15b7..b120f11dc2 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