From patchwork Sun Jun 10 03:00:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138075 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2573596lji; Sat, 9 Jun 2018 20:02:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLK/7IYGBeL7P1prvSdsDnkzkysO7ZxHHFH/tCl3Fq5X5MPhJIZBfLCROY/JveFuBJ3OOeq X-Received: by 2002:a0c:8601:: with SMTP id p1-v6mr10804947qva.184.1528599772599; Sat, 09 Jun 2018 20:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528599772; cv=none; d=google.com; s=arc-20160816; b=Ra7Cypzu50ZY0DWyUhug7rQTXYTnwJOLWoRtbAJAtdsTdJ9voUD9UXka4Gmfd7zw+j SqR1qeAqflJRmSea+OAJAXXIzAUvHMX6UJrhjlLAlzHfdcsHvaKusXmYIIzszOh1PZwB ub20w2RHYzp59YVFtp2xV2pNuMbDYl+/iSfesUDtVFWYTVdoLoyOlTwLSo3c+9w4qelP Znu0yMYfxsxZlXmeu0oF3dAAlOzuDxoJfhmkzIcA5i9WfaHFguvwC+sv3a40GRaS6Mi2 JvQEVgsZVpitntBj0A0iciWd+VZKv0RzvEEfmCizPBzGJbzH2i9OU3gaK4Fpshivrxi8 0SGw== 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:arc-authentication-results; bh=nc8xWXUdkiMLiKu/AUrUH1Pr6L00YHRjLLeytlE0ns8=; b=S2KpK+51K5EFBb+Klnshz3Jv5BIFY7GVk6zgJx54TqlN0nmvQjDHy03IUNBseegcad gwSLp+DqGPYtsK27PFFgfNerKbeFphP4VhH4zUVyqnC9Oxr0xn7ueuiIh/B9j3mjO2Ne Anwld3m2HLy6W4A6Q6LmLDRAcAMSftB3cb7pIuCEJMxy9qzUtIpNv+IUqSpJToV85Xjd thSSFqfbZUa3P64A0FLg0fMSRueITgutW4tlcpE+PQi92+tr8KrVZ1V3V7EMJk+sI803 +YLYgW+w86iyTyt5loMFddIY2yHqFj/V/QbMIZWFo4JMmfPl8En+pERIz4zFWu6wM9l7 u3bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YBoSnDpL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y7-v6si15618qth.349.2018.06.09.20.02.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:02:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YBoSnDpL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd2-0001VX-22 for patch@linaro.org; Sat, 09 Jun 2018 23:02:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqch-0001VI-9h for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqcf-00035n-P1 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:31 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:42517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqcf-00035b-IT for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:29 -0400 Received: by mail-pg0-x241.google.com with SMTP id c10-v6so2507859pgu.9 for ; Sat, 09 Jun 2018 20:02:29 -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=nc8xWXUdkiMLiKu/AUrUH1Pr6L00YHRjLLeytlE0ns8=; b=YBoSnDpLzaOxHI8+a8UYUhqMeu81zLePU1VGIMQlR75ZiM6EFIA+EZXKYRD139a0gS Dkk3M97SbT8SkQxLAZOjdrKZR0GsRXVOJTFkeZutgaP1y7GK9sGK+9uNsrm8H6JAs1wm 8XLNgKvOn9XJZIoLXG318bx93gUAUsBqjhHBI= 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=nc8xWXUdkiMLiKu/AUrUH1Pr6L00YHRjLLeytlE0ns8=; b=AejtTailbaWb9W2pnA3b9uJqRdFtbvGveITCWk2b9DTyxbyNQDUvkxjSTM2A5HK0mR kxEH7/Bgtvo4OO3ejSPifI4bmQVtf1ydHQZBj7D40zjj+OKSI9B62g7qcWoDqclxSflm lQf+G8TjMhsYViYnGYx5MABSwhBNzY0PjsNI8jZXsHCiupmgNqNLqAOILUjesw/POK1i bfXLLMvQgKCGr+gS5YVK3hMzx8ncWd2RZennSldLf5lss/RaBzcVoQNxqcGesl3z0wFv Uh6daq/Wwe4bDpZZiRFh7N6u2yK4qZAE/qgKCchlP/utBoJh1SaV0VH/KdIfc20200F8 3EUw== X-Gm-Message-State: APt69E3lPmB9qqmByLGHehlilH8Vq8LA+e8t1dpWU9nVTv6mMHGbqceZ r16Dza0YBrxxyQJ9/d5o6StkWM9XynA= X-Received: by 2002:a63:12:: with SMTP id 18-v6mr10594894pga.121.1528599748167; Sat, 09 Jun 2018 20:02:28 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:33 -1000 Message-Id: <20180610030220.3777-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 001/108] linux-user: Remove DEBUG 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 is redundant with both -strace and actual tracing. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 10 ---------- 1 file changed, 10 deletions(-) -- 2.17.1 Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7b9ac3b408..c212149245 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -163,7 +163,6 @@ * (The one remaining unallocated bit is 0x1000 which used to be CLONE_PID.) */ -//#define DEBUG /* Define DEBUG_ERESTARTSYS to force every syscall to be restarted * once. This exercises the codepaths for restart. */ @@ -5777,9 +5776,6 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) ie++; } arg_type = ie->arg_type; -#if defined(DEBUG) - gemu_log("ioctl: cmd=0x%04lx (%s)\n", (long)cmd, ie->name); -#endif if (ie->do_ioctl) { return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); } else if (!ie->host_cmd) { @@ -7980,9 +7976,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } #endif -#ifdef DEBUG - gemu_log("syscall %d", num); -#endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); if(do_strace) print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); @@ -12772,9 +12765,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; } fail: -#ifdef DEBUG - gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); -#endif if(do_strace) print_syscall_ret(num, ret); trace_guest_user_syscall_ret(cpu, num, ret); From patchwork Sun Jun 10 03:00:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138079 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2575482lji; Sat, 9 Jun 2018 20:05:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK6DO3oDb1TFX495qVKxAR+2FtoTvIHz8oI5KjNn6iUdKIl5DeBVaIy+JhjJroeLKSV+OLn X-Received: by 2002:aed:3c27:: with SMTP id t36-v6mr11216112qte.398.1528599950820; Sat, 09 Jun 2018 20:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528599950; cv=none; d=google.com; s=arc-20160816; b=PwqshAPKwJVIqlm7J6sFc391xYTunE2bkrVWBxu+VkF+SjV7nlCu5R3T6aJt7ZbgOV AHvECvRoy/ynhv5pWMj6UtCGa7P06E7WD/F6stExIhRu9Vle1FNmjj/aEj0zhMKPWKMR ZGcrYB13gWIpdZd+HBpBoc+vjYMobyQs3L63jikrrzFMeKdZfdJHGILf7Nt8CqqOZ0xO QZR57/00FWUmghhDW1m02dt77bfVstah9gnWvd4TyrhLro3LaeXKRwfbibRcXt/Bx4X/ Hp+LRswnWRPhPjrmv1uJIdJCc4uApD3BDv6wBLwaHOdQ2b0rLkusw7JnfKuavFx2hMTq EiMw== 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:arc-authentication-results; bh=aZhX4crw3nZleV9x/cupabZl+g+1NR+rOFu8N2TUSEM=; b=kDX8Xd4818aEEmnK6zJFbdU0c/Fl2wvDqQaDvwwcOQhRmheyixXH6lKAmuiNCgaWcW yKStcpB1Fvjn2b0t8jnrcz1gGRR+t/TCBE2jg6j4hxQq+qT+7bO00aWTFdAHmHonwyXL 1k6DjW6mkqzXNEFRhiqY/WzWx4t1T/7oxh0j2dqGT3UpcaDQhWGk3A3z/GvWMHzjKK3P IbgGKjYD2Q2ZIr+hLaGyjn8gPKLUtSBp2yohMQrB6l7nac1AVpoXpuo7MJ5z5C0qidhO nnGcNO21b+1KSFxP5gj94bHkIL3ddmySjjc38DmkzsVqD8jz2pHmdIIV7Y4ajxISofT0 6TNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X0Hb1JZH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g4-v6si6429483qtp.109.2018.06.09.20.05.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X0Hb1JZH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfu-00046B-8F for patch@linaro.org; Sat, 09 Jun 2018 23:05:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcj-0001VV-1I for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqch-00036T-OP for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:33 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:41349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqch-00036D-IH for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:31 -0400 Received: by mail-pg0-x242.google.com with SMTP id l65-v6so8131785pgl.8 for ; Sat, 09 Jun 2018 20:02: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=aZhX4crw3nZleV9x/cupabZl+g+1NR+rOFu8N2TUSEM=; b=X0Hb1JZHWwpbzofYBnr71xsE2MXhAc78z923kvXObE4Iqd7LyapgLoqvxuI3NG1rY/ JyyLaCoq374TIF02RRu5mzoqtpd5Mpco1ShnfUPqTPqVYpkBIYD08R0rwcG4jYu82lqy RZwRNER/o4NEDTzfTj8SEVKy0aHqsBzR6ebIY= 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=aZhX4crw3nZleV9x/cupabZl+g+1NR+rOFu8N2TUSEM=; b=E4BY7YlbwvLlvDPI/mb96fzr65/oOLKPTRwwOXsf7ln6R+GsK6M4N+95ps3/GcY1n+ hCsRf8+ExobK/wpY4Em4SUHe2sajGjkSWPxAqrGZjyb2GRcYq6flKOS9BnDKf7vULUjD 2X3L2YxXa/qemr23MRjkYxKRk6Lg+gO1G4f5VTCIzyesLBBcS6C8YRwV8l8PzLdtHd9W vib0wlHXjyHdZJJ4BdWIOFVhDyPOYvpOGJ5NxNsuUIicgRaoIDhv5uzl6M7+En2e7j05 BjplMcl6AeMVqYLAT0aXampjqGxUNxbMbAbeMb/B5aYbGM+SuJmYniut/o22VVPR30t0 SzJg== X-Gm-Message-State: APt69E0F8AA36tdnaBVl0Wqx8ydvq07HU295BPOQFsFK4jd/L7cl1Ezf mD2TBICuuh2eDpHJk4LOUufgpi2d1Fc= X-Received: by 2002:a63:6742:: with SMTP id b63-v6mr10419554pgc.54.1528599750219; Sat, 09 Jun 2018 20:02:30 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:34 -1000 Message-Id: <20180610030220.3777-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 002/108] linux-user: Split out do_syscall1 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 was supposed to be a single point of return for do_syscall so that tracing works properly. However, there are a few bugs in that area. It is significantly simpler to simply split out an inner function to enforce this. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 77 +++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 29 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c212149245..ec3bc1cbe5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7947,13 +7947,15 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask, return 0; } -/* do_syscall() should always have a single exit point at the end so - that actions, such as logging of syscall results, can be performed. - All errnos that do_syscall() returns must be -TARGET_. */ -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) +/* This is an internal helper for do_syscall so that it is easier + * to have a single return point, so that actions, such as logging + * of syscall results, can be performed. + * All errnos that do_syscall() returns must be -TARGET_. + */ +static abi_long do_syscall1(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); abi_long ret; @@ -7961,25 +7963,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, struct statfs stfs; void *p; -#if defined(DEBUG_ERESTARTSYS) - /* Debug-only code for exercising the syscall-restart code paths - * in the per-architecture cpu main loops: restart every syscall - * the guest makes once before letting it through. - */ - { - static int flag; - - flag = !flag; - if (flag) { - return -TARGET_ERESTARTSYS; - } - } -#endif - - trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); - if(do_strace) - print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - switch(num) { case TARGET_NR_exit: /* In old applications this may be used to implement _exit(2). @@ -12765,11 +12748,47 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; } fail: - if(do_strace) - print_syscall_ret(num, ret); - trace_guest_user_syscall_ret(cpu, num, ret); return ret; efault: ret = -TARGET_EFAULT; goto fail; } + +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); + abi_long ret; + +#ifdef DEBUG_ERESTARTSYS + /* Debug-only code for exercising the syscall-restart code paths + * in the per-architecture cpu main loops: restart every syscall + * the guest makes once before letting it through. + */ + { + static bool flag; + flag = !flag; + if (flag) { + return -TARGET_ERESTARTSYS; + } + } +#endif + + 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); + } + + trace_guest_user_syscall_ret(cpu, num, ret); + return ret; +} From patchwork Sun Jun 10 03:00:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138086 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2578463lji; Sat, 9 Jun 2018 20:11:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKWuyfA2dYsE7XLHjCkFVVqiedmhObYEpMmyFt0jO0+BZ+sFiMXWmDUiiSCO2cavrq4/akg X-Received: by 2002:a37:b4c3:: with SMTP id d186-v6mr6451859qkf.400.1528600265863; Sat, 09 Jun 2018 20:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600265; cv=none; d=google.com; s=arc-20160816; b=IPOOWI52WAT0OkD+I7AbQSvYwibCjA427rW7oHb5R2UKwNBeJ038WcdIst4VWGlOuu sk9W25DmCPf6TbJrLx6a6dF2nJ4ehyILhh7je4DAGZ9mzARWTG93oLzHMMpGZx3ffY5U YMAgzcTo35aPyVObXCgnv4UT6hb9cbF1bLO+Z5NIbZS4DYMz7LcqkeA5Z93bp78XeQsC SRBG+VuA8oR5vu2T39liLIgIS/o0GfgzE0KCA3OVEMNvcjQcnnuRMcJh5jg3ot1eAdyu ThdRUbBMfsvbAwUzhkzgej1gY1gEZ5bGlum8+uWSgXM1zlO9FdnBKbjybq8J6QrUJ5sq fDPA== 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:arc-authentication-results; bh=dNF4TFbxYN4khbwvUV5Z7l0c4VdZ9bjG3YZvjPwkPYw=; b=P4WOTuCWuA1Vqvuq79BQhVZhErF05nqziEQWphO4+PNwWdrQhhHSL7LStjJS7UyCWZ tk0+o8PW+WYnVUuf8gof3vXIcN9vpCdGFMS8Et6L5WKp/DGt86yXknVzpYK6BXazER12 AGdafF/vmV/YVcgU0ilztF1dAGSZD3OQRWshtfMlcY3XzPpPedrfX+aty3OTI8j2aQcf uxiCtkbj42TOWOD6xj1Byf8w1zSGlHoGoWNoe3wN0wxeESgdZlJ/1Q72UhCT8diQg6w5 JYN4YWbRRBuXMYZZnBd1abUAqhdiRhfWunmmQQoIFF6Yfx31jgh1wAHSJJSFd7jHq4yq FVdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PxP/9CXY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n20-v6si1040069qtk.219.2018.06.09.20.11.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PxP/9CXY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqkz-0000vO-4J for patch@linaro.org; Sat, 09 Jun 2018 23:11:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcu-0001dF-Ht for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqcm-00038u-HY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:44 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:33739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqcm-00038b-2G for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:36 -0400 Received: by mail-pl0-x241.google.com with SMTP id n10-v6so10390178plp.0 for ; Sat, 09 Jun 2018 20:02: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=dNF4TFbxYN4khbwvUV5Z7l0c4VdZ9bjG3YZvjPwkPYw=; b=PxP/9CXYOirIwOxxNqpuOcbTZF3Xi/HgO0uganL8JZO4jpdb5FTUD+Irnqln8a4s9G VxbH0muqdbItTEHRxATGziRz6AqFfbdzhE90OlTEkFlgIWPX/V+B1j9NYsS05/s7w7TW pqo61VZ02E3fuKShwMSUV9Q60xVjPEEEQzw9Y= 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=dNF4TFbxYN4khbwvUV5Z7l0c4VdZ9bjG3YZvjPwkPYw=; b=hxVk5mM/ao/DYeV5DgVGdIxd7Iy7JeI+vW/QR09VpNSZZHK2qyFUAlpnjwQtDEaICF CFc/W5QsIwPmBoBXWqWm/cnrrZDn7v0928gl8Av20ZXVuycROzkStwuXd9zUBGTi1jzN rser3gQ7jwkXoHn22NGxxGjLw/UAu6MCD9cstWOYaWmj72g63y5szXyVJfMuFVi+TmLe DhqQUMD7+V4CFUD2Xmuay/kxObdYG8yAiS63iDfrZ+95hef3YX7DKh23UDCdPBq6rpGG OClKDhQbB/m7rADqGYdMa3lPunMXgmJea6QrDuAWvPqLAnDAJGmdACd4qxTafy3hDzm5 FL3A== X-Gm-Message-State: APt69E0qWMTN3mDodpw/fPFYamkcxZ6rmWhtvbGwRBlxtSfIYnpb2TOp 6F292gCMXQ7hi4RCYhbxputOZpfuozw= X-Received: by 2002:a17:902:1029:: with SMTP id b38-v6mr12786615pla.277.1528599753775; Sat, 09 Jun 2018 20:02:33 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:35 -1000 Message-Id: <20180610030220.3777-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 003/108] linux-user: Relax single exit from "break" 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" Transform outermost "break" to "return ret". If the immediately preceeding statement was an assignment to ret, return the value directly. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 970 +++++++++++++++++-------------------------- 1 file changed, 390 insertions(+), 580 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ec3bc1cbe5..efe882612b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7971,8 +7971,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, Do thread termination if we have more then one thread. */ if (block_signals()) { - ret = -TARGET_ERESTARTSYS; - break; + return -TARGET_ERESTARTSYS; } cpu_list_lock(); @@ -8004,12 +8003,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif gdb_exit(cpu_env, arg1); _exit(arg1); - ret = 0; /* avoid warning */ - break; + return 0; /* avoid warning */ case TARGET_NR_read: - if (arg3 == 0) - ret = 0; - else { + if (arg3 == 0) { + return 0; + } else { if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; ret = get_errno(safe_read(arg1, p, arg3)); @@ -8019,7 +8017,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user(p, arg2, ret); } - break; + return ret; case TARGET_NR_write: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; @@ -8035,7 +8033,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(safe_write(arg1, p, arg3)); } unlock_user(p, arg2, 0); - break; + return ret; + #ifdef TARGET_NR_open case TARGET_NR_open: if (!(p = lock_user_string(arg1))) @@ -8045,7 +8044,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg3)); fd_trans_unregister(ret); unlock_user(p, arg1, 0); - break; + return ret; #endif case TARGET_NR_openat: if (!(p = lock_user_string(arg2))) @@ -8055,29 +8054,27 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg4)); fd_trans_unregister(ret); unlock_user(p, arg2, 0); - break; + 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); - break; + 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); - break; + return ret; #endif case TARGET_NR_close: fd_trans_unregister(arg1); - ret = get_errno(close(arg1)); - break; + return get_errno(close(arg1)); + case TARGET_NR_brk: - ret = do_brk(arg1); - break; + return do_brk(arg1); #ifdef TARGET_NR_fork case TARGET_NR_fork: - ret = get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); - break; + return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); #endif #ifdef TARGET_NR_waitpid case TARGET_NR_waitpid: @@ -8088,7 +8085,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_s32(host_to_target_waitstatus(status), arg2)) goto efault; } - break; + return ret; #endif #ifdef TARGET_NR_waitid case TARGET_NR_waitid: @@ -8103,7 +8100,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg3, sizeof(target_siginfo_t)); } } - break; + return ret; #endif #ifdef TARGET_NR_creat /* not on alpha */ case TARGET_NR_creat: @@ -8112,7 +8109,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(creat(p, arg2)); fd_trans_unregister(ret); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_link case TARGET_NR_link: @@ -8127,7 +8124,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } - break; + return ret; #endif #if defined(TARGET_NR_linkat) case TARGET_NR_linkat: @@ -8144,7 +8141,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); unlock_user(p2, arg4, 0); } - break; + return ret; #endif #ifdef TARGET_NR_unlink case TARGET_NR_unlink: @@ -8152,7 +8149,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(unlink(p)); unlock_user(p, arg1, 0); - break; + return ret; #endif #if defined(TARGET_NR_unlinkat) case TARGET_NR_unlinkat: @@ -8160,7 +8157,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(unlinkat(arg1, p, arg3)); unlock_user(p, arg2, 0); - break; + return ret; #endif case TARGET_NR_execve: { @@ -8258,13 +8255,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, g_free(argp); g_free(envp); } - break; + return ret; case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chdir(p)); unlock_user(p, arg1, 0); - break; + return ret; #ifdef TARGET_NR_time case TARGET_NR_time: { @@ -8275,7 +8272,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_sal(host_time, arg1)) goto efault; } - break; + return ret; #endif #ifdef TARGET_NR_mknod case TARGET_NR_mknod: @@ -8283,7 +8280,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(mknod(p, arg2, arg3)); unlock_user(p, arg1, 0); - break; + return ret; #endif #if defined(TARGET_NR_mknodat) case TARGET_NR_mknodat: @@ -8291,7 +8288,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(mknodat(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); - break; + return ret; #endif #ifdef TARGET_NR_chmod case TARGET_NR_chmod: @@ -8299,7 +8296,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(chmod(p, arg2)); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_break case TARGET_NR_break: @@ -8310,19 +8307,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented; #endif case TARGET_NR_lseek: - ret = get_errno(lseek(arg1, arg2, arg3)); - break; + return get_errno(lseek(arg1, arg2, arg3)); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_getxpid: ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid(); - ret = get_errno(getpid()); - break; + return get_errno(getpid()); #endif #ifdef TARGET_NR_getpid case TARGET_NR_getpid: - ret = get_errno(getpid()); - break; + return get_errno(getpid()); #endif case TARGET_NR_mount: { @@ -8378,14 +8372,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p3, arg3, 0); } } - break; + return ret; #ifdef TARGET_NR_umount case TARGET_NR_umount: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(umount(p)); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_stime /* not on alpha */ case TARGET_NR_stime: @@ -8393,16 +8387,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, time_t host_time; if (get_user_sal(host_time, arg1)) goto efault; - ret = get_errno(stime(&host_time)); + return get_errno(stime(&host_time)); } - break; #endif case TARGET_NR_ptrace: goto unimplemented; #ifdef TARGET_NR_alarm /* not on alpha */ case TARGET_NR_alarm: - ret = alarm(arg1); - break; + return alarm(arg1); #endif #ifdef TARGET_NR_oldfstat case TARGET_NR_oldfstat: @@ -8413,8 +8405,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!block_signals()) { sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); } - ret = -TARGET_EINTR; - break; + return -TARGET_EINTR; #endif #ifdef TARGET_NR_utime case TARGET_NR_utime: @@ -8436,7 +8427,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(utime(p, host_tbuf)); unlock_user(p, arg1, 0); } - break; + return ret; #endif #ifdef TARGET_NR_utimes case TARGET_NR_utimes: @@ -8456,7 +8447,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(utimes(p, tvp)); unlock_user(p, arg1, 0); } - break; + return ret; #endif #if defined(TARGET_NR_futimesat) case TARGET_NR_futimesat: @@ -8476,7 +8467,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(futimesat(arg1, path(p), tvp)); unlock_user(p, arg2, 0); } - break; + return ret; #endif #ifdef TARGET_NR_stty case TARGET_NR_stty: @@ -8492,7 +8483,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(access(path(p), arg2)); unlock_user(p, arg1, 0); - break; + return ret; #endif #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) case TARGET_NR_faccessat: @@ -8500,12 +8491,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(faccessat(arg1, p, arg3, 0)); unlock_user(p, arg2, 0); - break; + return ret; #endif #ifdef TARGET_NR_nice /* not on alpha */ case TARGET_NR_nice: - ret = get_errno(nice(arg1)); - break; + return get_errno(nice(arg1)); #endif #ifdef TARGET_NR_ftime case TARGET_NR_ftime: @@ -8513,16 +8503,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_sync: sync(); - ret = 0; - break; + return 0; #if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) case TARGET_NR_syncfs: - ret = get_errno(syncfs(arg1)); - break; + return get_errno(syncfs(arg1)); #endif case TARGET_NR_kill: - ret = get_errno(safe_kill(arg1, target_to_host_signal(arg2))); - break; + return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); #ifdef TARGET_NR_rename case TARGET_NR_rename: { @@ -8536,7 +8523,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } - break; + return ret; #endif #if defined(TARGET_NR_renameat) case TARGET_NR_renameat: @@ -8551,7 +8538,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg4, 0); unlock_user(p, arg2, 0); } - break; + return ret; #endif #if defined(TARGET_NR_renameat2) case TARGET_NR_renameat2: @@ -8567,7 +8554,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg4, 0); unlock_user(p, arg2, 0); } - break; + return ret; #endif #ifdef TARGET_NR_mkdir case TARGET_NR_mkdir: @@ -8575,7 +8562,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(mkdir(p, arg2)); unlock_user(p, arg1, 0); - break; + return ret; #endif #if defined(TARGET_NR_mkdirat) case TARGET_NR_mkdirat: @@ -8583,7 +8570,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(mkdirat(arg1, p, arg3)); unlock_user(p, arg2, 0); - break; + return ret; #endif #ifdef TARGET_NR_rmdir case TARGET_NR_rmdir: @@ -8591,24 +8578,22 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(rmdir(p)); unlock_user(p, arg1, 0); - break; + return ret; #endif case TARGET_NR_dup: ret = get_errno(dup(arg1)); if (ret >= 0) { fd_trans_dup(arg1, ret); } - break; + return ret; #ifdef TARGET_NR_pipe case TARGET_NR_pipe: - ret = do_pipe(cpu_env, arg1, 0, 0); - break; + return do_pipe(cpu_env, arg1, 0, 0); #endif #ifdef TARGET_NR_pipe2 case TARGET_NR_pipe2: - ret = do_pipe(cpu_env, arg1, - target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); - break; + return do_pipe(cpu_env, arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); #endif case TARGET_NR_times: { @@ -8627,7 +8612,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) ret = host_to_target_clock_t(ret); } - break; + return ret; #ifdef TARGET_NR_prof case TARGET_NR_prof: goto unimplemented; @@ -8645,34 +8630,31 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(acct(path(p))); unlock_user(p, arg1, 0); } - break; + return ret; #ifdef TARGET_NR_umount2 case TARGET_NR_umount2: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(umount2(p, arg2)); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_lock case TARGET_NR_lock: goto unimplemented; #endif case TARGET_NR_ioctl: - ret = do_ioctl(arg1, arg2, arg3); - break; + return do_ioctl(arg1, arg2, arg3); #ifdef TARGET_NR_fcntl case TARGET_NR_fcntl: - ret = do_fcntl(arg1, arg2, arg3); - break; + return do_fcntl(arg1, arg2, arg3); #endif #ifdef TARGET_NR_mpx case TARGET_NR_mpx: goto unimplemented; #endif case TARGET_NR_setpgid: - ret = get_errno(setpgid(arg1, arg2)); - break; + return get_errno(setpgid(arg1, arg2)); #ifdef TARGET_NR_ulimit case TARGET_NR_ulimit: goto unimplemented; @@ -8682,14 +8664,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented; #endif case TARGET_NR_umask: - ret = get_errno(umask(arg1)); - break; + return get_errno(umask(arg1)); case TARGET_NR_chroot: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); - break; + return ret; #ifdef TARGET_NR_ustat case TARGET_NR_ustat: goto unimplemented; @@ -8700,7 +8681,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (ret >= 0) { fd_trans_dup(arg1, arg2); } - break; + return ret; #endif #if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3) case TARGET_NR_dup3: @@ -8715,22 +8696,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (ret >= 0) { fd_trans_dup(arg1, arg2); } - break; + return ret; } #endif #ifdef TARGET_NR_getppid /* not on alpha */ case TARGET_NR_getppid: - ret = get_errno(getppid()); - break; + return get_errno(getppid()); #endif #ifdef TARGET_NR_getpgrp case TARGET_NR_getpgrp: - ret = get_errno(getpgrp()); - break; + return get_errno(getpgrp()); #endif case TARGET_NR_setsid: - ret = get_errno(setsid()); - break; + return get_errno(setsid()); #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { @@ -8814,7 +8792,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #endif } - break; + return ret; #endif case TARGET_NR_rt_sigaction: { @@ -8831,8 +8809,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_sigaction act, oact, *pact = 0; if (arg4 != sizeof(target_sigset_t)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } if (arg2) { if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) @@ -8864,8 +8841,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_sigaction *oact; if (sigsetsize != sizeof(target_sigset_t)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } if (arg2) { if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { @@ -8892,7 +8868,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(oact, arg3, 1); #endif } - break; + return ret; #ifdef TARGET_NR_sgetmask /* not on alpha */ case TARGET_NR_sgetmask: { @@ -8904,7 +8880,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = target_set; } } - break; + return ret; #endif #ifdef TARGET_NR_ssetmask /* not on alpha */ case TARGET_NR_ssetmask: @@ -8918,7 +8894,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = target_set; } } - break; + return ret; #endif #ifdef TARGET_NR_sigprocmask case TARGET_NR_sigprocmask: @@ -8988,7 +8964,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #endif } - break; + return ret; #endif case TARGET_NR_rt_sigprocmask: { @@ -8996,8 +8972,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, sigset_t set, oldset, *set_ptr; if (arg4 != sizeof(target_sigset_t)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } if (arg2) { @@ -9032,7 +9007,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg3, sizeof(target_sigset_t)); } } - break; + return ret; #ifdef TARGET_NR_sigpending case TARGET_NR_sigpending: { @@ -9045,7 +9020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, sizeof(target_sigset_t)); } } - break; + return ret; #endif case TARGET_NR_rt_sigpending: { @@ -9057,8 +9032,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, * the old_sigset_t is smaller in size. */ if (arg2 > sizeof(target_sigset_t)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } ret = get_errno(sigpending(&set)); @@ -9069,7 +9043,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, sizeof(target_sigset_t)); } } - break; + return ret; #ifdef TARGET_NR_sigsuspend case TARGET_NR_sigsuspend: { @@ -9089,15 +9063,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ts->in_sigsuspend = 1; } } - break; + return ret; #endif case TARGET_NR_rt_sigsuspend: { TaskState *ts = cpu->opaque; if (arg2 != sizeof(target_sigset_t)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) goto efault; @@ -9109,7 +9082,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ts->in_sigsuspend = 1; } } - break; + return ret; case TARGET_NR_rt_sigtimedwait: { sigset_t set; @@ -9117,8 +9090,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, siginfo_t uinfo; if (arg4 != sizeof(target_sigset_t)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) @@ -9146,7 +9118,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = host_to_target_signal(ret); } } - break; + return ret; case TARGET_NR_rt_sigqueueinfo: { siginfo_t uinfo; @@ -9159,7 +9131,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg3, 0); ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); } - break; + return ret; case TARGET_NR_rt_tgsigqueueinfo: { siginfo_t uinfo; @@ -9172,7 +9144,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg4, 0); ret = get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo)); } - break; + return ret; #ifdef TARGET_NR_sigreturn case TARGET_NR_sigreturn: if (block_signals()) { @@ -9180,21 +9152,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { ret = do_sigreturn(cpu_env); } - break; + return ret; #endif case TARGET_NR_rt_sigreturn: if (block_signals()) { - ret = -TARGET_ERESTARTSYS; + return -TARGET_ERESTARTSYS; } else { - ret = do_rt_sigreturn(cpu_env); + return do_rt_sigreturn(cpu_env); } - break; case TARGET_NR_sethostname: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(sethostname(p, arg2)); unlock_user(p, arg1, 0); - break; + return ret; case TARGET_NR_setrlimit: { int resource = target_to_host_resource(arg1); @@ -9205,9 +9176,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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); - ret = get_errno(setrlimit(resource, &rlim)); + return get_errno(setrlimit(resource, &rlim)); } - break; case TARGET_NR_getrlimit: { int resource = target_to_host_resource(arg1); @@ -9223,7 +9193,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(target_rlim, arg2, 1); } } - break; + return ret; case TARGET_NR_getrusage: { struct rusage rusage; @@ -9232,7 +9202,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = host_to_target_rusage(arg2, &rusage); } } - break; + return ret; case TARGET_NR_gettimeofday: { struct timeval tv; @@ -9242,7 +9212,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; case TARGET_NR_settimeofday: { struct timeval tv, *ptv = NULL; @@ -9262,9 +9232,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ptz = &tz; } - ret = get_errno(settimeofday(ptv, ptz)); + return get_errno(settimeofday(ptv, ptz)); } - break; #if defined(TARGET_NR_select) case TARGET_NR_select: #if defined(TARGET_WANT_NI_OLD_SELECT) @@ -9277,7 +9246,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #else ret = do_select(arg1, arg2, arg3, arg4, arg5); #endif - break; + return ret; #endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: @@ -9381,7 +9350,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #ifdef TARGET_NR_symlink case TARGET_NR_symlink: @@ -9396,7 +9365,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg2, 0); unlock_user(p, arg1, 0); } - break; + return ret; #endif #if defined(TARGET_NR_symlinkat) case TARGET_NR_symlinkat: @@ -9411,7 +9380,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg3, 0); unlock_user(p, arg1, 0); } - break; + return ret; #endif #ifdef TARGET_NR_oldlstat case TARGET_NR_oldlstat: @@ -9447,7 +9416,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg2, ret); unlock_user(p, arg1, 0); } - break; + return ret; #endif #if defined(TARGET_NR_readlinkat) case TARGET_NR_readlinkat: @@ -9468,7 +9437,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg3, ret); unlock_user(p, arg2, 0); } - break; + return ret; #endif #ifdef TARGET_NR_uselib case TARGET_NR_uselib: @@ -9480,7 +9449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(swapon(p, arg2)); unlock_user(p, arg1, 0); - break; + return ret; #endif case TARGET_NR_reboot: if (arg3 == LINUX_REBOOT_CMD_RESTART2) { @@ -9494,7 +9463,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { ret = get_errno(reboot(arg1, arg2, arg3, NULL)); } - break; + return ret; #ifdef TARGET_NR_readdir case TARGET_NR_readdir: goto unimplemented; @@ -9527,22 +9496,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5, arg6)); #endif - break; + return ret; #endif #ifdef TARGET_NR_mmap2 case TARGET_NR_mmap2: #ifndef MMAP_SHIFT #define MMAP_SHIFT 12 #endif - ret = get_errno(target_mmap(arg1, arg2, arg3, - target_to_host_bitmask(arg4, mmap_flags_tbl), - arg5, - arg6 << MMAP_SHIFT)); - break; + 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: - ret = get_errno(target_munmap(arg1, arg2)); - break; + return get_errno(target_munmap(arg1, arg2)); case TARGET_NR_mprotect: { TaskState *ts = cpu->opaque; @@ -9555,58 +9522,49 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg1 = ts->info->stack_limit; } } - ret = get_errno(target_mprotect(arg1, arg2, arg3)); - break; + return get_errno(target_mprotect(arg1, arg2, arg3)); #ifdef TARGET_NR_mremap case TARGET_NR_mremap: - ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); - break; + 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: - ret = get_errno(msync(g2h(arg1), arg2, arg3)); - break; + return get_errno(msync(g2h(arg1), arg2, arg3)); #endif #ifdef TARGET_NR_mlock case TARGET_NR_mlock: - ret = get_errno(mlock(g2h(arg1), arg2)); - break; + return get_errno(mlock(g2h(arg1), arg2)); #endif #ifdef TARGET_NR_munlock case TARGET_NR_munlock: - ret = get_errno(munlock(g2h(arg1), arg2)); - break; + return get_errno(munlock(g2h(arg1), arg2)); #endif #ifdef TARGET_NR_mlockall case TARGET_NR_mlockall: - ret = get_errno(mlockall(target_to_host_mlockall_arg(arg1))); - break; + return get_errno(mlockall(target_to_host_mlockall_arg(arg1))); #endif #ifdef TARGET_NR_munlockall case TARGET_NR_munlockall: - ret = get_errno(munlockall()); - break; + return get_errno(munlockall()); #endif case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(truncate(p, arg2)); unlock_user(p, arg1, 0); - break; + return ret; case TARGET_NR_ftruncate: - ret = get_errno(ftruncate(arg1, arg2)); - break; + return get_errno(ftruncate(arg1, arg2)); case TARGET_NR_fchmod: - ret = get_errno(fchmod(arg1, arg2)); - break; + return get_errno(fchmod(arg1, arg2)); #if defined(TARGET_NR_fchmodat) case TARGET_NR_fchmodat: if (!(p = lock_user_string(arg2))) goto efault; ret = get_errno(fchmodat(arg1, p, arg3, 0)); unlock_user(p, arg2, 0); - break; + return ret; #endif case TARGET_NR_getpriority: /* Note that negative values are valid for getpriority, so we must @@ -9614,8 +9572,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, errno = 0; ret = getpriority(arg1, arg2); if (ret == -1 && errno != 0) { - ret = -host_to_target_errno(errno); - break; + return -host_to_target_errno(errno); } #ifdef TARGET_ALPHA /* Return value is the unbiased priority. Signal no error. */ @@ -9624,10 +9581,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* Return value is a biased priority to avoid negative numbers. */ ret = 20 - ret; #endif - break; + return ret; case TARGET_NR_setpriority: - ret = get_errno(setpriority(arg1, arg2, arg3)); - break; + return get_errno(setpriority(arg1, arg2, arg3)); #ifdef TARGET_NR_profil case TARGET_NR_profil: goto unimplemented; @@ -9662,7 +9618,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg2, 1); } - break; + return ret; case TARGET_NR_fstatfs: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs; @@ -9692,7 +9648,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg3, 1); } - break; + return ret; case TARGET_NR_fstatfs64: ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; @@ -9703,91 +9659,73 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: - ret = do_socketcall(arg1, arg2); - break; + return do_socketcall(arg1, arg2); #endif #ifdef TARGET_NR_accept case TARGET_NR_accept: - ret = do_accept4(arg1, arg2, arg3, 0); - break; + return do_accept4(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_accept4 case TARGET_NR_accept4: - ret = do_accept4(arg1, arg2, arg3, arg4); - break; + return do_accept4(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: - ret = do_bind(arg1, arg2, arg3); - break; + return do_bind(arg1, arg2, arg3); #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: - ret = do_connect(arg1, arg2, arg3); - break; + return do_connect(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: - ret = do_getpeername(arg1, arg2, arg3); - break; + return do_getpeername(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: - ret = do_getsockname(arg1, arg2, arg3); - break; + return do_getsockname(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: - ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5); - break; + return do_getsockopt(arg1, arg2, arg3, arg4, arg5); #endif #ifdef TARGET_NR_listen case TARGET_NR_listen: - ret = get_errno(listen(arg1, arg2)); - break; + return get_errno(listen(arg1, arg2)); #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: - ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); - break; + return do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); #endif #ifdef TARGET_NR_recvfrom case TARGET_NR_recvfrom: - ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); - break; + return do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_recvmsg case TARGET_NR_recvmsg: - ret = do_sendrecvmsg(arg1, arg2, arg3, 0); - break; + return do_sendrecvmsg(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_send case TARGET_NR_send: - ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0); - break; + return do_sendto(arg1, arg2, arg3, arg4, 0, 0); #endif #ifdef TARGET_NR_sendmsg case TARGET_NR_sendmsg: - ret = do_sendrecvmsg(arg1, arg2, arg3, 1); - break; + return do_sendrecvmsg(arg1, arg2, arg3, 1); #endif #ifdef TARGET_NR_sendmmsg case TARGET_NR_sendmmsg: - ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); - break; + return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); case TARGET_NR_recvmmsg: - ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); - break; + return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); #endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: - ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); - break; + return do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: - ret = get_errno(shutdown(arg1, arg2)); - break; + return get_errno(shutdown(arg1, arg2)); #endif #if defined(TARGET_NR_getrandom) && defined(__NR_getrandom) case TARGET_NR_getrandom: @@ -9797,22 +9735,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } ret = get_errno(getrandom(p, arg2, arg3)); unlock_user(p, arg1, ret); - break; + return ret; #endif #ifdef TARGET_NR_socket case TARGET_NR_socket: - ret = do_socket(arg1, arg2, arg3); - break; + return do_socket(arg1, arg2, arg3); #endif #ifdef TARGET_NR_socketpair case TARGET_NR_socketpair: - ret = do_socketpair(arg1, arg2, arg3, arg4); - break; + return do_socketpair(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_setsockopt case TARGET_NR_setsockopt: - ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); - break; + return do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); #endif #if defined(TARGET_NR_syslog) case TARGET_NR_syslog: @@ -9828,10 +9763,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: /* Set messages level */ case TARGET_SYSLOG_ACTION_SIZE_UNREAD: /* Number of chars */ case TARGET_SYSLOG_ACTION_SIZE_BUFFER: /* Size of the buffer */ - { - ret = get_errno(sys_syslog((int)arg1, NULL, (int)arg3)); - } - break; + return get_errno(sys_syslog((int)arg1, NULL, (int)arg3)); case TARGET_SYSLOG_ACTION_READ: /* Read from log */ case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */ case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */ @@ -9840,9 +9772,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (len < 0) { goto fail; } - ret = 0; if (len == 0) { - break; + return 0; } p = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!p) { @@ -9852,10 +9783,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); unlock_user(p, arg2, arg3); } - break; + return ret; default: - ret = -EINVAL; - break; + return -TARGET_EINVAL; } } break; @@ -9882,7 +9812,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; case TARGET_NR_getitimer: { struct itimerval value; @@ -9896,7 +9826,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #ifdef TARGET_NR_stat case TARGET_NR_stat: if (!(p = lock_user_string(arg1))) @@ -9941,7 +9871,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(target_st, arg2, 1); } } - break; + return ret; #ifdef TARGET_NR_olduname case TARGET_NR_olduname: goto unimplemented; @@ -9951,17 +9881,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented; #endif case TARGET_NR_vhangup: - ret = get_errno(vhangup()); - break; + return get_errno(vhangup()); #ifdef TARGET_NR_idle case TARGET_NR_idle: goto unimplemented; #endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: - ret = do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, - arg6, arg7, arg8, 0); - break; + return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, + arg6, arg7, arg8, 0); #endif case TARGET_NR_wait4: { @@ -9989,14 +9917,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } - break; + return ret; #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(swapoff(p)); unlock_user(p, arg1, 0); - break; + return ret; #endif case TARGET_NR_sysinfo: { @@ -10024,70 +9952,57 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(target_value, arg1, 1); } } - break; + return ret; #ifdef TARGET_NR_ipc case TARGET_NR_ipc: - ret = do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); - break; + return do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_semget case TARGET_NR_semget: - ret = get_errno(semget(arg1, arg2, arg3)); - break; + return get_errno(semget(arg1, arg2, arg3)); #endif #ifdef TARGET_NR_semop case TARGET_NR_semop: - ret = do_semop(arg1, arg2, arg3); - break; + return do_semop(arg1, arg2, arg3); #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: - ret = do_semctl(arg1, arg2, arg3, arg4); - break; + return do_semctl(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_msgctl case TARGET_NR_msgctl: - ret = do_msgctl(arg1, arg2, arg3); - break; + return do_msgctl(arg1, arg2, arg3); #endif #ifdef TARGET_NR_msgget case TARGET_NR_msgget: - ret = get_errno(msgget(arg1, arg2)); - break; + return get_errno(msgget(arg1, arg2)); #endif #ifdef TARGET_NR_msgrcv case TARGET_NR_msgrcv: - ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5); - break; + return do_msgrcv(arg1, arg2, arg3, arg4, arg5); #endif #ifdef TARGET_NR_msgsnd case TARGET_NR_msgsnd: - ret = do_msgsnd(arg1, arg2, arg3, arg4); - break; + return do_msgsnd(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_shmget case TARGET_NR_shmget: - ret = get_errno(shmget(arg1, arg2, arg3)); - break; + return get_errno(shmget(arg1, arg2, arg3)); #endif #ifdef TARGET_NR_shmctl case TARGET_NR_shmctl: - ret = do_shmctl(arg1, arg2, arg3); - break; + return do_shmctl(arg1, arg2, arg3); #endif #ifdef TARGET_NR_shmat case TARGET_NR_shmat: - ret = do_shmat(cpu_env, arg1, arg2, arg3); - break; + return do_shmat(cpu_env, arg1, arg2, arg3); #endif #ifdef TARGET_NR_shmdt case TARGET_NR_shmdt: - ret = do_shmdt(arg1); - break; + return do_shmdt(arg1); #endif case TARGET_NR_fsync: - ret = get_errno(fsync(arg1)); - break; + 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 @@ -10104,7 +10019,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #else ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); #endif - break; + return ret; #ifdef __NR_exit_group /* new thread calls */ case TARGET_NR_exit_group: @@ -10112,15 +10027,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, _mcleanup(); #endif gdb_exit(cpu_env, arg1); - ret = get_errno(exit_group(arg1)); - break; + return get_errno(exit_group(arg1)); #endif case TARGET_NR_setdomainname: if (!(p = lock_user_string(arg1))) goto efault; ret = get_errno(setdomainname(p, arg2)); unlock_user(p, arg1, 0); - break; + return ret; case TARGET_NR_uname: /* no need to transcode because we use the linux syscall */ { @@ -10142,17 +10056,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user_struct(buf, arg1, 1); } - break; + return ret; #ifdef TARGET_I386 case TARGET_NR_modify_ldt: - ret = do_modify_ldt(cpu_env, arg1, arg2, arg3); - break; + return do_modify_ldt(cpu_env, arg1, arg2, arg3); #if !defined(TARGET_X86_64) case TARGET_NR_vm86old: goto unimplemented; case TARGET_NR_vm86: - ret = do_vm86(cpu_env, arg1, arg2); - break; + return do_vm86(cpu_env, arg1, arg2); #endif #endif case TARGET_NR_adjtimex: @@ -10169,7 +10081,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } - break; + return ret; #if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME) case TARGET_NR_clock_adjtime: { @@ -10185,7 +10097,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } - break; + return ret; #endif #ifdef TARGET_NR_create_module case TARGET_NR_create_module: @@ -10199,11 +10111,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_quotactl: goto unimplemented; case TARGET_NR_getpgid: - ret = get_errno(getpgid(arg1)); - break; + return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: - ret = get_errno(fchdir(arg1)); - break; + return get_errno(fchdir(arg1)); #ifdef TARGET_NR_bdflush /* not on x86_64 */ case TARGET_NR_bdflush: goto unimplemented; @@ -10213,8 +10123,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented; #endif case TARGET_NR_personality: - ret = get_errno(personality(arg1)); - break; + return get_errno(personality(arg1)); #ifdef TARGET_NR_afs_syscall case TARGET_NR_afs_syscall: goto unimplemented; @@ -10237,7 +10146,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #ifdef TARGET_NR_getdents case TARGET_NR_getdents: @@ -10369,7 +10278,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(dirp, arg2, ret); } #endif - break; + return ret; #endif /* TARGET_NR_getdents */ #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) case TARGET_NR_getdents64: @@ -10397,12 +10306,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user(dirp, arg2, ret); } - break; + return ret; #endif /* TARGET_NR_getdents64 */ #if defined(TARGET_NR__newselect) case TARGET_NR__newselect: - ret = do_select(arg1, arg2, arg3, arg4, arg5); - break; + return do_select(arg1, arg2, arg3, arg4, arg5); #endif #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) # ifdef TARGET_NR_poll @@ -10421,8 +10329,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_pfd = NULL; if (nfds) { if (nfds > (INT_MAX / sizeof(struct target_pollfd))) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } target_pfd = lock_user(VERIFY_WRITE, arg1, @@ -10458,8 +10365,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg4) { if (arg5 != sizeof(target_sigset_t)) { unlock_user(target_pfd, arg1, 0); - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1); @@ -10481,7 +10387,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg4) { unlock_user(target_set, arg4, 0); } - break; + return ret; } # endif # ifdef TARGET_NR_poll @@ -10498,8 +10404,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* -ve poll() timeout means "infinite" */ pts = NULL; } - ret = get_errno(safe_ppoll(pfd, nfds, pts, NULL, 0)); - break; + return get_errno(safe_ppoll(pfd, nfds, pts, NULL, 0)); } # endif default: @@ -10513,13 +10418,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); } - break; + return ret; #endif case TARGET_NR_flock: /* NOTE: the flock constant seems to be the same for every Linux platform */ - ret = get_errno(safe_flock(arg1, arg2)); - break; + return get_errno(safe_flock(arg1, arg2)); case TARGET_NR_readv: { struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); @@ -10530,7 +10434,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } - break; + return ret; case TARGET_NR_writev: { struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); @@ -10541,7 +10445,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } - break; + return ret; #if defined(TARGET_NR_preadv) case TARGET_NR_preadv: { @@ -10556,7 +10460,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } - break; + return ret; #endif #if defined(TARGET_NR_pwritev) case TARGET_NR_pwritev: @@ -10572,22 +10476,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } - break; + return ret; #endif case TARGET_NR_getsid: - ret = get_errno(getsid(arg1)); - break; + return get_errno(getsid(arg1)); #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */ case TARGET_NR_fdatasync: - ret = get_errno(fdatasync(arg1)); - break; + return get_errno(fdatasync(arg1)); #endif #ifdef TARGET_NR__sysctl case TARGET_NR__sysctl: /* We don't implement this, but ENOTDIR is always a safe return value. */ - ret = -TARGET_ENOTDIR; - break; + return -TARGET_ENOTDIR; #endif case TARGET_NR_sched_getaffinity: { @@ -10599,8 +10500,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, * care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof(abi_ulong) - 1)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); @@ -10619,8 +10519,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, */ int numcpus = sysconf(_SC_NPROCESSORS_CONF); if (numcpus > arg2 * 8) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } ret = arg2; } @@ -10630,7 +10529,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } - break; + return ret; case TARGET_NR_sched_setaffinity: { unsigned int mask_size; @@ -10641,20 +10540,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, * care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof(abi_ulong) - 1)) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); mask = alloca(mask_size); ret = target_to_host_cpu_mask(mask, mask_size, arg3, arg2); if (ret) { - break; + return ret; } - ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask)); + return get_errno(sys_sched_setaffinity(arg1, mask_size, mask)); } - break; case TARGET_NR_getcpu: { unsigned cpu, node; @@ -10671,7 +10568,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; case TARGET_NR_sched_setparam: { struct sched_param *target_schp; @@ -10684,9 +10581,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg2, 0); - ret = get_errno(sched_setparam(arg1, &schp)); + return get_errno(sched_setparam(arg1, &schp)); } - break; case TARGET_NR_sched_getparam: { struct sched_param *target_schp; @@ -10703,7 +10599,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(target_schp, arg2, 1); } } - break; + return ret; case TARGET_NR_sched_setscheduler: { struct sched_param *target_schp; @@ -10715,21 +10611,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg3, 0); - ret = get_errno(sched_setscheduler(arg1, arg2, &schp)); + return get_errno(sched_setscheduler(arg1, arg2, &schp)); } - break; case TARGET_NR_sched_getscheduler: - ret = get_errno(sched_getscheduler(arg1)); - break; + return get_errno(sched_getscheduler(arg1)); case TARGET_NR_sched_yield: - ret = get_errno(sched_yield()); - break; + return get_errno(sched_yield()); case TARGET_NR_sched_get_priority_max: - ret = get_errno(sched_get_priority_max(arg1)); - break; + return get_errno(sched_get_priority_max(arg1)); case TARGET_NR_sched_get_priority_min: - ret = get_errno(sched_get_priority_min(arg1)); - break; + return get_errno(sched_get_priority_min(arg1)); case TARGET_NR_sched_rr_get_interval: { struct timespec ts; @@ -10738,7 +10629,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = host_to_target_timespec(arg2, &ts); } } - break; + return ret; case TARGET_NR_nanosleep: { struct timespec req, rem; @@ -10748,7 +10639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, host_to_target_timespec(arg2, &rem); } } - break; + return ret; #ifdef TARGET_NR_query_module case TARGET_NR_query_module: goto unimplemented; @@ -10767,7 +10658,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_ual(deathsig, arg2)) { goto efault; } - break; + return ret; } #ifdef PR_GET_NAME case PR_GET_NAME: @@ -10779,7 +10670,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 16); - break; + return ret; } case PR_SET_NAME: { @@ -10790,7 +10681,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); unlock_user(name, arg2, 0); - break; + return ret; } #endif #ifdef TARGET_AARCH64 @@ -10811,32 +10702,29 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, env->vfp.zcr_el[1] = vq - 1; ret = vq * 16; } - break; + return ret; case TARGET_PR_SVE_GET_VL: ret = -TARGET_EINVAL; if (arm_feature(cpu_env, ARM_FEATURE_SVE)) { CPUARMState *env = cpu_env; ret = ((env->vfp.zcr_el[1] & 0xf) + 1) * 16; } - break; + return ret; #endif /* AARCH64 */ case PR_GET_SECCOMP: case PR_SET_SECCOMP: /* Disable seccomp to prevent the target disabling syscalls we * need. */ - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; default: /* Most prctl options have no pointer arguments */ - ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); - break; + return get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); } break; #ifdef TARGET_NR_arch_prctl case TARGET_NR_arch_prctl: #if defined(TARGET_I386) && !defined(TARGET_ABI32) - ret = do_arch_prctl(cpu_env, arg1, arg2); - break; + return do_arch_prctl(cpu_env, arg1, arg2); #else goto unimplemented; #endif @@ -10851,7 +10739,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, ret); - break; + return ret; case TARGET_NR_pwrite64: if (regpairs_aligned(cpu_env, num)) { arg4 = arg5; @@ -10861,14 +10749,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, 0); - break; + return ret; #endif case TARGET_NR_getcwd: if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0))) goto efault; ret = get_errno(sys_getcwd1(p, arg2)); unlock_user(p, arg1, ret); - break; + return ret; case TARGET_NR_capget: case TARGET_NR_capset: { @@ -10937,11 +10825,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(target_data, arg2, 0); } } - break; + return ret; } case TARGET_NR_sigaltstack: - ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env)); - break; + return do_sigaltstack(arg1, arg2, + get_sp_from_cpustate((CPUArchState *)cpu_env)); #ifdef CONFIG_SENDFILE case TARGET_NR_sendfile: @@ -10951,7 +10839,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg3) { ret = get_user_sal(off, arg3); if (is_error(ret)) { - break; + return ret; } offp = &off; } @@ -10962,7 +10850,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = ret2; } } - break; + return ret; } #ifdef TARGET_NR_sendfile64 case TARGET_NR_sendfile64: @@ -10972,7 +10860,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg3) { ret = get_user_s64(off, arg3); if (is_error(ret)) { - break; + return ret; } offp = &off; } @@ -10983,7 +10871,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = ret2; } } - break; + return ret; } #endif #else @@ -11004,10 +10892,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: - ret = get_errno(do_fork(cpu_env, - CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD, - 0, 0, 0, 0)); - break; + 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: @@ -11023,7 +10910,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); unlock_user_struct(target_rlim, arg2, 1); } - break; + return ret; } #endif #ifdef TARGET_NR_truncate64 @@ -11032,12 +10919,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_ftruncate64 case TARGET_NR_ftruncate64: - ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); - break; + return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: @@ -11047,7 +10933,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); - break; + return ret; #endif #ifdef TARGET_NR_lstat64 case TARGET_NR_lstat64: @@ -11057,14 +10943,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); - break; + return ret; #endif #ifdef TARGET_NR_fstat64 case TARGET_NR_fstat64: ret = get_errno(fstat(arg1, &st)); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg2, &st); - break; + return ret; #endif #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) #ifdef TARGET_NR_fstatat64 @@ -11078,7 +10964,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(fstatat(arg1, path(p), &st, arg4)); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg3, &st); - break; + return ret; #endif #ifdef TARGET_NR_lchown case TARGET_NR_lchown: @@ -11086,34 +10972,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_getuid case TARGET_NR_getuid: - ret = get_errno(high2lowuid(getuid())); - break; + return get_errno(high2lowuid(getuid())); #endif #ifdef TARGET_NR_getgid case TARGET_NR_getgid: - ret = get_errno(high2lowgid(getgid())); - break; + return get_errno(high2lowgid(getgid())); #endif #ifdef TARGET_NR_geteuid case TARGET_NR_geteuid: - ret = get_errno(high2lowuid(geteuid())); - break; + return get_errno(high2lowuid(geteuid())); #endif #ifdef TARGET_NR_getegid case TARGET_NR_getegid: - ret = get_errno(high2lowgid(getegid())); - break; + return get_errno(high2lowgid(getegid())); #endif case TARGET_NR_setreuid: - ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); - break; + return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); case TARGET_NR_setregid: - ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); - break; + return get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); case TARGET_NR_getgroups: { int gidsetsize = arg1; @@ -11124,7 +11004,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize == 0) - break; + return ret; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * sizeof(target_id), 0); if (!target_grouplist) @@ -11134,7 +11014,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id)); } } - break; + return ret; case TARGET_NR_setgroups: { int gidsetsize = arg1; @@ -11153,12 +11033,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user(target_grouplist, arg2, 0); } - ret = get_errno(setgroups(gidsetsize, grouplist)); + return get_errno(setgroups(gidsetsize, grouplist)); } - break; case TARGET_NR_fchown: - ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); - break; + return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); #if defined(TARGET_NR_fchownat) case TARGET_NR_fchownat: if (!(p = lock_user_string(arg2))) @@ -11166,14 +11044,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5)); unlock_user(p, arg2, 0); - break; + return ret; #endif #ifdef TARGET_NR_setresuid case TARGET_NR_setresuid: - ret = get_errno(sys_setresuid(low2highuid(arg1), - low2highuid(arg2), - low2highuid(arg3))); - break; + return get_errno(sys_setresuid(low2highuid(arg1), + low2highuid(arg2), + low2highuid(arg3))); #endif #ifdef TARGET_NR_getresuid case TARGET_NR_getresuid: @@ -11187,14 +11064,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #ifdef TARGET_NR_getresgid case TARGET_NR_setresgid: - ret = get_errno(sys_setresgid(low2highgid(arg1), - low2highgid(arg2), - low2highgid(arg3))); - break; + return get_errno(sys_setresgid(low2highgid(arg1), + low2highgid(arg2), + low2highgid(arg3))); #endif #ifdef TARGET_NR_getresgid case TARGET_NR_getresgid: @@ -11208,7 +11084,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #ifdef TARGET_NR_chown case TARGET_NR_chown: @@ -11216,20 +11092,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); - break; + return ret; #endif case TARGET_NR_setuid: - ret = get_errno(sys_setuid(low2highuid(arg1))); - break; + return get_errno(sys_setuid(low2highuid(arg1))); case TARGET_NR_setgid: - ret = get_errno(sys_setgid(low2highgid(arg1))); - break; + return get_errno(sys_setgid(low2highgid(arg1))); case TARGET_NR_setfsuid: - ret = get_errno(setfsuid(arg1)); - break; + return get_errno(setfsuid(arg1)); case TARGET_NR_setfsgid: - ret = get_errno(setfsgid(arg1)); - break; + return get_errno(setfsgid(arg1)); #ifdef TARGET_NR_lchown32 case TARGET_NR_lchown32: @@ -11237,12 +11109,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(lchown(p, arg2, arg3)); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_getuid32 case TARGET_NR_getuid32: - ret = get_errno(getuid()); - break; + return get_errno(getuid()); #endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) @@ -11253,8 +11124,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, euid=geteuid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid; } - ret = get_errno(getuid()); - break; + return get_errno(getuid()); #endif #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) /* Alpha specific */ @@ -11264,8 +11134,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, egid=getegid(); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid; } - ret = get_errno(getgid()); - break; + return get_errno(getgid()); #endif #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) /* Alpha specific */ @@ -11303,7 +11172,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, -- Grabs a copy of the HWRPB; surely not used. */ } - break; + return ret; #endif #if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) /* Alpha specific */ @@ -11394,7 +11263,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, -- Not implemented in linux kernel */ } - break; + return ret; #endif #ifdef TARGET_NR_osf_sigprocmask /* Alpha specific. */ @@ -11426,33 +11295,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = mask; } } - break; + return ret; #endif #ifdef TARGET_NR_getgid32 case TARGET_NR_getgid32: - ret = get_errno(getgid()); - break; + return get_errno(getgid()); #endif #ifdef TARGET_NR_geteuid32 case TARGET_NR_geteuid32: - ret = get_errno(geteuid()); - break; + return get_errno(geteuid()); #endif #ifdef TARGET_NR_getegid32 case TARGET_NR_getegid32: - ret = get_errno(getegid()); - break; + return get_errno(getegid()); #endif #ifdef TARGET_NR_setreuid32 case TARGET_NR_setreuid32: - ret = get_errno(setreuid(arg1, arg2)); - break; + return get_errno(setreuid(arg1, arg2)); #endif #ifdef TARGET_NR_setregid32 case TARGET_NR_setregid32: - ret = get_errno(setregid(arg1, arg2)); - break; + return get_errno(setregid(arg1, arg2)); #endif #ifdef TARGET_NR_getgroups32 case TARGET_NR_getgroups32: @@ -11465,7 +11329,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist = alloca(gidsetsize * sizeof(gid_t)); ret = get_errno(getgroups(gidsetsize, grouplist)); if (gidsetsize == 0) - break; + return ret; if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); if (!target_grouplist) { @@ -11477,7 +11341,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(target_grouplist, arg2, gidsetsize * 4); } } - break; + return ret; #endif #ifdef TARGET_NR_setgroups32 case TARGET_NR_setgroups32: @@ -11496,19 +11360,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, for(i = 0;i < gidsetsize; i++) grouplist[i] = tswap32(target_grouplist[i]); unlock_user(target_grouplist, arg2, 0); - ret = get_errno(setgroups(gidsetsize, grouplist)); + return get_errno(setgroups(gidsetsize, grouplist)); } - break; #endif #ifdef TARGET_NR_fchown32 case TARGET_NR_fchown32: - ret = get_errno(fchown(arg1, arg2, arg3)); - break; + return get_errno(fchown(arg1, arg2, arg3)); #endif #ifdef TARGET_NR_setresuid32 case TARGET_NR_setresuid32: - ret = get_errno(sys_setresuid(arg1, arg2, arg3)); - break; + return get_errno(sys_setresuid(arg1, arg2, arg3)); #endif #ifdef TARGET_NR_getresuid32 case TARGET_NR_getresuid32: @@ -11522,12 +11383,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #ifdef TARGET_NR_setresgid32 case TARGET_NR_setresgid32: - ret = get_errno(sys_setresgid(arg1, arg2, arg3)); - break; + return get_errno(sys_setresgid(arg1, arg2, arg3)); #endif #ifdef TARGET_NR_getresgid32 case TARGET_NR_getresgid32: @@ -11541,7 +11401,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #ifdef TARGET_NR_chown32 case TARGET_NR_chown32: @@ -11549,27 +11409,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(chown(p, arg2, arg3)); unlock_user(p, arg1, 0); - break; + return ret; #endif #ifdef TARGET_NR_setuid32 case TARGET_NR_setuid32: - ret = get_errno(sys_setuid(arg1)); - break; + return get_errno(sys_setuid(arg1)); #endif #ifdef TARGET_NR_setgid32 case TARGET_NR_setgid32: - ret = get_errno(sys_setgid(arg1)); - break; + return get_errno(sys_setgid(arg1)); #endif #ifdef TARGET_NR_setfsuid32 case TARGET_NR_setfsuid32: - ret = get_errno(setfsuid(arg1)); - break; + return get_errno(setfsuid(arg1)); #endif #ifdef TARGET_NR_setfsgid32 case TARGET_NR_setfsgid32: - ret = get_errno(setfsgid(arg1)); - break; + return get_errno(setfsgid(arg1)); #endif case TARGET_NR_pivot_root: @@ -11593,7 +11449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, mincore_fail: unlock_user(a, arg1, 0); } - break; + return ret; #endif #ifdef TARGET_NR_arm_fadvise64_64 case TARGET_NR_arm_fadvise64_64: @@ -11605,8 +11461,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, */ ret = posix_fadvise(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg2); - ret = -host_to_target_errno(ret); - break; + return -host_to_target_errno(ret); #endif #if TARGET_ABI_BITS == 32 @@ -11632,11 +11487,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg6 = arg7; } #endif - ret = -host_to_target_errno(posix_fadvise(arg1, - target_offset64(arg2, arg3), - target_offset64(arg4, arg5), - arg6)); - break; + ret = posix_fadvise(arg1, target_offset64(arg2, arg3), + target_offset64(arg4, arg5), arg6); + return -host_to_target_errno(ret); #endif #ifdef TARGET_NR_fadvise64 @@ -11649,10 +11502,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg4 = arg5; arg5 = arg6; } - ret = -host_to_target_errno(posix_fadvise(arg1, - target_offset64(arg2, arg3), - arg4, arg5)); - break; + ret = posix_fadvise(arg1, target_offset64(arg2, arg3), arg4, arg5); + return -host_to_target_errno(ret); #endif #else /* not a 32-bit ABI */ @@ -11672,8 +11523,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, default: break; } #endif - ret = -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4)); - break; + return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4)); #endif #endif /* end of 64-bit ABI fadvise handling */ @@ -11683,8 +11533,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, turns private file-backed mappings into anonymous mappings. This will break MADV_DONTNEED. This is a hint, so ignoring and returning success is ok. */ - ret = get_errno(0); - break; + return 0; #endif #if TARGET_ABI_BITS == 32 case TARGET_NR_fcntl64: @@ -11703,8 +11552,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, cmd = target_to_host_fcntl_cmd(arg2); if (cmd == -TARGET_EINVAL) { - ret = cmd; - break; + return cmd; } switch(arg2) { @@ -11731,14 +11579,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = do_fcntl(arg1, arg2, arg3); break; } - break; + return ret; } #endif #ifdef TARGET_NR_cacheflush case TARGET_NR_cacheflush: /* self-modifying code is handled automatically, so nothing needed */ - ret = 0; - break; + return 0; #endif #ifdef TARGET_NR_security case TARGET_NR_security: @@ -11746,12 +11593,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: - ret = TARGET_PAGE_SIZE; - break; + return TARGET_PAGE_SIZE; #endif case TARGET_NR_gettid: - ret = get_errno(gettid()); - break; + return get_errno(gettid()); #ifdef TARGET_NR_readahead case TARGET_NR_readahead: #if TARGET_ABI_BITS == 32 @@ -11764,7 +11609,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #else ret = get_errno(readahead(arg1, arg2, arg3)); #endif - break; + return ret; #endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr @@ -11775,8 +11620,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { - ret = -TARGET_EFAULT; - break; + return -TARGET_EFAULT; } } p = lock_user_string(arg1); @@ -11791,7 +11635,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user(p, arg1, 0); unlock_user(b, arg2, arg3); - break; + return ret; } case TARGET_NR_flistxattr: { @@ -11799,13 +11643,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg2) { b = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!b) { - ret = -TARGET_EFAULT; - break; + return -TARGET_EFAULT; } } ret = get_errno(flistxattr(arg1, b, arg3)); unlock_user(b, arg2, arg3); - break; + return ret; } case TARGET_NR_setxattr: case TARGET_NR_lsetxattr: @@ -11814,8 +11657,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { - ret = -TARGET_EFAULT; - break; + return -TARGET_EFAULT; } } p = lock_user_string(arg1); @@ -11833,15 +11675,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } - break; + return ret; case TARGET_NR_fsetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_READ, arg3, arg4, 1); if (!v) { - ret = -TARGET_EFAULT; - break; + return -TARGET_EFAULT; } } n = lock_user_string(arg2); @@ -11853,7 +11694,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(n, arg2, 0); unlock_user(v, arg3, 0); } - break; + return ret; case TARGET_NR_getxattr: case TARGET_NR_lgetxattr: { @@ -11861,8 +11702,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { - ret = -TARGET_EFAULT; - break; + return -TARGET_EFAULT; } } p = lock_user_string(arg1); @@ -11880,15 +11720,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } - break; + return ret; case TARGET_NR_fgetxattr: { void *n, *v = 0; if (arg3) { v = lock_user(VERIFY_WRITE, arg3, arg4, 0); if (!v) { - ret = -TARGET_EFAULT; - break; + return -TARGET_EFAULT; } } n = lock_user_string(arg2); @@ -11900,7 +11739,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(n, arg2, 0); unlock_user(v, arg3, arg4); } - break; + return ret; case TARGET_NR_removexattr: case TARGET_NR_lremovexattr: { @@ -11919,7 +11758,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); unlock_user(n, arg2, 0); } - break; + return ret; case TARGET_NR_fremovexattr: { void *n; @@ -11931,15 +11770,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user(n, arg2, 0); } - break; + return ret; #endif #endif /* CONFIG_ATTR */ #ifdef TARGET_NR_set_thread_area case TARGET_NR_set_thread_area: #if defined(TARGET_MIPS) ((CPUMIPSState *) cpu_env)->active_tc.CP0_UserLocal = arg1; - ret = 0; - break; + return 0; #elif defined(TARGET_CRIS) if (arg1 & 0xff) ret = -TARGET_EINVAL; @@ -11947,16 +11785,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1; ret = 0; } - break; + return ret; #elif defined(TARGET_I386) && defined(TARGET_ABI32) - ret = do_set_thread_area(cpu_env, arg1); - break; + return do_set_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { TaskState *ts = cpu->opaque; ts->tp_value = arg1; - ret = 0; - break; + return 0; } #else goto unimplemented_nowarn; @@ -11965,13 +11801,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_get_thread_area case TARGET_NR_get_thread_area: #if defined(TARGET_I386) && defined(TARGET_ABI32) - ret = do_get_thread_area(cpu_env, arg1); - break; + return do_get_thread_area(cpu_env, arg1); #elif defined(TARGET_M68K) { TaskState *ts = cpu->opaque; - ret = ts->tp_value; - break; + return ts->tp_value; } #else goto unimplemented_nowarn; @@ -11991,7 +11825,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { ret = get_errno(clock_settime(arg1, &ts)); } - break; + return ret; } #endif #ifdef TARGET_NR_clock_gettime @@ -12002,7 +11836,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { ret = host_to_target_timespec(arg2, &ts); } - break; + return ret; } #endif #ifdef TARGET_NR_clock_getres @@ -12013,7 +11847,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { host_to_target_timespec(arg2, &ts); } - break; + return ret; } #endif #ifdef TARGET_NR_clock_nanosleep @@ -12033,24 +11867,21 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ((CPUPPCState *)cpu_env)->crf[0] |= 1; } #endif - break; + return ret; } #endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: - ret = get_errno(set_tid_address((int *)g2h(arg1))); - break; + return get_errno(set_tid_address((int *)g2h(arg1))); #endif case TARGET_NR_tkill: - ret = get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2))); - break; + return get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2))); case TARGET_NR_tgkill: - ret = get_errno(safe_tgkill((int)arg1, (int)arg2, - target_to_host_signal(arg3))); - break; + return get_errno(safe_tgkill((int)arg1, (int)arg2, + target_to_host_signal(arg3))); #ifdef TARGET_NR_set_robust_list case TARGET_NR_set_robust_list: @@ -12092,18 +11923,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); } } - break; + return ret; #endif case TARGET_NR_futex: - ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6); - break; + return do_futex(arg1, arg2, arg3, arg4, arg5, arg6); #if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) case TARGET_NR_inotify_init: ret = get_errno(sys_inotify_init()); if (ret >= 0) { fd_trans_register(ret, &target_inotify_trans); } - break; + return ret; #endif #ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) @@ -12113,7 +11943,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (ret >= 0) { fd_trans_register(ret, &target_inotify_trans); } - break; + return ret; #endif #endif #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) @@ -12121,12 +11951,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p = lock_user_string(arg2); ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3)); unlock_user(p, arg2, 0); - break; + return ret; #endif #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: - ret = get_errno(sys_inotify_rm_watch(arg1, arg2)); - break; + return get_errno(sys_inotify_rm_watch(arg1, arg2)); #endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) @@ -12151,17 +11980,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr)); unlock_user (p, arg1, 0); } - break; + return ret; case TARGET_NR_mq_unlink: p = lock_user_string(arg1 - 1); if (!p) { - ret = -TARGET_EFAULT; - break; + return -TARGET_EFAULT; } ret = get_errno(mq_unlink(p)); unlock_user (p, arg1, 0); - break; + return ret; case TARGET_NR_mq_timedsend: { @@ -12177,7 +12005,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } unlock_user (p, arg2, arg3); } - break; + return ret; case TARGET_NR_mq_timedreceive: { @@ -12198,7 +12026,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg4 != 0) put_user_u32(prio, arg4); } - break; + return ret; /* Not implemented for now... */ /* case TARGET_NR_mq_notify: */ @@ -12219,7 +12047,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, copy_to_user_mq_attr(arg3, &posix_mq_attr_out); } } - break; + return ret; #endif #ifdef CONFIG_SPLICE @@ -12228,7 +12056,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { ret = get_errno(tee(arg1,arg2,arg3,arg4)); } - break; + return ret; #endif #ifdef TARGET_NR_splice case TARGET_NR_splice: @@ -12259,7 +12087,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } - break; + return ret; #endif #ifdef TARGET_NR_vmsplice case TARGET_NR_vmsplice: @@ -12272,7 +12100,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } - break; + return ret; #endif #endif /* CONFIG_SPLICE */ #ifdef CONFIG_EVENTFD @@ -12282,7 +12110,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (ret >= 0) { fd_trans_register(ret, &target_eventfd_trans); } - break; + return ret; #endif #if defined(TARGET_NR_eventfd2) case TARGET_NR_eventfd2: @@ -12298,7 +12126,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (ret >= 0) { fd_trans_register(ret, &target_eventfd_trans); } - break; + return ret; } #endif #endif /* CONFIG_EVENTFD */ @@ -12310,7 +12138,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #else ret = get_errno(fallocate(arg1, arg2, arg3, arg4)); #endif - break; + return ret; #endif #if defined(CONFIG_SYNC_FILE_RANGE) #if defined(TARGET_NR_sync_file_range) @@ -12326,7 +12154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #else ret = get_errno(sync_file_range(arg1, arg2, arg3, arg4)); #endif - break; + return ret; #endif #if defined(TARGET_NR_sync_file_range2) case TARGET_NR_sync_file_range2: @@ -12337,29 +12165,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #else ret = get_errno(sync_file_range(arg1, arg3, arg4, arg2)); #endif - break; + return ret; #endif #endif #if defined(TARGET_NR_signalfd4) case TARGET_NR_signalfd4: - ret = do_signalfd4(arg1, arg2, arg4); - break; + return do_signalfd4(arg1, arg2, arg4); #endif #if defined(TARGET_NR_signalfd) case TARGET_NR_signalfd: - ret = do_signalfd4(arg1, arg2, 0); - break; + return do_signalfd4(arg1, arg2, 0); #endif #if defined(CONFIG_EPOLL) #if defined(TARGET_NR_epoll_create) case TARGET_NR_epoll_create: - ret = get_errno(epoll_create(arg1)); - break; + return get_errno(epoll_create(arg1)); #endif #if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1) case TARGET_NR_epoll_create1: - ret = get_errno(epoll_create1(arg1)); - break; + return get_errno(epoll_create1(arg1)); #endif #if defined(TARGET_NR_epoll_ctl) case TARGET_NR_epoll_ctl: @@ -12380,8 +12204,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(target_ep, arg4, 0); epp = &ep; } - ret = get_errno(epoll_ctl(arg1, arg2, arg3, epp)); - break; + return get_errno(epoll_ctl(arg1, arg2, arg3, epp)); } #endif @@ -12400,8 +12223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int timeout = arg4; if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } target_ep = lock_user(VERIFY_WRITE, arg2, @@ -12413,8 +12235,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ep = g_try_new(struct epoll_event, maxevents); if (!ep) { unlock_user(target_ep, arg2, 0); - ret = -TARGET_ENOMEM; - break; + return -TARGET_ENOMEM; } switch (num) { @@ -12444,7 +12265,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout, set, SIGSET_T_SIZE)); - break; } #endif #if defined(TARGET_NR_epoll_wait) @@ -12468,7 +12288,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(target_ep, arg2, 0); } g_free(ep); - break; + return ret; } #endif #endif @@ -12498,7 +12318,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_rold->rlim_max = tswap64(rold.rlim_max); unlock_user_struct(target_rold, arg4, 1); } - break; + return ret; } #endif #ifdef TARGET_NR_gethostname @@ -12511,7 +12331,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { ret = -TARGET_EFAULT; } - break; + return ret; } #endif #ifdef TARGET_NR_atomic_cmpxchg_32 @@ -12532,17 +12352,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } if (mem_value == arg2) put_user_u32(arg1, arg6); - ret = mem_value; - break; + return mem_value; } #endif #ifdef TARGET_NR_atomic_barrier case TARGET_NR_atomic_barrier: - { - /* Like the kernel implementation and the qemu arm barrier, no-op this? */ - ret = 0; - break; - } + /* Like the kernel implementation and the + qemu arm barrier, no-op this? */ + return 0; #endif #ifdef TARGET_NR_timer_create @@ -12564,7 +12381,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, phost_sevp = &host_sevp; ret = target_to_host_sigevent(phost_sevp, arg2); if (ret != 0) { - break; + return ret; } } @@ -12577,7 +12394,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } - break; + return ret; } #endif @@ -12605,7 +12422,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; } #endif @@ -12628,7 +12445,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -TARGET_EFAULT; } } - break; + return ret; } #endif @@ -12645,7 +12462,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(timer_getoverrun(htimer)); } fd_trans_unregister(ret); - break; + return ret; } #endif @@ -12662,15 +12479,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(timer_delete(htimer)); g_posix_timers[timerid] = 0; } - break; + return ret; } #endif #if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_create: - ret = get_errno(timerfd_create(arg1, - target_to_host_bitmask(arg2, fcntl_flags_tbl))); - break; + return get_errno(timerfd_create(arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl))); #endif #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD) @@ -12684,7 +12500,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD) @@ -12707,35 +12523,30 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; #endif #if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get) case TARGET_NR_ioprio_get: - ret = get_errno(ioprio_get(arg1, arg2)); - break; + return get_errno(ioprio_get(arg1, arg2)); #endif #if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set) case TARGET_NR_ioprio_set: - ret = get_errno(ioprio_set(arg1, arg2, arg3)); - break; + return get_errno(ioprio_set(arg1, arg2, arg3)); #endif #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS) case TARGET_NR_setns: - ret = get_errno(setns(arg1, arg2)); - break; + return get_errno(setns(arg1, arg2)); #endif #if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS) case TARGET_NR_unshare: - ret = get_errno(unshare(arg1)); - break; + return get_errno(unshare(arg1)); #endif #if defined(TARGET_NR_kcmp) && defined(__NR_kcmp) case TARGET_NR_kcmp: - ret = get_errno(kcmp(arg1, arg2, arg3, arg4, arg5)); - break; + return get_errno(kcmp(arg1, arg2, arg3, arg4, arg5)); #endif default: @@ -12744,8 +12555,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn: #endif - ret = -TARGET_ENOSYS; - break; + return -TARGET_ENOSYS; } fail: return ret; From patchwork Sun Jun 10 03:00:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138083 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2577281lji; Sat, 9 Jun 2018 20:08:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKzlj14qnszjdANSQFwFkRB6BwvdcQcT3YzkQyrdnu6mEUHPp/8AnZ3no9Rj2Peqy1DEpzM X-Received: by 2002:a37:c986:: with SMTP id m6-v6mr10623906qkl.382.1528600136604; Sat, 09 Jun 2018 20:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600136; cv=none; d=google.com; s=arc-20160816; b=adRlIrPrQIz1O1k0pTKwZkpAJjhpbmN3oviZNCeSiRnagssassyjoHo6Dloiqsae1l FWDVw3b8KF+SECwwLCGXdftZ9zzrDjWnlIWBHw8wCIvHcRIBR3UBuMo0UjmPM/6VretH EUGyZ0y20ttv06dcrUz2ILvz9ribpDQM7KuI2ws/HRrO3W53S3RVqeG4lXX5HPgj6/tZ mSWx6ulAPm52T2+UE1xlbEDjRExDwF9Z/inlYjcfGFMNe0XQdynZoIgu8XAuE/bbjtnU AcIkHT5Qcknz5aW0ZxGS4fIcM/8XvdOT7rwmof0+/4shFWFcdkUpE3HlMwr0/qn0p956 0Cqg== 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:arc-authentication-results; bh=uWVg5zUMEiMMcw2yRAIpPlnyzt698vX4oQYhWwyBWfM=; b=PhdJHq4wcbSjNoSq/qlUo+eFnkfCI7AfRWGJqAHsP6eYzG/naRWO28N3xzltuDqzMY d9oG77BxOcJAbVSYzwIr49vLAGQ78yGVQvH3GZyeekg3bOw+/dxplY9T2y9tWSpjh9yP x05B8B+7/uhaicOH7AHXdPouSzOuNZ4NufD2CfuNk+ynhRo/i+QSSGiZdPrELjfffIck NVIdFluqjd91O7NnFU1nx2nSnk33GNPtMPXvQYNz1sVa0jD9ihAPzxpCBdeLNM2pdqgY RXEPQVfTYMljZGURX3t7DrVXlkqGYVpquDrrg7tXa3uH+UFaI3mGEuSD2R6d5GAXO4TC 4yIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EidqQCnL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p5-v6si9071983qtf.238.2018.06.09.20.08.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:08:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EidqQCnL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqit-0006xZ-SP for patch@linaro.org; Sat, 09 Jun 2018 23:08:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcs-0001bZ-PQ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqco-00039K-DO for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:42 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:33741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqco-000396-1W for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:38 -0400 Received: by mail-pl0-x243.google.com with SMTP id n10-v6so10390194plp.0 for ; Sat, 09 Jun 2018 20:02: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=uWVg5zUMEiMMcw2yRAIpPlnyzt698vX4oQYhWwyBWfM=; b=EidqQCnLDdmbXiti+afqzOch3iqJmFkw63LC3LELR0ePkacouYU/gHk+ary8xNVKC4 xv7kFW5VVgroXLYZS+vdrXFG2KIcx1Q99HbqDvE3lVhdRdHVgdgW4Df9G+5ixjdWi4Bt apCTK/1ie2ZOVKlQr1Wsvb5ti8G5z79z+OqeI= 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=uWVg5zUMEiMMcw2yRAIpPlnyzt698vX4oQYhWwyBWfM=; b=cd8HkRftszZTliArFuPkMqRaIeBvfYv4D2VzD15p/qlS+6u959jbzI5O1XeDI8kykx 7oc0YLXJtby3iWmOFlp4v5z25FPuUu744uL6Qsovli7GqzRcnIuGWDExyXoqbrC83y9X hfhhRoe6qNPTYKiDJ/PZ6DQ8XvQMGcJnKrO415h2bs4YBXY9zeZmO9KMEoOr5b/jaWj0 Fx/hZkyNQfHCer0vauH+GEJlHNPKzL4TRIzaYSsa0HnZPjQ9RbZUlwqh9A9piSt1ATsG SbVOzkCLWPXYTy5TNGT20BIIOOiH788ygIOWVacFFSvlWgsjeAPow5LSnsY49fGcog7X rYgw== X-Gm-Message-State: APt69E2gy127kA2pJtRSEvy9pWq/Z8mQDPogSdfJcvY6/4nO6VEEedsI hAU1xFrbHSOuu2C7YrHDx0Nug5G9rkI= X-Received: by 2002:a17:902:3303:: with SMTP id a3-v6mr12930762plc.209.1528599756205; Sat, 09 Jun 2018 20:02:36 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:36 -1000 Message-Id: <20180610030220.3777-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 004/108] linux-user: Propagate goto efault to return 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" Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 341 ++++++++++++++++++++++--------------------- 1 file changed, 175 insertions(+), 166 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index efe882612b..a6b8268332 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8009,7 +8009,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return 0; } else { if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(safe_read(arg1, p, arg3)); if (ret >= 0 && fd_trans_host_to_target_data(arg1)) { @@ -8020,7 +8020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_write: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; + return -TARGET_EFAULT; if (fd_trans_target_to_host_data(arg1)) { void *copy = g_malloc(arg3); memcpy(copy, p, arg3); @@ -8038,7 +8038,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_open case TARGET_NR_open: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, target_to_host_bitmask(arg2, fcntl_flags_tbl), arg3)); @@ -8048,7 +8048,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_openat: if (!(p = lock_user_string(arg2))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(do_openat(cpu_env, arg1, p, target_to_host_bitmask(arg3, fcntl_flags_tbl), arg4)); @@ -8083,7 +8083,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(safe_wait4(arg1, &status, arg3, 0)); if (!is_error(ret) && arg2 && ret && put_user_s32(host_to_target_waitstatus(status), arg2)) - goto efault; + return -TARGET_EFAULT; } return ret; #endif @@ -8095,7 +8095,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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))) - goto efault; + return -TARGET_EFAULT; host_to_target_siginfo(p, &info); unlock_user(p, arg3, sizeof(target_siginfo_t)); } @@ -8105,7 +8105,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_creat /* not on alpha */ case TARGET_NR_creat: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(creat(p, arg2)); fd_trans_unregister(ret); unlock_user(p, arg1, 0); @@ -8131,7 +8131,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { void * p2 = NULL; if (!arg2 || !arg4) - goto efault; + return -TARGET_EFAULT; p = lock_user_string(arg2); p2 = lock_user_string(arg4); if (!p || !p2) @@ -8146,7 +8146,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_unlink case TARGET_NR_unlink: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(unlink(p)); unlock_user(p, arg1, 0); return ret; @@ -8154,7 +8154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_unlinkat) case TARGET_NR_unlinkat: if (!(p = lock_user_string(arg2))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(unlinkat(arg1, p, arg3)); unlock_user(p, arg2, 0); return ret; @@ -8174,7 +8174,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, guest_argp = arg2; for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) - goto efault; + return -TARGET_EFAULT; if (!addr) break; argc++; @@ -8183,7 +8183,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, guest_envp = arg3; for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) { if (get_user_ual(addr, gp)) - goto efault; + return -TARGET_EFAULT; if (!addr) break; envc++; @@ -8258,7 +8258,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(chdir(p)); unlock_user(p, arg1, 0); return ret; @@ -8270,14 +8270,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret) && arg1 && put_user_sal(host_time, arg1)) - goto efault; + return -TARGET_EFAULT; } return ret; #endif #ifdef TARGET_NR_mknod case TARGET_NR_mknod: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(mknod(p, arg2, arg3)); unlock_user(p, arg1, 0); return ret; @@ -8285,7 +8285,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_mknodat) case TARGET_NR_mknodat: if (!(p = lock_user_string(arg2))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(mknodat(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); return ret; @@ -8293,7 +8293,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_chmod case TARGET_NR_chmod: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(chmod(p, arg2)); unlock_user(p, arg1, 0); return ret; @@ -8326,7 +8326,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg1) { p = lock_user_string(arg1); if (!p) { - goto efault; + return -TARGET_EFAULT; } } else { p = NULL; @@ -8337,7 +8337,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg1) { unlock_user(p, arg1, 0); } - goto efault; + return -TARGET_EFAULT; } if (arg3) { @@ -8347,7 +8347,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); } unlock_user(p2, arg2, 0); - goto efault; + return -TARGET_EFAULT; } } else { p3 = NULL; @@ -8376,7 +8376,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_umount case TARGET_NR_umount: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(umount(p)); unlock_user(p, arg1, 0); return ret; @@ -8386,7 +8386,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { time_t host_time; if (get_user_sal(host_time, arg1)) - goto efault; + return -TARGET_EFAULT; return get_errno(stime(&host_time)); } #endif @@ -8414,7 +8414,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_utimbuf *target_tbuf; if (arg2) { if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) - goto efault; + return -TARGET_EFAULT; tbuf.actime = tswapal(target_tbuf->actime); tbuf.modtime = tswapal(target_tbuf->modtime); unlock_user_struct(target_tbuf, arg2, 0); @@ -8423,7 +8423,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, host_tbuf = NULL; } if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(utime(p, host_tbuf)); unlock_user(p, arg1, 0); } @@ -8437,13 +8437,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (copy_from_user_timeval(&tv[0], arg2) || copy_from_user_timeval(&tv[1], arg2 + sizeof(struct target_timeval))) - goto efault; + return -TARGET_EFAULT; tvp = tv; } else { tvp = NULL; } if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(utimes(p, tvp)); unlock_user(p, arg1, 0); } @@ -8457,13 +8457,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (copy_from_user_timeval(&tv[0], arg3) || copy_from_user_timeval(&tv[1], arg3 + sizeof(struct target_timeval))) - goto efault; + return -TARGET_EFAULT; tvp = tv; } else { tvp = NULL; } - if (!(p = lock_user_string(arg2))) - goto efault; + if (!(p = lock_user_string(arg2))) { + return -TARGET_EFAULT; + } ret = get_errno(futimesat(arg1, path(p), tvp)); unlock_user(p, arg2, 0); } @@ -8479,16 +8480,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_access case TARGET_NR_access: - if (!(p = lock_user_string(arg1))) - goto efault; + 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))) - goto efault; + if (!(p = lock_user_string(arg2))) { + return -TARGET_EFAULT; + } ret = get_errno(faccessat(arg1, p, arg3, 0)); unlock_user(p, arg2, 0); return ret; @@ -8559,7 +8562,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_mkdir case TARGET_NR_mkdir: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(mkdir(p, arg2)); unlock_user(p, arg1, 0); return ret; @@ -8567,7 +8570,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_mkdirat) case TARGET_NR_mkdirat: if (!(p = lock_user_string(arg2))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(mkdirat(arg1, p, arg3)); unlock_user(p, arg2, 0); return ret; @@ -8575,7 +8578,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_rmdir case TARGET_NR_rmdir: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(rmdir(p)); unlock_user(p, arg1, 0); return ret; @@ -8603,7 +8606,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg1) { tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); if (!tmsp) - goto efault; + 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)); @@ -8625,8 +8628,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg1 == 0) { ret = get_errno(acct(NULL)); } else { - if (!(p = lock_user_string(arg1))) - goto efault; + if (!(p = lock_user_string(arg1))) { + return -TARGET_EFAULT; + } ret = get_errno(acct(path(p))); unlock_user(p, arg1, 0); } @@ -8634,7 +8638,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_umount2 case TARGET_NR_umount2: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(umount2(p, arg2)); unlock_user(p, arg1, 0); return ret; @@ -8667,7 +8671,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(umask(arg1)); case TARGET_NR_chroot: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); return ret; @@ -8717,7 +8721,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_old_sigaction *old_act; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - goto efault; + 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; @@ -8728,7 +8732,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - goto efault; + 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; @@ -8739,7 +8743,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - goto efault; + 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; @@ -8753,7 +8757,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - goto efault; + 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]; @@ -8767,7 +8771,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_sigaction act, oact, *pact; if (arg2) { if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - goto efault; + 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; @@ -8783,7 +8787,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - goto efault; + 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; @@ -8813,7 +8817,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } if (arg2) { if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) - goto efault; + return -TARGET_EFAULT; act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags; @@ -8824,7 +8828,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(do_sigaction(arg1, pact, &oact)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) - goto efault; + return -TARGET_EFAULT; rt_act->_sa_handler = oact._sa_handler; rt_act->sa_mask = oact.sa_mask; rt_act->sa_flags = oact.sa_flags; @@ -8845,7 +8849,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } if (arg2) { if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { - goto efault; + return -TARGET_EFAULT; } #ifdef TARGET_ARCH_HAS_KA_RESTORER act->ka_restorer = restorer; @@ -8947,7 +8951,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) - goto efault; + return -TARGET_EFAULT; target_to_host_old_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; @@ -8958,7 +8962,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = do_sigprocmask(how, set_ptr, &oldset); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) - goto efault; + return -TARGET_EFAULT; host_to_target_old_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } @@ -8991,7 +8995,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) - goto efault; + return -TARGET_EFAULT; target_to_host_sigset(&set, p); unlock_user(p, arg2, 0); set_ptr = &set; @@ -9002,7 +9006,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = do_sigprocmask(how, set_ptr, &oldset); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) - goto efault; + return -TARGET_EFAULT; host_to_target_sigset(p, &oldset); unlock_user(p, arg3, sizeof(target_sigset_t)); } @@ -9015,7 +9019,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) - goto efault; + return -TARGET_EFAULT; host_to_target_old_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } @@ -9038,7 +9042,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(sigpending(&set)); if (!is_error(ret)) { if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0))) - goto efault; + return -TARGET_EFAULT; host_to_target_sigset(p, &set); unlock_user(p, arg1, sizeof(target_sigset_t)); } @@ -9053,7 +9057,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); #else if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - goto efault; + return -TARGET_EFAULT; target_to_host_old_sigset(&ts->sigsuspend_mask, p); unlock_user(p, arg1, 0); #endif @@ -9073,7 +9077,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EINVAL; } if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - goto efault; + 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, @@ -9094,7 +9098,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1))) - goto efault; + return -TARGET_EFAULT; target_to_host_sigset(&set, p); unlock_user(p, arg1, 0); if (arg3) { @@ -9110,7 +9114,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0); if (!p) { - goto efault; + return -TARGET_EFAULT; } host_to_target_siginfo(p, &uinfo); unlock_user(p, arg2, sizeof(target_siginfo_t)); @@ -9125,7 +9129,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); if (!p) { - goto efault; + return -TARGET_EFAULT; } target_to_host_siginfo(&uinfo, p); unlock_user(p, arg3, 0); @@ -9138,7 +9142,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p = lock_user(VERIFY_READ, arg4, sizeof(target_siginfo_t), 1); if (!p) { - goto efault; + return -TARGET_EFAULT; } target_to_host_siginfo(&uinfo, p); unlock_user(p, arg4, 0); @@ -9162,7 +9166,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } case TARGET_NR_sethostname: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(sethostname(p, arg2)); unlock_user(p, arg1, 0); return ret; @@ -9172,7 +9176,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_rlimit *target_rlim; struct rlimit rlim; if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1)) - goto efault; + 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); @@ -9187,7 +9191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(getrlimit(resource, &rlim)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) - goto efault; + 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); @@ -9209,7 +9213,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(gettimeofday(&tv, NULL)); if (!is_error(ret)) { if (copy_to_user_timeval(arg1, &tv)) - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -9220,14 +9224,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg1) { if (copy_from_user_timeval(&tv, arg1)) { - goto efault; + return -TARGET_EFAULT; } ptv = &tv; } if (arg2) { if (copy_from_user_timezone(&tz, arg2)) { - goto efault; + return -TARGET_EFAULT; } ptz = &tz; } @@ -9294,7 +9298,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, */ if (ts_addr) { if (target_to_host_timespec(&ts, ts_addr)) { - goto efault; + return -TARGET_EFAULT; } ts_ptr = &ts; } else { @@ -9308,7 +9312,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1); if (!arg7) { - goto efault; + return -TARGET_EFAULT; } arg_sigset = tswapal(arg7[0]); arg_sigsize = tswapal(arg7[1]); @@ -9324,7 +9328,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_sigset = lock_user(VERIFY_READ, arg_sigset, sizeof(*target_sigset), 1); if (!target_sigset) { - goto efault; + return -TARGET_EFAULT; } target_to_host_sigset(&set, target_sigset); unlock_user(target_sigset, arg_sigset, 0); @@ -9340,14 +9344,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n)) - goto efault; + return -TARGET_EFAULT; if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n)) - goto efault; + return -TARGET_EFAULT; if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n)) - goto efault; + return -TARGET_EFAULT; if (ts_addr && host_to_target_timespec(ts_addr, &ts)) - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -9446,7 +9450,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(swapon(p, arg2)); unlock_user(p, arg1, 0); return ret; @@ -9456,7 +9460,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* arg4 must be ignored in all other cases */ p = lock_user_string(arg4); if (!p) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(reboot(arg1, arg2, arg3, p)); unlock_user(p, arg4, 0); @@ -9478,7 +9482,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, abi_ulong *v; abi_ulong v1, v2, v3, v4, v5, v6; if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1))) - goto efault; + return -TARGET_EFAULT; v1 = tswapal(v[0]); v2 = tswapal(v[1]); v3 = tswapal(v[2]); @@ -9550,7 +9554,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(truncate(p, arg2)); unlock_user(p, arg1, 0); return ret; @@ -9561,7 +9565,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_fchmodat) case TARGET_NR_fchmodat: if (!(p = lock_user_string(arg2))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(fchmodat(arg1, p, arg3, 0)); unlock_user(p, arg2, 0); return ret; @@ -9589,8 +9593,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented; #endif case TARGET_NR_statfs: - if (!(p = lock_user_string(arg1))) - goto efault; + if (!(p = lock_user_string(arg1))) { + return -TARGET_EFAULT; + } ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs: @@ -9598,7 +9603,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_statfs *target_stfs; if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0)) - goto efault; + return -TARGET_EFAULT; __put_user(stfs.f_type, &target_stfs->f_type); __put_user(stfs.f_bsize, &target_stfs->f_bsize); __put_user(stfs.f_blocks, &target_stfs->f_blocks); @@ -9624,8 +9629,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto convert_statfs; #ifdef TARGET_NR_statfs64 case TARGET_NR_statfs64: - if (!(p = lock_user_string(arg1))) - goto efault; + if (!(p = lock_user_string(arg1))) { + return -TARGET_EFAULT; + } ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs64: @@ -9633,7 +9639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_statfs64 *target_stfs; if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0)) - goto efault; + return -TARGET_EFAULT; __put_user(stfs.f_type, &target_stfs->f_type); __put_user(stfs.f_bsize, &target_stfs->f_bsize); __put_user(stfs.f_blocks, &target_stfs->f_blocks); @@ -9731,7 +9737,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_getrandom: p = lock_user(VERIFY_WRITE, arg1, arg2, 0); if (!p) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(getrandom(p, arg2, arg3)); unlock_user(p, arg1, ret); @@ -9799,7 +9805,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (copy_from_user_timeval(&pvalue->it_interval, arg2) || copy_from_user_timeval(&pvalue->it_value, arg2 + sizeof(struct target_timeval))) - goto efault; + return -TARGET_EFAULT; } else { pvalue = NULL; } @@ -9809,7 +9815,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, &ovalue.it_interval) || copy_to_user_timeval(arg3 + sizeof(struct target_timeval), &ovalue.it_value)) - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -9823,22 +9829,24 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, &value.it_interval) || copy_to_user_timeval(arg2 + sizeof(struct target_timeval), &value.it_value)) - goto efault; + return -TARGET_EFAULT; } } return ret; #ifdef TARGET_NR_stat case TARGET_NR_stat: - if (!(p = lock_user_string(arg1))) - goto efault; + if (!(p = lock_user_string(arg1))) { + return -TARGET_EFAULT; + } ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; #endif #ifdef TARGET_NR_lstat case TARGET_NR_lstat: - if (!(p = lock_user_string(arg1))) - goto efault; + if (!(p = lock_user_string(arg1))) { + return -TARGET_EFAULT; + } ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; @@ -9853,7 +9861,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct target_stat *target_st; if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0)) - goto efault; + return -TARGET_EFAULT; memset(target_st, 0, sizeof(*target_st)); __put_user(st.st_dev, &target_st->st_dev); __put_user(st.st_ino, &target_st->st_ino); @@ -9907,7 +9915,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (status_ptr && ret) { status = host_to_target_waitstatus(status); if (put_user_s32(status, status_ptr)) - goto efault; + return -TARGET_EFAULT; } if (target_rusage) { rusage_err = host_to_target_rusage(target_rusage, &rusage); @@ -9921,7 +9929,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_swapoff case TARGET_NR_swapoff: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(swapoff(p)); unlock_user(p, arg1, 0); return ret; @@ -9934,7 +9942,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret) && arg1) { if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0)) - goto efault; + return -TARGET_EFAULT; __put_user(value.uptime, &target_value->uptime); __put_user(value.loads[0], &target_value->loads[0]); __put_user(value.loads[1], &target_value->loads[1]); @@ -10031,7 +10039,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_setdomainname: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(setdomainname(p, arg2)); unlock_user(p, arg1, 0); return ret; @@ -10041,7 +10049,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct new_utsname * buf; if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0)) - goto efault; + return -TARGET_EFAULT; ret = get_errno(sys_uname(buf)); if (!is_error(ret)) { /* Overwrite the native machine name with whatever is being @@ -10072,12 +10080,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct timex host_buf; if (target_to_host_timex(&host_buf, arg1) != 0) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(adjtimex(&host_buf)); if (!is_error(ret)) { if (host_to_target_timex(arg1, &host_buf) != 0) { - goto efault; + return -TARGET_EFAULT; } } } @@ -10088,12 +10096,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct timex htx, *phtx = &htx; if (target_to_host_timex(phtx, arg2) != 0) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(clock_adjtime(arg1, phtx)); if (!is_error(ret) && phtx) { if (host_to_target_timex(arg2, phtx) != 0) { - goto efault; + return -TARGET_EFAULT; } } } @@ -10143,7 +10151,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); #endif if ((ret == 0) && put_user_s64(res, arg4)) { - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -10174,7 +10182,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, count1 = 0; de = dirp; if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) - goto efault; + return -TARGET_EFAULT; tde = target_dirp; while (len > 0) { reclen = de->d_reclen; @@ -10202,7 +10210,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, abi_long count = arg3; if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(sys_getdents(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent *de; @@ -10231,7 +10239,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, dirp = lock_user(VERIFY_WRITE, arg2, count, 0); if (!dirp) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(sys_getdents64(arg1, dirp, count)); if (!is_error(ret)) { @@ -10286,7 +10294,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct linux_dirent64 *dirp; abi_long count = arg3; if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(sys_getdents64(arg1, dirp, count)); if (!is_error(ret)) { struct linux_dirent64 *de; @@ -10335,7 +10343,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1); if (!target_pfd) { - goto efault; + return -TARGET_EFAULT; } pfd = alloca(sizeof(struct pollfd) * nfds); @@ -10356,7 +10364,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg3) { if (target_to_host_timespec(timeout_ts, arg3)) { unlock_user(target_pfd, arg1, 0); - goto efault; + return -TARGET_EFAULT; } } else { timeout_ts = NULL; @@ -10371,7 +10379,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1); if (!target_set) { unlock_user(target_pfd, arg1, 0); - goto efault; + return -TARGET_EFAULT; } target_to_host_sigset(set, target_set); } else { @@ -10525,7 +10533,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } if (host_to_target_cpu_mask(mask, mask_size, arg3, ret)) { - goto efault; + return -TARGET_EFAULT; } } } @@ -10562,10 +10570,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; } if (arg1 && put_user_u32(cpu, arg1)) { - goto efault; + return -TARGET_EFAULT; } if (arg2 && put_user_u32(node, arg2)) { - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -10578,7 +10586,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EINVAL; } if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1)) - goto efault; + return -TARGET_EFAULT; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg2, 0); return get_errno(sched_setparam(arg1, &schp)); @@ -10594,7 +10602,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(sched_getparam(arg1, &schp)); if (!is_error(ret)) { if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0)) - goto efault; + return -TARGET_EFAULT; target_schp->sched_priority = tswap32(schp.sched_priority); unlock_user_struct(target_schp, arg2, 1); } @@ -10608,7 +10616,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EINVAL; } if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1)) - goto efault; + return -TARGET_EFAULT; schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg3, 0); return get_errno(sched_setscheduler(arg1, arg2, &schp)); @@ -10656,7 +10664,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); if (!is_error(ret) && arg2 && put_user_ual(deathsig, arg2)) { - goto efault; + return -TARGET_EFAULT; } return ret; } @@ -10665,7 +10673,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); if (!name) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); @@ -10676,7 +10684,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { void *name = lock_user(VERIFY_READ, arg2, 16, 1); if (!name) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(prctl(arg1, (unsigned long)name, arg3, arg4, arg5)); @@ -10736,7 +10744,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5 = arg6; } if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); unlock_user(p, arg2, ret); return ret; @@ -10746,14 +10754,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5 = arg6; } if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - goto efault; + 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))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(sys_getcwd1(p, arg2)); unlock_user(p, arg1, ret); return ret; @@ -10769,7 +10777,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int data_items = 1; if (!lock_user_struct(VERIFY_WRITE, target_header, arg1, 1)) { - goto efault; + return -TARGET_EFAULT; } header.version = tswap32(target_header->version); header.pid = tswap32(target_header->pid); @@ -10789,7 +10797,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } if (!target_data) { unlock_user_struct(target_header, arg1, 0); - goto efault; + return -TARGET_EFAULT; } if (num == TARGET_NR_capset) { @@ -10905,7 +10913,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { struct target_rlimit *target_rlim; if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0)) - goto efault; + 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); @@ -10916,7 +10924,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_truncate64 case TARGET_NR_truncate64: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); unlock_user(p, arg1, 0); return ret; @@ -10927,8 +10935,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: - if (!(p = lock_user_string(arg1))) - goto efault; + if (!(p = lock_user_string(arg1))) { + return -TARGET_EFAULT; + } ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) @@ -10937,8 +10946,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_lstat64 case TARGET_NR_lstat64: - if (!(p = lock_user_string(arg1))) - goto efault; + if (!(p = lock_user_string(arg1))) { + return -TARGET_EFAULT; + } ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) @@ -10959,9 +10969,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_newfstatat case TARGET_NR_newfstatat: #endif - if (!(p = lock_user_string(arg2))) - goto efault; + if (!(p = lock_user_string(arg2))) { + return -TARGET_EFAULT; + } ret = get_errno(fstatat(arg1, path(p), &st, arg4)); + unlock_user(p, arg2, 0); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg3, &st); return ret; @@ -10969,7 +10981,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_lchown case TARGET_NR_lchown: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); return ret; @@ -11008,7 +11020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * sizeof(target_id), 0); if (!target_grouplist) - goto efault; + return -TARGET_EFAULT; for(i = 0;i < ret; i++) target_grouplist[i] = tswapid(high2lowgid(grouplist[i])); unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id)); @@ -11040,7 +11052,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_fchownat) case TARGET_NR_fchownat: if (!(p = lock_user_string(arg2))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5)); unlock_user(p, arg2, 0); @@ -11061,7 +11073,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (put_user_id(high2lowuid(ruid), arg1) || put_user_id(high2lowuid(euid), arg2) || put_user_id(high2lowuid(suid), arg3)) - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -11081,7 +11093,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (put_user_id(high2lowgid(rgid), arg1) || put_user_id(high2lowgid(egid), arg2) || put_user_id(high2lowgid(sgid), arg3)) - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -11089,7 +11101,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_chown case TARGET_NR_chown: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); unlock_user(p, arg1, 0); return ret; @@ -11106,7 +11118,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_lchown32 case TARGET_NR_lchown32: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(lchown(p, arg2, arg3)); unlock_user(p, arg1, 0); return ret; @@ -11157,7 +11169,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; if (put_user_u64 (swcr, arg2)) - goto efault; + return -TARGET_EFAULT; ret = 0; } break; @@ -11184,7 +11196,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, uint64_t swcr, fpcr, orig_fpcr; if (get_user_u64 (swcr, arg2)) { - goto efault; + return -TARGET_EFAULT; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); fpcr = orig_fpcr & FPCR_DYN_MASK; @@ -11211,7 +11223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int si_code; if (get_user_u64(exc, arg2)) { - goto efault; + return -TARGET_EFAULT; } orig_fpcr = cpu_alpha_load_fpcr(cpu_env); @@ -11380,7 +11392,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (put_user_u32(ruid, arg1) || put_user_u32(euid, arg2) || put_user_u32(suid, arg3)) - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -11398,7 +11410,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (put_user_u32(rgid, arg1) || put_user_u32(egid, arg2) || put_user_u32(sgid, arg3)) - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -11406,7 +11418,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_chown32 case TARGET_NR_chown32: if (!(p = lock_user_string(arg1))) - goto efault; + return -TARGET_EFAULT; ret = get_errno(chown(p, arg2, arg3)); unlock_user(p, arg1, 0); return ret; @@ -11969,13 +11981,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, pposix_mq_attr = NULL; if (arg4) { if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) { - goto efault; + return -TARGET_EFAULT; } pposix_mq_attr = &posix_mq_attr; } p = lock_user_string(arg1 - 1); if (!p) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr)); unlock_user (p, arg1, 0); @@ -12065,25 +12077,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, loff_t *ploff_in = NULL, *ploff_out = NULL; if (arg2) { if (get_user_u64(loff_in, arg2)) { - goto efault; + return -TARGET_EFAULT; } ploff_in = &loff_in; } if (arg4) { if (get_user_u64(loff_out, arg4)) { - goto efault; + return -TARGET_EFAULT; } ploff_out = &loff_out; } ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6)); if (arg2) { if (put_user_u64(loff_in, arg2)) { - goto efault; + return -TARGET_EFAULT; } } if (arg4) { if (put_user_u64(loff_out, arg4)) { - goto efault; + return -TARGET_EFAULT; } } } @@ -12193,7 +12205,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg4) { struct target_epoll_event *target_ep; if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { - goto efault; + return -TARGET_EFAULT; } ep.events = tswap32(target_ep->events); /* The epoll_data_t union is just opaque data to the kernel, @@ -12229,7 +12241,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_ep = lock_user(VERIFY_WRITE, arg2, maxevents * sizeof(struct target_epoll_event), 1); if (!target_ep) { - goto efault; + return -TARGET_EFAULT; } ep = g_try_new(struct epoll_event, maxevents); @@ -12301,7 +12313,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int resource = target_to_host_resource(arg2); if (arg3) { if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { - goto efault; + return -TARGET_EFAULT; } rnew.rlim_cur = tswap64(target_rnew->rlim_cur); rnew.rlim_max = tswap64(target_rnew->rlim_max); @@ -12312,7 +12324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(sys_prlimit64(arg1, resource, rnewp, arg4 ? &rold : 0)); if (!is_error(ret) && arg4) { if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { - goto efault; + return -TARGET_EFAULT; } target_rold->rlim_cur = tswap64(rold.rlim_cur); target_rold->rlim_max = tswap64(rold.rlim_max); @@ -12390,7 +12402,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, phtimer = NULL; } else { if (put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { - goto efault; + return -TARGET_EFAULT; } } } @@ -12414,12 +12426,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct itimerspec hspec_new = {{0},}, hspec_old = {{0},}; if (target_to_host_itimerspec(&hspec_new, arg3)) { - goto efault; + return -TARGET_EFAULT; } ret = get_errno( timer_settime(htimer, arg2, &hspec_new, &hspec_old)); if (arg4 && host_to_target_itimerspec(arg4, &hspec_old)) { - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -12497,7 +12509,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(timerfd_gettime(arg1, &its_curr)); if (arg2 && host_to_target_itimerspec(arg2, &its_curr)) { - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -12510,7 +12522,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (arg3) { if (target_to_host_itimerspec(&its_new, arg3)) { - goto efault; + return -TARGET_EFAULT; } p_new = &its_new; } else { @@ -12520,7 +12532,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(timerfd_settime(arg1, arg2, p_new, &its_old)); if (arg4 && host_to_target_itimerspec(arg4, &its_old)) { - goto efault; + return -TARGET_EFAULT; } } return ret; @@ -12559,9 +12571,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } fail: return ret; -efault: - ret = -TARGET_EFAULT; - goto fail; } abi_long do_syscall(void *cpu_env, int num, abi_long arg1, From patchwork Sun Jun 10 03:00:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138076 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2573747lji; Sat, 9 Jun 2018 20:03:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ7ApLtTzJB7kyGv6/B5yjmzPWKS0D2jhJGSugADnomzSfI75RIWhg0o05F/NyZRa6rrKlQ X-Received: by 2002:a0c:ca12:: with SMTP id c18-v6mr10952545qvk.62.1528599784756; Sat, 09 Jun 2018 20:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528599784; cv=none; d=google.com; s=arc-20160816; b=Cv0hAwrWDy6/MgMdtae0djLb7fxou0Xoyh+A3PxnX6gxWZStUwH7b3az+jfFgSherr jiWMcOrQ8avXkizwZEupYQ4NOt56kNeL51R29HlaxN72jPlfO5uHYttZR9qIA6nH6Rqm /VQvUSwI7rPzakpEmmdHQOfNuuJ90jnwhTy406unrwXV2W6d3fsRtDtwdoMfv/S86Pms f3pw+0kfQae3THod6IFF7TxVT1CX+gWpikF9qCJP7llX+ZMQtJF4g0j1AQqJkaNulPiC NE2DqYU9fOUODYSIToW98khbt5CDqXJpfQWN/w8JdiNujg2EI4j7oI0HOWFETHMxss6W hOVw== 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:arc-authentication-results; bh=4cH1KchH60yn7x3nWoRbUGPDM7osjD47ISy+1P676Qw=; b=vTIk7ARqdUfgHU52Zdn4avW4mQls7f+8Pfp8nOeRbkZGC/0JBtH2OD1xO6K0oaejGT YXGllDfjzjs+ByFkuof7XvnpG0yjrEs5Jf2VipR/PVYzYpwkm3G8icpOnF+L+N4MIYCt xNBjGDidja+5OaPLFa+IsCDiRfK1AHIeqlJvkK3U7LXP0dUuzJ51eb7I4WgIqn8M5ZLw efyuTbCDgP8M8cm87mX5UfQDwL+XKB5FBGxGxCaVVaqg01gGUZtGGC8XJqtO99Wjo2/4 ct3uSA5rrVb2PSeGiw3UX9GSzMFn2eLydHViWmu2H4QazSPTmcn8+8w4b0XNWEOr1ri7 RWOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SvkMYvJq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d13-v6si3953381qvn.206.2018.06.09.20.03.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:03:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SvkMYvJq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdE-0001bj-4Z for patch@linaro.org; Sat, 09 Jun 2018 23:03:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcr-0001aZ-HJ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqcp-00039c-FJ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:41 -0400 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]:43589) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqcp-00039W-9R for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:39 -0400 Received: by mail-pg0-x235.google.com with SMTP id a14-v6so7516635pgw.10 for ; Sat, 09 Jun 2018 20:02: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=4cH1KchH60yn7x3nWoRbUGPDM7osjD47ISy+1P676Qw=; b=SvkMYvJqaKQfrQQ1TdryoddZ8R1KfUHhybh0jjLXTlX9/zk2QlOWCgoh8nKaXA7MHJ XV/QG2NWn24bj6dIRx5wYnNfcevk1XZl6clNaDkerIBFExcJ+PJNsmxaKYS6YyECIJ5D SWSEQz3hFiFB4lOCWRWMQ7JC7FcJy6lLyC3L0= 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=4cH1KchH60yn7x3nWoRbUGPDM7osjD47ISy+1P676Qw=; b=gsOnHzeIC++4tUt2IxuCmElkVxDyYcZZUQ3PUerJ+t5wGWph/z/89XiAckkU4kKnVB QNopovgHQUofjZc0LeUgTZneKusxLAlh2E5vnr/3tObuu9HKRSIu1f8Qo4kp0RcvFHz3 OgiijmOuhTN08oDr6CENjbDwTN+Wl+sqWDifECpPPaYpkUbP34rnz+iEU8OrBsMRveyc RGI719K7IAVQlaqfmfdPSUab5mudUBj42A0wKYhS6j7dooX65LVthMzyU7XOsN7Ymc4X bzIx72x3yidFCxxgd6NxrQCcVt7eFGfyby2XM9+JgHrAHNYn9uq47Jg1Gp7n4YdAJ+KD pu/g== X-Gm-Message-State: APt69E1Dq6bgYht9XjKCS0pSeRyXnZwCQtZlUjva1PkkNaxa5JjnvnAs OirlbJ/yiIsXp4HZrHCisUltBc0MJWw= X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr5026952pgv.306.1528599757961; Sat, 09 Jun 2018 20:02:37 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:37 -1000 Message-Id: <20180610030220.3777-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::235 Subject: [Qemu-devel] [PATCH v2 005/108] linux-user: Propagate goto unimplemented_nowarn to return 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" Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a6b8268332..06205d3d65 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11807,7 +11807,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return 0; } #else - goto unimplemented_nowarn; + return -TARGET_ENOSYS; #endif #endif #ifdef TARGET_NR_get_thread_area @@ -11820,12 +11820,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ts->tp_value; } #else - goto unimplemented_nowarn; + return -TARGET_ENOSYS; #endif #endif #ifdef TARGET_NR_getdomainname case TARGET_NR_getdomainname: - goto unimplemented_nowarn; + return -TARGET_ENOSYS; #endif #ifdef TARGET_NR_clock_settime @@ -11910,7 +11910,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, * holding a mutex that is shared with another process via * shared memory). */ - goto unimplemented_nowarn; + return -TARGET_ENOSYS; #endif #if defined(TARGET_NR_utimensat) @@ -12564,9 +12564,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); -#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) - unimplemented_nowarn: -#endif return -TARGET_ENOSYS; } fail: From patchwork Sun Jun 10 03:00:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138081 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2575626lji; Sat, 9 Jun 2018 20:06:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIv/DPtHAL8thh/cbVuWtYftrHSSjtHVM+dxkG2YqEt6Ytfs1nKXurydpO/Kn6JlHbyWYjt X-Received: by 2002:a0c:f149:: with SMTP id y9-v6mr10675623qvl.111.1528599965689; Sat, 09 Jun 2018 20:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528599965; cv=none; d=google.com; s=arc-20160816; b=g+iMti2otdacsDbUcZBNRikg/WSGw5KB1bRaq5iW4yW2/frWZ7htU27jGdbr1hAdcV kjnOKYcWSNH2Af3JMa46deOkEizpTR7rUzCHj9A5HFxixqInvJBlguNcmErWnlJnn6hL twxPJKwcC0PHXmErQCAMMjKbzmeFDdegz4yC2WXFIs9xdQVxZLZjNN6Iy3TuirZ0z4ll xjtht5bw/M5Z834T0N9HhCpTdSUskQGUblJqXZpwwDdbeJFwMuAzFAtzIGyb4q4NBQEd Zp/vsI6YqU9dO5uhox87W6WNCGBPhBmAm2kf2iJko/Wkf8l5UEQuSf/COTfzUDa9ePw5 W/Cw== 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:arc-authentication-results; bh=bMSA2JgMk6TcdOuFMAf/MvUXNmrYQQtaVYyqyfZQCa4=; b=w8BYw6SfVTfnSMNcgHluHi1fVw1YRpQWh8bAFc89INTMC/I1wBxGOmEYy3vU6uFTtJ pVng3jb3VRtiSHGJK2tMMcvFILJQ1jndCwkMI9WWTIj0jKAzG9OdaWGp+4j9aA6t1YKZ kljD/WWZf8NW5QjrG0hTCbUSsg4dAKjRS/cj8W7ncVLYKFK+ZlUpWz0w97FqXldEQNUO d4Ou4iAipOm+tGb6Nx1qcRT7sOVAxv8f49cPH9JOaQmTiM8NN4FJONAUxT+XEOgz5mZD NAxCB80zRKquk66Yi3fvJ87HDl1nL/pL6AUHrT0Jx0tfrvK19yvdOI1R6sZTz+iC1biH ywlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Xw1TwGVd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y81-v6si6840988qkg.368.2018.06.09.20.06.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:06:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Xw1TwGVd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg9-0004Q1-3v for patch@linaro.org; Sat, 09 Jun 2018 23:06:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqct-0001bp-2V for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqcr-0003AA-NZ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:43 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:40575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqcr-00039t-Fe for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:41 -0400 Received: by mail-pf0-x242.google.com with SMTP id z24-v6so8489912pfe.7 for ; Sat, 09 Jun 2018 20:02: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=bMSA2JgMk6TcdOuFMAf/MvUXNmrYQQtaVYyqyfZQCa4=; b=Xw1TwGVdSWtARBP4Ete1PBOKJ7vYbJN1rXElboVB6nhzrChpu3MDn28jXh6v1ETRH2 ZmV9Bu+dsArGMRJtrBtLyAd4rCZTk4fnycA3Y8VcEmxXIBjhNypozu4Dzk2Y6hc0Eybk zWBjp6phey0rHs4xqicFWHfeD5D35E8or+H/4= 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=bMSA2JgMk6TcdOuFMAf/MvUXNmrYQQtaVYyqyfZQCa4=; b=a+FoPUVs01Mcesg/6r2q4YAW+x21HZyFoFF8s6WgXtibY299PiDV86+xnKlUEvZy3Q KQHDlvOc4mx9rIDWIBN3KaXgKTz4rPofHEn+UeVql+XF4x6aJyqvEQUrEHzPTxj9dTlm z0fxBLeLoouEzux8sVi0EO8PwdGC6sJRdwQEKpaa+g/kjcxPXrIFW5rzpEMsEAI2rzej 0fY1g2VEJ9fgaYiacs8BDHAROB61CP7owMezoDgS4XCTkSRc7ReJgHkUy6NI00RnKjSH ogyEsxmGtwbG4nUZKLgrcC9vLGKuM6TK5vyPbuQM/cnzGfAms5NfGpPCIle+tNQLgKED LVpw== X-Gm-Message-State: APt69E2/2GAUXNtJg3nmXGqGqTHdEDmQP5NtBPc1+7OY5I0bu2KmWcP1 hFeiRjlSkRpbLyN7gkcgn5QNiDgamcE= X-Received: by 2002:a65:5c89:: with SMTP id a9-v6mr10219060pgt.51.1528599760060; Sat, 09 Jun 2018 20:02:40 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:38 -1000 Message-Id: <20180610030220.3777-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 006/108] linux-user: Propagate goto unimplemented to default 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 point in listing a syscall if you want the same effect as not listing it. In one less trivial case, the goto was demonstrably not reachable. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 144 +------------------------------------------ 1 file changed, 1 insertion(+), 143 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 06205d3d65..5a17803732 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8297,14 +8297,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(chmod(p, arg2)); unlock_user(p, arg1, 0); return ret; -#endif -#ifdef TARGET_NR_break - case TARGET_NR_break: - goto unimplemented; -#endif -#ifdef TARGET_NR_oldstat - case TARGET_NR_oldstat: - goto unimplemented; #endif case TARGET_NR_lseek: return get_errno(lseek(arg1, arg2, arg3)); @@ -8390,16 +8382,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(stime(&host_time)); } #endif - case TARGET_NR_ptrace: - goto unimplemented; #ifdef TARGET_NR_alarm /* not on alpha */ case TARGET_NR_alarm: return alarm(arg1); #endif -#ifdef TARGET_NR_oldfstat - case TARGET_NR_oldfstat: - goto unimplemented; -#endif #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: if (!block_signals()) { @@ -8470,14 +8456,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif -#ifdef TARGET_NR_stty - case TARGET_NR_stty: - goto unimplemented; -#endif -#ifdef TARGET_NR_gtty - case TARGET_NR_gtty: - goto unimplemented; -#endif #ifdef TARGET_NR_access case TARGET_NR_access: if (!(p = lock_user_string(arg1))) { @@ -8499,10 +8477,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_nice /* not on alpha */ case TARGET_NR_nice: return get_errno(nice(arg1)); -#endif -#ifdef TARGET_NR_ftime - case TARGET_NR_ftime: - goto unimplemented; #endif case TARGET_NR_sync: sync(); @@ -8616,14 +8590,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = host_to_target_clock_t(ret); } return ret; -#ifdef TARGET_NR_prof - case TARGET_NR_prof: - goto unimplemented; -#endif -#ifdef TARGET_NR_signal - case TARGET_NR_signal: - goto unimplemented; -#endif case TARGET_NR_acct: if (arg1 == 0) { ret = get_errno(acct(NULL)); @@ -8642,31 +8608,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(umount2(p, arg2)); unlock_user(p, arg1, 0); return ret; -#endif -#ifdef TARGET_NR_lock - case TARGET_NR_lock: - goto unimplemented; #endif case TARGET_NR_ioctl: return do_ioctl(arg1, arg2, arg3); #ifdef TARGET_NR_fcntl case TARGET_NR_fcntl: return do_fcntl(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_mpx - case TARGET_NR_mpx: - goto unimplemented; #endif case TARGET_NR_setpgid: return get_errno(setpgid(arg1, arg2)); -#ifdef TARGET_NR_ulimit - case TARGET_NR_ulimit: - goto unimplemented; -#endif -#ifdef TARGET_NR_oldolduname - case TARGET_NR_oldolduname: - goto unimplemented; -#endif case TARGET_NR_umask: return get_errno(umask(arg1)); case TARGET_NR_chroot: @@ -8675,10 +8625,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_ustat - case TARGET_NR_ustat: - goto unimplemented; -#endif #ifdef TARGET_NR_dup2 case TARGET_NR_dup2: ret = get_errno(dup2(arg1, arg2)); @@ -9386,10 +9332,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif -#ifdef TARGET_NR_oldlstat - case TARGET_NR_oldlstat: - goto unimplemented; -#endif #ifdef TARGET_NR_readlink case TARGET_NR_readlink: { @@ -9443,10 +9385,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif -#ifdef TARGET_NR_uselib - case TARGET_NR_uselib: - goto unimplemented; -#endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) @@ -9468,10 +9406,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_readdir - case TARGET_NR_readdir: - goto unimplemented; -#endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \ @@ -9588,10 +9522,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_setpriority: return get_errno(setpriority(arg1, arg2, arg3)); -#ifdef TARGET_NR_profil - case TARGET_NR_profil: - goto unimplemented; -#endif case TARGET_NR_statfs: if (!(p = lock_user_string(arg1))) { return -TARGET_EFAULT; @@ -9659,10 +9589,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; #endif -#ifdef TARGET_NR_ioperm - case TARGET_NR_ioperm: - goto unimplemented; -#endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: return do_socketcall(arg1, arg2); @@ -9880,20 +9806,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } return ret; -#ifdef TARGET_NR_olduname - case TARGET_NR_olduname: - goto unimplemented; -#endif -#ifdef TARGET_NR_iopl - case TARGET_NR_iopl: - goto unimplemented; -#endif case TARGET_NR_vhangup: return get_errno(vhangup()); -#ifdef TARGET_NR_idle - case TARGET_NR_idle: - goto unimplemented; -#endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, @@ -10069,8 +9983,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_modify_ldt: return do_modify_ldt(cpu_env, arg1, arg2, arg3); #if !defined(TARGET_X86_64) - case TARGET_NR_vm86old: - goto unimplemented; case TARGET_NR_vm86: return do_vm86(cpu_env, arg1, arg2); #endif @@ -10107,35 +10019,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } return ret; #endif -#ifdef TARGET_NR_create_module - case TARGET_NR_create_module: -#endif - case TARGET_NR_init_module: - case TARGET_NR_delete_module: -#ifdef TARGET_NR_get_kernel_syms - case TARGET_NR_get_kernel_syms: -#endif - goto unimplemented; - case TARGET_NR_quotactl: - goto unimplemented; case TARGET_NR_getpgid: return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: return get_errno(fchdir(arg1)); -#ifdef TARGET_NR_bdflush /* not on x86_64 */ - case TARGET_NR_bdflush: - goto unimplemented; -#endif -#ifdef TARGET_NR_sysfs - case TARGET_NR_sysfs: - goto unimplemented; -#endif case TARGET_NR_personality: return get_errno(personality(arg1)); -#ifdef TARGET_NR_afs_syscall - case TARGET_NR_afs_syscall: - goto unimplemented; -#endif #ifdef TARGET_NR__llseek /* Not on alpha */ case TARGET_NR__llseek: { @@ -10648,14 +10537,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } return ret; -#ifdef TARGET_NR_query_module - case TARGET_NR_query_module: - goto unimplemented; -#endif -#ifdef TARGET_NR_nfsservctl - case TARGET_NR_nfsservctl: - goto unimplemented; -#endif case TARGET_NR_prctl: switch (arg1) { case PR_GET_PDEATHSIG: @@ -10734,7 +10615,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_I386) && !defined(TARGET_ABI32) return do_arch_prctl(cpu_env, arg1, arg2); #else - goto unimplemented; +#error unreachable #endif #endif #ifdef TARGET_NR_pread64 @@ -10882,21 +10763,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } #endif -#else - case TARGET_NR_sendfile: -#ifdef TARGET_NR_sendfile64 - case TARGET_NR_sendfile64: -#endif - goto unimplemented; -#endif - -#ifdef TARGET_NR_getpmsg - case TARGET_NR_getpmsg: - goto unimplemented; -#endif -#ifdef TARGET_NR_putpmsg - case TARGET_NR_putpmsg: - goto unimplemented; #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: @@ -11439,9 +11305,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_setfsgid32: return get_errno(setfsgid(arg1)); #endif - - case TARGET_NR_pivot_root: - goto unimplemented; #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { @@ -11599,10 +11462,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* self-modifying code is handled automatically, so nothing needed */ return 0; #endif -#ifdef TARGET_NR_security - case TARGET_NR_security: - goto unimplemented; -#endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: return TARGET_PAGE_SIZE; @@ -12562,7 +12421,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif default: - unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); return -TARGET_ENOSYS; } From patchwork Sun Jun 10 03:00:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138077 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2573876lji; Sat, 9 Jun 2018 20:03:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIAJedP+D+2r5kkY3PBXD9ePr6rpSi5xv0+qH/ecrSM8a8mCId5ck0egzbufrf+2oX3Nm87 X-Received: by 2002:ac8:2a96:: with SMTP id b22-v6mr11688792qta.415.1528599796956; Sat, 09 Jun 2018 20:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528599796; cv=none; d=google.com; s=arc-20160816; b=TerIDkDc5GT2gdviwXqS5qZEQjPEHHm84DaE1fAIX7JHDHJmTlH6zLXAh7AoZAH/E4 bCshNv4khm4x26yGTaWUqgPUTds1fTrbo5iSdRAIuTc8qrq64eB0sqrjJbic3sWiccyt XRU9m1d2Z3v3UxvVjfXagwpxdlM0QUfNSOmmS+9+ju7t4Ov2kMcFErgEB+0dZcUIekXo p+jOtHV41aspsHHO7x95BgVXpL28wD1cu9l7I/Sh8LpaIiYCJ8j65otnQpGHb22pAZI9 fw/6UJxZTMkv+9GHujf84XFOmrjr1F4xrI007RCLFkTZvgWzPPmj9mCL4NU3caMTjHIt mcIw== 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:arc-authentication-results; bh=w3OhhwzXmiCocExQ6RAX8gk5UKnmzB9QSB7Nc++/r+4=; b=EJFVeAf8sCttH3/4WT2vWblo7+7ECrxW1nenkLSkwJ83nJcaZE4B3eFBY3ePHm5ZJ6 aunroeGU9+xQguP7eeX61edg17DoswS606qo3ZRgqgZ+O6q0NnW5R168oy8x6zFUx9Tu B1VUCAVx2Wv4tvsxgcnyt80lBPbnvk23z7Qi0CMxhXgq7TmZuUJc/nGYdIxftZMCoRrE V01woLQV3T/2TKihGmavhFZsdS3vJ6n4DjCFtodB5H6CdLH44cAclpWH9dA5/5OSPpPd BMc+R7ntJEOAFHFTk8X3x4kN8d5CiqHQ8opbgbMHrIMTqcXa9/DGWJ4SEXjRexpJVJkk MAjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=boaJHFjO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k72-v6si1011901qkh.83.2018.06.09.20.03.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:03:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=boaJHFjO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdQ-0001g4-CQ for patch@linaro.org; Sat, 09 Jun 2018 23:03:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcu-0001db-Tj for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqct-0003Ag-NB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:44 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:40738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqct-0003AO-EX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:43 -0400 Received: by mail-pg0-x230.google.com with SMTP id l2-v6so8127019pgc.7 for ; Sat, 09 Jun 2018 20:02: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=w3OhhwzXmiCocExQ6RAX8gk5UKnmzB9QSB7Nc++/r+4=; b=boaJHFjOieYsw1Bkn0eQsrWjzpc0XhWSmRKbONWpSbe9MTQXVnfl5F7+jJNW/PZ/c6 RFNVLiCdtVul+e0US4065gaczx63qfGDQjkkvP/AcvYo7WKnOLoJ8MxvB/Debp5gwEtH ylaay2qwxkCXFhSDBeuzt6FKVmhVsNVgsVg6c= 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=w3OhhwzXmiCocExQ6RAX8gk5UKnmzB9QSB7Nc++/r+4=; b=G8GfZ/P3LJvMkg3utle/IlZ/d7wBo1nNB/J7JIxcKiHVuVmAi0BuTTOL4vOiZqkjxK ULFMhzZ0sMMqI6TbFTHVUKNlj6fvvPjlSSsgss8nHH2i0tTry5utV4DIDyvH7jWMayoH wHrRNeXI5qvRGkrzealkG0Xs9PKDJ/fmwo5N8/1llQdwmffbfMahbTYK8ICLEGmqqJIA +sgvztBT22i8zmiXkeVXY2A7IDfPECI2trbwpFhhoqjltCgaa4IlV3QnE3+Tly8Hs6UE 6zLCCKScm0YcaZx+BO0pD2rqegkyMzB9Vk/HImpzNHWbdzKH4IgEO1Vwfz8UKwaXs/bS vg6g== X-Gm-Message-State: APt69E3gdaPFvkfoPdMud/wU3etZJ1SagvJj4zPVryy0atTK8g9UcWab 7SOiPxUmgoCsdZK51mLvFly6Gniy51s= X-Received: by 2002:a63:5ec4:: with SMTP id s187-v6mr10207019pgb.72.1528599762153; Sat, 09 Jun 2018 20:02:42 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:39 -1000 Message-Id: <20180610030220.3777-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::230 Subject: [Qemu-devel] [PATCH v2 007/108] linux-user: Propagate goto fail to return 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" Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 60 ++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 38 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5a17803732..fd8d48b0da 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8865,8 +8865,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how = SIG_SETMASK; break; default: - ret = -TARGET_EINVAL; - goto fail; + return -TARGET_EINVAL; } mask = arg2; target_to_host_old_sigset(&set, &mask); @@ -8893,8 +8892,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how = SIG_SETMASK; break; default: - ret = -TARGET_EINVAL; - goto fail; + return -TARGET_EINVAL; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) return -TARGET_EFAULT; @@ -8937,8 +8935,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how = SIG_SETMASK; break; default: - ret = -TARGET_EINVAL; - goto fail; + return -TARGET_EINVAL; } if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1))) return -TARGET_EFAULT; @@ -9227,15 +9224,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n); if (ret) { - goto fail; + return ret; } ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n); if (ret) { - goto fail; + return ret; } ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n); if (ret) { - goto fail; + return ret; } /* @@ -9268,8 +9265,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, sig.set = &set; if (arg_sigsize != sizeof(*target_sigset)) { /* Like the kernel, we enforce correct size sigsets */ - ret = -TARGET_EINVAL; - goto fail; + return -TARGET_EINVAL; } target_sigset = lock_user(VERIFY_READ, arg_sigset, sizeof(*target_sigset), 1); @@ -9700,17 +9696,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */ case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */ { - ret = -TARGET_EINVAL; if (len < 0) { - goto fail; + return -TARGET_EINVAL; } if (len == 0) { return 0; } p = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!p) { - ret = -TARGET_EFAULT; - goto fail; + return -TARGET_EFAULT; } ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); unlock_user(p, arg2, arg3); @@ -10056,8 +10050,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, dirp = g_try_malloc(count); if (!dirp) { - ret = -TARGET_ENOMEM; - goto fail; + return -TARGET_ENOMEM; } ret = get_errno(sys_getdents(arg1, dirp, count)); @@ -10456,7 +10449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg2 ? &node : NULL, NULL)); if (is_error(ret)) { - goto fail; + return ret; } if (arg1 && put_user_u32(cpu, arg1)) { return -TARGET_EFAULT; @@ -10903,8 +10896,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1); if (!target_grouplist) { - ret = -TARGET_EFAULT; - goto fail; + return -TARGET_EFAULT; } for (i = 0; i < gidsetsize; i++) { grouplist[i] = low2highgid(tswapid(target_grouplist[i])); @@ -11162,8 +11154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how = SIG_SETMASK; break; default: - ret = -TARGET_EINVAL; - goto fail; + return -TARGET_EINVAL; } mask = arg2; target_to_host_old_sigset(&set, &mask); @@ -11211,8 +11202,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); if (!target_grouplist) { - ret = -TARGET_EFAULT; - goto fail; + return -TARGET_EFAULT; } for(i = 0;i < ret; i++) target_grouplist[i] = tswap32(grouplist[i]); @@ -11232,8 +11222,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist = alloca(gidsetsize * sizeof(gid_t)); target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); if (!target_grouplist) { - ret = -TARGET_EFAULT; - goto fail; + return -TARGET_EFAULT; } for(i = 0;i < gidsetsize; i++) grouplist[i] = tswap32(target_grouplist[i]); @@ -11308,20 +11297,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { - void *a; - ret = -TARGET_ENOMEM; - a = lock_user(VERIFY_READ, arg1, arg2, 0); + void *a = lock_user(VERIFY_READ, arg1, arg2, 0); if (!a) { - goto fail; + return -TARGET_ENOMEM; } - ret = -TARGET_EFAULT; p = lock_user_string(arg3); if (!p) { - goto mincore_fail; + ret = -TARGET_EFAULT; + } else { + ret = get_errno(mincore(a, arg2, p)); + unlock_user(p, arg3, ret); } - ret = get_errno(mincore(a, arg2, p)); - unlock_user(p, arg3, ret); - mincore_fail: unlock_user(a, arg1, 0); } return ret; @@ -11787,8 +11773,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); else { if (!(p = lock_user_string(arg2))) { - ret = -TARGET_EFAULT; - goto fail; + return -TARGET_EFAULT; } ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); unlock_user(p, arg2, 0); @@ -12424,7 +12409,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, gemu_log("qemu: Unsupported syscall: %d\n", num); return -TARGET_ENOSYS; } -fail: return ret; } From patchwork Sun Jun 10 03:00:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138082 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2576978lji; Sat, 9 Jun 2018 20:08:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLxY+eHh/GiY3ogQSqg7uQeZj4zy+1tz+3VAP+ueSoBtOUTGyNOy97DoELT3U+hwwD2VkNN X-Received: by 2002:a0c:b176:: with SMTP id r51-v6mr10755551qvc.45.1528600107650; Sat, 09 Jun 2018 20:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600107; cv=none; d=google.com; s=arc-20160816; b=c6O+5GpsxWegak5Nl3ue/VxjvFs2hKu508uP8AtEpf281ccNd9JwIfOn35wM8N5Ryf 6jYK2krDpTcKmJvc3eMR1UITJ5ffXiJVqix5STb99xR9yO4hZ0lWp9kuYSMwEROsyHOc Hs6SYwbwSpCghJ6ltzLJ/yHiyrWTg5wUABj11X9dfedyBWuGObs49MNylMQELpnsqxGn hsOtxGFysIC9Okl3in0TLOUUlPXbbIH/G5kp7qDp/BjgFPDCOn571EiA3Yw7QHTht0E9 h2Arf7osJZR7Dld+cBu3b6Kp4d3Dji3vyiOCPhapO0YqzoxW4jvn4O87na0LmHTFZJP+ Y6aQ== 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:arc-authentication-results; bh=Jy8MfblGP5Ozmd8tz3QroxD7XAKcI8f15FrpZDq8KEE=; b=tupMqb04jdTmvdh2R4BlQDLY8UAH9ZxLY5ORW9FWDPwb7LNYoPToM7o5viK1jrXM74 15D+9p81ISA9eY7LROx+93fOiQ1u0L3L4+5hsG3J3D/idddbbAhU6v3J6OhkExbNOLsJ 6hk7lxvFdUylxaRBjXlqxwScMW6hceEGmtpHlfisJo3tUAsfpf7EOQ0Q/Uh7+UaWmIfY n+Brb96fESVR1kbmpYSlcu+1WbQc1lDuxmG6lapGiTZROQI7smeRUw+KcrBDPJioxlcI DlMA+E/KZCBI4xpj3bfNUA0d+7kapxpess/1hchBPI/i6bI/BA/35k+9oKT9JguPAnNO OdKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BmX6GPPY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h7-v6si4803807qvj.54.2018.06.09.20.08.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:08:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BmX6GPPY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqiR-0006tr-3r for patch@linaro.org; Sat, 09 Jun 2018 23:08:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcw-0001f5-F3 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqcv-0003BR-HD for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:46 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:35257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqcv-0003BB-C6 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:45 -0400 Received: by mail-pg0-x231.google.com with SMTP id 15-v6so8138103pge.2 for ; Sat, 09 Jun 2018 20:02: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=Jy8MfblGP5Ozmd8tz3QroxD7XAKcI8f15FrpZDq8KEE=; b=BmX6GPPYQ5qjlmX5KhonkvmlYlF1K0egps2IE/WSwQaNbiK+YBT9udp/i6RSJRF02e fO66KM6RVuKrrTtk7Pt8nxgsSs398NF67Ik2SoYjnu6BUV/1ISGKxDalzfgXwZLndlZv 1MMp6NA2U+XXijW+VLgOlfFTjZujKE0O8nbGI= 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=Jy8MfblGP5Ozmd8tz3QroxD7XAKcI8f15FrpZDq8KEE=; b=IQ+2vHdvLoMEkQeNN3uhT0rClRIdJy3ehoNB2RGRyTpX3IrK0XKWui0jFO/BFWfz2E faT3v3DjF2X2soW1ZsYaT1+e2hvY3REPhsYhaVgXpsbPwETPnv8DYrUvGnz7Jt2aDM/J ylGHyWJE8wlrlw2ZdnIzl2GrZitOH2V8eOA6cv1rsA7hXG4BZ3ktMEd0AmOqWu/0YVpy yQ5X1u6HpdbQ4FwQgIPIIea++7ytKvwLtja4iDpRkZFHQNMHa0dYwehwHz6Ff6edsMnP Pyubv0r90QcImWs42jxiHvSVNr3ygn9RyQrAP6EMDrm9Litvq3jNauwiyanaTpbC6gf+ DeUw== X-Gm-Message-State: APt69E0BDSgKbJlnZGPsMBkEpdY8/yyHnj5K3ZXjlceGb9QdOewNsrqo TfhLP3PpvZ8EjJX6TdGaxmBN4Wa7oyM= X-Received: by 2002:a62:3c15:: with SMTP id j21-v6mr12214899pfa.7.1528599764038; Sat, 09 Jun 2018 20:02:44 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:40 -1000 Message-Id: <20180610030220.3777-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::231 Subject: [Qemu-devel] [PATCH v2 008/108] linux-user: Make syscall number unsigned 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" Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/qemu.h | 2 +- linux-user/syscall.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 6fa1e968db..c628a5a05c 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -201,7 +201,7 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src, void target_set_brk(abi_ulong new_brk); abi_long do_brk(abi_ulong new_brk); void syscall_init(void); -abi_long do_syscall(void *cpu_env, int num, abi_long arg1, +abi_long do_syscall(void *cpu_env, unsigned 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); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fd8d48b0da..46f123ee13 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -719,20 +719,20 @@ static inline int next_free_host_timer(void) /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ #ifdef TARGET_ARM -static inline int regpairs_aligned(void *cpu_env, int num) +static inline int regpairs_aligned(void *cpu_env, unsigned 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; } +static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 1; } #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; } +static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 1; } #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) +static inline int regpairs_aligned(void *cpu_env, unsigned num) { switch (num) { case TARGET_NR_pread64: @@ -744,9 +744,9 @@ static inline int regpairs_aligned(void *cpu_env, int num) } } #elif defined(TARGET_XTENSA) -static inline int regpairs_aligned(void *cpu_env, int num) { return 1; } +static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 1; } #else -static inline int regpairs_aligned(void *cpu_env, int num) { return 0; } +static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 0; } #endif #define ERRNO_TABLE_SIZE 1200 @@ -7952,7 +7952,7 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask, * of syscall results, can be performed. * All errnos that do_syscall() returns must be -TARGET_. */ -static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, +static abi_long do_syscall1(void *cpu_env, unsigned 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) @@ -12412,7 +12412,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } -abi_long do_syscall(void *cpu_env, int num, abi_long arg1, +abi_long do_syscall(void *cpu_env, unsigned 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) From patchwork Sun Jun 10 03:00:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138080 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2575495lji; Sat, 9 Jun 2018 20:05:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1AXHR8RR7OsBcEpEDw+cpDMhqHQPsTcA24kx2hXqJXA0Zs/26gpTDLNDKQXKxiw9d8Ssf X-Received: by 2002:a37:10c4:: with SMTP id 65-v6mr10506284qkq.31.1528599952578; Sat, 09 Jun 2018 20:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528599952; cv=none; d=google.com; s=arc-20160816; b=yxvaXjUDjVc0RIyySYIOsAtsBgCzCw3yCdZsmkuC0kb/28i1ERG6HExFw8269UmluO uPcHmZfbvw12NDyoedsHfKPDJpc2StCPAAl6LiwiQ3vhTT/mfrTuMyW+8IBE9Ox1F9Mp n93wWcmXDu8ko7FWX2ffzxooUyG2XVBv1PuDVaFeJJYQWP6vha/I7UD9NWdeT+lqCanP jCxNMn0LxnF+5adTlc/8d/bK1SAGYVj33sZElDyLWY8LORGHZzsUAPBGuZ8NfTHkVVv9 AOjIIgtkO/LcbIPq9p9+WZjME39F3OjuIXqprkBBPIkLtte20h/p25sG0SxpVL67UXm9 uvqw== 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:arc-authentication-results; bh=hpaNMq1/oP2oPA//8l/SAajHBioV4Zg1sXyd+VtOq8c=; b=c9SJpQQ5ei23uGzSMSQ52QbtjZwsHFLA34EWNu90rsqBL9po4hYVFWAvvX+X4fv4EI sFJvxpdIedvkIt/AVzBAa8W0VjhbSTiKSbZshD0UO1VHF9k/NA6JqhqerVJNpj8am9HZ ieU+1rGwfACsuMpEchDjiq8EOhiioZ4dcIIxYggAJgI9L6RNvppZNUoO7pD9OtcV6QWm 0haAQ11jIvqQvcDQa98cSFkThRpTKIoos8zdIGHTM1sI2kobkpAo8KnBcBgUxUsKE8iZ ua4lPnjYqkcF7IKW/vKEqpBxh6TZOJPxHZKKXmjZip9DChIYI2VJDe6nopzK/eK4myHn gD/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WQMRrScF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h15-v6si958000qta.82.2018.06.09.20.05.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WQMRrScF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfw-00048u-27 for patch@linaro.org; Sat, 09 Jun 2018 23:05:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd0-0001jk-Mv for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqcx-0003C9-Jh for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:50 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:44838) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqcx-0003Bm-Bp for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:47 -0400 Received: by mail-pg0-x242.google.com with SMTP id p21-v6so8127188pgd.11 for ; Sat, 09 Jun 2018 20:02: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=hpaNMq1/oP2oPA//8l/SAajHBioV4Zg1sXyd+VtOq8c=; b=WQMRrScFtJ5rsj1a/+H/GziNQIAHADXJN6DXxsvEjwHdGINrUgv8NP3yPHWFTnNz/H ekqijGbfe0eg68cfKJo5ilytRgRAxYe8juHWi7zxRGpm4+TQHz3g70InFXGk74VXz0+z gxNyxqEb+laQnuVwWeyl+ilJyKVC5GoSiDl1g= 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=hpaNMq1/oP2oPA//8l/SAajHBioV4Zg1sXyd+VtOq8c=; b=SgmkqymgBEgqnp0Ki2FaoikSY66zgsOGTLUvmlZZnlN5yajOt1ydqrjKr0qUzF1fFg nPj46NgWEhYRojijta/DPwjOKOudTTMxvy1P+1xoAjV1d3ZWrgfWxMxFpyjeU76f+2/4 43TwWPCSbodtxHUDn6IIxvg9OekuMk51IfR+8FZaTCt50/xrn8XfQyKC2oFjsq/aQBeI Cvvxo0y0qKHxB5xYHRHeTlstamLRzqW5jSduH+ewWzpH5Iauw0zzyr6+HlxZx38+am4R Bsm323NShlC39yekF3fXuWDZ52JRvaeGVA5aiOlMPEDDsGeA4ef93GWbFsuFVeyOynoB lxqA== X-Gm-Message-State: APt69E2q9RzKev3y/LV3Sm0/jYSMPD458SVyy2DCH9xOkliPnMkg9q6v SCLkAzeRzYl5CfNVesL5Rxd0oAIJK5Q= X-Received: by 2002:a62:234a:: with SMTP id j71-v6mr11935177pfj.221.1528599766091; Sat, 09 Jun 2018 20:02:46 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:41 -1000 Message-Id: <20180610030220.3777-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 009/108] linux-user: Set up infrastructure for table-izing 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" At the same time, split out set_robust_list and get_robust_list. Put them together, along with their block comment, at the top of syscall_table. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 87 +++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 46f123ee13..8678e749ee 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7947,6 +7947,17 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask, return 0; } +typedef abi_long impl_fn(void *cpu_env, unsigned 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); + +#define IMPL(NAME) \ +static abi_long impl_##NAME(void *cpu_env, unsigned 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) + /* This is an internal helper for do_syscall so that it is easier * to have a single return point, so that actions, such as logging * of syscall results, can be performed. @@ -11740,23 +11751,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, return get_errno(safe_tgkill((int)arg1, (int)arg2, target_to_host_signal(arg3))); -#ifdef TARGET_NR_set_robust_list - case TARGET_NR_set_robust_list: - case TARGET_NR_get_robust_list: - /* The ABI for supporting robust futexes has userspace pass - * the kernel a pointer to a linked list which is updated by - * userspace after the syscall; the list is walked by the kernel - * when the thread exits. Since the linked list in QEMU guest - * memory isn't a valid linked list for the host and we have - * no way to reliably intercept the thread-death event, we can't - * support these. Silently return ENOSYS so that guest userspace - * falls back to a non-robust futex implementation (which should - * be OK except in the corner case of the guest crashing while - * holding a mutex that is shared with another process via - * shared memory). - */ - return -TARGET_ENOSYS; -#endif #if defined(TARGET_NR_utimensat) case TARGET_NR_utimensat: @@ -12412,6 +12406,54 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, return ret; } +/* The default action for a syscall not listed in syscall_table is to + * log the missing syscall. If a syscall is intentionally emulated as + * not present, then list it with impl_enosys as the implementation, + * which will avoid the logging. + */ +IMPL(enosys) +{ + return -TARGET_ENOSYS; +} + +/* For a given syscall number, return a function implementing it. + * Do this via switch statement instead of table because some targets + * do not begin at 0 and others have a large split in the middle of + * the numbers. The compiler should be able to produce a dense table. + */ +static impl_fn *syscall_table(unsigned num) +{ +#define SYSCALL_WITH(X, Y) case TARGET_NR_##X: return impl_##Y +#define SYSCALL(X) SYSCALL_WITH(X, X) + + switch (num) { + /* The ABI for supporting robust futexes has userspace pass + * the kernel a pointer to a linked list which is updated by + * userspace after the syscall; the list is walked by the kernel + * when the thread exits. Since the linked list in QEMU guest + * memory isn't a valid linked list for the host and we have + * no way to reliably intercept the thread-death event, we can't + * support these. Silently return ENOSYS so that guest userspace + * falls back to a non-robust futex implementation (which should + * be OK except in the corner case of the guest crashing while + * holding a mutex that is shared with another process via + * shared memory). + */ + SYSCALL_WITH(get_robust_list, enosys); + SYSCALL_WITH(set_robust_list, enosys); + + /* + * Other syscalls listed in collation order, with '_' ignored. + */ + } + +#undef SYSCALL +#undef SYSCALL_WITH + + /* After do_syscall1 is fully split, this will be impl_enosys. */ + return do_syscall1; +} + abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6, abi_long arg7, @@ -12419,6 +12461,7 @@ abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1, { CPUState *cpu = ENV_GET_CPU(cpu_env); abi_long ret; + impl_fn *fn; #ifdef DEBUG_ERESTARTSYS /* Debug-only code for exercising the syscall-restart code paths @@ -12437,14 +12480,16 @@ abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1, trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + fn = syscall_table(num); + 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); + ret = fn(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); + ret = fn(cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); } trace_guest_user_syscall_ret(cpu, num, ret); From patchwork Sun Jun 10 03:00:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138085 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2578289lji; Sat, 9 Jun 2018 20:10:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJ5tpzOmcFG3ZMEpbrlPnUupNca4wRa6xCB7z7KJ93J0OpMn4Ov4wb17GdRsvFqn+zjoDv X-Received: by 2002:a37:97c4:: with SMTP id z187-v6mr10532361qkd.196.1528600246284; Sat, 09 Jun 2018 20:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600246; cv=none; d=google.com; s=arc-20160816; b=ua/torUoFL/WKTc4S4A9doo7EfkrtDX53thqGhn5TYUg5RuGDSokUZFUfHhgnEcw/o euvcfPooLPORlvZsi5g/X+iSkj04lQwy8SNXYFZoFTZxF3P3FM+Mk3en8lTHapux7Vn7 dA08uWVUjjo39YzBjyejCSHmKE8E1xI7TvyalIPZvnhid3iEzvFXWqfHz3uUeUboJRRx 8dQx4JYNTJsXnLLuDhKTS8n/fpHB+PjOS1esr/FX+AFtbYpKz7KkbWg7Pqx6iq9WxOsx pn8Pupnkh6BHFbvG2E3J1luVbx5KFtzzCLv2jv8bFbDps0OamVXGpxESpo81MihMMpC2 VqWg== 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:arc-authentication-results; bh=v1gmxYTvtFoZy+0ESibyvIay/GhgpSmkgy8un55ftVc=; b=QXay66PwIxe25Vf9k2uY6pCDkChmRjhQCN03LBjsAsTn9E3GPmwE7gtHJR7LOgByGr ybyKAbuhtkyQbgLUrDDU78zwo+NZ4+Gj++tFg+al00HQme42wipFhUazsv5AuhgMNGdr Zolsd95a6m7kT394fvHZeLTrhVjAhJrfhQuBh8uuUyxwyed+FtdQXbRH0w0sOX25y/7c b3kmi6QyVjPuSm7mimZrUtcU+rtgi4kI1sIaA+qsLX6ihaYkhij66+Fjhd/F0K6/HgZF PvaCCKPXtvYrH4lzuIozOVksDZ4Q+WzHyJFxUOl0NRGdLsaGAJYbXBdjL3u/mb3vo96m tcvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dk+4yK8r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r7-v6si8371998qkk.85.2018.06.09.20.10.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:10:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dk+4yK8r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqkf-0000cX-Kf for patch@linaro.org; Sat, 09 Jun 2018 23:10:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd0-0001jj-My for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqcz-0003Ck-Fu for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:50 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqcz-0003CU-8M for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:49 -0400 Received: by mail-pf0-x242.google.com with SMTP id a63-v6so8498419pfl.1 for ; Sat, 09 Jun 2018 20:02: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=v1gmxYTvtFoZy+0ESibyvIay/GhgpSmkgy8un55ftVc=; b=dk+4yK8rgv2cYm/wiuDocbPxpJxr7yNmS1qGzizWAV9giKekBCPf9ir6tFbmkj5hOo O3xklsH7Ns4I2kanf00uvvPO70+eSt16r0pIatyjacPzDfgdJuC5H5p312O+zzCXEU1Z kotcNHcoHBJUMKdCZ/db9TfeXbWzjymWSMFSI= 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=v1gmxYTvtFoZy+0ESibyvIay/GhgpSmkgy8un55ftVc=; b=PsFYEOxqq4xGUz9eEpR00R99Ij9GYnIFjGqOUY8J9CnGeoQIJwxNXyoGrTq2UAtX3p OWgHsOiMCHK6o8urT9DIvKCReKv8HwHw5owYoAbglGkGzYJ2tafhYdBKR0vqy8CrmalR DYwYeZ9OJAkIABE7mFf9YmI8PP4jagNNXsOWYyA281rHyliO86mRNJtk4u7mMsjBcK2H Q9+9wl1OaZeZhnmk+RciVMb4CDb855dySFA8LAFZsemHUHWU21ebT0Unfrc/7nQT44nV R7n2pGAiBQ+IpHwPBUmyg8xIsfoef3T+PQI7YDci48CfVpKOaEIL+jn+gQIWhL7phDVX /rNA== X-Gm-Message-State: APt69E0j/WdrGS71F5hlQzQcRAYNAxfevsAX4mSSGM4r1Bk9VSe1Q7EO gdsrcex8ECne1VM2KJAn2L6I4BvvRUA= X-Received: by 2002:a63:83c3:: with SMTP id h186-v6mr10116244pge.298.1528599767997; Sat, 09 Jun 2018 20:02:47 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:42 -1000 Message-Id: <20180610030220.3777-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 010/108] linux-user: Split out brk, close, exit, 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" These are relatively simple unconditionally defined syscalls. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 179 ++++++++++++++++++++++++------------------- 1 file changed, 102 insertions(+), 77 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8678e749ee..6d2f9915ec 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7958,6 +7958,103 @@ static abi_long impl_##NAME(void *cpu_env, unsigned num, abi_long arg1, \ abi_long arg5, abi_long arg6, abi_long arg7, \ abi_long arg8) +IMPL(brk) +{ + return do_brk(arg1); +} + +IMPL(close) +{ + fd_trans_unregister(arg1); + return get_errno(close(arg1)); +} + +IMPL(exit) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + + /* 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)) { + /* Remove the CPU from the list. */ + QTAILQ_REMOVE(&cpus, cpu, node); + cpu_list_unlock(); + + TaskState *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); + } else { + cpu_list_unlock(); + +#ifdef TARGET_GPROF + _mcleanup(); +#endif + gdb_exit(cpu_env, arg1); + _exit(arg1); + } + g_assert_not_reached(); +} + +IMPL(read) +{ + abi_long ret; + char *p; + + if (arg3 == 0) { + return 0; + } + p = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!p) { + 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; +} + +IMPL(write) +{ + abi_long ret; + char *p; + + p = lock_user(VERIFY_READ, arg2, arg3, 1); + if (!p) { + 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, ret); + return ret; +} + /* This is an internal helper for do_syscall so that it is easier * to have a single return point, so that actions, such as logging * of syscall results, can be performed. @@ -7975,77 +8072,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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(&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(); -#ifdef TARGET_GPROF - _mcleanup(); -#endif - gdb_exit(cpu_env, arg1); - _exit(arg1); - return 0; /* avoid warning */ - case TARGET_NR_read: - if (arg3 == 0) { - return 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 (!(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; - #ifdef TARGET_NR_open case TARGET_NR_open: if (!(p = lock_user_string(arg1))) @@ -8077,12 +8103,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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 case TARGET_NR_fork: return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); @@ -12445,6 +12465,11 @@ static impl_fn *syscall_table(unsigned num) /* * Other syscalls listed in collation order, with '_' ignored. */ + SYSCALL(brk); + SYSCALL(close); + SYSCALL(exit); + SYSCALL(read); + SYSCALL(write); } #undef SYSCALL From patchwork Sun Jun 10 03:00:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138089 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2579485lji; Sat, 9 Jun 2018 20:12:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKwAr672qX9dJqD/qGx9pQ8zHXhDdEBHa5Xd1qbkNxm6HHQDfowJpfY60h3lC+nYDNFd6p3 X-Received: by 2002:ac8:2b46:: with SMTP id 6-v6mr6891508qtv.302.1528600375520; Sat, 09 Jun 2018 20:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600375; cv=none; d=google.com; s=arc-20160816; b=nSeMbMJCM0nYaXhIeJzFrka0BKlOQFKvQySBDe0+Dq2Cya5ONXCRo2zcb6/enakqfE kWf34w0TUiARJvlUZiyYISFaG5ZyBfH66Bj7vypP30vynzHVhMNViYJ08atHCcgBs62Z x8kw2eb+rF7I9GybaOhMoHrnp/PksBx3YTotqv9JrGsLTxuqkskvJJfdMpLustdjb/tc GSiULBPfv9ooN1+ao/TfAz3bexXlUqYXOEHkZksnRH4vXWiJeRasVzwxBDH4KgpQtSSh m8X3b3AUuzzcykiPmkRCNmanvbQ3qoafLzQ7N16i0mMq7DOe7jRiqwGKBYK8QaUYhQOI 9z4Q== 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:arc-authentication-results; bh=3OazyDaQ98WLzwavAlvx2ZeLx9Uw8bApVXczaU8PD30=; b=DqxLLB56IRo1WO916LuU/TB4Onb2gMIjmy0a/bAFDpcy/79oRMqKS25qW4jJQadCGL 6MiDzRuykIHGEURNXZba/khB6068KP9oxc0UqJxCjNO2fuMWpZYf1LUtoce2yHvz98pt UlEUWN7sBlrlyqr/28UF2y055ryAoBaMSnnYtS3KFptdhZxg6pyiyJVd/jGHx2j9e+Q2 WQXpOcEgWxhI4ujiQ5OY0QN25aIfLa1FLkj21TwnnKZiSMaN0PbxvhO0XuIukXyNYZ2Q GNXhUNdgi8PY4dAa8U5VVJ1cqzAiXwmCe9iDe/t5GSwgkL7ED3kjJvRLBGH/+k2A0/Lk HOuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c6CSBj9D; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t48-v6si384939qte.236.2018.06.09.20.12.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:12:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c6CSBj9D; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqmk-00025l-VO for patch@linaro.org; Sat, 09 Jun 2018 23:12:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd2-0001m1-RX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd1-0003DW-GK for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:52 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:33387) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd1-0003DC-8L for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:51 -0400 Received: by mail-pg0-x241.google.com with SMTP id e11-v6so8142360pgq.0 for ; Sat, 09 Jun 2018 20:02: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=3OazyDaQ98WLzwavAlvx2ZeLx9Uw8bApVXczaU8PD30=; b=c6CSBj9DgVXYSjdvVGiq8inDEp6NCZaDIyG4g1xZVY2I0kZcY7M5k3e/fZiEwuoFQY Yp98oTSUoQpl8ZhTR/st6U+4FRzZCrrFVFePwUnd87fTjuC7bAa0/LYosmbc0nA8SroD +AhKMycG3On4xxr5NqacIt9/KBk7Ymk8kN7I0= 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=3OazyDaQ98WLzwavAlvx2ZeLx9Uw8bApVXczaU8PD30=; b=hDUpnofJPjPoERwXcuu5qTXWmo/GyFLKeSG/pvxNE5uqClS4RJ/BQ++mmPHvfM5pa5 Zm7zaZPmn8KFXxC+DnTS2Ol6+C6JrK/3HFm9LTmduWW1A4jhrJAXoninfRa5XEPs5vaI nu+nR5XWp4X/e4K64ABPhDYQdRQWkUXeP3UdwhOiUf0pDzzHuwF6u3L3QLc46sLS92/S T1kiaSczDK+8DdjrwAMXHCxJXOkfGiu8wgRFW83MrGQOkVQG/Ql3Lz5vM32YskzX8rBG pW3aM5Pit8p0fOJSfi6MneC8We3QOLtSBOrXjEi06aAk9noMivtc4sr/pOzRA90eBWPi r+PA== X-Gm-Message-State: APt69E2fSd1imZe9k5Zb53BuOgRVmavcAoMaVZdSzuM91IDvbvu/QydO fOlG4m0LMSH8hf/pa2euLy4YGjnOVjw= X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr10420236pgp.221.1528599769977; Sat, 09 Jun 2018 20:02:49 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:43 -1000 Message-Id: <20180610030220.3777-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 011/108] 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" At the same time, fix the repeated re-reading of the argv and env arrays from guest memory. Instead read into a unified array once. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 203 ++++++++++++++++++++++--------------------- 1 file changed, 106 insertions(+), 97 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6d2f9915ec..aa6c4e1577 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7969,6 +7969,111 @@ IMPL(close) return get_errno(close(arg1)); } +IMPL(execve) +{ + abi_ulong *guest_ptrs; + char **host_ptrs; + int argc, envc, alloc, i; + abi_ulong gp; + abi_ulong guest_argp = arg2; + abi_ulong guest_envp = arg3; + char *filename; + abi_long ret; + + /* Initial estimate of number of guest pointers required. */ + alloc = 32; + guest_ptrs = g_new(abi_ulong, alloc); + + /* Iterate through argp and envp, counting entries, and + * reading guest addresses from the arrays. + */ + for (gp = guest_argp, argc = 0; gp; gp += sizeof(abi_ulong)) { + abi_ulong addr; + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + if (argc >= alloc) { + alloc *= 2; + guest_ptrs = g_renew(abi_ulong, guest_ptrs, alloc); + } + guest_ptrs[argc++] = addr; + } + for (gp = guest_envp, envc = 0; gp; gp += sizeof(abi_ulong)) { + abi_ulong addr; + if (get_user_ual(addr, gp)) { + return -TARGET_EFAULT; + } + if (!addr) { + break; + } + if (argc + envc >= alloc) { + alloc *= 2; + guest_ptrs = g_renew(abi_ulong, guest_ptrs, alloc); + } + guest_ptrs[argc + envc++] = addr; + } + + /* Exact number of host pointers required. */ + host_ptrs = g_new0(char *, argc + envc + 2); + + /* Iterate through the argp and envp that we already read + * and convert the guest pointers to host pointers. + */ + ret = -TARGET_EFAULT; + for (i = 0; i < argc; ++i) { + char *p = lock_user_string(guest_ptrs[i]); + if (!p) { + goto fini; + } + host_ptrs[i] = p; + } + for (i = 0; i < envc; ++i) { + char *p = lock_user_string(guest_ptrs[argc + i]); + if (!p) { + goto fini; + } + host_ptrs[argc + 1 + i] = p; + } + + /* Read the executable filename. */ + filename = lock_user_string(arg1); + if (!filename) { + goto fini; + } + + /* 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(filename, host_ptrs, host_ptrs + argc + 1)); + unlock_user(filename, arg1, 0); + + fini: + /* Deallocate everything we allocated above. */ + for (i = 0; i < argc; ++i) { + if (host_ptrs[i]) { + unlock_user(host_ptrs[i], guest_ptrs[i], 0); + } + } + for (i = 0; i < envc; ++i) { + if (host_ptrs[argc + 1 + i]) { + unlock_user(host_ptrs[argc + 1 + i], guest_ptrs[argc + i], 0); + } + } + g_free(host_ptrs); + g_free(guest_ptrs); + return ret; +} + IMPL(exit) { CPUState *cpu = ENV_GET_CPU(cpu_env); @@ -8190,103 +8295,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, unlock_user(p, arg2, 0); return ret; #endif - 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; @@ -12467,6 +12475,7 @@ static impl_fn *syscall_table(unsigned num) */ SYSCALL(brk); SYSCALL(close); + SYSCALL(execve); SYSCALL(exit); SYSCALL(read); SYSCALL(write); From patchwork Sun Jun 10 03:00:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138094 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580961lji; Sat, 9 Jun 2018 20:15:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImMudQP3qI5kRg8hI87dWHAfGTKgZsOXxoZ9JYWqF1iRMWTwRAoJSH8p+GciKiw2bfwDu9 X-Received: by 2002:ac8:3854:: with SMTP id r20-v6mr11439911qtb.190.1528600536239; Sat, 09 Jun 2018 20:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600536; cv=none; d=google.com; s=arc-20160816; b=nIM8e1SSfT0Jw/VcQz/mECuNorPveghAaUjJfVQXfLnERF1EAGy/n1Cw+uT99Fk7nD HBnZlgiJjAJwSrgkbFqiwWPOGRtx6HznLpkZgVLoRc/24nWL0BYYd1rav6LwHm0kCsBw L+36R5Zqr3F0myCl3WPM9+SgAo7MGLmrEH7VxE7hg7jG5m7U5DLyBdHzjiQoihZGf4Ax 72UoVfYymLkOaLoiZ9MYCw0HftCFLm9gDtrWRw5oioDCzlwpQ5U9WMK/d3VmThIfBuf6 4AaDwj0KZ2Yc3tlj4owYaDZH26fAeDsKqRIvmH9VroaKd5Xa7Np/dy3qkEQ8Motx3Se4 obpA== 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:arc-authentication-results; bh=j/sd47lthgp6bpUhdcpmpr619JLrsbdMYb5HPGVrIjU=; b=dLHgp397TBnME4dBdNHzJEutTbxZNcFa6UKQo9RCH5Q+gOolsKPgvLTEMwiXsq111M lpHadkIr6GWgdJqe31AODiCWe8blvhxBNQOvD35zOhCWPYtb2tl0/Dnkd+2MIj1JAbQD d0eInb8EvqW1kNDKFVw0JBhKnJrFJ0+V9am8zjpHFwNlJ9ZVN5v/bsCY25d15UmfDYEQ gW79e4f8WuLFgCtkPnMQZUdiqPBNLxA360S9F1Xy7bJhzZeTzuI5lTXSGtwDj44rNK3j t5UEi164kZv2J7j3rpNPintMkMtsEM+TAaF4yYbGEYT9X230Czij0rgDFclo260hTD7o As6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ij9rjx3E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h7-v6si4812145qvj.54.2018.06.09.20.15.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:15:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ij9rjx3E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqpL-0004ZM-Ma for patch@linaro.org; Sat, 09 Jun 2018 23:15:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd4-0001oB-LL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd3-0003EO-Ey for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:54 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:34313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd3-0003E8-90 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:53 -0400 Received: by mail-pg0-x22c.google.com with SMTP id q4-v6so7074086pgr.1 for ; Sat, 09 Jun 2018 20:02: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=j/sd47lthgp6bpUhdcpmpr619JLrsbdMYb5HPGVrIjU=; b=Ij9rjx3EMdPL8I7NLZrA0eCT+6PWsiokcxMgQlfVUe2WCpP8Fu0QotR/lmig5M8uM3 wHshI7zGF4ei4++exIVllicMqjdw4hc//5UmXk1izK6hpTme8JxkO/pLEwVK4T8xVZi4 yurSFWZo5ba/uUmeJSuQpkMOetWLVst68nQrU= 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=j/sd47lthgp6bpUhdcpmpr619JLrsbdMYb5HPGVrIjU=; b=KgyjKjV8D2vIo9H+j0dX+o31aU/c/XiIRuBvYw4of8GyEeGEr2DlB8M8ilcpOsD1U8 Fp9TO+jUwZK51qPmybMnLeE19SOz3dMztFJZqqoE8wuzjvZy3VB9mjfNoGe39NeWQyPK 52nLsk9a25HW6o0iCCYflGYGC1/Jlp5sY6FZ13boxCq+4UQOvBerTIPLVXg0ptMWkVGz hK5P03WOtycJX015FWc85K5PORQhIW5/UqvhTG9OQ8Jo8MoWSyIb0CmSSbLQ7hKBOxdt s32JhJ1mGXn/ruDL8IUNvZofgNsjhuqvqK7UqYcyA1NuwUvhe38c88nRs4iv4p3IZw7i 15/Q== X-Gm-Message-State: APt69E2xQrx3cJE5xk/c/uQ6qc4XVH4Jvtoof1OinhYXx87Cn7ws1Nsg L3tRT1JW8ja3+b19Vq2jr5Q2QPTm5CM= X-Received: by 2002:a63:7a4a:: with SMTP id j10-v6mr10442040pgn.421.1528599772043; Sat, 09 Jun 2018 20:02:52 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:44 -1000 Message-Id: <20180610030220.3777-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22c Subject: [Qemu-devel] [PATCH v2 012/108] linux-user: Split out open, 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 58 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index aa6c4e1577..a4d0f2720f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8116,6 +8116,40 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_open +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)); + unlock_user(p, arg1, 0); + fd_trans_unregister(ret); + return ret; +} +#endif + +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)); + unlock_user(p, arg2, 0); + fd_trans_unregister(ret); + return ret; +} + IMPL(read) { abi_long ret; @@ -8177,26 +8211,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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); @@ -12477,6 +12491,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(close); SYSCALL(execve); SYSCALL(exit); +#ifdef TARGET_NR_open + SYSCALL(open); +#endif + SYSCALL(openat); SYSCALL(read); SYSCALL(write); } From patchwork Sun Jun 10 03:00:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138084 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2577795lji; Sat, 9 Jun 2018 20:09:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzGe0QSGC0FWS44PKbTAuG2AKF3Y3eaWCPoJl8jNx9Lofu5QDFSh3xng//l1vhm77tmtAo X-Received: by 2002:aed:278d:: with SMTP id a13-v6mr11617843qtd.120.1528600189156; Sat, 09 Jun 2018 20:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600189; cv=none; d=google.com; s=arc-20160816; b=JIn8sI+anB20qXr4dnnRemjl01cPwykayuEmE0USdM4w8W1sbmdD+mtJLAKDNwivyc gQi1+PV4HzZY/Oy+NyfWGmePtdPVSLzIozS0Ivp1jvF5BmS1UfelJZRqD2V5gNcSDWGh Yv8fCZSdzcrB1EhYeZVHNPd63c3x8jweT6nE0KpOKPXQ38UE6demWSgcZ5aLUaJgF3aE h3PVKtHWPO2UqC6O9UWt5Px+BVksT9wOHY6qnceRgsFgL2Dk6yYfPMSx5C//jYfQlLmL puJSklphSznCE2fhMcAxH7nHk7D2Tkk//ivfH3k/fomxFdSEBuL2eze3VHBO3Y6mRVmb nyYQ== 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:arc-authentication-results; bh=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=DypjylAa8uLQwql8mji713eXPCQpkBvVR2LtpUXdOvIJK/Lmk44SdhUkDyH8tz3yEf b3xFQK0v+JZwmKvV3+0GYL+2+V8COG8s3ZHdxlRaPLHuHK0+yDwJN1bfoWvrzA6SZY64 jkjtctv0TZIOnn3dH6/xS9X4RBJZM+H+nyuJ0rOdOSHEndvP0DT2Mx1vm6aK5NvzdVa/ 4P2rk3YkZt0Oozq+bjmtHqkbOwxZj4CRxY2tcuPBph2kq0TDxmCvdtqfrbE/fr4zLF9i TKqUocZWquDQEqiuJhqKr6WJowcMPPUdw59mmAiSTD0dorUIE9dc2T/SYYTTuJDSNlhi 7iQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C5btyMAI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i188-v6si2629828qka.144.2018.06.09.20.09.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:09:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C5btyMAI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqjk-0007qp-J5 for patch@linaro.org; Sat, 09 Jun 2018 23:09:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd6-0001pp-5n for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd5-0003FA-59 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:56 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:45641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd4-0003Eo-T4 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:55 -0400 Received: by mail-pf0-x244.google.com with SMTP id a22-v6so8479202pfo.12 for ; Sat, 09 Jun 2018 20:02: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=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=C5btyMAILgN/wc8N5kvZuXl7yF7g3tu5O8tTOfFngt/c9GcKKJFlFubzz4OoA4yOiC PmK8eOuM8XiAiP6gZouq62/Pdc+L2PKA3EPYF+HpF+aW0c2frV+QYMs7cHxNv5+wF6OX GSftNWUrE7jpc5x/Ds10dvvgz0bpkV4VfI4zk= 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=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=kvrMMM6/9RkA3qimt9l+SVzoXOvBugl9KUrDc7bVuUW+aud8y1Xqb0WK2EtMVJmJPj GCVB7gUpm4vfovSkRqm3mV3B7QR7Ps9Q9gKXJ5ihs50DZsmJEmYDcY6K36XqM6O86YFo glQgFcFV7Fq702sIaNYaiB9SVFo1HHSiHQAKcqqWX2/Gh7IUv3RMohrEcUSZKtYXzfj4 a7mCAqaHd/mmq7RCMwr7EThrZ2Xn/D/gZiTONDbboSPtl3Kn6a7K2nn29r9XhuIyozNN IeAsPzDHUhh05WVRhqf44FY/HKpedrv5MqsiLs3sPYuiGKEP6vU+gp0xN+1PyvjCofSM 3avQ== X-Gm-Message-State: APt69E0t/T2VdiZ4JWGLNmA3YRKxxDxGkO0unyH+nCxvtuq804ciMi0g lL/6r05tKFxAu2SlfZMvjrJfClw1b3U= X-Received: by 2002:a62:e117:: with SMTP id q23-v6mr12249395pfh.75.1528599773634; Sat, 09 Jun 2018 20:02:53 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:45 -1000 Message-Id: <20180610030220.3777-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 013/108] linux-user: Split out name_to_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" At the same time, merge do_name_to_handle_at into the new function. All targets define this syscall; remove one of the two ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 116 +++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a4d0f2720f..90341f4254 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7361,59 +7361,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, @@ -8116,6 +8063,61 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef CONFIG_OPEN_BY_HANDLE +IMPL(name_to_handle_at) +{ + abi_long dirfd = arg1; + abi_long pathname = arg2; + abi_long handle = arg3; + abi_long mount_id = arg4; + abi_long flags = arg5; + 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 + #ifdef TARGET_NR_open IMPL(open) { @@ -8211,11 +8213,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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); @@ -12491,6 +12488,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(close); SYSCALL(execve); SYSCALL(exit); +#ifdef CONFIG_OPEN_BY_HANDLE + SYSCALL(name_to_handle_at); +#endif #ifdef TARGET_NR_open SYSCALL(open); #endif From patchwork Sun Jun 10 03:00:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138087 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2578724lji; Sat, 9 Jun 2018 20:11:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKjMQsmQ2uIVWuNw3LCvl6H2Alm7LA8PfkTl74tAWcQYn9/mF5JIWL1mU9iamrcL+wKbOl5 X-Received: by 2002:a0c:997b:: with SMTP id i56-v6mr11007518qvd.122.1528600293428; Sat, 09 Jun 2018 20:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600293; cv=none; d=google.com; s=arc-20160816; b=jQtJi+V+9Aphwir9UK+fxenQxuRP/SC0VFQhzNFIKM/Cwgvp33fJyimPwLCf4xjOse ObUU3J7txFgKndBlcqYJW5Z8JK0DJM/Mxwpk1UnMFVeSbgodHbOLsDLkWijnxwvs7fWa 7yFdzOW23wz1zKAizP7/2cTVlzCZUjs9twQzdmcLXZbLa66Trk+LTZ+Er++xb3YNhDN7 BCKFbCUfJofhmo5zihNUxBn1g8VGRZ5bEyYW/LCZxSIq5VSuEIMSW0bAKm2iIOS47joe jccEGTBOumsMLCkk2cpX0U+I3kFjas3+AHJiRPu9U/KD+2DFBsit7bQvn9duYhPUVLdd N5DA== 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:arc-authentication-results; bh=EZGrOUeL2270UIqGs54DWaac5GI5eD4C8UaLdVxq94M=; b=Q4obBuihNv6UzDhFzZo2sD6m5HdCkTlzCQ5OzwOP1Ae2Xt4X0wIaePbfwc1yACXqJX UoDsf0XtTnrS6cv5PNjUk/uMAU4ZQqtzVXPLsZaOb5ZUlLZb/2TGkcK2lnLU/HmmKWXI /MW+I+3Srf+NgOCuARwU6kzk3hW4vT4fPuAf2304CpJSU/eLWAqkPtbMHhpg0qqgWOyp 5vXJr2Yvhy7GVnEXI5nFcDB/MqzZjBpQWb9SdsaCCDNvUnxM1BpT6S833kRYb9NgNda9 KAcvv5YMV759EszWS7kjpOGbSoVhk8EZnF50h6thYCzgBHynrnLFlvsuM/pyceawxc7H Boyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cnrj15P5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f2-v6si84180qta.209.2018.06.09.20.11.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:11:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cnrj15P5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqlQ-0000zl-Pp for patch@linaro.org; Sat, 09 Jun 2018 23:11:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd9-0001t2-Ea for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd6-0003Fw-Nm for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:59 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd6-0003FU-IX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:56 -0400 Received: by mail-pf0-x243.google.com with SMTP id y5-v6so7582990pfn.4 for ; Sat, 09 Jun 2018 20:02: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=EZGrOUeL2270UIqGs54DWaac5GI5eD4C8UaLdVxq94M=; b=Cnrj15P5+1/qa/W8hSdLaIRMXJUK4WTQopVnIT4fyfnak0uNua5w+AMulmOM2rnExc mlwB6SkfIR4l0mKombsBffKgnSzgD+0kXZ4qmaR09os7ws5L/N+S3py5WRU/6QoARAmO Tcy3aWnDTWFBVcRfV3fjW1EVtVR2p1ncXb2IU= 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=EZGrOUeL2270UIqGs54DWaac5GI5eD4C8UaLdVxq94M=; b=DYpjrzL0fCjDkoSUVd0IuscE2cCUlSc90xWpt1Z4LFg9tTo6kfT8FpepBicVJDsTyF +8O0CGhi3qGoH8XQ0oUPfwoox7CIRrDYSVBoWl4TS0L4+7wZGbyuO1vl9TLVlcQ0kxjn uFIybMX56F+Nteeqm44SIsH2GR8uDG2/yaAYLGe8o6PU1HtzqArYNKgfo3PF3s9rJFMT ljn8DmMY/X9oM0RgjJJgfXcuE9oxpF/A1UtbqaNEoHA60TOFu6lu2+reiOIRcFlzEReX 77aesiNSHjzOJCqy8lNsu8iYU7mzTb8rW7axZzNPxFA4F81b2oa+aeolj8vmNlOgWBvx DLOA== X-Gm-Message-State: APt69E2FqYHWXBmmItEy7soCAhuPO9xuF1UwIvshkddcTEfeSVqRNeAY 9HoN73wZKxU+cORqVEG6VG+WEs4kIA4= X-Received: by 2002:a62:da59:: with SMTP id w25-v6mr12158258pfl.161.1528599775330; Sat, 09 Jun 2018 20:02:55 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:46 -1000 Message-Id: <20180610030220.3777-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 014/108] linux-user: Split out open_to_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" At the same time, merge do_open_to_handle_at into the new function. All targets define this syscall; remove one of the two ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 79 ++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 40 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 90341f4254..f51cc7e937 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7362,40 +7362,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, } } -#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) /* signalfd siginfo conversion */ @@ -8152,6 +8118,42 @@ IMPL(openat) return ret; } +#ifdef CONFIG_OPEN_BY_HANDLE +IMPL(open_by_handle_at) +{ + abi_long mount_fd = arg1; + abi_long handle = arg2; + abi_long flags = arg3; + 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); + + flags = target_to_host_bitmask(flags, fcntl_flags_tbl); + ret = get_errno(open_by_handle_at(mount_fd, fh, flags)); + + g_free(fh); + unlock_user(target_fh, handle, total_size); + + fd_trans_unregister(ret); + return ret; +} +#endif + IMPL(read) { abi_long ret; @@ -8213,12 +8215,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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 #ifdef TARGET_NR_fork case TARGET_NR_fork: return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); @@ -12495,6 +12491,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(open); #endif SYSCALL(openat); +#ifdef CONFIG_OPEN_BY_HANDLE + SYSCALL(open_by_handle_at); +#endif SYSCALL(read); SYSCALL(write); } From patchwork Sun Jun 10 03:00:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138092 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580230lji; Sat, 9 Jun 2018 20:14:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1mIszQWUH9zK3er/yvxoEIiyNpQghbWUt8dnlFR4CHZQvuoRJkv0VpR3Ne6Rl4Ww8Y7TC X-Received: by 2002:ac8:37f2:: with SMTP id e47-v6mr11170310qtc.386.1528600457343; Sat, 09 Jun 2018 20:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600457; cv=none; d=google.com; s=arc-20160816; b=WSytVNGIngg4/l/li5vyDIPlArpkRuitnW0erC9d4WbJd1SaHBdn9QAsX4rQzKswik 6aC1KoY2QrfCqdKpWl8NbH+aeeqgKD5jc+JEJkglXzCwacSv7P1qNRBZGIlOrfCOKqO+ Sy+KsunWchxFaVGEb1iTsoSoj7ng9Wg4oMfSBxp+qRHkCLfBmCBQmS1auEp5OWR4WDNZ atg9J5yJ/BnMxF5X85lEpI9rEgpYi2tYv4gxa1POx/8X9uNhU/MOrJIzgnY/ia++K42I hq8Br/P+c1s8o8bTyKIofj7xTjiN3nHBAH8XD8/DlOsg00pNblBOeK1j0sDYsokDyosR aw9w== 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:arc-authentication-results; bh=rAKn4akMvtjNjos1xTYioRl3XOSJGEfXiiI/zItlggw=; b=iWbGPW4wJIjhHGgvB9KunTWeOXcQAKstExVU/3UuVLkB+QHP6XU/8MKfZYMUlrnt0B uhbwI8lZL87decj8KEnsg4euVFx0pfz+83zDvU9S7DUDhPpqfa8raZVdmyIIPELXPc+Z qMRD7HW1Y0YQMJSPJ/tJi+hRKO28UGvrMfamWyb37mx+nLLoXwVsOBikfzy/jSS8HypY N+XRy8qzs1AN7AHPcDv9+I2NDkd5ZDTIjfZ1XjH8dXAWBOYWHd0cCZa0DfA/qs1fx2Hw q+bXQV8KHPx5i6JCqObDincxSNY2MWaN2MLhRGOD7x2PbWtSdiYOi9hKu/e29QuYYdCK RtTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kkUYdEAy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d41-v6si756616qkh.309.2018.06.09.20.14.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kkUYdEAy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqo4-0003J0-Lv for patch@linaro.org; Sat, 09 Jun 2018 23:14:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd9-0001tT-S1 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd8-0003Gj-Fq for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:59 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:39499) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd8-0003GS-AM for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:58 -0400 Received: by mail-pg0-x22c.google.com with SMTP id w12-v6so8138454pgc.6 for ; Sat, 09 Jun 2018 20:02: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=rAKn4akMvtjNjos1xTYioRl3XOSJGEfXiiI/zItlggw=; b=kkUYdEAyc6K+AFSlznXPb72aMKzor2UjINsUa2/JMum6KTSzkM1NjGfVhu5jg5Xnz+ SG/lJQqDWqpoTPQ716BeXAxZmE/RTSIlQPsIIwG8lw5OBVY4FlqkEHzlGphZZ1cNJ6Qc JRKOjhimtsXtvFxcTElBZZaEOWkj2bsuHhwZQ= 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=rAKn4akMvtjNjos1xTYioRl3XOSJGEfXiiI/zItlggw=; b=PURPyrzOVETEcAZbBMUgP9kbtm4YlvBDxLlLWIscLKHjUeABB+B4NlTXTaH2PVH3X1 G/DLfgpNB5TQvbgUfhFJAxIHckLxHnCPrcHe59uUpOTEKN30wELa6PM13ikGHWIY1gxU fO34LI4P3sydEjm7aFpMekiYv5/miTAH/wJ4bliiNY0DCOAwItQYk/dW/Cy+jvg6bA3s R1QUlYhVp8U8HypPAHN57oBb6RSpI7MX6nTFeMU4r0z7fvbsKXE5gimST5b3qiWjVlVH xGJwr7JTUTlgTUBALlYGDZPB4g7hszAuA8KMOCdfUZEe3hSwaj0IP47iUOJ3PyEYdxIE KSbA== X-Gm-Message-State: APt69E0k8EcRlC6rFo2awCmg+eWlzJBTfhS0KonYbw1V8KmHlu9Ym5fm zyPydVuBzknZA7tPRbauqoNZYpyAlj4= X-Received: by 2002:a62:8a83:: with SMTP id o3-v6mr12242174pfk.12.1528599777022; Sat, 09 Jun 2018 20:02:57 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:47 -1000 Message-Id: <20180610030220.3777-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22c Subject: [Qemu-devel] [PATCH v2 015/108] linux-user: Split out creat, fork, 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" All targets define waitid; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 104 +++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 39 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f51cc7e937..a146b696fd 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7882,6 +7882,22 @@ IMPL(close) return get_errno(close(arg1)); } +#ifdef TARGET_NR_creat +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 + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8029,6 +8045,13 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_fork +IMPL(fork) +{ + return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0)); +} +#endif + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -8174,6 +8197,38 @@ IMPL(read) return ret; } +IMPL(waitid) +{ + siginfo_t info; + abi_long ret; + + info.si_pid = 0; + ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL)); + if (!is_error(ret) && arg3 && info.si_pid != 0) { + target_siginfo_t *p + = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0); + if (!p) { + return -TARGET_EFAULT; + } + host_to_target_siginfo(p, &info); + unlock_user(p, arg3, sizeof(target_siginfo_t)); + } + return ret; +} + +#ifdef TARGET_NR_waitpid +IMPL(waitpid) +{ + int status; + abi_long 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 + IMPL(write) { abi_long ret; @@ -8215,45 +8270,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: - { - 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))) - 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: { @@ -12482,8 +12498,14 @@ static impl_fn *syscall_table(unsigned num) */ SYSCALL(brk); SYSCALL(close); +#ifdef TARGET_NR_creat + SYSCALL(creat); +#endif SYSCALL(execve); SYSCALL(exit); +#ifdef TARGET_NR_fork + SYSCALL(fork); +#endif #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif @@ -12495,6 +12517,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(open_by_handle_at); #endif SYSCALL(read); + SYSCALL(waitid); +#ifdef TARGET_NR_waitpid + SYSCALL(waitpid); +#endif SYSCALL(write); } From patchwork Sun Jun 10 03:00:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138099 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2584237lji; Sat, 9 Jun 2018 20:21:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKP5OnkPeI6AalDxGoz0bQUaDVfNXx5Y9cDFwosDyAkwaNt8taJhZxxyT+p5I9PY1zRuVP X-Received: by 2002:a37:295e:: with SMTP id p91-v6mr10214241qkh.415.1528600887103; Sat, 09 Jun 2018 20:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600887; cv=none; d=google.com; s=arc-20160816; b=C3vX8sP8OTiU0cYmTyQ+q/Dy7eghPj4lwA+JwaUbj7RPubFyIhhRKvjSCY7zs2GhUm 5FPfExa/BlbL+Rjr0jDXlhUXlJoRPCdb7GRB8HUvnixUzluUdRhoj795WRVdsklGv5Eh H240rEstESFOe87LLYGXwK+2t28o/QO3ASOdThbtlv1jcM8m77Wd80NE7egKI6He7OJN NfwaqeUH2y+OGPTD/X2+cod8E+wutfqpn/ynibg81INmY9iEfUWigwEt038oFWHjZTmx I2DJGnRPOw+y+bfuP73dT08i/qJ7xvhiR7vkFcc0hXnmWgrGeY9qwMm5qLhL3aVH4Fxs yYhg== 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:arc-authentication-results; bh=nUcgwKjKRtuUIl+X0SKW42bj2GseoHEMo16pVq3WZHs=; b=No/K02UoOdND6QafvZDAzVnN6KvMqodvYLnh0VWRTLeQxjc1G71XbB+QpsgO/kIU7w Z+efPd+uq1f6Mwxh9GfnsjIIf4wFXo529rBkl+kRbF8GrwKLNHLXDC/Zo0t7XSnBCRN2 j9LlQTGLIuJd+VSwK302kd2UqRysh0Ww82GpNjcxam44/ZeJNO1UDGxFkxV6mBf34c+B EZAbh2rL2PNIBztGYDGUEztt4qV4Q8yPvTGoTBHU5q3MHUx3ePMV2a8pTK0U/q24QmE7 lW82aLzE3FszT54eYa/pCvtzach/0HkOANpCmoQNftv+XWNTgQ8QqOakolsKAfnzjz1N ddeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hPPNacGv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n67-v6si22222390qkc.152.2018.06.09.20.21.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:21:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hPPNacGv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqv0-0001E7-G6 for patch@linaro.org; Sat, 09 Jun 2018 23:21:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdB-0001v7-AI for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdA-0003HQ-Gv for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:01 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:43596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdA-0003HB-Ax for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:00 -0400 Received: by mail-pl0-x241.google.com with SMTP id c41-v6so10384334plj.10 for ; Sat, 09 Jun 2018 20:03: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=nUcgwKjKRtuUIl+X0SKW42bj2GseoHEMo16pVq3WZHs=; b=hPPNacGv8/qPETwucWmNA6Z80FGeHSlc+Pkz86WvYJSihXl06HWCwEsqR/FqQDvx2j r2r6jnRNtRm96m+Df1b8zR/VSxP0gkdoLGJHZSh9a2npwDNKMaFIdw4L+uUiObtOelQD +DYVG+3OfjCBDu9eyxGD993ihb6pnQyuGHYw0= 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=nUcgwKjKRtuUIl+X0SKW42bj2GseoHEMo16pVq3WZHs=; b=YvMNvJ62+hTtrrWF2N/sK96DtRyprexixGA2WMRe8eILqOzYh+yx5YZEYnHLLXcc24 1P6DSftajZwF5gv2Sox0RHth/AeeS+sWjzLErcg7un6L9iQILatLl2XNRheVw2my/5+4 eIJsobb1SNX45JV/lHUr0UYnfPi6QOIn02Z5SYXeHYEueMc2GVGPD3zZ3a8CLBN2tZm+ bwixDsRUP7RRQoafUPZY8o7FUOkTrnTZ6D97DEVZGQnanR9OWuOCnOrlSMVJoV5guyJb nVTwWT/R7mh6sFlYF8swGw3G6grTrBCdyECiUFdAeG0ox6Fex7jOV/UCb1VpyP1kIWiX hkGw== X-Gm-Message-State: APt69E1i5QdINomYEZNZp3YkH38A5EYf3fqeodJKhkh6sCUP3cOvM+JF FvfdkW+Rcsp2INLreKrAdXSlG2onLqc= X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr12960917plv.176.1528599779153; Sat, 09 Jun 2018 20:02:59 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:48 -1000 Message-Id: <20180610030220.3777-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 016/108] 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" All targets define linkat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 66 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a146b696fd..936c7a7484 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8052,6 +8052,36 @@ IMPL(fork) } #endif +#ifdef TARGET_NR_link +IMPL(link) +{ + char *p1 = lock_user_string(arg1); + char *p2 = lock_user_string(arg2); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(link(p1, p2)); + } + unlock_user(p1, arg1, 0); + unlock_user(p2, arg2, 0); + return ret; +} +#endif + +IMPL(linkat) +{ + char *p1 = lock_user_string(arg2); + char *p2 = lock_user_string(arg4); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(linkat(arg1, p1, arg3, p2, arg5)); + } + unlock_user(p1, arg2, 0); + unlock_user(p2, arg4, 0); + return ret; +} + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -8270,38 +8300,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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))) @@ -12506,6 +12504,10 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_fork SYSCALL(fork); #endif +#ifdef TARGET_NR_link + SYSCALL(link); +#endif + SYSCALL(linkat); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif From patchwork Sun Jun 10 03:00:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138088 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2579268lji; Sat, 9 Jun 2018 20:12:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4yvs0ci93HKjeS5hqW7bbgaq9ic9L72Wc6FZip3wIBD9J2LPzG0S7cY2ul32yvXBjx8sB X-Received: by 2002:a0c:99df:: with SMTP id y31-v6mr10758514qve.156.1528600349298; Sat, 09 Jun 2018 20:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600349; cv=none; d=google.com; s=arc-20160816; b=doKKajr5jYua+/EgmIaZ2zGUxFZTPQULmaQpggwrGqgcRjew3AOKCAtDZDfUT07rDy 5j7ct7D30rP7KTAZ5etVD69uKBJj0sOA8V9ilO6b3/seUms5KCrQet5bphEuYhsnUpJf 4TZ2Ok648QDKOtucXn9bZddGeYoo8Nf62yQhG962ZsjwuVYjqYGVQ7Cy1r2G9OJjF9BL o02dspa6t9UiAbM63lip6wBYtkIZw8WIEzgcJCzN7tvKZ+QKLXHjKpXv26uUTVE1PnAt I6B2CHtPYJ6I54qToall+68JNyv9AHkGmSXOLr3PqrxUp4UnQvaeaFmuot4aFUEqae0h qQug== 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:arc-authentication-results; bh=mfT8RXdklKBfOd/G0853qiQYk5u1vwyyzpvmzW8G+v0=; b=g0nXtZcrCAwOlBmyGN/Qa/oHTPbyrsloF79lMLFeE+mNjfKcC6UpKuDtDk/xqItMGq 7mW6Dlal+rHQeP6Ov0XmqCbWNPkiu8qnRbegbxfprURZhntktW4smp6kvriKujFfxj5A ZugP2PEBdsDNG5XTeIU/0dkKYq85qVbURgQuX+7hwGErno5AYSP/o8OWfyEp+A6Fsk+x EWsSYwYQFRf/PrBDO9Nq2xvFllzJ2F8MrLE6dBMAoCG7FhABp3Qco5Rkrm3a1gkYZ1Mc UD7V9s9Ysa/9Lkc/9iywtAqsKkpCy+bCB0DLYLtyWZ8FYbZa7PKWnfZS01XTyl6whVue OCLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UO58uWjj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f3-v6si4276285qvl.57.2018.06.09.20.12.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:12:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UO58uWjj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqmK-0001n9-Id for patch@linaro.org; Sat, 09 Jun 2018 23:12:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdD-0001zS-Hw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdC-0003IF-Pc for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:03 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:32936) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdC-0003Hy-KA for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:02 -0400 Received: by mail-pf0-x244.google.com with SMTP id b17-v6so8494408pfi.0 for ; Sat, 09 Jun 2018 20:03: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=mfT8RXdklKBfOd/G0853qiQYk5u1vwyyzpvmzW8G+v0=; b=UO58uWjjawzOcm7ksW3lpVHV0tqUoaZgMArt8VpCNwyBcz42Iw0Y5SSjJFSuo4f/Wh GalL2BmaLijfhQ1I/6kL/d7YU7WLGLBwf3SSL1hyk6JqexFjIIvOqyqkLYk3N921whpF vN4m1CLQIztsqF8EIXCIRTr6XBQp2D55PM4yA= 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=mfT8RXdklKBfOd/G0853qiQYk5u1vwyyzpvmzW8G+v0=; b=jA/z0INlqcSaJS4IQSvqTxsJK6a3shjWj0XyuUDKId3+uJwvwGkG0xbZuT/D470Awb hTEr+A2w+iSJ2FwCi4Iu4EPUxYwQi+tMotC2EnjRUlfohOUCfHFt8ldoeu/BX1HSPLjR W1wcYR4/taunEPxw1rOFpFgls47FC5GA9NjC3Cq7PzzocavWj2ONnV3rJvjUk1eTCIHj mAyTLeA8EqZAqz+B96NNO+bmuWMr6Nu1PYj0cSQTH+eLYwig1B/oakjHDlx26WuEIg70 O9lVcdgtKoAL8rSsZ+VonXakIp7nrUdPCCpYbbXbo8DGsJS1tpr0p6s8NArDc1PwGO7p xYGQ== X-Gm-Message-State: APt69E2F2mnnq3Aa+mi9gnPaT6s5CAU9kpKIhB+UQP3QC0mGnJ0w8gsL wNgeAu0Jz7JOVpL2YIYNZfmlZpCdF9Q= X-Received: by 2002:a63:7206:: with SMTP id n6-v6mr10228598pgc.174.1528599781382; Sat, 09 Jun 2018 20:03:01 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:49 -1000 Message-Id: <20180610030220.3777-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 017/108] linux-user: Split out unlink, unlinkat 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 define unlinkat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 48 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 936c7a7484..e1b3c7e827 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8227,6 +8227,34 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_unlink +IMPL(unlink) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(unlink(p)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +IMPL(unlinkat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(unlinkat(arg1, p, arg3)); + unlock_user(p, arg2, 0); + return ret; +} + IMPL(waitid) { siginfo_t info; @@ -8300,22 +8328,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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_chdir: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; @@ -12519,6 +12531,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(open_by_handle_at); #endif SYSCALL(read); +#ifdef TARGET_NR_unlink + SYSCALL(unlink); +#endif + SYSCALL(unlinkat); SYSCALL(waitid); #ifdef TARGET_NR_waitpid SYSCALL(waitpid); From patchwork Sun Jun 10 03:00:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138090 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2579807lji; Sat, 9 Jun 2018 20:13:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLjOA1NoZyBTmrYgTFLBmYexw9qgkIfjignCgVOf1MIPetaKN/raqOnbdR0+vDhd7GGwcCi X-Received: by 2002:ac8:34f1:: with SMTP id x46-v6mr11505078qtb.135.1528600410558; Sat, 09 Jun 2018 20:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600410; cv=none; d=google.com; s=arc-20160816; b=GFriRmVEvO0M751dbyFVTh33E9yae5yNj9q+hy0Z92PZ5SSPdmKSAx2CunhZpzrRFt PzB1d1qYMZv6FWUCgSZ+z5ySiNb903uLEu+I0eK8vxOVfZBw42+LWlD3dhfWgZsoeSBN 4f88CWxcYl1sycWrRVXQ4aqaZ523t3cCWYrpaMWzrpbx/qzh5g3S1YkpMsHsFCHf/0Ei tDQ3+/Z5KLRC3dkj3Tpa1f1h34xl0ZvoHc78VR+UxuWR08ZHqtSee8O1DVR9jmalg2ul ORo8eB23RRsm95QWiJcW5U6Hn21F6HwKpXTzVsHPS/Ytz7ulKiBVG3RFTLbM5l6pmzxQ 1isQ== 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:arc-authentication-results; bh=6wYnvNkBxxZ2UramVCrT9GulDam0MWhznVrrLRpK2kM=; b=GZWeSzVeu+/RRjESUks5vM0yXb5/4jRWzaICM7z2twiT7UZM5j7JR/7NPj0Tu5U4vV Lf51shLXX60DmohmQ3MgtUP3dknawLu0a3JueYjTFyXhGv96/eQP9SZwije0ylzHynWd KgXnRwhx77UCnKuHWlEmHeHUa/unEG7b0p5uqYmrynU7/59EHYhKXpmw6gqe+dCPmpC5 cOlMMANlJewZOG/8sChwQscqz82L6cfMGudLTQNG5o67RNOEynW4ygp7/sxyZG1mLxj0 hFuOC5572DbnzcY9/oxZ9YzaRmIzHQH5VcfipllaWPEwNp2fWmnp8omDbs73CeJMs/Qq jEtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C4EK7bmY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p184-v6si7067271qkb.380.2018.06.09.20.13.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:13:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C4EK7bmY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqnJ-0002y3-Un for patch@linaro.org; Sat, 09 Jun 2018 23:13:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdI-000228-7y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdF-0003J1-4d for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:08 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:40842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdE-0003Il-Uj for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:05 -0400 Received: by mail-pg0-x244.google.com with SMTP id l2-v6so8127232pgc.7 for ; Sat, 09 Jun 2018 20:03:04 -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=6wYnvNkBxxZ2UramVCrT9GulDam0MWhznVrrLRpK2kM=; b=C4EK7bmYqV+Z3HBBCYUJvqXlBdYQZsutLYX9OPa1RgHSZcdIg71SzItmVsg+i3DE3C qiTrnqQHXC9NvMxggZvhesevyumeGTMt6gzjMODrShzmEd5761ZJM75Nd6lZyvnIalFS ue1tn4PVT5GZH6Dc0dsBSpd4XkUVCUgvlVtes= 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=6wYnvNkBxxZ2UramVCrT9GulDam0MWhznVrrLRpK2kM=; b=KbCM8d30OURV3VY5AD+23djlsfsh/3oGJ1Y4rzfPghHft8SXNT0yxag0BnPDvmtrhj 3kqL6ZgmFz45nRn6Ydkd4c+BM436Nolk5bCdTjcSObOXJ3sH4w9K7uLtx0CVCZlMrd7M C+ad4Ui5pAXEBRh0REk3ydON5XP98mSTefuyUH3IiCA5ZA/y6A025Ydu/cVLnfz+Vdus gncyAvmJjF1tmL52o8F8vEpdqUswrfSqtw7mf5JdQpTkhFzSgsipLo4kK7I5dbbO+eHB lHphB3Uj5CTxIsB0xGLTp5OlX4kRO/F9QrEfivIV38ftiGYrnYDP/Ty/BQP6y/+fNzUy RecA== X-Gm-Message-State: APt69E2VpJTJwuUA+oPa4584L5L3vM1cbW/V4H4B+jdP5A+wE+mcjSeK iOOXmbTuJTzsMMqlBz8ljfm650axnDo= X-Received: by 2002:a63:721d:: with SMTP id n29-v6mr10165931pgc.194.1528599783655; Sat, 09 Jun 2018 20:03:03 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:50 -1000 Message-Id: <20180610030220.3777-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 018/108] linux-user: Split out chdir, mknod, mknodat, time, chmod 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 define mknodat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 121 ++++++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 42 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e1b3c7e827..d32034ce38 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7876,6 +7876,34 @@ IMPL(brk) return do_brk(arg1); } +IMPL(chdir) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chdir(p)); + unlock_user(p, arg1, 0); + return ret; +} + +#ifdef TARGET_NR_chmod +IMPL(chmod) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chmod(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(close) { fd_trans_unregister(arg1); @@ -8082,6 +8110,34 @@ IMPL(linkat) return ret; } +#ifdef TARGET_NR_mknod +IMPL(mknod) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknod(p, arg2, arg3)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +IMPL(mknodat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknodat(arg1, p, arg3, arg4)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -8227,6 +8283,18 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_time +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 + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8328,48 +8396,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: - { - 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))) - 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))) - return -TARGET_EFAULT; - ret = get_errno(chmod(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_lseek: return get_errno(lseek(arg1, arg2, arg3)); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) @@ -12508,6 +12534,10 @@ static impl_fn *syscall_table(unsigned num) */ SYSCALL(brk); SYSCALL(close); + SYSCALL(chdir); +#ifdef TARGET_NR_chmod + SYSCALL(chmod); +#endif #ifdef TARGET_NR_creat SYSCALL(creat); #endif @@ -12520,6 +12550,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(link); #endif SYSCALL(linkat); +#ifdef TARGET_NR_mknod + SYSCALL(mknod); +#endif + SYSCALL(mknodat); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif @@ -12531,6 +12565,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(open_by_handle_at); #endif SYSCALL(read); +#ifdef TARGET_NR_time + SYSCALL(time); +#endif #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif From patchwork Sun Jun 10 03:00:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138101 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2584504lji; Sat, 9 Jun 2018 20:21:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKUCUFcTgeJu9/Pkz+eYX/g3Gl3/nYFhn8g7CGQP24suBwtFMlAYQLp2sCTUZG80htYKmZ2 X-Received: by 2002:a0c:e2cd:: with SMTP id t13-v6mr10774158qvl.47.1528600919031; Sat, 09 Jun 2018 20:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600919; cv=none; d=google.com; s=arc-20160816; b=QPDKz/XIwTDsfOCh4ryYCZDRVKjqoopDNP91zP7jRxJd95rexaLMMgfKHBKfCNh6+D sOHaDaa2E8H3CqgYbNU//4JapIfw1CY9Xsj1YitgMxpuxd1EwfxJRt9OofX8LSQZ+ijH S+HyJnQ8JJVDfpP2nMDwLfiGY9/mRYNLhjK6hQkw75eMjcHa95jVyOCHEfyg6D2x53kv uVkd6WFwC4jyxPrq27KPvc9v711uiKt+oKbvlgsFvyXPUh4K7aEQB3OCH1rfrl/FtuVX 3ZvlZHd4r1ZdpXJw2F6BNkg2P7ydY2Fl3VuDqsR2xvXnzlu2lTPkQrPPrqIkQKoaDK6q d+Ow== 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:arc-authentication-results; bh=0LBnHctWjTDpxuK0VTUuP0XoJOgCp3jsCOJM7Zsg3y8=; b=dd9t6Ix/QYtVusJ+5Rp168JxuL5n1DSPOni1i9F5SHG8KS/tuFxGyu12pNIpHEiyqo Y6gEGzrdoyI0TMmguH2k1K+er0HJ9odYeNCLLzIPUuTMggUHl43NM3OtxITCy7dk8R0I nGDzgmiHsfmVbAuBpA/nlsqlbZYMU4W+RfUqs0ZP+MO5XDuF9lDQWA7zB2FUomDcEMbh m6EN+759pRpCR2LrLEzLHvh1r+WygDJng/+WSxSkpicce/zeVnYbEYMgVpI7XrReGGVb s5jr11fNjN0Y2Z0Lb4wFUEHXb0AkEf9BKqNUGKAQUWyk2/fx66U5vDdBf4+7f0S6x8oL pv6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hcwAKLO6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y26-v6si8915830qtf.222.2018.06.09.20.21.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:21:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hcwAKLO6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqvW-0001I9-DA for patch@linaro.org; Sat, 09 Jun 2018 23:21:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdI-000229-87 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdH-0003Jc-8c for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:08 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:41358) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdH-0003JP-3N for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:07 -0400 Received: by mail-pf0-x241.google.com with SMTP id a11-v6so8485301pff.8 for ; Sat, 09 Jun 2018 20:03: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=0LBnHctWjTDpxuK0VTUuP0XoJOgCp3jsCOJM7Zsg3y8=; b=hcwAKLO6h2aMb07chaORM78lmhDBSbOGWG+fMmm9p73h/4wXtKYH9BSDFfi+QihqMp wDZNLLXBmXEVxf+hbkex5Ge4OJJ2voPQWLBzR9t17JZ7T1xDKeoa2sMBUd8Su8zzPUXk g65Jev+RA1zmKJP/T21EIRYkYsIo+YQOJxiNg= 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=0LBnHctWjTDpxuK0VTUuP0XoJOgCp3jsCOJM7Zsg3y8=; b=jYdkXYGyBUN1+E/Gu77XC9JLt8umt/rgDQEj71Ii/tvlTwDhUaTnofSqs8YnAGeRgV TKJLefb7Uw+hk2Y9tKHH5LjIfeiHC4MZfQb/10K56q4WYu0E7bhCXtTsuJgmlTAA5Vhh foZ4KF4UAPypaBlCfA5ay19LloCeH3gtoAHO0VPD6A+RS2cG2dFo3rFlYHY/WF6fGg7s 8B0QtBPxcXaxeMH6IJX81/9nO9S7GIboB1oReUjzdNvSDQLrcbWRQMtKuoHJhBYExWOd Iz/Z4Sptu7KZkQwVtp5vP3q558yzcKc281qu33x9uW8sCkx4NPVL70U8Kac9jkygKB/Y /7bA== X-Gm-Message-State: APt69E2l2ev7TAFB904mWyBe8pRPaBttVfN7ZP4ltSA6TsP+thUp/KwC RU0XnLusvZcmkpOqGDtCcN0gx6cheHo= X-Received: by 2002:a65:6356:: with SMTP id p22-v6mr10452538pgv.20.1528599785840; Sat, 09 Jun 2018 20:03:05 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:51 -1000 Message-Id: <20180610030220.3777-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 019/108] linux-user: Split out getpid, getxpid, lseek 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 | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d32034ce38..3d3983a504 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8080,6 +8080,21 @@ IMPL(fork) } #endif +#ifdef TARGET_NR_getpid +IMPL(getpid) +{ + return get_errno(getpid()); +} +#endif + +#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) +IMPL(getxpid) +{ + ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid(); + return get_errno(getpid()); +} +#endif + #ifdef TARGET_NR_link IMPL(link) { @@ -8110,6 +8125,11 @@ IMPL(linkat) return ret; } +IMPL(lseek) +{ + return get_errno(lseek(arg1, arg2, arg3)); +} + #ifdef TARGET_NR_mknod IMPL(mknod) { @@ -8396,18 +8416,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_lseek: - return get_errno(lseek(arg1, arg2, arg3)); -#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 */ @@ -12546,10 +12554,17 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_fork SYSCALL(fork); #endif +#ifdef TARGET_NR_getpid + SYSCALL(getpid); +#endif +#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) + SYSCALL(getxpid); +#endif #ifdef TARGET_NR_link SYSCALL(link); #endif SYSCALL(linkat); + SYSCALL(lseek); #ifdef TARGET_NR_mknod SYSCALL(mknod); #endif From patchwork Sun Jun 10 03:00:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138105 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2585947lji; Sat, 9 Jun 2018 20:24:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLx8OwhZ7BG3uSEDeR2PFtfqu+1ssKGvLJybKyfDtiJTuf/ydX8LPG2N0xWdxfITpq/YOB0 X-Received: by 2002:a37:660f:: with SMTP id a15-v6mr10515283qkc.440.1528601093035; Sat, 09 Jun 2018 20:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601093; cv=none; d=google.com; s=arc-20160816; b=PzZuI/P8PgilQWa1OARtH0/P2oXScliR+Ml1yG9QjBCkwB6ht1r+TsLH5WpRTXtBJ9 RVQgWdsYSF73xDUK6NqfF52ocxJSmjCdUv038mOhZ9RMFZKWQmhrFQx2XwJnC3tjtiml SMev/uGJ92jwosn8pOLYkQUdc1Epylu8CV//i0hgESKM04s3DMaNU7ug6rQ+XCAw5QpA LGn2sfMdYoRvA5e0q9w+IuCSTgCcJzsJeRIUFCHNVNqJ2Jn0V1nmA8bqDL3eji+ToXc0 Y/rng785SYJUEetttyPOt3gKJwaFWLtRsgnjpRscBt+DGpdaM5YA6LW77Nbev3MHX4+V yMfA== 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:arc-authentication-results; bh=rTOgHLFKmZqw+MjkWfMUvU0h1PwNDhCByYlrjh5verI=; b=N1xn+r2Or2PWoI/YE30zZL3AadaQVk3WueXdwe+SfHIwCSPEYH4Se5Dob8P3N/gQeV DjoLjuPErt8Gh3Sz3lDRUNCQ+gqEu78tWzGHrRE02rRYalL+T7h/bqy8oIt47ctk2S+f 0vNmVTQF8k0z6MkUWiFqN7tPW1KmzsMjFPDthtemTZRF0qEah54pP3YyK8vuJ7PpwJtE JMgc/W8RQHcAfpS5o0QYGbNnyxc4P3Yr9flwbSw/uKZA5heBl/AmFTLUoOqUFt920QyP qWiN2mEUg9LTgmvH9YnE1qLe5AfFYhpMaMR81FHMYSMqkoFABwK7p7S8BnqCfjnU+Thc jRYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eYTelkIq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y1-v6si385654qkl.43.2018.06.09.20.24.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:24:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eYTelkIq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqyK-0003fF-Dv for patch@linaro.org; Sat, 09 Jun 2018 23:24:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdK-00023D-4f for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdJ-0003KL-46 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:10 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:35650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdI-0003K5-Tz for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:09 -0400 Received: by mail-pg0-x243.google.com with SMTP id 15-v6so8138338pge.2 for ; Sat, 09 Jun 2018 20:03: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=rTOgHLFKmZqw+MjkWfMUvU0h1PwNDhCByYlrjh5verI=; b=eYTelkIqDt89++6aqkJhQbMPSx1o1bplWNFqpDVfLsWJJ5TJrXo3Z/giaLAUMvReu0 7xTafQZaPB4C1xJUQHXYs2gcNxRnrgX/g4rQzuqP4uZvlkFkMVxt0bFeXiiltG7zQi4z k7xJQu3SsBXWaup3sT5SEulPxLFXznX8lnJ24= 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=rTOgHLFKmZqw+MjkWfMUvU0h1PwNDhCByYlrjh5verI=; b=HrFsBNkvDQ3XrRvgXXRHYCI3WJmyy2Cyzc+sB2FuzIOoHGaVbjx5JjNKvNgn77Uo3f 5qAva91vbxKYSqLTpQsGP3cRWQG6WKS4AJbm8+8FSfNgI6vaHT2eDLOKrabmKnNU+gun zl+6YI3pbtRzPjQes2+GvCoLeTq198lvUgSxIfLqEhsNCR9pBMbQ5VzmIHkB9cHkIo91 pjhVnW5RxKB1HakxH9hW4qtkzBWwfy0y/4/BQgECP38ZIOs4sXIWT3GL9t/aPZQI8jGe GJg7YtZdZFIoHuRt084J0rSiNT83LqtTt/OacL66tXbQ4e/ru+gchFmehRkORX0BWKt7 94lQ== X-Gm-Message-State: APt69E2+KXt+5hJEY74+FkJiEWl1Z5QQaKiUyzkbshMAW02RQpxPGG9F StmZR/y0TQM1PLbgHKnkTtPpkyOo1y0= X-Received: by 2002:a65:630b:: with SMTP id g11-v6mr10221549pgv.303.1528599787663; Sat, 09 Jun 2018 20:03:07 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:52 -1000 Message-Id: <20180610030220.3777-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 020/108] linux-user: Split out mount, umount 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 | 118 ++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 63 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3d3983a504..844e771488 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8158,6 +8158,42 @@ IMPL(mknodat) return ret; } +IMPL(mount) +{ + char *p1 = NULL, *p2, *p3 = NULL; + abi_long ret = -TARGET_EFAULT; + + if (arg1) { + p1 = lock_user_string(arg1); + if (!p1) { + return ret; + } + } + p2 = lock_user_string(arg2); + if (!p2) { + goto exit2; + } + if (arg3) { + p3 = lock_user_string(arg3); + if (!p3) { + goto exit3; + } + } + + /* 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. + */ + ret = mount(p1, p2, p3, (unsigned long)arg4, arg5 ? g2h(arg5) : NULL); + ret = get_errno(ret); + + unlock_user(p3, arg3, 0); + exit3: + unlock_user(p2, arg2, 0); + exit2: + unlock_user(p1, arg1, 0); + return ret; +} + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -8315,6 +8351,21 @@ IMPL(time) } #endif +#ifdef TARGET_NR_umount +IMPL(umount) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(umount(p)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8416,69 +8467,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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))) - 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: { @@ -12569,6 +12557,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mknod); #endif SYSCALL(mknodat); + SYSCALL(mount); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif @@ -12583,6 +12572,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_time SYSCALL(time); #endif +#ifdef TARGET_NR_umount + SYSCALL(umount); +#endif #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif From patchwork Sun Jun 10 03:00:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138096 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2581841lji; Sat, 9 Jun 2018 20:17:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ9+XWJIoChBPQsothiXfNOJWmloAKivSzu9DBkZOmZx8lSGBPoJAOYk2dgGt3TQAAqx1o4 X-Received: by 2002:a0c:8c0b:: with SMTP id n11-v6mr10877565qvb.228.1528600632965; Sat, 09 Jun 2018 20:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600632; cv=none; d=google.com; s=arc-20160816; b=0kMuWTN4r4BXCaXdhVi6Dxte49xD9CdGh8+m+NObyZTuRqYVOxTqRulUQbSWixnfQn dJSBrtvVT2rmPswAOBwZhALT7BsSE8NJS16E/7+GQWisKnaxr1eGT1CYXOzkN/cGjeQv HsYSwea9MEuI8gG4llxQ53V0kYSPvn5lrDwutu6/DYRx6VjpQYVfJd51EQbPmID3gDKm GHUDQOp5VUeeawM1C/hJbeJA41SXQvtH70oGHHV78Sff89LWEXVd8Gv8yaJyxexrArfk M1BQagoYDRN9uPhfeQX9pOcAkLyPFJYpNBTi6aXD9ZmnGJlFQcJ3/m/MiCMFFudivc56 DImg== 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:arc-authentication-results; bh=QiiTLx4J3Rq2i0DJJV9Cz+JFpE6QW7LVFLjNNbjqNzY=; b=z+zyEbVhU5Qz20Fv7DRGjSHXXb3FJVWlgwlvpGeAj97OaQPrU05zeH0HV4ABUnDKFf toctpPiLKV/v2oD7RrsiWi5MQEv/dy/aBw948qMQC9PtzWmz4+kDzdSuHn/AlhdHTI50 ujicv5V8GmZHzeCRbXjwe+gfGMrdYSuhpP2STW3G4SDtp6eLgVXPPHwI+QOq2Oxs5ssm Cabcwa7iSEb5kJMmx+cFAClj9tjq/LbkhEOOjHCAxNZFqbyrdCuQRC/1wGO3ZPZO42LH VcVkpOeH/+0doiUFDY5CHF9ylLlA24FFQ/hN7y2QKdXDnOcnlMn9QkENKu8rVDUMO8v+ GeFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A5ym05p9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c18-v6si670664qkg.61.2018.06.09.20.17.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:17:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A5ym05p9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqqu-0005pn-AK for patch@linaro.org; Sat, 09 Jun 2018 23:17:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdM-00025a-IB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdL-0003LC-CC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:12 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:40841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdL-0003Ku-40 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:11 -0400 Received: by mail-pg0-x242.google.com with SMTP id l2-v6so8127289pgc.7 for ; Sat, 09 Jun 2018 20:03: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=QiiTLx4J3Rq2i0DJJV9Cz+JFpE6QW7LVFLjNNbjqNzY=; b=A5ym05p9RQEqNofqSk1boSz6+0Q9rtulP5L+CeV0LrOag85Ko4FVPSyaOvXbRX/Lbl 4PYlDqa2rCUL02G2EG0bjEV9wicCD6rfsfGr2nEaiiEJFiXhcYsjYopHiHuyv0dUybd5 AulAIDK50gSWxBZKbxAIAXTI67Hh/u5mpofLQ= 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=QiiTLx4J3Rq2i0DJJV9Cz+JFpE6QW7LVFLjNNbjqNzY=; b=X8t4czaZcrPn3KDJq80A+6xdTKVZ/vu/2C/8gkqEN+xOy4tWLh+DTtR3WthzEjubio xbe1gupX+wGW392KMs+O6rhhlPzb7wKATvTB16vBhR9OBGYzLMOJrROUqgH7XKyY5S/K 9F4Zb8YF6CxxTxbv/KeVVWNdokN1qku1g6Z5VuWtPfUDgz8R4czryzcjF1Xo+/nQYa+H yP/uXuokSr0WiZYQ8prBuDl77GiVXnUrVdMSOad/PMR0Brn1G9bxqdxY/MbqMDOjQRLA 2LjGc2yFDxg/T5+qgrylhGJvPHQexvfZdZqwvWItjhH0HCaWMGZ3s2xKGQQyL11u+L+1 tGnA== X-Gm-Message-State: APt69E3TICZSCxn8b13CwFMhfxDLTug/yqkrL/+LOVXMe7GfPlsmt9Fw 2nHCEbLgHVA9X8Ui0xCCnV8drE+jVDQ= X-Received: by 2002:a65:5d8a:: with SMTP id f10-v6mr10631476pgt.119.1528599789910; Sat, 09 Jun 2018 20:03:09 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:53 -1000 Message-Id: <20180610030220.3777-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 021/108] linux-user: Split out alarm, pause, stime, utime, utimes 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 | 155 ++++++++++++++++++++++++++----------------- 1 file changed, 93 insertions(+), 62 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 844e771488..d5f7519e62 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7871,6 +7871,13 @@ static abi_long impl_##NAME(void *cpu_env, unsigned num, abi_long arg1, \ abi_long arg5, abi_long arg6, abi_long arg7, \ abi_long arg8) +#ifdef TARGET_NR_alarm +IMPL(alarm) +{ + return alarm(arg1); +} +#endif + IMPL(brk) { return do_brk(arg1); @@ -8319,6 +8326,17 @@ IMPL(open_by_handle_at) } #endif +#ifdef TARGET_NR_pause +IMPL(pause) +{ + if (!block_signals()) { + CPUState *cpu = ENV_GET_CPU(cpu_env); + sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + } + return -TARGET_EINTR; +} +#endif + IMPL(read) { abi_long ret; @@ -8339,6 +8357,17 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_stime +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 IMPL(time) { @@ -8394,6 +8423,55 @@ IMPL(unlinkat) return ret; } +#ifdef TARGET_NR_utime +IMPL(utime) +{ + struct utimbuf tbuf; + char *p; + abi_long ret; + + if (arg2) { + struct target_utimbuf *target_tbuf; + 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); + } + p = lock_user_string(arg1); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utime(p, arg2 ? &tbuf : NULL)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_utimes +IMPL(utimes) +{ + struct timeval tv[2]; + char *p; + abi_long ret; + + if (arg2 && + (copy_from_user_timeval(&tv[0], arg2) || + copy_from_user_timeval(&tv[1], + arg2 + sizeof(struct target_timeval)))) { + return -TARGET_EFAULT; + } + p = lock_user_string(arg1); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(utimes(p, arg2 ? tv : NULL)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(waitid) { siginfo_t info; @@ -8467,68 +8545,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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); -#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: - { - 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: { @@ -12528,6 +12544,9 @@ static impl_fn *syscall_table(unsigned num) /* * Other syscalls listed in collation order, with '_' ignored. */ +#ifdef TARGET_NR_alarm + SYSCALL(alarm); +#endif SYSCALL(brk); SYSCALL(close); SYSCALL(chdir); @@ -12567,8 +12586,14 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(openat); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(open_by_handle_at); +#endif +#ifdef TARGET_NR_pause + SYSCALL(pause); #endif SYSCALL(read); +#ifdef TARGET_NR_stime + SYSCALL(stime); +#endif #ifdef TARGET_NR_time SYSCALL(time); #endif @@ -12579,6 +12604,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(unlink); #endif SYSCALL(unlinkat); +#ifdef TARGET_NR_utime + SYSCALL(utime); +#endif +#ifdef TARGET_NR_utimes + SYSCALL(utimes); +#endif SYSCALL(waitid); #ifdef TARGET_NR_waitpid SYSCALL(waitpid); From patchwork Sun Jun 10 03:00:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138093 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580750lji; Sat, 9 Jun 2018 20:15:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxR+rR+PmAroU8BbCsHNgrCZ7tL9b3XBik35bCudWxCVLrJbydqS/2HrYy6qL3yp/fch0D X-Received: by 2002:ac8:2be1:: with SMTP id n30-v6mr11044119qtn.18.1528600511963; Sat, 09 Jun 2018 20:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600511; cv=none; d=google.com; s=arc-20160816; b=So6chm0wIkWAt39m69RAOnJdYqTXgGY00axh0M3sF+kwkhIz7UHrRVujH6c4yHQPXs r3g/6Gq/OxlSFJ6ttXFoCGKDxsu96mLNt9966hxTdWWudE1wWANs5ZKq5/GEM/my9Kgu DZbO3Pyjh5f6V1xGMCQpAGvi0nkCotmNh6Jus9gquEKAhh/RTq+GE2hT7LaFfgQSewSP 4Do0udwfoHDnSVOSj4wRySBNXV35gbVhz1DeP9U1JY1Uxe7kdyT7dTcX62cIFpnkS7kH jOWiRqPQCCcZ6UqwLC2SZjKDB3BxLzSValD+/HgbThg115AojyRKErmZWmY6lFRl+rs/ zKNA== 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:arc-authentication-results; bh=TlwGDowEzig9O8tykcxop59hqYNHijUGPvLIhQuLKuw=; b=P3vUgKu+oBfJbIsl5G+XQqMGZ6rfAdaCMFAWCCss613gQKpmairMoePg5C3FXw9npd suH4Z+XoqCge8D9sagvBHmH1vi71VS8xPtt3pvyw2YWg60+WFanhboxluunlSDNY/NYM UnwByGHq676rp9nZ9GWzEkPSDCFP/wQXM1bDCRnH08xBDh2Yn6AazwjjssOBOy7Lwrhw iKflgRSErnANG/1IE2fqasqQKXiobxhnBuL43u3+DdVaWfR1okUjx77a9mrk7VfqhP0R Xuzu8Is2C9c0U8UAlc1VqDAesO4hWjci15HzitgS7JCitdWmkNqqGwP8UBvrgDciH8db XNZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aJGP0RRg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m42-v6si7758563qvm.136.2018.06.09.20.15.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:15:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aJGP0RRg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqox-0004Bb-AS for patch@linaro.org; Sat, 09 Jun 2018 23:15:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdR-00027h-66 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdO-0003M5-2i for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:17 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:44108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdN-0003Lk-QL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:13 -0400 Received: by mail-pl0-x241.google.com with SMTP id z9-v6so10386379plk.11 for ; Sat, 09 Jun 2018 20:03: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=TlwGDowEzig9O8tykcxop59hqYNHijUGPvLIhQuLKuw=; b=aJGP0RRgXQ2It8CUO7tRrMIgxHcu/H07Mkjam1Ea87mb8L9maIUgGcHHCuRZ4i2Dw4 UP7OA98+NJtRoq5ZApkHZrmdoR4Ha0DnX57l56RLLXHWKp6ARhxLlFjLguuMJQajc7Hg U+NIBxMOlBjzz4j7tti2hc5OC2wBEVs5RFYlc= 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=TlwGDowEzig9O8tykcxop59hqYNHijUGPvLIhQuLKuw=; b=p7iUQjmIAqEXmhq+owHPv8Mu/2Xn47naGlZ7KlGRCGS230O8/afHsJJH8tZaNkUkJS gGmMXWrURYzG6cItKHxm+kevjbN6bCeikc1++l06Zyu4dmSkOxqIqPIWS+B2EAt5e+p9 h431HN+5An7KR/LQb2C3yP6+MTGv9pdKxaCkwI3ClvBzPusnuSnci7gQ35d8hl54Ua6Z +Fd5FmUju8Gpkb59oWduPgLgQmMmq3IvCDjfIfgMChL+I3W1rqMgvyat9PfJ3LWMK3sR NYhPOB1m1mi1/HlTLosgMUpLnd2qDYgkivbRdY1XQ49otawdUqn/fpZXDJDUHkVCvhcP /N2Q== X-Gm-Message-State: APt69E2h5gq2bSMcr6o6iY/lpJsxUUarAhix+LvVCWIZCPOOab1I6nlb lIxH/dyMMoVEowCSwqUOkirOdfg1bYE= X-Received: by 2002:a17:902:1004:: with SMTP id b4-v6mr12927890pla.82.1528599792434; Sat, 09 Jun 2018 20:03:12 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:54 -1000 Message-Id: <20180610030220.3777-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 022/108] linux-user: Split out access, faccessat, futimesat, kill, nice, 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" All targets define faccessat and syncfs; remove the ifdefs. Fix the missing flags parameter to faccessat. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 143 +++++++++++++++++++++++++++---------------- 1 file changed, 91 insertions(+), 52 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d5f7519e62..6729a960ea 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7871,6 +7871,21 @@ static abi_long impl_##NAME(void *cpu_env, unsigned num, abi_long arg1, \ abi_long arg5, abi_long arg6, abi_long arg7, \ abi_long arg8) +#ifdef TARGET_NR_access +IMPL(access) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(access(path(p), arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8080,6 +8095,19 @@ IMPL(exit) g_assert_not_reached(); } +IMPL(faccessat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(faccessat(arg1, p, arg3, arg4)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef TARGET_NR_fork IMPL(fork) { @@ -8087,6 +8115,29 @@ IMPL(fork) } #endif +#ifdef TARGET_NR_futimesat +IMPL(futimesat) +{ + struct timeval tv[2]; + char *p; + abi_long ret; + + if (arg3 && + (copy_from_user_timeval(&tv[0], arg3) || + copy_from_user_timeval(&tv[1], + arg3 + sizeof(struct target_timeval)))) { + return -TARGET_EFAULT; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(futimesat(arg1, path(p), arg3 ? tv : NULL)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_getpid IMPL(getpid) { @@ -8102,6 +8153,11 @@ IMPL(getxpid) } #endif +IMPL(kill) +{ + return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); +} + #ifdef TARGET_NR_link IMPL(link) { @@ -8256,6 +8312,13 @@ IMPL(name_to_handle_at) } #endif +#ifdef TARGET_NR_nice +IMPL(nice) +{ + return get_errno(nice(arg1)); +} +#endif + #ifdef TARGET_NR_open IMPL(open) { @@ -8368,6 +8431,19 @@ IMPL(stime) } #endif +IMPL(sync) +{ + sync(); + return 0; +} + +#ifdef CONFIG_SYNCFS +IMPL(syncfs) +{ + return get_errno(syncfs(arg1)); +} +#endif + #ifdef TARGET_NR_time IMPL(time) { @@ -8545,58 +8621,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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))) { - 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)); -#endif - 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 case TARGET_NR_rename: { @@ -12544,6 +12568,9 @@ static impl_fn *syscall_table(unsigned num) /* * Other syscalls listed in collation order, with '_' ignored. */ +#ifdef TARGET_NR_access + SYSCALL(access); +#endif #ifdef TARGET_NR_alarm SYSCALL(alarm); #endif @@ -12558,15 +12585,20 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(execve); SYSCALL(exit); + SYSCALL(faccessat); #ifdef TARGET_NR_fork SYSCALL(fork); #endif +#ifdef TARGET_NR_futimesat + SYSCALL(futimesat); +#endif #ifdef TARGET_NR_getpid SYSCALL(getpid); #endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); #endif + SYSCALL(kill); #ifdef TARGET_NR_link SYSCALL(link); #endif @@ -12580,6 +12612,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif +#ifdef TARGET_NR_nice + SYSCALL(nice); +#endif #ifdef TARGET_NR_open SYSCALL(open); #endif @@ -12593,6 +12628,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(read); #ifdef TARGET_NR_stime SYSCALL(stime); +#endif + SYSCALL(sync); +#ifdef CONFIG_SYNCFS + SYSCALL(syncfs); #endif #ifdef TARGET_NR_time SYSCALL(time); From patchwork Sun Jun 10 03:00:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138091 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2580057lji; Sat, 9 Jun 2018 20:13:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKJkjeKYsobNHhsuKulZkCW+UFiOr4XrafQb3CxkGyaxBpCeDmfROlQIo1CUKOJPjZJhwUW X-Received: by 2002:ac8:1a57:: with SMTP id q23-v6mr11788172qtk.297.1528600436957; Sat, 09 Jun 2018 20:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600436; cv=none; d=google.com; s=arc-20160816; b=Izo6ECF/K4djfddS5rAYRjXc8mMX4d7VP8xmlQPZA4udOnm8UAoGqGlf0c7TiN/Gf+ o/wtvryUnT7bZDAACzPUDhc09kKMBuS6p7Zir2oQI1/tTAS8e7kqSO9m3bPwpfVgOHhW ZVr22V4LjxUAlrBrS8tYRSuWd5SCmfxq2qAUAKoa+oK1b+pcWCTwk5cFqLaZkZVi5C00 QoLGFTYg/QHT9fR6TAF0+T/Dpy3ljIOPHSsctJPyD0FTh30Pn8VNz7aJJWL9VMI/Qv9G Sh+WwHMjdkVocK2ukYjqIBkz9LUzWgxcQbeS/Si7TQzel737H5K5HRbTNxmhYp4/gh31 Tz2A== 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:arc-authentication-results; bh=WzmxZGdBvDscGIP/VGLn2OBk+WbNmgR42R8XKXkR1x4=; b=HOJg5GpKx4N9oz2bUP6TnP48Ts9oRdatfeAJ6OZ+6RIzMqvKacpyqahvto+16Xy4qi mJ1lD8XME6mrHdHJaBt/UkLE2jw+ql1rTE0FSuS5M692sUzyg82KwTvTff9LgFDyX662 lw9uhDbr9XDbWFAi2XwZLWaQ+m4jtelNBea6vCyQRKs7VcMNV2qzzkb/dBpr83XJJu/4 RB2q9KPAw3wHL1cD2DC78i9gZ3nkadZfcbqQdSv1TuDzaNWq83t3ZCojl9A3+BHbAxjC O3NwoIzxEZmYX7ysIZG4CaLqg2khx8uXCvs578kEqeyu/bi+MauDjzHOigvybke/wAY9 JiCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cog0wfr3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u10-v6si13317099qkk.26.2018.06.09.20.13.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:13:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cog0wfr3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqnk-000328-DZ for patch@linaro.org; Sat, 09 Jun 2018 23:13:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdR-00028L-T7 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdQ-0003N1-SK for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:17 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:34528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdQ-0003Mc-M9 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:16 -0400 Received: by mail-pl0-x244.google.com with SMTP id g20-v6so10400192plq.1 for ; Sat, 09 Jun 2018 20:03: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=WzmxZGdBvDscGIP/VGLn2OBk+WbNmgR42R8XKXkR1x4=; b=cog0wfr38kxOu8tWF6dRDl+hE1TEVnkqQnhqjIGt440ia6K4MGUjK1Z1FgIKQoQdfh z1QtxqFEPupMH+o9/dkkfK6aZrq0NZbe61xmiYFC0kw+In/aECzoloH8UpGODpUHkzcr XQAjcP2VEqWzbFv/f0PbemyHVBOgjp9+LwXiA= 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=WzmxZGdBvDscGIP/VGLn2OBk+WbNmgR42R8XKXkR1x4=; b=QMd8P7epOFxBPD0DPOWBuy7HLUl2cza5CqmT9NP59Cb2N15Eo4ypYjRu7DZ9k7VEY0 XBotphS+0qga+Ls2W/9keJ1Fj4A0ggzPR7P4nyNhUZbNAUY41n15T579XktZwvUkIcEZ guBKLMtTcWQFOQipCp075NQOzaaN76dFHdMBjAngtxZYU3zXWSKO5kIMLR8wNV5+j9Ya oanOJUe9odP4rsrbvXmX4opiWdvOXYlU8EUkFtji0anXdkH3qjbLSdJS9WwzIYtSEsk1 vm+U6WkSH0aYTQaGfZo8nvhGjo8tvS3eveauC2bEblgb9GUKR62J3VxIiY5252KOg3Fq A8rw== X-Gm-Message-State: APt69E1/VuBphwAWfGR4QOmMlIs9Uz39AdbzKxFXbdOVPfZfuRpxRzBf oQQHFU7ZkbGsgyAhuk4gkb+doz9uw+4= X-Received: by 2002:a17:902:9f84:: with SMTP id g4-v6mr12918048plq.339.1528599795369; Sat, 09 Jun 2018 20:03:15 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:55 -1000 Message-Id: <20180610030220.3777-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v2 023/108] 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" All targets define renameat2; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 101 +++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 48 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6729a960ea..e0a5d86956 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -628,7 +628,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, @@ -644,7 +643,6 @@ static int sys_renameat2(int oldfd, const char *old, return -1; } #endif -#endif /* TARGET_NR_renameat2 */ #ifdef CONFIG_INOTIFY #include @@ -8420,6 +8418,52 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_rename +IMPL(rename) +{ + char *p1 = lock_user_string(arg1); + char *p2 = lock_user_string(arg2); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(rename(p1, p2)); + } + unlock_user(p2, arg2, 0); + unlock_user(p1, arg1, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_renameat +IMPL(renameat) +{ + char *p1 = lock_user_string(arg2); + char *p2 = lock_user_string(arg4); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(renameat(arg1, p1, arg3, p2)); + } + unlock_user(p2, arg4, 0); + unlock_user(p1, arg2, 0); + return ret; +} +#endif + +IMPL(renameat2) +{ + char *p1 = lock_user_string(arg2); + char *p2 = lock_user_string(arg4); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(sys_renameat2(arg1, p1, arg3, p2, arg5)); + } + unlock_user(p2, arg4, 0); + unlock_user(p1, arg2, 0); + return ret; +} + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8621,52 +8665,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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))) @@ -12626,6 +12624,13 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(pause); #endif SYSCALL(read); +#ifdef TARGET_NR_rename + SYSCALL(rename); +#endif +#ifdef TARGET_NR_renameat + SYSCALL(renameat); +#endif + SYSCALL(renameat2); #ifdef TARGET_NR_stime SYSCALL(stime); #endif From patchwork Sun Jun 10 03:00:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138095 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2581656lji; Sat, 9 Jun 2018 20:16:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIq8OpO7BuopPxvIJPklI+4nRurV8aAighPDpVkwWt/Or/GVLLdw6HCU+1RlUI6cQW5tOxx X-Received: by 2002:a37:16e0:: with SMTP id 93-v6mr10938211qkw.148.1528600611868; Sat, 09 Jun 2018 20:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600611; cv=none; d=google.com; s=arc-20160816; b=FczTssN4sTK0VZhEWpuIeP6HrUtMBTBStJfPCaiX5WfBRORt4v2scLjYWfScJvsr3v WrPouG4s2RtREquLlluO6KDd3NKOZtA5WdnfyKh5+itNBWMpWCVOy+h/dhoxmKLLulMI /GR7HhJq9t7NwwDfXbww8IVDLIYNdGtHtP3YfivaGwyu7oT0M5bOlBrdrMb45leb4rn3 y6kKcSfqaaTCAfT8ceLan7vewuZsSlZnsgd+4HFX6PnycqSBuHIf3vsDrtgAyCR3/epD BL8fh6GxN/ex6abfuIYQWdMkKUoUsdwXW6MSlwYiD3lU/BlJ1F7roIk/3yy4DNqurbJy cTTg== 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:arc-authentication-results; bh=afOKpGObluULY1TIOPi+7mfMElPYC1od3X+Z6eVUsKk=; b=0afFTGtwAwPcQEYEyyrzU++axhT6sKgSyh35D2nnlGR9dW6HBSMtj6ZToZ/NQumkk4 ccOqiaT51RnSGZblFtZ681it4DU6FiElpNCueZiICXGQieHoQY2WMTiTsvC2KeWXunpB zIzoe7G5t3QKjZraRiIkkgi6sJQb+3bk1fKsakxqbuRBXZMQkaYL543XsARGuAeLonhX Mxau+9zcWyj0gwqjpQ+ZLWY5eWulyQEA5O3IDB5HAvez0WElWqiCNmI9QgbwF7Qd+MeQ xQhLnLriFDv4L45IED5FgPGutcSeEE6Vp0GdsAv5S+VLxISdtZ85txPCImifb3Rk4sIS 8skw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ij+CKuxu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z14-v6si4705435qvk.103.2018.06.09.20.16.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:16:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ij+CKuxu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqqZ-0005Yo-9y for patch@linaro.org; Sat, 09 Jun 2018 23:16:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdT-0002AK-N0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdS-0003Oh-R2 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:19 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:45905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdS-0003O8-LL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:18 -0400 Received: by mail-pl0-x244.google.com with SMTP id c23-v6so10384114plz.12 for ; Sat, 09 Jun 2018 20:03: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=afOKpGObluULY1TIOPi+7mfMElPYC1od3X+Z6eVUsKk=; b=ij+CKuxu77ntpFtIdee06rdy8eBAmiK2tMngO7FI3p0jnBjVDLXZv6t0PZIbr4yZDO qufWNPgQtUgRTCNOMnMnKv1lHgECd1wGJGrXy6X4TOgYwYh5RKsAksfW2Pc0QwDyOr65 0HRktjj/c1WqHEa4f9y+i+9gRE1301AE0tJCc= 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=afOKpGObluULY1TIOPi+7mfMElPYC1od3X+Z6eVUsKk=; b=obKi7zBH7Cnlcy+gNzPWNld+sQ+CMPelMRENQjEJ0vsGBMunlTDMC53mCZT/lJ1Kmj 0jH4JDhoX2pU6E3m2NK0vs0dlq7X3SiX7IMQCy9hbiRYB2fobFg5z2HuWUtriiCZTG6B Wh4c9FPDpZpTfjkOfny8o87VUQwTecvM0LcpZ3C9dOd5KT0lioJh/apNV8i1KWikKpcd fJXR9rh+VXt6I7W53anLXb/pBz036ohZRc4Pec7bGES2dem434ezavjLFiYBYg0npFtt JWPT4PbG3SqPNBPmk35jWaWsLmV8QCbj3BpLU0qkV4C7Ti5+EptqwR5o4P1bxEtkP6UY YzzQ== X-Gm-Message-State: APt69E1C3qcrCeQVNJPxnXNvZetT5mC0Y7dewVw9DNw5TjBHuQG55Zbk 2xXKBjaO4FzZL+tmHFAs7Icw6Aj+XOk= X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr2218917plb.255.1528599797489; Sat, 09 Jun 2018 20:03:17 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:56 -1000 Message-Id: <20180610030220.3777-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v2 024/108] linux-user: Split out dup, mkdir, mkdirat, 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" All targets define mkdirat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 90 +++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e0a5d86956..f22d45d2cb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7946,6 +7946,15 @@ IMPL(creat) } #endif +IMPL(dup) +{ + abi_long ret = get_errno(dup(arg1)); + if (ret >= 0) { + fd_trans_dup(arg1, ret); + } + return ret; +} + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8191,6 +8200,34 @@ IMPL(lseek) return get_errno(lseek(arg1, arg2, arg3)); } +#ifdef TARGET_NR_mkdir +IMPL(mkdir) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdir(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +IMPL(mkdirat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdirat(arg1, p, arg3)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef TARGET_NR_mknod IMPL(mknod) { @@ -8464,6 +8501,21 @@ IMPL(renameat2) return ret; } +#ifdef TARGET_NR_rmdir +IMPL(rmdir) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(rmdir(p)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8665,36 +8717,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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 -#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)); - 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); @@ -12581,6 +12603,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_creat SYSCALL(creat); #endif + SYSCALL(dup); SYSCALL(execve); SYSCALL(exit); SYSCALL(faccessat); @@ -12602,6 +12625,10 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(linkat); SYSCALL(lseek); +#ifdef TARGET_NR_mkdir + SYSCALL(mkdir); +#endif + SYSCALL(mkdirat); #ifdef TARGET_NR_mknod SYSCALL(mknod); #endif @@ -12631,6 +12658,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(renameat); #endif SYSCALL(renameat2); +#ifdef TARGET_NR_rmdir + SYSCALL(rmdir); +#endif #ifdef TARGET_NR_stime SYSCALL(stime); #endif From patchwork Sun Jun 10 03:00:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138097 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2582513lji; Sat, 9 Jun 2018 20:18:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIVIPUQlEXLRtl5LLwjKzyTD6YNiFEQdyubsecjsOfTfItHhjHcUb/PhM8X1xcI6tCsyFML X-Received: by 2002:a37:4a09:: with SMTP id x9-v6mr3341644qka.5.1528600699955; Sat, 09 Jun 2018 20:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600699; cv=none; d=google.com; s=arc-20160816; b=DKi2utOVNZR93q/R1MXtAjWJgZxz4k7VXMD8V+XcRFmuMGpi91fuCqKx+UyZMFFMmc EoASFUVqNuvpoEm6bNjs/pFO5OBiodoSKFuR11WV68vFZsT9VixoNMmQC+iWjqbgQiWR yJHYoQ7AaJd4pcCCnU5Csv2GnM4Al86y+w24Z3nITECVYhAziDg+jsRuJN/F/PFr3Mg4 sPOBUs9TN4w7csxA/7I2NtXx5J351BBHxfb0QeNu1Q8ZVpN2dswRTOSN4Y7+9jKcL/AD 8rztxtf3qVagTCzOtJo0Ed6B+I37p3NMPu9NK+izzprlOC68pNP1qgS1Kvp9H8414W+q USAg== 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:arc-authentication-results; bh=R4j+RT6f+GYqsFrf7zQPl8+tK/GawpYCnD8r6P5SW1Q=; b=LZn9OLzQVnLBNVDk0qf31Hg820GXWKTyVGsC/HQFUCevxpHd/DgwK3deDBjwxndPik vhAWrYpF9BIi4Gbpq0xSHRdFNaddFwyoLWW3hfrvdcG08GmGe0lnHvUKgbacWfM0GEVv FeXwFb11WYkZ0aAlUUfAHLLpzTRIsMRtqJSXaXImiZuiUQIn7wFfSlHxsNUcma0d9nCf LKN9MJNQ5sJQVDdSps6UPVdf9zzmY7ZozSJx/cFaPI2ADiLivWw2P6/uvL2HUB6oe1cx pmYaIaC290jaO8j/z32Njfp9F/rjjomSMXLXM7LjZpaa+ciDW1AmASRIEByTs7CUgJrx RMRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=La7lx9Uy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i49-v6si936178qvi.207.2018.06.09.20.18.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:18:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=La7lx9Uy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqrz-0006fy-A1 for patch@linaro.org; Sat, 09 Jun 2018 23:18:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdW-0002D1-BY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdV-0003Pq-42 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:22 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:35651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdU-0003PS-SR for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:21 -0400 Received: by mail-pl0-x243.google.com with SMTP id k1-v6so1987035plt.2 for ; Sat, 09 Jun 2018 20:03: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=R4j+RT6f+GYqsFrf7zQPl8+tK/GawpYCnD8r6P5SW1Q=; b=La7lx9UyBLVB5zgZGGFeRRmwj9DJFYy2z5xt9HxH6u9kapqqqwduarRTBJdNTXRwzh N+VWP+Ny7r8vbjev3P36pe4FXvxGdeSAc0n1TMNr4TK364OTyJv6xQiUdIsD5V0Au/O4 QP5C2M2EehCdyc4IOsDSeT+d7qJB8NBguW6xM= 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=R4j+RT6f+GYqsFrf7zQPl8+tK/GawpYCnD8r6P5SW1Q=; b=s2wmQHciQ06D0qaR6xjOMJUl+4VBM7RadzksUKSHWSGH2DRtJtFSv3sKME5j99h/hd LP8xHPleRsKRxekNDRwsEOvhGsFXGSNzePKTvs18TsSmRi0aFWnCMa72uiPFYMCZw5RR YnDA92UAWbSIPhN6Rq8naEoojDqMG+68v8ObzMGCd4KKx0o+TXU7eFbFHCV6lPEWmQUl mCwnQGP6aIZeR/GsygwqgciFMkaUhkHbMdDMz5qM89ylkIJecuryjexviMgrfHiqxelU /3gQnSZ3BDy+/2ebd7FeCniBlroJZufZL8yMe2bx0zIsMPERYYPGgyTa58ULzXwxmuqc N5ng== X-Gm-Message-State: APt69E2sucXrBgcatdlY+Q4kbOm5MEYoP5OCAr2nlRukXA1VekuUdDsp OlrVedI45NhHtrGVXW0IDDWD9BMAc8s= X-Received: by 2002:a17:902:d68b:: with SMTP id v11-v6mr12765650ply.16.1528599799673; Sat, 09 Jun 2018 20:03:19 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:57 -1000 Message-Id: <20180610030220.3777-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 025/108] linux-user: Split out acct, pipe, pipe2, times, 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" All targets define pipe2 and umount2; remove the ifdefs. Merge do_pipe2 into its only user. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 148 +++++++++++++++++++++++++------------------ 1 file changed, 88 insertions(+), 60 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f22d45d2cb..81e142f091 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1561,24 +1561,25 @@ 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); + if (flags) { +#ifdef CONFIG_PIPE2 + ret = pipe2(host_pipe, flags); +#else + return -ENOSYS; +#endif + } else { + ret = pipe(host_pipe); + } + ret = get_errno(ret); + if (is_error(ret)) { + return ret; + } /* Several targets have special calling conventions for the original pipe syscall, but didn't replicate this into the pipe2 syscall. */ @@ -1599,9 +1600,10 @@ static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, } if (put_user_s32(host_pipe[0], pipedes) - || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) + || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) { return -TARGET_EFAULT; - return get_errno(ret); + } + return ret; } static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn, @@ -7884,6 +7886,23 @@ IMPL(access) } #endif +IMPL(acct) +{ + if (arg1 == 0) { + return get_errno(acct(NULL)); + } else { + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(acct(path(p))); + unlock_user(p, arg1, 0); + return ret; + } +} + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8435,6 +8454,19 @@ IMPL(pause) } #endif +#ifdef TARGET_NR_pipe +IMPL(pipe) +{ + return do_pipe(cpu_env, arg1, 0, 0); +} +#endif + +IMPL(pipe2) +{ + return do_pipe(cpu_env, arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); +} + IMPL(read) { abi_long ret; @@ -8552,6 +8584,28 @@ IMPL(time) } #endif +IMPL(times) +{ + struct tms tms; + abi_long ret = get_errno(times(&tms)); + + if (is_error(ret)) { + return ret; + } + if (arg1) { + struct target_tms *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)); + } + return host_to_target_clock_t(ret); +} + #ifdef TARGET_NR_umount IMPL(umount) { @@ -8567,6 +8621,19 @@ IMPL(umount) } #endif +IMPL(umount2) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(umount2(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8717,52 +8784,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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; - 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)); - } else { - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(acct(path(p))); - 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 @@ -12591,6 +12612,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_access SYSCALL(access); #endif + SYSCALL(acct); #ifdef TARGET_NR_alarm SYSCALL(alarm); #endif @@ -12650,6 +12672,10 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_pause SYSCALL(pause); #endif +#ifdef TARGET_NR_pipe + SYSCALL(pipe); +#endif + SYSCALL(pipe2); SYSCALL(read); #ifdef TARGET_NR_rename SYSCALL(rename); @@ -12671,9 +12697,11 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_time SYSCALL(time); #endif + SYSCALL(times); #ifdef TARGET_NR_umount SYSCALL(umount); #endif + SYSCALL(umount2); #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif From patchwork Sun Jun 10 03:00:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138102 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2584947lji; Sat, 9 Jun 2018 20:22:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKguHNS//wwKcTb3qeoEWCRiQMspKKOLWlb8sJn/h3KTPvAie71ufYOSo1+I2NST3ZBfhBK X-Received: by 2002:a37:91c3:: with SMTP id t186-v6mr10823124qkd.37.1528600977684; Sat, 09 Jun 2018 20:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600977; cv=none; d=google.com; s=arc-20160816; b=kr6hpbeX/SempsdknFN7kAXOAypuR0kuUeTK7tLeQhqy/zzEjpkv8K0nyXJhZV5Bjo R47eOs2DJCSUU6dqGXS13PsWRUIy5vNMQ0f9P4UekotJHIlaosOMAcSXdEmuny/Vr0/i ojoBUnKilNyaeJRYTMGHXpQTz7ytkWnJ3LsrxlZCBctwyv8Q9QPaLJlmVeEu5kRE4B6s 5FWhUPpgjx70m11hsPsVvSm7ovc1fhldDZeIB1jeTV5YQOur7beiObKKrAzUmD08vPHx b8DfTYWFMIXfBWsxNKG6cv4MLg4LC6eE9XvgTzAZFgWXv28XDyDSPrQShvNzaHoIw1fA JgHA== 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:arc-authentication-results; bh=pcSZ52MrlGhMS8uvqUG+ZdJZ3IYLPDZ4l5v1NgkUIiQ=; b=cJLGVHdnVAT0sRupMJAGsbs5klFumHwGa3eHaL1wsO7BAv6o5vnxm/5e+4+fbmEe0/ Si2PIY5bzKLMlm+tuUzNHOyiwoJIPz6KVOKaWUxbEvMrD50nlAAFs3X+EGCfAqFvvGB5 AmNhnQBP2hMC7MV/DfBtq3JJN906w+IXFveSO8X+/VsTOW5Gfc1Yp+/pRYJupaTs6wOo rCvwP2y5H7M/4bt2yG6OyZoj7agssZlvm9SHlR4D/Nza0h8eN1EvjVfPUZ1fJdR7nFep l2bhevQena9VJmXAjQTKNqeiUqQVHGWefELW/IBzFDSdzqhVf18ijog/tGpPjfcW7dSF 57nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C/S9KUSl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j5-v6si2487898qvg.130.2018.06.09.20.22.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:22:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C/S9KUSl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqwT-0002Pg-3p for patch@linaro.org; Sat, 09 Jun 2018 23:22:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdb-0002Hu-3U for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdX-0003Qr-Us for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:27 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:41581) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdX-0003Qc-N2 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:23 -0400 Received: by mail-pl0-x241.google.com with SMTP id az12-v6so10379703plb.8 for ; Sat, 09 Jun 2018 20:03:23 -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=pcSZ52MrlGhMS8uvqUG+ZdJZ3IYLPDZ4l5v1NgkUIiQ=; b=C/S9KUSlgtimrnaawGdSdz720qJdIASt8S/35vhECriXvndBlxT4Ayq7x6USqYgN+v o6y0n69YU/gFQUtoMXnQCkp8/LtDXKE7quIc0INKheR+S2lTVcW5QNHmlFiWGkgs52L2 oln9ogO1bLsbhl9I7JcOAMZyvTXuwh4SEu3g8= 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=pcSZ52MrlGhMS8uvqUG+ZdJZ3IYLPDZ4l5v1NgkUIiQ=; b=ZJHdegWE9164VI9AE47bCM+V63mKlltW2Rrge/NkPOa3NdMd/Th4QTgLHqBpV7hx46 3CzFQ4ywD0m2U9XF7H/eAsM/CV7kw1tJePQNlBb+RrV/HjuIfH7ASiL608fgiPe/SEYl ZNBrnoG4YRyz9F5vKZsXhfhesx+86k/T/RcJBHWCG89akmOzwc+uW4OFC4EeGm/llFlf s2Q65LOfSTsge++Ahefk1nsiXWhXTo3Nbdknzss73iUmBGecbjfXqRWzfaq+9h9aExes xgqUGczIV7IoLlU6I/r6ALlBkQYjNe451mbsdoE1icmK1v9r+Vit2QBaDWHEoCIYWrsO PCsg== X-Gm-Message-State: APt69E1v45fUylEgHtk4qdIG7sOfg2utdlxPd7oZTHCo/XAItyfhxvTh 2fbTI7jksfZbsSFhrMd0JtcPPHGhfhw= X-Received: by 2002:a17:902:784d:: with SMTP id e13-v6mr12974182pln.197.1528599802522; Sat, 09 Jun 2018 20:03:22 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:58 -1000 Message-Id: <20180610030220.3777-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 026/108] 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" At the same time, merge do_ioctl into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 184 ++++++++++++++++++++++--------------------- 1 file changed, 94 insertions(+), 90 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 81e142f091..ebe57d86aa 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5754,94 +5754,6 @@ static IOCTLEntry ioctl_entries[] = { { 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 }, @@ -8179,6 +8091,99 @@ IMPL(getxpid) } #endif +/* ??? Implement proper locking for ioctls. */ +IMPL(ioctl) +{ + abi_long fd = arg1; + abi_long cmd = arg2; + abi_long 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; +} + IMPL(kill) { return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); @@ -8784,8 +8789,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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); @@ -12641,6 +12644,7 @@ static impl_fn *syscall_table(unsigned num) #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); #endif + SYSCALL(ioctl); SYSCALL(kill); #ifdef TARGET_NR_link SYSCALL(link); From patchwork Sun Jun 10 03:00:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138100 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2584274lji; Sat, 9 Jun 2018 20:21:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLh8IrWTu2JtnAWARg7ejbJtgKk5sv00JlW+s1XhN9GUxQeKQ1zpN9QFSXyjUwHDfsZ4rET X-Received: by 2002:a0c:d6c7:: with SMTP id l7-v6mr10893185qvi.36.1528600890281; Sat, 09 Jun 2018 20:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600890; cv=none; d=google.com; s=arc-20160816; b=HNDdk5OcCuFo5cgW8DWCH89K7tTJdYWFt6yKLq9+sdIqPebyVTAA5LA8HAZGnioG8z vTNtvrlZmGmD3i/n6m9+sFEeieE7LLfplQhHPv9Jjh2HuFDZb9xiy/KPSNQ/LM4MJ+V6 TsRH1S8mxXKlejl05BwogJeYKONSJbPpbXKu4ZxrNIPnA2XJkmdSffFZOB1UiGaa9poC jLkrW1kUfNtvznQ3AKCdSvvm1vkuxja3fkWT+QpNrVUhePI4GARifSw39mqG15pwhDDC Fk+nbvpL6pREdijwtPeJRbX98JAZZL/xLJoylJX2N1S/PAWf1JDUngj/I72reOovhrEq faUg== 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:arc-authentication-results; bh=Dr5d0oCNW5M4l5HB1MySFY3cQ+NoGuE+ieoRdjFlOso=; b=fRE+kseXUhBiuT09AJQ3WspcgKBr4izq+4I3xNVmY1mgOOygppmcJ47Z8njIy2je1a P/RS+UwBC7o4+77EeUxpJkw9so8XRlx5Bu+0oJ2g/NKE9D7vPkcyrIjmDJ6cSWDXuv7J +Dhj1WcxMFDFEIAeALPhcmC59m/ypn1qFmiV9a3YgtbTMz6jYjYBQSjxpsuX+BDhhbjE Sw5tkFIUf4QTfaMh+CLypnkjbdObROlJcoGuppvaxL5gZA6efCI4tKGTEd9+/BztLlEQ 5xjwsPugCQJo0TKhwPx2/c86l8BxOROG4b919Lt6Z6dXbQbpH3Lvu9u44r2OgH6Qp2YO ye8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d4+SmkOw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l127-v6si3123564qkc.251.2018.06.09.20.21.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:21:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d4+SmkOw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqv3-0000wv-JI for patch@linaro.org; Sat, 09 Jun 2018 23:21:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdb-0002IG-FF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqda-0003RK-Al for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:27 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:34528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqda-0003RA-2i for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:26 -0400 Received: by mail-pl0-x243.google.com with SMTP id g20-v6so10400293plq.1 for ; Sat, 09 Jun 2018 20:03: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=Dr5d0oCNW5M4l5HB1MySFY3cQ+NoGuE+ieoRdjFlOso=; b=d4+SmkOw0gZv37taI0bQtULiYC+IwYdZpBUps5jPnAqaMEzg0Xub/W93LgMl+p3okw 19ny4DrRWWkGFOQDSK4PtHlzwRTjesnBtMxPy5pfG1364BqTJGwBLbdSKgm086Fjnge5 tFee/an7hQTlQAzhEW7jpagzyFtYRWB85AKK0= 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=Dr5d0oCNW5M4l5HB1MySFY3cQ+NoGuE+ieoRdjFlOso=; b=pYDudK05nhl8iOp3pyn1jU/RkF4b4yDjBfxEEuEwrw7zFv4+GbQtbWQ67tMky/tIs4 vtZPc9+RQfA5pvVGMNrK75WKrTq1h8jLli2vzGUKCI0DGMVxQAjcEtEcovofS/6oqxVa ZBZFua142McgoNqCjuWerUAhKjUEemU/6Quisw8ciq6aaYjAJyG723vRYYnsmCfYnxrp rJdt2izzOkt0+/wan+0IGvVGn8qTEMZLJ3Tak7oFOik+voymt4XETrd/u6wEGvcBhl8N YiELT2/NUzGhIs0Ff9TIQZUctCMLcJl2vOHBMFdwcBBIYGuONMyY7h73XbD7PgU1mmdX MW8w== X-Gm-Message-State: APt69E0JZwvfw3g5FO9J9NkMQn0cUtn3H8u8i/pkIwT07823uIS9AIMB KyOotaau5Hx5plu3xiTGny21Jzla1+Q= X-Received: by 2002:a17:902:1029:: with SMTP id b38-v6mr12788953pla.277.1528599804924; Sat, 09 Jun 2018 20:03:24 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:59 -1000 Message-Id: <20180610030220.3777-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 027/108] linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, 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" All targets define dup3; remove the ifdef. If !CONFIG_DUP3, fall back to dup2 when flags == 0. This will help emulation of new targets that do not define the dup2 syscall, using dup3 as the syscall backing the dup2 posix function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 113 ++++++++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 38 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ebe57d86aa..8e13a16e91 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7855,6 +7855,19 @@ IMPL(chmod) } #endif +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; +} + IMPL(close) { fd_trans_unregister(arg1); @@ -7886,6 +7899,41 @@ IMPL(dup) return ret; } +#ifdef TARGET_NR_dup2 +IMPL(dup2) +{ + abi_long ret = get_errno(dup2(arg1, arg2)); + if (ret >= 0) { + fd_trans_dup(arg1, arg2); + } + return ret; +} +#endif + +IMPL(dup3) +{ + int host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl); + abi_long ret; + + if ((arg3 & ~TARGET_O_CLOEXEC) != 0) { + return -EINVAL; + } +#ifdef CONFIG_DUP3 + ret = dup3(arg1, arg2, host_flags); +#else + if (host_flags == 0) { + ret = dup2(arg1, arg2); + } else { + return -TARGET_ENOSYS; + } +#endif + ret = get_errno(ret); + if (ret >= 0) { + fd_trans_dup(arg1, arg2); + } + return ret; +} + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8046,6 +8094,13 @@ IMPL(faccessat) return ret; } +#ifdef TARGET_NR_fcntl +IMPL(fcntl) +{ + return do_fcntl(arg1, arg2, arg3); +} +#endif + #ifdef TARGET_NR_fork IMPL(fork) { @@ -8553,6 +8608,11 @@ IMPL(rmdir) } #endif +IMPL(setpgid) +{ + return get_errno(setpgid(arg1, arg2)); +} + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8611,6 +8671,11 @@ IMPL(times) return host_to_target_clock_t(ret); } +IMPL(umask) +{ + return get_errno(umask(arg1)); +} + #ifdef TARGET_NR_umount IMPL(umount) { @@ -8789,44 +8854,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: - return get_errno(umask(arg1)); - 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_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_getppid /* not on alpha */ case TARGET_NR_getppid: return get_errno(getppid()); @@ -12622,6 +12649,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(brk); SYSCALL(close); SYSCALL(chdir); + SYSCALL(chroot); #ifdef TARGET_NR_chmod SYSCALL(chmod); #endif @@ -12629,9 +12657,16 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(creat); #endif SYSCALL(dup); +#ifdef TARGET_NR_dup2 + SYSCALL(dup2); +#endif + SYSCALL(dup3); SYSCALL(execve); SYSCALL(exit); SYSCALL(faccessat); +#ifdef TARGET_NR_fcntl + SYSCALL(fcntl); +#endif #ifdef TARGET_NR_fork SYSCALL(fork); #endif @@ -12691,6 +12726,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_rmdir SYSCALL(rmdir); #endif + SYSCALL(setpgid); #ifdef TARGET_NR_stime SYSCALL(stime); #endif @@ -12702,6 +12738,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(time); #endif SYSCALL(times); + SYSCALL(umask); #ifdef TARGET_NR_umount SYSCALL(umount); #endif From patchwork Sun Jun 10 03:01:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138110 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2588028lji; Sat, 9 Jun 2018 20:28:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlRbbcMHjsxDu2Vg7k0uhdaJ+m/2bXSmSDFVGr/z41udxyLSobgmpChYXlonBMP8Y1Gbii X-Received: by 2002:a0c:9805:: with SMTP id c5-v6mr10877239qvd.9.1528601321933; Sat, 09 Jun 2018 20:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601321; cv=none; d=google.com; s=arc-20160816; b=RaO29QMcRAG3bdEMPeOt7jxSZ7d3BnFUFG62R1nc9awsZuOUNks9D9K+/gBpdJzb7M wy5zYmrfJgRFz6NXAuDePeynYiDBspRu8Vf61H6CiAg0rTNXO+SeuMdg4kLmCtURrikE W64lQrwzk+eXQ9J0d7/yXYqo4SFj9pOO8DaMtppUamSXb5GCbN8PbxeUiM3VAPFtvtN6 Vs1yqH4RWMeaPBWY8F574nyGDNQrwYLkEKXL77oo7TDqsb91jTecCP7WXd2FZE2KnMNn Hs7qMwIdQJMfeNpEgfn6TO0hefXIcd4Nh/p4yaCswYFL9dnn4ix/85wHcbB4z+vx6FZA AhKw== 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:arc-authentication-results; bh=T9juBo2ozVvgENxgpaulCOdTX0L1kHpLdmJiMUlcwRE=; b=Rjdrii/ytu2cmVW1uUNVjuhZoZdoZhCR8l/Qdl7TPj4HhY9tlqfydeAJYSIH6Mjqtn dOO6KGfF3P+kjB/6quFpd3qRS40033ktAgJkO23rpJTMnqKRhNx+Kze0GV2mHsz72Lyn StPT0lhpbTF6CbqqSWlKqnz/Mq8NvHUfwS2YFFzTrP/3FrXEAjFv6+QI+agSj21LcEHG IztTUR1vmOr8xnBkXYNPzAIyASsfkeaIQx1DMCrEJhCWLBd3Ajj5JOM9KobiKdLhW1Wt m4XETaz/khcX7vSPPIDC8WozWp0ZtkKIJbM4hAhE/dTPqbM8hyDGUf8xJ1wUnd4TYE5m aAEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IJQtL4vw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z197-v6si9161068qkz.375.2018.06.09.20.28.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IJQtL4vw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr21-000713-C6 for patch@linaro.org; Sat, 09 Jun 2018 23:28:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdd-0002KC-Az for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdc-0003SC-Eg for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:29 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:42796) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdc-0003Rr-8g for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:28 -0400 Received: by mail-pl0-x243.google.com with SMTP id w17-v6so10389854pll.9 for ; Sat, 09 Jun 2018 20:03: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=T9juBo2ozVvgENxgpaulCOdTX0L1kHpLdmJiMUlcwRE=; b=IJQtL4vwv0E+2PxyeU6OWys5CtAHasRE8qvtoesbWKMT7eCeFslnB+0U2XwB7HMeDn wE0Wejj+w3HlM/p92eIQsDGy+sw7vF7vRsweBV9JQfn3784MsT2eLS20yo4IZiThLAFN r73vxLZWDsdQAZyE12fc2jumBiGJb00gyb2ck= 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=T9juBo2ozVvgENxgpaulCOdTX0L1kHpLdmJiMUlcwRE=; b=aqJeM4F26AWUJ7XlMx9oMsqKCMbNLy/ni1x8gN76YwVKdlc9l/B2SKbY4iGFoF1dZb tbCFt3QPe2hBKVuzSkDZhqRMcW/QQqixEiYlqBvQ/w/OQr+1lrDywNtQw1cp5idT1H2/ yVC5i5MjOKu5aheOqFEOBuB4aHwv4l8wgtxGaB5TwJPuiM6VzzGj9Hha+O25JQKSAbvi 3KcQknoyZlli1LpHZD9KE/ts9luoNLvT4B0lCS4AN1aR/1xnCMK8UjQ+KRTbu1JgYNWw YMM3mvasNGB0UEuhIpCEblDnHcF8NE0dGwby/YuvKfl0+BHEPGqZ2dBgNabwvidgYmEz pShA== X-Gm-Message-State: APt69E2u/MeI1qfHWM2zlh9rNMInCnvfiqxqqSrh95xdTVRHcmc0BNV2 q3T3VxV+cpv9/rC52IaZ5arEyuy9YfM= X-Received: by 2002:a17:902:7248:: with SMTP id c8-v6mr13076098pll.128.1528599807054; Sat, 09 Jun 2018 20:03:27 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:00 -1000 Message-Id: <20180610030220.3777-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 028/108] linux-user: Split out getpgrp, getppid, 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.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8e13a16e91..d78288258a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8131,6 +8131,13 @@ IMPL(futimesat) } #endif +#ifdef TARGET_NR_getpgrp +IMPL(getpgrp) +{ + return get_errno(getpgrp()); +} +#endif + #ifdef TARGET_NR_getpid IMPL(getpid) { @@ -8138,6 +8145,13 @@ IMPL(getpid) } #endif +#ifdef TARGET_NR_getppid +IMPL(getppid) +{ + return get_errno(getppid()); +} +#endif + #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) IMPL(getxpid) { @@ -8613,6 +8627,11 @@ IMPL(setpgid) return get_errno(setpgid(arg1, arg2)); } +IMPL(setsid) +{ + return get_errno(setsid()); +} + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8854,16 +8873,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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()); -#endif - case TARGET_NR_setsid: - return get_errno(setsid()); #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { @@ -12673,9 +12682,15 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif +#ifdef TARGET_NR_getpgrp + SYSCALL(getpgrp); +#endif #ifdef TARGET_NR_getpid SYSCALL(getpid); #endif +#ifdef TARGET_NR_getppid + SYSCALL(getppid); +#endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); #endif @@ -12727,6 +12742,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rmdir); #endif SYSCALL(setpgid); + SYSCALL(setsid); #ifdef TARGET_NR_stime SYSCALL(stime); #endif From patchwork Sun Jun 10 03:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138113 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2589650lji; Sat, 9 Jun 2018 20:31:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKVp7gFyGnGIq2JZjOAv3a/bP2itY5pcjZHkJTfDSTmcZ3sNA/v0qU43S3Ofuj1mJAol2Dq X-Received: by 2002:a37:f50a:: with SMTP id l10-v6mr10227284qkk.109.1528601488095; Sat, 09 Jun 2018 20:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601488; cv=none; d=google.com; s=arc-20160816; b=G+BnMmxCk1MWlW5nY5xedjy3mvmye7ph4NDf9VQiFl49/UhioF+/DdhJnngbYpxYB+ LwPfIT1WX7P6mXonrL7TshEgSXNAR6P3SwPa+jD1vpAbMlbCb7TggrGXNDEs0ubLYKgB ZeAg4DARh/yE76fwXUgQYLNZdIXw5ap0rU5tVyLWTHJ7D76Mac5ZfUfkA4vPeQusf76N hQqkocePIbvqEclsPIHkuEgfoPn+l16ughWdXcq3e8iOFkFvyyYOCX3G2IVHKndFrlv2 GV/al21z7GR4AzgdqGs49OsalNy6LlHpFWr5HpY+5CJJKX3Kfx36Wm0W8qh5dhvTrbt4 iddg== 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:arc-authentication-results; bh=muVcap5oOTZx3qnIUkiQYwVwHlmYJy472O02cLaCR1c=; b=rKu2Dhge6G9yrkT1FgyMdJcaC1huPyim0ljk2jKaTGmxraz9Phux9I0kPt3d2FTydC kepg9g0EMDaR8XgOz5YZklh1AogN/e9L2lGIo6//J5eWeGI5OV8tEWoU7YDw4l+UZuo3 26RTvyRZ/xtqaAzCJU0fBTj4UXjLwu/at9mz7F34ApDCvMld7cHwACS+nCYqDUy0TUBF XDrA9cftDYX4GnyN4+Dh6Ao3djP1dNjs7i32FFbIbgEZv+KpKnoYJvWL0lTiqpWwIRxb tiYCJlOjyfpZ+UXlwIcJfR5ZDclffI2vvSRBrcGbFSQTs+BitJqDAYgwFPCjyrFoFszc /tig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cxiFje7w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a22-v6si13580144qkj.109.2018.06.09.20.31.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:31:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cxiFje7w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr4h-00019M-E9 for patch@linaro.org; Sat, 09 Jun 2018 23:31:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdg-0002Mu-2S for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqde-0003T5-Fj for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:32 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:45642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqde-0003Sj-7G for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:30 -0400 Received: by mail-pf0-x243.google.com with SMTP id a22-v6so8479543pfo.12 for ; Sat, 09 Jun 2018 20:03: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=muVcap5oOTZx3qnIUkiQYwVwHlmYJy472O02cLaCR1c=; b=cxiFje7wWReosg3f7twE2YJ+ZhoWRbAioz73ddiofMcbpdH5GJkCSW2F2PEuPB7z8L s8uylKOnQGrs38ZNpsVuBrMB3M7aGQ+ERa9Zl8Y5++f8ptWfz7QvLCu77YGoaMoWiryi 8svid2Db4qXvQZtSe+rWnoYQ6KphucYxTd31c= 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=muVcap5oOTZx3qnIUkiQYwVwHlmYJy472O02cLaCR1c=; b=dO80j/XuIIj7iL18/KNLfJsyfUw8s8cKgr1qRIZmH+mGDPa9cNV7wyl3cBwV0hgihN D70dRKGsziPwx4F5mUwNPtXQEpppfsVdZbwHy9OQXu6/DZPAsnKsgucWS0reGOcmgVNA TWPbMypn1d5QVHEjoJR4arohlveRW1wDAoYaAPMzI24F+2Ar8x8RKYVU8e3fpJUiTKhm slzYL5izMNOma6mxXZKj7WY8bKSqRrMv1H6kLUUr44yzSuG9H9/DvIB3LQ6qx/J1o5rh Yvyaz1hQrOM3pnsFMbeNzZDbn9vGzGyAmgor+TgBgYxkl4Mclclex8tLBHhQbmLX06hO MH7A== X-Gm-Message-State: APt69E00UJURWD+2dDAc0r6t01eskzUJd+Yvcs3pC53pHk7OU0ubHDGk gAYyn729iVIrDUNJkYi68/yGr6RUXhc= X-Received: by 2002:a65:660c:: with SMTP id w12-v6mr1723741pgv.404.1528599808948; Sat, 09 Jun 2018 20:03:28 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:01 -1000 Message-Id: <20180610030220.3777-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 029/108] linux-user: Split out rt_sigaction, 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.c | 325 ++++++++++++++++++++++--------------------- 1 file changed, 165 insertions(+), 160 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d78288258a..cdb4dd5bb4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8622,6 +8622,81 @@ IMPL(rmdir) } #endif +IMPL(rt_sigaction) +{ + abi_long ret; +#ifdef 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 = NULL; + struct target_sigaction *oact = NULL; + + 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 + } + if (arg3 && !lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { + ret = -TARGET_EFAULT; + } else { + ret = get_errno(do_sigaction(arg1, act, oact)); + } + if (act) { + unlock_user_struct(act, arg2, 0); + } + if (oact) { + unlock_user_struct(oact, arg3, 1); + } +#endif + return ret; +} + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); @@ -8632,6 +8707,92 @@ IMPL(setsid) return get_errno(setsid()); } +#ifdef TARGET_NR_sigaction +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_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 = 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 + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8873,166 +9034,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: { @@ -12741,8 +12742,12 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_rmdir SYSCALL(rmdir); #endif + SYSCALL(rt_sigaction); SYSCALL(setpgid); SYSCALL(setsid); +#ifdef TARGET_NR_sigaction + SYSCALL(sigaction); +#endif #ifdef TARGET_NR_stime SYSCALL(stime); #endif From patchwork Sun Jun 10 03:01:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138098 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2583401lji; Sat, 9 Jun 2018 20:20:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKH1Lz5rlcC3djJ/X2DIsmwpwqX2snhDO2/SNWit+B8MFHni85046QqakgQlXFo+7vcYlvH X-Received: by 2002:a37:2085:: with SMTP id g127-v6mr10103986qkg.402.1528600803241; Sat, 09 Jun 2018 20:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600803; cv=none; d=google.com; s=arc-20160816; b=rC/NagXwemGy04F/LbIe8EcN9UkGXArmDhxkQn2cCQpbEiq9+LzPa3teWbIEXVIqMo bpD2LA1cISZ3aHnuWYLm1C0rpWB+vOGvTnibNwtozBDPL1qgf5MNhfWRkdXxQLYg4Ivq YtwO39vqgDQlCHBu2+hB5vq60Cs2FQgDefb2RMBrj2rnO1nRHdUHkplmPXSFr2N3jzqx ua/KaVyN4EwDxPQjCf4gPEOH9sjwSKOk7FebafHSXVgpE2GKULF6OPoPGijOqHaZJvy0 Wm2zlBIh+5TRs6dOc2uYayEQaPqDY4Fa4dtTyyPzxVrdNO/n5+zNzmNb7mZ+RrMQJE4x ZdSw== 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:arc-authentication-results; bh=OU86JjjR2Bfp4cl+I7wJgMy91l6T/+cdMHYvOuVSfQk=; b=khDhMMnhwoKSTRzOc3V2LU5R9W4eNTDLcFb0xthMD3uszzX2EBYkPXe7G5i3ibhcRa xWNgyQP3jo4SRkLj0T6bLr/dqFNKZquxly0A63o5aZokYRyQlykaYN0i8JbBQrWnSwWy H0Z7ZdgeAPja65xueSOjh14OV2/unhCFElZpoaIFH3gkH9cy3V37GXV7B5AnL44pl4ak 0Bo00zwJXWmvfHR1QU7Yif1beKnPfua6hxCZ8TXa8/SLDJruBb6YPbCVQ0fxcNClrI6Z QjFVYiDDElIsTEO/77tWf9LoUjt3/5yRZcuQ88OMbQeiHJzV68wiBd5iN3YnprSNWymz N/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IQbMHcrI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n69-v6si2962328qka.44.2018.06.09.20.20.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:20:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IQbMHcrI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqte-00081R-IB for patch@linaro.org; Sat, 09 Jun 2018 23:20:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdh-0002Oh-LY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdg-0003Tl-Ah for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:33 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44839) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdg-0003TT-2U for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:32 -0400 Received: by mail-pg0-x241.google.com with SMTP id p21-v6so8127599pgd.11 for ; Sat, 09 Jun 2018 20:03: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=OU86JjjR2Bfp4cl+I7wJgMy91l6T/+cdMHYvOuVSfQk=; b=IQbMHcrIspXQ8byh1lA1Znuupy2KksJwbhwJLAA7s6uytXio4GPAdeSdMEFwnjpnLz UUSp9A2Pu9JdbcRb1PZEEMvOGxooURg9MxHyRLx0wPNUiRBspCeNXNX2UiL0Eqi9We7R XhNKsmuHo8IfUjjTDroICPtALvByl5pwmvrpw= 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=OU86JjjR2Bfp4cl+I7wJgMy91l6T/+cdMHYvOuVSfQk=; b=JGtRQx9CC8FBaPFzgzKRbRes+5A92Y4IPdDeABYb5FrJPLR0c+/bm2dxP9aVgTIuGX MIdlqZX/oOsUSYtm82624arL1W2Z3Ix7be4Um9tkemfULcyWx42gTkMHTruN31s89LsN NK0a2c4cvqVZgbvu3fImm3barmr3ceMUwoXmR47TJs2HyF5E1jYpZf9YQJ+59dNmkz2t aBn/yuAJ3vtACJxREiy1DkYj5N//hWbzHdu3WP7wkXGuvFHtqd2r2RT2wVpNOzzPzek9 zIHar49P3DbK8LpgAk7P53xpoG9ue0yct6OwGXXIOV7Ybz9Qb7JqGOSj2Q1TdMEr058k rfhw== X-Gm-Message-State: APt69E1/b1pRClmFDln7JTniwrAGQIytrT1dFncGUI6BTwO3iml3MP/R l7SlQvFfJ4S1NMIVJjzrt62pp+nPHaY= X-Received: by 2002:a63:7206:: with SMTP id n6-v6mr10229729pgc.174.1528599810844; Sat, 09 Jun 2018 20:03:30 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:02 -1000 Message-Id: <20180610030220.3777-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 030/108] linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, 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.c | 294 +++++++++++++++++++++++-------------------- 1 file changed, 158 insertions(+), 136 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cdb4dd5bb4..cc818ea65e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8697,6 +8697,65 @@ IMPL(rt_sigaction) return ret; } +IMPL(rt_sigprocmask) +{ + int how = 0; + sigset_t set, oldset, *set_ptr = NULL; + abi_long ret; + target_sigset_t *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_sgetmask +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 + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); @@ -8793,6 +8852,95 @@ IMPL(sigaction) } #endif +#ifdef TARGET_NR_sigprocmask +IMPL(sigprocmask) +{ + abi_long ret; +# ifdef 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 = NULL; + int how = 0; + abi_ulong *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_ssetmask +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 + #ifdef TARGET_NR_stime IMPL(stime) { @@ -9034,142 +9182,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: - { -#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: { @@ -12743,11 +12755,21 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rmdir); #endif SYSCALL(rt_sigaction); + SYSCALL(rt_sigprocmask); +#ifdef TARGET_NR_sgetmask + SYSCALL(sgetmask); +#endif SYSCALL(setpgid); SYSCALL(setsid); #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif +#ifdef TARGET_NR_sigprocmask + SYSCALL(sigprocmask); +#endif +#ifdef TARGET_NR_ssetmask + SYSCALL(ssetmask); +#endif #ifdef TARGET_NR_stime SYSCALL(stime); #endif From patchwork Sun Jun 10 03:01:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138117 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2591304lji; Sat, 9 Jun 2018 20:34:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdzqiOc+uQl9oAHbS4MUOQwyVytsRVCdY0E1/ANyHjq8uf95zAX4mXAKtt3riefkCykj7A X-Received: by 2002:a37:7044:: with SMTP id l65-v6mr10203671qkc.187.1528601657483; Sat, 09 Jun 2018 20:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601657; cv=none; d=google.com; s=arc-20160816; b=h1lwxnuUSynozLL80dhf9ZX58TVo0Dhw8td6oJIfgYnsqgKLmDyLfnAnBkahXgiNSh GdVpCSkwVBoL0iLOBAv3hldDUTgQCtDxfY8fCen2+z8yUg1hfn3xAHj1x5dfVD+2x7iw GYAhc7Rb3v6dNLu2fQ1MWCw6m+M0wO+phsWBdWN03V/RrS2yJOvEYqAejzhF9wcjFLgW 6xGlnlrlEf+l5IpFnj0AjTIvxOqUAPNW/YP8aI+qWHAc/1dj8vIbAleoGG1o0b+OM68K LxTVKN40DJWlNG7tZuF4X1U+1g3efzKSWvvOcAM+fh6xztowr+TQBgywrchX+X3ZTUVH mRKA== 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:arc-authentication-results; bh=RTUhwpTSkRz2YVJuO/N9YNNRZ/CAdKqRUxKILp8C9os=; b=RcLqJIv8MVqzxj/ekLuIfoqG4fM4pGtXC0kPloSlz2d52J6Z+5i71JK4u+6oclwceP csoPeIDyINotpKn+kXm84n9X6qemxOBeA+QR2xJjOYZuqHFnlyK+rlTZGrO2bPCtmCyw 2BDKpCFtxkH19zi93F2zCdFM0kZh4xHJbBirA0gj9Zd1B3nUQJoW4TxXUsK52ZdEjfzl bO/bZjvIgEJY4Hb6rPuz6amnF6/kUl2Xu2/RRVkVmBIVVG+nnrl6rM4tFLe7JL/wyxf8 YZeTxYyp+uxR/kmz2aBlyT+MpCGGHKXAwl4e6zhTYWMCejoqe+EQtDtYoIJq0L8Rd5NV 0P5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gPpbxgfV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t48-v6si415678qte.236.2018.06.09.20.34.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gPpbxgfV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr7Q-0003lo-U8 for patch@linaro.org; Sat, 09 Jun 2018 23:34:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdk-0002S6-Si for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdi-0003W6-Vg for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:36 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdi-0003Vk-Kn for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:34 -0400 Received: by mail-pf0-x243.google.com with SMTP id y5-v6so7583407pfn.4 for ; Sat, 09 Jun 2018 20:03: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=RTUhwpTSkRz2YVJuO/N9YNNRZ/CAdKqRUxKILp8C9os=; b=gPpbxgfVk6SPJ97CdZOlNByuCKWj3xYuVsvwPpErcnYdH0OmGwDaCHdB750AYx0a2t 2klb2vyR6jZbC9Q1IgCGh+VIqqbyd8erI1a/ZJ6kFv+DmhBO4ptjyBJ15NGuc5+8Eb2f igzS3ZkNA7YiPoSFaJOGyf+ON8xCZh0JhZtus= 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=RTUhwpTSkRz2YVJuO/N9YNNRZ/CAdKqRUxKILp8C9os=; b=p4Sitvm8pJ4rHHCU0aBQ2ySN2Nh+3m71KlxSIDn0qVYnFxHAldww23fODGZkhuPDv0 LdsOanPedEFN+G1InT9lXFCC5ni9Dm8v2O8KNmnW2OMA5E+2rN2uVTEFTnVxm9Alceh/ fyyT5RB8Kjg/kMu+yB6oomr2ssu2OsCmqoRu1EdkxMosCgMYOvjxbprXi4RXtA06rO/3 i1SrYNsrMvPS7u5wQmVjZ1DUVmRvBfJg4kMcXyZsixw/QLxNKSFpRIqbA5kfuLu/tEDg 4Tu7rj8KgoJu3c7qF2O7n5pj8jyuyFrjua49WQ3/9z6IX30URZLoP2MOsQFh5iWnDOPx DC4Q== X-Gm-Message-State: APt69E3+kwMS73IklezRw6u7mEjWHxDWhsligCRHI5vSShcjQqCFZ24J CIx3PpW+izbiY7csOKK994DLriuO5vU= X-Received: by 2002:a63:7906:: with SMTP id u6-v6mr10295632pgc.284.1528599813115; Sat, 09 Jun 2018 20:03:33 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:03 -1000 Message-Id: <20180610030220.3777-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 031/108] linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, 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.c | 176 +++++++++++++++++++++++++------------------ 1 file changed, 101 insertions(+), 75 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cc818ea65e..6869a0db47 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8697,6 +8697,32 @@ IMPL(rt_sigaction) return ret; } +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)) { + target_sigset_t *p; + 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; +} + IMPL(rt_sigprocmask) { int how = 0; @@ -8742,6 +8768,29 @@ IMPL(rt_sigprocmask) return ret; } +IMPL(rt_sigsuspend) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + target_sigset_t *p; + abi_long ret; + + 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_sgetmask IMPL(sgetmask) { @@ -8852,6 +8901,24 @@ IMPL(sigaction) } #endif +#ifdef TARGET_NR_sigpending +IMPL(sigpending) +{ + sigset_t set; + abi_long ret = get_errno(sigpending(&set)); + if (!is_error(ret)) { + abi_ulong *p; + 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 IMPL(sigprocmask) { @@ -8924,6 +8991,32 @@ IMPL(sigprocmask) } #endif +#ifdef TARGET_NR_sigsuspend +IMPL(sigsuspend) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + abi_long ret; + +# ifdef TARGET_ALPHA + abi_ulong mask = arg1; + target_to_host_old_sigset(&ts->sigsuspend_mask, &mask); +# else + abi_ulong *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_ssetmask IMPL(ssetmask) { @@ -9182,81 +9275,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: - { - 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; @@ -12755,7 +12773,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rmdir); #endif SYSCALL(rt_sigaction); + SYSCALL(rt_sigpending); SYSCALL(rt_sigprocmask); + SYSCALL(rt_sigsuspend); #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); #endif @@ -12764,9 +12784,15 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif +#ifdef TARGET_NR_sigpending + SYSCALL(sigpending); +#endif #ifdef TARGET_NR_sigprocmask SYSCALL(sigprocmask); #endif +#ifdef TARGET_NR_sigsuspend + SYSCALL(sigsuspend); +#endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); #endif From patchwork Sun Jun 10 03:01:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138122 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2592814lji; Sat, 9 Jun 2018 20:37:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI22NS3VdQHz1HGQfow+1fh3HHzsHkAF+ze3aiX66MiLP6LL0tzL/6xoancO4a8gAecErwq X-Received: by 2002:a37:f508:: with SMTP id l8-v6mr10233756qkk.434.1528601826773; Sat, 09 Jun 2018 20:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601826; cv=none; d=google.com; s=arc-20160816; b=vQ1RCjW5GqinrKCB+sVQf2HOA04dwWnFZ0ZUWmA4Yq6dSCwy7FkyISvLG+kbuapCDH acqwbKKI75henBG0AlnfzX4t7rVCAnKACTXjl6h3dt9n0n8jsOD6oxGoSqsSKF2KbPkU 4X9YiJcpmH6U8V+k6HtncizTsjU/R73Pwe6iQx9Ru6wY8+QAi+sxGc7QWN/ZqVeCQM67 ZAp0zZx1fA092q3MazU2vB6HDszygURvwrzTo8qzR8xU/u4Oeu0Kzk05YnsxJpnFNo2k WbGCiZJ0fVhAclMOhvBYKt2qe5IU7U4BDiN0dM+HJOQCGJ96XT6K4+ROb/qXeNx4yWv0 G0wA== 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:arc-authentication-results; bh=kZiVKj8/cdfgXpzW3ZGZCU7l5FhYHkHiIZvXR8y2SAk=; b=m1xiVSTyxYxc0AEKJUoLreMTAC4LMmk29k4Wiatyst3V/onumiWc6D2hKOfr6IoFdb MaS4GXXLG+sEmGteQX6kRmujlK38/3cCzLcfvJhKWhNoKlQviOs4W9qbzx6vzVYR5W9S pObWdLiIdkC0f7W/kIlZOOLe2K7/ff1eCb8zHQWUVoZo2IMMSXYoHJde9dcXcSmvoNHz lMp3jJPzwOGwWUAauqRjTYUM0mokQGGOABRTQmqrNxiEAJ5C+fdgGCLVqoXfxQSXjV78 cbysnrO/+X15tAeE/3bUYpAT1T3q+pXK7btUAdUeExEKkicjmERQFvklg4kOYpJidtqh l8pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YCGGipmQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x21-v6si4333139qtk.211.2018.06.09.20.37.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YCGGipmQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrAA-0006oV-4k for patch@linaro.org; Sat, 09 Jun 2018 23:37:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdm-0002Tl-Fx for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdl-0003Wy-Al for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:38 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:40843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdl-0003Wg-2d for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:37 -0400 Received: by mail-pg0-x243.google.com with SMTP id l2-v6so8127521pgc.7 for ; Sat, 09 Jun 2018 20:03: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=kZiVKj8/cdfgXpzW3ZGZCU7l5FhYHkHiIZvXR8y2SAk=; b=YCGGipmQat2J/HCX67HQX2KFBKqJMh0M2DLlKlI87MezEObE3WUWRd6i6kjpz+em+M nBj+aDlmE/nPI+y/B6maNcZLyMYzEFUavlXqzH/Hrw9SZSjlSVOsMi2Q9PNbFMkE+XrO YjCvvOC+hwGxv8QvOUNDSpCnoxUrtd6O72Zfg= 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=kZiVKj8/cdfgXpzW3ZGZCU7l5FhYHkHiIZvXR8y2SAk=; b=tnNy2rtjGC+bPQz97JEka1N1nd2HBJ9sjraBsn54Z+ukoTVujeLXOrXjKzIIg/V1Ks wTu73KIcV8F5EZcRDV6i4S3hREBPIIgCcs5tpLGyb/1njHXI9UGpuY+hwZ9RLNRAZN4D t/7T9vUDmIEfoL+w5/3s480Wgj6+hxtoGm/BxyYBX80xU+sOdo9R8DI/+2ZKEshPsV/p WWK3nVpr3ZTBM1vSursY19c9wLXhB0VlIie64ar8u1+QloP3tVVyzhA+zd1HreQH/5Lf yNT04WoHQ85v/7TsN9Bc1wcz6VGOIwsOyyQqAPoAax3ApiehilpAQqv+Mywu6cwx+sbY hTjQ== X-Gm-Message-State: APt69E1YP17rfzyzBtEyEcGHkoQX7U956oXOmis5dguAAq1R8S2hQyD6 67Kl66aMkseXhHqF7cWKnZ+Ms0bTZ78= X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr5029092pgv.306.1528599815828; Sat, 09 Jun 2018 20:03:35 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:04 -1000 Message-Id: <20180610030220.3777-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 032/108] linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait, 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 129 ++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 62 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6869a0db47..94dc773b4c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8768,6 +8768,20 @@ IMPL(rt_sigprocmask) return ret; } +IMPL(rt_sigqueueinfo) +{ + siginfo_t uinfo; + target_siginfo_t *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)); +} + IMPL(rt_sigsuspend) { CPUState *cpu = ENV_GET_CPU(cpu_env); @@ -8791,6 +8805,56 @@ IMPL(rt_sigsuspend) return ret; } +IMPL(rt_sigtimedwait) +{ + sigset_t set; + struct timespec uts, *puts = NULL; + void *p; + siginfo_t uinfo; + abi_long ret; + + 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; +} + +IMPL(rt_tgsigqueueinfo) +{ + siginfo_t uinfo; + target_siginfo_t *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_sgetmask IMPL(sgetmask) { @@ -9275,68 +9339,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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; - - 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()) { @@ -12775,7 +12777,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rt_sigaction); SYSCALL(rt_sigpending); SYSCALL(rt_sigprocmask); + SYSCALL(rt_sigqueueinfo); SYSCALL(rt_sigsuspend); + SYSCALL(rt_sigtimedwait); + SYSCALL(rt_tgsigqueueinfo); #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); #endif From patchwork Sun Jun 10 03:01:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138103 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2585221lji; Sat, 9 Jun 2018 20:23:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ9rufviGDdaG6MWGFtwniMdMQbMVZcTwXSkMP4Hnuzgt8V8cQfDy4sNt7UgTX3uNbYJrKx X-Received: by 2002:a37:434f:: with SMTP id q76-v6mr10148118qka.277.1528601012271; Sat, 09 Jun 2018 20:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601012; cv=none; d=google.com; s=arc-20160816; b=hMWnHniH1ldj6UUYkNa3VoajMlnkco6uIrn777W4YcKaBbDHLIQORtOcRTfDd4VQhk DVMcQXWnieN6I05fQcYwCEtPb2FJpJzUZp7yEjUo8NEC3FSJ9XP5GfHMeKmiiOABir6J Mrzacv/71JH0zt8s/ff27nIgBJBfLzA+/IhLlKv1/HP24iIFIxWR4UbEGvLkgSRXtIzb eANdsI2ZSdtA43U3+DQuyGxgp/2AMgpKBmWhBd6C4ZpqE87zMIpKE2W/vgrt4OIVll3c 1J5T2vBCwArgfeKj1/MHaAZsy0HFWNlQr9YGKYDczaPYoBMv54mzYACvK/3oYK5tgeOs qX6Q== 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:arc-authentication-results; bh=bUIbiyb6n/MWqS9aplOG1Wd+VcRE/eBlJtqcebCnTT0=; b=WYWZFHs3bl3bhlc0WMY3EcD4UyFiyidXJMAGrV8TNWvPSeGHpG6xJ43GffYNSfWMaD CJ/2zEKSejWMo08y6xYdw/w9TyazwQ0uJ0uKXNxe/8Vhu8Xe/K3AbbNT+vqXPH4eZUS1 GMDOvNOj8jce32KZw8MT6WLVz2riEZ+SPz6IAYFeOunr479Q4ZZt+cCvBSn4CkM1Syua rxsQdTaySWSouGq+jhXl0fIlrYzoLYrGb+BLDwM5P46+az7l/x+xsgPyVMOaY54JT9RJ +xZ+WORWdYhzvt+joS7iMOJHu7R+7FzAIwX4gXquT8zNxa0qDG0UDM1v3JIql1r7rggo XSkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ws2jBF0+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r65-v6si5130110qkh.24.2018.06.09.20.23.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ws2jBF0+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqx1-0002YG-Mu for patch@linaro.org; Sat, 09 Jun 2018 23:23:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdo-0002Vj-CA for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdn-0003XV-Et for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:40 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:35908) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdn-0003XN-72 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:39 -0400 Received: by mail-pl0-x244.google.com with SMTP id a7-v6so7899198plp.3 for ; Sat, 09 Jun 2018 20:03: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=bUIbiyb6n/MWqS9aplOG1Wd+VcRE/eBlJtqcebCnTT0=; b=Ws2jBF0+xMChVXeqQDGBnmRPfrFb/ROgNNqUUfk7oQVv6+G72JC1MS9O4wZwAUZPAW OBvYZUZyZMg14voWux/KmqaGmFd/sPfxMtprqtJLs3hsMYlZxirUdYdk4WEIDqBmJl7V GRV0T3FuZ5bNzQiGJPHj3ZQSdCmoiN5loKgLM= 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=bUIbiyb6n/MWqS9aplOG1Wd+VcRE/eBlJtqcebCnTT0=; b=odoy6JHtSalnzebg+s7tOz/x3zsHSlZFuo6eUE37aJj4EHUmYWn7ekg+SpSDRjZa0e VzWFOu44NJqn3STndJBcKXpaNGJ1g2CObrE2b1yPWFvWySQAEbEg+0TdoSIlce+n9JV0 k5VJCznOiKfRlmZNWa9s207xQjKyjJSAbezBtTrBG+sq7YXwNjRM7vXFpUWG1ei1RyWF 40gpFqYp7Mo1uW7ElIEdq6MUf8yoz3AvVdD3nJuemdL3bt5nQvmEW6RaNl6Um4lHZkwj 2CXTHhrieuMqXz3FbZSsL6Vq/zMa9ZuPTSQRIo7Qn3K5ZE8kQjtIfa7Z23biPjbUq/S0 Ytkg== X-Gm-Message-State: APt69E2EnP5JggJVHwO0f5Cm8RSxXuLCbEEYMGEmEgMVF2/FfZ2QRTkp qVyYX7ljwVYGfJkQMmNZP+hswdwNohc= X-Received: by 2002:a17:902:24c7:: with SMTP id l7-v6mr13003491plg.170.1528599818040; Sat, 09 Jun 2018 20:03:38 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:05 -1000 Message-Id: <20180610030220.3777-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v2 033/108] linux-user: Split out rt_sigreturn, sethostname, setrlimit, 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.c | 85 +++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 94dc773b4c..ac3592d776 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8782,6 +8782,14 @@ IMPL(rt_sigqueueinfo) return get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); } +IMPL(rt_sigreturn) +{ + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + return do_rt_sigreturn(cpu_env); +} + IMPL(rt_sigsuspend) { CPUState *cpu = ENV_GET_CPU(cpu_env); @@ -8869,11 +8877,39 @@ IMPL(sgetmask) } #endif +IMPL(sethostname) +{ + char *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; +} + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); } +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); + return get_errno(setrlimit(resource, &rlim)); +} + IMPL(setsid) { return get_errno(setsid()); @@ -9055,6 +9091,16 @@ IMPL(sigprocmask) } #endif +#ifdef TARGET_NR_sigreturn +IMPL(sigreturn) +{ + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + return do_sigreturn(cpu_env); +} +#endif + #ifdef TARGET_NR_sigsuspend IMPL(sigsuspend) { @@ -9339,39 +9385,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_sigreturn - case TARGET_NR_sigreturn: - if (block_signals()) { - ret = -TARGET_ERESTARTSYS; - } else { - ret = do_sigreturn(cpu_env); - } - return ret; -#endif - case TARGET_NR_rt_sigreturn: - if (block_signals()) { - return -TARGET_ERESTARTSYS; - } else { - return do_rt_sigreturn(cpu_env); - } - 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; - 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); - return get_errno(setrlimit(resource, &rlim)); - } case TARGET_NR_getrlimit: { int resource = target_to_host_resource(arg1); @@ -12778,13 +12791,16 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rt_sigpending); SYSCALL(rt_sigprocmask); SYSCALL(rt_sigqueueinfo); + SYSCALL(rt_sigreturn); SYSCALL(rt_sigsuspend); SYSCALL(rt_sigtimedwait); SYSCALL(rt_tgsigqueueinfo); #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); #endif + SYSCALL(sethostname); SYSCALL(setpgid); + SYSCALL(setrlimit); SYSCALL(setsid); #ifdef TARGET_NR_sigaction SYSCALL(sigaction); @@ -12795,6 +12811,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sigprocmask SYSCALL(sigprocmask); #endif +#ifdef TARGET_NR_sigreturn + SYSCALL(sigreturn); +#endif #ifdef TARGET_NR_sigsuspend SYSCALL(sigsuspend); #endif From patchwork Sun Jun 10 03:01:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138108 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2587310lji; Sat, 9 Jun 2018 20:27:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI/8Zt3dvBm7x29F5uz6FjVxcdLAQCvF0A07gw1qJQiQgih4PWBzinC+NmseEwJqYT2FbUC X-Received: by 2002:a0c:fa02:: with SMTP id q2-v6mr10849244qvn.180.1528601240069; Sat, 09 Jun 2018 20:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601240; cv=none; d=google.com; s=arc-20160816; b=fQEm7KUFs8w8kgTXuuLWVAaE9XdPA3eNA/+97QREQV9gP74NSE7hGU2paIfXMd3Nmc NApFj3489tb1XnRyfKdzoOT1M8IyF3DcWugoBQb2ehhq17f4Y6cQDNjYrKq6y/pm6sV0 GXLNje3XII59Epl+AYjo9+0RKxbSl0jcRtPu58EvhkOHnoLIrFgOkWSIQ92tn0LNuTGZ 9A3tRgdXIJfoAbIX0YN67bzRtgtirXzWhcKGk0Vq7YkGAp7zUqjQ+5UNUqNMApqRHqSQ Bc8yJDn97CdwA9H5jUcV23zeyumV/TIuOMVawefL84IOzaYtNYBT6Ec3H3iHsYoaQftz povA== 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:arc-authentication-results; bh=+mg4OSZtYr0DKnNd7OfrN+O8v56yUUa43TFaTkc9T0w=; b=C+CbW9mS2r7GgE1bhhYIuGSX9cLi1QontysZoMDeUIP3tlRzMkrFFPEWeTMGktVdac TQ9CSow2AhTGJLLatQ/XhPEZJnCmF4J1lCH28OfREc+x8m0XcPadocaihTtaey4tYfAQ 30ZoAUfMkua7M1jbBu/41Eo2WV9poJUO/yJw23ihA3yN8EbPV3gFcW9sStDZtqVjk1DJ RZ2FKlzF3Rph+r74NuDz4UeFxjmrZIN0HuF4v+1vRbgf4ALhZ5Hf7NOs3hza0UVrX9ZX oOzjeloN/1gY1chWK4/gyPZ9AEHmssOlWluGMPNVQhtqZu7xRIJKqiw5uwduQ09IF7t4 VS6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i8y18Wdr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g9-v6si1421706qtb.376.2018.06.09.20.27.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:27:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i8y18Wdr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr0h-0005od-E9 for patch@linaro.org; Sat, 09 Jun 2018 23:27:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdt-0002aC-16 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdp-0003YR-TY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:45 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:43002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdp-0003YF-Lf for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:41 -0400 Received: by mail-pf0-x231.google.com with SMTP id w7-v6so8478356pfn.9 for ; Sat, 09 Jun 2018 20:03: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=+mg4OSZtYr0DKnNd7OfrN+O8v56yUUa43TFaTkc9T0w=; b=i8y18WdrJEf0632SjsW8Fn8Lz9Ur0gnYc+TvwCrbj/Ls1fk89mnS5kzRKvxgJehTOa 5xfX7BPnNtFgDjgHeBftSLnZRnNfpqTyqW+LtSs1YgkRsnXOMFtaX5sMPCL9vEB0IzaT +o9xVTVd5o28ivDvSikz2UD3xTTmHcJxqJcWA= 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=+mg4OSZtYr0DKnNd7OfrN+O8v56yUUa43TFaTkc9T0w=; b=AA4jrsAFlRYaW4dQR3xrDiP/2vFXUGhfRqY+Vl8x4feW85FgMDqDuuKkM/lkCfbeFb jkBCLbA5Fr+C9tgIJu3b6rMn82XCb9jreKXHEpWjD+UbylfBUz0yiHugXE5TmsMQsPTd 9dcsq24vQaCAvBgmbUQobI+ow0cl6ZvZMhbxelyX+bblc1Ec9R0LEmI/J+ujGCSO7m3H NBT80Wn3SeicD8Qa7LACOwQS03coUBn6wRucd4HwlZ5tGaPxbMe9tRK7GcCP2TXXGnQE YkyJlw+gQkierJwU0KBOokN6QNf19YK8D6kAndftbS/LL4VZbrU525qZ4+5l4K9vzY8U 7OfA== X-Gm-Message-State: APt69E2e3D9I7W7VmfLk1AnuJGDBkDeF0OPdYrrPB9zrv9+6UxUbrRUz sYA/Y72Z99Hb/wYtdZgDR7qwZp5h0bI= X-Received: by 2002:a65:5d8a:: with SMTP id f10-v6mr10632693pgt.119.1528599820414; Sat, 09 Jun 2018 20:03:40 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:06 -1000 Message-Id: <20180610030220.3777-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::231 Subject: [Qemu-devel] [PATCH v2 034/108] linux-user: Split out getrlimit, getrusage, 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.c | 117 ++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 56 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ac3592d776..4c5292efed 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8152,6 +8152,49 @@ IMPL(getppid) } #endif +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; +} + +IMPL(getrusage) +{ + struct rusage rusage; + abi_long ret; + + ret = get_errno(getrusage(arg1, &rusage)); + if (!is_error(ret) && host_to_target_rusage(arg2, &rusage)) { + return -TARGET_EFAULT; + } + return ret; +} + +IMPL(gettimeofday) +{ + struct timeval tv; + abi_long ret; + + ret = get_errno(gettimeofday(&tv, NULL)); + if (!is_error(ret) && copy_to_user_timeval(arg1, &tv)) { + return -TARGET_EFAULT; + } + return ret; +} + #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) IMPL(getxpid) { @@ -8910,6 +8953,20 @@ IMPL(setrlimit) return get_errno(setrlimit(resource, &rlim)); } +IMPL(settimeofday) +{ + struct timeval tv; + struct timezone tz; + + if (arg1 && copy_from_user_timeval(&tv, arg1)) { + return -TARGET_EFAULT; + } + if (arg2 && copy_from_user_timezone(&tz, arg2)) { + return -TARGET_EFAULT; + } + return get_errno(settimeofday(arg1 ? &tv : NULL, arg2 ? &tz : NULL)); +} + IMPL(setsid) { return get_errno(setsid()); @@ -9385,62 +9442,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - 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; - 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; - 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) @@ -12737,6 +12738,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getppid SYSCALL(getppid); #endif + SYSCALL(getrlimit); + SYSCALL(getrusage); + SYSCALL(gettimeofday); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); #endif @@ -12801,6 +12805,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sethostname); SYSCALL(setpgid); SYSCALL(setrlimit); + SYSCALL(settimeofday); SYSCALL(setsid); #ifdef TARGET_NR_sigaction SYSCALL(sigaction); From patchwork Sun Jun 10 03:01:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138109 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2587994lji; Sat, 9 Jun 2018 20:28:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ23aCYfRWFta6EhtDMqQCjxwFh8xDqCOeuOo1AYp9HAbz2RwhkXIws2usVxQUkgUBLsUFN X-Received: by 2002:a37:b0c:: with SMTP id 12-v6mr10500041qkl.386.1528601319029; Sat, 09 Jun 2018 20:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601319; cv=none; d=google.com; s=arc-20160816; b=dkqyw3CNtUGjyLVAqPdFso0/sDrTLMcnIPFOXXtV8jbfVoIWabJhs7qZp9soxlkA8R BVrAyHJ0W9RS/eNDnSMY9gS+vlShv4QLbOV6JCFR8t8VGUxV93BGXtMrI9a+MpXZXjUm U+aCGTlA4ShWqYCFbcngFdtzSyJO74XtfSIID4BTCKWE1+i+KZ0FY+tyRu6eF867werU Nw47pSVTSfvLAXDffFo5rgUtGZTxgJu84cBU4+oBoVWIAqZCBsSC6iF4EhSmoWnnd1vv /PSgoSr+xmW4GZOKThFy8um1CH7NJwJxcwgPHgdTnl8ybK6ONp5+RPpd2d6kaqTcJKpI HILw== 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:arc-authentication-results; bh=q77aN0uTm6VQD+p8xaMsT74Yp6BjxuMGVjkQVhsPWd4=; b=xmVaFTtgUcHzzqq1pbnOdaICh3G6bj5Ty6UTsKXM4k2t8WxHgcL+gaqg3Azs6werXn sq+PSMNeartTc6eouyNw8F9Y+k9GPFt9RxvCiSwrORSKVKSlCykqW7pK+WQ8UHDHclw7 RusyXkFRpE6cDtUvR9dqP+UsGThhlMaY0FVX6YKd6slDg+mokbhXUnrD5iWVk/chpm4B PjVHJjsqQ0hIYnkkwDMS1quQeS8dNVI7ObMR8DrJ2zoF7xxfQCzv3ypa/hc90P/4wTvA 1kjw54O/PnmPelYUZRSL1e4HPUiAhtbp2Rx2U4QTpYvW0Cts7k5kEeqCYv3rbD95nnIF hk0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K3hdCcf2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b45-v6si2112503qtc.235.2018.06.09.20.28.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K3hdCcf2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr1y-0007ID-EY for patch@linaro.org; Sat, 09 Jun 2018 23:28:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdt-0002ap-MB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqds-0003ZH-Cg for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:45 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:33389) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqds-0003Yv-4K for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:44 -0400 Received: by mail-pg0-x242.google.com with SMTP id e11-v6so8142855pgq.0 for ; Sat, 09 Jun 2018 20:03: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=q77aN0uTm6VQD+p8xaMsT74Yp6BjxuMGVjkQVhsPWd4=; b=K3hdCcf2u729s5Q7yMtJeeBExlLYDq1ysgUQ+wqR/PwbtYRkJZDoFdoruQhgtW1Gjf FdOYzcma39ut6iA1fT/k4x5shSpW1yox87IFXzHnEHcmAqY3H/r9ar68QfMuh4Msra08 RG5g1utkYblIegVaRF3N28dkkVwOW+XgXVOW8= 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=q77aN0uTm6VQD+p8xaMsT74Yp6BjxuMGVjkQVhsPWd4=; b=ZjvXt9XaW1JygkxZXPOnXVoIq4VRjU8OxOx5AvURO9Xf9jwR+A3aYVf48tmzPzLv9z kFNirfj0OYIyNoNveuazS74m97rfUtVE1i+0ijhHrKkEqPqDCGDaNFCeWcr2MZqr0XvA WZw5/3jUeQnTOfK5wxQuBSuFZyZg3mR9WwBEQeKBAXSm5+C5SXLMaTd4kSMgireq2pNF JW2EkJYkYMynpMq+DA+KrXah1eUR35LVkLOSHzDn4aLKL0xstvmMHSMamZYF1zOduKQP Sk1f7mDheBRs6RdHryDwQsAf0FhGNrqGY416UQ4n1cPFmUZza6TI4rK5nHBrF36cJrXr 56uQ== X-Gm-Message-State: APt69E2l2jkEEXIIcxfIn7B2hHpdReiX/eES4IpjkgzKv5yaOgS6bbbV m7u0kMJHRMF53VGPaz4yQl7vRraXsT8= X-Received: by 2002:a63:6d05:: with SMTP id i5-v6mr10418933pgc.321.1528599822856; Sat, 09 Jun 2018 20:03:42 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:07 -1000 Message-Id: <20180610030220.3777-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 035/108] linux-user: Split out select, pselect6, 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" All targets define pselect6; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 251 ++++++++++++++++++++++--------------------- 1 file changed, 130 insertions(+), 121 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4c5292efed..326323e377 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8483,6 +8483,13 @@ IMPL(name_to_handle_at) } #endif +#ifdef TARGET_NR__newselect +IMPL(_newselect) +{ + return do_select(arg1, arg2, arg3, arg4, arg5); +} +#endif + #ifdef TARGET_NR_nice IMPL(nice) { @@ -8584,6 +8591,107 @@ IMPL(pipe2) target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); } +IMPL(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 = NULL; + target_sigset_t *target_sigset; + abi_long ret; + + /* + * 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 = NULL; + + 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; + } + + /* Extract the two packed args for the sigset */ + if (arg6) { + abi_ulong arg_sigset, arg_sigsize, *arg7; + + sig_ptr = &sig; + sig.set = NULL; + 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); + } + } + + 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; +} + IMPL(read) { abi_long ret; @@ -8920,6 +9028,17 @@ IMPL(sgetmask) } #endif +#if defined(TARGET_NR_select) && !defined(TARGET_WANT_NI_OLD_SELECT) +IMPL(select) +{ +# ifdef TARGET_WANT_OLD_SYS_SELECT + return do_old_select(arg1); +# else + return do_select(arg1, arg2, arg3, arg4, arg5); +# endif +} +#endif + IMPL(sethostname) { char *p = lock_user_string(arg1); @@ -9442,123 +9561,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: - { - 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: { @@ -10459,10 +10461,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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: @@ -12763,6 +12761,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif +#ifdef TARGET_NR__newselect + SYSCALL(_newselect); +#endif #ifdef TARGET_NR_nice SYSCALL(nice); #endif @@ -12780,6 +12781,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(pipe); #endif SYSCALL(pipe2); + SYSCALL(pselect6); SYSCALL(read); #ifdef TARGET_NR_rename SYSCALL(rename); @@ -12801,6 +12803,13 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rt_tgsigqueueinfo); #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); +#endif +#ifdef TARGET_NR_select +# ifdef TARGET_WANT_NI_OLD_SELECT + SYSCALL_WITH(select, enosys); +# else + SYSCALL(select); +# endif #endif SYSCALL(sethostname); SYSCALL(setpgid); From patchwork Sun Jun 10 03:01:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138104 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2585718lji; Sat, 9 Jun 2018 20:24:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKixWx7ORREdABG4eGuZqoNrimMSztUsw8TCXyA3JRKISe7ROFveNZiv/8gQas1nMou8WdJ X-Received: by 2002:a0c:b116:: with SMTP id q22-v6mr10934435qvc.19.1528601069714; Sat, 09 Jun 2018 20:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601069; cv=none; d=google.com; s=arc-20160816; b=awJEijIc0kNa7xbDHjVBqYGAJesSz9Z/TfzfgdcGMA/Xc4pGc9ZPAQn/eAFBDD9Ow6 dURKR9mM/RP+u3TkuDGjzL2NKBro+Yi1Dd5k8qeLzTYwmZSSSnUYcKEavRlNbFGAEp6O 5ULR4dMLFVhZYXBBBe3pUOaFbiO7FYeFIh1ugltAzvfQHcMBlczi4NYRcVQPTfkMLiU3 lmy1nhsdgCENflO4+1g7MS0UFgo1RpmYm74FebYLuKi+upXdXBnPe4/NSAIAdJwvLL2V gbch+D/2j2MAI58nmnO3TM7QAJEO1nQaoL3BVCzs5bdXQv/e/SMkE4hBilGg/gsjYOOp JnVg== 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:arc-authentication-results; bh=MO3CtHl8xhdjUTpLRWtjJqDVjOPhlwO8K7Ht7HuLk7c=; b=IfFlgsqlqGcQF6ggK0gLV6U/hmwiXeXYPlU5C+Y4efrKjDLLpjzhhdfLrnzKumf/vK Linvt3ZD9CsOdtMZotP7TCT0xi8kivTjTf3hAaihwtBUWT04H68EBUirIjuJ4ud4GiDn bq69rJgWMPGrFFG0j1kqGSbORK3GS545/NJy1TliXm2eolnsTn47Sguof8Hp8RMa02d+ r5NFuaU+zUwzWT4zuTOxTH5q2COWPcdj37rRufD0X+zEs85NvPBu1XpMOj+kTjU4gKWk HjWFd+zn+eWMRC34ONxwhGBTtFOjr6NUG6F0toYjzPeRVHRBjCcII2SwUUf8LoVEOpnh BeyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eafUr+Xo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u4-v6si3890318qke.259.2018.06.09.20.24.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:24:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eafUr+Xo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqxx-0003JR-4F for patch@linaro.org; Sat, 09 Jun 2018 23:24:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdv-0002bB-II for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdu-0003a2-Ke for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:47 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:38926) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdu-0003Zo-EP for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:46 -0400 Received: by mail-pg0-x242.google.com with SMTP id w12-v6so8138873pgc.6 for ; Sat, 09 Jun 2018 20:03: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=MO3CtHl8xhdjUTpLRWtjJqDVjOPhlwO8K7Ht7HuLk7c=; b=eafUr+XooCrEkiQK4qNoMJ8OXIiyHSBujJX1Ajttp+aA77fw/daNofNYkuUYycTNai zfx0GiY5Uhf/NK7JkmdlxxHUxnLeGcGbkGSYdmlEclYzsKXYQbl7pzHTkbcfrC2AmQjg cTaJrofkeg03K90qF9KSgnFwhNFJ8XUf3jOt0= 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=MO3CtHl8xhdjUTpLRWtjJqDVjOPhlwO8K7Ht7HuLk7c=; b=CH0c/Om7TVZPfRidUQ0SnSf8QtNKsq54izikaAvIjaFc3O57ykO3OKCoCz3W6oS8TM qU90+mxClDL6Q7+eS8j97XN/nu1uEKdX0ynQcv52lxTDuhJwaU5qG4M1CBR9mBUzM64C ia5Gkk6LTfo0t1vPi3TA17W/RkCO6pWSZBSwULYHmYKZKT1RCOpdNxGN9k6ZuAQ9hXEH WpXi33gJd6oDlBVpmHc8KNKr24rR2s0TVw/vs4RHFXP/o74K+P2mUMv+bo3eUJ+6Fo36 f2F8+0z+Hx9h0kj+CHW5F/YEUGwuZuWvvGgM2KWzhdKW0QFG+/VxmjHKxj6iLouIDttu A8jg== X-Gm-Message-State: APt69E3bWraLKl5dK7HoggXE1u8p7/xyF8Jj8QspqYG+Z7CysWJWIkRM rew2P2l8+YvzaJIWNMRhAT4kezPdeaY= X-Received: by 2002:a63:3641:: with SMTP id d62-v6mr10184577pga.18.1528599825190; Sat, 09 Jun 2018 20:03:45 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:08 -1000 Message-Id: <20180610030220.3777-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 036/108] 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" All targets define symlinkat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 64 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 326323e377..39d8a70d7d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9331,6 +9331,36 @@ IMPL(stime) } #endif +#ifdef TARGET_NR_symlink +IMPL(symlink) +{ + char *p1 = lock_user_string(arg1); + char *p2 = lock_user_string(arg2); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(symlink(p1, p2)); + } + unlock_user(p2, arg2, 0); + unlock_user(p1, arg1, 0); + return ret; +} +#endif + +IMPL(symlinkat) +{ + char *p1 = lock_user_string(arg1); + char *p2 = lock_user_string(arg3); + abi_long ret = -TARGET_EFAULT; + + if (p1 && p2) { + ret = get_errno(symlinkat(p1, arg2, p2)); + } + unlock_user(p2, arg3, 0); + unlock_user(p1, arg1, 0); + return ret; +} + IMPL(sync) { sync(); @@ -9561,36 +9591,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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_readlink case TARGET_NR_readlink: { @@ -12837,6 +12837,10 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_stime SYSCALL(stime); #endif +#ifdef TARGET_NR_symlink + SYSCALL(symlink); +#endif + SYSCALL(symlinkat); SYSCALL(sync); #ifdef CONFIG_SYNCFS SYSCALL(syncfs); From patchwork Sun Jun 10 03:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138106 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2586296lji; Sat, 9 Jun 2018 20:25:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJo4Y4sioQIWhks3tY8RK3fGfFwpZYx3ZBVjOcrZGt5sH5x9MKO6Ut5oy+Xtd/KehdivZba X-Received: by 2002:ac8:509:: with SMTP id u9-v6mr11292639qtg.97.1528601128430; Sat, 09 Jun 2018 20:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601128; cv=none; d=google.com; s=arc-20160816; b=q5aFKZUzOVPXsi8kERrx7/VcyZdcfiwXxrgikXk7RITYS5br3QBx7Eko4q1yiz3GrV 5loCxwEDd8A7ia4zw9WEaalqFFjl3elr2eek1dbMIinGNZjR2bb9vmJpYZKH2ycubjHq yF7efcjSSaYD769UM08qz/Vd6FMcg5zbp+9ROB69lvl+MwYX9om8NPVqfiL9a+JC5YZP k3/pP64LlUQ3NWmF0TEsD/Sl75cszLLRWZ2aH9SEtwIHoQ1o13bWU8BThL8Br3rKLVR6 wQ5+Wjb9HbDoTkCBvEqL4tn6z7SlqUYv0DsMsg9SrkKfXoMuSD6ECz90WrXh62SaEebS 5o6Q== 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:arc-authentication-results; bh=NquHwfpUFzaw1yvcQe0KD+aaVwrtvkWldlItTbf1Tls=; b=PE6JSiQjbgNWsUhwQCXUqsTAJzayC1nDwkEFCxXY40UTbjX6Cd5sH2Y0ERe3qH7pFb hh+ZeFu/GGuUoseo3vHzF+ySyuOWHW29+HtGLsiaNrxYTjoAoCDUcTuA2+XSSHInKidH 8UYMcLzO9LkndqvP46FOZszKfKohxWX6Iye/Z8SRta4ZR8U8YjAZIQVmbvErVvkNvgFM 5DNU5hQqTRoR292zGHhYGkcOfQey1I1/EKIhZIRsf8nCyZnRFiOv6+Pf97H68g29Omo4 gxegHXw50ydmR3BeBQUWsuMy+CmbNBN3hM+BjiSFrSl+bcVJHroLKOO59PptFx8NOSOx xGzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ye7XVlCo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w66-v6si18797436qkb.343.2018.06.09.20.25.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ye7XVlCo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqyt-0004YV-Qo for patch@linaro.org; Sat, 09 Jun 2018 23:25:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdx-0002bu-9H for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdw-0003ao-E9 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:49 -0400 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]:38365) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdw-0003ac-8T for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:48 -0400 Received: by mail-pf0-x236.google.com with SMTP id b74-v6so8493620pfl.5 for ; Sat, 09 Jun 2018 20:03: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=NquHwfpUFzaw1yvcQe0KD+aaVwrtvkWldlItTbf1Tls=; b=Ye7XVlCoh1jYHtdUgc5rN+RT9DlwEiXTEwTW2iGc91P26ndTNUHAOjIcnE95z4uQLC 50BJYIHXE86NU+vqtDDjDZqdxyv6KnzM+u93BrJMzeGajH7s4dWy5BCtFBIJZIKQFmyi pU3C98M19HUunety/nRWbAODcOm3GnWdVQAg0= 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=NquHwfpUFzaw1yvcQe0KD+aaVwrtvkWldlItTbf1Tls=; b=mh9D5mQsZYojwYcLt7nGOWkkNln07hwVE6+qct00kVSCqBsReT9OCWAYv2Yn9DhEWc BxbLZuBB86LY+SRuFcIBfJOEOF3BFAC/V879pl69I88px5HnsTaGKCQ24UonJ0jVGHcu yFpQ0Ii+O+5y+8nL3FdNeCmHOX7qw20/PjnDJwRWZ7WPAj4o2QodexF+9A710HzQFtUe EEXy2Go2J8ieLlj+xnM35ua4PWjROL/Edh51hI5sMx2eXh6lgFpB3Q2DPpQrW5IlRnF6 1YW6g67NPgT7CspNrMKh2EyeYwhJicYw45eWAtUXElmmsm//mcKKVomJZ5aGOPN2784X o1yA== X-Gm-Message-State: APt69E2w41PsUko89+T/Wk270CjvNMZLPOadBlNkb7b/2mkqlefNgwdK HXMmy+YBvp8xR4jjhNX26quzRWPN3vE= X-Received: by 2002:a63:8c4f:: with SMTP id q15-v6mr10643292pgn.236.1528599827041; Sat, 09 Jun 2018 20:03:47 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:09 -1000 Message-Id: <20180610030220.3777-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::236 Subject: [Qemu-devel] [PATCH v2 037/108] 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" All targets define readlinkat; remove the ifdef. Unify the two with do_readlinkat so that we do not replicate the /proc/self/exe handling. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 96 ++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 53 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 39d8a70d7d..f1123479df 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8712,6 +8712,45 @@ IMPL(read) return ret; } +static abi_long do_readlinkat(abi_long dirfd, abi_long target_path, + abi_long target_buf, abi_long bufsize) +{ + char *host_path, *host_buf; + abi_long ret; + + host_path = lock_user_string(target_path); + host_buf = lock_user(VERIFY_WRITE, target_buf, bufsize, 0); + if (!host_path || !host_buf) { + ret = -TARGET_EFAULT; + } else if (is_proc_myself(host_path, "exe")) { + char real[PATH_MAX], *temp; + temp = realpath(exec_path, real); + if (temp == NULL) { + ret = get_errno(-1); + } else { + ret = MIN(strlen(real), bufsize); + memcpy(host_buf, real, ret); + } + } else { + ret = get_errno(readlinkat(dirfd, path(host_path), host_buf, bufsize)); + } + unlock_user(host_buf, target_buf, ret); + unlock_user(host_path, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_readlink +IMPL(readlink) +{ + return do_readlinkat(AT_FDCWD, arg1, arg2, arg3); +} +#endif + +IMPL(readlinkat) +{ + return do_readlinkat(arg1, arg2, arg3, arg4); +} + #ifdef TARGET_NR_rename IMPL(rename) { @@ -9591,59 +9630,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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))) @@ -12783,6 +12769,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(pipe2); SYSCALL(pselect6); SYSCALL(read); +#ifdef TARGET_NR_readlink + SYSCALL(readlink); +#endif + SYSCALL(readlinkat); #ifdef TARGET_NR_rename SYSCALL(rename); #endif From patchwork Sun Jun 10 03:01:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138107 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2586570lji; Sat, 9 Jun 2018 20:26:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKJggoNqncM6zjlhHQQe3Cb9olz+g+EYgCswKfM+SP5sLXaViDoB7t6F2Gd+jAKOBNMzLT1 X-Received: by 2002:aed:3e6f:: with SMTP id m44-v6mr11839170qtf.4.1528601159923; Sat, 09 Jun 2018 20:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601159; cv=none; d=google.com; s=arc-20160816; b=S8JQaMkjwpY7iUrhr2c95nAsfNorvwQSb8kfJFpdxQMTpV0LoA+/+152ihC6S7zU0E lTyxkAp8YHBAVQV4J2VPnJsXrzYyQZ4uam+GefFAh6m2PTQzlZo3E/DKY3M+/Zt+LWES IT4n9UIWs/j4QLLZP6fnptcu3lFvW9TphEbF8TDbr50KbpC0upUuYOiO6AFdaLJTTgaD E0QJy3tF8ZQsB6QVkmEHY+7dqUcXYCShmLcfQWnxbCFWfD+NZ7nEDGhwEhFs1QYlCBrh m99BSMofDQo/y82jnc46O/DXh6oGleGEGmUUyBmDfRhOpDDFlvR8KW29q/bRVif4xAQ/ S0QQ== 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:arc-authentication-results; bh=jy7CgZicyeGhKGBp2uV1pJO87lURt3gu4HYMf+LnvLo=; b=d3eK50yoMcEwpao6bgKE7eWV7LBTtk9sA8jb28nGIhRkz/kjxxMAKyYjkNOZvFtt4U LQln8WePJu/zDYXkO9KjScacpMxl5ThDTpO5rEXpgCz2OvHwqAJX0fYvIkniwt0Xoaz4 Ne+bqANuj016Kd9qc1tElZf6GhJqunQB1hV+t0XImGFajfQb2KWN4nRg8j3fpoUDOJhT y1BrqQjSNMb8CiJKC8ali1q14pTLN8s88vIRm+cAJzz1SbbC5PHpD9ThQg5fABYEp4NC 0lRFD4Y6blIcLMfjExet0ukMlBhVw7BkL+EU2uzSBvKgs2396wkfXgHNgLMR/Wgo5bN0 uGVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TKVh/w1Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v44-v6si4550958qvc.183.2018.06.09.20.25.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:25:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TKVh/w1Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqzP-0004fr-9q for patch@linaro.org; Sat, 09 Jun 2018 23:25:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqdz-0002e7-JP for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqdy-0003bQ-CD for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:51 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:38799) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqdy-0003bD-4R for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:50 -0400 Received: by mail-pl0-x242.google.com with SMTP id b14-v6so10400850pls.5 for ; Sat, 09 Jun 2018 20:03: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=jy7CgZicyeGhKGBp2uV1pJO87lURt3gu4HYMf+LnvLo=; b=TKVh/w1Q8tBvFsLCeU6VCmeySOrjQyftsU0D3l4ImJNnMiMy9ZmxLRSXg/sqR+g/Ej yxO+/40v9D0C2y+6uEq3ommq72zfy8qak5I1lX4/1EC27nEejCmtuV7D10Fbv9I1/TMT jUA2m1OGz4GRIXSFF/Fk/QsgwSAdQHU6UhwA4= 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=jy7CgZicyeGhKGBp2uV1pJO87lURt3gu4HYMf+LnvLo=; b=Ow3/QaiJW3snLmO1+8ejNBDDfgZ96we8KK9S4b3UeK1uqhhtLg7PuGUIkVbbXnY37j ODlEcdWVTm9RUBXc27oOhpSOLtsK2PzMCiWKazv1ibDSAf7fhgFeSOGZvKZmVPdRiydq mtCV1Quz8W3tRjuUjwxAK8iwbHI4PYj8c0r4FcQyLCuJjPBz38SGGzQMJLekd0MDnouK wyJdHjVIyE9ubzaQqeHhr4ok+LSsi2mOVmbWp0KVUi24am048KVRuLsj+ktOSM6F29YK w8Js2Iwottbk+z8/6CvcHWB9GFyD841dCPZ2c1OHnOAbC9DkhzCx0bWUeFEJ3rwRrXBN t+vA== X-Gm-Message-State: APt69E2lhhJ3LegXStmtSIsUoPEuOV6LhGeBwQOAFqEV2mvSsCtR82Ov PZRIwmLZ0iIo1oOijH4ARKUu7grfnfk= X-Received: by 2002:a17:902:760e:: with SMTP id k14-v6mr12929490pll.310.1528599828857; Sat, 09 Jun 2018 20:03:48 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:10 -1000 Message-Id: <20180610030220.3777-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 038/108] linux-user: Split out mmap, mmap2, reboot, swapon 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 define swapon; remove the ifdef. Add a comment noting the incorrect implementation of mmap2. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 142 ++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 61 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f1123479df..a3374955da 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8392,6 +8392,49 @@ IMPL(mknodat) return ret; } +#ifdef TARGET_NR_mmap +IMPL(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 orig_arg1 = arg1; + abi_ulong *v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1); + + if (!v) { + return -TARGET_EFAULT; + } + arg1 = tswapal(v[0]); + arg2 = tswapal(v[1]); + arg3 = tswapal(v[2]); + arg4 = tswapal(v[3]); + arg5 = tswapal(v[4]); + arg6 = tswapal(v[5]); + unlock_user(v, orig_arg1, 0); +# endif + return get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_tbl), + arg5, arg6)); +} +#endif + +#ifdef TARGET_NR_mmap2 +IMPL(mmap2) +{ +#ifndef MMAP_SHIFT +#define MMAP_SHIFT 12 +#endif + /* ??? The argument to target_mmap is abi_ulong. Therefore this + * truncates the true offset for ABI32, which are the only users + * (and only point) of this syscall. + */ + return get_errno(target_mmap(arg1, arg2, arg3, + target_to_host_bitmask(arg4, mmap_flags_tbl), + arg5, arg6 << MMAP_SHIFT)); +} +#endif + IMPL(mount) { char *p1 = NULL, *p2, *p3 = NULL; @@ -8751,6 +8794,23 @@ IMPL(readlinkat) return do_readlinkat(arg1, arg2, arg3, arg4); } +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; +} + #ifdef TARGET_NR_rename IMPL(rename) { @@ -9370,6 +9430,19 @@ IMPL(stime) } #endif +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; +} + #ifdef TARGET_NR_symlink IMPL(symlink) { @@ -9630,67 +9703,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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 */ - 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_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: @@ -12743,6 +12755,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mknod); #endif SYSCALL(mknodat); +#ifdef TARGET_NR_mmap + SYSCALL(mmap); +#endif +#ifdef TARGET_NR_mmap2 + SYSCALL(mmap2); +#endif SYSCALL(mount); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); @@ -12773,6 +12791,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(readlink); #endif SYSCALL(readlinkat); + SYSCALL(reboot); #ifdef TARGET_NR_rename SYSCALL(rename); #endif @@ -12827,6 +12846,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_stime SYSCALL(stime); #endif + SYSCALL(swapon); #ifdef TARGET_NR_symlink SYSCALL(symlink); #endif From patchwork Sun Jun 10 03:01:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138112 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2588258lji; Sat, 9 Jun 2018 20:29:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJpooRrzVk9Wp4zD9nqlcwFcI5HsNojuJ7mOixG61GBHvx2uehOCpl9sLeo+VyrWjjGb3B1 X-Received: by 2002:a37:8943:: with SMTP id l64-v6mr10603680qkd.134.1528601347145; Sat, 09 Jun 2018 20:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601347; cv=none; d=google.com; s=arc-20160816; b=M0ipMSHYUaM+jGsklKdZiEiODn4W61fYuvZ6k7hU2H25g9/1j0I4Srrr2SpLac+nSs ts9EYlTJsQWrlux5a6TZWPwoctVHErpcLGsQvj13nGTPfClq0Et8XGCsb++zLjEoZKZ4 D4gXAycbJnkwVFHJNRWq8FFELE79/RcBM6u61iI8MopQ1fIZj95bb7oVwnUkPJGWL0w9 zt0G58yMuN1TbUQxldIy8J/TAyX9ykYvXtxL8c1DJwsHi+j5exzBQE7q6tqtuNJRmMNI Lod/94HN13xAxLjGbCssS/vjBybKYiz8AawTTgsTFLQ6Da2S/uyagQam9jRNJIK49xhY Tgtw== 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:arc-authentication-results; bh=X1WxCmt0CcNso6cR9qzCWvyUwSVdM9PtMoZxkMDzt6g=; b=xsRb+dR3VShmEGlr9MvNE6TgWFMrqzmJoJg/4r5Ol1kPDwuxUlI5bhIRKXKr8K3/P7 MtpB7WYO5ciGfBgf8EMwiGim0/0uPLY+wRCxzHPI+HphUEIzFgEBggp0kvfxhRSxAPIE BVTyiKqWAtK5OXCApS7mrnGjwhVgZlD78IVlIPX/oiQCK1JdKMOlnVsUpxNa3j/sp6vu M+RUALYBvzAqhhiCGgFLmVJTpFBSWewErmrg8TazPoBX00npcG6MVy3xsH1r1LKg3G0F 4PDiAH945rsFvsPESk8uXE0gr4A0uFpLqCOY6jXPS9Q6LlrvcYar7BMhIUXeGTkJPcNf +6fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YJGyXx2Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o37-v6si1845386qtj.9.2018.06.09.20.29.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YJGyXx2Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr2Q-0007ML-Jv for patch@linaro.org; Sat, 09 Jun 2018 23:29:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqe2-0002hX-Qx for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqe0-0003c3-GK for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:54 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:45905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqe0-0003bo-69 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:52 -0400 Received: by mail-pl0-x243.google.com with SMTP id c23-v6so10384472plz.12 for ; Sat, 09 Jun 2018 20:03: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=X1WxCmt0CcNso6cR9qzCWvyUwSVdM9PtMoZxkMDzt6g=; b=YJGyXx2QgA6qiF5hC0tfTHbeUwFmwINHJfwDG5gioJ12FJzCd8KvxRuhyTXG491Y+0 os3qnoSNZ55RCNF6J6abD0p9HpzFk0SoZ52BJDhOT9qiqNNhazTA0hAYDPJyhuKd7WwK nRfJ5ZE7l+9tTtc0+ko5JnNrMKscOtuPL/XEw= 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=X1WxCmt0CcNso6cR9qzCWvyUwSVdM9PtMoZxkMDzt6g=; b=Gjuzcxq41MB13KioKeMTRrV1Zp3KPynBARWMXX9NN+u1zwA1wquZLybkX9cqVeMVSt rx65iKkB6MwFxWXfi7L0ps8f3LBlDPqP/ekdfpJVqpoYa1M3Ployy+XfqtZ5fiCfWh2M iWEJrZgS6aKyZWQZBzU6yrdJHEOv5oziKWVBOLgLICft41N+q/2jX8ptp5QEEEGyqKT5 beu0k+VLcXse4H/WdxCxNFoVQLuQXp/qMuS0lczx2f9uJYJTb+y0Qk1q22QcWcUUZcQG WYpzDhspNWZi1g+/yFWaMDdLNIYhnRWlSkh5/4Sh9WDq31lQk3xeWzLrtev5MGLrW3dB 9adA== X-Gm-Message-State: APt69E0XZnQgcSMsRqLFK9wMEg0gmFOjcDGNac5hn6oXCZ3DQ7jZhyt/ LQ9Oo/t86MO1kTC6hNULWeJhu5pxoz4= X-Received: by 2002:a17:902:301:: with SMTP id 1-v6mr12922652pld.127.1528599830959; Sat, 09 Jun 2018 20:03:50 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:11 -1000 Message-Id: <20180610030220.3777-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 039/108] linux-user: Split out mprotect, mremap, msync, munmap 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 define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 61 ++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a3374955da..7504ad74b5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8471,6 +8471,37 @@ IMPL(mount) return ret; } +IMPL(mprotect) +{ + /* Special hack to detect libc making the stack executable. */ + if (arg3 & PROT_GROWSDOWN) { + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + + if (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)); +} + +IMPL(mremap) +{ + return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); +} + +IMPL(msync) +{ + return get_errno(msync(g2h(arg1), arg2, arg3)); +} + +IMPL(munmap) +{ + return get_errno(target_munmap(arg1, arg2)); +} + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -9696,37 +9727,13 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { - CPUState *cpu = ENV_GET_CPU(cpu_env); + CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); abi_long ret; struct stat st; struct statfs stfs; void *p; switch(num) { - 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)); @@ -12762,6 +12769,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mmap2); #endif SYSCALL(mount); + SYSCALL(mprotect); + SYSCALL(mremap); + SYSCALL(msync); + SYSCALL(munmap); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif From patchwork Sun Jun 10 03:01:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138115 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2590282lji; Sat, 9 Jun 2018 20:32:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLUYzXdkfQd2GjbPWvNMTMXC5tp9d1cmWSiOeXd7Z7C6bw7XXJwVXcDt7YgGS9Ujfc518t7 X-Received: by 2002:ac8:25db:: with SMTP id f27-v6mr11781999qtf.128.1528601545713; Sat, 09 Jun 2018 20:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601545; cv=none; d=google.com; s=arc-20160816; b=wMrUqwSZLG1Fdg6Pxmk3vLi7A5/KylPVjNUucpv0QdE2Or7aF7Y2xZjeQNx3umntZI Hrx2Srb0iYzWCai5gPUvgiUfmG4BXUP7Y4ZqHCkISe1dzWgKebE+2TjiQl4xSbEUxpyy /xn3FVbfnwYAReKxKa13lFaakBYbDdCXnU+hzbGbiszWdwhwcIAUrwNWZE5uqc2PEAa8 NZX6tZhHqsbWv5QqE1Fpm0IcsFU2ptOvbDel19L8KBj0LxznLAeJoXqa02quOArYhYJ3 wSiTwkLNx9S/DlCdP4O14+TRj7bcnsbQtR7ZrTyfb/vdO9ad2Z806tKqimn9LIdQs9i0 iKcQ== 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:arc-authentication-results; bh=QxGSXlqhVGnV3DO9GhiiNNbzyWrn3NgqnERUTAKyqCw=; b=ytE7TDnHJm4l68vRMkZJBqpHApRk2cRG30hRDXVA2/YCp3QgeUyQcB7w+wdxSRs/rm gwtJPUz437uhY+p6YLKSdXbripSsY4BNxwsPDe7DGunMCz+rM8E2PexmtLw+uGO6Bam9 FKqpAB5TIvasYbJ4eWKl+gWqdYdHl14Wi/3RX1xBV3HxALjz9aVBWjO/V3T8MjZeP/Yy ZL3sROAVNprrceXnXjC54MWNZZuWZRZluNIzj5Y2kVvoBOrHQGS/CyC8hpurgjA7FiWo 4zY0DfZvRezCZh4lWHUrJQ5jwI5mbWpg8fFKmjF9z/inlOdeyoRKd5i8OxSr5T7HA3e1 ORSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Savqus4i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s184-v6si3337077qkc.399.2018.06.09.20.32.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:32:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Savqus4i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr5d-0002KN-3P for patch@linaro.org; Sat, 09 Jun 2018 23:32:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqe3-0002i7-9Y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqe2-0003cc-7B for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:55 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:47032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqe2-0003cM-1g for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:54 -0400 Received: by mail-pg0-x242.google.com with SMTP id d2-v6so8129647pga.13 for ; Sat, 09 Jun 2018 20:03: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=QxGSXlqhVGnV3DO9GhiiNNbzyWrn3NgqnERUTAKyqCw=; b=Savqus4ilEky/EzdkHFzW3mBF6I9BmicTlRChWd7m16zVAXY5FexTyhPDC5CvF5bQZ ZmKkyDjkDkXpIl33qtmUDN558xtEtzneQ3s9ER52OjPsDxz1L5nAZdembpePw3Jx1pYQ r2JsG5i2UkAgSHJpjI3NX/tZQnvCtNq4y8slc= 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=QxGSXlqhVGnV3DO9GhiiNNbzyWrn3NgqnERUTAKyqCw=; b=ES82LSF/KwtFoeV9sw5YyyAqKkB+59UShab7bESdofkUcmqRQ8MXS9Qw+WqXnyBqsv kym3QkzNKBLRPZkugjsdrlAZLEvNXbrfmMeHY5c7LqSDIQaz8FQNPShgkx1m6VCUXGSy PphAPdcWr3W/vvju1p4NOu9d6W+TwVGC6ptnpmbxBjbe1AuoC4J+Aal0usht3yLjiZWE PNddDrdbGpAvxQU1Alb6pAccC3ZrikvC2CfcqcceykW0WW2jIW5hMX82lmFt9mtK+NmD ejV6qbnyukOd6rN2PnOCfJzbK8JJxly6YkYU0W+TROIbcVsMLsod2FPB5F6aa++ZBm8v 0ZRA== X-Gm-Message-State: APt69E3HfwgNlNIvYwb3qdAbIoNZ/6xUEp8OlPMiwNmT0AqnParFt9zI HIRPGPbZ8GNQ1JeVqvO7slwYaKlrTRM= X-Received: by 2002:a63:2b15:: with SMTP id r21-v6mr10433772pgr.269.1528599832826; Sat, 09 Jun 2018 20:03:52 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:12 -1000 Message-Id: <20180610030220.3777-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 040/108] linux-user: Split out mlock, mlockall, munlock, munlockall 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 define all of these; remove the ifdefs. Merge target_to_host_mlockall_arg into its only caller. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7504ad74b5..f79aebe869 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7144,21 +7144,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 - static inline abi_long host_to_target_stat64(void *cpu_env, abi_ulong target_addr, struct stat *host_st) @@ -8392,6 +8377,23 @@ IMPL(mknodat) return ret; } +IMPL(mlock) +{ + return get_errno(mlock(g2h(arg1), arg2)); +} + +IMPL(mlockall) +{ + int host_flags = 0; + if (arg1 & TARGET_MLOCKALL_MCL_CURRENT) { + host_flags |= MCL_CURRENT; + } + if (arg1 & TARGET_MLOCKALL_MCL_FUTURE) { + host_flags |= MCL_FUTURE; + } + return get_errno(mlockall(host_flags)); +} + #ifdef TARGET_NR_mmap IMPL(mmap) { @@ -8497,6 +8499,16 @@ IMPL(msync) return get_errno(msync(g2h(arg1), arg2, arg3)); } +IMPL(munlock) +{ + return get_errno(munlock(g2h(arg1), arg2)); +} + +IMPL(munlockall) +{ + return get_errno(munlockall()); +} + IMPL(munmap) { return get_errno(target_munmap(arg1, arg2)); @@ -9734,22 +9746,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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 case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; @@ -12762,6 +12758,8 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mknod); #endif SYSCALL(mknodat); + SYSCALL(mlock); + SYSCALL(mlockall); #ifdef TARGET_NR_mmap SYSCALL(mmap); #endif @@ -12772,6 +12770,8 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mprotect); SYSCALL(mremap); SYSCALL(msync); + SYSCALL(munlock); + SYSCALL(munlockall); SYSCALL(munmap); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); From patchwork Sun Jun 10 03:01:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138111 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2588048lji; Sat, 9 Jun 2018 20:28:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKeDk8wmsrjcurUhMOWMTAbr8V2cNeF/mgRamhqsGjDuzszTNfo9NjwmemwOoVA8jOU66qF X-Received: by 2002:a37:1399:: with SMTP id 25-v6mr9998637qkt.83.1528601324141; Sat, 09 Jun 2018 20:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601324; cv=none; d=google.com; s=arc-20160816; b=Utw4hhf0pyLy33hfIB8CLNVLrP+c6OBP6JU/iFfLjnofjgQs5j2+oqDu8TMkwTrpZ5 Bv6aqtMU/YGP8i2VwEiCNG7O9io0b7dDOionADOR31z1l1K6VrXygPaVdapYsvN9loEg Tqk7E7DuTTbZZE5nIpnrf5DD+EXy7Q/eVur97XKstMzsITs3jUAFb96iKmVDVfTp6u6g omR33CT9orGtdDrwQ+IZiqw0Zi6c/2fOy+Ql2XdAQlqzpys1G4CDRjy/9/leOlMOxqHg TGDl089/ZGmofnWvpYaFEdgP/Vkx/dzcOoTfVKviFYm0owdRnGvXPNW7Lsowsintk8oo DFQw== 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:arc-authentication-results; bh=fJyw5nIy4yvt/fDKhgIoq5kfbDLbyImGxwi43b0Dc8s=; b=R/NLSgxycK1WXn5g8vu61dLekWlZPtIco3tgtxB7tHDv7q9sl0Ejx9vFZeZGX3ffj5 mtB2cMcJMAwN/vBGeyvKrRf7aX+kApDVOvyXxf1TyShBCR7wg0en7loIj6dQZcLFo3NM boki+yyN9CDoens92NZQebMjoJWKJslTUljHIlCBvZBu88T5jR/nLrdOhn2WWQEe7in3 jya69sDVwFk00UadkT5pxEWnB1N+OAi+ax6AvQ6FQ9P6Xf6+8HtzYFpLbR8EOmX/zIpj lS7TERVSVurR2cFagKawh/etihctqhW1gVgmtVZsxg6RCBhU5u+yFAQb/xaLZGeHTaOV Q8uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PCx1Aiu1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u3-v6si6784963qvk.231.2018.06.09.20.28.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PCx1Aiu1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr23-00072P-I1 for patch@linaro.org; Sat, 09 Jun 2018 23:28:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqe5-0002k0-2w for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqe4-0003dG-5h for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:57 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:47033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqe3-0003d3-Ve for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:56 -0400 Received: by mail-pg0-x243.google.com with SMTP id d2-v6so8129667pga.13 for ; Sat, 09 Jun 2018 20:03: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=fJyw5nIy4yvt/fDKhgIoq5kfbDLbyImGxwi43b0Dc8s=; b=PCx1Aiu17oZXwjMko2vH7+vH25URlrz5tYbCMf64c5y+E2d3P/WJ+2gHlPf4eqJq7A 33C7lNolG7xYZY2/4C7rCMi2f2YZK5hpOjcqsO4k3m2kh6c+jvTtX/egjrkMwwpw2Y8p LB0ZNtVv7lEItv3U2PSvyWYO25Q5fQfBVm9h0= 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=fJyw5nIy4yvt/fDKhgIoq5kfbDLbyImGxwi43b0Dc8s=; b=SpYlowd8j36Ar2MtMSauVV7QKhjrC2FQ9doR+3kkrEejLKPtOYVXVzR+5U/jiqe0PF 7OMuftAD/QPGFfR0R55Zo2fV2q29aHRKjH24No8MqLAKD8GN6/y5grhjgKmL5UZrtt1u IfJwgqZ+0j1f3Uzc2K19L3CD5Ai30UIIndTHKUXD/DOa30jAsMZUsaSZpcKxo7o5lqVY 9ATT5u85/ZoWkAo74pvaiDpHbqrb3EqHuvE0hnJqGVw9omNyzcXg2hrMPz5UUNJY8O25 +3deGpmpfxfgPMppA4wa3Ipx6rNYfjTCjyRMgzSqrvkPzI/GMcCvl5MVGTnDKrsrcIdt uVLQ== X-Gm-Message-State: APt69E0GkstHmeimnhVmj4UCHwnd3tp0yB5Ecq7wsrlkMBPdhShyN6RH d5SrHc4zLFpcVC3GIS7BwK7iz2iZsC4= X-Received: by 2002:a63:7206:: with SMTP id n6-v6mr10230594pgc.174.1528599834820; Sat, 09 Jun 2018 20:03:54 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:13 -1000 Message-Id: <20180610030220.3777-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 041/108] linux-user: Split out fchmod, fchmodat, ftruncate, truncate 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 define fchmodat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 58 ++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f79aebe869..df8422cd3a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8079,6 +8079,24 @@ IMPL(faccessat) return ret; } +IMPL(fchmod) +{ + return get_errno(fchmod(arg1, arg2)); +} + +IMPL(fchmodat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(fchmodat(arg1, p, arg3, 0)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef TARGET_NR_fcntl IMPL(fcntl) { @@ -8093,6 +8111,11 @@ IMPL(fork) } #endif +IMPL(ftruncate) +{ + return get_errno(ftruncate(arg1, arg2)); +} + #ifdef TARGET_NR_futimesat IMPL(futimesat) { @@ -9563,6 +9586,19 @@ IMPL(times) return host_to_target_clock_t(ret); } +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; +} + IMPL(umask) { return get_errno(umask(arg1)); @@ -9746,24 +9782,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - 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; - case TARGET_NR_ftruncate: - return get_errno(ftruncate(arg1, arg2)); - 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 differentiate based on errno settings. */ @@ -12719,12 +12737,15 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(execve); SYSCALL(exit); SYSCALL(faccessat); + SYSCALL(fchmod); + SYSCALL(fchmodat); #ifdef TARGET_NR_fcntl SYSCALL(fcntl); #endif #ifdef TARGET_NR_fork SYSCALL(fork); #endif + SYSCALL(ftruncate); #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif @@ -12870,6 +12891,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(time); #endif SYSCALL(times); + SYSCALL(truncate); SYSCALL(umask); #ifdef TARGET_NR_umount SYSCALL(umount); From patchwork Sun Jun 10 03:01:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138114 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2590007lji; Sat, 9 Jun 2018 20:31:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJTcTS2RVMKBtURCenedJuv5KDZxOZaQ5J5UOlHJbOjGlFJqTMGDtZP6NEZNDp4DiKFs2cQ X-Received: by 2002:aed:25cb:: with SMTP id y11-v6mr11554365qtc.333.1528601517703; Sat, 09 Jun 2018 20:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601517; cv=none; d=google.com; s=arc-20160816; b=xB0c4ntdFBEMEEmieCa2O/3B26qMX7cR7ilB2StRIcFgIASR4Wxx/ocTobPk5dJ5I0 OdNn+uDQ++RCYC3q6hnspq3Kq5c94am30a5PdGk0zHSjE+9HJTGBCKmoS0uWxcTQFz2U SFPk7hi1QflEVplX6qUOfa0xJwZlp3LLZChmzEPoiE3m/NFIoSpbPrGC5s+G0CYno8SZ gP2QFssrICMgMJZl2fx9rrAaIEsvo9fX0ZYDOGVP3hORuTP0apRJV0y+Nyg4b9NiD4Hr NEPAqxYeNks8Ran4j9U7Gv+4BvA0Rl7zF31upIWalS3e/iAMSjknL5MUgb2hxeRQIoaQ OoNQ== 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:arc-authentication-results; bh=aelzVM/F3mmjQ+WdFXQpG8KOCYOaODvftBQqj0+75ys=; b=igfcHaDiuHNfH4B0uTR4rMClOT1cA8ceYT3/g9iLeu9EPy2neoO3FW2tyUHMtxGbnW 5klDhgaRWGKWDeqUxCQAC/oSFuSPmhJ8Cm689oZQ7QkwfT8jCebMlNiv+SUeBM7JezyM dNE8Kyvh1aM3JWhD76/I0ina/tJwfCJ4A6zpZuHIHsiSdCIdM9ZoZlCNo60ZJd1bkO2z xJA1xNBT1zGey1E5/R0sFBg099MLmpNjKH/9I04BJvx6Zz7FlBi9CPe97cgO0bqLVMsg irOFtck/j7hFSZZft1c3kVgej4/z3hqQEM+5yBkgudsZTxRanK5YBltzy07HgUp2ErB9 AqWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E0zkv+0Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e66-v6si1165305qkc.264.2018.06.09.20.31.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:31:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E0zkv+0Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr5B-0001XJ-3i for patch@linaro.org; Sat, 09 Jun 2018 23:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqe8-0002np-H6 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqe6-0003do-QF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:00 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:38246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqe6-0003db-II for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:58 -0400 Received: by mail-pg0-x243.google.com with SMTP id c9-v6so8135601pgf.5 for ; Sat, 09 Jun 2018 20:03: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=aelzVM/F3mmjQ+WdFXQpG8KOCYOaODvftBQqj0+75ys=; b=E0zkv+0QUfAQK5GkIalQHbPn5jhUSSJH6qKWoOBpreB+tGIVyleJC3ua7thsacK4Uq uKEppbtjuK+8Z+8+QnzqkvJDWEcBaUS1Qjq4A07heB74ndGFoLI59CGtAA73oJZHMbPE RSVzRhDBgJeA2K1GFIXN1Ey5mfKW1t4rCdcXk= 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=aelzVM/F3mmjQ+WdFXQpG8KOCYOaODvftBQqj0+75ys=; b=p7PXbB2Du4OlrhhMH1m+aTeSf2cGT4BOWt9RVUfyrO8VwonaCg5M5X4PNcmBIv0h10 D+N7PSZmUlRHBzTekX+HvboJcW4arTrHCJ8eR/dG+DOSH/upaKRWL7VUUWNDaFax1ALI 5C2b0EEauO4EME2P32WdvhZBySsCkNkMB+iVgRC/5RTyaLwPM5TKwHmdnNRqrAm3WmYe agLMdFrT48UjvIBPwSpt8ROBKCShLZypFti9mPAJvYTbSGxeBGWyiMILyqgMLmcBmdzI JkJ5aFF+9Dr7KQv3UsbIrVw7H7A0wZxgBkPBUkpEv7GZRymedwzl42DUkeeMFSBhuU4x Zfww== X-Gm-Message-State: APt69E1OPIIcyGsfEz5Tg204UOm+D41OC2PvsB6qX9eqIpZeDu6IsK+/ jzd2qaC5Lihp2aMydx6QN+vjU9Q4pdw= X-Received: by 2002:a62:ff1d:: with SMTP id b29-v6mr12283070pfn.181.1528599837312; Sat, 09 Jun 2018 20:03:57 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:14 -1000 Message-Id: <20180610030220.3777-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 042/108] linux-user: Split out fstatfs, fstatfs64, statfs, statfs64 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 | 193 ++++++++++++++++++++++++++++--------------- 1 file changed, 125 insertions(+), 68 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index df8422cd3a..86583988c4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7207,6 +7207,61 @@ static inline abi_long host_to_target_stat64(void *cpu_env, return 0; } +static abi_long host_to_target_statfs(abi_ulong target_addr, + struct statfs *stfs) +{ + struct target_statfs *target_stfs; + + if (!lock_user_struct(VERIFY_WRITE, target_stfs, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(stfs->f_type, &target_stfs->f_type); + __put_user(stfs->f_bsize, &target_stfs->f_bsize); + __put_user(stfs->f_blocks, &target_stfs->f_blocks); + __put_user(stfs->f_bfree, &target_stfs->f_bfree); + __put_user(stfs->f_bavail, &target_stfs->f_bavail); + __put_user(stfs->f_files, &target_stfs->f_files); + __put_user(stfs->f_ffree, &target_stfs->f_ffree); + __put_user(stfs->f_fsid.__val[0], &target_stfs->f_fsid.val[0]); + __put_user(stfs->f_fsid.__val[1], &target_stfs->f_fsid.val[1]); + __put_user(stfs->f_namelen, &target_stfs->f_namelen); + __put_user(stfs->f_frsize, &target_stfs->f_frsize); +#ifdef _STATFS_F_FLAGS + __put_user(stfs->f_flags, &target_stfs->f_flags); +#else + __put_user(0, &target_stfs->f_flags); +#endif + memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); + unlock_user_struct(target_stfs, target_addr, 1); + return 0; +} + +#ifdef TARGET_NR_statfs64 +static abi_long host_to_target_statfs64(abi_ulong target_addr, + struct statfs *stfs) +{ + struct target_statfs64 *target_stfs; + + if (!lock_user_struct(VERIFY_WRITE, target_stfs, target_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(stfs->f_type, &target_stfs->f_type); + __put_user(stfs->f_bsize, &target_stfs->f_bsize); + __put_user(stfs->f_blocks, &target_stfs->f_blocks); + __put_user(stfs->f_bfree, &target_stfs->f_bfree); + __put_user(stfs->f_bavail, &target_stfs->f_bavail); + __put_user(stfs->f_files, &target_stfs->f_files); + __put_user(stfs->f_ffree, &target_stfs->f_ffree); + __put_user(stfs->f_fsid.__val[0], &target_stfs->f_fsid.val[0]); + __put_user(stfs->f_fsid.__val[1], &target_stfs->f_fsid.val[1]); + __put_user(stfs->f_namelen, &target_stfs->f_namelen); + __put_user(stfs->f_frsize, &target_stfs->f_frsize); + memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); + unlock_user_struct(target_stfs, target_addr, 1); + return 0; +} +#endif + /* ??? Using host futex calls even when target atomic operations are not really atomic probably breaks things. However implementing futexes locally would make futexes shared between multiple processes @@ -8111,6 +8166,32 @@ IMPL(fork) } #endif +IMPL(fstatfs) +{ + struct statfs stfs; + abi_long ret; + + ret = get_errno(fstatfs(arg1, &stfs)); + if (!is_error(ret) && host_to_target_statfs(arg2, &stfs)) { + return -TARGET_EFAULT; + } + return ret; +} + +#ifdef TARGET_NR_fstatfs64 +IMPL(fstatfs64) +{ + struct statfs stfs; + abi_long ret; + + ret = get_errno(fstatfs(arg1, &stfs)); + if (!is_error(ret) && host_to_target_statfs64(arg3, &stfs)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(ftruncate) { return get_errno(ftruncate(arg1, arg2)); @@ -9485,6 +9566,42 @@ IMPL(ssetmask) } #endif +IMPL(statfs) +{ + char *p = lock_user_string(arg1); + struct statfs stfs; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(statfs(path(p), &stfs)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_statfs(arg2, &stfs)) { + return -TARGET_EFAULT; + } + return ret; +} + +#ifdef TARGET_NR_statfs64 +IMPL(statfs64) +{ + char *p = lock_user_string(arg1); + struct statfs stfs; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(statfs(path(p), &stfs)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_statfs64(arg3, &stfs)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_stime IMPL(stime) { @@ -9778,7 +9895,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); abi_long ret; struct stat st; - struct statfs stfs; void *p; switch(num) { @@ -9800,73 +9916,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, return ret; case TARGET_NR_setpriority: return get_errno(setpriority(arg1, arg2, arg3)); - case TARGET_NR_statfs: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(statfs(path(p), &stfs)); - unlock_user(p, arg1, 0); - convert_statfs: - if (!is_error(ret)) { - struct target_statfs *target_stfs; - - if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0)) - return -TARGET_EFAULT; - __put_user(stfs.f_type, &target_stfs->f_type); - __put_user(stfs.f_bsize, &target_stfs->f_bsize); - __put_user(stfs.f_blocks, &target_stfs->f_blocks); - __put_user(stfs.f_bfree, &target_stfs->f_bfree); - __put_user(stfs.f_bavail, &target_stfs->f_bavail); - __put_user(stfs.f_files, &target_stfs->f_files); - __put_user(stfs.f_ffree, &target_stfs->f_ffree); - __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); - __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); - __put_user(stfs.f_namelen, &target_stfs->f_namelen); - __put_user(stfs.f_frsize, &target_stfs->f_frsize); -#ifdef _STATFS_F_FLAGS - __put_user(stfs.f_flags, &target_stfs->f_flags); -#else - __put_user(0, &target_stfs->f_flags); -#endif - memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); - unlock_user_struct(target_stfs, arg2, 1); - } - return ret; - case TARGET_NR_fstatfs: - ret = get_errno(fstatfs(arg1, &stfs)); - goto convert_statfs; -#ifdef TARGET_NR_statfs64 - case TARGET_NR_statfs64: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(statfs(path(p), &stfs)); - unlock_user(p, arg1, 0); - convert_statfs64: - if (!is_error(ret)) { - struct target_statfs64 *target_stfs; - - if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0)) - return -TARGET_EFAULT; - __put_user(stfs.f_type, &target_stfs->f_type); - __put_user(stfs.f_bsize, &target_stfs->f_bsize); - __put_user(stfs.f_blocks, &target_stfs->f_blocks); - __put_user(stfs.f_bfree, &target_stfs->f_bfree); - __put_user(stfs.f_bavail, &target_stfs->f_bavail); - __put_user(stfs.f_files, &target_stfs->f_files); - __put_user(stfs.f_ffree, &target_stfs->f_ffree); - __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); - __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); - __put_user(stfs.f_namelen, &target_stfs->f_namelen); - __put_user(stfs.f_frsize, &target_stfs->f_frsize); - memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); - unlock_user_struct(target_stfs, arg3, 1); - } - return ret; - case TARGET_NR_fstatfs64: - ret = get_errno(fstatfs(arg1, &stfs)); - goto convert_statfs64; -#endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: return do_socketcall(arg1, arg2); @@ -12744,6 +12793,10 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_fork SYSCALL(fork); +#endif + SYSCALL(fstatfs); +#ifdef TARGET_NR_fstatfs64 + SYSCALL(fstatfs64); #endif SYSCALL(ftruncate); #ifdef TARGET_NR_futimesat @@ -12874,6 +12927,10 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); +#endif + SYSCALL(statfs); +#ifdef TARGET_NR_statfs64 + SYSCALL(statfs64); #endif #ifdef TARGET_NR_stime SYSCALL(stime); From patchwork Sun Jun 10 03:01:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138118 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2591608lji; Sat, 9 Jun 2018 20:34:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL9qypHHTQ4N4wfqI8cdcR0WHINTjrVB9aSrUpblX6lRkGhibJP1Czh4IyAcL8iPZASDwmo X-Received: by 2002:ae9:df06:: with SMTP id t6-v6mr10152037qkf.46.1528601690826; Sat, 09 Jun 2018 20:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601690; cv=none; d=google.com; s=arc-20160816; b=Keyuca0ba1E6mnhTUqyZtI0ttg4A2vog2oNnx66TII0/wbexWSFWXcMbfbZHHh43pb cFlFlsk2FIuEHod6loPdbaXs6aO04QTSIRNbR0OOvDDYcaLdz6Bf8cCdGNRm+pxfDdDv fDn/o/uZSOTOIvrbgKYJZ8WNA0NvENtbcmGYwDrk7k7Ld90w0ixx+nsUGtnfWDdjxJl+ EG2O56gejB81+aN1JWP/63TIRJR42NVdt4j1YVbxCwq34VR1XtbeHKPO1z1nDSQwJFaY CQt13wpJeWWvHeUHwrEcfkJu9HxWtDtvJEyfmOIQZHOQQ3rnYGKffTRh8kL/udW4TXRn KWbA== 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:arc-authentication-results; bh=GNKzSio2SBkgR4wvRREYC8akk3s9QztX958J6dqMyBM=; b=bM2tl4O9kLExgInymcIuvoj7gAC6LbLTeAUDPJimNIKNJYual5Q0MY+OoOTty3AHyO ybu/X0j0jR3yv8LTK+DRN+HARaSKWvqYrPk4qnrlvWZvSJzkUKBodAxkysTfg7gke5ri gGfQKPlDw+Lw5RMAMNPkolcRqDulazcDUz1t6Irs/5fN5tRfNQwOS5iajj2QXja+IPiz 6Scwk1F6ffTta6hu9yuvHvXC3056i3ynFp/w0BeNsGu97F/YTB4R8NfMyTThgumMmZe4 zITeZtjZPySdUGdaEf6fLvZzK/GKUOyIUIRR7QfrZwAQh1TPF3XQzo4WQE5/olSQD0Ba 97ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=buuJ6uKE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j3-v6si83649qtp.72.2018.06.09.20.34.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:34:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=buuJ6uKE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr7y-0004pH-Bt for patch@linaro.org; Sat, 09 Jun 2018 23:34:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeB-0002st-PC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqe9-0003eR-5Y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:03 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:44506) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqe8-0003e6-Uy for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:01 -0400 Received: by mail-pf0-x244.google.com with SMTP id h12-v6so8485496pfk.11 for ; Sat, 09 Jun 2018 20:04: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=GNKzSio2SBkgR4wvRREYC8akk3s9QztX958J6dqMyBM=; b=buuJ6uKEtbWE+VV8+9M9gzsTFGVitmVxYY5GDvFO9VktgBY1xfAMmqU8NJBUBnoeIB SnRR1IWQkQxb5JCD/taZ38oL5Xvba8PuFyiHqSAHvL5QGDWSM+Emjm59ecTS3XVU5uAK yRhnkCa+BijCX1qfa1MchLcmvXnQvfUXH9XxY= 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=GNKzSio2SBkgR4wvRREYC8akk3s9QztX958J6dqMyBM=; b=kfGqduO779n+CNbwFSxwjOOR2yNfj6qroZG/F/rlcjX2qAEpDrVQW3qmraTDu7XFFR hw7xxxtJfKOk7eDL6F9L9Dy4zUV6q/U3I/vrkPIlKNILrKDjfk2ffb6bFvYRA4BYOADn 66f+9K11mW4QrfjxIFSfuheRyDGe6CFSGdtVC/SoxK04X71GTuJKLbqLLSSmkHNtUh4H 2HOVMq6eng1ps57N8cuBGj6VAlEKJd5W6uxtyUgifdKzvlliyHbWnC57343egKTUbsgH 9b1xblsP2/sM2kV9SkVl6JPrC/19gmScoVT9dVzntBjIuKog+ybOTg96NkOwLoQKLF6F bXoA== X-Gm-Message-State: APt69E3wTcGJG73A918SS2DtF51T7jpqVqKHVmu/5xBgKl5bsGRkwdL8 rlf63jpXKYZZlz3dAD7mgEM5CXytIDA= X-Received: by 2002:a62:3e11:: with SMTP id l17-v6mr12299808pfa.18.1528599839786; Sat, 09 Jun 2018 20:03:59 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:15 -1000 Message-Id: <20180610030220.3777-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 043/108] 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.c | 46 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 86583988c4..6d8d2eb780 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8241,6 +8241,27 @@ IMPL(getppid) } #endif +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; + return ret; +#else + /* Return value is a biased priority to avoid negative numbers. */ + return 20 - ret; +#endif +} + IMPL(getrlimit) { int resource = target_to_host_resource(arg1); @@ -9303,6 +9324,11 @@ IMPL(setpgid) return get_errno(setpgid(arg1, arg2)); } +IMPL(setpriority) +{ + return get_errno(setpriority(arg1, arg2, arg3)); +} + IMPL(setrlimit) { int resource = target_to_host_resource(arg1); @@ -9898,24 +9924,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned 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_socketcall case TARGET_NR_socketcall: return do_socketcall(arg1, arg2); @@ -12811,6 +12819,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getppid SYSCALL(getppid); #endif + SYSCALL(getpriority); SYSCALL(getrlimit); SYSCALL(getrusage); SYSCALL(gettimeofday); @@ -12907,6 +12916,7 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(sethostname); SYSCALL(setpgid); + SYSCALL(setpriority); SYSCALL(setrlimit); SYSCALL(settimeofday); SYSCALL(setsid); From patchwork Sun Jun 10 03:01:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138125 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2594241lji; Sat, 9 Jun 2018 20:39:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJBYb0XNTfRKMSwJeDIPLPDT58hFO6dehtnAR+Mxi7OEG26f3ACMd5HJWA/vIWmLpDxdt3m X-Received: by 2002:a0c:8c8a:: with SMTP id p10-v6mr10676641qvb.68.1528601989195; Sat, 09 Jun 2018 20:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601989; cv=none; d=google.com; s=arc-20160816; b=xhS4yuuVJejNB1fpvjcpgviI3ELnBe5nKAJa3OFai0kWOVzPHYC2jIWKU2qqnLt7EA 2ufWzA1u9EsBubu9DVoDopZBaYsw1aQuNACZa3/+Wx82+l2Vl5yn2RE0ftLu3QgFRsEC pr8v9enXc4uU97y8SDv6BUjA7uAs9HmhsnDEOLJ9d7qTG9GwJzp98DXsAkYtYpfZCjEF eQxwCtWLFQjzUnW2teHl7XaLAWw+uidCb9oLmMKYW8Vg/KfE6d/RPpt2J/XrpbhB90XJ L9ktspoe/MzzgIF+SSoBCEtDCH30c3T1GzjmCeyC7SVPV6Leqro+b8B5LqkSxqitCgd5 oGjA== 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:arc-authentication-results; bh=nbIFk6joHhHEk0ILieO0O1pHXD5skH7BjGeQK2uTGmQ=; b=HgforJHAb6VAtzy0in8Ja1/R+80RkUoShLZoQdhgQqYU9q6lRUx1VCSXryGDO/wXEP wNOZKEORYPMGLyefGyjmubRu34j4QmO2qgnxqsuwzK1DRl1mVvdtaqgfwpDYU7JXjSbr jznhUW256rfJbWP3m/tf7q3EZWIB9uydQGNiNgBJW07fgW3UNx56cJYIyprbrf8rKNqB auNkTchEhrcnLWQJewkbOTixtToK7LRWW+jCFn/4dg/H7Wh7Vv/S5RT1P9dzUey6Bc5o Kxukvf8HMtjR9K0pVeRugYc7CQXxrh7ZJaCpW1/WG9g2duUYO9pI3DYC3FX6M7o6KH0Z JGXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PA1oiOuE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s72-v6si6661559qka.20.2018.06.09.20.39.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:39:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PA1oiOuE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrCm-0000nR-LW for patch@linaro.org; Sat, 09 Jun 2018 23:39:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeD-0002um-LI for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeB-0003fE-Sx for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:05 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:39880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeB-0003f3-Kc for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:03 -0400 Received: by mail-pl0-x242.google.com with SMTP id f1-v6so10399794plt.6 for ; Sat, 09 Jun 2018 20:04: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=nbIFk6joHhHEk0ILieO0O1pHXD5skH7BjGeQK2uTGmQ=; b=PA1oiOuEQoN1YrQnuWyoIWDU9BkpB7jOnOTCvZTGuHqHW1U1A9wCRlFLUQFW1D2SUd Sh4nNJ+Gjon+tOLyPJsVNM9HYIj5nn5cdTz+08KfT+p5Pc6RwLWYYetXPrUtL+aNl4wc XBjRtheiKlk2UmBzstKffN5Xc8CV1wRgzjcAQ= 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=nbIFk6joHhHEk0ILieO0O1pHXD5skH7BjGeQK2uTGmQ=; b=FP4TehYiOAm76m4yqcvNSXfOHYtekRzFxQvyZxZ5OaAGHXpIM6tpBqwrjx30n7rKjZ V5lW4gatReoDg1nerTEOWjfCGm50suEjm+wUqJ4j8EqarGOl7LQLEbYCsIwuS1JB6Roq Wvk+Mg3qriQ3zToSKXe6JCXv2Q3H8Sk1nwqk7uxuCd1ipARtA2GQq+AmOUO0OowV8/lA N/66Y/K1Cg55ih++jzhmC2XjSJ/9g3wTeKlb6RbJlVRr50cfgDASAR5mA7mkWa6OXv1i U1+YLynVdLKxNTaOM7gKKTwWfCY8A4x24FDPnFD4Q1f53MtsgA+GBQC9C0lJXmqp6EO3 t8Pw== X-Gm-Message-State: APt69E3FaWPGtE8aXbyzyRhaYqfYqzGg2KOB5myI44RxlawDrKuehGX4 RrWeV/TXw+eeX7lrwd/3kQvA2OiUnrA= X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr12843581plb.74.1528599842460; Sat, 09 Jun 2018 20:04:02 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:16 -1000 Message-Id: <20180610030220.3777-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 044/108] linux-user: Split out socketcall 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" At the same time, merge do_socketcall into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 194 +++++++++++++++++++++---------------------- 1 file changed, 97 insertions(+), 97 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6d8d2eb780..d50c84614e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4184,99 +4184,6 @@ fail: return ret; } -#ifdef TARGET_NR_socketcall -/* do_socketcall() must return target values and target errnos. */ -static abi_long do_socketcall(int num, abi_ulong vptr) -{ - static const unsigned nargs[] = { /* number of arguments per operation */ - [TARGET_SYS_SOCKET] = 3, /* domain, type, protocol */ - [TARGET_SYS_BIND] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_CONNECT] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_LISTEN] = 2, /* fd, backlog */ - [TARGET_SYS_ACCEPT] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_GETSOCKNAME] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_GETPEERNAME] = 3, /* fd, addr, addrlen */ - [TARGET_SYS_SOCKETPAIR] = 4, /* domain, type, protocol, tab */ - [TARGET_SYS_SEND] = 4, /* fd, msg, len, flags */ - [TARGET_SYS_RECV] = 4, /* fd, msg, len, flags */ - [TARGET_SYS_SENDTO] = 6, /* fd, msg, len, flags, addr, addrlen */ - [TARGET_SYS_RECVFROM] = 6, /* fd, msg, len, flags, addr, addrlen */ - [TARGET_SYS_SHUTDOWN] = 2, /* fd, how */ - [TARGET_SYS_SETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ - [TARGET_SYS_GETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ - [TARGET_SYS_SENDMSG] = 3, /* fd, msg, flags */ - [TARGET_SYS_RECVMSG] = 3, /* fd, msg, flags */ - [TARGET_SYS_ACCEPT4] = 4, /* fd, addr, addrlen, flags */ - [TARGET_SYS_RECVMMSG] = 4, /* fd, msgvec, vlen, flags */ - [TARGET_SYS_SENDMMSG] = 4, /* fd, msgvec, vlen, flags */ - }; - abi_long a[6]; /* max 6 args */ - unsigned i; - - /* check the range of the first argument num */ - /* (TARGET_SYS_SENDMMSG is the highest among TARGET_SYS_xxx) */ - if (num < 1 || num > TARGET_SYS_SENDMMSG) { - return -TARGET_EINVAL; - } - /* ensure we have space for args */ - if (nargs[num] > ARRAY_SIZE(a)) { - return -TARGET_EINVAL; - } - /* collect the arguments in a[] according to nargs[] */ - for (i = 0; i < nargs[num]; ++i) { - if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) { - return -TARGET_EFAULT; - } - } - /* now when we have the args, invoke the appropriate underlying function */ - switch (num) { - case TARGET_SYS_SOCKET: /* domain, type, protocol */ - return do_socket(a[0], a[1], a[2]); - case TARGET_SYS_BIND: /* sockfd, addr, addrlen */ - return do_bind(a[0], a[1], a[2]); - case TARGET_SYS_CONNECT: /* sockfd, addr, addrlen */ - return do_connect(a[0], a[1], a[2]); - case TARGET_SYS_LISTEN: /* sockfd, backlog */ - return get_errno(listen(a[0], a[1])); - case TARGET_SYS_ACCEPT: /* sockfd, addr, addrlen */ - return do_accept4(a[0], a[1], a[2], 0); - case TARGET_SYS_GETSOCKNAME: /* sockfd, addr, addrlen */ - return do_getsockname(a[0], a[1], a[2]); - case TARGET_SYS_GETPEERNAME: /* sockfd, addr, addrlen */ - return do_getpeername(a[0], a[1], a[2]); - case TARGET_SYS_SOCKETPAIR: /* domain, type, protocol, tab */ - return do_socketpair(a[0], a[1], a[2], a[3]); - case TARGET_SYS_SEND: /* sockfd, msg, len, flags */ - return do_sendto(a[0], a[1], a[2], a[3], 0, 0); - case TARGET_SYS_RECV: /* sockfd, msg, len, flags */ - return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0); - case TARGET_SYS_SENDTO: /* sockfd, msg, len, flags, addr, addrlen */ - return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]); - case TARGET_SYS_RECVFROM: /* sockfd, msg, len, flags, addr, addrlen */ - return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]); - case TARGET_SYS_SHUTDOWN: /* sockfd, how */ - return get_errno(shutdown(a[0], a[1])); - case TARGET_SYS_SETSOCKOPT: /* sockfd, level, optname, optval, optlen */ - return do_setsockopt(a[0], a[1], a[2], a[3], a[4]); - case TARGET_SYS_GETSOCKOPT: /* sockfd, level, optname, optval, optlen */ - return do_getsockopt(a[0], a[1], a[2], a[3], a[4]); - case TARGET_SYS_SENDMSG: /* sockfd, msg, flags */ - return do_sendrecvmsg(a[0], a[1], a[2], 1); - case TARGET_SYS_RECVMSG: /* sockfd, msg, flags */ - return do_sendrecvmsg(a[0], a[1], a[2], 0); - case TARGET_SYS_ACCEPT4: /* sockfd, addr, addrlen, flags */ - return do_accept4(a[0], a[1], a[2], a[3]); - case TARGET_SYS_RECVMMSG: /* sockfd, msgvec, vlen, flags */ - return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0); - case TARGET_SYS_SENDMMSG: /* sockfd, msgvec, vlen, flags */ - return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1); - default: - gemu_log("Unsupported socketcall: %d\n", num); - return -TARGET_EINVAL; - } -} -#endif - #define N_SHM_REGIONS 32 static struct shm_region { @@ -9575,6 +9482,100 @@ IMPL(sigsuspend) } #endif +#ifdef TARGET_NR_socketcall +IMPL(socketcall) +{ + static const unsigned nargs[] = { /* number of arguments per operation */ + [TARGET_SYS_SOCKET] = 3, /* domain, type, protocol */ + [TARGET_SYS_BIND] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_CONNECT] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_LISTEN] = 2, /* fd, backlog */ + [TARGET_SYS_ACCEPT] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_GETSOCKNAME] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_GETPEERNAME] = 3, /* fd, addr, addrlen */ + [TARGET_SYS_SOCKETPAIR] = 4, /* domain, type, protocol, tab */ + [TARGET_SYS_SEND] = 4, /* fd, msg, len, flags */ + [TARGET_SYS_RECV] = 4, /* fd, msg, len, flags */ + [TARGET_SYS_SENDTO] = 6, /* fd, msg, len, flags, addr, addrlen */ + [TARGET_SYS_RECVFROM] = 6, /* fd, msg, len, flags, addr, addrlen */ + [TARGET_SYS_SHUTDOWN] = 2, /* fd, how */ + [TARGET_SYS_SETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ + [TARGET_SYS_GETSOCKOPT] = 5, /* fd, level, optname, optval, optlen */ + [TARGET_SYS_SENDMSG] = 3, /* fd, msg, flags */ + [TARGET_SYS_RECVMSG] = 3, /* fd, msg, flags */ + [TARGET_SYS_ACCEPT4] = 4, /* fd, addr, addrlen, flags */ + [TARGET_SYS_RECVMMSG] = 4, /* fd, msgvec, vlen, flags */ + [TARGET_SYS_SENDMMSG] = 4, /* fd, msgvec, vlen, flags */ + }; + abi_ulong vptr = arg2; + abi_long a[6]; /* max 6 args */ + unsigned i; + + /* check the range of the first argument num */ + num = arg1; + /* (TARGET_SYS_SENDMMSG is the highest among TARGET_SYS_xxx) */ + if (num < 1 || num > TARGET_SYS_SENDMMSG) { + return -TARGET_EINVAL; + } + /* ensure we have space for args */ + if (nargs[num] > ARRAY_SIZE(a)) { + return -TARGET_EINVAL; + } + /* collect the arguments in a[] according to nargs[] */ + for (i = 0; i < nargs[num]; ++i) { + if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) { + return -TARGET_EFAULT; + } + } + /* now when we have the args, invoke the appropriate underlying function */ + switch (num) { + case TARGET_SYS_SOCKET: /* domain, type, protocol */ + return do_socket(a[0], a[1], a[2]); + case TARGET_SYS_BIND: /* sockfd, addr, addrlen */ + return do_bind(a[0], a[1], a[2]); + case TARGET_SYS_CONNECT: /* sockfd, addr, addrlen */ + return do_connect(a[0], a[1], a[2]); + case TARGET_SYS_LISTEN: /* sockfd, backlog */ + return get_errno(listen(a[0], a[1])); + case TARGET_SYS_ACCEPT: /* sockfd, addr, addrlen */ + return do_accept4(a[0], a[1], a[2], 0); + case TARGET_SYS_GETSOCKNAME: /* sockfd, addr, addrlen */ + return do_getsockname(a[0], a[1], a[2]); + case TARGET_SYS_GETPEERNAME: /* sockfd, addr, addrlen */ + return do_getpeername(a[0], a[1], a[2]); + case TARGET_SYS_SOCKETPAIR: /* domain, type, protocol, tab */ + return do_socketpair(a[0], a[1], a[2], a[3]); + case TARGET_SYS_SEND: /* sockfd, msg, len, flags */ + return do_sendto(a[0], a[1], a[2], a[3], 0, 0); + case TARGET_SYS_RECV: /* sockfd, msg, len, flags */ + return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0); + case TARGET_SYS_SENDTO: /* sockfd, msg, len, flags, addr, addrlen */ + return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]); + case TARGET_SYS_RECVFROM: /* sockfd, msg, len, flags, addr, addrlen */ + return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]); + case TARGET_SYS_SHUTDOWN: /* sockfd, how */ + return get_errno(shutdown(a[0], a[1])); + case TARGET_SYS_SETSOCKOPT: /* sockfd, level, optname, optval, optlen */ + return do_setsockopt(a[0], a[1], a[2], a[3], a[4]); + case TARGET_SYS_GETSOCKOPT: /* sockfd, level, optname, optval, optlen */ + return do_getsockopt(a[0], a[1], a[2], a[3], a[4]); + case TARGET_SYS_SENDMSG: /* sockfd, msg, flags */ + return do_sendrecvmsg(a[0], a[1], a[2], 1); + case TARGET_SYS_RECVMSG: /* sockfd, msg, flags */ + return do_sendrecvmsg(a[0], a[1], a[2], 0); + case TARGET_SYS_ACCEPT4: /* sockfd, addr, addrlen, flags */ + return do_accept4(a[0], a[1], a[2], a[3]); + case TARGET_SYS_RECVMMSG: /* sockfd, msgvec, vlen, flags */ + return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0); + case TARGET_SYS_SENDMMSG: /* sockfd, msgvec, vlen, flags */ + return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 1); + default: + gemu_log("Unsupported socketcall: %d\n", num); + return -TARGET_EINVAL; + } +} +#endif + #ifdef TARGET_NR_ssetmask IMPL(ssetmask) { @@ -9924,10 +9925,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_socketcall - case TARGET_NR_socketcall: - return do_socketcall(arg1, arg2); -#endif #ifdef TARGET_NR_accept case TARGET_NR_accept: return do_accept4(arg1, arg2, arg3, 0); @@ -12935,6 +12932,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sigsuspend SYSCALL(sigsuspend); #endif +#ifdef TARGET_NR_socketcall + SYSCALL(socketcall); +#endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); #endif From patchwork Sun Jun 10 03:01:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138130 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2595736lji; Sat, 9 Jun 2018 20:42:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKokQzjrbIjq4+bZdkW53CYG03ksJm6H5A8nbgnvgZV7UOdWLqyvfH2J8xxGAUCb07kQZQg X-Received: by 2002:ae9:df06:: with SMTP id t6-v6mr10162068qkf.46.1528602156198; Sat, 09 Jun 2018 20:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602156; cv=none; d=google.com; s=arc-20160816; b=JUpxdSGhAy9BdN0hqNykv+ovTVZVbv/TBGoT04dVISuGY+Cqlz+QqCPFyZ7ffq7jzF 6CsNwb+NgywtCetdGgNV9fOmn/jbxzqgJxJ/+H4nCxQTEVhqeytADIJTc3SbwYkaPclr pLLpDspDEEWvaLhCrmNI6ai3PMJ85a5Wy3/GJDq5s2yH3PUdar3FFKdbBQpSHEmahabc hFWHO9cDffIPshtuVbnQpiR2a4Ap0q83vu/0Kv+MDSYg07qvc1gxjT8XUSTKbTRob+TZ AKwR/h9gvf6bYijXWLwk2T08R2sT3YqFbfu+Q2jgNENPOQA9IcJUJ+lIQWTnmjZtEBRG V2ig== 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:arc-authentication-results; bh=0/K+nhAHgOYfScD/OD6yrOXgVFZcrI0ZG2H89d5kxRs=; b=Fi/HosZQw2ayZ2hgR+OYxdzOOuGhrjy0t0d2H3WlyUFO24aQMhFRfPMiL2mngTr3Ca 54NHFX4uZAxDr1V5PkRVgXFS3CkcmRrozyobg3/7CPSM1SQzChjZeUaRpNrh5tURTwC6 ofGe7jOleFsKRlSFmVpwIHHLOSjVR+kS/AEKe6B9E2Hy+bs/lnANb/3BQ75E8h3E1TQg GA9Eu+3vMofgx5hPDCUGqjsjJtYt9yuoIu88/0PrAJyvxzhQi6+n2jMMFGM16L4iG/Tu tBd8halC6tdgAQbTBCTQvxVGOJ8OSRCvWKerem7xzDMKjlQziJLcQR+R6EElcLRLq6JH rB9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WAPKdIyb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p1-v6si1869475qtg.172.2018.06.09.20.42.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WAPKdIyb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrFT-0003fb-IO for patch@linaro.org; Sat, 09 Jun 2018 23:42:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeE-0002w8-UM for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeD-0003fr-VA for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:06 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:39881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeD-0003fX-Oq for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:05 -0400 Received: by mail-pl0-x243.google.com with SMTP id f1-v6so10399814plt.6 for ; Sat, 09 Jun 2018 20:04: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=0/K+nhAHgOYfScD/OD6yrOXgVFZcrI0ZG2H89d5kxRs=; b=WAPKdIyb2rgvk2CeTemSEE25RiNDFrSA4ZmRW96xPOrI5CU1LB1Kx+dgSxS5i+7plE nyxtv3LerR3KuNu6OIYCEgkLh7fMdtOEZX51Cc523UmbdRVWR6r+Qs9jX9AU9NpC0s5D nnQ04Muw1yGRH1fJA+cROzv8IYTabgsphK+6g= 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=0/K+nhAHgOYfScD/OD6yrOXgVFZcrI0ZG2H89d5kxRs=; b=ps3draHFW4Sz98jvIiJuWv/F9vBETvro/XHP+A16IQmF1l8IO5KI3ZBk6+plC0iC8Z zytN5AvqRNCjmAL/s89g9yQyLPBpPHpZ5W4KOqqjfMTxVErFmJZ7hE0I3CevsQR1NrHg XUUM3InqH0Mt9W+ybXVRe5L/es5+UuxnObpkVRhb0dJgANbt+yVbLLkx414YT1xhUb6J 2FCcLJupDk82FAuDaAcuayFIrH8kpUuNl5mz8bimcVdAA1uBJ4HrWEvBGdLvov6Mukf/ LiCdNTQp/4Bu9PkZ6/goWh8QzDiSRGPN+AleVNjcvbTL5Ngw66IJsIKgu+wF/sCu0hct oc0A== X-Gm-Message-State: APt69E3Gmjh77+fIuk1Z+wKxxSBnB1plS9xIk45ne9atnfkuVoKx3T0N h6R4wa2ZEmYUaOZArppeS+X5w1qDQqA= X-Received: by 2002:a17:902:43:: with SMTP id 61-v6mr12925191pla.112.1528599844606; Sat, 09 Jun 2018 20:04:04 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:17 -1000 Message-Id: <20180610030220.3777-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 045/108] linux-user: Split out accept, accept4, bind, connect 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 define accept4; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 52 ++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d50c84614e..155da4f523 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7730,6 +7730,18 @@ static abi_long impl_##NAME(void *cpu_env, unsigned num, abi_long arg1, \ abi_long arg5, abi_long arg6, abi_long arg7, \ abi_long arg8) +#ifdef TARGET_NR_accept +IMPL(accept) +{ + return do_accept4(arg1, arg2, arg3, 0); +} +#endif + +IMPL(accept4) +{ + return do_accept4(arg1, arg2, arg3, arg4); +} + #ifdef TARGET_NR_access IMPL(access) { @@ -7769,6 +7781,13 @@ IMPL(alarm) } #endif +#ifdef TARGET_NR_bind +IMPL(bind) +{ + return do_bind(arg1, arg2, arg3); +} +#endif + IMPL(brk) { return do_brk(arg1); @@ -7821,6 +7840,13 @@ IMPL(close) return get_errno(close(arg1)); } +#ifdef TARGET_NR_connect +IMPL(connect) +{ + return do_connect(arg1, arg2, arg3); +} +#endif + #ifdef TARGET_NR_creat IMPL(creat) { @@ -9925,22 +9951,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_accept - case TARGET_NR_accept: - return do_accept4(arg1, arg2, arg3, 0); -#endif -#ifdef TARGET_NR_accept4 - case TARGET_NR_accept4: - return do_accept4(arg1, arg2, arg3, arg4); -#endif -#ifdef TARGET_NR_bind - case TARGET_NR_bind: - return do_bind(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_connect - case TARGET_NR_connect: - return do_connect(arg1, arg2, arg3); -#endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: return do_getpeername(arg1, arg2, arg3); @@ -12769,9 +12779,16 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_access SYSCALL(access); #endif +#ifdef TARGET_NR_accept + SYSCALL(accept); +#endif + SYSCALL(accept4); SYSCALL(acct); #ifdef TARGET_NR_alarm SYSCALL(alarm); +#endif +#ifdef TARGET_NR_bind + SYSCALL(bind); #endif SYSCALL(brk); SYSCALL(close); @@ -12780,6 +12797,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_chmod SYSCALL(chmod); #endif +#ifdef TARGET_NR_connect + SYSCALL(connect); +#endif #ifdef TARGET_NR_creat SYSCALL(creat); #endif From patchwork Sun Jun 10 03:01:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138133 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2597200lji; Sat, 9 Jun 2018 20:45:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKFyPR2ilV/WMZJUDX5QGRIE4adk8rRh7Nx2r41j0HpySQh0sKL//erhmj80vfXJ5Izf3di X-Received: by 2002:a0c:aa10:: with SMTP id d16-v6mr10958225qvb.198.1528602314807; Sat, 09 Jun 2018 20:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602314; cv=none; d=google.com; s=arc-20160816; b=hC2UexhbZ3DKRjCuesU7FIpNz8c7tWiv0pTRGZFEXFA4lL6dymLuXdtMg58sIQqRDB aCBtCRdRGfOoASbdR5+0elbUD4mnoNp5tiUrP71QLc0lMo58DtIvUAo5qb+2G4Dsp63E HMWUTFj195TY10ZB6lc0tF2uR+dlwzNJbbqEUXpB7V/C9W74+8gDZYhB+lh5LPx2VB3g HwdYUb508be+RvXa5V76Gp3oL3k0MnntrBtJY30YKb46M8CE1lhTNmhS1X/wNA0fBbG+ 3s3u2LaSiZ6A+qldJE+jSboXJHHnnkEol3rA5vLGr4jbwrUQT1wz4QsZZGQSiMxJAaCG dbPw== 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:arc-authentication-results; bh=KzgeLj332Hg4hhdYbzBjX+ZAj17V4ISuX+GMsvoIFCk=; b=T5rKADXxiQQT4qy5DJiJWpn1L6Kz718W/rQiqNBpauv0bhg0sZghd77vbG2ab280vC /4o/2A2Nkk482rmvx4UbBDl0ZDQ4SNntSeaHtD0FpK7o5LaXKjAkiJQaUgzmw2z9Tl05 wOR3dT4OLRk2opBLrup5Ja4zMR1jMbxWP3UIq3sALDCQ1IxIZIYVWQqwv+vWd/bnWjPX Km7pEughXSHyYuTH9JaLpG80Pi/fy0G7QPF5IWe+3DUUmKKtKpkykYPBX0WF/pCOjtes HV5MWRlcPFEr5atYxG3ez+VyTD5WnqjW5G0Cv568QX3IN0dIt55sTDjy6bAtGlkSAlSF ymrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AGMk63ta; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v18-v6si4572370qta.163.2018.06.09.20.45.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:45:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AGMk63ta; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrI2-00061l-6B for patch@linaro.org; Sat, 09 Jun 2018 23:45:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeH-0002z6-NZ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeG-0003gQ-Hj for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:09 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:33743) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeG-0003gF-Bk for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:08 -0400 Received: by mail-pl0-x241.google.com with SMTP id n10-v6so10391225plp.0 for ; Sat, 09 Jun 2018 20:04: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=KzgeLj332Hg4hhdYbzBjX+ZAj17V4ISuX+GMsvoIFCk=; b=AGMk63taUU3N3waxP05MsTnB2+J5PQODHYhua4R55CYCUqkCuss8GrQ5J3ufw3lhjP Wodp0S96BBteukuLU6y80U1kKCmOaNSK6BUwkultN1qvcaxLBJ5lnnmgz27xOSVquzn4 vRBcuGQ9MbdmkDTO0DwlEHMrTFKUcQcNOYclc= 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=KzgeLj332Hg4hhdYbzBjX+ZAj17V4ISuX+GMsvoIFCk=; b=A4rwnmw2DeZtkd+TnS3toSbr1xw3qzY0wnWOIl6tkUFKg382MypG3EnI+zpiVZpGsK yGnYXdV83q6n8bDKYWMZrmJUDWZ76k/hEqBhG+jbUj30nU+OyYgDWhFI4DA7NmdBLhMk JhRr60fV06xA9dw214IFickyXVeULJCzVvkbbmQbo9jNxn91JidNmXPN2P2rdvLcIYfj pJ/6dHp1VmH/Ab3gLmnn1MpYuWOTLD6NP78PjXD472jjiza94aHwUMLnVm8BejGdlaJ2 XDMO0Hw8ctlsm/M35DFuHKyg9hmfzdLGxu7eLaB3CuXabduvidmR71trm1FEZy1ImZaE OR/g== X-Gm-Message-State: APt69E0/eDaRvvUbRWebzBnKUgmqLy50xnZub7OjSllhW7PK7yJFs/jD L+qCnTkGbNGGKvQNzY2jiACFSWL+V/k= X-Received: by 2002:a17:902:b604:: with SMTP id b4-v6mr12940611pls.18.1528599847137; Sat, 09 Jun 2018 20:04:07 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:18 -1000 Message-Id: <20180610030220.3777-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 046/108] linux-user: Split out 7 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" Handle getpeername, getsockname, getsockopt, listen, recv, recvfrom, recvmsg. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 98 +++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 155da4f523..98a982f83f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8153,6 +8153,13 @@ IMPL(futimesat) } #endif +#ifdef TARGET_NR_getpeername +IMPL(getpeername) +{ + return do_getpeername(arg1, arg2, arg3); +} +#endif + #ifdef TARGET_NR_getpgrp IMPL(getpgrp) { @@ -8226,6 +8233,20 @@ IMPL(getrusage) return ret; } +#ifdef TARGET_NR_getsockname +IMPL(getsockname) +{ + return do_getsockname(arg1, arg2, arg3); +} +#endif + +#ifdef TARGET_NR_getsockopt +IMPL(getsockopt) +{ + return do_getsockopt(arg1, arg2, arg3, arg4, arg5); +} +#endif + IMPL(gettimeofday) { struct timeval tv; @@ -8374,6 +8395,13 @@ IMPL(linkat) return ret; } +#ifdef TARGET_NR_listen +IMPL(listen) +{ + return get_errno(listen(arg1, arg2)); +} +#endif + IMPL(lseek) { return get_errno(lseek(arg1, arg2, arg3)); @@ -8912,6 +8940,27 @@ IMPL(reboot) return ret; } +#ifdef TARGET_NR_recv +IMPL(recv) +{ + return do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); +} +#endif + +#ifdef TARGET_NR_recvfrom +IMPL(recvfrom) +{ + return do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); +} +#endif + +#ifdef TARGET_NR_recvmsg +IMPL(recvmsg) +{ + return do_sendrecvmsg(arg1, arg2, arg3, 0); +} +#endif + #ifdef TARGET_NR_rename IMPL(rename) { @@ -9951,34 +10000,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getpeername - case TARGET_NR_getpeername: - return do_getpeername(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_getsockname - case TARGET_NR_getsockname: - return do_getsockname(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_getsockopt - case TARGET_NR_getsockopt: - return do_getsockopt(arg1, arg2, arg3, arg4, arg5); -#endif -#ifdef TARGET_NR_listen - case TARGET_NR_listen: - return get_errno(listen(arg1, arg2)); -#endif -#ifdef TARGET_NR_recv - case TARGET_NR_recv: - return do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); -#endif -#ifdef TARGET_NR_recvfrom - case TARGET_NR_recvfrom: - return do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); -#endif -#ifdef TARGET_NR_recvmsg - case TARGET_NR_recvmsg: - return do_sendrecvmsg(arg1, arg2, arg3, 0); -#endif #ifdef TARGET_NR_send case TARGET_NR_send: return do_sendto(arg1, arg2, arg3, arg4, 0, 0); @@ -12827,6 +12848,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif +#ifdef TARGET_NR_getpeername + SYSCALL(getpeername); +#endif #ifdef TARGET_NR_getpgrp SYSCALL(getpgrp); #endif @@ -12839,6 +12863,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getpriority); SYSCALL(getrlimit); SYSCALL(getrusage); +#ifdef TARGET_NR_getsockname + SYSCALL(getsockname); +#endif +#ifdef TARGET_NR_getsockopt + SYSCALL(getsockopt); +#endif SYSCALL(gettimeofday); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); @@ -12849,6 +12879,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(link); #endif SYSCALL(linkat); +#ifdef TARGET_NR_listen + SYSCALL(listen); +#endif SYSCALL(lseek); #ifdef TARGET_NR_mkdir SYSCALL(mkdir); @@ -12903,6 +12936,15 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(readlinkat); SYSCALL(reboot); +#ifdef TARGET_NR_recv + SYSCALL(recv); +#endif +#ifdef TARGET_NR_recvfrom + SYSCALL(recvfrom); +#endif +#ifdef TARGET_NR_recvmsg + SYSCALL(recvmsg); +#endif #ifdef TARGET_NR_rename SYSCALL(rename); #endif From patchwork Sun Jun 10 03:01:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138116 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2590545lji; Sat, 9 Jun 2018 20:32:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJxjm4rPnz1drtSzmla3maVENOThWVH/Bw1P4Q1qNmZCf41IOsQaR9hDkDafomvOKikK01O X-Received: by 2002:ac8:5357:: with SMTP id d23-v6mr11698063qto.141.1528601577174; Sat, 09 Jun 2018 20:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601577; cv=none; d=google.com; s=arc-20160816; b=KLzDgMBJppP0bnnlkEl7kxfqkqFGEPgpaR0EAPDFJH2YbpXT3o7Pxv1N2Z9cCVK1u+ 4TuI2u6nBWIrHj4rnefuX1ZpX7eanxLVepRR/zRJNcFSVyoDNb84LCQ/8N4a9iblyPvO fsNqawu2ZIIoI6SdlxzaoU5xtGvtB2NMiFEqwm2dCmHV8hcpkxsy8+dpMMXEG/ERyV9A 0vw6WpMXuIDq+qJcw8AOlFPjNuM69zRajsH4AanPSIrCJguQDTZd8MRVb6rq70YnNaT/ sxBrkTq4XWPAwKooon6Bxv5SLa/5Gufqkbzr9NJ3d4oZioeADstbuXOn7r/1VCQG/ama Rg/w== 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:arc-authentication-results; bh=OBIc/rQtLZMy4OOibis5Hv2ns2cWIr/YC3Xq+oUp3Kk=; b=fCj/Pi6/om52Rjy/TaNd8pV3UPgd7M5IGLLKvs2C6f9RECS+W63Wgl6U6xMw6L+VRw NxQT8vf/JfmM+PZn3dpBtSVw2B2CfubAIXMK33TOfiB3mlvH/lD0eEMYrrXjS3jlLcr/ ljpvT7GAUdtZAYwInfovSJ1CDb92AAxYsYvZTBdoI7hPsEAN4qfOkanwjR7aJGfUp5JB EgS9lArhG74+5KO6/SmzlJXP7OqUWGKafDUnnpliOdlDaI9AIvyguZbCgzOcClwPROWd AvI8OIuzlwUYyRFIYf/AxCBoZSWdoUu0KNGGm8/5yrGXUkrnMRbUE1wEBKIF8oldarnU Yt3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OI4LaxGz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h47-v6si9556517qvi.184.2018.06.09.20.32.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OI4LaxGz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr68-0002SK-Gz for patch@linaro.org; Sat, 09 Jun 2018 23:32:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeK-00032H-UQ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeI-0003hD-Bz for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:12 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:44843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeI-0003go-5l for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:10 -0400 Received: by mail-pg0-x244.google.com with SMTP id p21-v6so8127954pgd.11 for ; Sat, 09 Jun 2018 20:04: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=OBIc/rQtLZMy4OOibis5Hv2ns2cWIr/YC3Xq+oUp3Kk=; b=OI4LaxGz7eS7rYyTwR6JmA27t4OoNOeZVPqz5p/b+TynCJZG5vFgu4kgNVM73vbrYZ bSjYk8Y4FNtM5/rDg71Cclm+poV9678k4jm9Uy5f+z9NiD2+tfc5fXhg/IfACY9/6YmI slH/6y2/H0wf6pZ0ZH+dtVZ1keh/vXHAep2cQ= 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=OBIc/rQtLZMy4OOibis5Hv2ns2cWIr/YC3Xq+oUp3Kk=; b=Y4XDfNzv4cllsjCENhfKjEu3f7SgnkSSnDOO50A8JC5racvTxfwc514+lpIs+SZt3d DPJ4Lrv+bZ4NPXB1g0Ier9/RW2eaeVGeYfyxZrZM8ym8+A3+ixVio6VgJAXxDwNIle0N zeTVIFbzySknTlbYsagr5enNl2WCVsdrXwEn8U8ugaXH3BcL2/aewjlSsXk4mlz9sQGH dIn6Ez3e+uv7bF6Q0UJRI9tVxih2Z6XvdV78U4+ldbl+pgDMXuTiBIE8li19chfbS6sO MklSieK8AxFxAOVAjI9Gin4ux4GJT8JsVQoGXw7e2npxeflfQi01R1wthri2LGqO5P3z 9k3A== X-Gm-Message-State: APt69E2t2MzzbCobpXJ0tW8RjQAOJH6Y1ftwZsVcNV8t94xR9exIJJhQ Vp0GAQFb+kyVS5vp3h22jeImbdMyb04= X-Received: by 2002:a65:6356:: with SMTP id p22-v6mr10454935pgv.20.1528599849006; Sat, 09 Jun 2018 20:04:09 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:19 -1000 Message-Id: <20180610030220.3777-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 047/108] linux-user: Split out recvmmsg, send, sendmmsg, sendmsg, sendto 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 | 68 ++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 98a982f83f..977f61610c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8954,6 +8954,13 @@ IMPL(recvfrom) } #endif +#ifdef TARGET_NR_recvmmsg +IMPL(recvmmsg) +{ + return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); +} +#endif + #ifdef TARGET_NR_recvmsg IMPL(recvmsg) { @@ -9288,6 +9295,34 @@ IMPL(select) } #endif +#ifdef TARGET_NR_send +IMPL(send) +{ + return do_sendto(arg1, arg2, arg3, arg4, 0, 0); +} +#endif + +#ifdef TARGET_NR_sendmsg +IMPL(sendmsg) +{ + return do_sendrecvmsg(arg1, arg2, arg3, 1); +} +#endif + +#ifdef TARGET_NR_sendmmsg +IMPL(sendmmsg) +{ + return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); +} +#endif + +#ifdef TARGET_NR_sendto +IMPL(sendto) +{ + return do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); +} +#endif + IMPL(sethostname) { char *p = lock_user_string(arg1); @@ -10000,24 +10035,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_send - case TARGET_NR_send: - return do_sendto(arg1, arg2, arg3, arg4, 0, 0); -#endif -#ifdef TARGET_NR_sendmsg - case TARGET_NR_sendmsg: - return do_sendrecvmsg(arg1, arg2, arg3, 1); -#endif -#ifdef TARGET_NR_sendmmsg - case TARGET_NR_sendmmsg: - return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); - case TARGET_NR_recvmmsg: - return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); -#endif -#ifdef TARGET_NR_sendto - case TARGET_NR_sendto: - return do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); -#endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: return get_errno(shutdown(arg1, arg2)); @@ -12942,6 +12959,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_recvfrom SYSCALL(recvfrom); #endif +#ifdef TARGET_NR_recvmmsg + SYSCALL(recvmmsg); +#endif #ifdef TARGET_NR_recvmsg SYSCALL(recvmsg); #endif @@ -12972,6 +12992,18 @@ static impl_fn *syscall_table(unsigned num) # else SYSCALL(select); # endif +#endif +#ifdef TARGET_NR_send + SYSCALL(send); +#endif +#ifdef TARGET_NR_sendmmsg + SYSCALL(sendmmsg); +#endif +#ifdef TARGET_NR_sendmsg + SYSCALL(sendmsg); +#endif +#ifdef TARGET_NR_sendto + SYSCALL(sendto); #endif SYSCALL(sethostname); SYSCALL(setpgid); From patchwork Sun Jun 10 03:01:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138119 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2591880lji; Sat, 9 Jun 2018 20:35:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJcQR4BoqJPvZBhSWmg2uajvI2LTEf8aKhwXrMaPwsED8eWMExf7pyoo27zoP+fCWaryfG4 X-Received: by 2002:ac8:3854:: with SMTP id r20-v6mr11470424qtb.190.1528601718289; Sat, 09 Jun 2018 20:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601718; cv=none; d=google.com; s=arc-20160816; b=TbxjjPqykJcjCpji82keW0G88daej8kBnS5JsoaNBAoXl7y0zGtb74Dw5GktLfMqMT K5FbN4QVoc3RgaV3q+sBy5dJeMWhrSgJrsuMRFc8MSRkQ/oapN5z3c33kqGbLvr8eQ82 trGvB9uaNRHpZXcuttgMNCYKeYo90szQR3nQhLWv0K6/ewqNy5WDed/Z31F/NDD6Ut1V YtMKP0SH6ABFbOvAdbPuwcxn/z4J1R1rj6MjPz7pNeUKnBq2TZoTrhNCO3Y63XaltkgY zIh0t5iuJ24x2DfnicdCrqJy72UEx+YxeUbHePj4NU1p3l6kSYz5EzCMf/FON7ncgeen OH2w== 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:arc-authentication-results; bh=tObNJbna5DJ9avJPvFGoAZlFiPJwl7Jm1RCZ5QclQGY=; b=JoPN+QivIecFuWVPAU5okuQh8xMw9SgihcZhq286h1lC8ykhwZObRA3NataUkr6jeX bqm95Mr38QHqVl3BSWOqxzUKK7zMGBjSokGeJKA48H8YyEbVtBtplHgMVtJwqjc3qOLi dACRenhYqJySFM8gJbVZ958wSUseU3Im7iTb/hy5Iep2IzsJTp7oMCChPgXDgFdNmAKz zHbGIv4nTfsWxUHSeIzOQJADTLctsB3z93JG5UoYjkmFEhD0308AQf1nlpmFq1Q+rpyS MdD7BSrzXotjPpw7XXKkBZWFsHwy0fheNkJt76ZwUP7kyEiZ3TiPs2zhreFLUWs3Xboz KnMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NXwDOd9L; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 68-v6si2011475qkc.114.2018.06.09.20.35.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:35:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NXwDOd9L; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr8P-00050l-MJ for patch@linaro.org; Sat, 09 Jun 2018 23:35:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeL-00033B-QD for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeK-0003hu-IJ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:13 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:40843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeK-0003hm-80 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:12 -0400 Received: by mail-pg0-x241.google.com with SMTP id l2-v6so8127859pgc.7 for ; Sat, 09 Jun 2018 20:04: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=tObNJbna5DJ9avJPvFGoAZlFiPJwl7Jm1RCZ5QclQGY=; b=NXwDOd9LD0ulgbzwT/NjfjNXQzNctCtC8m3FZ7tj51vXoJ9g7p6Ir9ZkatZhwGMExN u3l9zy7WPLquJpd9WpUPZfnDZwdyq2JsW4D9z/8mxbbfNdbdsiSgSrFHp227Ax1qgqOc wZaC1q/ScWyVllBccdYzxNYsHvK3uR7sSsk8U= 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=tObNJbna5DJ9avJPvFGoAZlFiPJwl7Jm1RCZ5QclQGY=; b=Igz5CfWnaJTAAiPbXqbMI+BCSdWtEUbWzbKgUUcaxjhz7Tf6+/DoofxLYdIuFbV8Y7 ZeIv14RtZG0/y4z19lT6110CLF7pLa3xk0GRoLEOaZoOLgHQuCTxj2JwozzrcKQqAL+0 p0BsVre2hNC5dnNcUYOwMI6EGqdlQo13cXCXRfuRIP6hCTKjmtpWQQ92EZEiP57PTyJz Y4u/zwy2sSaWvtOGSUdrM/73zR5Xqf3nwbqd5wJ+8FQCGjkZOE7fX57tVXAXT60VkJj5 B9FfvRFfVN0GrcJDME2TtkWy7NrSPFspSXG6NAK2VqR2VEyFvWVMPIPdvVKLvSHAeUG5 lEdg== X-Gm-Message-State: APt69E0J6DcfTimj4jyqrKNjUFwftrijYwtMvqAcJv1ICzFi0wJ6QFsd ID9N8rcpfYqkHR6kr6Sc9wnFBeT9bMM= X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr10269044pgt.98.1528599851057; Sat, 09 Jun 2018 20:04:11 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:20 -1000 Message-Id: <20180610030220.3777-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 048/108] linux-user: Split out getrandom, shutdown, setsockopt, socket, socketpair 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 define getrandom; remove the ifdef. Define a stub if the host __NR_getrandom is not defined. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 90 ++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 977f61610c..4dc2312ae6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -249,6 +249,14 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define TARGET_NR__llseek TARGET_NR_llseek #endif +/* These definitions produce an ENOSYS from the host kernel. + * Performing a bogus syscall is lazier than boilerplating + * the replacement functions here in C. + */ +#ifndef __NR_getrandom +#define __NR_getrandom -1 +#endif + #ifdef __NR_gettid _syscall0(int, gettid) #else @@ -315,9 +323,7 @@ _syscall2(int, ioprio_get, int, which, int, who) #if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set) _syscall3(int, ioprio_set, int, which, int, who, int, ioprio) #endif -#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, @@ -8202,6 +8208,19 @@ IMPL(getpriority) #endif } +IMPL(getrandom) +{ + char *p = lock_user(VERIFY_WRITE, arg1, arg2, 0); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(getrandom(p, arg2, arg3)); + unlock_user(p, arg1, ret); + return ret; +} + IMPL(getrlimit) { int resource = target_to_host_resource(arg1); @@ -9284,6 +9303,13 @@ IMPL(sgetmask) } #endif +#ifdef TARGET_NR_shutdown +IMPL(shutdown) +{ + return get_errno(shutdown(arg1, arg2)); +} +#endif + #if defined(TARGET_NR_select) && !defined(TARGET_WANT_NI_OLD_SELECT) IMPL(select) { @@ -9361,6 +9387,13 @@ IMPL(setrlimit) return get_errno(setrlimit(resource, &rlim)); } +#ifdef TARGET_NR_setsockopt +IMPL(setsockopt) +{ + return do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); +} +#endif + IMPL(settimeofday) { struct timeval tv; @@ -9592,6 +9625,13 @@ IMPL(sigsuspend) } #endif +#ifdef TARGET_NR_socket +IMPL(socket) +{ + return do_socket(arg1, arg2, arg3); +} +#endif + #ifdef TARGET_NR_socketcall IMPL(socketcall) { @@ -9686,6 +9726,13 @@ IMPL(socketcall) } #endif +#ifdef TARGET_NR_socketpair +IMPL(socketpair) +{ + return do_socketpair(arg1, arg2, arg3, arg4); +} +#endif + #ifdef TARGET_NR_ssetmask IMPL(ssetmask) { @@ -10035,32 +10082,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_shutdown - case TARGET_NR_shutdown: - return get_errno(shutdown(arg1, arg2)); -#endif -#if defined(TARGET_NR_getrandom) && defined(__NR_getrandom) - case TARGET_NR_getrandom: - p = lock_user(VERIFY_WRITE, arg1, arg2, 0); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(getrandom(p, arg2, arg3)); - unlock_user(p, arg1, ret); - return ret; -#endif -#ifdef TARGET_NR_socket - case TARGET_NR_socket: - return do_socket(arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_socketpair - case TARGET_NR_socketpair: - return do_socketpair(arg1, arg2, arg3, arg4); -#endif -#ifdef TARGET_NR_setsockopt - case TARGET_NR_setsockopt: - return do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); -#endif #if defined(TARGET_NR_syslog) case TARGET_NR_syslog: { @@ -12878,6 +12899,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getppid); #endif SYSCALL(getpriority); + SYSCALL(getrandom); SYSCALL(getrlimit); SYSCALL(getrusage); #ifdef TARGET_NR_getsockname @@ -12986,6 +13008,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); #endif +#ifdef TARGET_NR_shutdown + SYSCALL(shutdown); +#endif #ifdef TARGET_NR_select # ifdef TARGET_WANT_NI_OLD_SELECT SYSCALL_WITH(select, enosys); @@ -13009,6 +13034,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(setpgid); SYSCALL(setpriority); SYSCALL(setrlimit); +#ifdef TARGET_NR_setsockopt + SYSCALL(setsockopt); +#endif SYSCALL(settimeofday); SYSCALL(setsid); #ifdef TARGET_NR_sigaction @@ -13026,9 +13054,15 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sigsuspend SYSCALL(sigsuspend); #endif +#ifdef TARGET_NR_socket + SYSCALL(socket); +#endif #ifdef TARGET_NR_socketcall SYSCALL(socketcall); #endif +#ifdef TARGET_NR_socketpair + SYSCALL(socketpair); +#endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); #endif From patchwork Sun Jun 10 03:01:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138120 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2592029lji; Sat, 9 Jun 2018 20:35:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImEaMUiFqbqiDgn1KVjeAlmoqhFmhlSh8WbTN5k1ADSaHUXEkSZ/ROnNEikc2UDIjLOa1u X-Received: by 2002:ac8:24fa:: with SMTP id t55-v6mr11854679qtt.196.1528601737577; Sat, 09 Jun 2018 20:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601737; cv=none; d=google.com; s=arc-20160816; b=SqQa6X2vcxJ6cGHOdO1gFlvS0AtZIun9QKBX7K/X/PgkIivMdSRA8QKnUdP2xWdXO2 Hep+MY46cIcP3xCp/lzPnlCcPQTBQUilusdX18RzhwQP97DBBAZ4PnPe4sxSNR03fcZD Ne9hxEGQ5ITuvgcLxvp1Q6MwFjzyeZrAzaJi/i5cSnVvsIV5rA5eupvGwCMrP7smLT5x qoPjfzQXdFc2bGB5GtGxsazyVS8Png5t2s/Uhu5pPJmNflaqfuFFUYAzQKaCYFWJb9Y1 OpHjZ4BmhlXaxDcZeo8gH2FE2xJimevpte27pGwJAIjkbW+RawAtQHUVdG7zBI93zLmX kfBw== 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:arc-authentication-results; bh=MUvX6lyiWfqoJVTOqtiDDnvFbBTaBxc2WWyvr2yzI6U=; b=L4xKSVdW+uBTOF2KS62Ht0bxKse9Pq8RCii4c2Eoty99m95Ksssf/2FSUxqPQezKAo yudoTnYHrlIbUs27V1cKX2glLjqsqrIPZeKnCfoO85+gl8thFjG/zEoIGUBJOpPuxqF3 o7i6tK7oiAqvyaz/Izn2Wcc4wWep1O4GdyODaJ8Kt8d1MoX8ij4vNDMiOXEamkdNxWyC gOeoQwmOS4LhF3EdycRlapxVGsVbtC1Kjzr2ZjfHGWnTFhpPVg6f2rcWLb2FIBu74PQH Y0aAJ64soTwPsouZkCzcJ9IgRkx3fqGsg8L+jaC1iEH/Z1F/YoDBsc6DJbjVL01kiJfJ 9ZIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kGyHA2WY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s203-v6si7366102qke.188.2018.06.09.20.35.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:35:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kGyHA2WY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr8j-0005XF-2i for patch@linaro.org; Sat, 09 Jun 2018 23:35:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeN-00034o-70 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeM-0003iZ-69 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:15 -0400 Received: from mail-pl0-x232.google.com ([2607:f8b0:400e:c01::232]:42131) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeM-0003iF-0Y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:14 -0400 Received: by mail-pl0-x232.google.com with SMTP id w17-v6so10390336pll.9 for ; Sat, 09 Jun 2018 20:04: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=MUvX6lyiWfqoJVTOqtiDDnvFbBTaBxc2WWyvr2yzI6U=; b=kGyHA2WYGfG+sq8JMb6cq32o7dVPPhnhJ8eWxAhagMEUViPJ8cQ+4sIVs4SvCgqWtG Qw+Zh9r9MJ9yKv/kvASZiWJk1IwKFhy9TKP0uLhRQx/R+SxjasisdqU8W2pusk87dz6r PPQduZnOHKxiRSQ+qWP+cfNmKGY5q8ay8yZ+U= 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=MUvX6lyiWfqoJVTOqtiDDnvFbBTaBxc2WWyvr2yzI6U=; b=sq9OEKRIlprQN7icvGguLzrR/5C/Y1ph8WireGKkOfwppxJJYb5gaWLUlIUfaN6X6g FTJPy8E17U6XJ/54bD87aAER9FSIYiBh2IAD/3TfRT2n01qKOTohi0AXROPzlzVE73mR 7Ze0qO8z8cQTHCJRjW898Tpq+V1XJt6xuy/bR6/Yk4THpyJX9gYgvFkasUWfXbwuv10K WjVr330nfznHwNLTuI1C/JWVeXkR4WQ6XZSHhz8PdkMUScoAhps3ThfXjd/NwSPO95Zt GDok4fnX+Hv4efHwHBNe+4Cx4vCxX6b7KgjJm9r9vNcBMfJGcXSTjDtnJ82KqTaBpNsb 9Hwg== X-Gm-Message-State: APt69E1iGw1PKOKXWejQlsqs/uuARmWDNP6wIizY1tw2vhcdbU9D9kDI VUs0qNcFtfhfc3mTkESyo7Te/9K7sYE= X-Received: by 2002:a17:902:8e87:: with SMTP id bg7-v6mr12895596plb.129.1528599852827; Sat, 09 Jun 2018 20:04:12 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:21 -1000 Message-Id: <20180610030220.3777-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::232 Subject: [Qemu-devel] [PATCH v2 049/108] linux-user: Fix stub gettid 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 "proper" implementation of the stub would assign ENOSYS to errno and return -1. As it is, the subsequent get_error will return whatever garbage value was in errno. Use the bogus syscall method for defining the stub function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4dc2312ae6..46c7c485fd 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -256,17 +256,12 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #ifndef __NR_getrandom #define __NR_getrandom -1 #endif - -#ifdef __NR_gettid -_syscall0(int, gettid) -#else -/* This is a replacement for the host gettid() and must return a host - errno. */ -static int gettid(void) { - return -ENOSYS; -} +#ifndef __NR_gettid +#define __NR_gettid -1 #endif +_syscall0(int, gettid) + /* 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 From patchwork Sun Jun 10 03:01:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138123 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2593527lji; Sat, 9 Jun 2018 20:38:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3QzUSDa8fXA1KLK7NE/tVXaD2MJUhxWOeiX5jn2QnyN/ArI4mONTcmtMek5EqqQZ0tvFU X-Received: by 2002:a0c:d4d2:: with SMTP id y18-v6mr10766051qvh.63.1528601904841; Sat, 09 Jun 2018 20:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601904; cv=none; d=google.com; s=arc-20160816; b=dilAqvhXkjXPOED1A5pJpQu7Gu+VVPf7AJt0kvCuiLjE4J2ymU+N9Mi8ooi9hHSyYX Cs54rsBGMNtKORh1aRT4hVDX6+i0nG3qYMRMuK7521rwTdTbDOKl0jjn/1DhuHk7j0nU +zHpFzDRXRJzXsyKuAch8/oQ52yeg5VASDJ3XONS1K/ZsTdz6APz//+DIB+iXJoW8RkR gpOfsX9PBvjxdMb6huWrQTURrcWf82HA64/nB5NzRa8i7kfDNPhq1U5YbEyzVWn57bXd DqZ2NjwIo2+pZFlUxQh9KCSQZb1VpxUVV2cNY7Rgs2oCInyRZviuLU9fOPixcQ+ZhUMe BmVg== 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:arc-authentication-results; bh=SF2dE5sRByvOLy3iaC3SQQTLER/KaLyYNlFv9XOiQRI=; b=j0ECQdfd00xk83eMbBKoKWttg01R/BPjfye3O043bjxSd5Ig7mGuJB2BNKwRP8VFuY HfRpAp5sfS7E9NlOSZPXdiPbSkI0NlKZIIgXRWFCOmZicfwziRUkJDmila5S5gKYq3aV 2oFfOmDeOjBhjENI5N6gLlDbwKLYnFxNsEqex6pH28/OxvVIsREuAgWLkOyg/xN7oZXl 6LxuYLwFuLQ8ueAFYvlg/KCQsDl8ACjl7r5A0mnMtr3UcDxkeG1WGTmMsJ1m8bXrbT4r Hocl4bgdpOsbxHTVb6B5f9qrfOQpqIlES/nIlY4RR8xC27byb2dbZdbLDRNmwaqHHkW1 iOqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YLudTcir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i4-v6si1975341qkf.65.2018.06.09.20.38.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YLudTcir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrBQ-0007te-9F for patch@linaro.org; Sat, 09 Jun 2018 23:38:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeP-00037D-DS for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeO-0003jF-68 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:17 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:35910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeN-0003j3-Tm for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:16 -0400 Received: by mail-pl0-x244.google.com with SMTP id a7-v6so7899611plp.3 for ; Sat, 09 Jun 2018 20:04: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=SF2dE5sRByvOLy3iaC3SQQTLER/KaLyYNlFv9XOiQRI=; b=YLudTcirlVSyLa6GbHTLf8fDWESUDYiLYRFovvFeyTYMJmz0kpsBow1i1NmKvt634v mqaRGjvPI99efsne7R7ilZuRSOZhQCPrCsop9XvQ7NAmLoDjUfDpbwQ7SsHo7IQQr+2J wlwVyTG7Y0++B6UTSWoVDcEozm2H1MPdZVCs0= 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=SF2dE5sRByvOLy3iaC3SQQTLER/KaLyYNlFv9XOiQRI=; b=frkcMI1lfVcty7edNXbea3YO75Opc6P4aFHfCgBOJvKPL0OWxuWFwIKb52CTEhRnGE ch3n+fZ4YIeyFQDrzJNlb3kLBWU8480N0/rSVBzK3bnLOqB7AK5mALShvbPNwrnfYCto 1ZmrPm1xrm9ralS3l40GtEYx8BFIIGlyFSNczmzUGFfsSvfIgXJz/yGJBnFpgzKJSdUb H++MV9VnWPMXo8Fam0AQhnV70w+YN+feGUCRvFu5SAAnmEqMyzpWJ635QFPdvVMSPvWj N11gRgbxSDpc6Yw36WQTxtgHkCrYVV/rOdi5XYkfm0Iw0a5v0tTaa9n4+6TH1T20Xoli AFRw== X-Gm-Message-State: APt69E3JY75bpj0OwmLOOfFWN3jyshetitJw3Inc2ctmHFvD5BZBJrqQ wKyeNi8/sGSwOwV5FRFM+k41oZNjWDs= X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr12600416ple.285.1528599854735; Sat, 09 Jun 2018 20:04:14 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:22 -1000 Message-Id: <20180610030220.3777-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v2 050/108] linux-user: Split out getitimer, setitimer, syslog 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 define syslog; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 155 ++++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 76 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 46c7c485fd..c8fc7fc908 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8154,6 +8154,20 @@ IMPL(futimesat) } #endif +IMPL(getitimer) +{ + struct itimerval value; + abi_long ret = get_errno(getitimer(arg1, &value)); + + if (!is_error(ret) && arg2 && + (copy_to_user_timeval(arg2, &value.it_interval) || + copy_to_user_timeval(arg2 + sizeof(struct target_timeval), + &value.it_value))) { + return -TARGET_EFAULT; + } + return ret; +} + #ifdef TARGET_NR_getpeername IMPL(getpeername) { @@ -9357,6 +9371,28 @@ IMPL(sethostname) return ret; } +IMPL(setitimer) +{ + struct itimerval ivalue, ovalue; + abi_long ret; + + if (arg2 && + (copy_from_user_timeval(&ivalue.it_interval, arg2) || + copy_from_user_timeval(&ivalue.it_value, + arg2 + sizeof(struct target_timeval)))) { + return -TARGET_EFAULT; + } + ret = get_errno(setitimer(arg1, arg2 ? &ivalue : NULL, + arg3 ? &ovalue : NULL)); + if (!is_error(ret) && arg3 && + (copy_to_user_timeval(arg3, &ovalue.it_interval) || + copy_to_user_timeval(arg3 + sizeof(struct target_timeval), + &ovalue.it_value))) { + return -TARGET_EFAULT; + } + return ret; +} + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); @@ -9848,6 +9884,46 @@ IMPL(syncfs) } #endif +IMPL(syslog) +{ + abi_long ret; + char *p; + int len; + + switch (arg1) { + case TARGET_SYSLOG_ACTION_CLOSE: /* Close log */ + case TARGET_SYSLOG_ACTION_OPEN: /* Open log */ + case TARGET_SYSLOG_ACTION_CLEAR: /* Clear ring buffer */ + case TARGET_SYSLOG_ACTION_CONSOLE_OFF: /* Disable logging */ + case TARGET_SYSLOG_ACTION_CONSOLE_ON: /* Enable logging */ + case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: /* Set messages level */ + case TARGET_SYSLOG_ACTION_SIZE_UNREAD: /* Number of chars */ + case TARGET_SYSLOG_ACTION_SIZE_BUFFER: /* Size of the buffer */ + return get_errno(sys_syslog((int)arg1, NULL, (int)arg3)); + + case TARGET_SYSLOG_ACTION_READ: /* Read from log */ + case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */ + case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */ + len = arg2; + if (len < 0) { + return -TARGET_EINVAL; + } + if (len == 0) { + return 0; + } + p = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); + unlock_user(p, arg2, arg3); + return ret; + + default: + return -TARGET_EINVAL; + } +} + #ifdef TARGET_NR_time IMPL(time) { @@ -10077,82 +10153,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_syslog) - case TARGET_NR_syslog: - { - int len = arg2; - - switch (arg1) { - case TARGET_SYSLOG_ACTION_CLOSE: /* Close log */ - case TARGET_SYSLOG_ACTION_OPEN: /* Open log */ - case TARGET_SYSLOG_ACTION_CLEAR: /* Clear ring buffer */ - case TARGET_SYSLOG_ACTION_CONSOLE_OFF: /* Disable logging */ - case TARGET_SYSLOG_ACTION_CONSOLE_ON: /* Enable logging */ - case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: /* Set messages level */ - case TARGET_SYSLOG_ACTION_SIZE_UNREAD: /* Number of chars */ - case TARGET_SYSLOG_ACTION_SIZE_BUFFER: /* Size of the buffer */ - return get_errno(sys_syslog((int)arg1, NULL, (int)arg3)); - case TARGET_SYSLOG_ACTION_READ: /* Read from log */ - case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */ - case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */ - { - if (len < 0) { - return -TARGET_EINVAL; - } - if (len == 0) { - return 0; - } - p = lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(sys_syslog((int)arg1, p, (int)arg3)); - unlock_user(p, arg2, arg3); - } - return ret; - default: - return -TARGET_EINVAL; - } - } - break; -#endif - case TARGET_NR_setitimer: - { - struct itimerval value, ovalue, *pvalue; - - if (arg2) { - pvalue = &value; - if (copy_from_user_timeval(&pvalue->it_interval, arg2) - || copy_from_user_timeval(&pvalue->it_value, - arg2 + sizeof(struct target_timeval))) - return -TARGET_EFAULT; - } else { - pvalue = NULL; - } - ret = get_errno(setitimer(arg1, pvalue, &ovalue)); - if (!is_error(ret) && arg3) { - if (copy_to_user_timeval(arg3, - &ovalue.it_interval) - || copy_to_user_timeval(arg3 + sizeof(struct target_timeval), - &ovalue.it_value)) - return -TARGET_EFAULT; - } - } - return ret; - case TARGET_NR_getitimer: - { - struct itimerval value; - - ret = get_errno(getitimer(arg1, &value)); - if (!is_error(ret) && arg2) { - if (copy_to_user_timeval(arg2, - &value.it_interval) - || copy_to_user_timeval(arg2 + sizeof(struct target_timeval), - &value.it_value)) - return -TARGET_EFAULT; - } - } - return ret; #ifdef TARGET_NR_stat case TARGET_NR_stat: if (!(p = lock_user_string(arg1))) { @@ -12881,6 +12881,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif + SYSCALL(getitimer); #ifdef TARGET_NR_getpeername SYSCALL(getpeername); #endif @@ -13026,6 +13027,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sendto); #endif SYSCALL(sethostname); + SYSCALL(setitimer); SYSCALL(setpgid); SYSCALL(setpriority); SYSCALL(setrlimit); @@ -13077,6 +13079,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_SYNCFS SYSCALL(syncfs); #endif + SYSCALL(syslog); #ifdef TARGET_NR_time SYSCALL(time); #endif From patchwork Sun Jun 10 03:01:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138126 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2594518lji; Sat, 9 Jun 2018 20:40:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK58Z8xFPKYdumOBGDKUw592aVvFj0ahkF/38AvI/AmghwZDmBnx2YKQI4dF0nZF/aPJh4W X-Received: by 2002:a37:2648:: with SMTP id y69-v6mr10600934qkg.258.1528602020317; Sat, 09 Jun 2018 20:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602020; cv=none; d=google.com; s=arc-20160816; b=cIW/tVbF3d67i76xplBUWsYNP68p/pMjvhPJzKAFXMiH0bFm1TbKcAlocbdRm9r9aq OmHBEjeXWcYw6PLs8o7wJf6HNTsif4OgNwUjdK2NnLnhvLVDKkfumOICnioow/W5ZSjx 4Eey1UEEm4q7JsXJ6GQgoUmI1ZWsOpJ2mtAp/hh+6EhzHmujH47yZOp9xrKnKidTgVHx Pv81IB8UPehYocR3E3zA/XKDclFPFRXDc/f1n3/RbhmmDA7iiZ9ZSiAv0ogJtCNnNyKy qP4UAnIOfxeHv9G+NDNF3zrTTqGBs1cTmbt02NSUb1PMWo2vXe/DGZLYTQoyrenG+ZhC YgHg== 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:arc-authentication-results; bh=ySbzxelQtsO4OgTE8VIJgIVKguLD8H7LWHuTCeWLlCc=; b=1Jyt3Cbb7WAc6n1S0TIBney0Akc2wFC5KHv25sqk64CGi49poHr4559zAiJNTuWszW hDR2bc6JqsBF6VQ46bfxEqr2M/nhW51VK82F+QwgRQiHoLHJP21e9gOWXWnValJ3Sog+ sdNNdYH+tV/w6Zi31zkLI++DgO7eQ88Xaeq62iqCNlTjvUCHFaHvwvOwP98dbxcIATD0 sAgo869JmLGQEhJ15hTPj9yNXcH8jTd7+Rmc9f4r0pUh0mwcD1fUBH0+fUqUuZNGwjsE PgxF9rkbyKT0zUvTGl+Tl1YHA1rBoDqyp9du73JqxXYSS6kl7IsVZIZh0Ut/NSQxNn6h fJhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IBpCrmrH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w1-v6si9567861qtg.224.2018.06.09.20.40.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IBpCrmrH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrDH-00029b-Pa for patch@linaro.org; Sat, 09 Jun 2018 23:40:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeT-0003Av-DW for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeQ-0003kI-4u for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:21 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:41585) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeP-0003jz-Sw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:18 -0400 Received: by mail-pl0-x243.google.com with SMTP id az12-v6so10380339plb.8 for ; Sat, 09 Jun 2018 20:04:17 -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=ySbzxelQtsO4OgTE8VIJgIVKguLD8H7LWHuTCeWLlCc=; b=IBpCrmrHwiIO26Q7MShK7g4YRmDlI3ofRxEZOmov7MkrVvBRKjl9TFUKKgugL6sn3W cjP+xAx5te4vzYoTIUDe3GTbChsEfafCt7/5wwedd0XARtUNo/z3bahJYWj+9jLA0vJk fLUsFD7a9hPwv9ucQ2YmME6E85eP4nqlBtwh8= 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=ySbzxelQtsO4OgTE8VIJgIVKguLD8H7LWHuTCeWLlCc=; b=arVWMLFfeYUsPjVPpbDzD46N52sIA7N7yigBlRcYam+I1/yv+5sVCU+8U3ks83pAVk RiOfCrSQObQy4bYQQ43g5fq+4gcCTmG/QCYv9iQRc/iSLPFHBcq4WL6GI7GgPfkGpQ+a +dmOONOqVjYBKkhIpIQBXcfhGg5FNUXh4LmIob3sdAknsLQA5a0vSv2ec+RhfhNnmdov A60Nyl+wP5fwEsPkgzOgS+97UCMTsj9u44pE7uf8NVgN8Uhd+n9miaKwbN3yLVQSMuQd mCaBs+qDuKw4BTj3prOJFLuu2DdC4Ad/taH08XH5F5W686k4jtgtTaOgtHfnrVB2K89d ZzFg== X-Gm-Message-State: APt69E1boSiqT/akXmZwSk2w4AnlJkClsWyjVdAm4TQtnlHtskH3oBrD GiAD6ksTWdXprJVZTe+7Ev22jQP70Qc= X-Received: by 2002:a17:902:784d:: with SMTP id e13-v6mr12976706pln.197.1528599856717; Sat, 09 Jun 2018 20:04:16 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:23 -1000 Message-Id: <20180610030220.3777-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 051/108] linux-user: Split out fstat, lstat, stat 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 | 129 +++++++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 47 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c8fc7fc908..4f6c01092b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7052,6 +7052,31 @@ static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp, return 0; } +static abi_long host_to_target_stat(abi_ulong target_addr, struct stat *st) +{ + struct target_stat *target_st; + + if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0)) { + return -TARGET_EFAULT; + } + memset(target_st, 0, sizeof(*target_st)); + __put_user(st->st_dev, &target_st->st_dev); + __put_user(st->st_ino, &target_st->st_ino); + __put_user(st->st_mode, &target_st->st_mode); + __put_user(st->st_uid, &target_st->st_uid); + __put_user(st->st_gid, &target_st->st_gid); + __put_user(st->st_nlink, &target_st->st_nlink); + __put_user(st->st_rdev, &target_st->st_rdev); + __put_user(st->st_size, &target_st->st_size); + __put_user(st->st_blksize, &target_st->st_blksize); + __put_user(st->st_blocks, &target_st->st_blocks); + __put_user(st->st_atime, &target_st->target_st_atime); + __put_user(st->st_mtime, &target_st->target_st_mtime); + __put_user(st->st_ctime, &target_st->target_st_ctime); + unlock_user_struct(target_st, target_addr, 1); + return 0; +} + static inline abi_long host_to_target_stat64(void *cpu_env, abi_ulong target_addr, struct stat *host_st) @@ -8100,6 +8125,18 @@ IMPL(fork) } #endif +IMPL(fstat) +{ + struct stat st; + abi_long ret; + + ret = get_errno(fstat(arg1, &st)); + if (!is_error(ret) && host_to_target_stat(arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} + IMPL(fstatfs) { struct statfs stfs; @@ -8435,6 +8472,25 @@ IMPL(lseek) return get_errno(lseek(arg1, arg2, arg3)); } +#ifdef TARGET_NR_lstat +IMPL(lstat) +{ + char *p = lock_user_string(arg1); + struct stat st; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(lstat(path(p), &st)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_stat(arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_mkdir IMPL(mkdir) { @@ -9781,6 +9837,25 @@ IMPL(ssetmask) } #endif +#ifdef TARGET_NR_stat +IMPL(stat) +{ + char *p = lock_user_string(arg1); + struct stat st; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(stat(path(p), &st)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_stat(arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(statfs) { char *p = lock_user_string(arg1); @@ -10153,53 +10228,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_stat - case TARGET_NR_stat: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(stat(path(p), &st)); - unlock_user(p, arg1, 0); - goto do_stat; -#endif -#ifdef TARGET_NR_lstat - case TARGET_NR_lstat: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(lstat(path(p), &st)); - unlock_user(p, arg1, 0); - goto do_stat; -#endif - case TARGET_NR_fstat: - { - ret = get_errno(fstat(arg1, &st)); -#if defined(TARGET_NR_stat) || defined(TARGET_NR_lstat) - do_stat: -#endif - if (!is_error(ret)) { - struct target_stat *target_st; - - if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0)) - return -TARGET_EFAULT; - memset(target_st, 0, sizeof(*target_st)); - __put_user(st.st_dev, &target_st->st_dev); - __put_user(st.st_ino, &target_st->st_ino); - __put_user(st.st_mode, &target_st->st_mode); - __put_user(st.st_uid, &target_st->st_uid); - __put_user(st.st_gid, &target_st->st_gid); - __put_user(st.st_nlink, &target_st->st_nlink); - __put_user(st.st_rdev, &target_st->st_rdev); - __put_user(st.st_size, &target_st->st_size); - __put_user(st.st_blksize, &target_st->st_blksize); - __put_user(st.st_blocks, &target_st->st_blocks); - __put_user(st.st_atime, &target_st->target_st_atime); - __put_user(st.st_mtime, &target_st->target_st_mtime); - __put_user(st.st_ctime, &target_st->target_st_ctime); - unlock_user_struct(target_st, arg2, 1); - } - } - return ret; case TARGET_NR_vhangup: return get_errno(vhangup()); #ifdef TARGET_NR_syscall @@ -12873,6 +12901,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_fork SYSCALL(fork); #endif + SYSCALL(fstat); SYSCALL(fstatfs); #ifdef TARGET_NR_fstatfs64 SYSCALL(fstatfs64); @@ -12918,6 +12947,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(listen); #endif SYSCALL(lseek); +#ifdef TARGET_NR_lstat + SYSCALL(lstat); +#endif #ifdef TARGET_NR_mkdir SYSCALL(mkdir); #endif @@ -13062,6 +13094,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); +#endif +#ifdef TARGET_NR_stat + SYSCALL(stat); #endif SYSCALL(statfs); #ifdef TARGET_NR_statfs64 From patchwork Sun Jun 10 03:01:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138128 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2595012lji; Sat, 9 Jun 2018 20:41:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLZv4b2yjArKGN50EOYMAOpg09UGVN1kX5HcWzVfpoMffxzuF41nP8aNwH0hpnpOn4FsIxE X-Received: by 2002:ac8:2836:: with SMTP id 51-v6mr11744080qtq.131.1528602069563; Sat, 09 Jun 2018 20:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602069; cv=none; d=google.com; s=arc-20160816; b=p8ZmXqkKXk2X+n0zkf41MXyFG8zllSDJadtyaNkx5fb4QPsh83l8TLk9Xn2oxCNdhM eQmtjOzbssjTCKtGI9hsn0gEpv9RfwPRWVH11BM0Y1v6aBIVU8sOXxIIZc5QkKl8gyfd 8lDwMNxgwTMlUVQYa4B9U04MvBBykUlyHy2m2zRKabgqgKtcE4/fKMdv43/gBTQVxY1y rLyhWhsw6qEYGXrscia2N9yXaaex6xfIOvN1vTDjbrO+N4ATGLUn8+S+1sZwTL+xkf+g wnKDBnUwMCxrLc/2ePu/laqEc7JPrbElAbFEcg33n/HMDhfCHyHzf5/qNrBJEeDXo1Sa iavw== 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:arc-authentication-results; bh=+9FBDCGrmf2va8DsMokYKksAPRBWVfDs5ghfJ28qSC0=; b=l75nDYRVok5rwzUj4mM7h3ioQkw4qdgQ69jT98+lf3zQIxRQebPDOkuBwCmrE6mQTX IIO0utF0GZvemaBLYBPx1eF+Ya5AKRF5xisoBGBxJx+Nalerp6LnSUjJdARyXR279Olx kAH7EK5XnEEIddwAOIZpP0xIj8VjOdnzwD3lTmbxKOCisKF+R3vpI0CtrmE3kM5UE4cL VAv8bcZ7+UjwWlPPpUFrKqwdTQGKpHoBb0BXXhsryovEEkOxX7K5LQIiJp0C9/Nw3Hjz +VR+pSRidWGdUd+mOPVYSpHI+rrhC1J37lJ9wMpqyUrYEMnjEFsMc56goU0mQJc5nrQ2 7jJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QaGQnSH4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h33-v6si40712qtk.78.2018.06.09.20.41.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QaGQnSH4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrE5-0002TR-1F for patch@linaro.org; Sat, 09 Jun 2018 23:41:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeT-0003Aw-DS for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeR-0003kp-SB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:21 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:42385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeR-0003kh-N0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:19 -0400 Received: by mail-pf0-x244.google.com with SMTP id w7-v6so8478742pfn.9 for ; Sat, 09 Jun 2018 20:04: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=+9FBDCGrmf2va8DsMokYKksAPRBWVfDs5ghfJ28qSC0=; b=QaGQnSH4AJSaU3pshAJBLMIeIVuntQZLVs/6qh7FNGNpkzP1D7Z5CWNLm86gyiUAtq m0yNH91+FfAQCIQ6DooWREUJ0iahxmIu4Fn0GQqlhO3wt69tOHjluPWLL+1pBkAgsJqd 5zWklf9kk5qKSXCuxtjCCyorDVmeviIJ5YHls= 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=+9FBDCGrmf2va8DsMokYKksAPRBWVfDs5ghfJ28qSC0=; b=WOkKuuKQYHJ9SkjZLwU9lpEKSHj/cwH/aypuxHD+5AbvHlTsWnUk0jdMX7vOi33nKE KyAMjzFf+2Tngwb6nOmmr95tasoH38CVVFj3I0OOd1SeQC0vx9UC3q9ZdxMnbAEzXxRb 34KLEgXfQRbwElsoTxMpFSw4bB4t4Ck/vR32YdyMjUhKfPcdMZeyzT1nD93/ZQSk2zQu d6uSJQ2cPLDms6HnorEou0MuHdE1eVXVT0gi2qD1YCjM7McEkZW6Om/BmW7lLVJRkEFP TNExfn2b3ErvnRHvAJ2aEdSMBfP8C9DeclI5RNQOt+Pwf76qTItNynFBKSpys/fQGr5f BL2g== X-Gm-Message-State: APt69E1OH1Y8qTBb0v0ui+/4FXFqiIRdABQPtga5hc0twj6aE+To4CWb 58AZD9N4/a0Zw12q0v2Nlhd7Z2yyvls= X-Received: by 2002:a63:3c4c:: with SMTP id i12-v6mr10447548pgn.309.1528599858541; Sat, 09 Jun 2018 20:04:18 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:24 -1000 Message-Id: <20180610030220.3777-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 052/108] linux-user: Unwrap TARGET_NR_syscall early 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" Unwrapping early produces a much nicer log output. Disallow recursive syscall, as per ARM and MIPS. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4f6c01092b..87374014b1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10230,11 +10230,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, switch(num) { case TARGET_NR_vhangup: return get_errno(vhangup()); -#ifdef TARGET_NR_syscall - case TARGET_NR_syscall: - return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, - arg6, arg7, arg8, 0); -#endif case TARGET_NR_wait4: { int status; @@ -13171,6 +13166,32 @@ abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1, } } #endif +#ifdef TARGET_NR_syscall + /* For the benefit of strace, unwrap NR_syscall now. */ + if (num == TARGET_NR_syscall) { + num = arg1 & 0xffff; + if (num == TARGET_NR_syscall) { + /* Do not allow recursion. */ + ret = -TARGET_ENOSYS; + 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); + print_syscall_ret(num, ret); + } + trace_guest_user_syscall_ret(cpu, num, ret); + return ret; + } + arg1 = arg2; + arg2 = arg3; + arg3 = arg4; + arg4 = arg5; + arg5 = arg6; + arg6 = arg7; + arg7 = arg8; + arg8 = 0; + } +#endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); From patchwork Sun Jun 10 03:01:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138137 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2598695lji; Sat, 9 Jun 2018 20:48:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJVqt1/5UW9pRhWRy47ck8ZSXa+7hdnvP0s6X0CBYNG5ROfA97+7H1RqrNgX44ZgTY299WT X-Received: by 2002:a37:660f:: with SMTP id a15-v6mr10547529qkc.440.1528602488529; Sat, 09 Jun 2018 20:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602488; cv=none; d=google.com; s=arc-20160816; b=YzbmrSvTui1axQt6LyrsELJmFBjoDFlpOhx2ttnVro+iP1gVgyjC+HsfqtvwqSueDG d2TUow1PtKp+KZVbrd2bTeocJVJVrZWUsShEP6o3ZAn7Gg3JCvh1cqoW1vqlFAFpKF0h kQUJDxPQLgCE9d9u/6tC4spZtCtyRMJYOhkvbwrjlk173bPPK3EYf3+PQuUzY8PJds+T TlqO7ruf4gxjpeeqTsp23MMfMat+Pm3lubbMc30kOVbKy372BZPrGjF5IAj5Dr39DJYn 0VvmGjfnT8SBXIAdPwLYFzch/kbdrr6sLjgi0kyYRaBbO4iYN5igSAei+N9++fbDB2VX seqA== 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:arc-authentication-results; bh=r/JZ9Kq3fbaGkjGRdS3WOr/GkHVFl9LVGQIvJBANdVs=; b=dILBbbHU1A8hGS4e7n6Rwjk/RyHbRAdyIYCYuqwt2BWx52q5EvTck609n5IAXnoLb+ O50gmne+J6bX9Lv2FTLncbSRvSUdwN+DJ1PP21tjZFWksFiJ0baKk6zBdFngaiFLjSN/ pQ9qR2TLd8xE7YEKvnkSw87uQCJSwQYafvAG0Jn3tJHoxo44dR6vgvxVKVOaW0fOLBL+ R52teRxN088JA+YtcVieJqu60BTguy+1XyCc8VCmO4eeUyfsXeMzWQQZPkOqdy5C6dSL pRgQxpN5IB/2h7l4gP9xiIFGEaZQSKIJM3eWfBC5CPuLPu9VV7lz+06whihqELw3O3Ik 71vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JZCDQ5Ir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 38-v6si2628729qtg.165.2018.06.09.20.48.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JZCDQ5Ir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrKp-0000e1-V5 for patch@linaro.org; Sat, 09 Jun 2018 23:48:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeW-0003B8-4V for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeU-0003lh-65 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:23 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeT-0003lT-Ua for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:22 -0400 Received: by mail-pf0-x244.google.com with SMTP id a63-v6so8499317pfl.1 for ; Sat, 09 Jun 2018 20:04: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=r/JZ9Kq3fbaGkjGRdS3WOr/GkHVFl9LVGQIvJBANdVs=; b=JZCDQ5Ir18RhlWJhqKYGxFrrVMyzrfnMqLXnbvFnsda+2f3QJuB4DqINggZlnOe6z+ gLhZ1a36CnsxtZAxyyNUByUWKe1ciTQXK9w3eyyQB87cCg9HWY+A+9vGSnTUCz+LAsXq UiVKdTCIJkOCbbS0KLCGPfIPRJ2eixEqZyX7Q= 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=r/JZ9Kq3fbaGkjGRdS3WOr/GkHVFl9LVGQIvJBANdVs=; b=S9V7bU7ZJw3Ta5eX9cvv8wHzTbPNrwvB3I66A0BTAk0qczRf4+Wj544vx2XGUlclz7 C00mAQdkWn0Tsl1iem6r93qILgGtyGEtGBBtiEqR43s6reAGUw9rnQ++4jtbPzmHIaWN DVwaAMsli8XLvKUbP7ms9tTPBGxaETRjy+Y7cQZbvDTTorMAVvYaaSgeBnLWXgbMqKyl lXSwnaI8hYGliuovuUNMkzI3i50Ojp8g6GHrG8SIvgHzeGgOuPuJUAKEf+ma4SSir0Ow Q5DPXG2etmRqVzX++3IdbJ+SwKry1BBl+jJq3gEvP8sZ9+APtuSCNLxgZDGsNj7l5vzW NXkQ== X-Gm-Message-State: APt69E1tbK0dVI395TgM4littVNpVQR67rYlxw1ztKQ0B+jRWQheAwxw YxkqYM3RkI3c1xtNOoRWTnUxOKI5fcE= X-Received: by 2002:a63:5ec4:: with SMTP id s187-v6mr10210562pgb.72.1528599860759; Sat, 09 Jun 2018 20:04:20 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:25 -1000 Message-Id: <20180610030220.3777-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 053/108] linux-user: Split out swapoff, sysinfo, vhangup, wait4 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 define swapoff; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 140 +++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 64 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 87374014b1..a0fbbbbb4a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9903,6 +9903,19 @@ IMPL(stime) } #endif +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; +} + IMPL(swapon) { char *p = lock_user_string(arg1); @@ -9959,6 +9972,36 @@ IMPL(syncfs) } #endif +IMPL(sysinfo) +{ + struct sysinfo value; + abi_long ret = get_errno(sysinfo(&value)); + + if (!is_error(ret) && arg1) { + struct target_sysinfo *target_value; + + if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0)) { + return -TARGET_EFAULT; + } + __put_user(value.uptime, &target_value->uptime); + __put_user(value.loads[0], &target_value->loads[0]); + __put_user(value.loads[1], &target_value->loads[1]); + __put_user(value.loads[2], &target_value->loads[2]); + __put_user(value.totalram, &target_value->totalram); + __put_user(value.freeram, &target_value->freeram); + __put_user(value.sharedram, &target_value->sharedram); + __put_user(value.bufferram, &target_value->bufferram); + __put_user(value.totalswap, &target_value->totalswap); + __put_user(value.freeswap, &target_value->freeswap); + __put_user(value.procs, &target_value->procs); + __put_user(value.totalhigh, &target_value->totalhigh); + __put_user(value.freehigh, &target_value->freehigh); + __put_user(value.mem_unit, &target_value->mem_unit); + unlock_user_struct(target_value, arg1, 1); + } + return ret; +} + IMPL(syslog) { abi_long ret; @@ -10156,6 +10199,35 @@ IMPL(utimes) } #endif +IMPL(vhangup) +{ + return get_errno(vhangup()); +} + +IMPL(wait4) +{ + int status; + struct rusage rusage; + abi_long ret; + + ret = get_errno(safe_wait4(arg1, &status, arg3, &rusage)); + if (!is_error(ret)) { + if (ret && arg2) { + status = host_to_target_waitstatus(status); + if (put_user_s32(status, arg2)) { + return -TARGET_EFAULT; + } + } + if (arg4) { + abi_long err = host_to_target_rusage(arg4, &rusage); + if (err) { + return err; + } + } + } + return ret; +} + IMPL(waitid) { siginfo_t info; @@ -10228,70 +10300,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_vhangup: - return get_errno(vhangup()); - 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))) - return -TARGET_EFAULT; - ret = get_errno(swapoff(p)); - unlock_user(p, arg1, 0); - return ret; -#endif - case TARGET_NR_sysinfo: - { - struct target_sysinfo *target_value; - struct sysinfo value; - ret = get_errno(sysinfo(&value)); - if (!is_error(ret) && arg1) - { - if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0)) - return -TARGET_EFAULT; - __put_user(value.uptime, &target_value->uptime); - __put_user(value.loads[0], &target_value->loads[0]); - __put_user(value.loads[1], &target_value->loads[1]); - __put_user(value.loads[2], &target_value->loads[2]); - __put_user(value.totalram, &target_value->totalram); - __put_user(value.freeram, &target_value->freeram); - __put_user(value.sharedram, &target_value->sharedram); - __put_user(value.bufferram, &target_value->bufferram); - __put_user(value.totalswap, &target_value->totalswap); - __put_user(value.freeswap, &target_value->freeswap); - __put_user(value.procs, &target_value->procs); - __put_user(value.totalhigh, &target_value->totalhigh); - __put_user(value.freehigh, &target_value->freehigh); - __put_user(value.mem_unit, &target_value->mem_unit); - unlock_user_struct(target_value, arg1, 1); - } - } - return ret; #ifdef TARGET_NR_ipc case TARGET_NR_ipc: return do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); @@ -13100,6 +13108,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_stime SYSCALL(stime); #endif + SYSCALL(swapoff); SYSCALL(swapon); #ifdef TARGET_NR_symlink SYSCALL(symlink); @@ -13109,6 +13118,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_SYNCFS SYSCALL(syncfs); #endif + SYSCALL(sysinfo); SYSCALL(syslog); #ifdef TARGET_NR_time SYSCALL(time); @@ -13130,6 +13140,8 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_utimes SYSCALL(utimes); #endif + SYSCALL(vhangup); + SYSCALL(wait4); SYSCALL(waitid); #ifdef TARGET_NR_waitpid SYSCALL(waitpid); From patchwork Sun Jun 10 03:01:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138134 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2597614lji; Sat, 9 Jun 2018 20:46:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtCX5OtiLmWTqwKi1eQxSIal5JlXGIeItRYTlE0HP87YLrpLcP+bjE4/3zEJIXebdSYKSB X-Received: by 2002:a37:a241:: with SMTP id l62-v6mr10296399qke.329.1528602366676; Sat, 09 Jun 2018 20:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602366; cv=none; d=google.com; s=arc-20160816; b=nXs+pxwEGC1DjVwBCN2UQzyyDKEGW2UAJGdIoSh92ovqCuAvGEPbfECRui9349vKA2 AjQYz27BvoL4exVOayUhPUr2uadZ8xEs8me21wGT3y+um1EHOsYoGbAvNFhg7mYn6YiL nx/so6rGMQL4TeDzXadXyowb3i0jCKSdU2szDicX0QmyvP/dV5JukTgLmRGsYOjwc0jS KO8nw1ypROc7i0XXhMRv3hObZJB3KU4M0r3J1cZQ2ZD7MtV/uvBGG5+txLaYe8jo3zXg PseVx1kLFOEnk7Hji+3ocXwZXWNmWZylCcwFPMYmv5x9cvoCtHdQnY8lo0UwJ8vL/LZs ae7Q== 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:arc-authentication-results; bh=qLsfi8GrsvhESP+qp9nMm079y5R91LfHICSUFAzSBXg=; b=TvvHNJrJ2BtoFC4eKIl9JzvJfKK2kAIt1yANGzpPzieQuJYm44fE/JBIiSZMQxQLSf 4ABTVM06tq60cKLt6oPAq/ZNGnVALEU/h5EEvuCECqouwOU7zBqgmm17dsgxliBBclix +E73donFsBE9bh4zzqdLkwYpsMMLw+wEuofVuuN5TI9tHm3jjJto5cGvY9tFMhqk547G voOSBbV1VOWPIsl28XExXrEo+W5VTJ5qrt93ViPTXevbV1s7gX6OZ2hew0gfG/8jpoQM fEOZthrMYGNVva8D4iR/fUdzEykNsFqpkFNc/PHYiVGAc4qPy5BLHq1ywJjGLWYzmfIA U4OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kTSLoGNi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k97-v6si1952182qte.98.2018.06.09.20.46.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:46:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kTSLoGNi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrIs-0007qI-3q for patch@linaro.org; Sat, 09 Jun 2018 23:46:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeY-0003Co-KX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeX-0003mR-9I for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:26 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:41584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeX-0003mG-1O for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:25 -0400 Received: by mail-pl0-x241.google.com with SMTP id az12-v6so10380409plb.8 for ; Sat, 09 Jun 2018 20:04: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=qLsfi8GrsvhESP+qp9nMm079y5R91LfHICSUFAzSBXg=; b=kTSLoGNiAj8VXkOcCMrDQwGe4N96FkdHh8Y3nImVYIioAZt6C0GyvSfPsv5B9pinav wooxe9tyvf1+niK0hsrGTzwsJVnBfhyOp87NugWQ09rubQcvmSHQsAhALf8nGtRi/z+O Ev2qfhY3Drs6yUUVMxdyiqzJIERL2nges21GQ= 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=qLsfi8GrsvhESP+qp9nMm079y5R91LfHICSUFAzSBXg=; b=lkMt0tSQk9tCVQYrLrqhRvI/Jx2gOFOM9cBflDidirC527eTK40mdlfK2rSR6ZP/2p XafMryHoyqGKYozRD+7O3ZaBQStlTC2a54lWqxMCQesaPltX76DlNT3XO77bnyFqKO9Q RLyMf8MXN7jL9pluGyK3QF4oIdXEE7cpVW+2wA1HI6/ZMRG9H4AyYwz9e9wDLEmneFYI WXMIMMX9yMfen5xKy5SN8gL/KIhs88q7fXCNkI8mhBzHYXzDXjMtyuryBjMGNmxB26Kp b3x7RhU2nGln/WRpkbuAvT1AQg9TenJtz0UiE10fZ0m1KEwPHTJ96yJUIIoOaZcE0EQn rSrA== X-Gm-Message-State: APt69E2dMC8MxhdDEJcxt7saO4OYc6/lUzHqaI6C3DM/X4P0qoWfOyXs DB/bbeg2RgTesL5JDsiJ+SJYpUzmg5g= X-Received: by 2002:a17:902:760e:: with SMTP id k14-v6mr12931152pll.310.1528599863759; Sat, 09 Jun 2018 20:04:23 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:26 -1000 Message-Id: <20180610030220.3777-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 054/108] linux-user: Split out ipc 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" At the same time, merge do_ipc into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 193 ++++++++++++++++++------------------------- 1 file changed, 82 insertions(+), 111 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a0fbbbbb4a..6ac7532ea6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4962,113 +4962,6 @@ static inline abi_long do_shmdt(abi_ulong shmaddr) 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, @@ -8425,6 +8318,85 @@ IMPL(ioctl) return ret; } +#ifdef TARGET_NR_ipc +IMPL(ipc) +{ + unsigned int call = arg1; + abi_long first = arg2; + abi_long second = arg3; + abi_long third = arg4; + abi_long ptr = arg5; + abi_long fifth = arg6; + int version; + abi_long ret; + abi_ulong atptr; + + version = call >> 16; + call &= 0xffff; + + /* IPC_* and SHM_* command values are the same on all linux platforms */ + switch (call) { + case IPCOP_semop: + return do_semop(first, ptr, second); + case IPCOP_semget: + return get_errno(semget(first, second, third)); + case IPCOP_semctl: + /* The semun argument to semctl is passed by value, + * so dereference the ptr argument. + */ + get_user_ual(atptr, ptr); + return do_semctl(first, second, third, atptr); + + case IPCOP_msgget: + return get_errno(msgget(first, second)); + case IPCOP_msgsnd: + return do_msgsnd(first, ptr, second, third); + case IPCOP_msgctl: + return do_msgctl(first, second, ptr); + 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)) { + return -TARGET_EFAULT; + } + + ret = do_msgrcv(first, tswapal(tmp->msgp), second, + tswapal(tmp->msgtyp), third); + unlock_user_struct(tmp, ptr, 0); + return ret; + } + return do_msgrcv(first, ptr, second, fifth, third); + + case IPCOP_shmat: + if (version == 1) { + return -TARGET_EINVAL; + } + ret = do_shmat(cpu_env, first, ptr, second); + if (is_error(ret)) { + return get_errno(ret); + } + if (put_user_ual(ret, third)) { + return -TARGET_EFAULT; + } + return ret; + case IPCOP_shmdt: + return do_shmdt(ptr); + case IPCOP_shmget: + return get_errno(shmget(first, second, third)); + case IPCOP_shmctl: + return do_shmctl(first, second, ptr); + + default: + gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); + return -TARGET_ENOSYS; + } +} +#endif + IMPL(kill) { return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); @@ -10300,10 +10272,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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)); @@ -12941,6 +12909,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getxpid); #endif SYSCALL(ioctl); +#ifdef TARGET_NR_ipc + SYSCALL(ipc); +#endif SYSCALL(kill); #ifdef TARGET_NR_link SYSCALL(link); From patchwork Sun Jun 10 03:01:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138135 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2597857lji; Sat, 9 Jun 2018 20:46:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKmwufAnaB1crmV/qNVsSM94dvwcC8tpw6l/Uaw/zAphHTbzFVc1axBzDRjYG5FFRJcD7F0 X-Received: by 2002:ac8:1af0:: with SMTP id h45-v6mr11028799qtk.16.1528602396560; Sat, 09 Jun 2018 20:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602396; cv=none; d=google.com; s=arc-20160816; b=md6rdyjB9BshxqmdF1uPC/7KCbm4q/BaSBi8cNVFNnCZUcMPBIq8tnrWeWlgIMPESw pi88nepp0xvuQjyC2ScSo/wOgFc57PWXVbDzzYcS6N6anGV3wTB+ajam4VeWAX3RvrhK 8RiXvGJbY95Kra7QFSBtDG7dlAu4BP/4u2zINlobQXBBP/GnyKver2/2xNQzEGYX3KWK WzxJGAmGi7ff5RSAPh5jrEjcE+UNChoXI1F0VVyzfYrqzSLYs8WlAvJnu0xkW6yin4Wo yXDO96U2/ROfl2imKzyuLzPqd5WYk34A+HWn3QcFM2rzFRKz7E8kcvdbCaH0GkeGZDAS Mu4w== 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:arc-authentication-results; bh=yikHZIxzjoyUKNQPQDvJAn42HOCHs6MNr67IyjVvUqY=; b=hr9aOsuXQACmJHg15KjKhjwhWMmoQa8oCtm0ztJUtQL+BR2OZGrRntB3bwlxU/KuiW lBs+IfD0fH4DKqgmtSUjkrgSnmVl/ps7FGn55v4MPJOV17F0b873PK5/Zd+p3NyvsoOu 0FwJqSEvwZ2klwEcDb/FDjw4NZaVRSmeGG5AFtI//sI56mCE6hS42/x49Ud8vgN7Opkh ol+Oj3WhSpYBxT/Y3ybIB/GhU+BiiDb5mJNTwrWJPqLHghO15EZY8lBHSBiXxeGoYmGL j5wp4o/987HdfuZBmGGoSBex6dnlabfYsj6qoPemxp/Pb2euoTh1phzsnGeDJeYiuWcI FExQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PUYCTjPD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e48-v6si1501356qtc.270.2018.06.09.20.46.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:46:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PUYCTjPD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrJM-0007u1-0l for patch@linaro.org; Sat, 09 Jun 2018 23:46:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqec-0003Gr-Dm for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeZ-0003nS-89 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:30 -0400 Received: from mail-pl0-x230.google.com ([2607:f8b0:400e:c01::230]:36985) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeY-0003n7-W9 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:27 -0400 Received: by mail-pl0-x230.google.com with SMTP id 31-v6so10386055plc.4 for ; Sat, 09 Jun 2018 20:04: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=yikHZIxzjoyUKNQPQDvJAn42HOCHs6MNr67IyjVvUqY=; b=PUYCTjPDe1gxey5HhE26Q6sJQohyc3bPl648Tu78nwV6DshiH6fiQNTmGdR73vLXox bu0hph8oGnCZoIq8HwzgW1WMhrhjJBbPS87JyYxv4yYvaBndLyus7UbE/oaHvf8A9OYj LRNaHFaMU93ZN2+MIR66vhpyX7cszI0P50gR4= 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=yikHZIxzjoyUKNQPQDvJAn42HOCHs6MNr67IyjVvUqY=; b=cVPqLP/Ce+qiIdsgbhxx9V+dky5Khwe3RyUDncpi5kp6sWsbeZpsV1DW88zFKvcebZ TKxvqrf1Q18vMYsIWSNv+HVO1iF8l3An274RwYLrcJuGwNkxV9tQMzhavecvh+qJjTPf DaeupUBlIbJaRFTeXOhfqgTCQ0W2VZ1oGQ/iXB47806T3d4K49pmpO2rSncXgFMDjMh8 VvIE71fBCQ9LiQwv7ULtHNmQgUqtpgyuG5cznZHmXnq7OO7Ov11kk4PuwChloZ2qXYd5 pmGu0RC9POIztd/DJxHc+y4ggkazNsX/0uZiYmNXCvgLHXjpCZ5sjeOQxBSamQuOZleN UvVg== X-Gm-Message-State: APt69E3c0yC5c9O54wBk1pFekBaZx8+XnXG9n5uglmxFV4XlXG5sfLUo JJ0ZR1WB5xBClMLx9DH+TWw7sdnQs98= X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr12844630plb.74.1528599865684; Sat, 09 Jun 2018 20:04:25 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:27 -1000 Message-Id: <20180610030220.3777-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::230 Subject: [Qemu-devel] [PATCH v2 055/108] 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" This is msgctl, msgget, msgrcv, msgsnd, shmat, shmctl, shmdt, shmget, semctl, semget, semop. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 154 ++++++++++++++++++++++++++++++------------- 1 file changed, 110 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6ac7532ea6..1c3a4590fb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8636,6 +8636,34 @@ IMPL(mremap) return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); } +#ifdef TARGET_NR_msgctl +IMPL(msgctl) +{ + return do_msgctl(arg1, arg2, arg3); +} +#endif + +#ifdef TARGET_NR_msgget +IMPL(msgget) +{ + return get_errno(msgget(arg1, arg2)); +} +#endif + +#ifdef TARGET_NR_msgrcv +IMPL(msgrcv) +{ + return do_msgrcv(arg1, arg2, arg3, arg4, arg5); +} +#endif + +#ifdef TARGET_NR_msgsnd +IMPL(msgsnd) +{ + return do_msgsnd(arg1, arg2, arg3, arg4); +} +#endif + IMPL(msync) { return get_errno(msync(g2h(arg1), arg2, arg3)); @@ -9340,6 +9368,34 @@ IMPL(sgetmask) } #endif +#ifdef TARGET_NR_shmat +IMPL(shmat) +{ + return do_shmat(cpu_env, arg1, arg2, arg3); +} +#endif + +#ifdef TARGET_NR_shmctl +IMPL(shmctl) +{ + return do_shmctl(arg1, arg2, arg3); +} +#endif + +#ifdef TARGET_NR_shmdt +IMPL(shmdt) +{ + return do_shmdt(arg1); +} +#endif + +#ifdef TARGET_NR_shmget +IMPL(shmget) +{ + return get_errno(shmget(arg1, arg2, arg3)); +} +#endif + #ifdef TARGET_NR_shutdown IMPL(shutdown) { @@ -9358,6 +9414,27 @@ IMPL(select) } #endif +#ifdef TARGET_NR_semctl +IMPL(semctl) +{ + return do_semctl(arg1, arg2, arg3, arg4); +} +#endif + +#ifdef TARGET_NR_semget +IMPL(semget) +{ + return get_errno(semget(arg1, arg2, arg3)); +} +#endif + +#ifdef TARGET_NR_semop +IMPL(semop) +{ + return do_semop(arg1, arg2, arg3); +} +#endif + #ifdef TARGET_NR_send IMPL(send) { @@ -10272,50 +10349,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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: @@ -12943,6 +12976,18 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mount); SYSCALL(mprotect); SYSCALL(mremap); +#ifdef TARGET_NR_msgctl + SYSCALL(msgctl); +#endif +#ifdef TARGET_NR_msgget + SYSCALL(msgget); +#endif +#ifdef TARGET_NR_msgrcv + SYSCALL(msgrcv); +#endif +#ifdef TARGET_NR_msgsnd + SYSCALL(msgsnd); +#endif SYSCALL(msync); SYSCALL(munlock); SYSCALL(munlockall); @@ -13010,6 +13055,18 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); #endif +#ifdef TARGET_NR_shmat + SYSCALL(shmat); +#endif +#ifdef TARGET_NR_shmctl + SYSCALL(shmctl); +#endif +#ifdef TARGET_NR_shmdt + SYSCALL(shmdt); +#endif +#ifdef TARGET_NR_shmget + SYSCALL(shmget); +#endif #ifdef TARGET_NR_shutdown SYSCALL(shutdown); #endif @@ -13020,6 +13077,15 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(select); # endif #endif +#ifdef TARGET_NR_semctl + SYSCALL(semctl); +#endif +#ifdef TARGET_NR_semget + SYSCALL(semget); +#endif +#ifdef TARGET_NR_semop + SYSCALL(semop); +#endif #ifdef TARGET_NR_send SYSCALL(send); #endif From patchwork Sun Jun 10 03:01:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138141 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600151lji; Sat, 9 Jun 2018 20:51:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ+aSsWYpLw80NwpLHr6tx+L4mCBCTdVxI8Iw8Jd5ei3EkDpehFmyHamscDG8pKBcDqWe/B X-Received: by 2002:ac8:720f:: with SMTP id a15-v6mr11080180qtp.243.1528602661578; Sat, 09 Jun 2018 20:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602661; cv=none; d=google.com; s=arc-20160816; b=S8XOKqS4S/9sr0gX1zuhlLuNRFHENtq2IlFW6wcsfbyePKR/rmHhC03kH5VnY+dp1x RzAmQ5+STNAFiOBJb0h1D21qbaqmG7uYSmzT6B3WlYTJ1zG7GMP9dgN7mZZfL/mZxfCX gwF/UozA7re31cLjqbCtbKWwbsOufSlZh/DUWqS2KdW3sZPQlXcresz8EsvHWtFUUb1O IgRKVK/Td2qq5puUey/GZblN+FEZI1UO5DiqI2R6rTPhW4XEam5b6f4mMRY9droGcBlH aQY4TVHqJpdfA1kBO0/yVuZ6ONxgZnQReZVdkG3S+V4oOimG3w5Hi6DUa8kKoZjUebyi bxuQ== 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:arc-authentication-results; bh=KDrYlD4y0ZQb7noKMHlGiVzA+1uZZIv4M/OeCZr0M8s=; b=SEfACAwJqJEod2DZCioS4kGSRsN3rjieTfbM+aHZuP+6kkbhyh+yFbTb0w/D4T5xJQ p8NwLig/RsMdFTRR6ZBRu28TTybKcdZlnAdpTE0QRILFGW1AKRdrQKraGhJ5u9RfZGSn xxRHmq7wHH+0UwKOu2xyIlxK3MWOIR2GXg58r5/1IVfwydzmZchXipyzYW+jFkvUsc5V u7kHpSQ3RHtNiyU3jB8nRROWUenR/DbE5ZqhX48jdZxdatWz2dXIj8v8y/NLRDcZwpI1 SL+XGrBnVqTRGId03pXNzn2Turwca9C+bAe/2kjPhvMCBX7LBsm/HoOKdmzQclAS+oJ6 6Jvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q22TzBzd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h19-v6si5740640qta.374.2018.06.09.20.51.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:51:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q22TzBzd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrNc-0003wL-SJ for patch@linaro.org; Sat, 09 Jun 2018 23:51:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqec-0003H5-Lc for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeb-0003nx-C8 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:30 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:38928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeb-0003nr-6F for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:29 -0400 Received: by mail-pg0-x242.google.com with SMTP id w12-v6so8139290pgc.6 for ; Sat, 09 Jun 2018 20:04:29 -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=KDrYlD4y0ZQb7noKMHlGiVzA+1uZZIv4M/OeCZr0M8s=; b=Q22TzBzdaQc/099X4/z8ZuNj+SracIyGSylMzx5IkVJvM8MN6g21jeaeMq0z/245xd wdx+f24Z7xAG5CbGHkOM6lYfMSKC41W6kfkADkMwHvH6CMg1IeV6LhzR941/wK5lwYga 1fNeQDIVrExuQDavuLTG0/lIYFeOY8uT8nuO0= 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=KDrYlD4y0ZQb7noKMHlGiVzA+1uZZIv4M/OeCZr0M8s=; b=DJvj9ID5gwUMkWOckn6kQdhUuHUTmt126sq57Onq6CUIyyc7DT7TxSEAIIYyF1N9zo gxrfpoSOEy9mEwk8kD0+FWvZMKhs9EBXAmNzv48O2NXUWelfvqlNqy1XTPPx/R+9I/eC KrfHv6GLuNFmkuKQD8h0bCLraa6Fxf7hkQLbgCbQ7gYppUZP3ZWpuEVe6OuJGHUQc/O3 SNNHSYvF0grC5beJCmF1nF6AEiu1OfapVO/rBLJ7jHTIF6Yr1LgehADmDIjAJbI5Yhuk vcBh5e7Ip6f06Qi7hxpqGjWfUrjcep2QOQVmqj9ImOEa/d7VpE5YldnSRFnh+BNxqDVN 9ppA== X-Gm-Message-State: APt69E27nXA3gWZufKqu5mvjT470wJYSXDPOHm49iaiV03hDcS25W/hz YQX5ICgVpH1EUWKYXW6eNpnHWWx7GNg= X-Received: by 2002:a63:3641:: with SMTP id d62-v6mr10186086pga.18.1528599868055; Sat, 09 Jun 2018 20:04:28 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:28 -1000 Message-Id: <20180610030220.3777-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 056/108] linux-user: Split out clone, exit_group, fsync 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 | 70 ++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 28 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1c3a4590fb..41facf4b44 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7753,6 +7753,25 @@ IMPL(chroot) return ret; } +IMPL(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) + return get_errno(do_fork(cpu_env, arg1, arg2, arg4, arg6, arg5)); +#elif defined(TARGET_CLONE_BACKWARDS) + return get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); +#elif defined(TARGET_CLONE_BACKWARDS2) + return get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg5, arg4)); +#else + return get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); +#endif +} + IMPL(close) { fd_trans_unregister(arg1); @@ -7973,6 +7992,17 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef __NR_exit_group +IMPL(exit_group) +{ +# ifdef TARGET_GPROF + _mcleanup(); +# endif + gdb_exit(cpu_env, arg1); + return get_errno(exit_group(arg1)); +} +#endif + IMPL(faccessat) { char *p = lock_user_string(arg2); @@ -8056,6 +8086,11 @@ IMPL(fstatfs64) } #endif +IMPL(fsync) +{ + return get_errno(fsync(arg1)); +} + IMPL(ftruncate) { return get_errno(ftruncate(arg1, arg2)); @@ -10349,34 +10384,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - 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: -#ifdef TARGET_GPROF - _mcleanup(); -#endif - gdb_exit(cpu_env, arg1); - return get_errno(exit_group(arg1)); -#endif case TARGET_NR_setdomainname: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; @@ -12877,6 +12884,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(bind); #endif SYSCALL(brk); + SYSCALL(clone); SYSCALL(close); SYSCALL(chdir); SYSCALL(chroot); @@ -12896,6 +12904,11 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(dup3); SYSCALL(execve); SYSCALL(exit); +#ifdef __NR_exit_group + SYSCALL(exit_group); +#else + SYSCALL_WITH(exit_group, enosys); +#endif SYSCALL(faccessat); SYSCALL(fchmod); SYSCALL(fchmodat); @@ -12910,6 +12923,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_fstatfs64 SYSCALL(fstatfs64); #endif + SYSCALL(fsync); SYSCALL(ftruncate); #ifdef TARGET_NR_futimesat SYSCALL(futimesat); From patchwork Sun Jun 10 03:01:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138142 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600577lji; Sat, 9 Jun 2018 20:51:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZk01TJEaRayhkRr6qRf3jItmCdv3zWA6GoLgZTYQ/3d+dEb2GO2Cq9/vOTTc0N0a7d9lD X-Received: by 2002:a37:a047:: with SMTP id j68-v6mr10342193qke.126.1528602707552; Sat, 09 Jun 2018 20:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602707; cv=none; d=google.com; s=arc-20160816; b=MQziWhx4gKJUcoMuWT8Xwbq/J13krFV56l8Pe+7sHkoa7O2DPC7wMieg2RFeLh8Xxd QnCKW4w0wVEsIgVt+e52JD9sImW2YeEQYuzhUPizalxH06gFy1WG1VtwlEnvetv+ER1z TdBuwyzGycx8xCTf3KyJPj7ZPgcmA4q2GyVnND0/FkDyE7r3ksFz0DJjdiRuStrcmrz+ mQTzywI0L8AXubyMpsFhkr6BC5NYWxo3To3N39bQk9HqNDelaoZ1Gw5GZzlX6tPsgBp5 gfFUEal5pb1uZt7PcJahN7ZWKYl8SCzj0fgoLuiATaudn6E/IpBPPNu0slfn8Oq62KPx mEsg== 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:arc-authentication-results; bh=WGFHAB/vN3arsGutgbAc0x4zLYG2uK6T4yTo+ScdTdc=; b=he/v5iHniCeOac7sLKXRPHQDFJLCUelBaCJZoDMO2ub/DGCdovPhXGG7VEn4dTqbDO hj9yfTL4vx1UXFxcRilrd0N5v0bzvt7AHYjG/dMKgoCg1GDq6ThDW5lkR75Kb9Jjl7Wu /9b9BOqPFKciXwRN0UAWv+IaDPhOaZEfeoZWCxiWmdGS388V7wU+iAthJ5GKcoHrdAiE DXe5NJMhxJ6t3/mlD/tj4XM8gAxP4YuK4zn+BAxypWbdroSP2Vu2NRQ/+3D10MWaWiis FHxeRoGsAVxkF/+IrmIIZk7V4anQtC1099FtqMuL9PBbyBI8NeBPv/Zk/UMvoUXRUjH7 +xMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HffRWYCj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i67-v6si1635582qkb.226.2018.06.09.20.51.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:51:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HffRWYCj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrOM-0004tH-W2 for patch@linaro.org; Sat, 09 Jun 2018 23:51:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqee-0003JH-QT for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqed-0003od-GC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:32 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:45642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqed-0003oP-8E for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:31 -0400 Received: by mail-pf0-x241.google.com with SMTP id a22-v6so8480163pfo.12 for ; Sat, 09 Jun 2018 20:04: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=WGFHAB/vN3arsGutgbAc0x4zLYG2uK6T4yTo+ScdTdc=; b=HffRWYCjauKm47jwJiZRG2iqmWw8klx401UxwXB+6bGJQKgnn07qrH+a2woKp1FGM8 WkLsPAjVip+UW3d+B7p+71827XqqW2z1JsucE5T65ew8HbeM2907ALpV2hPOiRQXVKON WazQjuInbSGCZdcXpzF1XkyvH7A38Z/roBaeM= 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=WGFHAB/vN3arsGutgbAc0x4zLYG2uK6T4yTo+ScdTdc=; b=VanjlvZ2p7E0YQJMu4U5XkGpZYAjFCOjKi41ir2IVo27yM4g5fyoGjBYsfbwivbSjp 2WVzhZqkjB7lBnQeKKSIhnAHUPIHy2UFvML8VZoP6ucmKWcrg6uWOJEd1adluJX8Aobs iKbur2Xx9Nh/oJ0bSlP4BODQsGThMvRNiv2pVv+Be7n9p4OUrFZwyDgG1bghlV2SzvqQ Y2eonEdTKOqWIhzgGXaCr2WN2HKYwaz8O6GrPz+5+6ym2YQHZLdtk848iibHcrRbSTpl w3yGOxyqxCYTU8XtduNG2a2JMYOUrytgrE4myyLOY3xUhrzOG3idnSbgBVRXInG8qQQB U70w== X-Gm-Message-State: APt69E2ZgrOKKXwey6zof4VYs703gxlvOKhkugTT7jNacdgNd0pKeuWm 7XIe6ZylFleyizTI+YSbxJING7EBu5I= X-Received: by 2002:a65:494b:: with SMTP id q11-v6mr10610467pgs.105.1528599870031; Sat, 09 Jun 2018 20:04:30 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:29 -1000 Message-Id: <20180610030220.3777-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 057/108] linux-user: Split out modify_ldt, setdomainname, uname 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" At the same time, merge do_modify_ldt into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 123 +++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 57 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 41facf4b44..4967b84f21 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5755,7 +5755,6 @@ static bitmask_transtbl mmap_flags_tbl[] = { }; #if defined(TARGET_I386) - /* NOTE: there is really one LDT for all the threads */ static uint8_t *ldt_table; @@ -5870,29 +5869,6 @@ install: return 0; } -/* specific and weird i386 syscalls */ -static abi_long do_modify_ldt(CPUX86State *env, int func, abi_ulong ptr, - unsigned long bytecount) -{ - abi_long ret; - - switch (func) { - case 0: - ret = read_ldt(ptr, bytecount); - break; - case 1: - ret = write_ldt(env, ptr, bytecount, 1); - break; - case 0x11: - ret = write_ldt(env, ptr, bytecount, 0); - break; - default: - ret = -TARGET_ENOSYS; - break; - } - return ret; -} - #if defined(TARGET_I386) && defined(TARGET_ABI32) abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr) { @@ -8614,6 +8590,28 @@ IMPL(mmap2) } #endif +#ifdef TARGET_I386 +/* ??? Other TARGET_NR_modify_ldt should be deleted. */ +IMPL(modify_ldt) +{ + CPUX86State *env = cpu_env; + int func = arg1; + abi_ulong ptr = arg2; + abi_ulong bytecount = arg3; + + switch (func) { + case 0: + return read_ldt(ptr, bytecount); + case 1: + return write_ldt(env, ptr, bytecount, 1); + case 0x11: + return write_ldt(env, ptr, bytecount, 0); + default: + return -TARGET_ENOSYS; + } +} +#endif + IMPL(mount) { char *p1 = NULL, *p2, *p3 = NULL; @@ -9498,6 +9496,19 @@ IMPL(sendto) } #endif +IMPL(setdomainname) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(setdomainname(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + IMPL(sethostname) { char *p = lock_user_string(arg1); @@ -10206,6 +10217,31 @@ IMPL(umount2) return ret; } +IMPL(uname) +{ + struct new_utsname *buf; + abi_long ret; + + if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0)) { + return -TARGET_EFAULT; + } + /* No need to transcode because we use the linux syscall. */ + ret = get_errno(sys_uname(buf)); + if (!is_error(ret)) { + /* Overwrite the native machine name with whatever is being + emulated. */ + g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env), + sizeof(buf->machine)); + /* Allow the user to override the reported release. */ + if (qemu_uname_release && *qemu_uname_release) { + g_strlcpy(buf->release, qemu_uname_release, + sizeof(buf->release)); + } + } + unlock_user_struct(buf, arg1, 1); + return ret; +} + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -10384,41 +10420,9 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_setdomainname: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(setdomainname(p, arg2)); - unlock_user(p, arg1, 0); - return ret; - case TARGET_NR_uname: - /* no need to transcode because we use the linux syscall */ - { - struct new_utsname * buf; - - if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0)) - return -TARGET_EFAULT; - ret = get_errno(sys_uname(buf)); - if (!is_error(ret)) { - /* Overwrite the native machine name with whatever is being - emulated. */ - g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env), - sizeof(buf->machine)); - /* Allow the user to override the reported release. */ - if (qemu_uname_release && *qemu_uname_release) { - g_strlcpy(buf->release, qemu_uname_release, - sizeof(buf->release)); - } - } - unlock_user_struct(buf, arg1, 1); - } - return ret; -#ifdef TARGET_I386 - case TARGET_NR_modify_ldt: - return do_modify_ldt(cpu_env, arg1, arg2, arg3); -#if !defined(TARGET_X86_64) +#if defined(TARGET_I386) && !defined(TARGET_X86_64) case TARGET_NR_vm86: return do_vm86(cpu_env, arg1, arg2); -#endif #endif case TARGET_NR_adjtimex: { @@ -12986,6 +12990,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_mmap2 SYSCALL(mmap2); +#endif +#ifdef TARGET_I386 + SYSCALL(modify_ldt); #endif SYSCALL(mount); SYSCALL(mprotect); @@ -13112,6 +13119,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sendto SYSCALL(sendto); #endif + SYSCALL(setdomainname); SYSCALL(sethostname); SYSCALL(setitimer); SYSCALL(setpgid); @@ -13181,6 +13189,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(umount); #endif SYSCALL(umount2); + SYSCALL(uname); #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif From patchwork Sun Jun 10 03:01:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138127 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2594786lji; Sat, 9 Jun 2018 20:40:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLQeR9BIb9xp8sKoyVhZNCXEgUV+oitEPTmSWYtxtvJ/NwlLhuCPZlrNfVBVDO3IwD1JJhN X-Received: by 2002:a0c:d5a6:: with SMTP id g35-v6mr10843763qvi.197.1528602048788; Sat, 09 Jun 2018 20:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602048; cv=none; d=google.com; s=arc-20160816; b=ba6eK3V3qH3Xd82nxRIcmfb5raajiZhh70qHGLtqBZaNZxPAWTm2gGCte9w/4rIrO7 lXhx2urImBss0fXmVvF5b44rfXF5+INNG7aJ3tG3Tb7Ln4g6/akHuoJlJa9zwnVWcqL7 16BOfE0sRBFtE8/fcHJwIdBV7qCcLWOHy2+pJLEL0lSZeZ1wCBm88ZCHGlkB6kk//+Sg KRyiOgIn5lwuQUuVoOuu+fex76Dgs2PuOH0gDdTE/epqdiVB4X+p6xO8GQHO94gAbXO+ A083xhFWc4pqPh0W0da4EYns6tJi0llgGut3w4ZfBCR+O3Ijr+KypRDTDNtmAZTdM43v gZXw== 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:arc-authentication-results; bh=a6qGN8OS/+bW0TBXAGBHrcNC1tMVFe+4yj1F5DXUrHM=; b=mHOX5g/2rJ2xOEy0BXiOG5482en0e4C+kkYEF2txbTujIuzNR8KxIcItoOAmb47cDu F/ul+ebWJQsl5DL8+JTVF3fiWJPuSY5Ggqz0qn4BIpnGwhPXqdZc9eezpBuHkRKoDsM4 mSpv93Vy3diuzKpeiZP4z2SyRlP27nFhY8DZxLjepYjNkRUlaVXS6isKJOZUklg8CA6n 8vy69ujHpKg+DP7h5qbcyk6VCF2Ns2W9AvtPqbUqavVOoLJrTM5wp3124zADxIj0AmBG fmNM7qdz8N3C/wBCTYfE8KbEBYSBfhwyWdrGZ5SBpDFEha1JKmMrJpk2U66lp/P/VjIl JpwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SEcTNx88; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b185-v6si3917833qka.52.2018.06.09.20.40.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:40:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SEcTNx88; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrDk-0002DZ-8v for patch@linaro.org; Sat, 09 Jun 2018 23:40:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeg-0003Kb-32 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqef-0003pF-2Y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:34 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:42384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqee-0003ow-Tw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:33 -0400 Received: by mail-pf0-x241.google.com with SMTP id w7-v6so8478858pfn.9 for ; Sat, 09 Jun 2018 20:04: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=a6qGN8OS/+bW0TBXAGBHrcNC1tMVFe+4yj1F5DXUrHM=; b=SEcTNx886xSA0WemdmPmClKxyJpemMVkJeOpU5rGRPiciu+wHj7bJDeJFvcumty72B o3ACFqYnA1fz9b1kCb7f8Z9vHZWbloYgWVp4Im7L1tP/MdQpIOnLelcGzSiJO98JHvXb hdmzlGMl83ADuGDo/uT+Hpb5zvFkpSq5XV1IM= 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=a6qGN8OS/+bW0TBXAGBHrcNC1tMVFe+4yj1F5DXUrHM=; b=Ehaj7xp24xH01QnpaLBSm1hCTDhGJpV4pe2GYU9HFGk7d1+VNTZ5/tx1bssIVcxWPm GsDDx4c3CXdzJ5HhFeTf7DBHLLUsUSeHS6HjcpQUquBs1eU+UTbPQjIKGeyMnS7W9nh0 DCV4W3iNb01Dy443PBGDQfi0WwLR85YUWVH8uEmkNXUXAs1AE2aFKa7f+3cr6DHCvd1e JhJv5GCwH5luACv76ukf/j/TPIfFHJtkm7K2pPXDxohEjURkHTilF8OKp7ikkCNXCR49 El/pYPa8hrBijxFTucildrLQ5G8petzxvssBmm14giLcb19P/uPEghp13RPaUu5MPwuc q1/Q== X-Gm-Message-State: APt69E2JZZ+/A7wn8AtaTTqLKEYTBqlSJA/WMcA8rgpGp1Kw4yCNVZ/D JJ1f1BYJf+3b6RTmOe7WL7xRn+gcVfw= X-Received: by 2002:a63:721d:: with SMTP id n29-v6mr10169069pgc.194.1528599871722; Sat, 09 Jun 2018 20:04:31 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:30 -1000 Message-Id: <20180610030220.3777-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 058/108] linux-user: Split out adjtimex, clock_adjtime, vm86 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 define clock_adjtime; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 85 +++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 36 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4967b84f21..7ff05dd33c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7669,6 +7669,23 @@ IMPL(acct) } } +IMPL(adjtimex) +{ + struct timex host_buf; + abi_long ret; + + if (target_to_host_timex(&host_buf, arg1) != 0) { + return -TARGET_EFAULT; + } + ret = get_errno(adjtimex(&host_buf)); + if (!is_error(ret)) { + if (host_to_target_timex(arg1, &host_buf) != 0) { + return -TARGET_EFAULT; + } + } + return ret; +} + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -7729,6 +7746,23 @@ IMPL(chroot) return ret; } +#ifdef CONFIG_CLOCK_ADJTIME +IMPL(clock_adjtime) +{ + struct timex htx; + abi_long ret; + + if (target_to_host_timex(&htx, arg2)) { + return -TARGET_EFAULT; + } + ret = get_errno(clock_adjtime(arg1, &htx)); + if (!is_error(ret) && host_to_target_timex(arg2, &htx)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(clone) { /* Linux manages to have three different orderings for its @@ -10324,6 +10358,14 @@ IMPL(vhangup) return get_errno(vhangup()); } +#if defined(TARGET_I386) && !defined(TARGET_X86_64) +/* ??? Other TARGET_NR_vm86 should be deleted. */ +IMPL(vm86) +{ + return do_vm86(cpu_env, arg1, arg2); +} +#endif + IMPL(wait4) { int status; @@ -10420,42 +10462,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_I386) && !defined(TARGET_X86_64) - case TARGET_NR_vm86: - return do_vm86(cpu_env, arg1, arg2); -#endif - case TARGET_NR_adjtimex: - { - struct timex host_buf; - - if (target_to_host_timex(&host_buf, arg1) != 0) { - return -TARGET_EFAULT; - } - ret = get_errno(adjtimex(&host_buf)); - if (!is_error(ret)) { - if (host_to_target_timex(arg1, &host_buf) != 0) { - return -TARGET_EFAULT; - } - } - } - return ret; -#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME) - case TARGET_NR_clock_adjtime: - { - struct timex htx, *phtx = &htx; - - if (target_to_host_timex(phtx, arg2) != 0) { - return -TARGET_EFAULT; - } - ret = get_errno(clock_adjtime(arg1, phtx)); - if (!is_error(ret) && phtx) { - if (host_to_target_timex(arg2, phtx) != 0) { - return -TARGET_EFAULT; - } - } - } - return ret; -#endif case TARGET_NR_getpgid: return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: @@ -12881,6 +12887,7 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(accept4); SYSCALL(acct); + SYSCALL(adjtimex); #ifdef TARGET_NR_alarm SYSCALL(alarm); #endif @@ -12888,6 +12895,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(bind); #endif SYSCALL(brk); +#ifdef CONFIG_CLOCK_ADJTIME + SYSCALL(clock_adjtime); +#endif SYSCALL(clone); SYSCALL(close); SYSCALL(chdir); @@ -13201,6 +13211,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(utimes); #endif SYSCALL(vhangup); +#if defined(TARGET_I386) && !defined(TARGET_X86_64) + SYSCALL(vm86); +#endif SYSCALL(wait4); SYSCALL(waitid); #ifdef TARGET_NR_waitpid From patchwork Sun Jun 10 03:01:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138144 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600873lji; Sat, 9 Jun 2018 20:52:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI6kaToQMgsIojtJd8Fszx2FR8PA4YbBOE9LH1qehhx1z3i8yCD+VWdBldeuWKwQ+YWPQIn X-Received: by 2002:ac8:2384:: with SMTP id q4-v6mr11662403qtq.29.1528602736296; Sat, 09 Jun 2018 20:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602736; cv=none; d=google.com; s=arc-20160816; b=RjV97qcHfELfA2TP7g2RVIN/QQlKvUDKQiVfUT5t+ImreEhls42ZfV7m2Fdh8mtDMy rQhbg9MiKGJ1ZCqYzWbmaGk1TLwbr8xfOK/DjhL0f6V5RBkDZOclviHiqxMphXOk5/Fd KZUnYufiZT4O7S3YeQDIE0M63ZLVDLwia+RlVRDznlDlhtyN+kdZUpPgLbjFEOS3cZzc VdKCWPCeUgIaOWGfkc7gOckwMEBUnP5mp+OkxCrRrkb+5rFdy9MbpIkD84soBDRtmvmb RUAUd+64zQ0xxvtBFXHqXkZl6uS+6d3vgQvCqagdaZzHRbT3ZgPuCN5doBSCsqCPythJ r+IQ== 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:arc-authentication-results; bh=4dqj+cLBsMxzVMwLkE8oWADqdkLghraPxNYeOgC5ufg=; b=Z8Y4vbfMhCKVzbZCLrnoP5nGNtpH90vHwVlboQ/xmx0oiFV+dY2KVE7MMrcoKbjCUz nW/EcAr8vGifjw5PWI/CTwE/35wXRjFr3o7OVHfJ5/zXNtjpr0lG0h4a16fb8CrbASMp z8FNKIp2qzArYMhD2BFdmOWANSDyv05n5J7j0HoSqNl6lsQIeet8p89iW49I5NPFWqfD 9DlUZqlKQ2Av2lGb0PDGM7lfFAcg8LB916InMHfQsM24rXB+7E9sq/8T55ZBFcvQbHYA vNPFtVfIgGsPsnfHcFVTyNqbeLTNqhtKulw4OCG+LqadB0dCDpx2xL5TdFeWebfuRHXa 4dBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OKjNqTd7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c27-v6si4034913qta.261.2018.06.09.20.52.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:52:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OKjNqTd7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrOp-0004x1-MR for patch@linaro.org; Sat, 09 Jun 2018 23:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqel-0003Q2-DF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqei-0003rE-7C for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:39 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:46988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeh-0003r9-Vy for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:36 -0400 Received: by mail-pf0-x244.google.com with SMTP id q1-v6so8483019pff.13 for ; Sat, 09 Jun 2018 20:04: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=4dqj+cLBsMxzVMwLkE8oWADqdkLghraPxNYeOgC5ufg=; b=OKjNqTd7RClSHDWfITBXxP/QANsVEglOZvpgZl0bnPheISXDYccqMRgwlZ65gNm31T tNfeTmye1frDmMbbkeNX9CPzQ/WNJiQQBLNkIGYkjg6twOJbG1mBDP0etOGBH+L3Z/IV 1rnT7U18H4PMNLPRLu1PzhgmIBPxE1SViFfB4= 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=4dqj+cLBsMxzVMwLkE8oWADqdkLghraPxNYeOgC5ufg=; b=iZ4iztoFAYMd54CKF5aKVRBhU79/gyBGFi4x3YtLGfvRtc5KA9NbW+Sz0RQCdz88AF P3dRYoRAB8/29xMndRoftPWSA4D3cw5/YRIbBEh4ZZ4OUnftOz26ZYiwUd7VbEGIT8za zeEiUW2ca4urWW90tez+emQeBmHx5/w/6/CeEpagJjMtugsbIWxoARKIy28yxyGwU1jo Gxe+hQeayceBkhd64e3z/Cg5+PUCIw6gXslvs5qnUV7zbbbtMPLtGusvZZ2lDmDnpvNQ 1B9XBS90aJQzMOApII/dktSA5Fpc6IzFsMj0CUKQZWqeavrwVxr8SNd7NTw0gVRPtByZ eDUw== X-Gm-Message-State: APt69E3ZVb/ALrh1MfsAK2sL3JqENWbHpMIl4tsz1NkmQubqrNGioww7 rFCQ1o15xI61ItcVjEeNfbSy2CzwfDE= X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr12038833pfx.246.1528599874790; Sat, 09 Jun 2018 20:04:34 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:31 -1000 Message-Id: <20180610030220.3777-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 059/108] linux-user: Split out fchdir, getpgid, llseek, personality 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" Given that we use _LARGEFILE_SOURCE and _FILEOFFSET_BITS == 64, there is no need to special-case llseek on the host side; always use lseek. Define _llseek in terms of llseek, rather than the other way around. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 81 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 39 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7ff05dd33c..f5f21658a8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -240,15 +240,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_inotify_add_watch __NR_inotify_add_watch #define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch -#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__) -#define __NR__llseek __NR_lseek -#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 -#endif - /* These definitions produce an ENOSYS from the host kernel. * Performing a bogus syscall is lazier than boilerplating * the replacement functions here in C. @@ -280,10 +271,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) @@ -8026,6 +8013,11 @@ IMPL(faccessat) return ret; } +IMPL(fchdir) +{ + return get_errno(fchdir(arg1)); +} + IMPL(fchmod) { return get_errno(fchmod(arg1, arg2)); @@ -8150,6 +8142,11 @@ IMPL(getpeername) } #endif +IMPL(getpgid) +{ + return get_errno(getpgid(arg1)); +} + #ifdef TARGET_NR_getpgrp IMPL(getpgrp) { @@ -8484,6 +8481,27 @@ IMPL(listen) } #endif +/* Older kernel ports have _llseek() instead of llseek() */ +#if defined(TARGET_NR__llseek) && !defined(TARGET_NR_llseek) +#define TARGET_NR_llseek TARGET_NR__llseek +#endif + +#ifdef TARGET_NR_llseek +IMPL(llseek) +{ + off_t res; + + res = lseek(arg1, ((uint64_t)arg2 << 32) | (abi_ulong)arg3, arg5); + if (res == -1) { + return -host_to_target_errno(errno); + } + if (put_user_s64(res, arg4)) { + return -TARGET_EFAULT; + } + return 0; +} +#endif + IMPL(lseek) { return get_errno(lseek(arg1, arg2, arg3)); @@ -8901,6 +8919,11 @@ IMPL(pause) } #endif +IMPL(personality) +{ + return get_errno(personality(arg1)); +} + #ifdef TARGET_NR_pipe IMPL(pipe) { @@ -10462,32 +10485,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_getpgid: - return get_errno(getpgid(arg1)); - case TARGET_NR_fchdir: - 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 @@ -12924,6 +12921,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL_WITH(exit_group, enosys); #endif SYSCALL(faccessat); + SYSCALL(fchdir); SYSCALL(fchmod); SYSCALL(fchmodat); #ifdef TARGET_NR_fcntl @@ -12946,6 +12944,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getpeername SYSCALL(getpeername); #endif + SYSCALL(getpgid); #ifdef TARGET_NR_getpgrp SYSCALL(getpgrp); #endif @@ -12980,6 +12979,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(linkat); #ifdef TARGET_NR_listen SYSCALL(listen); +#endif +#ifdef TARGET_NR_llseek + SYSCALL(llseek); #endif SYSCALL(lseek); #ifdef TARGET_NR_lstat @@ -13042,6 +13044,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_pause SYSCALL(pause); #endif + SYSCALL(personality); #ifdef TARGET_NR_pipe SYSCALL(pipe); #endif From patchwork Sun Jun 10 03:01:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138149 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2602866lji; Sat, 9 Jun 2018 20:56:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISCBcjLlC56sOWZ4ClLfH/RR2g1iotPdl5rQ0lBJMtIIA9hqWyJC6+iCKBmeAW2DruzegI X-Received: by 2002:a0c:9588:: with SMTP id s8-v6mr11091166qvs.23.1528602968319; Sat, 09 Jun 2018 20:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602968; cv=none; d=google.com; s=arc-20160816; b=dIj7cJTrQfNmeFqRwMwoqBxo44HuoqQm8OWfahi5jR+szs0yBZm3cSzcbvF4TfgjHl sz50lniCxL7sBFs82FyrNeo+hashy2wjPOqcXG7cja+8477zu3AHg0RHBxXQTEoeojfZ qyj/a0A0/+9Ye1knG5FJD1n4HtctQ1e2Cn7IEl32T/Prhy2xaRAFOuq/NLEsOMNAagiN Pj/m3Ehh6Mt3zAbtCaAi9Dq0R6YVc5KM/lOlqJttYniBwGMaRqj8D7xH6AiGcKTp77Qi CExRVsfIDEAeVGAZQngP6eg8vktaKmObQmEuySogoWhqn5/nCJmLAp/fsWqYXoRZQd9R ZiIw== 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:arc-authentication-results; bh=Lzw/JRx37tqXQbLnj4evXXdQpDvmQGzkx2xaVa/H3NM=; b=0z/gPSqIs2BxkVjfLeaSEg8hZZg+MJrWmx0oD1CutsNh4g3ZowhOI7P+0iJsk0RNwC bhqJmsBQT7Hino0prpFtfq6fDNCRDnzXR7rN+y/CBQeoTjs11emOaDeOcOmDe/z/5f9Z 3ErRqqw9XjutDvl+YC2mYmLubh8oxkQ7bAsL85WsysQm5LEPTthpZSjY9c5J4/pFei9M 6H/QWa1CEQlprlQnLOCM8bFlLj+ydSvLXrQUoOTj5Ti5zDrl09QOodo9QDsUkNpfON8V fzrdEB9tm6w+8nFEWHs0Hua/NYAEbJ2pJ+Jq38ATJOjzB45LLqjOe5cp/Dax+v/2KpaR PiVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Vyea4o1y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u6-v6si892278qkc.122.2018.06.09.20.56.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Vyea4o1y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrSZ-0001Cx-Nq for patch@linaro.org; Sat, 09 Jun 2018 23:56:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqel-0003QH-LY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqej-0003rY-Sm for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:39 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:37249) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqej-0003rN-KT for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:37 -0400 Received: by mail-pf0-x244.google.com with SMTP id y5-v6so7584032pfn.4 for ; Sat, 09 Jun 2018 20:04: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=Lzw/JRx37tqXQbLnj4evXXdQpDvmQGzkx2xaVa/H3NM=; b=Vyea4o1yPOqwOjzogeA4vwjTkdwUeA9q/zTrjyGjTMqdKnmUR9khyZtLOVNuNf/8wV 69CCdXehnnYj5saXsUQhCjREEvWFVpmfLp0NhpQzcFWrk94KOCeqNdMShXfce7a3xLAs 1Z332eXb8aFe/L6krtZ8F3Qxis3OvO6PoKXhA= 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=Lzw/JRx37tqXQbLnj4evXXdQpDvmQGzkx2xaVa/H3NM=; b=shvQW+sT6YMvCcJbgu0F0uAP1U2jeni1qyTOd/fneVov8nXXWdFQWVGU6w2IdfEby8 +/zcBl0yiBy04ANpJprtXwW0vzLsXKBmaFEy31+eiQTSZI82IUATsBaW6CUZc//QEkg7 0fgQh46xn/zcgARfU1gTZIsCDudIu+C9rVChN+idRxkParupmBCH6IaGgULbpXjn6jNy AqWpe1yB7uS31wI+hHMQIwewAyT8tHjUIZczxmmoZjtMczutsayjN+row8UTfTTgeDU6 fF2l0U33lJ8UPe6AiuyoB663wtO3MiJXn8ReuI73muOEzE0/DLoO6Xts3CVDquIZTmpc zwcw== X-Gm-Message-State: APt69E01L2JgZjuQSeWTDcQQaDw5IOLmqDrCgLcY5GUkXdh5/67KGJeG tLvY2Y3OeqBfVcIdLBxgBbkmhM7Su1w= X-Received: by 2002:a62:67c5:: with SMTP id t66-v6mr12287467pfj.20.1528599876453; Sat, 09 Jun 2018 20:04:36 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:32 -1000 Message-Id: <20180610030220.3777-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 060/108] linux-user: Split out getdents, getdents64 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 | 329 ++++++++++++++++++++++--------------------- 1 file changed, 170 insertions(+), 159 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f5f21658a8..600702ea3e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8121,6 +8121,170 @@ IMPL(futimesat) } #endif +#ifdef TARGET_NR_getdents +IMPL(getdents) +{ + abi_long ret; +# ifdef EMULATE_GETDENTS_WITH_GETDENTS +# if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 + struct target_dirent *target_dirp; + struct linux_dirent *dirp; + abi_long count = arg3; + + dirp = g_try_malloc(count); + if (!dirp) { + return -TARGET_ENOMEM; + } + + ret = get_errno(sys_getdents(arg1, dirp, count)); + if (!is_error(ret)) { + struct linux_dirent *de; + struct target_dirent *tde; + int len = ret; + int reclen, treclen; + int count1, tnamelen; + + count1 = 0; + de = dirp; + target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0); + if (!target_dirp) { + return -TARGET_EFAULT; + } + tde = target_dirp; + while (len > 0) { + reclen = de->d_reclen; + tnamelen = reclen - offsetof(struct linux_dirent, d_name); + assert(tnamelen >= 0); + treclen = tnamelen + offsetof(struct target_dirent, d_name); + assert(count1 + treclen <= count); + tde->d_reclen = tswap16(treclen); + tde->d_ino = tswapal(de->d_ino); + tde->d_off = tswapal(de->d_off); + memcpy(tde->d_name, de->d_name, tnamelen); + de = (struct linux_dirent *)((char *)de + reclen); + len -= reclen; + tde = (struct target_dirent *)((char *)tde + treclen); + count1 += treclen; + } + ret = count1; + unlock_user(target_dirp, arg2, ret); + } + g_free(dirp); +# else + struct linux_dirent *dirp; + abi_long count = arg3; + + dirp = lock_user(VERIFY_WRITE, arg2, count, 0); + if (!dirp) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_getdents(arg1, dirp, count)); + if (!is_error(ret)) { + struct linux_dirent *de = dirp; + int len = ret; + int reclen; + + while (len > 0) { + reclen = de->d_reclen; + if (reclen > len) { + break; + } + de->d_reclen = tswap16(reclen); + tswapls(&de->d_ino); + tswapls(&de->d_off); + de = (struct linux_dirent *)((char *)de + reclen); + len -= reclen; + } + } + unlock_user(dirp, arg2, ret); +# endif +# else + /* Implement getdents in terms of getdents64 */ + struct linux_dirent64 *dirp; + abi_long count = arg3; + + dirp = lock_user(VERIFY_WRITE, arg2, count, 0); + if (!dirp) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_getdents64(arg1, dirp, count)); + if (!is_error(ret)) { + /* Convert the dirent64 structs to target dirent. We do this + * in-place, since we can guarantee that a target_dirent is no + * larger than a dirent64; however this means we have to be + * careful to read everything before writing in the new format. + */ + struct linux_dirent64 *de = dirp; + struct target_dirent *tde = (struct target_dirent *)dirp; + int len = ret; + int tlen = 0; + + while (len > 0) { + int namelen, treclen; + int reclen = de->d_reclen; + uint64_t ino = de->d_ino; + int64_t off = de->d_off; + uint8_t type = de->d_type; + + namelen = strlen(de->d_name); + treclen = offsetof(struct target_dirent, d_name) + namelen + 2; + treclen = QEMU_ALIGN_UP(treclen, sizeof(abi_long)); + + memmove(tde->d_name, de->d_name, namelen + 1); + tde->d_ino = tswapal(ino); + tde->d_off = tswapal(off); + tde->d_reclen = tswap16(treclen); + /* The target_dirent type is in what was formerly a padding + * byte at the end of the structure: + */ + *(((char *)tde) + treclen - 1) = type; + + de = (struct linux_dirent64 *)((char *)de + reclen); + tde = (struct target_dirent *)((char *)tde + treclen); + len -= reclen; + tlen += treclen; + } + ret = tlen; + } + unlock_user(dirp, arg2, ret); +# endif + return ret; +} +#endif + +#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) +IMPL(getdents64) +{ + struct linux_dirent64 *dirp; + abi_long count = arg3; + abi_long ret; + + dirp = lock_user(VERIFY_WRITE, arg2, count, 0); + if (!dirp) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_getdents64(arg1, dirp, count)); + if (!is_error(ret)) { + struct linux_dirent64 *de = dirp; + int len = ret; + + while (len > 0) { + int reclen = de->d_reclen; + if (reclen > len) { + break; + } + de->d_reclen = tswap16(reclen); + tswap64s((uint64_t *)&de->d_ino); + tswap64s((uint64_t *)&de->d_off); + de = (struct linux_dirent64 *)((char *)de + reclen); + len -= reclen; + } + } + unlock_user(dirp, arg2, ret); + return ret; +} +#endif /* TARGET_NR_getdents64 */ + IMPL(getitimer) { struct itimerval value; @@ -10485,165 +10649,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getdents - case TARGET_NR_getdents: -#ifdef EMULATE_GETDENTS_WITH_GETDENTS -#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 - { - struct target_dirent *target_dirp; - struct linux_dirent *dirp; - abi_long count = arg3; - - dirp = g_try_malloc(count); - if (!dirp) { - return -TARGET_ENOMEM; - } - - ret = get_errno(sys_getdents(arg1, dirp, count)); - if (!is_error(ret)) { - struct linux_dirent *de; - struct target_dirent *tde; - int len = ret; - int reclen, treclen; - int count1, tnamelen; - - count1 = 0; - de = dirp; - if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) - return -TARGET_EFAULT; - tde = target_dirp; - while (len > 0) { - reclen = de->d_reclen; - tnamelen = reclen - offsetof(struct linux_dirent, d_name); - assert(tnamelen >= 0); - treclen = tnamelen + offsetof(struct target_dirent, d_name); - assert(count1 + treclen <= count); - tde->d_reclen = tswap16(treclen); - tde->d_ino = tswapal(de->d_ino); - tde->d_off = tswapal(de->d_off); - memcpy(tde->d_name, de->d_name, tnamelen); - de = (struct linux_dirent *)((char *)de + reclen); - len -= reclen; - tde = (struct target_dirent *)((char *)tde + treclen); - count1 += treclen; - } - ret = count1; - unlock_user(target_dirp, arg2, ret); - } - g_free(dirp); - } -#else - { - struct linux_dirent *dirp; - abi_long count = arg3; - - if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) - return -TARGET_EFAULT; - ret = get_errno(sys_getdents(arg1, dirp, count)); - if (!is_error(ret)) { - struct linux_dirent *de; - int len = ret; - int reclen; - de = dirp; - while (len > 0) { - reclen = de->d_reclen; - if (reclen > len) - break; - de->d_reclen = tswap16(reclen); - tswapls(&de->d_ino); - tswapls(&de->d_off); - de = (struct linux_dirent *)((char *)de + reclen); - len -= reclen; - } - } - unlock_user(dirp, arg2, ret); - } -#endif -#else - /* Implement getdents in terms of getdents64 */ - { - struct linux_dirent64 *dirp; - abi_long count = arg3; - - dirp = lock_user(VERIFY_WRITE, arg2, count, 0); - if (!dirp) { - return -TARGET_EFAULT; - } - ret = get_errno(sys_getdents64(arg1, dirp, count)); - if (!is_error(ret)) { - /* Convert the dirent64 structs to target dirent. We do this - * in-place, since we can guarantee that a target_dirent is no - * larger than a dirent64; however this means we have to be - * careful to read everything before writing in the new format. - */ - struct linux_dirent64 *de; - struct target_dirent *tde; - int len = ret; - int tlen = 0; - - de = dirp; - tde = (struct target_dirent *)dirp; - while (len > 0) { - int namelen, treclen; - int reclen = de->d_reclen; - uint64_t ino = de->d_ino; - int64_t off = de->d_off; - uint8_t type = de->d_type; - - namelen = strlen(de->d_name); - treclen = offsetof(struct target_dirent, d_name) - + namelen + 2; - treclen = QEMU_ALIGN_UP(treclen, sizeof(abi_long)); - - memmove(tde->d_name, de->d_name, namelen + 1); - tde->d_ino = tswapal(ino); - tde->d_off = tswapal(off); - tde->d_reclen = tswap16(treclen); - /* The target_dirent type is in what was formerly a padding - * byte at the end of the structure: - */ - *(((char *)tde) + treclen - 1) = type; - - de = (struct linux_dirent64 *)((char *)de + reclen); - tde = (struct target_dirent *)((char *)tde + treclen); - len -= reclen; - tlen += treclen; - } - ret = tlen; - } - unlock_user(dirp, arg2, ret); - } -#endif - return ret; -#endif /* TARGET_NR_getdents */ -#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) - case TARGET_NR_getdents64: - { - struct linux_dirent64 *dirp; - abi_long count = arg3; - if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0))) - return -TARGET_EFAULT; - ret = get_errno(sys_getdents64(arg1, dirp, count)); - if (!is_error(ret)) { - struct linux_dirent64 *de; - int len = ret; - int reclen; - de = dirp; - while (len > 0) { - reclen = de->d_reclen; - if (reclen > len) - break; - de->d_reclen = tswap16(reclen); - tswap64s((uint64_t *)&de->d_ino); - tswap64s((uint64_t *)&de->d_off); - de = (struct linux_dirent64 *)((char *)de + reclen); - len -= reclen; - } - } - unlock_user(dirp, arg2, ret); - } - return ret; -#endif /* TARGET_NR_getdents64 */ #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) # ifdef TARGET_NR_poll case TARGET_NR_poll: @@ -12939,6 +12944,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(ftruncate); #ifdef TARGET_NR_futimesat SYSCALL(futimesat); +#endif +#ifdef TARGET_NR_getdents + SYSCALL(getdents); +#endif +#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) + SYSCALL(getdents64); #endif SYSCALL(getitimer); #ifdef TARGET_NR_getpeername From patchwork Sun Jun 10 03:01:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138150 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2603086lji; Sat, 9 Jun 2018 20:56:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ783O+g+aURSQxE4/8g7Pk1tS62FuoXiIUQ5LwR1bbu7TYLqt8KrLZq8fTwZprxTL6n0kV X-Received: by 2002:a0c:9c88:: with SMTP id i8-v6mr10925876qvf.193.1528602996664; Sat, 09 Jun 2018 20:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602996; cv=none; d=google.com; s=arc-20160816; b=ZjqqKjgi1unpJ+z2UjkaOrRHhpd8ZVp9O7XI7QtSOdLG/ixtP8fFK/MhzKCZBhJDk9 9YUiA2zFe7HwtZ3KiAMMgk0U3TpqIi8tPWYfHJABHSDamEVfCZ9L2FH3jGUaTEAaVX1X nAyb+Iggboy6f70mTIERWzZYZnnfCM7Dy0abyL1Ra4RmhBwy37krazXtyIl+r0nNRySb rjZFldZSWPOACREja7x+CQ2iBcxHXW/hGkG8eNzFnNZfcBnXbgVLU4wIEDeLo7ydsEA9 yyo+s95KpZ5J6Jk5Vxyh5Xi9pwB2WW6+DVN5mSNH6g9VbEQUkBVuOBlIWMSTzWEi0EA/ gVWA== 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:arc-authentication-results; bh=BEsMWgTH49iFDdmp2MfOksyWfRzKkXoFJXJNoz/B4uE=; b=G/TvGiw20SpvJlz1eqCQ7U4ZCstdEXA6Wut7tZ8dYULk7WRlIAVHikAsq402LB6Kfv aAg0X8svJDmJli3CrL7nSsXsh+xWxxSi1gbCF4OMFkJmWoq7tD5fSMtBAkBct97b6O7G KPY0XpCj8kpRWPscFS5BLgt+CRdSsCuV6WEBXJ1AzYcFja38ExLQbULcnXuF0rrMOcuJ 354fABVDd3FuMvrhjHdwJgf+3Ru6YDEnvL9IbB/FKpq0k7Ot119MB/SOM0TbUv06znw1 BO/bKPD48L2PQp1nC8+oskw8NBG3nmhZEnr69olB/pzeQaxIx+v4nS3JW0o6GR9mRapZ WvLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZIxyNgpF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v52-v6si3334728qtc.356.2018.06.09.20.56.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:56:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZIxyNgpF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrT2-0001H3-4J for patch@linaro.org; Sat, 09 Jun 2018 23:56:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqen-0003Rc-0D for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqel-0003sw-Os for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:41 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34415) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqel-0003sS-Gw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:39 -0400 Received: by mail-pf0-x242.google.com with SMTP id a63-v6so8499503pfl.1 for ; Sat, 09 Jun 2018 20:04: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=BEsMWgTH49iFDdmp2MfOksyWfRzKkXoFJXJNoz/B4uE=; b=ZIxyNgpFuvAyr5E57ap3hX87JqeMfymIqtoAiaeiIbTV1g0KzqEEmwPMvVeudlBePS TpPSVZI7V1VADyV4KEqaNjIcErju+cBRixSDUvA067VHopwinPMrTY8ghL+grEDs/i2O Ly1ROIc6aF/U6etclOG+sAvHWIejP+dgskS+U= 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=BEsMWgTH49iFDdmp2MfOksyWfRzKkXoFJXJNoz/B4uE=; b=P7INpGEa27k2YHqBN/ufvNOdNws7P7hjdG3kVbdX4JW46rghJxSg9eLfgXuimxWM8t 0LbPfqnOAARUpNVBZFn6UAtwEu5ahwjUd3fnIcJMF/XYZ20nVmEENpheQmrLYInP3N7P QtETkffhH7FsPlLdGPW1EiEqTPVnrjeDZOkKXenXiphHxOh6OoNlalYUDEX+aTYU+rol QpGWdIWUqbnQiPp51AcPjrMNunJHEiMOYRb9puD57iI+ac6p/rFOQiIIR3rfSMYAIhvc qGXEp7NuuJnGx899jqoQstB4j6Fu0Ll7ktw7JCGCaBLnztJGq8dC01dRDXZhJBDgRMeB WWNQ== X-Gm-Message-State: APt69E37qvF/f29gVjR/DYwlLveVE+v69LWqCCEDA8DtwUZsI8oYJS85 R/DrEPlI0uXy8GKOpqP6+4Jcl3L4pAE= X-Received: by 2002:a63:6742:: with SMTP id b63-v6mr10424258pgc.54.1528599878330; Sat, 09 Jun 2018 20:04:38 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:33 -1000 Message-Id: <20180610030220.3777-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 061/108] linux-user: Split out poll, ppoll 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 define ppoll; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 232 +++++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 108 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 600702ea3e..362d315ce8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9101,6 +9101,126 @@ IMPL(pipe2) target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); } +static struct pollfd *get_pollfd(abi_ulong nfds, abi_ulong target_addr, + struct target_pollfd **ptfd, abi_long *err) +{ + struct target_pollfd *target_pfd; + struct pollfd *pfd; + abi_ulong i; + + if (nfds > (INT_MAX / sizeof(struct target_pollfd))) { + *err = -TARGET_EINVAL; + return NULL; + } + pfd = g_try_new(struct pollfd, nfds); + if (pfd == NULL) { + *err = -TARGET_ENOMEM; + return NULL; + } + + *ptfd = target_pfd = lock_user(VERIFY_WRITE, target_addr, + sizeof(struct target_pollfd) * nfds, 1); + if (!target_pfd) { + *err = -TARGET_EFAULT; + g_free(pfd); + return NULL; + } + + for (i = 0; i < nfds; i++) { + pfd[i].fd = tswap32(target_pfd[i].fd); + pfd[i].events = tswap16(target_pfd[i].events); + } + + *err = 0; + return pfd; +} + +static abi_long put_pollfd(abi_ulong nfds, abi_ulong target_addr, + struct pollfd *pfd, + struct target_pollfd *target_pfd, abi_long ret) +{ + if (!is_error(ret)) { + abi_ulong i; + for (i = 0; i < nfds; i++) { + target_pfd[i].revents = tswap16(pfd[i].revents); + } + } + unlock_user(target_pfd, target_addr, sizeof(struct target_pollfd) * nfds); + g_free(pfd); + return ret; +} + +#ifdef TARGET_NR_poll +IMPL(poll) +{ + struct timespec ts, *pts; + struct target_pollfd *target_pfd; + struct pollfd *pfd; + abi_long ret; + + if (arg3 >= 0) { + /* Convert ms to secs, ns */ + ts.tv_sec = arg3 / 1000; + ts.tv_nsec = (arg3 % 1000) * 1000000LL; + pts = &ts; + } else { + /* -ve poll() timeout means "infinite" */ + pts = NULL; + } + + pfd = get_pollfd(arg2, arg1, &target_pfd, &ret); + if (pfd == NULL) { + return ret; + } + ret = safe_ppoll(pfd, arg2, pts, NULL, 0); + return put_pollfd(arg2, arg1, pfd, target_pfd, get_errno(ret)); +} +#endif + +IMPL(ppoll) +{ + struct timespec ts; + sigset_t set; + struct target_pollfd *target_pfd; + struct pollfd *pfd; + abi_long ret; + + if (arg3) { + if (target_to_host_timespec(&ts, arg3)) { + return -TARGET_EFAULT; + } + } + + if (arg4) { + target_sigset_t *target_set; + if (arg5 != sizeof(target_sigset_t)) { + return -TARGET_EINVAL; + } + target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1); + if (!target_set) { + return -TARGET_EFAULT; + } + target_to_host_sigset(&set, target_set); + unlock_user(target_set, arg4, 0); + } + + pfd = get_pollfd(arg2, arg1, &target_pfd, &ret); + if (pfd == NULL) { + return ret; + } + ret = safe_ppoll(pfd, arg2, arg3 ? &ts : NULL, + arg4 ? &set : NULL, SIGSET_T_SIZE); + ret = put_pollfd(arg2, arg1, pfd, target_pfd, get_errno(ret)); + + if (!is_error(ret) && arg3) { + abi_long err = host_to_target_timespec(arg3, &ts); + if (err) { + return err; + } + } + return ret; +} + IMPL(pselect6) { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; @@ -10649,114 +10769,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll) -# ifdef TARGET_NR_poll - case TARGET_NR_poll: -# endif -# ifdef TARGET_NR_ppoll - case TARGET_NR_ppoll: -# endif - { - struct target_pollfd *target_pfd; - unsigned int nfds = arg2; - struct pollfd *pfd; - unsigned int i; - - pfd = NULL; - target_pfd = NULL; - if (nfds) { - if (nfds > (INT_MAX / sizeof(struct target_pollfd))) { - return -TARGET_EINVAL; - } - - target_pfd = lock_user(VERIFY_WRITE, arg1, - sizeof(struct target_pollfd) * nfds, 1); - if (!target_pfd) { - return -TARGET_EFAULT; - } - - pfd = alloca(sizeof(struct pollfd) * nfds); - for (i = 0; i < nfds; i++) { - pfd[i].fd = tswap32(target_pfd[i].fd); - pfd[i].events = tswap16(target_pfd[i].events); - } - } - - switch (num) { -# ifdef TARGET_NR_ppoll - case TARGET_NR_ppoll: - { - struct timespec _timeout_ts, *timeout_ts = &_timeout_ts; - target_sigset_t *target_set; - sigset_t _set, *set = &_set; - - if (arg3) { - if (target_to_host_timespec(timeout_ts, arg3)) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EFAULT; - } - } else { - timeout_ts = NULL; - } - - if (arg4) { - if (arg5 != sizeof(target_sigset_t)) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EINVAL; - } - - target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1); - if (!target_set) { - unlock_user(target_pfd, arg1, 0); - return -TARGET_EFAULT; - } - target_to_host_sigset(set, target_set); - } else { - set = NULL; - } - - ret = get_errno(safe_ppoll(pfd, nfds, timeout_ts, - set, SIGSET_T_SIZE)); - - if (!is_error(ret) && arg3) { - host_to_target_timespec(arg3, timeout_ts); - } - if (arg4) { - unlock_user(target_set, arg4, 0); - } - return ret; - } -# endif -# ifdef TARGET_NR_poll - case TARGET_NR_poll: - { - struct timespec ts, *pts; - - if (arg3 >= 0) { - /* Convert ms to secs, ns */ - ts.tv_sec = arg3 / 1000; - ts.tv_nsec = (arg3 % 1000) * 1000000LL; - pts = &ts; - } else { - /* -ve poll() timeout means "infinite" */ - pts = NULL; - } - return get_errno(safe_ppoll(pfd, nfds, pts, NULL, 0)); - } -# endif - default: - g_assert_not_reached(); - } - - if (!is_error(ret)) { - for(i = 0; i < nfds; i++) { - target_pfd[i].revents = tswap16(pfd[i].revents); - } - } - unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); - } - return ret; -#endif case TARGET_NR_flock: /* NOTE: the flock constant seems to be the same for every Linux platform */ @@ -13060,6 +13072,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(pipe); #endif SYSCALL(pipe2); +#ifdef TARGET_NR_poll + SYSCALL(poll); +#endif + SYSCALL(ppoll); SYSCALL(pselect6); SYSCALL(read); #ifdef TARGET_NR_readlink From patchwork Sun Jun 10 03:01:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138131 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2596261lji; Sat, 9 Jun 2018 20:43:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9b3XmIFwu+Md3U6nOVak4dZqcjfRgpXnEj1aVoy14bmm06faCcxc8HH+exo6lssp9QLeA X-Received: by 2002:ac8:16d6:: with SMTP id y22-v6mr3751548qtk.352.1528602213554; Sat, 09 Jun 2018 20:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602213; cv=none; d=google.com; s=arc-20160816; b=AWOyfauT7fpI2KAqOd0OTOPuPueeQ9q1THt0KUkheMspwSidQ8sr2vZEDBMh/Jt8eV Z6m/5BXUBkAlPfFJ3jWWcFqGK/J2+CoGq3/iTr48SD5APX6nAm5yfI+YFvWbwdaZL05R miqTg+QcjeG7mR6m3x565KIVnzD8M6ZMVJs0iYtVU0NguvhhVjFjMcf+i8u0P2A3L9Fr T86YAWivi+iVrVwGsIll3oFVYwf3Sbe+btc+87cowVQ+8NEy/7/kLY/oi9ou9xLzo//d t7C5+QrKrwawjFairqyhfCp05EdZ6mkOQ0SFkINY+UyAsoS1QryOCHfMe74EiZHxjQzn XbiQ== 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:arc-authentication-results; bh=Q3zsLN52/w7gqJ6E51v6W4Qx9N3X1e6YhQA4YDsmY/s=; b=PD1WPePfjgKAETkeucfYpKf/Kt7ekb1oGopX2kcXY5+yIdV1NJkm/ShlN4LiN0stoP smOqDg7nfnPnmLZelYQKHpetEirhd7r199FsqrqPxnj5VFfn1kvkibb63Nf/T0LynCMK 6SV49LOHDRJS706ec+HmqDXaN6KsIAhUebHae6OsYbHTjEqbZ/a+J60j0To77/18YYI3 QMeI8XYmyyDMQDioM0Wyk5jHuQRbLLr4/B7cCyrx2N6aiC9aQQh0MD/vH1B0ATDEbxFk C0BXojktnDZskZsrK/KY1hjcVQDxo0JkRcdHm1usRWp1d0iHoo+h06kEhbwGGGPI0b1C oLBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I94OAC4x; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i5-v6si60505qtc.150.2018.06.09.20.43.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I94OAC4x; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrGO-0004VT-T9 for patch@linaro.org; Sat, 09 Jun 2018 23:43:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeo-0003TQ-L8 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqen-0003tU-Eg for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:42 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:40579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqen-0003t7-69 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:41 -0400 Received: by mail-pf0-x243.google.com with SMTP id z24-v6so8491109pfe.7 for ; Sat, 09 Jun 2018 20:04: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=Q3zsLN52/w7gqJ6E51v6W4Qx9N3X1e6YhQA4YDsmY/s=; b=I94OAC4xgHQtXznzD++07GOoGFcKL290APBhTRwGMFgetC3K954WhbgxSWoaMftLc+ IXmg80BaPq6aIVq4BdVKCqv+muEWFZJGZiEa8TFaIhWwFQI5prAMb8U7CaIvF4ElHnEx bLERZVEXf4sXGTziVoKveVQKmKvj4rTZatGig= 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=Q3zsLN52/w7gqJ6E51v6W4Qx9N3X1e6YhQA4YDsmY/s=; b=AUdhmpHYbbxnJybiVtwlTSOk1kv3MpU6PNsZ46/RJna9ZYcKa/q0gqvQkOHSZSyShW jlDLq1wxbw4a17nxtbwtxjc4y7Mv/VaSiYZV3yyKBpnXQBD73k0mZom0wOHFLMPK2uli Q9LyhHc0r7fvbJjgkXjluB50HFyOofzPZZKPmw5J6faIk7P3xcZysLmEF7CHZQEc5ONb R4qT17QBoLOtZXQ0CiGLkRJlX83T0PB0BjBP//Sohjemi7M93da4zyvk1/a9f3JQfsjY 3Dvo3GNQ0mQvI8G4cCmNILaVJDKVQR4UiUgisyRjx92Lb5vsjBmEkpFYrbACSVoI25Ht I2IQ== X-Gm-Message-State: APt69E0jk0rBhdm8fYrBKD2sTqqRUO2g31ZZ1aZ6AOPBXRGXAROtQn2x YDdfu2to/hn2gjB5ZAPRaN2JU2LVEqQ= X-Received: by 2002:a65:6356:: with SMTP id p22-v6mr10456040pgv.20.1528599880003; Sat, 09 Jun 2018 20:04:40 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:34 -1000 Message-Id: <20180610030220.3777-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 062/108] linux-user: Split out flock, preadv, pwritev, 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" All targets define preadv and pwritev; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 135 ++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 362d315ce8..07fa043965 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8043,6 +8043,12 @@ IMPL(fcntl) } #endif +IMPL(flock) +{ + /* The flock constant seems to be the same for every Linux platform. */ + return get_errno(safe_flock(arg1, arg2)); +} + #ifdef TARGET_NR_fork IMPL(fork) { @@ -9221,6 +9227,24 @@ IMPL(ppoll) return ret; } +IMPL(preadv) +{ + struct iovec *vec; + abi_long ret; + + 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; +} + IMPL(pselect6) { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; @@ -9322,6 +9346,24 @@ IMPL(pselect6) return ret; } +IMPL(pwritev) +{ + struct iovec *vec; + abi_long ret; + + 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; +} + IMPL(read) { abi_long ret; @@ -9381,6 +9423,21 @@ IMPL(readlinkat) return do_readlinkat(arg1, arg2, arg3, arg4); } +IMPL(readv) +{ + struct iovec *vec; + abi_long ret; + + 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; +} + IMPL(reboot) { abi_long ret; @@ -10753,6 +10810,21 @@ IMPL(write) return ret; } +IMPL(writev) +{ + struct iovec *vec; + abi_long ret; + + 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; +} + /* This is an internal helper for do_syscall so that it is easier * to have a single return point, so that actions, such as logging * of syscall results, can be performed. @@ -10769,64 +10841,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_flock: - /* 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: - { - 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 ?) */ @@ -12944,6 +12958,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_fcntl SYSCALL(fcntl); #endif + SYSCALL(flock); #ifdef TARGET_NR_fork SYSCALL(fork); #endif @@ -13076,12 +13091,15 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(poll); #endif SYSCALL(ppoll); + SYSCALL(preadv); SYSCALL(pselect6); + SYSCALL(pwritev); SYSCALL(read); #ifdef TARGET_NR_readlink SYSCALL(readlink); #endif SYSCALL(readlinkat); + SYSCALL(readv); SYSCALL(reboot); #ifdef TARGET_NR_recv SYSCALL(recv); @@ -13250,6 +13268,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(waitpid); #endif SYSCALL(write); + SYSCALL(writev); } #undef SYSCALL From patchwork Sun Jun 10 03:01:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138147 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2602394lji; Sat, 9 Jun 2018 20:55:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIsiJF0B/OZVA8hfW0NrCxtnuYdenZPHDh3QXbNvVvzCl9rOEDt/WenB/N9LT1KhMbJqGyi X-Received: by 2002:ac8:2f2a:: with SMTP id j39-v6mr11638794qta.74.1528602904966; Sat, 09 Jun 2018 20:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602904; cv=none; d=google.com; s=arc-20160816; b=NOakxHJPxHx0BTDjRLZ2yKFQmJda0xp3isNL3ARDBUgZ7RSGK1+YCziX/lOVEZ7DbB iWhZOJHKiHcaln1tsftC9ko5tbLH7mcMo46+QVPAp6DvA5mPw+Z2mnV2pjVGtKox5n5P KGHMVCNgK4jBB0ZIslfOoWOHhvvQKcMONy65g3x6praabqCZtL7z1ebe09XBx1pBIROb uHl1gba4dya+ioMoIqfedLp3d2aweKNDL17gjxXD6oYWlS6E4O3pLCKY/Z/Gt8uMTroH 0WRaJIWonmz3J8n92XqldWhWjZEg+EweRdxJG21P7RPKK5cddQz/Q/dHBxJxJXQ1KJwP B6Cg== 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:arc-authentication-results; bh=OJ64N1ZkPa33+gTHoTwS9Q5hpSvK2Sp61kAqUtj5TKk=; b=YB9SyZs+86i27x9SIo1ktxaBWOl7mhQWjzftlXH5+RAZp1zEiaE+YWxl9aIMIdzWD9 paItkvMxtye/IabJ16LsktkSWZ6kCowViNHNWYbQZUVtrhE96wkskepAKCT+9cinfsZQ EraGQn2Xe4hn6dC8pPDrvNwkE6nTkIfex2hJzcHnGCICV4SMil3rZIyvD90rY/DY3Fkb a/9LAmQSGfjGQAfu0e2t8MKMA4p1BN+c0FanlAqTA+R14XZFdWxB4Aj2cg8FwqEW6TZV mIzqrTKcsv4OieRR+V6csuWJk31gc/wWxqsIxtGx9CHAJlj+3fJFQAJ+JazNvsg8GGhP MU5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LgKDm/b+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m38-v6si9234585qtm.176.2018.06.09.20.55.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:55:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LgKDm/b+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrRY-0007Mi-DW for patch@linaro.org; Sat, 09 Jun 2018 23:55:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeq-0003V2-75 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqep-0003uj-9K for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:44 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:40578) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqep-0003tw-3O for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:43 -0400 Received: by mail-pf0-x241.google.com with SMTP id z24-v6so8491137pfe.7 for ; Sat, 09 Jun 2018 20:04: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=OJ64N1ZkPa33+gTHoTwS9Q5hpSvK2Sp61kAqUtj5TKk=; b=LgKDm/b+3I435FwO3c48pXlf6TbQhBwXLtxVVLr4k4bgeKf8KkLiJrLKgCcC8qqxoF pDRcW7LNSeI5aHSzHNZEG4OPF/6f88FRIZ6s1w2n0HE3/ZbjHaMb3m9zZrVwxgFKL7tq H7VBLFFp1AciQKszhkwz1H0iQxMzfL8HNNIwM= 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=OJ64N1ZkPa33+gTHoTwS9Q5hpSvK2Sp61kAqUtj5TKk=; b=cgGj2PKWh4aqD7IMvgOXEK2Lyh7jOT659vmJBCRSO74RzcF44VzzB7MXxLvq7JJoFP zgQMuEht07+sAW8AHVsK2g3t/ZCsh/dslCdesILK130FT3vnTXLkVN/hitbscqUUatR6 Bq2PeRX3RnRi77cldTdVrZIX5u0Kj+5J+iVea31KkMHwCmM44zyQ0LnY/KK/QAMwLUvX bKYr81tIeePqMyQA5K4k0t+e5eGLGWguaeKJtsFP4AcbTVP34LpGdDAiYySUHmZb6DDP W6UMzNbF6782IK8oukSvS7ttNl1kKYDwwn2OebBmoe95/+oEqqYf+awDzmOkLNbXOP16 QPiA== X-Gm-Message-State: APt69E0rjGRqKzC2yjEPA0+KAYOkgunGUevPW8ktvHmorZgI/IrdEGSF vUWz5a/Q45SD0/qZ5GoXVRpCI37et0Q= X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr10270115pgt.98.1528599881911; Sat, 09 Jun 2018 20:04:41 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:35 -1000 Message-Id: <20180610030220.3777-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 063/108] linux-user: Split out fdatasync, getsid, _sysctl 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 define fdatasync; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 07fa043965..1907b32499 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8043,6 +8043,11 @@ IMPL(fcntl) } #endif +IMPL(fdatasync) +{ + return get_errno(fdatasync(arg1)); +} + IMPL(flock) { /* The flock constant seems to be the same for every Linux platform. */ @@ -8403,6 +8408,11 @@ IMPL(getrusage) return ret; } +IMPL(getsid) +{ + return get_errno(getsid(arg1)); +} + #ifdef TARGET_NR_getsockname IMPL(getsockname) { @@ -10465,6 +10475,14 @@ IMPL(syncfs) } #endif +#ifdef TARGET_NR__sysctl +IMPL(_sysctl) +{ + /* We don't implement this, but ENOTDIR is always a safe return value. */ + return -TARGET_ENOTDIR; +} +#endif + IMPL(sysinfo) { struct sysinfo value; @@ -10841,18 +10859,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - 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)); -#endif -#ifdef TARGET_NR__sysctl - case TARGET_NR__sysctl: - /* We don't implement this, but ENOTDIR is always a safe - return value. */ - return -TARGET_ENOTDIR; -#endif case TARGET_NR_sched_getaffinity: { unsigned int mask_size; @@ -12958,6 +12964,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_fcntl SYSCALL(fcntl); #endif + SYSCALL(fdatasync); SYSCALL(flock); #ifdef TARGET_NR_fork SYSCALL(fork); @@ -12996,6 +13003,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getrandom); SYSCALL(getrlimit); SYSCALL(getrusage); + SYSCALL(getsid); #ifdef TARGET_NR_getsockname SYSCALL(getsockname); #endif @@ -13234,6 +13242,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sync); #ifdef CONFIG_SYNCFS SYSCALL(syncfs); +#endif +#ifdef TARGET_NR__sysctl + SYSCALL(_sysctl); #endif SYSCALL(sysinfo); SYSCALL(syslog); From patchwork Sun Jun 10 03:01:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138124 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2593558lji; Sat, 9 Jun 2018 20:38:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIkAWDIUChVMfs/LnTwYSeMPG2hfl9AnQCdKwAkGTzeuI6lf1/ROmtFu37NzQBq5bxc8ZfI X-Received: by 2002:a37:7d42:: with SMTP id y63-v6mr10052129qkc.293.1528601908577; Sat, 09 Jun 2018 20:38:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601908; cv=none; d=google.com; s=arc-20160816; b=y3imSJOcoKbemo3iuIkkNXaUR5MPzcEWmeeiUG7B06F85Lt5LQQOT6tDOEI+yBPnRQ PilPuumyGhBQZSPg6q3cqyApvyecSyz/z9FU2XcsS53fvI3iOMo7W9iefUX5dxgF00PG S3ocSqF8NgngCl4GqxEjzB2DrvZuz5j78L6U1GosrNkVqFuvHKEHB1zfdELpuYRNBqLx Ns+lFYcS6fdwzergG3lU3+pyhwTA3s5qbsb1jJw5shYD3q/TfOVO6HrSYUGkr33SkA10 zr9WbmEZ+o2ykklBqrKhEMvcTB3TCl0X1ASD/RBXJlLENMJaRSG/s9TwssAHjjcn9Gp/ YfsQ== 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:arc-authentication-results; bh=Lf8heLOQnvP3Ys1IsclJ1J79nLc1YRq7KLkfBimhTZA=; b=KH4SHh9AsX12LMh1favCPwCYEn+6q7+C4nh0azL7U10VmgWVZlhFgxZk0lPWml5D/C DztoPrrwWO0GB6CJ8OePYFGI7UdvmouNRHYsmq00m67ZE8SQAy9DrJwp0zU0I6l1MfCR szVMq2zhJqytgsecHqbUhpMLDig3L1ria4ZIswd5NVYeBnX11RuqIzj7mLlbQr4fxGIb 7FL5eTiPWp2CWp/JmQPWWPXLGKom9IMYo0afBbci6J8EmqCBiRH58DbASOegQFHIpY6n ZHGfJpM7Jazd75X3gHg/fTSfirIz4etflR+bauGV6ApkjBVrlau+2ZbKLnk/QjUAzzEB ZsNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=P51sUvGk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 23-v6si653677qtu.370.2018.06.09.20.38.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:38:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=P51sUvGk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrBU-0007zO-18 for patch@linaro.org; Sat, 09 Jun 2018 23:38:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeu-0003Zc-Do for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqer-0003xv-7l for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:48 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:42525) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeq-0003wg-Vz for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:45 -0400 Received: by mail-pg0-x244.google.com with SMTP id c10-v6so2509166pgu.9 for ; Sat, 09 Jun 2018 20:04: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=Lf8heLOQnvP3Ys1IsclJ1J79nLc1YRq7KLkfBimhTZA=; b=P51sUvGkUvqd4ZbifxPnkrOdnFWusmwmzCxo4qn5NJl08wEwgqq+uEjhrg2u0KwIt4 MemLHMkpBG89zg2HsY3JCzDkmQLs9BtSXmAD1ehqlG68Fc+HsXXceRe7h8aAkl969fQ7 OlSw7RMh3EvPR5504N6ArbdkMcbBKyfXOqtgA= 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=Lf8heLOQnvP3Ys1IsclJ1J79nLc1YRq7KLkfBimhTZA=; b=mYdpA+hW1Jk4BBKKUz3GLStxGmm1q//3ZOywGtQBDvUfUEKHgXhOTpUKZTSGp9CnHo H0M+gkaVaxjHcvFMx8UWoQw29Z+KAbJ6jE9ZNWMkCC8xaUTlGBLnAFaKblaO17WO4EGv ManflH9d+zIjypZuq91r6fqJrRN/HTflJ7+zgApr2hQ+wU7BIBDHZIUTC1+8cialx3Om RlM1YDqgGbbq8BPst9/I46EIN/OjhyW0S2ia2FsxVcNO55pstWpI6bX5NKHJzB3NSOd8 x4ZR9uc7UOB0OEkchcpBfeeLwnIK62dSDxqDolkrH7IQ401aKUYDWizHW1v/D6nEBlU7 Il2w== X-Gm-Message-State: APt69E1XEJ+RrekAZGYzU+T3QLB/BAReUtnITuh1eV3CQtI1JRiswpQA 1qpN9Sn6HJ4gngxWs87Iu+QLKBYtrqw= X-Received: by 2002:a65:630b:: with SMTP id g11-v6mr10224989pgv.303.1528599883717; Sat, 09 Jun 2018 20:04:43 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:36 -1000 Message-Id: <20180610030220.3777-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 064/108] linux-user: Split out sched 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 sched_getaffinity, sched_getparam, sched_get_priority_max, sched_get_priority_min, sched_getscheduler, sched_rr_get_interval, sched_setaffinity, sched_setparam, sched_setscheduler, sched_yield. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 281 ++++++++++++++++++++++++------------------- 1 file changed, 158 insertions(+), 123 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1907b32499..84f21634c8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9795,6 +9795,154 @@ IMPL(rt_tgsigqueueinfo) return get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo)); } +IMPL(sched_getaffinity) +{ + unsigned int mask_size; + unsigned long *mask; + abi_long ret; + + /* + * sched_getaffinity needs multiples of ulong, so need to take + * care of mismatches between target ulong and host ulong sizes. + */ + if (arg2 & (sizeof(abi_ulong) - 1)) { + return -TARGET_EINVAL; + } + mask_size = QEMU_ALIGN_UP(arg2, sizeof(unsigned long)); + mask = alloca(mask_size); + memset(mask, 0, mask_size); + + ret = get_errno(sys_sched_getaffinity(arg1, mask_size, mask)); + if (!is_error(ret)) { + if (ret > arg2) { + /* More data returned than the caller's buffer will fit. + * This only happens if sizeof(abi_long) < sizeof(long) + * and the caller passed us a buffer holding an odd number + * of abi_longs. If the host kernel is actually using the + * extra 4 bytes then fail EINVAL; otherwise we can just + * ignore them and only copy the interesting part. + */ + int numcpus = sysconf(_SC_NPROCESSORS_CONF); + if (numcpus > arg2 * 8) { + return -TARGET_EINVAL; + } + ret = arg2; + } + if (host_to_target_cpu_mask(mask, mask_size, arg3, ret)) { + return -TARGET_EFAULT; + } + } + return ret; +} + +IMPL(sched_getparam) +{ + struct sched_param *target_schp; + struct sched_param schp; + abi_long ret; + + if (arg2 == 0) { + return -TARGET_EINVAL; + } + ret = get_errno(sched_getparam(arg1, &schp)); + if (!is_error(ret)) { + if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0)) { + return -TARGET_EFAULT; + } + target_schp->sched_priority = tswap32(schp.sched_priority); + unlock_user_struct(target_schp, arg2, 1); + } + return ret; +} + +IMPL(sched_get_priority_max) +{ + return get_errno(sched_get_priority_max(arg1)); +} + +IMPL(sched_get_priority_min) +{ + return get_errno(sched_get_priority_min(arg1)); +} + +IMPL(sched_getscheduler) +{ + return get_errno(sched_getscheduler(arg1)); +} + +IMPL(sched_rr_get_interval) +{ + struct timespec ts; + abi_long ret; + + ret = get_errno(sched_rr_get_interval(arg1, &ts)); + if (!is_error(ret)) { + ret = host_to_target_timespec(arg2, &ts); + } + return ret; +} + +IMPL(sched_setaffinity) +{ + unsigned int mask_size; + unsigned long *mask; + abi_long ret; + + /* + * sched_setaffinity needs multiples of ulong, so need to take + * care of mismatches between target ulong and host ulong sizes. + */ + if (arg2 & (sizeof(abi_ulong) - 1)) { + return -TARGET_EINVAL; + } + mask_size = QEMU_ALIGN_UP(arg2, sizeof(unsigned long)); + mask = alloca(mask_size); + + ret = target_to_host_cpu_mask(mask, mask_size, arg3, arg2); + if (ret) { + return ret; + } + + return get_errno(sys_sched_setaffinity(arg1, mask_size, mask)); +} + +IMPL(sched_setparam) +{ + struct sched_param *target_schp; + struct sched_param schp; + + if (arg2 == 0) { + return -TARGET_EINVAL; + } + if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1)) { + return -TARGET_EFAULT; + } + schp.sched_priority = tswap32(target_schp->sched_priority); + unlock_user_struct(target_schp, arg2, 0); + return get_errno(sched_setparam(arg1, &schp)); +} + +IMPL(sched_setscheduler) +{ + struct sched_param *target_schp; + struct sched_param schp; + + if (arg3 == 0) { + return -TARGET_EINVAL; + } + if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1)) { + return -TARGET_EFAULT; + } + schp.sched_priority = tswap32(target_schp->sched_priority); + unlock_user_struct(target_schp, arg3, 0); + return get_errno(sched_setscheduler(arg1, arg2, &schp)); +} + +IMPL(sched_yield) +{ + return get_errno(sched_yield()); +} + #ifdef TARGET_NR_sgetmask IMPL(sgetmask) { @@ -10859,68 +11007,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_sched_getaffinity: - { - unsigned int mask_size; - unsigned long *mask; - - /* - * sched_getaffinity needs multiples of ulong, so need to take - * care of mismatches between target ulong and host ulong sizes. - */ - if (arg2 & (sizeof(abi_ulong) - 1)) { - return -TARGET_EINVAL; - } - mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); - - mask = alloca(mask_size); - memset(mask, 0, mask_size); - ret = get_errno(sys_sched_getaffinity(arg1, mask_size, mask)); - - if (!is_error(ret)) { - if (ret > arg2) { - /* More data returned than the caller's buffer will fit. - * This only happens if sizeof(abi_long) < sizeof(long) - * and the caller passed us a buffer holding an odd number - * of abi_longs. If the host kernel is actually using the - * extra 4 bytes then fail EINVAL; otherwise we can just - * ignore them and only copy the interesting part. - */ - int numcpus = sysconf(_SC_NPROCESSORS_CONF); - if (numcpus > arg2 * 8) { - return -TARGET_EINVAL; - } - ret = arg2; - } - - if (host_to_target_cpu_mask(mask, mask_size, arg3, ret)) { - return -TARGET_EFAULT; - } - } - } - return ret; - case TARGET_NR_sched_setaffinity: - { - unsigned int mask_size; - unsigned long *mask; - - /* - * sched_setaffinity needs multiples of ulong, so need to take - * care of mismatches between target ulong and host ulong sizes. - */ - if (arg2 & (sizeof(abi_ulong) - 1)) { - return -TARGET_EINVAL; - } - mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); - mask = alloca(mask_size); - - ret = target_to_host_cpu_mask(mask, mask_size, arg3, arg2); - if (ret) { - return ret; - } - - return get_errno(sys_sched_setaffinity(arg1, mask_size, mask)); - } case TARGET_NR_getcpu: { unsigned cpu, node; @@ -10938,67 +11024,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, } } return ret; - case TARGET_NR_sched_setparam: - { - struct sched_param *target_schp; - struct sched_param schp; - - if (arg2 == 0) { - return -TARGET_EINVAL; - } - if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1)) - return -TARGET_EFAULT; - schp.sched_priority = tswap32(target_schp->sched_priority); - unlock_user_struct(target_schp, arg2, 0); - return get_errno(sched_setparam(arg1, &schp)); - } - case TARGET_NR_sched_getparam: - { - struct sched_param *target_schp; - struct sched_param schp; - - if (arg2 == 0) { - return -TARGET_EINVAL; - } - ret = get_errno(sched_getparam(arg1, &schp)); - if (!is_error(ret)) { - if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0)) - return -TARGET_EFAULT; - target_schp->sched_priority = tswap32(schp.sched_priority); - unlock_user_struct(target_schp, arg2, 1); - } - } - return ret; - case TARGET_NR_sched_setscheduler: - { - struct sched_param *target_schp; - struct sched_param schp; - if (arg3 == 0) { - return -TARGET_EINVAL; - } - if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1)) - return -TARGET_EFAULT; - schp.sched_priority = tswap32(target_schp->sched_priority); - unlock_user_struct(target_schp, arg3, 0); - return get_errno(sched_setscheduler(arg1, arg2, &schp)); - } - case TARGET_NR_sched_getscheduler: - return get_errno(sched_getscheduler(arg1)); - case TARGET_NR_sched_yield: - return get_errno(sched_yield()); - case TARGET_NR_sched_get_priority_max: - return get_errno(sched_get_priority_max(arg1)); - case TARGET_NR_sched_get_priority_min: - return get_errno(sched_get_priority_min(arg1)); - case TARGET_NR_sched_rr_get_interval: - { - struct timespec ts; - ret = get_errno(sched_rr_get_interval(arg1, &ts)); - if (!is_error(ret)) { - ret = host_to_target_timespec(arg2, &ts); - } - } - return ret; case TARGET_NR_nanosleep: { struct timespec req, rem; @@ -13139,6 +13164,16 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(rt_sigsuspend); SYSCALL(rt_sigtimedwait); SYSCALL(rt_tgsigqueueinfo); + SYSCALL(sched_getaffinity); + SYSCALL(sched_getparam); + SYSCALL(sched_get_priority_max); + SYSCALL(sched_get_priority_min); + SYSCALL(sched_getscheduler); + SYSCALL(sched_rr_get_interval); + SYSCALL(sched_setaffinity); + SYSCALL(sched_setparam); + SYSCALL(sched_setscheduler); + SYSCALL(sched_yield); #ifdef TARGET_NR_sgetmask SYSCALL(sgetmask); #endif From patchwork Sun Jun 10 03:01:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138121 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2592078lji; Sat, 9 Jun 2018 20:35:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL4VUJTh6x9wOcp+pD9BJpfJ0y/Nhf4+jEYTMcqd3XKowFlNn2GENPTGGoPWZostPw6HBiE X-Received: by 2002:ac8:247c:: with SMTP id d57-v6mr11558505qtd.155.1528601741923; Sat, 09 Jun 2018 20:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601741; cv=none; d=google.com; s=arc-20160816; b=kKWRM91smbpDZCEEGOeUL/ZXeDVwQNG0hh58rxoSdFcYGUgxSg6V3r/mqQNoBKjwci EEyU2hPdaSSSb0sBJ7JW5fg23XUIj1vhZQWBhsMx/d2NNvKX8HqMoHrFBDjC6S3BxNnY MDmRxvFNZfkanp9F+E1J15G348mFnhrAFxXfo+FHXOgpPDlkdDnnLiiWr2179WV1oJza PiheSBcfV4SgGfKL7tBdHtchwRnGga/xp+khBWhZS/yLoxQObaX8Oe1lLFquRyJzYJkb 3g8x6zdxWYwyKYgzWsSCKs3SuJyqmJ7s1ekdk5EapT3cnGa0ys3GyKrYTjL2DB42uTfH q/cw== 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:arc-authentication-results; bh=C35LhXR5lkYDxiW/MvH8SV/CPiKRDq1P2MDlJ0nUK2M=; b=BiHWOz2f4MJK6aWsPVMOl2APslHCq0bzgHCRkp87/nq0AfPRwB8SDtqHWsNgm6PuiN eazlHfSKQsmRjbXnaj296OsFcaO0kTmArmmILLYBQ3ge89cyYSG2QiO2Sz5a/NH9gRfC tEbxz4uh78f8f3bsNkuZCji5V2kDmBQpfeWAbt+UQMGBmvkH670MenNusFox8JVI6zPA InCSeXPWydbqK1UMW0TxBvvOHh0ZUSQCxoOCcWoCrEaVEdqstRr7Jaf7LdzBC6vYgYbV Igx6+WEzXyznt0m4KA2oNusRVXQLCpFNYmUbMo4r26FvttnoSvsxfsRZzT3a4cxMPC6S FY3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Y+uJv/7V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a17-v6si15295196qkc.297.2018.06.09.20.35.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:35:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Y+uJv/7V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr8n-0005aC-Ae for patch@linaro.org; Sat, 09 Jun 2018 23:35:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeu-0003Zo-Kb for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqet-0003zW-6B for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:48 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqes-0003z9-Sw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:47 -0400 Received: by mail-pf0-x242.google.com with SMTP id w7-v6so8479000pfn.9 for ; Sat, 09 Jun 2018 20:04: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=C35LhXR5lkYDxiW/MvH8SV/CPiKRDq1P2MDlJ0nUK2M=; b=Y+uJv/7Va7/S2NlkSRptd5i8qkdL/I3+IxrEhXdlL111vLYAtcQ5l/lf5O/85Jzn7z w4SG98FPzIb7vt1B3IQzK/WmD7U6KZJfEdoaWRJjwa0WSAstU6SlomJpS5azvi00dz4I HwuaqXUltjwGx2BoMzPs9GCgh/UIbKhgZfttE= 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=C35LhXR5lkYDxiW/MvH8SV/CPiKRDq1P2MDlJ0nUK2M=; b=GRYh6rnwkKSGqVlbg06Be1ZzN8j35uWraw8489HKpZ6aICAvjI2VotkjuV/jvzv5Y2 x2erJ+lbZSJczTgiFE0OSdPOAD4YNUFMWcHVM40entwz7cBX+GKUraYJ7q9VFpt5M5Ud kCngaNVqCSWcK6CeiMiV+dAYmyiMIF9Pw5JmeABzeFHHFvasOsthlKVMc+0HqDdltYkv QbTHspSpYAhsznWVbbwkb6ITBZI8NsUP7It2+MYlyC9SLwMIAaLCzTx2i34/PPiHTJbS kju7ABu7/bP0Mkze1zUhwxGStuilDthV/Czeg5/sXgVotm0azHcSD/nkok136k0rEVWL 7mzg== X-Gm-Message-State: APt69E2WZFyx5HY/l0dApI1R0xk3D6zZZIX58xKNqrdCychoujcSv0Ph R29k2tCB9b0jMNuuGTu6EKN4OrxWyp8= X-Received: by 2002:a65:5d8a:: with SMTP id f10-v6mr10635070pgt.119.1528599885694; Sat, 09 Jun 2018 20:04:45 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:37 -1000 Message-Id: <20180610030220.3777-66-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 065/108] linux-user: Split out getcpu, nanosleep, prctl 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 | 214 +++++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 100 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 84f21634c8..ee3a31f06d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8132,6 +8132,24 @@ IMPL(futimesat) } #endif +IMPL(getcpu) +{ + unsigned cpu, node; + abi_long ret; + + ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL, arg2 ? &node : NULL, NULL)); + if (is_error(ret)) { + return ret; + } + if (arg1 && put_user_u32(cpu, arg1)) { + return -TARGET_EFAULT; + } + if (arg2 && put_user_u32(node, arg2)) { + return -TARGET_EFAULT; + } + return ret; +} + #ifdef TARGET_NR_getdents IMPL(getdents) { @@ -9004,6 +9022,25 @@ IMPL(name_to_handle_at) } #endif +IMPL(nanosleep) +{ + struct timespec req, rem; + abi_long ret; + + ret = target_to_host_timespec(&req, arg1); + if (ret < 0) { + return ret; + } + ret = safe_nanosleep(&req, &rem); + if (ret < 0) { + return -host_to_target_errno(errno); + } + if (arg2) { + return host_to_target_timespec(arg2, &rem); + } + return 0; +} + #ifdef TARGET_NR__newselect IMPL(_newselect) { @@ -9237,6 +9274,80 @@ IMPL(ppoll) return ret; } +IMPL(prctl) +{ + int deathsig; + void *name; + abi_long ret; + + switch (arg1) { + case PR_GET_PDEATHSIG: + ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); + if (!is_error(ret) && arg2 && put_user_ual(deathsig, arg2)) { + return -TARGET_EFAULT; + } + return ret; + +#ifdef PR_GET_NAME + case PR_GET_NAME: + name = lock_user(VERIFY_WRITE, arg2, 16, 1); + if (!name) { + return -TARGET_EFAULT; + } + ret = get_errno(prctl(arg1, (uintptr_t)name, arg3, arg4, arg5)); + unlock_user(name, arg2, 16); + return ret; +#endif +#ifdef PR_SET_NAME + case PR_SET_NAME: + name = lock_user(VERIFY_READ, arg2, 16, 1); + if (!name) { + return -TARGET_EFAULT; + } + ret = get_errno(prctl(arg1, (uintptr_t)name, arg3, arg4, arg5)); + unlock_user(name, arg2, 0); + return ret; +#endif +#ifdef TARGET_AARCH64 + case TARGET_PR_SVE_SET_VL: + /* We cannot support either PR_SVE_SET_VL_ONEXEC + or PR_SVE_VL_INHERIT. Therefore, anything above + ARM_MAX_VQ results in EINVAL. */ + ret = -TARGET_EINVAL; + if (arm_feature(cpu_env, ARM_FEATURE_SVE) + && arg2 >= 0 && arg2 <= ARM_MAX_VQ * 16 && !(arg2 & 15)) { + CPUARMState *env = cpu_env; + int old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; + int vq = MAX(arg2 / 16, 1); + + if (vq < old_vq) { + aarch64_sve_narrow_vq(env, vq); + } + env->vfp.zcr_el[1] = vq - 1; + ret = vq * 16; + } + return ret; + + case TARGET_PR_SVE_GET_VL: + ret = -TARGET_EINVAL; + if (arm_feature(cpu_env, ARM_FEATURE_SVE)) { + CPUARMState *env = cpu_env; + ret = ((env->vfp.zcr_el[1] & 0xf) + 1) * 16; + } + return ret; +#endif /* AARCH64 */ + + case PR_GET_SECCOMP: + case PR_SET_SECCOMP: + /* Disable seccomp to prevent the target disabling syscalls we need. */ + return -TARGET_EINVAL; + + default: + /* Most prctl options have no pointer arguments */ + return get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); + } +} + IMPL(preadv) { struct iovec *vec; @@ -11007,106 +11118,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_getcpu: - { - unsigned cpu, node; - ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL, - arg2 ? &node : NULL, - NULL)); - if (is_error(ret)) { - return ret; - } - if (arg1 && put_user_u32(cpu, arg1)) { - return -TARGET_EFAULT; - } - if (arg2 && put_user_u32(node, arg2)) { - return -TARGET_EFAULT; - } - } - return ret; - case TARGET_NR_nanosleep: - { - struct timespec req, rem; - target_to_host_timespec(&req, arg1); - ret = get_errno(safe_nanosleep(&req, &rem)); - if (is_error(ret) && arg2) { - host_to_target_timespec(arg2, &rem); - } - } - return ret; - case TARGET_NR_prctl: - switch (arg1) { - case PR_GET_PDEATHSIG: - { - int deathsig; - ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); - if (!is_error(ret) && arg2 - && put_user_ual(deathsig, arg2)) { - return -TARGET_EFAULT; - } - return ret; - } -#ifdef PR_GET_NAME - case PR_GET_NAME: - { - void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); - if (!name) { - return -TARGET_EFAULT; - } - ret = get_errno(prctl(arg1, (unsigned long)name, - arg3, arg4, arg5)); - unlock_user(name, arg2, 16); - return ret; - } - case PR_SET_NAME: - { - void *name = lock_user(VERIFY_READ, arg2, 16, 1); - if (!name) { - return -TARGET_EFAULT; - } - ret = get_errno(prctl(arg1, (unsigned long)name, - arg3, arg4, arg5)); - unlock_user(name, arg2, 0); - return ret; - } -#endif -#ifdef TARGET_AARCH64 - case TARGET_PR_SVE_SET_VL: - /* We cannot support either PR_SVE_SET_VL_ONEXEC - or PR_SVE_VL_INHERIT. Therefore, anything above - ARM_MAX_VQ results in EINVAL. */ - ret = -TARGET_EINVAL; - if (arm_feature(cpu_env, ARM_FEATURE_SVE) - && arg2 >= 0 && arg2 <= ARM_MAX_VQ * 16 && !(arg2 & 15)) { - CPUARMState *env = cpu_env; - int old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; - int vq = MAX(arg2 / 16, 1); - - if (vq < old_vq) { - aarch64_sve_narrow_vq(env, vq); - } - env->vfp.zcr_el[1] = vq - 1; - ret = vq * 16; - } - return ret; - case TARGET_PR_SVE_GET_VL: - ret = -TARGET_EINVAL; - if (arm_feature(cpu_env, ARM_FEATURE_SVE)) { - CPUARMState *env = cpu_env; - ret = ((env->vfp.zcr_el[1] & 0xf) + 1) * 16; - } - return ret; -#endif /* AARCH64 */ - case PR_GET_SECCOMP: - case PR_SET_SECCOMP: - /* Disable seccomp to prevent the target disabling syscalls we - * need. */ - return -TARGET_EINVAL; - default: - /* Most prctl options have no pointer arguments */ - return get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); - } - break; #ifdef TARGET_NR_arch_prctl case TARGET_NR_arch_prctl: #if defined(TARGET_I386) && !defined(TARGET_ABI32) @@ -13004,6 +13015,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif + SYSCALL(getcpu); #ifdef TARGET_NR_getdents SYSCALL(getdents); #endif @@ -13099,6 +13111,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif + SYSCALL(nanosleep); #ifdef TARGET_NR__newselect SYSCALL(_newselect); #endif @@ -13124,6 +13137,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(poll); #endif SYSCALL(ppoll); + SYSCALL(prctl); SYSCALL(preadv); SYSCALL(pselect6); SYSCALL(pwritev); From patchwork Sun Jun 10 03:01:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138153 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2604884lji; Sat, 9 Jun 2018 21:00:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKzLheqnPgSaQ3fSrnnWs7Yzj5bQvEEZ/JiwVD6k6l/a1EaRsX62sFSYE7OUZCXNWGYgky4 X-Received: by 2002:ac8:328d:: with SMTP id z13-v6mr11589930qta.305.1528603202095; Sat, 09 Jun 2018 21:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603202; cv=none; d=google.com; s=arc-20160816; b=1BzTtOmOTI/qMNgoUCjuCm+N2hIyy+/d9gQFcVbLJNY0xCoC9+ZNOpqVBb5jR+b5m0 r7iHSF4FAHOjGmIUHadoFDeuDzdVngC/3OW5l7k+GzBqFOOJJYNwVv8b8dOjBp8tsSRI InoRey+nE6HDt0+S6ZpL2M3nLXGIsYH9aAqC0/z4AMdlWEOhZdiGsxpFHZnRFWWRubSv 5h1WSyi0G9xMJioQmYIgOaXF9LYdxV8sa/lTWx+5E4+UNLg4L6eF8N6RQjHOT12fEw/7 N/w5mbx8oUiOFDXR1ZwjGMz3MaPy18bFcstEIhZCeam1oKb80i/6EiU+ZxavysOCuXIB IY8A== 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:arc-authentication-results; bh=9+MuT/uQabhArjlyjrnItekracZ5fkskfajdM8mX/fY=; b=QJi9kDfmrD7BCABboLwOV0JEF+LqiYI0n5td/zSTfzkqsyTWPTykeJBfNbKGafrIeY AoNwUMOQ1GTIWoYazpCsm4q57NzXi89vT8hd+RSMLIJHZSc1nCDKPBlkzaFOAINkEE34 Fq69brSX98d712/g5VAFaa0cUUay2f7OYFC3Jqn4Mm/372hJ90BL7uUy4ZAIQE8RRIHY C3Ta2bHfEfEYnB30ZfpGFRdF+tMiSmuN8sz9e+d1kBlngGqq2dkEFuNXjFkbo2a9uTie Roumt4zXjHes+3XgCRE2U2vMzah8ylCqPStBsei/7uJy94MUG9EW0nOjm4HD91vlGbvs j4XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XfcSpRPY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x76-v6si302723qkb.248.2018.06.09.21.00.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:00:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XfcSpRPY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrWL-0004QC-Fz for patch@linaro.org; Sun, 10 Jun 2018 00:00:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqev-0003ah-GM for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeu-00041P-Nd for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:49 -0400 Received: from mail-pl0-x231.google.com ([2607:f8b0:400e:c01::231]:43105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeu-00040q-IG for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:48 -0400 Received: by mail-pl0-x231.google.com with SMTP id c41-v6so10385516plj.10 for ; Sat, 09 Jun 2018 20:04: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=9+MuT/uQabhArjlyjrnItekracZ5fkskfajdM8mX/fY=; b=XfcSpRPY4PRFNbf+VV217fGBcQ6KBvQjhZ3Ec0sU5o3X0+dG+gGpauaUbpbZ429tDp MvAqn4vMFDWosVtTpkcZlzRV7CrVupidgQnC8zeK8+jVeS12FA89YawwRUTk97cCHTJd hYoU9AA9XxWfHUHKfAhaHsFhIliPMAtfZnovY= 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=9+MuT/uQabhArjlyjrnItekracZ5fkskfajdM8mX/fY=; b=mBzKAil1WYOynhduKN5l72JmnYOhD3GtzgWU4LyZIgFE7BXlMt4S+Dh+FLscEFvqlE 6TqjYeP1BsxTpkWfOZ0juCF6y577M12h3BuzV1Q/a7/5r6wc/tn6pk9w1r3lGENvAZD7 Vedm8q6VXSY9fwdgd+CM0QD3qXcG2oMcNjRZqQyyxgmD0xQNTOxlgGN7I54LcDOgPI6E /3YrNOpGzr5EKbWeulp87iXqmM/bp2WviRwG8tCzPu0afAAkQ5AnfZYknN7eUPAVGJp3 UlxAd/yS5BCAoVc2+kKdFunPBdAbmkkdrgZpvLyaxcNFBT0XN2WQAJP5owg4RZCvjlsL Dx8Q== X-Gm-Message-State: APt69E1FecwedFKMwSbFsBIRCO/maVrhI/8NSkB5+DiEyYB3/7aldcDf 69mS8ytx2oQJMhEGV9taI6qgKHbsb+U= X-Received: by 2002:a17:902:7248:: with SMTP id c8-v6mr13079820pll.128.1528599887360; Sat, 09 Jun 2018 20:04:47 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:38 -1000 Message-Id: <20180610030220.3777-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::231 Subject: [Qemu-devel] [PATCH v2 066/108] linux-user: Split out arch_prctl 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 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ee3a31f06d..e3765069ab 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7680,6 +7680,17 @@ IMPL(alarm) } #endif +#ifdef TARGET_NR_arch_prctl +IMPL(arch_prctl) +{ +# if defined(TARGET_I386) && !defined(TARGET_ABI32) + return do_arch_prctl(cpu_env, arg1, arg2); +# else +# error unreachable +# endif +} +#endif + #ifdef TARGET_NR_bind IMPL(bind) { @@ -11118,14 +11129,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_arch_prctl - case TARGET_NR_arch_prctl: -#if defined(TARGET_I386) && !defined(TARGET_ABI32) - return do_arch_prctl(cpu_env, arg1, arg2); -#else -#error unreachable -#endif -#endif #ifdef TARGET_NR_pread64 case TARGET_NR_pread64: if (regpairs_aligned(cpu_env, num)) { @@ -12961,6 +12964,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_alarm SYSCALL(alarm); #endif +#ifdef TARGET_NR_arch_prctl + SYSCALL(arch_prctl); +#endif #ifdef TARGET_NR_bind SYSCALL(bind); #endif From patchwork Sun Jun 10 03:01:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138138 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2598957lji; Sat, 9 Jun 2018 20:48:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI66zchK09hLYW0a5FDeUKfggpCW8x2H17I34BcLj+s7lJSGzp+QPmCqRXvKdS0nHQ4/MjY X-Received: by 2002:a0c:8c0b:: with SMTP id n11-v6mr10923490qvb.228.1528602521720; Sat, 09 Jun 2018 20:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602521; cv=none; d=google.com; s=arc-20160816; b=Vkbued6WF6yzmUKih0VtrEQQJ/4AooctjFkUzKfw+l7HQTBpaYb6+KiA19gbgafuT5 wPdCHVspvvwbrOmzqVbLnnqbbZHTOC/qp+I7QQdJIxMhnw9wPzbyKt6le41jk/pyImv/ ED5NNUoovV18CGREKIYJtlTWMQTRoFy9no+fv5M+o+zRLHSAiL5p3rDEoOU6e0scNuPu aJrxFhY/BSNEzrF1rauK2SB3mrkanA1l6GX/vXcxgu2/j8NywZVcEP1NkaxoA01VuuiE 3uQ8nd0ocRzYbQ/qkcvL/6B5kh66By7unLh+lOTmSnKekExYN3gNQdVFA4YZRbEqTObm TyMQ== 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:arc-authentication-results; bh=irHbyPS+1lITcWMlCJqtgZWg28HnELfB+tyG6dr8bXU=; b=qJrGie/gYH5hJ9sVU2fVM8sGin5zI+RVBCNvjKagEH+OpVMHXK7ACmbzo5B9jEZDYf kwuUoNFT/hFEVChdsdlYJdIcrJhsM8xAM5nQqABxtS1j3SBOuUzdmajkkQBg9t3ZkzP+ K7ru3bqkE6PjQSuHbioPUzB+LvBLMO3E7GlL8yBFWGdFuinTKxBcV82gUzoAyBkX52Tf qyveGZUsQK2L8O2k4wDowKsH+yQ5cOCY04eMYCQ0YyvPPEF5FEcNpfsiz8/pbdfWoHMm BrcuAZgRVWTulEjxTbXAzbMkcTbAg6Hv+eLAnnfu9FIaH1CnqzWR9txDrNOit38rDcPM bTHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BqNWYVvh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d36-v6si1708278qtk.281.2018.06.09.20.48.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BqNWYVvh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrLN-0001Qb-4q for patch@linaro.org; Sat, 09 Jun 2018 23:48:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqex-0003cy-PF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqew-00044M-OR for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:51 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqew-00043V-Hz for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:50 -0400 Received: by mail-pf0-x241.google.com with SMTP id a12-v6so8499528pfi.3 for ; Sat, 09 Jun 2018 20:04: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=irHbyPS+1lITcWMlCJqtgZWg28HnELfB+tyG6dr8bXU=; b=BqNWYVvhfuiYS9Z9E5+E4fUruHJgeCxkb3WK0zA9det/rnPuATyf6yJz3rnUcYLD1t Wpz1ugkvXZQaIFrPbp7tTSaFwSU05a7WD6qVzwmWgzwgSu11dnmCvlvXeUlegCF92F9d cYDczu8pbJcOpmvsFVc/geyo8KHKQETUFM+KM= 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=irHbyPS+1lITcWMlCJqtgZWg28HnELfB+tyG6dr8bXU=; b=jejfpsu3E6IExklQKJLgW1TaeE2iH6j08MYGJRq+A8LNmlKJAHVhd6Y1qE8mspY6sx YnIe7YRO+qxhauBEL0UEJsJGsGO9ZTBW4MDG3p/GAasIf27Q8ZWJFWbn0ZD2lKCKdVnG gLmEwCH/0rVyJ810VH7l+7B9texTS1MT0UwPbYNFFtd57+nG81OQSkbeaPFYVL2w/bEb 9LE6VlR1sHK8LP3cgG4eg4xYHjpP2gd9XvWUfkabOA2LZsKv8Jkk5OCzTPPgm8XWjzog yRbwjufnO2twy5V7QY6tolPguStIFlXyVzZccX1YERXMI0rgOoBN+MX6QXyhvC/KcUmb +U3Q== X-Gm-Message-State: APt69E0/8kTaeUCP4yjgxP4aRYgst/ZnqAymYDr5rBKPRi7BGWooeHzd agIBexiuliBCrx7ftikllCoPz4S3ANA= X-Received: by 2002:a62:a104:: with SMTP id b4-v6mr12279064pff.159.1528599889350; Sat, 09 Jun 2018 20:04:49 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:39 -1000 Message-Id: <20180610030220.3777-68-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 067/108] linux-user: Split out getcwd, pread64, pwrite64, sigaltstack 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 define pread64 and pwrite64; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 88 ++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 32 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e3765069ab..1e1ac8defd 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8161,6 +8161,19 @@ IMPL(getcpu) return ret; } +IMPL(getcwd) +{ + char *p = lock_user(VERIFY_WRITE, arg1, arg2, 0); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_getcwd1(p, arg2)); + unlock_user(p, arg1, ret); + return ret; +} + #ifdef TARGET_NR_getdents IMPL(getdents) { @@ -9359,6 +9372,23 @@ IMPL(prctl) } } +IMPL(pread64) +{ + void *p = lock_user(VERIFY_WRITE, arg2, arg3, 0); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + if (regpairs_aligned(cpu_env, TARGET_NR_pread64)) { + arg4 = arg5; + arg5 = arg6; + } + ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); + unlock_user(p, arg2, ret); + return ret; +} + IMPL(preadv) { struct iovec *vec; @@ -9478,6 +9508,23 @@ IMPL(pselect6) return ret; } +IMPL(pwrite64) +{ + void *p = lock_user(VERIFY_READ, arg2, arg3, 1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + if (regpairs_aligned(cpu_env, TARGET_NR_pwrite64)) { + arg4 = arg5; + arg5 = arg6; + } + ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); + unlock_user(p, arg2, 0); + return ret; +} + IMPL(pwritev) { struct iovec *vec; @@ -10359,6 +10406,11 @@ IMPL(sigaction) } #endif +IMPL(sigaltstack) +{ + return do_sigaltstack(arg1, arg2, get_sp_from_cpustate(cpu_env)); +} + #ifdef TARGET_NR_sigpending IMPL(sigpending) { @@ -11129,34 +11181,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_pread64 - case TARGET_NR_pread64: - if (regpairs_aligned(cpu_env, num)) { - arg4 = arg5; - arg5 = arg6; - } - if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) - 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 (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) - 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))) - return -TARGET_EFAULT; - ret = get_errno(sys_getcwd1(p, arg2)); - unlock_user(p, arg1, ret); - return ret; case TARGET_NR_capget: case TARGET_NR_capset: { @@ -11227,10 +11251,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, } return ret; } - case TARGET_NR_sigaltstack: - return do_sigaltstack(arg1, arg2, - get_sp_from_cpustate((CPUArchState *)cpu_env)); - #ifdef CONFIG_SENDFILE case TARGET_NR_sendfile: { @@ -13022,6 +13042,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(futimesat); #endif SYSCALL(getcpu); + SYSCALL(getcwd); #ifdef TARGET_NR_getdents SYSCALL(getdents); #endif @@ -13144,8 +13165,10 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(ppoll); SYSCALL(prctl); + SYSCALL(pread64); SYSCALL(preadv); SYSCALL(pselect6); + SYSCALL(pwrite64); SYSCALL(pwritev); SYSCALL(read); #ifdef TARGET_NR_readlink @@ -13254,6 +13277,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif + SYSCALL(sigaltstack); #ifdef TARGET_NR_sigpending SYSCALL(sigpending); #endif From patchwork Sun Jun 10 03:01:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138139 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2599197lji; Sat, 9 Jun 2018 20:49:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK/uAEF4FtYcd5txzX8JJIIapGO9bBWAqwNEZRtDBUONHruXQQ9U7FgXQ4UJaNEXO637tNo X-Received: by 2002:aed:24aa:: with SMTP id t39-v6mr11838662qtc.253.1528602550553; Sat, 09 Jun 2018 20:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602550; cv=none; d=google.com; s=arc-20160816; b=C3Td92FWm48Qa4xv9CrxsO46H6CdDOPYSdkxr2/2K0gkSGyofYSbBDlZG+tOIV2/W1 CRkj8y3eFJCjv/A3ITsFPWPS6g4C+BZiJsAjwxF+UtOx6MyOKG7O1NLbwW+FQbH8wsX0 QVdoQa+9hZnjW3Um4TiKAIn2tTpyNc6JiRxdzyQQn3zqfJVsC10z/uAZbPTLV3ykAgnF WoUjxhls6E1A54fN12EOokL7AsnWROILPVAah9lqvrUYXPi6r0yJXJlSVCnk2hcE7A8y HszdxVvrSQn9ZNNO0rnSBKrDvEVM8UFkdTkwYOnhJui7YhMk7gi1d+WaG6PC9byMghx+ PbJA== 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:arc-authentication-results; bh=w08wgPKrKdruduYDw0BSz8pPv8SAxVK5e/RpTln5atg=; b=G8nbgi452wB3a+4DhNDPCgv+gPHlPozJTcBeq4jShw4svc8QVln6xG0SwsSveKy5/e uicainyFCXKwOqiqXqyYi+KYssxPbuXPLAfUa+QqykG2RWVjW5SuZAqWCen8HBH0p7u6 gVV/QKo41gcSwYIYThC6j4bfvvMY7d+6JGiVO7+r0fhPTHxoI0I+JaYvQgoUmcBJBPFo WgqH7pX60igzWGttpHdvkYdhd3u6q7ZfnwsU/mtatlovq4+sJW31kJjEnOK/4Vk0lfEs Ot6xw7k7YWe0CD7TyzN+HLzhn6A8M1Cy0deintYBJ36lZmZCoHZRKuaSQprNlrGfwC1l is6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q8IYHJ/k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n67-v6si22260247qkc.152.2018.06.09.20.49.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:49:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q8IYHJ/k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrLp-0001Ub-T5 for patch@linaro.org; Sat, 09 Jun 2018 23:49:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqez-0003ed-ND for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqey-00046p-D9 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:53 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:39883) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqey-000465-4u for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:52 -0400 Received: by mail-pl0-x241.google.com with SMTP id f1-v6so10400347plt.6 for ; Sat, 09 Jun 2018 20:04: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=w08wgPKrKdruduYDw0BSz8pPv8SAxVK5e/RpTln5atg=; b=Q8IYHJ/kkzfhbPVPM9qNQw2pmmj2s5MGofQVtvXDbRcvSI4wcg3t/lmI5NfTGYuoMx nAAWnpOiKkmrHYluoI5kQb4saDfy8UaBym2d4P72rywOs+f2PYGiY2Ho2sNaM6J6Wrpj m8k+kBEeke8+m0efpbG2wAIyahMQZCyCRtGlM= 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=w08wgPKrKdruduYDw0BSz8pPv8SAxVK5e/RpTln5atg=; b=gow8ha7dWdGePB40HEhsziKRXUQAMc1SbD1Kr+2QK12DUSEhnpYfbsRJ+hkdALQq0/ aYbP/Q+x7wsyTHra5sLXzwGfZdYX/HGJfPonTE1i60Akb6OPqujE3fIsRU+t1dWrqTM2 hcxeOafm3jaPPZq6IiXunKcSlNO/zkuj8Zvo5XaqZI/QBB4lrP1BWabLnY9T4P6kNxe4 Pv5un/YO4yax/6in0TQBr0HPrU4HLfZkUA7GXdq1mFJNgQg/wnA3w+LUJQLkDNdLVcps G8WUWKU2UwJ+09M94BNIC9ZZfbZolI8T5Qzm530D9pSog7eA5PrmhfJjpOWnI1jxYZ/0 pw4A== X-Gm-Message-State: APt69E2m0PNhmpZmSf6pwDMyR3FJj0ljMK88zZQ0yKrJp0QOAgkZO68l biCDyNP1dEJHjHaI6GPB4HPyHaiioOk= X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr12966032plv.176.1528599890995; Sat, 09 Jun 2018 20:04:50 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:40 -1000 Message-Id: <20180610030220.3777-69-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 068/108] linux-user: Split out capget, capset 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 | 156 ++++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 70 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1e1ac8defd..c906719152 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7703,6 +7703,90 @@ IMPL(brk) return do_brk(arg1); } +IMPL(capget) +{ + struct target_user_cap_header *target_header; + struct __user_cap_header_struct header; + struct __user_cap_data_struct data[2]; + int data_items; + abi_long ret; + + if (!lock_user_struct(VERIFY_WRITE, target_header, arg1, 1)) { + return -TARGET_EFAULT; + } + header.version = tswap32(target_header->version); + header.pid = tswap32(target_header->pid); + + /* Version 2 and up takes pointer to two user_data structs */ + data_items = (header.version == _LINUX_CAPABILITY_VERSION ? 1 : 2); + + ret = get_errno(capget(&header, arg2 ? data : NULL)); + + /* The kernel always updates version for both capget and capset */ + target_header->version = tswap32(header.version); + unlock_user_struct(target_header, arg1, 1); + + if (arg2) { + struct target_user_cap_data *target_data; + int target_datalen = sizeof(*target_data) * data_items; + int i; + + target_data = lock_user(VERIFY_WRITE, arg2, target_datalen, 0); + if (!target_data) { + return -TARGET_EFAULT; + } + for (i = 0; i < data_items; i++) { + target_data[i].effective = tswap32(data[i].effective); + target_data[i].permitted = tswap32(data[i].permitted); + target_data[i].inheritable = tswap32(data[i].inheritable); + } + unlock_user(target_data, arg2, target_datalen); + } + return ret; +} + +IMPL(capset) +{ + struct target_user_cap_header *target_header; + struct __user_cap_header_struct header; + struct __user_cap_data_struct data[2]; + abi_long ret; + + if (!lock_user_struct(VERIFY_WRITE, target_header, arg1, 1)) { + return -TARGET_EFAULT; + } + header.version = tswap32(target_header->version); + header.pid = tswap32(target_header->pid); + + if (arg2) { + /* Version 2 and up takes pointer to two user_data structs */ + int data_items = (header.version == _LINUX_CAPABILITY_VERSION ? 1 : 2); + struct target_user_cap_data *target_data; + int target_datalen = sizeof(*target_data) * data_items; + int i; + + target_data = lock_user(VERIFY_READ, arg2, target_datalen, 1); + if (!target_data) { + unlock_user_struct(target_header, arg1, 0); + return -TARGET_EFAULT; + } + + for (i = 0; i < data_items; i++) { + data[i].effective = tswap32(target_data[i].effective); + data[i].permitted = tswap32(target_data[i].permitted); + data[i].inheritable = tswap32(target_data[i].inheritable); + } + unlock_user(target_data, arg2, 0); + } + + ret = get_errno(capset(&header, arg2 ? data : NULL)); + + /* The kernel always updates version for both capget and capset */ + target_header->version = tswap32(header.version); + unlock_user_struct(target_header, arg1, 1); + return ret; +} + IMPL(chdir) { char *p = lock_user_string(arg1); @@ -11181,76 +11265,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_capget: - case TARGET_NR_capset: - { - struct target_user_cap_header *target_header; - struct target_user_cap_data *target_data = NULL; - struct __user_cap_header_struct header; - struct __user_cap_data_struct data[2]; - struct __user_cap_data_struct *dataptr = NULL; - int i, target_datalen; - int data_items = 1; - - if (!lock_user_struct(VERIFY_WRITE, target_header, arg1, 1)) { - return -TARGET_EFAULT; - } - header.version = tswap32(target_header->version); - header.pid = tswap32(target_header->pid); - - if (header.version != _LINUX_CAPABILITY_VERSION) { - /* Version 2 and up takes pointer to two user_data structs */ - data_items = 2; - } - - target_datalen = sizeof(*target_data) * data_items; - - if (arg2) { - if (num == TARGET_NR_capget) { - target_data = lock_user(VERIFY_WRITE, arg2, target_datalen, 0); - } else { - target_data = lock_user(VERIFY_READ, arg2, target_datalen, 1); - } - if (!target_data) { - unlock_user_struct(target_header, arg1, 0); - return -TARGET_EFAULT; - } - - if (num == TARGET_NR_capset) { - for (i = 0; i < data_items; i++) { - data[i].effective = tswap32(target_data[i].effective); - data[i].permitted = tswap32(target_data[i].permitted); - data[i].inheritable = tswap32(target_data[i].inheritable); - } - } - - dataptr = data; - } - - if (num == TARGET_NR_capget) { - ret = get_errno(capget(&header, dataptr)); - } else { - ret = get_errno(capset(&header, dataptr)); - } - - /* The kernel always updates version for both capget and capset */ - target_header->version = tswap32(header.version); - unlock_user_struct(target_header, arg1, 1); - - if (arg2) { - if (num == TARGET_NR_capget) { - for (i = 0; i < data_items; i++) { - target_data[i].effective = tswap32(data[i].effective); - target_data[i].permitted = tswap32(data[i].permitted); - target_data[i].inheritable = tswap32(data[i].inheritable); - } - unlock_user(target_data, arg2, target_datalen); - } else { - unlock_user(target_data, arg2, 0); - } - } - return ret; - } #ifdef CONFIG_SENDFILE case TARGET_NR_sendfile: { @@ -12991,6 +13005,8 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(bind); #endif SYSCALL(brk); + SYSCALL(capget); + SYSCALL(capset); #ifdef CONFIG_CLOCK_ADJTIME SYSCALL(clock_adjtime); #endif From patchwork Sun Jun 10 03:01:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138129 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2595051lji; Sat, 9 Jun 2018 20:41:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIuiRfT7C728ThP4KF0ybie9lbOHekebXVu+ctQL5UjAt8qvNZavm078bqXJBbtI89yDfkQ X-Received: by 2002:ac8:4603:: with SMTP id p3-v6mr11767453qtn.418.1528602073367; Sat, 09 Jun 2018 20:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602073; cv=none; d=google.com; s=arc-20160816; b=mwYU2NFZVbFJys/KWnrCdIeA+YHbeMGqfVQJvlvnMSw6SXRdrVepE4EK5tfYWX+jh9 Vp7Rlpj0Ufh374kOsc/LtirXxrnbreVcPxMBRD+sriUiQBqxasgNRiKDros/OCjXoWs2 /OwE8dH++yyO+CcDL1j4QwMs/LTna2M8HLYIsUE9gdXIyRqOirYFtbLXd1cA7N2pYhRm mrus7wtwvn3UM0SeRRyYvS8anKRFDRQcNCngvt0Bi1ovy2lbvt/UOJm4/ZdSDZnzZ96s OGMk9pari+lJcoZrgFHYRLET4/hZ7ufDkLDsK7+rb72+4bwwf1kQTt2X3d3vos0CfwuD HRlg== 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:arc-authentication-results; bh=kc0hgGrcRSKNkw5JFcIBERDb7+5rWbSVFM7jobrTo9w=; b=mkDZhrJo5EpNf9iqwVlz4Tlozh76QMc+SXeNcxS0oeuXFzIaNCZ1wJgdOiOP5DYx/i WJq1ydwUmfjDd0cLJJuglg73xNXeqv4eGbvPPaCN+wpPufABUPDK/+3c3NGDovJ9VPFw W/+MT2o5N+Unjuy73mXSTP3FPDVgwpiRJJfxuWsW46UNRm6zh975xeJi6Ep0LWm+jH6f zGucx2dK0BtEm1k1S4XUVHtL+zZkHLpahQTG5saIZ82XJMArxeQWxgvZZdZfddoAfjq9 KvROdlYni4WgjbC0U37kWzoh4AhT9nMQgvzOvMdlwK7TjUg2lejVUh3B64XNwJsJTGGy Wa9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QF6539FI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m42-v6si7794755qvm.136.2018.06.09.20.41.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QF6539FI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrE8-0002WM-PI for patch@linaro.org; Sat, 09 Jun 2018 23:41:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf3-0003hf-Ey for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf0-00048T-6v for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:57 -0400 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:34313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf0-00047e-1k for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:54 -0400 Received: by mail-pg0-x22a.google.com with SMTP id q4-v6so7075239pgr.1 for ; Sat, 09 Jun 2018 20:04: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=kc0hgGrcRSKNkw5JFcIBERDb7+5rWbSVFM7jobrTo9w=; b=QF6539FIIfR9jbBCp97gR1i7qTsurZtQuXlhZk2XEBsPi9VvDJmJM7+D4YaEAN9VNR w93dxJnZwXDcCDTbBpm8kUB3NsKhxXyDCCwvDksdV+/IpyeFhJD+ZLVz1AimU8yYQFY0 qK3leQd/FJ3HjBfTt1CBnMPtFNUFDLPVUnUK4= 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=kc0hgGrcRSKNkw5JFcIBERDb7+5rWbSVFM7jobrTo9w=; b=YDgxJMP5jw6fZnQ9N4CYrS+3XKpRYN6Tz9zWb8vmAenS+yjWDP4mFjE7sSPdwUj9TY G8edpxlIH7S/g0KqF/HA+pSY2aaOFWK6c6VO9xeshilzED2gpg33n7Pb2l3XbsRKB0Yj Luft6YZX7Nvc+L4o5RvodgUYCOthGtNvHw6ABbtDG2lrIy73EXiM6xsgxrlBJzFB/iO6 7HOZdcRq71veFreiOgJ7aeHZ8Klc0Nz4F+FnUx7QkqJItQZm+7Yc96FQPbwRYoCNOYCQ dmN06p3WjUPuVxzEmcS0eMQH1nVuSVLaR6K+Hwnz2EyE02IkjFGxtOM5e2Na5c5gwATg FjIg== X-Gm-Message-State: APt69E3b2HmiJ4iIe5q5A+cuSFCNLqwA80cMSLgB6Vi60SFAbJ0fHRI+ mPN8xD9w8GbrRrVJnvrF45WibgQ43Bw= X-Received: by 2002:a63:83c3:: with SMTP id h186-v6mr10120702pge.298.1528599892796; Sat, 09 Jun 2018 20:04:52 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:41 -1000 Message-Id: <20180610030220.3777-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a Subject: [Qemu-devel] [PATCH v2 069/108] linux-user: Split out sendfile, sendfile64 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 | 92 +++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c906719152..39e416db0b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10284,6 +10284,48 @@ IMPL(send) } #endif +#ifdef CONFIG_SENDFILE +IMPL(sendfile) +{ + abi_long ret; + off_t off; + + if (!arg3) { + return get_errno(sendfile(arg1, arg2, NULL, arg4)); + } + + if (get_user_sal(off, arg3)) { + return -TARGET_EFAULT; + } + ret = get_errno(sendfile(arg1, arg2, &off, arg4)); + if (!is_error(ret) && arg3 && put_user_sal(off, arg3)) { + return -TARGET_EFAULT; + } + return ret; +} + +# ifdef TARGET_NR_sendfile64 +IMPL(sendfile64) +{ + abi_long ret; + off_t off; + + if (!arg3) { + return get_errno(sendfile(arg1, arg2, NULL, arg4)); + } + + if (get_user_s64(off, arg3)) { + return -TARGET_EFAULT; + } + ret = get_errno(sendfile(arg1, arg2, &off, arg4)); + if (!is_error(ret) && arg3 && put_user_s64(off, arg3)) { + return -TARGET_EFAULT; + } + return ret; +} +# endif +#endif /* CONFIG_SENDFILE */ + #ifdef TARGET_NR_sendmsg IMPL(sendmsg) { @@ -11265,50 +11307,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef CONFIG_SENDFILE - case TARGET_NR_sendfile: - { - off_t *offp = NULL; - off_t off; - if (arg3) { - ret = get_user_sal(off, arg3); - if (is_error(ret)) { - return ret; - } - offp = &off; - } - ret = get_errno(sendfile(arg1, arg2, offp, arg4)); - if (!is_error(ret) && arg3) { - abi_long ret2 = put_user_sal(off, arg3); - if (is_error(ret2)) { - ret = ret2; - } - } - return ret; - } -#ifdef TARGET_NR_sendfile64 - case TARGET_NR_sendfile64: - { - off_t *offp = NULL; - off_t off; - if (arg3) { - ret = get_user_s64(off, arg3); - if (is_error(ret)) { - return ret; - } - offp = &off; - } - ret = get_errno(sendfile(arg1, arg2, offp, arg4)); - if (!is_error(ret) && arg3) { - abi_long ret2 = put_user_s64(off, arg3); - if (is_error(ret2)) { - ret = ret2; - } - } - return ret; - } -#endif -#endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: return get_errno(do_fork(cpu_env, @@ -13270,6 +13268,12 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_send SYSCALL(send); #endif +#ifdef CONFIG_SENDFILE + SYSCALL(sendfile); +# ifdef TARGET_NR_sendfile64 + SYSCALL(sendfile64); +# endif +#endif #ifdef TARGET_NR_sendmmsg SYSCALL(sendmmsg); #endif From patchwork Sun Jun 10 03:01:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138132 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2596467lji; Sat, 9 Jun 2018 20:43:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlP20XAXX66mzF411kSZouV9YYBA57vim6OV2pyOYtq/vb7WztWLQpZAi6uQmiLb0e8cys X-Received: by 2002:ac8:1bf0:: with SMTP id m45-v6mr11744915qtk.337.1528602233325; Sat, 09 Jun 2018 20:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602233; cv=none; d=google.com; s=arc-20160816; b=lLIVcR6phqh+zDaLotW9vyoihqlfjQ44lcBbopTlof6WQIgGK3PFZBSTqicxV+Bwqz lB4nCEPPPSSmcZoQkPQ04hkf8H9Wc4cLlhYUBkGmue55wpNcDLpXNHdHpf9G6mgxQBn4 m1mWnf/YdNBdoxEKuyV9sHZrNdlGYLuhqxwcFVMl8pCXSVJ+9iwBbyqsVhxNcMzGE8xt bQBtBRLSSvpg4PzE6p/Ptb8IA6lqxEDXPTiSjYJRGBJXx1oMBQ+vMf7TbJ1Am8UdR/XK iEYjsF/zU/ymn1T1QfrGi6s/s91gHYBgdOgJFt6c/5EmXSHWDYGjL7YufSJsMl3ui60F WJkw== 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:arc-authentication-results; bh=Dy18omCGqsPmW0DQ04jlvLVm4Iv1FbJd+HMNkW7NmX8=; b=C+pErNMsHPwMgG2MBPxlSMR7bRQs7okKGOG9tmv1d+WyiHBGH+tuvY7zB+93Xg4Ayw /hHAO3jaEBwdXsreeDhZmzKiFKF8g4BL4ytqNg5h3hGYH7LB57DUhiZ6J7wlb4bTOAqb t4p2lw535ZFR8+cYYoiIInBGXALg0uKSBGXJ4VAvKB6zAIKWVMGEoi7NWqNcJQ9VUh5V 85FZzZ0fj8b0kODbnDy4kgmOuv2MDepYSZRWwdKZaSmyHjqEPG227mJFXj2g13La+NlO NKt2ce6UHqn+z8Wa9RlLA5082sc+PMBO/AVPq142/8cPHiEA4UvtNU65TtmiH5bWa04T JPyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UR+TgYc7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v12-v6si2441300qvb.1.2018.06.09.20.43.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UR+TgYc7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrGi-0004n0-NB for patch@linaro.org; Sat, 09 Jun 2018 23:43:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf3-0003he-Ey for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf1-00049Y-V7 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:57 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:38930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf1-00049C-NH for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:55 -0400 Received: by mail-pg0-x244.google.com with SMTP id w12-v6so8139553pgc.6 for ; Sat, 09 Jun 2018 20:04: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=Dy18omCGqsPmW0DQ04jlvLVm4Iv1FbJd+HMNkW7NmX8=; b=UR+TgYc7rX3xGDTZHx8gTrHxUjHYtLKR8bYXrs5Mv5jZuMe80wAUJTWWK9q0NKpHkQ jllOGBluw3l33kSwh741cA6hJ2S+fe0Y3sqy43D/5+d7pARSF+BpTJvVh7dM5uqZ7n0j 0gRAQnBx4eqzTvwfJvsRgbkW0n0mQcwPA/y0c= 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=Dy18omCGqsPmW0DQ04jlvLVm4Iv1FbJd+HMNkW7NmX8=; b=PNRyP90vQLXNXIQbT3LyXn9SrZY4z57vR+L+3lgkZcY/taD3+7fCT8lv9ekoRLGasU p6iyUoYf+TidzKgSgL8JghHpJGcv3jvvOJSZedkt3TBF8j+JmDBzh7Y7AvxF7ren5uKZ rwV/zbCxIqiYhk7ZYkhWIfuW4iIULiqjdKFMB7I3hG4r7CoM6Bii1FxOJuy401TUYuaV m4mu60QohOH1qjdXBSWFvcfS2qVtw3Bzq+Lzd3WqLKNa/T7FSDHUtlJGar7MM7X8WUrN Msc1mZW0iH+SFCTwqgv3WYqZMv9eTFuBNv1PXPtqtdWgMQw6uY98qDjTWl7y/FLW8KFI beQg== X-Gm-Message-State: APt69E0sX70KsJ8dQwV5Rx9+w67PVusVpDO9+6hgD8IcNRMwWKNQOHT1 I/NN6aS9Pkhh81lB19j1wZ1EKKVSuQ0= X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr10424887pgp.221.1528599894553; Sat, 09 Jun 2018 20:04:54 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:42 -1000 Message-Id: <20180610030220.3777-71-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 070/108] linux-user: Split out ftruncate64, truncate64, ugetrlimit, 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 133 +++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 63 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 39e416db0b..c2dc7131bb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6718,34 +6718,6 @@ static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) } #endif /* TARGET_ABI_BITS != 32 */ -#ifdef TARGET_NR_truncate64 -static inline abi_long target_truncate64(void *cpu_env, const char *arg1, - abi_long arg2, - abi_long arg3, - abi_long arg4) -{ - if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { - arg2 = arg3; - arg3 = arg4; - } - return get_errno(truncate64(arg1, target_offset64(arg2, arg3))); -} -#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) { @@ -8204,6 +8176,17 @@ IMPL(ftruncate) return get_errno(ftruncate(arg1, arg2)); } +#ifdef TARGET_NR_ftruncate64 +IMPL(ftruncate64) +{ + if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { + arg2 = arg3; + arg3 = arg4; + } + return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); +} +#endif + #ifdef TARGET_NR_futimesat IMPL(futimesat) { @@ -11048,6 +11031,45 @@ IMPL(truncate) return ret; } +#ifdef TARGET_NR_truncate64 +IMPL(truncate64) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { + arg2 = arg3; + arg3 = arg4; + } + ret = get_errno(truncate64(p, target_offset64(arg2, arg3))); + unlock_user(p, arg1, 0); + return ret; +} +#endif + +#ifdef TARGET_NR_ugetrlimit +IMPL(ugetrlimit) +{ + struct rlimit rlim; + int resource = target_to_host_resource(arg1); + abi_long ret = get_errno(getrlimit(resource, &rlim)); + + if (!is_error(ret)) { + struct target_rlimit *target_rlim; + 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 + IMPL(umask) { return get_errno(umask(arg1)); @@ -11183,6 +11205,14 @@ IMPL(utimes) } #endif +#ifdef TARGET_NR_vfork +IMPL(vfork) +{ + return get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD, + 0, 0, 0, 0)); +} +#endif + IMPL(vhangup) { return get_errno(vhangup()); @@ -11307,41 +11337,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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: - { - struct rlimit rlim; - int resource = target_to_host_resource(arg1); - ret = get_errno(getrlimit(resource, &rlim)); - if (!is_error(ret)) { - struct target_rlimit *target_rlim; - 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 -#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))) { @@ -13052,6 +13047,9 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(fsync); SYSCALL(ftruncate); +#ifdef TARGET_NR_ftruncate64 + SYSCALL(ftruncate64); +#endif #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif @@ -13352,6 +13350,12 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(times); SYSCALL(truncate); +#ifdef TARGET_NR_truncate64 + SYSCALL(truncate64); +#endif +#ifdef TARGET_NR_ugetrlimit + SYSCALL(ugetrlimit); +#endif SYSCALL(umask); #ifdef TARGET_NR_umount SYSCALL(umount); @@ -13367,6 +13371,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_utimes SYSCALL(utimes); +#endif +#ifdef TARGET_NR_vfork + SYSCALL(vfork); #endif SYSCALL(vhangup); #if defined(TARGET_I386) && !defined(TARGET_X86_64) From patchwork Sun Jun 10 03:01:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138143 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600670lji; Sat, 9 Jun 2018 20:51:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK65YHOBp2lTWZoGpsawzaubPc7+UR8cWcRP/QFrx+HVsXokhpegHNIcgcwxaIfkcs9lQts X-Received: by 2002:a37:7ac2:: with SMTP id v185-v6mr10274286qkc.321.1528602718712; Sat, 09 Jun 2018 20:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602718; cv=none; d=google.com; s=arc-20160816; b=iXicBWIrrhLqALzalUSW6JkUioaQzgwSQ8BennMr5nCfylcE/XGGENU7cbQlWNNax3 2JcZZ5ckB0iFURueLBsYCshLgte5hsJMwE8dngLPHBlc/89A3av8MwlV0TPKdWoHMRiA 2HpRErXHD+hV3i3NPPF+WexVPHJyYok7nF46pwQVGicmAPeIWe/Va5yNeJrranjNwut0 sauDLqPOdCVpJ18augqqjpT4clXgpoY/Z8zazJ0pT+0ojklZuRwnprO/LfcJRgru9h6Z xp+LiyaijmoeCycDuwfxjscnfc63C5hZ4z3i0i7UcOdgAJKnt7+o34qWU6wTr8ZeKBOW 9SiA== 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:arc-authentication-results; bh=x3MiIU0NgMU/ZotHQUHhC0rgCoaYX9fX35dm5DONe24=; b=CZYaKTKdzqslws6iV9+dPsedei0zNdkR7M5Qm9DREjk7k2fDWolDff4Ew5d3+It6Y7 EPyZgX5a49FTxlh01TG8O+TljUs6EjtG67xn89HHd4rYa5DcHSYZ8Xajs07sqoEyB2JF +AkgVk1LGdHF+23D/MzuHqyMpa4BL5Y7JB1jlStdQ/88rwMfapJiBU01jIne6D298dfB ToKCp5VT3Li+3bXyzLkHn2aOCYPJd2xr3UNqlskmuOisU0uUdaWTjFqxHMsg/LH6zPcD 5+EgYvlb0nN4xq9Yicceq7WqP8FXsPxQPfm9qa9Y7lLxOiZXBguzXVxG1BWkdU70H6hY u1Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IsNI5BI7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y9-v6si266544qtf.398.2018.06.09.20.51.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:51:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IsNI5BI7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrOY-0004jS-3X for patch@linaro.org; Sat, 09 Jun 2018 23:51:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf5-0003ic-84 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf3-0004Bp-S8 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:59 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:38122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf3-0004As-Kc for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:57 -0400 Received: by mail-pf0-x243.google.com with SMTP id b74-v6so8494347pfl.5 for ; Sat, 09 Jun 2018 20:04: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=x3MiIU0NgMU/ZotHQUHhC0rgCoaYX9fX35dm5DONe24=; b=IsNI5BI7u0N3XywffqDh4vbvjDqkDxAZ1FFSP1hsOlRUNX4wPNz1u15ICGSU1/NuyX KRVRDhIAR0gLnqz7yYPQ0be+tsgvH1SlwTMojQDqIckxbB81/eb15Y6i2gEBhKkY5B81 lGVp1nTk3zRgKU8GyoC3FhZqApHFVOdi8r3Yg= 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=x3MiIU0NgMU/ZotHQUHhC0rgCoaYX9fX35dm5DONe24=; b=BmXLoY3jdMyteolVzSoQd6gQcgGmPvQF4c8kbOlVByRlU4OGhE9bWyr+M2sh8f3u+r AtmFGByY08SzVP29JZYYWjMaFH+LwXSrzYCQcY6fwBXokq14GncD8mJF+n1RlGCXdgag k67uzB3z+h09YyNWipDjkfuBsP/ue/aVSs5xQYIQjS06YFJfMeA32h9nxFPOH0GmB6Wa +ySuY+4Q63Bk3qj+7Zo4c0tmEHeuce1qgKo1ih1PGA6agp3f7FOyLdFxPqPraJWG5j8D aR6njIJ0M055bGTflNVUFiI0W4dGpFqRbnCRuCdjvgkdG2B5TGLIP6bCljBy9acWmC2o fZTg== X-Gm-Message-State: APt69E3q06V3sG95j0OVSiUY1K+Htmjip2uaEiMI7jBctHW7uMcginul cj5xaY49hYTebZuvnFHvOuGBEp2nKvk= X-Received: by 2002:a63:8c4f:: with SMTP id q15-v6mr10645832pgn.236.1528599896465; Sat, 09 Jun 2018 20:04:56 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:43 -1000 Message-Id: <20180610030220.3777-72-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 071/108] linux-user: Split out fstat64, fstatat64, newfstatat, lstat64, stat64 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" Comment on the odd overlap of fstatat64 and newfstatat, especially with respect to nios2. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 135 ++++++++++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c2dc7131bb..8d6b949b8a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8140,6 +8140,42 @@ IMPL(fstat) return ret; } +#ifdef TARGET_NR_fstat64 +IMPL(fstat64) +{ + struct stat st; + abi_long ret; + + ret = get_errno(fstat(arg1, &st)); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + +/* Some targets name this syscall newfstatat, with the same arguments. */ +/* ??? Our nios2/syscall_nr.h defines both names; the kernel does not. + * Preserve previous behavior and map both syscalls to this function. + */ +IMPL(fstatat64) +{ + char *p; + abi_long ret; + struct stat st; + + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(fstatat(arg1, path(p), &st, arg4)); + unlock_user(p, arg2, 0); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg3, &st)) { + return -TARGET_EFAULT; + } + return ret; +} + IMPL(fstatfs) { struct statfs stfs; @@ -8815,6 +8851,25 @@ IMPL(lstat) } #endif +#ifdef TARGET_NR_lstat64 +IMPL(lstat64) +{ + char *p = lock_user_string(arg1); + struct stat st; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(lstat(path(p), &st)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_mkdir IMPL(mkdir) { @@ -10790,6 +10845,25 @@ IMPL(stat) } #endif +#ifdef TARGET_NR_stat64 +IMPL(stat64) +{ + char *p = lock_user_string(arg1); + struct stat st; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(stat(path(p), &st)); + unlock_user(p, arg1, 0); + if (!is_error(ret) && host_to_target_stat64(cpu_env, arg2, &st)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(statfs) { char *p = lock_user_string(arg1); @@ -11333,55 +11407,9 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, { CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); abi_long ret; - struct stat st; void *p; switch(num) { -#ifdef TARGET_NR_stat64 - case TARGET_NR_stat64: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(stat(path(p), &st)); - unlock_user(p, arg1, 0); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg2, &st); - return ret; -#endif -#ifdef TARGET_NR_lstat64 - case TARGET_NR_lstat64: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(lstat(path(p), &st)); - unlock_user(p, arg1, 0); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg2, &st); - return ret; -#endif -#ifdef TARGET_NR_fstat64 - case TARGET_NR_fstat64: - ret = get_errno(fstat(arg1, &st)); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg2, &st); - return ret; -#endif -#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) -#ifdef TARGET_NR_fstatat64 - case TARGET_NR_fstatat64: -#endif -#ifdef TARGET_NR_newfstatat - case TARGET_NR_newfstatat: -#endif - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(fstatat(arg1, path(p), &st, arg4)); - unlock_user(p, arg2, 0); - if (!is_error(ret)) - ret = host_to_target_stat64(cpu_env, arg3, &st); - return ret; -#endif #ifdef TARGET_NR_lchown case TARGET_NR_lchown: if (!(p = lock_user_string(arg1))) @@ -13041,6 +13069,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fork); #endif SYSCALL(fstat); +#ifdef TARGET_NR_fstat64 + SYSCALL(fstat64); +#endif +#ifdef TARGET_NR_fstatat64 + SYSCALL(fstatat64); +#endif SYSCALL(fstatfs); #ifdef TARGET_NR_fstatfs64 SYSCALL(fstatfs64); @@ -13109,6 +13143,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_lstat SYSCALL(lstat); #endif +#ifdef TARGET_NR_lstat64 + SYSCALL(lstat64); +#endif #ifdef TARGET_NR_mkdir SYSCALL(mkdir); #endif @@ -13151,6 +13188,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(name_to_handle_at); #endif SYSCALL(nanosleep); +#ifdef TARGET_NR_newfstatat + SYSCALL_WITH(newfstatat, fstatat64); +#endif #ifdef TARGET_NR__newselect SYSCALL(_newselect); #endif @@ -13322,6 +13362,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_stat SYSCALL(stat); +#endif +#ifdef TARGET_NR_stat64 + SYSCALL(stat64); #endif SYSCALL(statfs); #ifdef TARGET_NR_statfs64 From patchwork Sun Jun 10 03:01:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138156 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2606955lji; Sat, 9 Jun 2018 21:02:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIK7uTO8pM6/iWF6zZG6pRIUqxfbX4lItqXiET5DS+dWu1I7uzpHn8xhWfPUzuGB7+zJGuA X-Received: by 2002:ac8:3805:: with SMTP id q5-v6mr11936124qtb.410.1528603374407; Sat, 09 Jun 2018 21:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603374; cv=none; d=google.com; s=arc-20160816; b=R0Mjiim7aEQI+SoQ8uQJSENkNtWxvOkN+uTFX3aP+BgZ72F9gEWjhur0HO7qGhgxZi 8D1a+rvrmuCXwl7TyPqp+KTZtfPE20Z+fMuNg9XTsabrbIUuHclmue9sQW4K9LqI2/Xz Y+Y8faQDtbLWzssKOu/3kNurfMjPUOa0CPDCHRyEiVbO0VcMKp3slHWyiIzFLID8eD4D m05xTHtrm6/LG2Q0CwipSTnm3uVJBanOgC4chgcXLajVyao0wq52d5eOH7fHVtlLseNS YVPsBeHoz8CYtZvs0F/U//rwbF2U998TMy4wK2h0EW7ruFQDf8AZV3FAGvOFbGCcZIS+ +byw== 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:arc-authentication-results; bh=iMs2Z8N1qvLee4RKGzCZHqwUUHVJYzMlAhUPAV95u24=; b=H9D6IkgN7rAYq0UmsHONVp7ElhnhRzxEwCEf3GfAI0HezjaELyXdxIkHPXd6wQYuJG jVGfOE4N+uBB1p2N2DQX/dcDrDPnxOaaHU0faUrInQBiRadGYS7dvhVJVnkLwbagzKU8 D4VRdWe7B7BUR0Fr2XH1fhXEcNIOnImhWQrUKl1pH1BX15ysMlBIfPZOhfP+zbxJw9eD jJurJugxxjinXU2+Kq6tCTFfpMPE6UyUhKk6UXdaXArsZ+a7UggbyBdI/XN7YOdC77VY NIOm0nc0aKGfGv+vxtSGv3kOsxDAKpb8kbaMq+bLw+d7UvwMYVHUVSh+S7VhwRpLK8Ib JSrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Hf5DFGMm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 17-v6si9447025qkm.57.2018.06.09.21.02.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:02:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Hf5DFGMm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZ7-0006tJ-SJ for patch@linaro.org; Sun, 10 Jun 2018 00:02:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf7-0003jk-3h for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf5-0004EJ-Ua for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:01 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:44111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf5-0004DM-Mq for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:59 -0400 Received: by mail-pl0-x242.google.com with SMTP id z9-v6so10387518plk.11 for ; Sat, 09 Jun 2018 20:04: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=iMs2Z8N1qvLee4RKGzCZHqwUUHVJYzMlAhUPAV95u24=; b=Hf5DFGMmS6R3yNFJwltXyXMQzjJeEjcrCjnAOSVr2O65Kw5eNo+grrlap1CJRYhAqE /l/j7kgMalSm7yBmXtek01AHsCrwNQPFEpiOVYaHE+iOytMNBX4qB1lYwxYZaf91bYCP 3By6KCSiXkTiQCxA1kya5RO9SNBshcrCZcEQM= 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=iMs2Z8N1qvLee4RKGzCZHqwUUHVJYzMlAhUPAV95u24=; b=WTUqbRH4uJ31FC43SXq+KepJxHWNTjWhNRtJYfVlCkkfQgI969+2zWpt1PGHy9jAuF dnJBLwHInUvVLR0ze3nwrr/ir+I9sDGZdRxZpGSAYNWYccqPX5mUFdJamOrBnElfidIE IBYsGQLHp5sWP7VxSfpg7Mdlqz5GoICPcFZZynR0qYFrUcWyHyOhOfGhnraY6QVJqSPK 78FcQib8C/BJVpbcu7VlIDocNiGDlrhEkACjQpn1T751cSNZeQZlGYrsct3aWJfccgDT rIB2KjD5+DsVdOg3MYXonLtEzCAZ7iC7sqAb2oAP52nnx9TrgCQZ6G4O+kISYT7qzEub p6qQ== X-Gm-Message-State: APt69E1QAj2lSWvjiawHKCu7PFg22LU+uL45H8JLKyC9unTbiYffABe8 vOJEGaeIODMhr/fU6Pi7lWedSPXa+iQ= X-Received: by 2002:a17:902:760e:: with SMTP id k14-v6mr12932756pll.310.1528599898563; Sat, 09 Jun 2018 20:04:58 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:44 -1000 Message-Id: <20180610030220.3777-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 072/108] linux-user: Split out getegid, geteuid, getgid, getuid, lchown 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 | 82 +++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 24 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8d6b949b8a..f8e34d28b1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8441,6 +8441,27 @@ IMPL(getdents64) } #endif /* TARGET_NR_getdents64 */ +#ifdef TARGET_NR_getegid +IMPL(getegid) +{ + return get_errno(high2lowgid(getegid())); +} +#endif + +#ifdef TARGET_NR_geteuid +IMPL(geteuid) +{ + return get_errno(high2lowuid(geteuid())); +} +#endif + +#ifdef TARGET_NR_getgid +IMPL(getgid) +{ + return get_errno(high2lowgid(getgid())); +} +#endif + IMPL(getitimer) { struct itimerval value; @@ -8584,6 +8605,13 @@ IMPL(gettimeofday) return ret; } +#ifdef TARGET_NR_getuid +IMPL(getuid) +{ + return get_errno(high2lowuid(getuid())); +} +#endif + #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) IMPL(getxpid) { @@ -8769,6 +8797,21 @@ IMPL(kill) return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); } +#ifdef TARGET_NR_lchown +IMPL(lchown) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_link IMPL(link) { @@ -11410,30 +11453,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_lchown - case TARGET_NR_lchown: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3))); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_getuid - case TARGET_NR_getuid: - return get_errno(high2lowuid(getuid())); -#endif -#ifdef TARGET_NR_getgid - case TARGET_NR_getgid: - return get_errno(high2lowgid(getgid())); -#endif -#ifdef TARGET_NR_geteuid - case TARGET_NR_geteuid: - return get_errno(high2lowuid(geteuid())); -#endif -#ifdef TARGET_NR_getegid - case TARGET_NR_getegid: - return get_errno(high2lowgid(getegid())); -#endif case TARGET_NR_setreuid: return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); case TARGET_NR_setregid: @@ -13094,6 +13113,15 @@ static impl_fn *syscall_table(unsigned num) #endif #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) SYSCALL(getdents64); +#endif +#ifdef TARGET_NR_getegid + SYSCALL(getegid); +#endif +#ifdef TARGET_NR_geteuid + SYSCALL(geteuid); +#endif +#ifdef TARGET_NR_getgid + SYSCALL(getgid); #endif SYSCALL(getitimer); #ifdef TARGET_NR_getpeername @@ -13121,6 +13149,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getsockopt); #endif SYSCALL(gettimeofday); +#ifdef TARGET_NR_getuid + SYSCALL(getuid); +#endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); #endif @@ -13129,6 +13160,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(ipc); #endif SYSCALL(kill); +#ifdef TARGET_NR_lchown + SYSCALL(lchown); +#endif #ifdef TARGET_NR_link SYSCALL(link); #endif From patchwork Sun Jun 10 03:01:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138136 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2597888lji; Sat, 9 Jun 2018 20:46:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL3DovulgV1SON4F+GbmITVOOhrOFa5aOlsVfr4YWEZo5V0TdDvGQ8p9cX5iSKlx3V0cxT2 X-Received: by 2002:aed:3f36:: with SMTP id p51-v6mr11454746qtf.213.1528602401010; Sat, 09 Jun 2018 20:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602401; cv=none; d=google.com; s=arc-20160816; b=SKVXeISk4ChOiyu+VhwarHesnlcz3QE2u+RYNHXma/xjEL7XN7kREKpYPtdthUV3Y4 PSBI4YJkhzyND/f6fTkzA43jxhqt4tJJQSva8iXejsRlPn+MXK4VgmZjtVTgJsRe1U2H rf7anIhOKSYdJTmlpOTTSWbpxwk6bXCgFdUeRPMTbvUPTZJoN+k4Jm21SemGCJtjxRn3 KBVLqw32xDB+rhbOXvyOk7xlR+cWFwo4e0IRaJq+yjdKlcM4bNXwWyOoMhbFfZs1ivkg YZ6ujg2ftQ6I7xyIsUCbW0LJwDgSAwwyb+3bN7AfRXatuLUeDISTLuhNIgK8xwtvAI/Y mong== 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:arc-authentication-results; bh=d9muHfjUp4Bj3UWUzaKvDRlH2aaTiMZ5LFfnfhySqTI=; b=aMkKL+DAETbtvEqOhwk0FuLOcCkzFL19CaO0S9Bwu/zQu5kO5anwYKFnWwKC4HnKip 56McuvyjETcAaTWJi8djTdx2TKC6AjqrO8p08iQ/1yL5Jw+i042jKoW6JdPppFQnxAIf m/GKRjgmVBhI0+Ljbm6u8bObhs2C8kqMJB+rpX7xQXA5mZslrqaDnFk939O8TfGufDus e7Oc3KJKJ5jQvvE3w+O76OfXUQ1qDaroHuinDk+DUgmCeC+Eve6NW9HCOOlc1S0NLRX5 VMZ5t4l15gU0M1+GPBvEgDSu7x2xmYl8wKIv1Gr/vQcTy58tFO6s7qp+0M8/u1ZPgTQ9 UoXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d8lcKrt8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b44-v6si7573309qtb.263.2018.06.09.20.46.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d8lcKrt8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrJQ-0007wF-BS for patch@linaro.org; Sat, 09 Jun 2018 23:46:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf8-0003nU-S8 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf7-0004H0-Jv for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:02 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:41587) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf7-0004FX-CC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:01 -0400 Received: by mail-pl0-x241.google.com with SMTP id az12-v6so10380824plb.8 for ; Sat, 09 Jun 2018 20:05: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=d9muHfjUp4Bj3UWUzaKvDRlH2aaTiMZ5LFfnfhySqTI=; b=d8lcKrt8PDnMKcoV7/DeUBoS8Rfd4yI8dv70zVvd95e+cGBVlGPL+zBEoffcEBGS05 EQ79tBgZNUTXldAAWPsPoVjMO5CCfbL8yNI8hlsAd/QviHwkuCn77/RwNQ3FxDn0xusv KXaUonT/mZezzO7KT/JifP/4z/+GHqU2AznkY= 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=d9muHfjUp4Bj3UWUzaKvDRlH2aaTiMZ5LFfnfhySqTI=; b=XSBmFTpP4WTZaBNWkKGv8foQIarEp+8x9zChlzsj9QpgrO0UHoCnmCUtpm3wOyok75 RFGUeBNN5VNld4eq5VzPCsBe0TIy+C0vbdkBg88dfhZ8hczzoj5b0YrUGX3QMjEIV5pV RqrEk/ZH1b59Om6kg0jhZwYizWRWmiiKO3YOhSsqw4F5ctyeQcSvwsAlKiR6UdhzRdhy x4VTfOjEQLz6YDzE0xCUu0fKai2uBoxiN8WJbFxdU+kMAX8nYBXreMnJ4tJAJtVl6g9T Lu2U7kDVGQYjlKjxtjQVF63sDvCqoRBhPxEBY2VmWfCKeHR8dSE8LsvW7DQ5+F7yM8ut SH0Q== X-Gm-Message-State: APt69E0lW9exrvCjIB+oSOj5e0GitynLAvd1AjzVfBTtlPk27gKvjwB4 dEq+qyiDbfdW+xq2Tvp8ilpmDcjxoe8= X-Received: by 2002:a17:902:e3:: with SMTP id a90-v6mr3927562pla.227.1528599900257; Sat, 09 Jun 2018 20:05:00 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:45 -1000 Message-Id: <20180610030220.3777-74-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 073/108] linux-user: Split out getgroups, setgroups, setregid, setreuid 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 | 107 +++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f8e34d28b1..915e1f1a91 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8462,6 +8462,32 @@ IMPL(getgid) } #endif +IMPL(getgroups) +{ + int gidsetsize = arg1; + gid_t *grouplist; + abi_long ret; + + grouplist = alloca(gidsetsize * sizeof(gid_t)); + ret = get_errno(getgroups(gidsetsize, grouplist)); + + if (!is_error(ret) && gidsetsize != 0) { + target_id *target_gl; + int i; + + target_gl = lock_user(VERIFY_WRITE, arg2, + gidsetsize * sizeof(target_id), 0); + if (!target_gl) { + return -TARGET_EFAULT; + } + for (i = 0; i < ret; i++) { + target_gl[i] = tswapid(high2lowgid(grouplist[i])); + } + unlock_user(target_gl, arg2, gidsetsize * sizeof(target_id)); + } + return ret; +} + IMPL(getitimer) { struct itimerval value; @@ -10441,6 +10467,29 @@ IMPL(setdomainname) return ret; } +IMPL(setgroups) +{ + int gidsetsize = arg1; + gid_t *grouplist = NULL; + + if (gidsetsize) { + target_id *target_gl; + int i; + + grouplist = alloca(gidsetsize * sizeof(gid_t)); + target_gl = lock_user(VERIFY_READ, arg2, + gidsetsize * sizeof(target_id), 1); + if (!target_gl) { + return -TARGET_EFAULT; + } + for (i = 0; i < gidsetsize; i++) { + grouplist[i] = low2highgid(tswapid(target_gl[i])); + } + unlock_user(target_gl, arg2, 0); + } + return get_errno(setgroups(gidsetsize, grouplist)); +} + IMPL(sethostname) { char *p = lock_user_string(arg1); @@ -10486,6 +10535,16 @@ IMPL(setpriority) return get_errno(setpriority(arg1, arg2, arg3)); } +IMPL(setregid) +{ + return get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); +} + +IMPL(setreuid) +{ + return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); +} + IMPL(setrlimit) { int resource = target_to_host_resource(arg1); @@ -11453,50 +11512,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_setreuid: - return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); - case TARGET_NR_setregid: - return get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); - case TARGET_NR_getgroups: - { - int gidsetsize = arg1; - target_id *target_grouplist; - gid_t *grouplist; - int i; - - grouplist = alloca(gidsetsize * sizeof(gid_t)); - ret = get_errno(getgroups(gidsetsize, grouplist)); - if (gidsetsize == 0) - return ret; - if (!is_error(ret)) { - target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * sizeof(target_id), 0); - if (!target_grouplist) - return -TARGET_EFAULT; - for(i = 0;i < ret; i++) - target_grouplist[i] = tswapid(high2lowgid(grouplist[i])); - unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id)); - } - } - return ret; - case TARGET_NR_setgroups: - { - int gidsetsize = arg1; - target_id *target_grouplist; - gid_t *grouplist = NULL; - int i; - if (gidsetsize) { - grouplist = alloca(gidsetsize * sizeof(gid_t)); - target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1); - if (!target_grouplist) { - return -TARGET_EFAULT; - } - for (i = 0; i < gidsetsize; i++) { - grouplist[i] = low2highgid(tswapid(target_grouplist[i])); - } - unlock_user(target_grouplist, arg2, 0); - } - return get_errno(setgroups(gidsetsize, grouplist)); - } case TARGET_NR_fchown: return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); #if defined(TARGET_NR_fchownat) @@ -13123,6 +13138,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getgid SYSCALL(getgid); #endif + SYSCALL(getgroups); SYSCALL(getitimer); #ifdef TARGET_NR_getpeername SYSCALL(getpeername); @@ -13356,10 +13372,13 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sendto); #endif SYSCALL(setdomainname); + SYSCALL(setgroups); SYSCALL(sethostname); SYSCALL(setitimer); SYSCALL(setpgid); SYSCALL(setpriority); + SYSCALL(setregid); + SYSCALL(setreuid); SYSCALL(setrlimit); #ifdef TARGET_NR_setsockopt SYSCALL(setsockopt); From patchwork Sun Jun 10 03:01:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138155 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2606911lji; Sat, 9 Jun 2018 21:02:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ/2t9VFBVMPEZF9RWKGSX/nsfhmzlbqWFeTqMGLtERu6v/FL9bjMYfMM1r31rqMRkZcyt2 X-Received: by 2002:a0c:93a2:: with SMTP id f31-v6mr10924493qvf.151.1528603370856; Sat, 09 Jun 2018 21:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603370; cv=none; d=google.com; s=arc-20160816; b=QBGFzCy7FUbGBczA1EgWRYjy+GHGnY7qPCd8tQXBDeTiUH4HLoXD8HpyTAQWc6StdG oXX0XHFRa3uAxUZnMg4c9POcvjx/mJtWcpV48gyqlPI+gjy/E48d2Pc0sC5r3hFRyuIh 67OQmiaktg9LuJQCjbo5uadL1syjfRjnzO5Y2hP/aNFBlltgwogjfAdpv89XG807r4Mj A8FOleLtAvH19lZPnNw6Rad8SuUuhj4tYdUoiQ/8dqAn9/jGebOH295ObmVmw2oKZoQI hB0oIvi2ZM3vwNLJvYNAqRdWIEvvWoXxgpURSxnnIkC/PB6p8bjxjdJFYnNzm6RMCp8V m8dA== 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:arc-authentication-results; bh=PAMvoUup1MEEtHTT+kodKawFkMWQPuORADOIcTcuknQ=; b=gbJABDLXKB14N7sWZ6LxOyTghLfSwgtrw0e7Sn18w9qXgSjT0V2hbgw106GVQ3MaBR W1DSBqOBUVHgknp+IfDspVx2jT9tTSmnIOrourg04zfKyr2JOeIrRbpNQ1qau5jN7aIW 2czPTZb4zsQ1HQA80bEOJZ8cduorgfJocQRqO8iDM2amK+HyKmr3CivWQ3PouuS6wImm NhwgIgKkNeegrjfINTbFRbL3wYX6BV1Z8/zfjpLcS7bxF2pq/TfDHKef7wbO+yHwIjhh S5V9bkMmusNMlRmbWXf1/7eIBr/rXWeerH//2UODXXx+yXeJxom0jjXlsavnXtVJqQck hwTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KwyHBJYz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 29-v6si6404824qkv.336.2018.06.09.21.02.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:02:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KwyHBJYz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZ4-0006q8-6c for patch@linaro.org; Sun, 10 Jun 2018 00:02:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfC-0003oH-3i for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf9-0004JO-EX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:06 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:41588) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf9-0004J0-7g for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:03 -0400 Received: by mail-pl0-x242.google.com with SMTP id az12-v6so10380849plb.8 for ; Sat, 09 Jun 2018 20:05: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=PAMvoUup1MEEtHTT+kodKawFkMWQPuORADOIcTcuknQ=; b=KwyHBJYzhxQDZAwsdWuSE35u4KxqKD2T5mqP0XaLiS1bIwPk4ZNvSYzJG2x6e8sx0s MzICptw6WhlC4yf/X4cFzZJYMnKMZ7WtOCpXUZGpIUkoC0P7BZgG2Lujwf0JrEDvPvxN xIQZrnv68/m3CE924k5b+BVulr0JN8tTRSdGw= 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=PAMvoUup1MEEtHTT+kodKawFkMWQPuORADOIcTcuknQ=; b=UK9gQZEMaZegFzLOpIF9vDmzJzk2m+vrAHKEWLw4AF9Ehdr+vxVKf0nb2A4Jy5nt21 kdJ8Syqt7LeEO0h7g9ZsqjAfcUaqpSVUUyFpzFKGcdktHaGBvXXShxyuhq1PGx4MJNVi ZlVDGkQ17kYRtGvKKMmfKODKPLGZ7hU8YwhpR26EO585GxnTSYfHBY9+e8tscs9Xy1jN Jtn0hV5S1Bjygg+cdkZtSGNeH0fIFlmUhiSCXrHfpgO3zTOsnqE1aZTVcrW2clRoLIFN puBgHaEXEU7y6pdYuv/yXejgt3s4HM7fIrOLFOiAOeCPzystyHkWuYwiHTOLcg0Zua3j bapg== X-Gm-Message-State: APt69E0TyGlTGOvXkBGradl32IsuFdlTXOLnyVX/a1R2mQDLLjkGdLSC tsLlQ0nkGUxqhzgNKO2fu0yAqMkXmro= X-Received: by 2002:a17:902:b604:: with SMTP id b4-v6mr12943077pls.18.1528599902081; Sat, 09 Jun 2018 20:05:02 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:46 -1000 Message-Id: <20180610030220.3777-75-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 074/108] linux-user: Split out fchown, fchownat, setresgid, setresuid 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 define fchownat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 66 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 915e1f1a91..75b869fb33 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8103,6 +8103,25 @@ IMPL(fchmodat) return ret; } +IMPL(fchown) +{ + return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); +} + +IMPL(fchownat) +{ + char *p = lock_user_string(arg2); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(fchownat(arg1, p, low2highuid(arg3), + low2highgid(arg4), arg5)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef TARGET_NR_fcntl IMPL(fcntl) { @@ -10540,6 +10559,22 @@ IMPL(setregid) return get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); } +#ifdef TARGET_NR_setresgid +IMPL(setresgid) +{ + return get_errno(sys_setresgid(low2highgid(arg1), low2highgid(arg2), + low2highgid(arg3))); +} +#endif + +#ifdef TARGET_NR_setresuid +IMPL(setresuid) +{ + return get_errno(sys_setresuid(low2highuid(arg1), low2highuid(arg2), + low2highuid(arg3))); +} +#endif + IMPL(setreuid) { return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); @@ -11512,23 +11547,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_fchown: - return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); -#if defined(TARGET_NR_fchownat) - case TARGET_NR_fchownat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(fchownat(arg1, p, low2highuid(arg3), - low2highgid(arg4), arg5)); - unlock_user(p, arg2, 0); - return ret; -#endif -#ifdef TARGET_NR_setresuid - case TARGET_NR_setresuid: - return get_errno(sys_setresuid(low2highuid(arg1), - low2highuid(arg2), - low2highuid(arg3))); -#endif #ifdef TARGET_NR_getresuid case TARGET_NR_getresuid: { @@ -11543,12 +11561,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, } return ret; #endif -#ifdef TARGET_NR_getresgid - case TARGET_NR_setresgid: - return get_errno(sys_setresgid(low2highgid(arg1), - low2highgid(arg2), - low2highgid(arg3))); -#endif #ifdef TARGET_NR_getresgid case TARGET_NR_getresgid: { @@ -13094,6 +13106,8 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fchdir); SYSCALL(fchmod); SYSCALL(fchmodat); + SYSCALL(fchown); + SYSCALL(fchownat); #ifdef TARGET_NR_fcntl SYSCALL(fcntl); #endif @@ -13378,6 +13392,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(setpgid); SYSCALL(setpriority); SYSCALL(setregid); +#ifdef TARGET_NR_setresgid + SYSCALL(setresgid); +#endif +#ifdef TARGET_NR_setresuid + SYSCALL(setresuid); +#endif SYSCALL(setreuid); SYSCALL(setrlimit); #ifdef TARGET_NR_setsockopt From patchwork Sun Jun 10 03:01:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138146 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2602216lji; Sat, 9 Jun 2018 20:54:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJNmArr8+93tJeEdS9xRyGhyrbnnMHA7bYO74cA1DmbMKHnM+wGqGj0rX7dWHI8TjwNUkGt X-Received: by 2002:a37:5105:: with SMTP id f5-v6mr10146023qkb.265.1528602883842; Sat, 09 Jun 2018 20:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602883; cv=none; d=google.com; s=arc-20160816; b=AvWQs7gIrY2eysPd+/nDnwR7OwBrr5q30qDxEl1EK3/onE++W9RT42KLWW1RKr/eOY vJ4b+p2kXx5me53mRI+diQMAP9JW5p5iCIa31v2ZPSqemw7gopDz7yVTk10sIqsGOsWv 99Wld6YMSY/MU276MC2TF2O9q5M4h3gkfzzh5MGvqgc239bVnCmS2tPTlQYHxZUvJa/G R2jxrnwHpIMQOPBt+loUAXjsR7H1kmqHjgnOzaEvu9k5xc3zCaztBhdSzGjJ77LtSOcF Lbu5k37EMNqwTK4MYLjiyPXLw1qndv0CXY6z5pE/RkCXSxfbBJfDJkdzUM63M4BnQqOx BKJQ== 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:arc-authentication-results; bh=Sk2fDlU0DnsE/sliHTdfILgkVOkFTcoylt1dgKwuElY=; b=Ywy8B3kkVXKA89TrMbLSRXrz06HkDDFHE3cxfMHEREZGIJnUn1mHNQa6ftEk3w0XNY CcFU4rQHCd0JUnQzs8L+cfnt/jh3hsFdvbyBWB5VyVuXLy/dBp7518NlDBSPaiaBJBCt LxONcFUvgIZKQhLL+Q/CxwD2dOh7QddSB0B5q2lJ+0pGdPxx2W8p6SRxmzjalOEW5WGD hb07JB8Gtzx6HArRmkA6/g29R/t+TNp29Oq6JYpVHTmC1SaHWNuT67Enxsuob35PA6r3 fVzrp8SqPhsTTFDYCoATEKumuhkee2uImbwffxibM0lq/UPy5hcUPr5Squlp7aIE5Nr7 lMtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IPeriKnH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r2-v6si6426146qtj.249.2018.06.09.20.54.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:54:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IPeriKnH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrRD-00070L-76 for patch@linaro.org; Sat, 09 Jun 2018 23:54:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfC-0003ov-Lh for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfB-0004Jp-IF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:06 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:42385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfB-0004Jf-CC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:05 -0400 Received: by mail-pf0-x241.google.com with SMTP id w7-v6so8479182pfn.9 for ; Sat, 09 Jun 2018 20:05: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=Sk2fDlU0DnsE/sliHTdfILgkVOkFTcoylt1dgKwuElY=; b=IPeriKnH1+mr5PezpknxXG6T+fjc6G4XX/B3Lc1oR3Ch5X69kDrhpj91+hQwThzoMT fxhtRNEl45dtL3frfFQniE6/nloHcRlDtABSKf6qjFlc4lEDF0U/PWd5cWpXC3kSBGCq WBIxDA2Bg/47PSAJiZ3AKoWU3Ai2yP2cndhUA= 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=Sk2fDlU0DnsE/sliHTdfILgkVOkFTcoylt1dgKwuElY=; b=KhIpeJTYdChQ/WRIb9DIHyOMj7nWsRuc635cakSHO/+3AtJNEj2q1tm3Z/+VA+OH49 xclYHBBgebStF+5LIQt/EMqMDD3pZRzHUxoPiq9LXIlyZi65CHsEvPVgg/TlvqvWP+49 YASsKuPKqT3g0ItK62at8rUHrPec/m9DnF4aXg4NBxX1hxL2n4jeCUstrzFpABNHg8nN WpPbeg9Ico9F7HAx8+jpIsX0zIWvYf9bl5q42rUQlWyp4q1sokPqXGe2VyCccLuTEfAs Lwx4jCNbvVoZs3s6bN2+Oluy9KoNwR420Yf9KI6Mwhj9OgwvOkb6Gyct0mD40g7OJOq0 T75g== X-Gm-Message-State: APt69E2i8LV3FSDbJxMh91n5RgIqO3Qgt9/5/kuKbTwCwF+bmjSB9sD0 iA+fhroCohRxeMyHZ1RxlW3Za7ShedQ= X-Received: by 2002:a62:e117:: with SMTP id q23-v6mr12255358pfh.75.1528599904183; Sat, 09 Jun 2018 20:05:04 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:47 -1000 Message-Id: <20180610030220.3777-76-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 075/108] linux-user: Split out chown, getresgid, getresuid 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 | 94 +++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 75b869fb33..c55c414239 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7787,6 +7787,21 @@ IMPL(chmod) } #endif +#ifdef TARGET_NR_chown +IMPL(chown) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(chroot) { char *p = lock_user_string(arg1); @@ -8588,6 +8603,38 @@ IMPL(getrandom) return ret; } +#ifdef TARGET_NR_getresgid +IMPL(getresgid) +{ + gid_t rgid, egid, sgid; + abi_long ret = get_errno(getresgid(&rgid, &egid, &sgid)); + + if (!is_error(ret) && + (put_user_id(high2lowgid(rgid), arg1) || + put_user_id(high2lowgid(egid), arg2) || + put_user_id(high2lowgid(sgid), arg3))) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + +#ifdef TARGET_NR_getresuid +IMPL(getresuid) +{ + uid_t ruid, euid, suid; + abi_long ret = get_errno(getresuid(&ruid, &euid, &suid)); + + if (!is_error(ret) && + (put_user_id(high2lowuid(ruid), arg1) || + put_user_id(high2lowuid(euid), arg2) || + put_user_id(high2lowuid(suid), arg3))) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(getrlimit) { int resource = target_to_host_resource(arg1); @@ -11547,42 +11594,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getresuid - case TARGET_NR_getresuid: - { - uid_t ruid, euid, suid; - ret = get_errno(getresuid(&ruid, &euid, &suid)); - if (!is_error(ret)) { - if (put_user_id(high2lowuid(ruid), arg1) - || put_user_id(high2lowuid(euid), arg2) - || put_user_id(high2lowuid(suid), arg3)) - return -TARGET_EFAULT; - } - } - return ret; -#endif -#ifdef TARGET_NR_getresgid - case TARGET_NR_getresgid: - { - gid_t rgid, egid, sgid; - ret = get_errno(getresgid(&rgid, &egid, &sgid)); - if (!is_error(ret)) { - if (put_user_id(high2lowgid(rgid), arg1) - || put_user_id(high2lowgid(egid), arg2) - || put_user_id(high2lowgid(sgid), arg3)) - return -TARGET_EFAULT; - } - } - return ret; -#endif -#ifdef TARGET_NR_chown - case TARGET_NR_chown: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_setuid: return get_errno(sys_setuid(low2highuid(arg1))); case TARGET_NR_setgid: @@ -13080,10 +13091,13 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(clone); SYSCALL(close); SYSCALL(chdir); - SYSCALL(chroot); #ifdef TARGET_NR_chmod SYSCALL(chmod); #endif +#ifdef TARGET_NR_chown + SYSCALL(chown); +#endif + SYSCALL(chroot); #ifdef TARGET_NR_connect SYSCALL(connect); #endif @@ -13169,6 +13183,12 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(getpriority); SYSCALL(getrandom); +#ifdef TARGET_NR_getresgid + SYSCALL(getresgid); +#endif +#ifdef TARGET_NR_getresuid + SYSCALL(getresuid); +#endif SYSCALL(getrlimit); SYSCALL(getrusage); SYSCALL(getsid); From patchwork Sun Jun 10 03:01:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138140 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2599377lji; Sat, 9 Jun 2018 20:49:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJb1AnOCAixH6G9mep/1UUZSVIPKMh+/i69e0ZApmtk2/B1saXzKRHjvKidtPChew6ypHrX X-Received: by 2002:a37:646:: with SMTP id 67-v6mr10071813qkg.35.1528602570170; Sat, 09 Jun 2018 20:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602570; cv=none; d=google.com; s=arc-20160816; b=ozZdX2t4z39D87GUyeqfnMQfybAJjThmwLIuPsS+Q1ukw5faDTpi4ARXO/54STGhqp TZFq25exl3PRv4tfQ4WgEFp1RmkK6X0Sf+kijXIAXbgjdz6IvudcbCCmsoXA8mLW7jic 1+AFfI/GGLkPjxDNyWXt7hk6YdSoMci307rNHmfe3AzIo2RBd9+muuLSfwx7MCkSux7V iOUWtGpXkcNEsgXslzLzEjPp0OWMTbO4MR+BHDrTMFtwAxGBcMm/IBGOk5+xh5+puUpo DcNW41MJF7lfy05LJ+vqTL00Br18OK5JBoIJneSsoFjji1k0Fnr04RpPvZkyDQ9o5/Xk c7nw== 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:arc-authentication-results; bh=0r7ZojhBR0H1j2YjDJ1B1Qxo+NrSeT9peX3xz5O1fqk=; b=s0jZIgUl2pusIGVbQHg+ZLg0Hif0eLUdWm9eaAgFf3gYvHFsPpiQs4G+ttIq16r36L FExMm70I7JYb7S6AWoSteIiuvug7VJIATH+uxZz4B/LWg4NCjiOh2MvyYK5sfepo60jj 5k6EOi5hiVfWh8igbQ6P7kaBvB+Z9zOk1xzdiYj/ozZp8owzyCTIKAn7jJQxEUVHHFxO 0z5Z4GiI7EZoh/GziKUx+fdC4/IY53jh0g3SCPNQARRadpKe+1Ew3hIP1KfRZWnyw82V G688QmWQCifnzhIEbAlbhLpF/3n19rE8RtNZXVO1L7uN7rszEOL3uYRSm62esCH2Mors 7+/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OrWHrRUq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u10-v6si13368089qkk.26.2018.06.09.20.49.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:49:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OrWHrRUq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrM9-0001nq-HH for patch@linaro.org; Sat, 09 Jun 2018 23:49:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfE-0003qY-9a for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfD-0004Kc-De for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:08 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:43801) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfD-0004KK-7u for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:07 -0400 Received: by mail-pf0-x241.google.com with SMTP id j20-v6so8482171pff.10 for ; Sat, 09 Jun 2018 20:05: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=0r7ZojhBR0H1j2YjDJ1B1Qxo+NrSeT9peX3xz5O1fqk=; b=OrWHrRUqfL//B1tD9D505L58pKQ1uBrWCBjh9lw+OZ0bEuOE6lqqv9E9G8A8LDjRry tO0iGnV+KblrorIj55oTCjDxCZIDNfVtEx+IZmlLpWBA62FxWRD56v5AwGgLHqhRfXjg v/hud9i+NZ94sKpbI4Hzj6iq4WghV2Ktvv5mc= 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=0r7ZojhBR0H1j2YjDJ1B1Qxo+NrSeT9peX3xz5O1fqk=; b=eVbU0qJp1nSDFjgsbSAIJkZ6n4ORCK1NRAD7Vk60NpD0mcNlqMHIhH3aeVJL2oSEZ4 vcmSQjagkXIBpvtzgSlpxpEMtxVilOtkbDTuqU0CDXVBnmd+b0MS0X9QnJErzBe5Ah8c ysmA8JpDKkBirOlm7sxVuaMupBWtBzSoA0bkLQIdNh6yMWGXDmvZ7LjLN5KmNwGl8+7W sNDP4wdrrC12+F5KrkeIJNUTA4XWq9J/uGPZao7zDFAUUVvo4CWGR6yZ9HLBWPARHvwS IVFIYERJq/JVgKHREJZjee+dP/8Mek2Eocb2OTGcCb8cF2JTmEM7cVTqVe/28pqPmN4g GH3g== X-Gm-Message-State: APt69E0oYRlB46YGByEaaQJVDLvC4W3nTQrjxxdfBjH8USFwGMdkoT4y NeyN6662IxlMmmGNVM5PFZldY0HoxJc= X-Received: by 2002:a63:7d4c:: with SMTP id m12-v6mr10215593pgn.201.1528599906137; Sat, 09 Jun 2018 20:05:06 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:48 -1000 Message-Id: <20180610030220.3777-77-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 076/108] linux-user: Split out setfsgid, setfsuid, setgid, setuid 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 | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c55c414239..76a66b56fe 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10533,6 +10533,21 @@ IMPL(setdomainname) return ret; } +IMPL(setfsgid) +{ + return get_errno(setfsgid(arg1)); +} + +IMPL(setfsuid) +{ + return get_errno(setfsuid(arg1)); +} + +IMPL(setgid) +{ + return get_errno(sys_setgid(low2highgid(arg1))); +} + IMPL(setgroups) { int gidsetsize = arg1; @@ -10668,6 +10683,11 @@ IMPL(setsid) return get_errno(setsid()); } +IMPL(setuid) +{ + return get_errno(sys_setuid(low2highuid(arg1))); +} + #ifdef TARGET_NR_sigaction IMPL(sigaction) { @@ -11594,15 +11614,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_setuid: - return get_errno(sys_setuid(low2highuid(arg1))); - case TARGET_NR_setgid: - return get_errno(sys_setgid(low2highgid(arg1))); - case TARGET_NR_setfsuid: - return get_errno(setfsuid(arg1)); - case TARGET_NR_setfsgid: - return get_errno(setfsgid(arg1)); - #ifdef TARGET_NR_lchown32 case TARGET_NR_lchown32: if (!(p = lock_user_string(arg1))) @@ -13406,6 +13417,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sendto); #endif SYSCALL(setdomainname); + SYSCALL(setfsgid); + SYSCALL(setfsuid); + SYSCALL(setgid); SYSCALL(setgroups); SYSCALL(sethostname); SYSCALL(setitimer); @@ -13425,6 +13439,7 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(settimeofday); SYSCALL(setsid); + SYSCALL(setuid); #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif From patchwork Sun Jun 10 03:01:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138159 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2607332lji; Sat, 9 Jun 2018 21:03:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLQWCL2JytbjV5ZiVxEUxSdlhrOzPei/MSxNGf8Lp1JPXUjDvrctgQMEYC+UpA6fBOn40LY X-Received: by 2002:a37:3c8a:: with SMTP id j132-v6mr10348588qka.266.1528603405734; Sat, 09 Jun 2018 21:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603405; cv=none; d=google.com; s=arc-20160816; b=qC6rndYlFK5/T1dpNVYwboJbOOpp2Ms2kQf3oDEwj7nmND4HZJzKKWsFyMuZ5c7fbI 3ZZWAdcF6r+UI3CZ0bOkZ23Rc6fccv+atcAN9snxYcnxdP8a4UHJo59V2BQbC7VU/644 HOX+BeU4aQzWDbyVmIW2duc7UP8qErXA1h28ght742SNbLwkCP5WIJ361Yf2WgbjMHD0 ATZ7rLPydf4XBDzWswdimmH2lQ75+oEzApNYKAIpN4vacLGGiF4C8aaw/QidpFZMreN+ t3nB4G9qH3ib92QzKUdD/PY1HCi00JgrcpyxXhlYAi4kK3GLivs1r85FCxwELc8dfZPF NS8w== 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:arc-authentication-results; bh=h/36ytP56M6RmyXRMPuv0T4xjmPyu6N2o33pMb66D64=; b=G75C6pPyYW0SygFC1VOBNwaHthDC7VFCBOkMvacjoAhf6P0hJmNhLiHdtHnVg97nih RMMFhburQQyiqYP0QY+5bmhLXdZx5Q/up0N4dF3MgY80RMATiG0cxCyr9V5sUE4lRPTf +Zyb/1sx0Ev5HXXpfxgRjXHpGXAmWGTzCXrC/pJjH1h4r5oCn/LzUmrMGQRMvJ6zR6gh vqMQVIT5/6uhkABRhqRQ1IQ+HxFVobj9AClQF127HaCCUNzibpBUsfAYjZxmfyrBfFuy JFFD9VyDs/Ep02TA7lRIwf7eoCtiFTvf/3u7QcPSIjT5Mfpr7ydqYjCcCgPerlBsEoz9 6JsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kZxri0Ml; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l6-v6si12267066qvk.254.2018.06.09.21.03.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:03:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kZxri0Ml; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZd-0006xH-7r for patch@linaro.org; Sun, 10 Jun 2018 00:03:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfG-0003sq-Dt for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfF-0004L7-El for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:10 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:46239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfF-0004Kv-9A for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:09 -0400 Received: by mail-pl0-x243.google.com with SMTP id 30-v6so10377639pld.13 for ; Sat, 09 Jun 2018 20:05: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=h/36ytP56M6RmyXRMPuv0T4xjmPyu6N2o33pMb66D64=; b=kZxri0MlOxPRhEk3x2FHG54xPsOeyW3cSNMKP+BAOtKGJNLcf8IpCzhcRabpJqlJzY NHAz5IhklghQ7EO1UE4CjC4nwnRQfMwosjgOou26T7/GPmED2KZjEU/Ke3/UQ7Byayqy 1p5xLsZGHzVedMcnqjKq2TYx2w22+jn9otGZA= 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/36ytP56M6RmyXRMPuv0T4xjmPyu6N2o33pMb66D64=; b=PrB41sc1NRz1AoIcyVbR9rbeO2Jr4gxy8+vOm3LfgKr+KEB0pV6dfIL+rcslGewVN8 8hEzncN7T9mzGYFHJvVa9TndoZcUvuo+g8EvYisgP+Co9H1iqsMVJvFbv/IwrJYG85Gb B1bRvGriSMCBGr23WbDpDw8zj61gLGq0IqcmsCtGBBKfsvWE84yqfGwCNVQL1pQ/UF27 v4HcFgnlQNaMTErME/kvwwf3gtJaiEsJyJ5Gcff/Fv2zcuqP+o2Cx5aGBkTKzvjLEWJY WqQ7hmlARPzIjK3HB64pK4xgfrN67oJrbUPJviWdI+ZlwXp7oTa2nNCsU/xwyN/nuFGM BnnQ== X-Gm-Message-State: APt69E2B6KCSfdmxgjaSzedBaPktj5H0BW6emoMnPTqWd55uvpAkWvNR HyB49KbKnK5CNNjHcVwtRl1w8zOr/3k= X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr2223938plb.255.1528599908098; Sat, 09 Jun 2018 20:05:08 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:49 -1000 Message-Id: <20180610030220.3777-78-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 077/108] linux-user: Split out getuid32, getxgid, getxuid, lchown32 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 | 83 ++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 76a66b56fe..17560ebd41 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8704,6 +8704,21 @@ IMPL(getuid) } #endif +#ifdef TARGET_NR_getuid32 +IMPL(getuid32) +{ + return get_errno(getuid()); +} +#endif + +#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) +IMPL(getxgid) +{ + ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getegid(); + return get_errno(getgid()); +} +#endif + #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) IMPL(getxpid) { @@ -8712,6 +8727,14 @@ IMPL(getxpid) } #endif +#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) +IMPL(getxuid) +{ + ((CPUAlphaState *)cpu_env)->ir[IR_A4] = geteuid(); + return get_errno(getuid()); +} +#endif + /* ??? Implement proper locking for ioctls. */ IMPL(ioctl) { @@ -8904,6 +8927,21 @@ IMPL(lchown) } #endif +#ifdef TARGET_NR_lchown32 +IMPL(lchown32) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(lchown(p, arg2, arg3)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_link IMPL(link) { @@ -11614,39 +11652,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_lchown32 - case TARGET_NR_lchown32: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(lchown(p, arg2, arg3)); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_getuid32 - case TARGET_NR_getuid32: - return get_errno(getuid()); -#endif - -#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) - /* Alpha specific */ - case TARGET_NR_getxuid: - { - uid_t euid; - euid=geteuid(); - ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid; - } - return get_errno(getuid()); -#endif -#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) - /* Alpha specific */ - case TARGET_NR_getxgid: - { - uid_t egid; - egid=getegid(); - ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid; - } - return get_errno(getgid()); -#endif #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) /* Alpha specific */ case TARGET_NR_osf_getsysinfo: @@ -13213,8 +13218,17 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getuid SYSCALL(getuid); #endif +#ifdef TARGET_NR_getuid32 + SYSCALL(getuid32); +#endif +#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) + SYSCALL(getxgid); +#endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) SYSCALL(getxpid); +#endif +#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) + SYSCALL(getxuid); #endif SYSCALL(ioctl); #ifdef TARGET_NR_ipc @@ -13224,6 +13238,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_lchown SYSCALL(lchown); #endif +#ifdef TARGET_NR_lchown32 + SYSCALL(lchown32); +#endif #ifdef TARGET_NR_link SYSCALL(link); #endif From patchwork Sun Jun 10 03:01:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138145 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600887lji; Sat, 9 Jun 2018 20:52:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL9vB2G/qpvssii//mLYg7kfS0ZZ13se1yXQipVE1ut9O86xUQZ4hvrUPO6azIm9Dz7A8ra X-Received: by 2002:aed:3ba3:: with SMTP id r32-v6mr11549974qte.362.1528602738306; Sat, 09 Jun 2018 20:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602738; cv=none; d=google.com; s=arc-20160816; b=VjPrZQp2d5CfTCybAjUzvjLAey8eoj2HYkg3cCD7RO1GybjCmN3NeJKSc1/vNCfG/Y 0e991KAVy9yQywEc1fmRzIi9eyi2AEN9gwEhIUmfp4HpdPmfMIKcmd9o+aLl4ceGyCIW 5OmDvAEFTwqDGCrNqr5+d/slTZ7ADDXi+oZrim1xMmFZGRyeXC0gwIHO5hct4FcKZOcV i76ZY7noZcNXXdgv42phT0yAYtyV/APqSDQVPVrBuVbJjB6Yi7zC/MMmaqjeBcpIRJgw R6AT3VVvL9nNY0u2gybzVmI4DwtAOCq2tiMCduA3GesVzvAvZUkSzqbvrkeQqcrCKtdm K80g== 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:arc-authentication-results; bh=8+14MLF8Fqk1uqq8p44jusU/RdOQfrK1yUjLT+Lb4M8=; b=KNW9d9O6wsu90VQxHqKcwXlUyywSn3WfSX6YxcrlNIj++pGrbqeOYREf5qWe6qfj8p TnWM6Dc5KX5UeaTQYV7iQMsiOQIIgX7Oy7RvH1CD+hiuaO+4a1VniY39N4U6681sgCtz GdlLogCFPJiC6sQgmMDQzjeOXsW/DX+KOGzRQsMu3GPoaj5jM5G13jN4m4NaAfLBpRaE 54FSeobKWH2EqFECcTam7QFRrOng8/NtE+URJv2BFDZ/dc9EIuJnbOfkkBPub5buhz6g vhwWoQxwhnZ1jRxk2fDUWwvwruXoljMeiTMdWAXBc/yRGzXXLgus7VZETmelwV/BgaV6 pJNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Gms9mzTV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j34-v6si2777829qvc.201.2018.06.09.20.52.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:52:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Gms9mzTV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrOr-0004yw-Pc for patch@linaro.org; Sat, 09 Jun 2018 23:52:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfL-0003xn-3f for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfH-0004Lm-St for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:15 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:37284) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfH-0004La-JN for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:11 -0400 Received: by mail-pl0-x243.google.com with SMTP id 31-v6so10386558plc.4 for ; Sat, 09 Jun 2018 20:05:11 -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=8+14MLF8Fqk1uqq8p44jusU/RdOQfrK1yUjLT+Lb4M8=; b=Gms9mzTVBnWDd8eJsk7Wx70Rmqm5LSpojq+aMz/lJMRM+aKMEYmdxPQJmtYipPVFil VA4PmzLtf2GyDWpcQe38kBPm3xM27WGhkEVbsrhZIrwur36W1AELMBggM5D9BFfmCY9w loJN+XjFnbUoaMBPiyHICvGkFiJEOV4iTIS8o= 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=8+14MLF8Fqk1uqq8p44jusU/RdOQfrK1yUjLT+Lb4M8=; b=Wd2JcwAYs2Ycf5xbvHAz/u4cUg3sR4rQE0tCd6xhPSDg+EBHFEO7GIHg7XAdtloRtY lH+7/z2rq8InVcMRwUDgumA/63lpbafFy3qLJZjX0GDUsMqNuWjdCM3jqU5SPxtlXJq4 XEdhHQJz7YO7eSVLQnZ0DSppglmdLUdSu0CIuP4d89RPiIhJSsAnA6XO3QZ0HPtnk6fu jys9mxxkm4qfGlZpB8t6SczCgskkG1LmZ4XYbjDzwN+wiUSaQFPL2Ogqg8Bcdc3oNudN KXTauWu1ETwhCAUEQNqjkNVkiaA7f2xK7syE2VCjM/8yFli99P2JAHMvL2EdKId/avFs Tg4w== X-Gm-Message-State: APt69E3/7LyKsX5ZYK2imrHUqZ1dyIrrjUiZ+REL4i/JR1YuG3MzmU9N MrW4TTp7N+Pl6itJRzQcCqJcM4b07mU= X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr12602775ple.285.1528599910398; Sat, 09 Jun 2018 20:05:10 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:50 -1000 Message-Id: <20180610030220.3777-79-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 078/108] linux-user: Split out osf_getsysinfo, osf_setsysinfo, osf_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.c | 323 ++++++++++++++++++++++--------------------- 1 file changed, 162 insertions(+), 161 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 17560ebd41..ae591a6523 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9444,6 +9444,159 @@ IMPL(open_by_handle_at) } #endif +#if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) +IMPL(osf_getsysinfo) +{ + uint64_t swcr, fpcr; + + switch (arg1) { + case TARGET_GSI_IEEE_FP_CONTROL: + fpcr = cpu_alpha_load_fpcr(cpu_env); + + /* Copied from linux ieee_fpcr_to_swcr. */ + swcr = (fpcr >> 35) & SWCR_STATUS_MASK; + swcr |= (fpcr >> 36) & SWCR_MAP_DMZ; + swcr |= (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV + | SWCR_TRAP_ENABLE_DZE + | SWCR_TRAP_ENABLE_OVF); + swcr |= (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF + | SWCR_TRAP_ENABLE_INE); + swcr |= (fpcr >> 47) & SWCR_MAP_UMZ; + swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; + + if (put_user_u64(swcr, arg2)) { + return -TARGET_EFAULT; + } + return 0; + + default: + /* case GSI_IEEE_STATE_AT_SIGNAL: + * -- Not implemented in linux kernel. + * case GSI_UACPROC: + * -- Retrieves current unaligned access state; not much used. + * case GSI_PROC_TYPE: + * -- Retrieves implver information; surely not used. + * case GSI_GET_HWRPB: + * -- Grabs a copy of the HWRPB; surely not used. + */ + return -TARGET_EOPNOTSUPP; + } +} +#endif + +#if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) +IMPL(osf_setsysinfo) +{ + uint64_t swcr, fpcr, exc, orig_fpcr; + int si_code; + + switch (arg1) { + case TARGET_SSI_IEEE_FP_CONTROL: + if (get_user_u64(swcr, arg2)) { + return -TARGET_EFAULT; + } + orig_fpcr = cpu_alpha_load_fpcr(cpu_env); + fpcr = orig_fpcr & FPCR_DYN_MASK; + + /* Copied from linux ieee_swcr_to_fpcr. */ + fpcr |= (swcr & SWCR_STATUS_MASK) << 35; + fpcr |= (swcr & SWCR_MAP_DMZ) << 36; + fpcr |= (~swcr & (SWCR_TRAP_ENABLE_INV + | SWCR_TRAP_ENABLE_DZE + | SWCR_TRAP_ENABLE_OVF)) << 48; + fpcr |= (~swcr & (SWCR_TRAP_ENABLE_UNF + | SWCR_TRAP_ENABLE_INE)) << 57; + fpcr |= (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); + fpcr |= (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; + + cpu_alpha_store_fpcr(cpu_env, fpcr); + return 0; + + case TARGET_SSI_IEEE_RAISE_EXCEPTION: + if (get_user_u64(exc, arg2)) { + return -TARGET_EFAULT; + } + orig_fpcr = cpu_alpha_load_fpcr(cpu_env); + + /* We only add to the exception status here. */ + fpcr = orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); + cpu_alpha_store_fpcr(cpu_env, fpcr); + + /* Old exceptions are not signaled. */ + fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK); + + /* If any exceptions set by this call, + and are unmasked, send a signal. */ + si_code = 0; + if ((fpcr & (FPCR_INE | FPCR_INED)) == FPCR_INE) { + si_code = TARGET_FPE_FLTRES; + } + if ((fpcr & (FPCR_UNF | FPCR_UNFD)) == FPCR_UNF) { + si_code = TARGET_FPE_FLTUND; + } + if ((fpcr & (FPCR_OVF | FPCR_OVFD)) == FPCR_OVF) { + si_code = TARGET_FPE_FLTOVF; + } + if ((fpcr & (FPCR_DZE | FPCR_DZED)) == FPCR_DZE) { + si_code = TARGET_FPE_FLTDIV; + } + if ((fpcr & (FPCR_INV | FPCR_INVD)) == FPCR_INV) { + si_code = TARGET_FPE_FLTINV; + } + if (si_code != 0) { + CPUAlphaState *env = cpu_env; + target_siginfo_t info; + + info.si_signo = SIGFPE; + info.si_errno = 0; + info.si_code = si_code; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + } + return 0; + + default: + /* case SSI_NVPAIRS: + * -- Used with SSIN_UACPROC to enable unaligned accesses. + * case SSI_IEEE_STATE_AT_SIGNAL: + * case SSI_IEEE_IGNORE_STATE_AT_SIGNAL: + * -- Not implemented in linux kernel + */ + return -TARGET_EOPNOTSUPP; + } +} +#endif + +#if defined(TARGET_NR_osf_sigprocmask) && defined(TARGET_ALPHA) +IMPL(osf_sigprocmask) +{ + abi_ulong mask = arg2; + int how; + sigset_t set, oldset; + + 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; + } + target_to_host_old_sigset(&set, &mask); + ret = do_sigprocmask(how, &set, &oldset); + if (!ret) { + host_to_target_old_sigset(&mask, &oldset); + ret = mask; + } + return ret; +} +#endif + #ifdef TARGET_NR_pause IMPL(pause) { @@ -11652,167 +11805,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) - /* Alpha specific */ - case TARGET_NR_osf_getsysinfo: - ret = -TARGET_EOPNOTSUPP; - switch (arg1) { - case TARGET_GSI_IEEE_FP_CONTROL: - { - uint64_t swcr, fpcr = cpu_alpha_load_fpcr (cpu_env); - - /* Copied from linux ieee_fpcr_to_swcr. */ - swcr = (fpcr >> 35) & SWCR_STATUS_MASK; - swcr |= (fpcr >> 36) & SWCR_MAP_DMZ; - swcr |= (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV - | SWCR_TRAP_ENABLE_DZE - | SWCR_TRAP_ENABLE_OVF); - swcr |= (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF - | SWCR_TRAP_ENABLE_INE); - swcr |= (fpcr >> 47) & SWCR_MAP_UMZ; - swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; - - if (put_user_u64 (swcr, arg2)) - return -TARGET_EFAULT; - ret = 0; - } - break; - - /* case GSI_IEEE_STATE_AT_SIGNAL: - -- Not implemented in linux kernel. - case GSI_UACPROC: - -- Retrieves current unaligned access state; not much used. - case GSI_PROC_TYPE: - -- Retrieves implver information; surely not used. - case GSI_GET_HWRPB: - -- Grabs a copy of the HWRPB; surely not used. - */ - } - return ret; -#endif -#if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) - /* Alpha specific */ - case TARGET_NR_osf_setsysinfo: - ret = -TARGET_EOPNOTSUPP; - switch (arg1) { - case TARGET_SSI_IEEE_FP_CONTROL: - { - uint64_t swcr, fpcr, orig_fpcr; - - if (get_user_u64 (swcr, arg2)) { - return -TARGET_EFAULT; - } - orig_fpcr = cpu_alpha_load_fpcr(cpu_env); - fpcr = orig_fpcr & FPCR_DYN_MASK; - - /* Copied from linux ieee_swcr_to_fpcr. */ - fpcr |= (swcr & SWCR_STATUS_MASK) << 35; - fpcr |= (swcr & SWCR_MAP_DMZ) << 36; - fpcr |= (~swcr & (SWCR_TRAP_ENABLE_INV - | SWCR_TRAP_ENABLE_DZE - | SWCR_TRAP_ENABLE_OVF)) << 48; - fpcr |= (~swcr & (SWCR_TRAP_ENABLE_UNF - | SWCR_TRAP_ENABLE_INE)) << 57; - fpcr |= (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); - fpcr |= (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; - - cpu_alpha_store_fpcr(cpu_env, fpcr); - ret = 0; - } - break; - - case TARGET_SSI_IEEE_RAISE_EXCEPTION: - { - uint64_t exc, fpcr, orig_fpcr; - int si_code; - - if (get_user_u64(exc, arg2)) { - return -TARGET_EFAULT; - } - - orig_fpcr = cpu_alpha_load_fpcr(cpu_env); - - /* We only add to the exception status here. */ - fpcr = orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); - - cpu_alpha_store_fpcr(cpu_env, fpcr); - ret = 0; - - /* Old exceptions are not signaled. */ - fpcr &= ~(orig_fpcr & FPCR_STATUS_MASK); - - /* If any exceptions set by this call, - and are unmasked, send a signal. */ - si_code = 0; - if ((fpcr & (FPCR_INE | FPCR_INED)) == FPCR_INE) { - si_code = TARGET_FPE_FLTRES; - } - if ((fpcr & (FPCR_UNF | FPCR_UNFD)) == FPCR_UNF) { - si_code = TARGET_FPE_FLTUND; - } - if ((fpcr & (FPCR_OVF | FPCR_OVFD)) == FPCR_OVF) { - si_code = TARGET_FPE_FLTOVF; - } - if ((fpcr & (FPCR_DZE | FPCR_DZED)) == FPCR_DZE) { - si_code = TARGET_FPE_FLTDIV; - } - if ((fpcr & (FPCR_INV | FPCR_INVD)) == FPCR_INV) { - si_code = TARGET_FPE_FLTINV; - } - if (si_code != 0) { - target_siginfo_t info; - info.si_signo = SIGFPE; - info.si_errno = 0; - info.si_code = si_code; - info._sifields._sigfault._addr - = ((CPUArchState *)cpu_env)->pc; - queue_signal((CPUArchState *)cpu_env, info.si_signo, - QEMU_SI_FAULT, &info); - } - } - break; - - /* case SSI_NVPAIRS: - -- Used with SSIN_UACPROC to enable unaligned accesses. - case SSI_IEEE_STATE_AT_SIGNAL: - case SSI_IEEE_IGNORE_STATE_AT_SIGNAL: - -- Not implemented in linux kernel - */ - } - return ret; -#endif -#ifdef TARGET_NR_osf_sigprocmask - /* Alpha specific. */ - case TARGET_NR_osf_sigprocmask: - { - abi_ulong mask; - int how; - sigset_t set, oldset; - - 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 (!ret) { - host_to_target_old_sigset(&mask, &oldset); - ret = mask; - } - } - return ret; -#endif - #ifdef TARGET_NR_getgid32 case TARGET_NR_getgid32: return get_errno(getgid()); @@ -13316,6 +13308,15 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(open_by_handle_at); #endif +#if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) + SYSCALL(osf_getsysinfo); +#endif +#if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) + SYSCALL(osf_setsysinfo); +#endif +#if defined(TARGET_NR_osf_sigprocmask) && defined(TARGET_ALPHA) + SYSCALL(osf_sigprocmask); +#endif #ifdef TARGET_NR_pause SYSCALL(pause); #endif From patchwork Sun Jun 10 03:01:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138163 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2609153lji; Sat, 9 Jun 2018 21:06:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJoOzuyvsiYM+mxhkxmnGMcFD01BCVppcKVW/NSdJr83MNe0s6gwgLJe4b47IpIxfm+391U X-Received: by 2002:aed:24fb:: with SMTP id u56-v6mr6092841qtc.203.1528603573747; Sat, 09 Jun 2018 21:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603573; cv=none; d=google.com; s=arc-20160816; b=EdEUC56279p6cs9GKkTxc7D6PW5G/jb+Ai0XbifV/SNQVYEOYSOyWNR9vQNGoTzu8/ 7aexbVLvVBsci//2x095jSIcLTvjignY0MpevI+gppihaBRb1ZF/msWk4UeGFE+zJmVz mUuOIVBhWh4tPY9Z2gfg2mzqFk0lTr5GQuQQ+fkV3Rc5ankN4zKzHSLMusDWzw//y7Gl VRprztJbaFUMi+Km1/eicsSBi73NxDPjSpMPEVEemEu0Ak8F3sdDQt9HoRibJjq66JfY sEptuuQcsBbgIoC7QNNC6CQRhyHh52Qv0S3SZ0mWiYM+wU2glu1l1xaFSXmqcX7NTCMZ 7XVg== 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:arc-authentication-results; bh=KLOF75MuxIiciS1cvvVtBEg4Z9aeDdENZ2YjGYTbsss=; b=mU42lKc3x2tZ8Aok5S5NtQ3tTQgf25UN2wSo7n+2aXK81ekMHyno4aWBLkLwwel0vK Ds8qWpqhHcbA7eMezU9r7209JTxgGfInX9b8r9HxgrY+qTfsSrmymQyjX1QEbvYUD24S nCNylVOm3Xn8r9loK2bGBmwhN7T+8/ixVonbxfF/P/1xz45p7VzOMOobEeP1N38OhHfr MNZ6FibVFYPjMgfXPWGOew4kEhqfHZLu3v3oNhvIuU//ic4yvmhBjtUimIfR5HfeRvC7 b5q5+I4hTfsq97bWUupyqUxBbaxJ9YJAYQBUpnAuUlr5SHJqxSt1w0+QMxEqVvbNol62 BA/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GNvnHQTm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e35-v6si4568854qvd.129.2018.06.09.21.06.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GNvnHQTm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrcL-0000yd-2B for patch@linaro.org; Sun, 10 Jun 2018 00:06:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfL-0003xl-2V for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfJ-0004M1-TW for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:15 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:45906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfJ-0004Lu-NQ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:13 -0400 Received: by mail-pl0-x241.google.com with SMTP id c23-v6so10385320plz.12 for ; Sat, 09 Jun 2018 20:05: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=KLOF75MuxIiciS1cvvVtBEg4Z9aeDdENZ2YjGYTbsss=; b=GNvnHQTm4MyOEKnKrTT7Rac3MLqkwlkJuzOMjQHab2bqMxDEbVH+tv82MYYimrrRTg JQ06qGO+ODAiGRfQF6otXKXMn9RqoR1mku49Jg2FRQDJkgyqnMXlhKtYL1YVGXKWk0+T PrW95Hc/npHcZR6BkrazPPWPZyhLEDIajp1BE= 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=KLOF75MuxIiciS1cvvVtBEg4Z9aeDdENZ2YjGYTbsss=; b=tAWASyG+HywWcgfnp2gwQx6jMqHB414YF7YlnF18tz+VThnsa5zkckQDIaquNJALqb OrUpLXr+ZLL6NnRaCkblAvKngRlujCv9+ydBTmLD6fDHpA4iOzRzYx7WYrF+7ccgdaik BpovjHkb7yiD8FMqxzghyCESCA0EKWtj3WrkjvD1I8eY8wgF+rLGEQxfj8Fz9SZoLlQt RhI+6Q0qrOY9vFqXsd4U61sJjdbMCSjJAPgg0O74BSkUFPCdgHcLdaPMiZvfoqIbUBcC Y2anHgG5tI8CtP4stlNB1b1ghY/cAljc42W+4yHPR+Ow2/MJ0FMm4S/YHwMAaFDMShOO RNCw== X-Gm-Message-State: APt69E2BOGoIaVfU8v2XD05bNr47+8sgi0qJ0q+KMiqS6knB2dUR4a/g VFn8S5+13dfm2ZaS9zbNAvJUdR0CfiE= X-Received: by 2002:a17:902:1029:: with SMTP id b38-v6mr12793763pla.277.1528599912551; Sat, 09 Jun 2018 20:05:12 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:51 -1000 Message-Id: <20180610030220.3777-80-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 079/108] linux-user: Split out getegid32, geteuid32, getgid32, setregid32, setreuid32 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 | 70 +++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ae591a6523..c8bd13092e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8482,6 +8482,13 @@ IMPL(getegid) } #endif +#ifdef TARGET_NR_getegid32 +IMPL(getegid32) +{ + return get_errno(getegid()); +} +#endif + #ifdef TARGET_NR_geteuid IMPL(geteuid) { @@ -8489,6 +8496,13 @@ IMPL(geteuid) } #endif +#ifdef TARGET_NR_geteuid32 +IMPL(geteuid32) +{ + return get_errno(geteuid()); +} +#endif + #ifdef TARGET_NR_getgid IMPL(getgid) { @@ -8496,6 +8510,13 @@ IMPL(getgid) } #endif +#ifdef TARGET_NR_getgid32 +IMPL(getgid32) +{ + return get_errno(getgid()); +} +#endif + IMPL(getgroups) { int gidsetsize = arg1; @@ -10812,6 +10833,13 @@ IMPL(setregid) return get_errno(setregid(low2highgid(arg1), low2highgid(arg2))); } +#ifdef TARGET_NR_setregid32 +IMPL(setregid32) +{ + return get_errno(setregid(arg1, arg2)); +} +#endif + #ifdef TARGET_NR_setresgid IMPL(setresgid) { @@ -10833,6 +10861,13 @@ IMPL(setreuid) return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); } +#ifdef TARGET_NR_setreuid32 +IMPL(setreuid32) +{ + return get_errno(setreuid(arg1, arg2)); +} +#endif + IMPL(setrlimit) { int resource = target_to_host_resource(arg1); @@ -11805,26 +11840,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getgid32 - case TARGET_NR_getgid32: - return get_errno(getgid()); -#endif -#ifdef TARGET_NR_geteuid32 - case TARGET_NR_geteuid32: - return get_errno(geteuid()); -#endif -#ifdef TARGET_NR_getegid32 - case TARGET_NR_getegid32: - return get_errno(getegid()); -#endif -#ifdef TARGET_NR_setreuid32 - case TARGET_NR_setreuid32: - return get_errno(setreuid(arg1, arg2)); -#endif -#ifdef TARGET_NR_setregid32 - case TARGET_NR_setregid32: - return get_errno(setregid(arg1, arg2)); -#endif #ifdef TARGET_NR_getgroups32 case TARGET_NR_getgroups32: { @@ -13168,11 +13183,20 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getegid SYSCALL(getegid); #endif +#ifdef TARGET_NR_getegid32 + SYSCALL(getegid32); +#endif #ifdef TARGET_NR_geteuid SYSCALL(geteuid); #endif +#ifdef TARGET_NR_geteuid32 + SYSCALL(geteuid32); +#endif #ifdef TARGET_NR_getgid SYSCALL(getgid); +#endif +#ifdef TARGET_NR_getgid32 + SYSCALL(getgid32); #endif SYSCALL(getgroups); SYSCALL(getitimer); @@ -13447,10 +13471,16 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_setresgid SYSCALL(setresgid); #endif +#ifdef TARGET_NR_setregid32 + SYSCALL(setregid32); +#endif #ifdef TARGET_NR_setresuid SYSCALL(setresuid); #endif SYSCALL(setreuid); +#ifdef TARGET_NR_setreuid32 + SYSCALL(setreuid32); +#endif SYSCALL(setrlimit); #ifdef TARGET_NR_setsockopt SYSCALL(setsockopt); From patchwork Sun Jun 10 03:01:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138148 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2602418lji; Sat, 9 Jun 2018 20:55:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZfxpCyYSEX9+q/BQ1WapWmzhS9gNx+LBEneVyPcUXB/104eSyNjcPKu4dxNPK+JE6a3vr X-Received: by 2002:aed:2a2e:: with SMTP id c43-v6mr11894656qtd.36.1528602908323; Sat, 09 Jun 2018 20:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602908; cv=none; d=google.com; s=arc-20160816; b=dumTSY5+H/uihavTuQMgQN78rm03CcxQFpAOuch+e3ww14x4A8rve0P1ANWhgyH1i3 QzX5AslCqUxMe0qY+yOg6ZQWSF56Iy6ftx2isYctvmSrCDeXs9e96WS7Eh0w0b0S8XXv ovamxdAJC/bstl+DTlCjhfhPTCu2ZBlscjcaUtPaVuCQgUwPVu+joLiIHBbB6xpc2LwH UfQEfT694oevC9IRYz6b6LUIy5YPK2OiqmTIAXkyVPNyuvq8/BhjdYWE6CJVWNK+glSU ERmM61wAyMLvA3mct+PTgXc+KaEaA4RJh2wEQDwhNe9LMLx4x3tOo8IzTllHfgDXoTr0 MO8g== 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:arc-authentication-results; bh=IkrY1Z2tJmo6hGZdiQt8/HqWJyCtyMCObOLqWroRbt8=; b=UjE47ZHlUQlSQlsgo8T5qfFdloLZ5UJH7qzFRPGOQTvXG+a/rHi52W0yasoUUXZVTf 4vbrs2e40yrSylEkbYFmutXBcSqZzYYxG74zx/SS9BsRD/6qgmjvqevUfzXxVm9da9Wl q6zQFSyqART1ngTrewGkdgi8aaMA4NDc3DwYKcdWdcS2t97XRP9hnYAhjOi9D1LiRieS B8RlNMn43+sm9rB2NxRPJTJhav1+pEif3VTC+RCkHgHl7IImSkT4cWHtPAHTa/wr2oNs op0hKUGnGxg7R+O2cwUbdGL5/Sm053PsOnweDzFqs1k6+e38B0dmtaZ9lkpEr9AI2JPl ugXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OIHLNUwB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a26-v6si1748939qtj.326.2018.06.09.20.55.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OIHLNUwB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrRb-0007PB-Ox for patch@linaro.org; Sat, 09 Jun 2018 23:55:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfM-0003zf-UR for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfL-0004Mg-R5 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:16 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:33746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfL-0004MN-Ir for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:15 -0400 Received: by mail-pl0-x242.google.com with SMTP id n10-v6so10391995plp.0 for ; Sat, 09 Jun 2018 20:05: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=IkrY1Z2tJmo6hGZdiQt8/HqWJyCtyMCObOLqWroRbt8=; b=OIHLNUwBgc1Vq5Zv+E4Toa9YTbpwobYoYW3gqtBfZUI+y/tspfO23UjvSecRMNa3mA 0MUCgVgqe96hJ20OOqB0MwQFBaNfWcvScgKHDy1gW2PGLPMD45R0t0h+8I7ty4BcxU5o dVhxC/nIfUUxgfMb+2uciyjNLmmaES2+e0qOM= 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=IkrY1Z2tJmo6hGZdiQt8/HqWJyCtyMCObOLqWroRbt8=; b=NVgBNkMysLOsLT4t1POuRS4gb5CGiSf3TviAo/MlKCwnfx8LGY47N6QkdGtXrpG6Xm tC8inZh8NGjlhCTK4tNXj/Q19ryoBOTW526r0AF+o0PuDbxXnzoJcd+spSX/torjOWFU CaGA3HRMLfUFjRXtow3aDdLK24eOjjfTYfah9dSi/HKQ1oYLIeaTKmZF1hQ8cz8CkizV y6fXMi+F0GBXQ5OUiiCU6+AHSMm7K7T/UGuFBCKH2+2kL2JIIP+U8Rb882DMAEZRogKM UVFyaAESNjqPjfWPBwcEbZPos8OaELWW++r2fYoZbk2w1VSReGrzyKcl19L2n8nbOCYv wvNg== X-Gm-Message-State: APt69E0p06EChDOr1A6XwN/iIRgVYf6nCGF+s9z0u49S3csUQBgYxQVE GFIBAnw7lKG7TBYl+q4j1050QYX9SGo= X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr12796138pla.88.1528599914405; Sat, 09 Jun 2018 20:05:14 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:52 -1000 Message-Id: <20180610030220.3777-81-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 080/108] linux-user: Split out fchown32, getgroups32, setgroups32 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 | 114 +++++++++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 47 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c8bd13092e..031033c0ea 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8123,6 +8123,13 @@ IMPL(fchown) return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); } +#ifdef TARGET_NR_fchown32 +IMPL(fchown32) +{ + return get_errno(fchown(arg1, arg2, arg3)); +} +#endif + IMPL(fchownat) { char *p = lock_user_string(arg2); @@ -8543,6 +8550,33 @@ IMPL(getgroups) return ret; } +#ifdef TARGET_NR_getgroups32 +IMPL(getgroups32) +{ + int gidsetsize = arg1; + gid_t *grouplist; + abi_long ret; + + grouplist = alloca(gidsetsize * sizeof(gid_t)); + ret = get_errno(getgroups(gidsetsize, grouplist)); + + if (!is_error(ret) && gidsetsize != 0) { + uint32_t *target_gl; + int i; + + target_gl = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); + if (!target_gl) { + return -TARGET_EFAULT; + } + for (i = 0; i < ret; i++) { + target_gl[i] = tswap32(grouplist[i]); + } + unlock_user(target_gl, arg2, gidsetsize * 4); + } + return ret; +} +#endif + IMPL(getitimer) { struct itimerval value; @@ -10783,6 +10817,30 @@ IMPL(setgroups) return get_errno(setgroups(gidsetsize, grouplist)); } +#ifdef TARGET_NR_setgroups32 +IMPL(setgroups32) +{ + int gidsetsize = arg1; + gid_t *grouplist = NULL; + + if (gidsetsize) { + uint32_t *target_gl; + int i; + + grouplist = alloca(gidsetsize * sizeof(gid_t)); + target_gl = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); + if (!target_gl) { + return -TARGET_EFAULT; + } + for (i = 0; i < gidsetsize; i++) { + grouplist[i] = tswap32(target_gl[i]); + } + unlock_user(target_gl, arg2, 0); + } + return get_errno(setgroups(gidsetsize, grouplist)); +} +#endif + IMPL(sethostname) { char *p = lock_user_string(arg1); @@ -11840,53 +11898,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getgroups32 - case TARGET_NR_getgroups32: - { - int gidsetsize = arg1; - uint32_t *target_grouplist; - gid_t *grouplist; - int i; - - grouplist = alloca(gidsetsize * sizeof(gid_t)); - ret = get_errno(getgroups(gidsetsize, grouplist)); - if (gidsetsize == 0) - return ret; - if (!is_error(ret)) { - target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); - if (!target_grouplist) { - return -TARGET_EFAULT; - } - for(i = 0;i < ret; i++) - target_grouplist[i] = tswap32(grouplist[i]); - unlock_user(target_grouplist, arg2, gidsetsize * 4); - } - } - return ret; -#endif -#ifdef TARGET_NR_setgroups32 - case TARGET_NR_setgroups32: - { - int gidsetsize = arg1; - uint32_t *target_grouplist; - gid_t *grouplist; - int i; - - grouplist = alloca(gidsetsize * sizeof(gid_t)); - target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); - if (!target_grouplist) { - return -TARGET_EFAULT; - } - for(i = 0;i < gidsetsize; i++) - grouplist[i] = tswap32(target_grouplist[i]); - unlock_user(target_grouplist, arg2, 0); - return get_errno(setgroups(gidsetsize, grouplist)); - } -#endif -#ifdef TARGET_NR_fchown32 - case TARGET_NR_fchown32: - return get_errno(fchown(arg1, arg2, arg3)); -#endif #ifdef TARGET_NR_setresuid32 case TARGET_NR_setresuid32: return get_errno(sys_setresuid(arg1, arg2, arg3)); @@ -13144,6 +13155,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fchmod); SYSCALL(fchmodat); SYSCALL(fchown); +#ifdef TARGET_NR_fchown32 + SYSCALL(fchown32); +#endif SYSCALL(fchownat); #ifdef TARGET_NR_fcntl SYSCALL(fcntl); @@ -13199,6 +13213,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getgid32); #endif SYSCALL(getgroups); +#ifdef TARGET_NR_getgroups32 + SYSCALL(getgroups32); +#endif SYSCALL(getitimer); #ifdef TARGET_NR_getpeername SYSCALL(getpeername); @@ -13463,6 +13480,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(setfsuid); SYSCALL(setgid); SYSCALL(setgroups); +#ifdef TARGET_NR_setgroups32 + SYSCALL(setgroups32); +#endif SYSCALL(sethostname); SYSCALL(setitimer); SYSCALL(setpgid); From patchwork Sun Jun 10 03:01:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138152 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2604727lji; Sat, 9 Jun 2018 20:59:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJLq8N4th+a/3Lo8FSIGAgUujGTl1ctPIgpDoFqAzJI6j3zOOsbPmFOR/wn2wRiHlGJHPBx X-Received: by 2002:ac8:3426:: with SMTP id u35-v6mr11616167qtb.288.1528603187518; Sat, 09 Jun 2018 20:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603187; cv=none; d=google.com; s=arc-20160816; b=1Dafv2EplL8b5orEeOfB7wxDWjCi7SEnHswyLckoBiVV+Gt+jiQzEIuGQTUnFn86yD K+nJGbejL26BFCqQ6mRoccKji61tirUJcCcD+GOtFXIpJzrKJLsDAPlEubnzXc0RHUn0 0RSGPP8haxNI+cbt9UmjGpuACKYRUhraOlbC30Fv+Obc5HFDz65FcLkd3RslDtd1frTS Y71SDemIbqQPVbXze5L/Mb2wvFZKNMnVZskCSYcgYVbA1GEQeEYtZc3haV2wZjh5Cx33 fvE3rHSuKRU0uL8AfLMsHdMUNIs+rf23+/Qyzlzu9/r7FQYS0aCpdtV6xXCLChtDtArx 6fwQ== 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:arc-authentication-results; bh=eKNa1DsH+OxIQ1x9aRCezT/ioFBhMALTf/PEP0/c5zw=; b=Z0+NCh0qMaS1cLK8JAD+GnZTHrWCJJFqSa9sualqRrZkC+I2ZCcOJSEYZqm6BkIlg3 u0e1pwdLw1Rf533D47/xNzIAUPhKicgpPHAWzEt5D2NtrTwedsgHQUVStrCKbH7M5q9S sY5JE7AatpONviT2x7kLHWCdBbH6Po6yvjPSvdMMvCUf9obdTjUaQH1Ev/NMCgtli3r/ 2x9dw4t00faHqDdJp3cPodLM4tvJfDrUKaWNwDYo3LlML60/yedzdcG3SapnLnJmVpIK 90gWITd99NZpiGz98CVoMdFx6ysakw/zCD1n8rwMJ8Pqh7XIAhuii1B2cmsWaDD3iA/o JvTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PRyMnfgz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h5-v6si4854280qkd.22.2018.06.09.20.59.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:59:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PRyMnfgz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrW7-0004DB-0V for patch@linaro.org; Sat, 09 Jun 2018 23:59:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfO-00041E-Fx for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfN-0004N7-Ej for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:18 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:35912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfN-0004Ms-8V for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:17 -0400 Received: by mail-pl0-x244.google.com with SMTP id a7-v6so7900314plp.3 for ; Sat, 09 Jun 2018 20:05:17 -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=eKNa1DsH+OxIQ1x9aRCezT/ioFBhMALTf/PEP0/c5zw=; b=PRyMnfgzFTZy3l0RQ6y+MtkVl6iGinnKYcBz8i5C/Ss4K9MqnEdxL72rH82HPSmumd dKlCcNxnFZQs4Q6ML6fuZttKH1mbA/zO/9+HbI+dPeI4JlV5pBzi1SMuJj+u/kwKnvFm InxBRbtfSXiYbOu89KEBvq1QmoU/PXnugQQUw= 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=eKNa1DsH+OxIQ1x9aRCezT/ioFBhMALTf/PEP0/c5zw=; b=un3eLO7XNOSq1COCMwnzdOusnnZwrwSEp6kbXR6hYbv0p9eIgU5IpNq0evoHgMJlQa 9f9ov7MAdReyPlHbuebYN+UMifr4UiF9fEDJ7oA9m9oK3dsRUJa0G+uO7XRNNEElvjTy M5tanXC29Nb07MB2RbC/yTn6VeNGOJXMrcVgn9Bn4K2I3krmo0RGEYSzwNJfPT9V+8BV YCkHLsnyk0Gcwu7bQ9DkVtUy3X8xm7p9wgDg7vDn3VQlth9N/9N02Qq4uHIJ1RmCIxqj NJGAXx1p9syDkD2bbmbgQbbfc84+rQZEwq3FNeZWnsJFebthWTRY1vx15iToiu7QQdmf bFFQ== X-Gm-Message-State: APt69E2GLmp+TMNDG1KyM74r7SqGmqNo8Zpr09PZ6gRmDbKQBj6z4VIJ IklcINtOznCUYKPSv50M23cNKFcdU9k= X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr12936064plt.91.1528599916125; Sat, 09 Jun 2018 20:05:16 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:53 -1000 Message-Id: <20180610030220.3777-82-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v2 081/108] linux-user: Split out getresgid32, getresuid32, setresgid32, setresuid32 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 | 93 +++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 36 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 031033c0ea..af96cc95d3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8674,6 +8674,22 @@ IMPL(getresgid) } #endif +#ifdef TARGET_NR_getresgid32 +IMPL(getresgid32) +{ + gid_t rgid, egid, sgid; + abi_long ret = get_errno(getresgid(&rgid, &egid, &sgid)); + + if (!is_error(ret) && + (put_user_u32(rgid, arg1) || + put_user_u32(egid, arg2) || + put_user_u32(sgid, arg3))) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_getresuid IMPL(getresuid) { @@ -8690,6 +8706,21 @@ IMPL(getresuid) } #endif +#ifdef TARGET_NR_getresuid32 +IMPL(getresuid32) +{ + uid_t ruid, euid, suid; + abi_long ret = get_errno(getresuid(&ruid, &euid, &suid)); + + if (!is_error(ret) && + (put_user_u32(ruid, arg1) || + put_user_u32(euid, arg2) || + put_user_u32(suid, arg3))) { + return -TARGET_EFAULT; + } + return ret; +} +#endif IMPL(getrlimit) { int resource = target_to_host_resource(arg1); @@ -10906,6 +10937,13 @@ IMPL(setresgid) } #endif +#ifdef TARGET_NR_setresgid32 +IMPL(setresgid32) +{ + return get_errno(sys_setresgid(arg1, arg2, arg3)); +} +#endif + #ifdef TARGET_NR_setresuid IMPL(setresuid) { @@ -10914,6 +10952,13 @@ IMPL(setresuid) } #endif +#ifdef TARGET_NR_setresuid32 +IMPL(setresuid32) +{ + return get_errno(sys_setresuid(arg1, arg2, arg3)); +} +#endif + IMPL(setreuid) { return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2))); @@ -11898,42 +11943,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_setresuid32 - case TARGET_NR_setresuid32: - return get_errno(sys_setresuid(arg1, arg2, arg3)); -#endif -#ifdef TARGET_NR_getresuid32 - case TARGET_NR_getresuid32: - { - uid_t ruid, euid, suid; - ret = get_errno(getresuid(&ruid, &euid, &suid)); - if (!is_error(ret)) { - if (put_user_u32(ruid, arg1) - || put_user_u32(euid, arg2) - || put_user_u32(suid, arg3)) - return -TARGET_EFAULT; - } - } - return ret; -#endif -#ifdef TARGET_NR_setresgid32 - case TARGET_NR_setresgid32: - return get_errno(sys_setresgid(arg1, arg2, arg3)); -#endif -#ifdef TARGET_NR_getresgid32 - case TARGET_NR_getresgid32: - { - gid_t rgid, egid, sgid; - ret = get_errno(getresgid(&rgid, &egid, &sgid)); - if (!is_error(ret)) { - if (put_user_u32(rgid, arg1) - || put_user_u32(egid, arg2) - || put_user_u32(sgid, arg3)) - return -TARGET_EFAULT; - } - } - return ret; -#endif #ifdef TARGET_NR_chown32 case TARGET_NR_chown32: if (!(p = lock_user_string(arg1))) @@ -13235,8 +13244,14 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getresgid SYSCALL(getresgid); #endif +#ifdef TARGET_NR_getresgid32 + SYSCALL(getresgid32); +#endif #ifdef TARGET_NR_getresuid SYSCALL(getresuid); +#endif +#ifdef TARGET_NR_getresuid32 + SYSCALL(getresuid32); #endif SYSCALL(getrlimit); SYSCALL(getrusage); @@ -13491,11 +13506,17 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_setresgid SYSCALL(setresgid); #endif +#ifdef TARGET_NR_setresgid32 + SYSCALL(setresgid32); +#endif #ifdef TARGET_NR_setregid32 SYSCALL(setregid32); #endif #ifdef TARGET_NR_setresuid SYSCALL(setresuid); +#endif +#ifdef TARGET_NR_setresuid32 + SYSCALL(setresuid32); #endif SYSCALL(setreuid); #ifdef TARGET_NR_setreuid32 From patchwork Sun Jun 10 03:01:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138151 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2603792lji; Sat, 9 Jun 2018 20:57:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLTgxaZx2jzhzO4X69hUXuNGfos7usAWFnIa38+Q6etQOr18tTMMypufPdb54w+NEPAcGLx X-Received: by 2002:a37:15cd:: with SMTP id 74-v6mr10665662qkv.335.1528603073225; Sat, 09 Jun 2018 20:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603073; cv=none; d=google.com; s=arc-20160816; b=08uU5mN07FOS2ACjGkttAHC+VCUQwTTYknfukBl7ljw6HDdohBmU36oiV1Ja4fIp/w dog0lVOSfnugY+rPCe2CwGyuWAChtNeWeQslP2hHlKooIrTA/tdDkITCtNLQM1ZVgudf y1gpWiUbwUjrVVZPmLOdG9DjAn5fZI4kcfjt8YUVEJ/g3Vd3AriavOvHpKAXWi+oA5lx SDIYgmXLaRN6lqvIgbdR9k8s4Dvg+VrBRoGN7a/DykUgLx0K1kOkhUcna1TKXqqiXqLw UMmD1Dyx8NVBsXfm34WkE4sRMHw1gWSBIfpNWlVFngTxXsJiBxBAqKK+H5u/2T8aY1Gf SYjA== 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:arc-authentication-results; bh=+n2lKBW6p5nuY81WSsCh3TN8fpItL8XwNfAloRWOuKc=; b=S9Io6D8Sn2t2LH8jNDQQUUoijDIGdMa0y0h+T5yCkaMRI24oZk4JlytJGyhWmXPBmU gEONUUl0AHQq9P7OURDQi+SNcSgiM13vrDIoLvknwp0lPtxxiPVkxmH2yuA7UVK6pRV4 4yxcBbBqnSor62REF1rl33A9Xh2Op79MLH+U1KM/zjm8rnP8DuGw+XsrU3gIjkkavjVO h1jZ2MjZmrx5j3kSWrv+1B1cUb4IBbtgT3zkq4VERb3gZfS3S12/cMYwNz+eRi3g9d/1 TCMd+3NLaH+zqPJhz8b/zN076SILTjv87zRTve6x7WIIIkUhP+9P8bWJGciGYUGCX3jd l8lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kgFGz6Pq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d5-v6si4709382qtn.268.2018.06.09.20.57.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kgFGz6Pq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrUG-0002JH-Jt for patch@linaro.org; Sat, 09 Jun 2018 23:57:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfQ-00043c-Ry for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfP-0004NX-Fu for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:20 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:41364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfP-0004NL-98 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:19 -0400 Received: by mail-pf0-x244.google.com with SMTP id a11-v6so8486595pff.8 for ; Sat, 09 Jun 2018 20:05: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=+n2lKBW6p5nuY81WSsCh3TN8fpItL8XwNfAloRWOuKc=; b=kgFGz6PqVoLlrRqQ4V/WvlH9zivsCclVPhRVMRMTCfjfg0LvdjasJRAojShIx46UL/ BMxPTebmE17ux37Aodz9x3StcaUMu7EmimDsQXJSCBn547imNpO3jCt0KHvDXYjCEMbY /qevr+vS/hUWpkGMhN2wjQ1x3yNFB5iawQoe8= 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=+n2lKBW6p5nuY81WSsCh3TN8fpItL8XwNfAloRWOuKc=; b=F9mtVF9F7fZNY2iL2IWd6SlE5fdN6SSLbaefSEZh9OVIgzZ/7mXQPsvwwOLbrwfpBi ErUXrYkRSL0p+zyft2wAjis+0yrZUhM6z6QORPoNutVl38GZCiuIuEWT9c7JDbdRcDng Ff3YkM5eQKKzlnSA74+gIA0khqZTC77NRnIkHZ1eLL4IDsUNrRV8ZLkW6hEiQD5MjAgN 8urmhuPFtgqL8p6LGWHLPmZJCBwA9M1Ke7YDeT3sJm5qVWhiv/pWtqqK7qvjVNOUxVJ0 1iAjMRnkuKl5fPyn0CwpbJZ3AmT07fmmiO7ebdV98gK+xz2iYnsGhHZLXX1vc9Y1DlJW S2rA== X-Gm-Message-State: APt69E0droCI0x4An2xI9DN64XJAmhc65bMpek/IjBueeAR20uLs7KE7 qyScqqpDeLiVQlAOrZZ/5GoO8QPQ94I= X-Received: by 2002:a63:745a:: with SMTP id e26-v6mr10160449pgn.377.1528599917886; Sat, 09 Jun 2018 20:05:17 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:54 -1000 Message-Id: <20180610030220.3777-83-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 082/108] linux-user: Split out chown32, setfsgid32, setfsuid32, setgid32, setuid32 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 | 82 +++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 24 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index af96cc95d3..fc7f301519 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7802,6 +7802,21 @@ IMPL(chown) } #endif +#ifdef TARGET_NR_chown32 +IMPL(chown32) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chown(p, arg2, arg3)); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(chroot) { char *p = lock_user_string(arg1); @@ -10815,16 +10830,37 @@ IMPL(setfsgid) return get_errno(setfsgid(arg1)); } +#ifdef TARGET_NR_setfsgid32 +IMPL(setfsgid32) +{ + return get_errno(setfsgid(arg1)); +} +#endif + IMPL(setfsuid) { return get_errno(setfsuid(arg1)); } +#ifdef TARGET_NR_setfsuid32 +IMPL(setfsuid32) +{ + return get_errno(setfsuid(arg1)); +} +#endif + IMPL(setgid) { return get_errno(sys_setgid(low2highgid(arg1))); } +#ifdef TARGET_NR_setgid32 +IMPL(setgid32) +{ + return get_errno(sys_setgid(arg1)); +} +#endif + IMPL(setgroups) { int gidsetsize = arg1; @@ -11017,6 +11053,13 @@ IMPL(setuid) return get_errno(sys_setuid(low2highuid(arg1))); } +#ifdef TARGET_NR_setuid32 +IMPL(setuid32) +{ + return get_errno(sys_setuid(arg1)); +} +#endif + #ifdef TARGET_NR_sigaction IMPL(sigaction) { @@ -11943,30 +11986,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_chown32 - case TARGET_NR_chown32: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chown(p, arg2, arg3)); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_setuid32 - case TARGET_NR_setuid32: - return get_errno(sys_setuid(arg1)); -#endif -#ifdef TARGET_NR_setgid32 - case TARGET_NR_setgid32: - return get_errno(sys_setgid(arg1)); -#endif -#ifdef TARGET_NR_setfsuid32 - case TARGET_NR_setfsuid32: - return get_errno(setfsuid(arg1)); -#endif -#ifdef TARGET_NR_setfsgid32 - case TARGET_NR_setfsgid32: - return get_errno(setfsgid(arg1)); -#endif #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { @@ -13139,6 +13158,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_chown SYSCALL(chown); +#endif +#ifdef TARGET_NR_chown32 + SYSCALL(chown32); #endif SYSCALL(chroot); #ifdef TARGET_NR_connect @@ -13492,8 +13514,17 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(setdomainname); SYSCALL(setfsgid); +#ifdef TARGET_NR_setfsgid32 + SYSCALL(setfsgid32); +#endif SYSCALL(setfsuid); +#ifdef TARGET_NR_setfsuid32 + SYSCALL(setfsuid32); +#endif SYSCALL(setgid); +#ifdef TARGET_NR_setgid32 + SYSCALL(setgid32); +#endif SYSCALL(setgroups); #ifdef TARGET_NR_setgroups32 SYSCALL(setgroups32); @@ -13529,6 +13560,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(settimeofday); SYSCALL(setsid); SYSCALL(setuid); +#ifdef TARGET_NR_setuid32 + SYSCALL(setuid32); +#endif #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif From patchwork Sun Jun 10 03:01:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138167 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2610690lji; Sat, 9 Jun 2018 21:08:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLy7deiMzsR5CxSO0rpK/kSYMR0nAZHZyYk2srWdK2WwR6zqFWoPi+BvsKG43RDuacS5hDH X-Received: by 2002:ac8:1842:: with SMTP id n2-v6mr11601082qtk.124.1528603731641; Sat, 09 Jun 2018 21:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603731; cv=none; d=google.com; s=arc-20160816; b=dhZhbqqTfnqW72AJa2fKHSgw6ewARxnKFMw0c4P/aUwcyboBhGBe24tNBg7yzn4Wdk pqfK9W24VvASk/8W/cfzOzeWO12DFQug5O+2QSIH57g9V02tyXUfIEam+OZHrCYF3qwm jVM3fyLuEe9LK+7edvfAhOafwzS6gP4K0uG7OCLmuHgJxwSyduY+USLfn8MiiylFObbw XJBNvEkKNB95Q0UK8ISnIXjQS3GKjmzQPPPC7j+DiYU2g1GnhT3rEr6rOJyR3MqIf3vT kCysqv7ZOTcF7MT+bNkBtjgfW3Z1/qWIKuzrH/UFR9cLWFqldefhT4g81m8gl4Yf9bX2 j/ww== 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:arc-authentication-results; bh=jJu66j4M4vMFwAAiOgcsW0pzqL3MDUUhI187vdBYAZk=; b=T8NemanCzSSa/Fqd35n9GhcciqnsGV5gkV7SFsfVq9whtXwBgn0qJ00S2jZGDn1rKA x5pzBPZI1kbHl10up25YwSkBgKvzwsOh6X+pii96Q/Qpqcgs6Lzbse2/uYxh9ydoEtiy h4+zXnd2MBgCMHtu9Bmhx+8eMOA5wMtSFJJyL8tNs3M2SmNxmxDZe39QsIlwPkfSySbu vGwQDYXf+qY730+S3UFux0AZsYrSCPXpPv8MOkgB8kUeCzrmxCM+oJ6lRHxUZNaSsSQQ Z7pymZ/Oemw7Wb2PAhN9FLQAIThJv5KQOF3Zl24r5Y+zKtlmZWkzuG54gxq8/4ioFUmt YbPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aLpQ8Ze9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p67-v6si4590047qkh.201.2018.06.09.21.08.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aLpQ8Ze9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRret-0003M4-34 for patch@linaro.org; Sun, 10 Jun 2018 00:08:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfU-000489-8o for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfR-0004Pj-2g for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:24 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:44846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfQ-0004OE-R0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:20 -0400 Received: by mail-pg0-x242.google.com with SMTP id p21-v6so8128641pgd.11 for ; Sat, 09 Jun 2018 20:05: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=jJu66j4M4vMFwAAiOgcsW0pzqL3MDUUhI187vdBYAZk=; b=aLpQ8Ze9s58xHR8gKPSx8KG4i0+lHMYx5FXAXJiE28zDguS2TGt+inQIHyUQnrXf8h OgH2/xppAxgFF8ddFdeAnu8ODpCVFwlptBftufKycQIrMTfxsZGmV/t3Zyzn2tkNa+kK mRTnEtDsxX+eLEoKI8710ZJEB4/JjI3UTpV78= 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=jJu66j4M4vMFwAAiOgcsW0pzqL3MDUUhI187vdBYAZk=; b=QQkhNn3LdVJamiQAIIYe1KHC56JnieZm742zPGYuztBBra+0iG9TGdgvzSflkdKmpF ig1dcWMFtDkHmioWTDGWLM2yoGH9BB4KslTCyxyXuAlWusf+T8qMpuIa9SpaQihtMELC qIow2uq+8ISWZCEiqjcL2EbEwqeGNFK3H2ydvQ8+agsKR17sYPucjxICaDHgU1OZ1N5Y xy9HEC4VjMHCdj3LWmgksvNu58iBHA+5qTl/RJ3HrSLrx2piw0NZbv7SBUZN/kyKXeTl CvA/e1Zxqyc48m+z+gd5nX9toVTkb6BH55sduRWI1ImnU9qtW7rZnUiXk+GWlN6DTcPB fIIw== X-Gm-Message-State: APt69E1mHHBZ8Li8NG9rPCopR6cTdpNoEqtHo7uuGcp4Lvd2fCyLLGzn EzcngIGNxfD/7IFk660T/GNJKgt0jTs= X-Received: by 2002:a65:6356:: with SMTP id p22-v6mr10457431pgv.20.1528599919552; Sat, 09 Jun 2018 20:05:19 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:55 -1000 Message-Id: <20180610030220.3777-84-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 083/108] linux-user: Split out mincore 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 define mincore; remove the ifdef. At the same time, fix two bugs in the implementation: (1) The pages to check need not be readable, only valid. (2) The third argument is an output vector, which (2a) needs to be writable, and (2b) sized properly. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fc7f301519..afe6df5efa 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9144,6 +9144,31 @@ IMPL(lstat64) } #endif +IMPL(mincore) +{ + void *a, *p; + size_t veclen; + abi_long ret; + + /* Note that this is not the same as VERIFY_WRITE or VERIFY_READ. + * Moreover, we want to test the exact pages of guest memory. + */ + if (page_check_range(arg1, arg2, PAGE_VALID)) { + return -TARGET_ENOMEM; + } + a = g2h(arg1); + + veclen = DIV_ROUND_UP(arg2, TARGET_PAGE_SIZE); + p = lock_user(VERIFY_WRITE, arg3, veclen, 0); + if (!p) { + return -TARGET_EFAULT; + } + + ret = get_errno(mincore(a, arg2, p)); + unlock_user(p, arg3, veclen); + return ret; +} + #ifdef TARGET_NR_mkdir IMPL(mkdir) { @@ -11986,24 +12011,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_mincore - case TARGET_NR_mincore: - { - void *a = lock_user(VERIFY_READ, arg1, arg2, 0); - if (!a) { - return -TARGET_ENOMEM; - } - p = lock_user_string(arg3); - if (!p) { - ret = -TARGET_EFAULT; - } else { - ret = get_errno(mincore(a, arg2, p)); - unlock_user(p, arg3, ret); - } - unlock_user(a, arg1, 0); - } - return ret; -#endif #ifdef TARGET_NR_arm_fadvise64_64 case TARGET_NR_arm_fadvise64_64: /* arm_fadvise64_64 looks like fadvise64_64 but @@ -13328,6 +13335,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_lstat64 SYSCALL(lstat64); #endif + SYSCALL(mincore); #ifdef TARGET_NR_mkdir SYSCALL(mkdir); #endif From patchwork Sun Jun 10 03:01:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138154 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2605052lji; Sat, 9 Jun 2018 21:00:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlh4SFvXXP+F8KOt8/nX+bO7KBcFqiSlUauOOtumKxrg5e8pkgIg7QiWSKYwPV6a5iEiDR X-Received: by 2002:a37:ba47:: with SMTP id k68-v6mr10546686qkf.105.1528603214683; Sat, 09 Jun 2018 21:00:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603214; cv=none; d=google.com; s=arc-20160816; b=k9k3adx5iAPG5/cw9JhhY8XNV6Z1jJ1HNnfDULCKTXcxKuek5QL5PZWIIO8tBtovht +w9HLTfUEyGo++hWEiohCfTIAfrqmvz/u7X8bG9teOTjFvt5Kr8dTyoy8CPFfft1XzMe DVj0TIhY2oIimCgEnxKdlYMY951ZwFgCrbeJ3svlLsutB2ZzlqFrCJPI5wjuwom3nxND zh2G2NzzG3pk0jz/8GTJXKnkdh6KOB4Ka98bTJTmCA5RFQnWIsnTsG8HwRob1kMGio4X MIPJZfvkzrrvEzw2svhVuhyAy8Y2AFo6j3eqI4bJQXquvS8XWd92Y4/+bzU0dbOlO9ho 3rLA== 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:arc-authentication-results; bh=OXhzWrCzOnky8k7+EQTtpUJxLpSgxeCkisL1amDlPa4=; b=uXMWdG1l6vYWwAJMGl4O3wMPEmBq/n7Yd+lXw+NIOSDqbxkAG7I+t+MZ2jnt4MCspa AR4nZCPDpk4D8exRLKnylTPC9EVYuWkafJi5wM0DaK/keCb4FdILf7qnorPaICPdopb3 Iq+ZtjSlIYRzjbr5KW7PAElB0qqb2z3IV6UEdly+zpP1cGCR/9HNk0D65lWBV6KDOEiT AymiCgcH3zbIjnCdiYiHQ2aEvE48ILf1z9eLPXUTd7EEEJu4ne2gIRuxPOs0fwZbd6Fx Cv6MRauDDL7IMGxWLQOTrZUaEKgYLA1QRe61vWbjdBy6cdD9jkTu6ob0Iw4UxLR5OOJJ 6c0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MMRP6Ft/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m100-v6si153858qkh.104.2018.06.09.21.00.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:00:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MMRP6Ft/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrWY-0004HG-4Z for patch@linaro.org; Sun, 10 Jun 2018 00:00:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfU-00048D-9f for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfS-0004Rp-Px for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:24 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:38930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfS-0004QX-B0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:22 -0400 Received: by mail-pg0-x243.google.com with SMTP id w12-v6so8139803pgc.6 for ; Sat, 09 Jun 2018 20:05: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=OXhzWrCzOnky8k7+EQTtpUJxLpSgxeCkisL1amDlPa4=; b=MMRP6Ft/HTwnpZn8ieOBlReaYXl1m16/jw71GaGLHuY9sQ+qYzOZCOasGdOSW87Pcf qW7tZ71cD+eAl79OOm98h/imDs32o/bKaipQEXVaBZWAUSjEGTgqBzVWR533Ef9AuOcw s75oTd8pvXOII6OhLYvKKik/jAOtX63UmZwmY= 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=OXhzWrCzOnky8k7+EQTtpUJxLpSgxeCkisL1amDlPa4=; b=RKS/T08Jqe/7YK+ZqGlMsX1JKDaSyc9vlazBIs8Zt1XkKEzEbkEauBuMTxyOv5mobt n9n3MEqw88U2V7dz71FRzHcVkEy/xuaxRgNg6VGtw9YxVdIsasxAs0rzapoDMrqQP21K pBk4oPIG53uE6ZkfvlvKkc4ULMDLfFITBbCoZ79/SZIDtNOtG+6/HQKrmeJCo3tc1rSN b6LY/OWdLa52NreMONbZA0pJ7rvEuAeH7aDjRGcSZxXqV1XsVpWFL9nrvlscWbJly+76 p+OMm0hF7hAOV1LTvS4c3qdMzHXW3lkzDMYho7bIy6WlUI41wBxXm/gHA5LBKQMPpZR/ p46A== X-Gm-Message-State: APt69E1CUdUDYA7zGs1BLZTZbKjjWc1/M1/jj7meH5RFxpjC9MFOa+lS JCjkgdM8EgX3t6HTP2c0xzmVNC+u1jE= X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr5032809pgv.306.1528599921141; Sat, 09 Jun 2018 20:05:21 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:56 -1000 Message-Id: <20180610030220.3777-85-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 084/108] linux-user: Split out fadvise64, fadvise64_64 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" Generalize the s390x guest advice frobbing to support s390x as a host. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 189 ++++++++++++++++++++++++++----------------- 1 file changed, 113 insertions(+), 76 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index afe6df5efa..5f056cf660 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8110,6 +8110,109 @@ IMPL(faccessat) return ret; } +/* The advise values for DONTNEED and NOREUSE differ for s390x. + * Which means that we need to translate for the host as well. + */ +static int target_to_host_fadvise64_advice(int advice) +{ + switch (advice) { + case 0 ... 3: + return advice; +#ifdef TARGET_S390X + case 6: + return POSIX_FADV_DONTNEED; + case 7: + return POSIX_FADV_NOREUSE; +#else + case 4: + return POSIX_FADV_DONTNEED; + case 5: + return POSIX_FADV_NOREUSE; +#endif + default: + return -TARGET_EINVAL; + } +} + +#if TARGET_ABI_BITS == 32 +# ifdef TARGET_NR_fadvise64 +IMPL(fadvise64) +{ + abi_long ret; + off_t off, len; + int advice; + + /* 5 args: fd, offset (high, low), len, advice */ + if (regpairs_aligned(cpu_env, num)) { + /* offset is in (3,4), len in 5 and advice in 6 */ + off = target_offset64(arg3, arg4); + len = arg5; + advice = arg6; + } else { + off = target_offset64(arg2, arg3); + len = arg4; + advice = arg5; + } + advice = target_to_host_fadvise64_advice(advice); + if (advice < 0) { + return advice; + } + ret = posix_fadvise(arg1, off, len, advice); + return -host_to_target_errno(ret); +} +# endif +/* ??? TARGET_NR_arm_fadvise64_64 should be TARGET_NR_fadvise64_64. + * The argument ordering is the same as ppc32 and xtensa anyway. + */ +# ifdef TARGET_NR_arm_fadvise64_64 +# define TARGET_NR_fadvise64_64 TARGET_NR_arm_fadvise64_64 +# endif +# ifdef TARGET_NR_fadvise64_64 +IMPL(fadvise64_64) +{ + abi_long ret; + off_t off, len; + int advice; + +# if defined(TARGET_ARM) || defined(TARGET_PPC) || defined(TARGET_XTENSA) + /* 6 args: fd, advice, offset (high, low), len (high, low) */ + advice = arg2; + off = target_offset64(arg3, arg4); + len = target_offset64(arg5, arg6); +# else + /* 6 args: fd, offset (high, low), len (high, low), advice */ + if (regpairs_aligned(cpu_env, num)) { + /* offset is in (3,4), len in (5,6) and advice in 7 */ + off = target_offset64(arg3, arg4); + len = target_offset64(arg5, arg6); + advice = arg7; + } else { + off = target_offset64(arg2, arg3); + len = target_offset64(arg4, arg5); + advice = arg6; + } +# endif + advice = target_to_host_fadvise64_advice(advice); + if (advice < 0) { + return advice; + } + ret = posix_fadvise(arg1, off, len, advice); + return -host_to_target_errno(ret); +} +# endif +#else /* TARGET_ABI_BITS == 64 */ +# if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_fadvise64) +IMPL(fadvise64) +{ + int advice = target_to_host_fadvise64_advice(arg4); + if (advice < 0) { + return advice; + } + return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, advice)); +} +# endif +#endif /* end fadvise64 handling */ + IMPL(fchdir) { return get_errno(fchdir(arg1)); @@ -12011,82 +12114,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_arm_fadvise64_64 - case TARGET_NR_arm_fadvise64_64: - /* arm_fadvise64_64 looks like fadvise64_64 but - * with different argument order: fd, advice, offset, len - * rather than the usual fd, offset, len, advice. - * Note that offset and len are both 64-bit so appear as - * pairs of 32-bit registers. - */ - ret = posix_fadvise(arg1, target_offset64(arg3, arg4), - target_offset64(arg5, arg6), arg2); - return -host_to_target_errno(ret); -#endif - -#if TARGET_ABI_BITS == 32 - -#ifdef TARGET_NR_fadvise64_64 - case TARGET_NR_fadvise64_64: -#if defined(TARGET_PPC) || defined(TARGET_XTENSA) - /* 6 args: fd, advice, offset (high, low), len (high, low) */ - ret = arg2; - arg2 = arg3; - arg3 = arg4; - arg4 = arg5; - arg5 = arg6; - arg6 = ret; -#else - /* 6 args: fd, offset (high, low), len (high, low), advice */ - if (regpairs_aligned(cpu_env, num)) { - /* offset is in (3,4), len in (5,6) and advice in 7 */ - arg2 = arg3; - arg3 = arg4; - arg4 = arg5; - arg5 = arg6; - arg6 = arg7; - } -#endif - ret = posix_fadvise(arg1, target_offset64(arg2, arg3), - target_offset64(arg4, arg5), arg6); - return -host_to_target_errno(ret); -#endif - -#ifdef TARGET_NR_fadvise64 - case TARGET_NR_fadvise64: - /* 5 args: fd, offset (high, low), len, advice */ - if (regpairs_aligned(cpu_env, num)) { - /* offset is in (3,4), len in 5 and advice in 6 */ - arg2 = arg3; - arg3 = arg4; - arg4 = arg5; - arg5 = arg6; - } - ret = posix_fadvise(arg1, target_offset64(arg2, arg3), arg4, arg5); - return -host_to_target_errno(ret); -#endif - -#else /* not a 32-bit ABI */ -#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_fadvise64) -#ifdef TARGET_NR_fadvise64_64 - case TARGET_NR_fadvise64_64: -#endif -#ifdef TARGET_NR_fadvise64 - case TARGET_NR_fadvise64: -#endif -#ifdef TARGET_S390X - switch (arg4) { - case 4: arg4 = POSIX_FADV_NOREUSE + 1; break; /* make sure it's an invalid value */ - case 5: arg4 = POSIX_FADV_NOREUSE + 2; break; /* ditto */ - case 6: arg4 = POSIX_FADV_DONTNEED; break; - case 7: arg4 = POSIX_FADV_NOREUSE; break; - default: break; - } -#endif - return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4)); -#endif -#endif /* end of 64-bit ABI fadvise handling */ - #ifdef TARGET_NR_madvise case TARGET_NR_madvise: /* A straight passthrough may not be safe because qemu sometimes @@ -13189,6 +13216,16 @@ static impl_fn *syscall_table(unsigned num) SYSCALL_WITH(exit_group, enosys); #endif SYSCALL(faccessat); +#ifdef TARGET_NR_fadvise64 + SYSCALL(fadvise64); +#endif +#ifdef TARGET_NR_fadvise64_64 +# if TARGET_ABI_BITS == 32 + SYSCALL(fadvise64_64); +# else + SYSCALL_WITH(fadvise64_64, fadvise64); +# endif +#endif SYSCALL(fchdir); SYSCALL(fchmod); SYSCALL(fchmodat); From patchwork Sun Jun 10 03:01:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138161 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2608808lji; Sat, 9 Jun 2018 21:05:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKRvlSFrtZhLnUGGjxhNwYaaIVENMQUsPlmPnJI6S53sLyzNWuHfm0pxPxZMRn2Z7z8hnlm X-Received: by 2002:a37:1563:: with SMTP id f96-v6mr10599392qkh.150.1528603543059; Sat, 09 Jun 2018 21:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603543; cv=none; d=google.com; s=arc-20160816; b=ezjK6UxoBv5GFNEEgH/Wg3oV/VvfFNTQ2Ff6RA+C2h/KNem2Y0oatWtpsuMpzAO9fA misCjAPYRjsX4aEvOHaB1gxEamPLGePkeYjNNhiW0gUBcfw9Z53ZlP9f2QfyvH0pT19M FmI8i1HcN+5VNAhxLf9VF9yvHg+Pyu8adZH6er1y4S226I51FZ5jzMYnaLqlfXGWZbt2 IHt/DTSaF3JT4jW/aV67RgnV94BWGPzMljQmiI1LS2IEflixazXMKirUfA9v3heUyYvF pGpCt0ee1fM9iXhVx5LTDL/zzopXCH6zkyK5fsBpB1cqdsmVNH3/LUJ1kX41YyTxgbAH 16AA== 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:arc-authentication-results; bh=necN1lO+nHCcY51p1EFxrAesRsn55Shjd6qdfMOwjsg=; b=oINIc1c/RYgc0PmFQa9wXzSHEauIfKCdEpZQV8iNg4xS2STnwNC+9TkbK5kZiQVeas yaczUK1nw8dbfwOYQp6Ro4gJ/V9qc1a1RA5s56MIXbCl1ZJS4D5QwNj78PU2MFQWskpX QCeqYBzd/mRTKkb1CrfQ308WxUw/RU+mEwEszJqPWBDegtIFUKT3kCXfrkCXpimgqGf2 8eToTbZbHpVqe1lg6yJX2yq78rykDTm9zkRi3NXWhUpJwd1paEWUIw031/T3BYOJfUSu ddBQn+Txu4xCULX6pJdqpRozuNNnolVW+cVAx6hpDq38+iCBW9ugZnJVgpX3bU6IhWu6 p3RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MM9gzF8U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o26-v6si15118158qto.16.2018.06.09.21.05.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:05:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MM9gzF8U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrbq-0000qq-E3 for patch@linaro.org; Sun, 10 Jun 2018 00:05:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfV-0004AM-Rw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfU-0004Tt-JY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:25 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfU-0004SS-AV for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:24 -0400 Received: by mail-pf0-x241.google.com with SMTP id a12-v6so8499859pfi.3 for ; Sat, 09 Jun 2018 20:05: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=necN1lO+nHCcY51p1EFxrAesRsn55Shjd6qdfMOwjsg=; b=MM9gzF8U9JSe63RMFVVqsvXvuh/7WEsofGgCSlAtz/fLP8RzpL7USVSarGHiCtDJt3 iyQ+6333TQowtaZJiGCc+txkA6OOGEoBxVdbEh/k4OMsjwQ8RMhC3L+ht72YhrVK0/+U +QkVJy21BM50VvobISm+uDrpCW6/cCH41HsvA= 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=necN1lO+nHCcY51p1EFxrAesRsn55Shjd6qdfMOwjsg=; b=US7IDC7SDM/AOcJ4Sj0fK92O75pqUM7ZTTTKXzQBjXdU9AYsz/yxiQX0mbISctfAll CHgzkf72ILctFmDs/Z6Yb7ZNa+ONkiM0o1XqxSmkeOTJoxamzGD8cfK5zDDjTwpYfAne O9NWjmnjqTEZ9e7giTz+JoIiFmWu+4IyXRnZYQGQ1gkB5c/ffihX2RDfQdbVzzc1Yw0B xzNO/+XWiOkgSY2QFsTaWzYtoc7EsSObdHq4LUrJ9j1qCGGBEY2yic5qT3ZPjKAhjibE hNsyFJiclsDPgAHgwdWSUQn0ao+DhpHQ8a2NN6HZyIMenlqg0rargFn2PSPlvMk5qun7 zUzg== X-Gm-Message-State: APt69E2Uf2Nr+kUJIt+d1gUcFhaGD6/FVjjrQBsMe2zXNPxyCVKaJEs4 V/GsULB12gYNuIfxNPEi5Ug8S3c0MTw= X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr10271520pgt.98.1528599923176; Sat, 09 Jun 2018 20:05:23 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:57 -1000 Message-Id: <20180610030220.3777-86-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 085/108] linux-user: Split out cacheflush, fcntl64, getpagesize, madvise 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 define madvise; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 144 ++++++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 64 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5f056cf660..bcddb28947 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7675,6 +7675,14 @@ IMPL(brk) return do_brk(arg1); } +#ifdef TARGET_NR_cacheflush +IMPL(cacheflush) +{ + /* Self-modifying code is handled automatically, so nothing needed. */ + return 0; +} +#endif + IMPL(capget) { struct target_user_cap_header *target_header; @@ -8269,6 +8277,52 @@ IMPL(fcntl) } #endif +#if TARGET_ABI_BITS == 32 +IMPL(fcntl64) +{ + int cmd; + struct flock64 fl; + from_flock64_fn *copyfrom = copy_from_user_flock64; + to_flock64_fn *copyto = copy_to_user_flock64; + abi_long ret; + +#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 -TARGET_EINVAL; + } + + switch (arg2) { + case TARGET_F_GETLK64: + ret = copyfrom(&fl, arg3); + if (ret) { + return ret; + } + ret = get_errno(fcntl(arg1, cmd, &fl)); + if (ret == 0) { + ret = copyto(arg3, &fl); + } + return ret; + + case TARGET_F_SETLK64: + case TARGET_F_SETLKW64: + ret = copyfrom(&fl, arg3); + if (ret) { + return ret; + } + return get_errno(safe_fcntl(arg1, cmd, &fl)); + + default: + return do_fcntl(arg1, arg2, arg3); + } +} +#endif + IMPL(fdatasync) { return get_errno(fdatasync(arg1)); @@ -8709,6 +8763,13 @@ IMPL(getitimer) return ret; } +#ifdef TARGET_NR_getpagesize +IMPL(getpagesize) +{ + return TARGET_PAGE_SIZE; +} +#endif + #ifdef TARGET_NR_getpeername IMPL(getpeername) { @@ -9247,6 +9308,15 @@ IMPL(lstat64) } #endif +IMPL(madvise) +{ + /* A straight passthrough may not be safe because qemu sometimes + turns private file-backed mappings into anonymous mappings. + This will break MADV_DONTNEED. + This is a hint, so ignoring and returning success is ok. */ + return 0; +} + IMPL(mincore) { void *a, *p; @@ -12114,70 +12184,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_madvise - case TARGET_NR_madvise: - /* A straight passthrough may not be safe because qemu sometimes - turns private file-backed mappings into anonymous mappings. - This will break MADV_DONTNEED. - 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(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 */ - return 0; -#endif -#ifdef TARGET_NR_getpagesize - case TARGET_NR_getpagesize: - return TARGET_PAGE_SIZE; -#endif case TARGET_NR_gettid: return get_errno(gettid()); #ifdef TARGET_NR_readahead @@ -13179,6 +13185,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(bind); #endif SYSCALL(brk); +#ifdef TARGET_NR_cacheflush + SYSCALL(cacheflush); +#endif SYSCALL(capget); SYSCALL(capset); #ifdef CONFIG_CLOCK_ADJTIME @@ -13236,6 +13245,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fchownat); #ifdef TARGET_NR_fcntl SYSCALL(fcntl); +#endif +#if TARGET_ABI_BITS == 32 + SYSCALL(fcntl64); #endif SYSCALL(fdatasync); SYSCALL(flock); @@ -13292,6 +13304,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getgroups32); #endif SYSCALL(getitimer); +#ifdef TARGET_NR_getpagesize + SYSCALL(getpagesize); +#endif #ifdef TARGET_NR_getpeername SYSCALL(getpeername); #endif @@ -13372,6 +13387,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_lstat64 SYSCALL(lstat64); #endif + SYSCALL(madvise); SYSCALL(mincore); #ifdef TARGET_NR_mkdir SYSCALL(mkdir); From patchwork Sun Jun 10 03:01:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138158 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2607145lji; Sat, 9 Jun 2018 21:03:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIh/gAhueD6oCqN8eR5/BTsN/jaXlrHE7yFjxJpH52Afzyt9V0NqHmw42zMWlczqDOEcCu7 X-Received: by 2002:a0c:a916:: with SMTP id y22-v6mr10976066qva.179.1528603390041; Sat, 09 Jun 2018 21:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603390; cv=none; d=google.com; s=arc-20160816; b=vjE14fbgJJPLvolS1UfUArnreNgkGuB31HnKkA8MYaPDCzO+3FIRg7OUZK//St6YgU VRRdOyanrQTmAArsI7UR90fa+i/maRVxYQIGU1YfOxvlFyGyZWNhF18rKqRP12S8QVcL TDygChUvNgJ9OkCns+Q/7tL3XPRFCDyiayPF7J3Lskrbk6CntgyJN80Hb5LeVl0ZGMo7 ymlzjgwQGpMuaycvb0dr1gSrmRNJgFExgboI1lu32MBMBYAfu9UcGGuh69wKMtbH71Rj sEV8Vr8OtckVGQXVwnqaOpxZV7e8Dj6tEaS7d0UazPmkFxx61viO9a09mo5qbk8UUoiO Zd/g== 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:arc-authentication-results; bh=6r3VIlXxdv24PQAq4vDjTSBr3IMhJIKhmjDNerJdXbw=; b=cXNHViyJjJqCZYSm/3Tl4AxS/HtdC79oqji56Nm+wwsHixCwXRCiv4RMmldhjuE5mk do8Fwxs8tBRlZ2ZHZ1bupl7nRY4emNWKUECSuVyKFGR4LZ8mGH5a0OTlhpLlRnHzTtCJ nSsXyK+ljg9h3cxO+u7HrbJKW/eZMdAN859Li4GcSRhGKjDnCTy2IH4WPMqhDKiblUii 0qkz82d+M28V90GK3gByPhcLrKQ3DrFLjwzElXJSIQ2es3q44GbaWTxtkb893iozezdC GoYPv1juTw3w1Awmisvi2FsyYpJNHOeqOuK0wAfrgVFMYN1aWXt0/hyrBze7t/jdoozV PeVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ISIgBl1K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s69-v6si5632108qkl.373.2018.06.09.21.03.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:03:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ISIgBl1K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZN-0006lA-E9 for patch@linaro.org; Sun, 10 Jun 2018 00:03:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfX-0004ED-NA for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfW-0004WO-7u for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:27 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:34417) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfW-0004VT-0k for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:26 -0400 Received: by mail-pf0-x243.google.com with SMTP id a63-v6so8499989pfl.1 for ; Sat, 09 Jun 2018 20:05: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=6r3VIlXxdv24PQAq4vDjTSBr3IMhJIKhmjDNerJdXbw=; b=ISIgBl1KqUN3YGBvalPwt4ncA35AYIwfinXBvReFxZloCyarlFfuYu+qpYXaxCdrG2 /l2I7zGzRDcLUR/vTCFtlI3ItoGWzQ1E6oaCFAF6vX/yG84G5llnqMD/LP/pN9nrn/+E bVKJU8cULeD1czBE9FjMWtY1c7q6f+qVX4/Ig= 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=6r3VIlXxdv24PQAq4vDjTSBr3IMhJIKhmjDNerJdXbw=; b=T4L1lG2y84bXpZOcZkuc7+KbeDyJeLyfhaMZvWRhm7G09F5A+K1BR76Y72rIzxbA/R DWjovlcEsQ6nXpfQYTldnt9dpzQ1B2Of6DLR57SileWqFMz/ISMR9LZ+akFvIVagwZS7 G8Lf4HHgKqPPipZyEfrGUVHOSeX+QMMzlsHMiZAup0ZmoqgbwLwTbGcHQQEh0wN/+LQG AE8WkH9/YIjhrPvtCJt6bgSxyM/jE8z5P5GM8x80GKTwWFSdy87Vmouvf3yamkA0ToXX JdD/cc4n4geZ3kOmB4bgSklsAuKOxW5JbeIT1cP6pConrZ7sDzg83HjJ5MyyzXEcfEP6 8zUg== X-Gm-Message-State: APt69E3S+y7PdcweIPFigC+V/hgemWNgCExGQ3PFhEWQ7CuYxsgE56o+ lPqWBM0drX0EIoU4uV2vmi7Pc2OdmTQ= X-Received: by 2002:a65:5d8a:: with SMTP id f10-v6mr10636494pgt.119.1528599924889; Sat, 09 Jun 2018 20:05:24 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:58 -1000 Message-Id: <20180610030220.3777-87-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 086/108] linux-user: Split out gettid, readahead 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 define readahead; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bcddb28947..0897449273 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8950,6 +8950,11 @@ IMPL(getsockopt) } #endif +IMPL(gettid) +{ + return get_errno(gettid()); +} + IMPL(gettimeofday) { struct timeval tv; @@ -10337,6 +10342,20 @@ static abi_long do_readlinkat(abi_long dirfd, abi_long target_path, return ret; } +IMPL(readahead) +{ +#if TARGET_ABI_BITS == 32 + if (regpairs_aligned(cpu_env, num)) { + arg2 = arg3; + arg3 = arg4; + arg4 = arg5; + } + return get_errno(readahead(arg1, target_offset64(arg2, arg3) , arg4)); +#else + return get_errno(readahead(arg1, arg2, arg3)); +#endif +} + #ifdef TARGET_NR_readlink IMPL(readlink) { @@ -12184,22 +12203,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_gettid: - return get_errno(gettid()); -#ifdef TARGET_NR_readahead - case TARGET_NR_readahead: -#if TARGET_ABI_BITS == 32 - if (regpairs_aligned(cpu_env, num)) { - arg2 = arg3; - arg3 = arg4; - arg4 = arg5; - } - ret = get_errno(readahead(arg1, target_offset64(arg2, arg3) , arg4)); -#else - ret = get_errno(readahead(arg1, arg2, arg3)); -#endif - return ret; -#endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr case TARGET_NR_listxattr: @@ -13343,6 +13346,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getsockopt SYSCALL(getsockopt); #endif + SYSCALL(gettid); SYSCALL(gettimeofday); #ifdef TARGET_NR_getuid SYSCALL(getuid); @@ -13475,6 +13479,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(pwrite64); SYSCALL(pwritev); SYSCALL(read); + SYSCALL(readahead); #ifdef TARGET_NR_readlink SYSCALL(readlink); #endif From patchwork Sun Jun 10 03:01:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138162 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2608990lji; Sat, 9 Jun 2018 21:05:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJjLD8ilBWhCPttKvgotz0wGpNdl2rs5HKWUJVcHEfvg/wSUF/Xka1xbblNGEcTjsSlXZ/y X-Received: by 2002:aed:3ac7:: with SMTP id o65-v6mr11560271qte.127.1528603558930; Sat, 09 Jun 2018 21:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603558; cv=none; d=google.com; s=arc-20160816; b=deUaJqiD1gYdyxZe2hNVEYcq74HrqLQQq8iKWmwGHKjbcrfzVGjCqTBUSvhRZTdmIN 91cLkx4fkWXjzGgqHTI8xS99pWyoI/kSPEgGYsFby3hw8ns02O6vqrv5vanrINQa82wX edrHiPMFsnAkbzEMSViuaEeaPD2BHbLml2mGMsczpnGTr9fWfNfzE7ORQaN856tTftPD 0hEvNyL72KssA9BxT5GRMKiuG/UhM92/SKZCtW0YCZIuUidH/Ji/1GrUTy6Q74725iz8 RlRfk4NU2mkO9JEJR2Tj/S2FsHHuM8F/agYHQ8+LEkdIwDxWKeZob/nygPu92X3mycmW 0YUw== 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:arc-authentication-results; bh=XyAo9SXJ9Cfar4HnwBLCXuw/sTqKMfM0/MatVpqiLrw=; b=RDytjrS8GoUIY/huURihRMfet89Mm43LPnP3NtB5BhHmC5MWLcmfY30Gixh2fVQAkq mv1SktT+77ISEXM9Z0ZbFoK7dL5SejICYmyw9tW0sLh58dBOzhafvX0VKuCsrFhVjrqe zmIsOqmHfzPUcWLH038xPWeaC8WfqIHwDkmFP4DJEQp1UaBZZ90J+vKDiGZC3VLZw0pa qX7vbN+Qbrki4VUo1SbhBQ+cs7TTQlit0KC6SSMT1ej3hxrD2s5+0g8BynDHEsq0Wx0a nUIHQbE33qsXWkz0BDsMRoEHJsNguxljRbEmRaTFI0OcZXPyLfh9Qw5Qup2KVa6uYhSz gl4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jZ384wzL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i187-v6si5322160qke.393.2018.06.09.21.05.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:05:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jZ384wzL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrc6-0000lE-Bf for patch@linaro.org; Sun, 10 Jun 2018 00:05:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfa-0004Hb-9c for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfY-0004Yq-IL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:30 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:38123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfY-0004Xw-3O for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:28 -0400 Received: by mail-pf0-x243.google.com with SMTP id b74-v6so8494653pfl.5 for ; Sat, 09 Jun 2018 20:05: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=XyAo9SXJ9Cfar4HnwBLCXuw/sTqKMfM0/MatVpqiLrw=; b=jZ384wzLXjPjBaDsTo9lKmCSXkNBNO1ZSIuatfKRom5zVXojXVqQG848bHluxnnVwt JZyaBs/KO6aLSZYFyl12QXIn+WrqRzegWuCE1iq6mYPTzm/q5/+oW+MjBl5yCFqGdr/r uMJhDbWxlojJhPfsUkY9SKlirQ0g3GE2T9ed0= 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=XyAo9SXJ9Cfar4HnwBLCXuw/sTqKMfM0/MatVpqiLrw=; b=I627SK4+9e1dm1LNjFHljj2YFdqDZfmVTW9tZAhVPC4ZbqZZhq4n1ZCtQOY9KCdony tTM0Ht3K+pFj0NO6VUhJe1l5eVwBpKj2EslQGa6CqvJHo2XdGXzY262f8UEZhLX5XED/ OexhePk3uwKb3viZJBlndX6Hnlm418gXS9Lx249U0cYgkYVRuJCuxQSA8qbtjPboz0Hs SsIH0Y/k/HAPggVmbnafEafotlDDIODeUyVW5WUArvMQeUsJoVrpsiWpQVt3eNNi1o2/ DlITIKqGZ0fjD/VSxfdj4b3IFFU7pr4wRSGai+q4kdOY9nYdYBgu+Q+W2LiYkdWKtMb5 hCeg== X-Gm-Message-State: APt69E09qYE7Id2pJzeSZ7WHhVuEMN4cqNJRem3tBNyK5Sr6wPl9rp0+ cwOnW9YNgAu8tkuzmQ/mFoJxcQBKFk8= X-Received: by 2002:a65:65d6:: with SMTP id y22-v6mr10399518pgv.270.1528599926727; Sat, 09 Jun 2018 20:05:26 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:59 -1000 Message-Id: <20180610030220.3777-88-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 087/108] linux-user: Split out xattr 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 fgetxattr, flistxattr, fremovexattr, fsetxattr, getxattr, lgetxattr, listxattr, llistxattr, lremovexattr, lsetxattr, removexattr, setxattr. All targets define all of these; simplify the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 453 +++++++++++++++++++++++++++---------------- 1 file changed, 291 insertions(+), 162 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0897449273..c37af32bb6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8328,6 +8328,46 @@ IMPL(fdatasync) return get_errno(fdatasync(arg1)); } +#ifdef CONFIG_ATTR +IMPL(fgetxattr) +{ + void *n, *v = 0; + abi_long ret; + + if (arg3) { + v = lock_user(VERIFY_WRITE, arg3, arg4, 0); + if (!v) { + return -TARGET_EFAULT; + } + } + n = lock_user_string(arg2); + if (n) { + ret = get_errno(fgetxattr(arg1, n, v, arg4)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(n, arg2, 0); + unlock_user(v, arg3, arg4); + return ret; +} + +IMPL(flistxattr) +{ + void *b = 0; + abi_long ret; + + if (arg2) { + b = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!b) { + return -TARGET_EFAULT; + } + } + ret = get_errno(flistxattr(arg1, b, arg3)); + unlock_user(b, arg2, arg3); + return ret; +} +#endif + IMPL(flock) { /* The flock constant seems to be the same for every Linux platform. */ @@ -8341,6 +8381,45 @@ IMPL(fork) } #endif +#ifdef CONFIG_ATTR +IMPL(fremovexattr) +{ + void *n; + abi_long ret; + + n = lock_user_string(arg2); + if (n) { + ret = get_errno(fremovexattr(arg1, n)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(n, arg2, 0); + return ret; +} + +IMPL(fsetxattr) +{ + void *n, *v = 0; + abi_long ret; + + if (arg3) { + v = lock_user(VERIFY_READ, arg3, arg4, 1); + if (!v) { + return -TARGET_EFAULT; + } + } + n = lock_user_string(arg2); + if (n) { + ret = get_errno(fsetxattr(arg1, n, v, arg4, arg5)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(n, arg2, 0); + unlock_user(v, arg3, 0); + return ret; +} +#endif + IMPL(fstat) { struct stat st; @@ -8981,6 +9060,32 @@ IMPL(getuid32) } #endif +#ifdef CONFIG_ATTR +IMPL(getxattr) +{ + void *p, *n, *v = 0; + abi_long ret; + + if (arg3) { + v = lock_user(VERIFY_WRITE, arg3, arg4, 0); + if (!v) { + return -TARGET_EFAULT; + } + } + p = lock_user_string(arg1); + n = lock_user_string(arg2); + if (p && n) { + ret = get_errno(getxattr(p, n, v, arg4)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + unlock_user(v, arg3, arg4); + return ret; +} +#endif + #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) IMPL(getxgid) { @@ -9212,6 +9317,32 @@ IMPL(lchown32) } #endif +#ifdef CONFIG_ATTR +IMPL(lgetxattr) +{ + void *p, *n, *v = 0; + abi_long ret; + + if (arg3) { + v = lock_user(VERIFY_WRITE, arg3, arg4, 0); + if (!v) { + return -TARGET_EFAULT; + } + } + p = lock_user_string(arg1); + n = lock_user_string(arg2); + if (p && n) { + ret = get_errno(lgetxattr(p, n, v, arg4)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + unlock_user(v, arg3, arg4); + return ret; +} +#endif + #ifdef TARGET_NR_link IMPL(link) { @@ -9249,6 +9380,50 @@ IMPL(listen) } #endif +#ifdef CONFIG_ATTR +IMPL(listxattr) +{ + void *p = lock_user_string(arg1); + void *b = 0; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + if (arg2) { + b = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!b) { + return -TARGET_EFAULT; + } + } + ret = get_errno(listxattr(p, b, arg3)); + unlock_user(p, arg1, 0); + unlock_user(b, arg2, arg3); + return ret; +} + +IMPL(llistxattr) +{ + void *p = lock_user_string(arg1); + void *b = 0; + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + if (arg2) { + b = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!b) { + return -TARGET_EFAULT; + } + } + ret = get_errno(llistxattr(p, b, arg3)); + unlock_user(p, arg1, 0); + unlock_user(b, arg2, arg3); + return ret; +} +#endif + /* Older kernel ports have _llseek() instead of llseek() */ #if defined(TARGET_NR__llseek) && !defined(TARGET_NR_llseek) #define TARGET_NR_llseek TARGET_NR__llseek @@ -9270,11 +9445,54 @@ IMPL(llseek) } #endif +#ifdef CONFIG_ATTR +IMPL(lremovexattr) +{ + char *p = lock_user_string(arg1); + char *n = lock_user_string(arg2); + abi_long ret = -TARGET_EFAULT; + + if (p && n) { + ret = get_errno(lremovexattr(p, n)); + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + return ret; +} +#endif + IMPL(lseek) { return get_errno(lseek(arg1, arg2, arg3)); } +#ifdef CONFIG_ATTR +IMPL(lsetxattr) +{ + char *p, *n; + void *v = 0; + abi_long ret; + + if (arg3) { + v = lock_user(VERIFY_READ, arg3, arg4, 1); + if (!v) { + return -TARGET_EFAULT; + } + } + p = lock_user_string(arg1); + n = lock_user_string(arg2); + if (p && n) { + ret = get_errno(lsetxattr(p, n, v, arg4, arg5)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + unlock_user(v, arg3, 0); + return ret; +} +#endif + #ifdef TARGET_NR_lstat IMPL(lstat) { @@ -10428,6 +10646,22 @@ IMPL(recvmsg) } #endif +#ifdef CONFIG_ATTR +IMPL(removexattr) +{ + char *p = lock_user_string(arg1); + char *n = lock_user_string(arg2); + abi_long ret = -TARGET_EFAULT; + + if (p && n) { + ret = get_errno(removexattr(p, n)); + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_rename IMPL(rename) { @@ -11277,6 +11511,33 @@ IMPL(setuid32) } #endif +#ifdef CONFIG_ATTR +IMPL(setxattr) +{ + char *p, *n; + void *v = 0; + abi_long ret; + + if (arg3) { + v = lock_user(VERIFY_READ, arg3, arg4, 1); + if (!v) { + return -TARGET_EFAULT; + } + } + p = lock_user_string(arg1); + n = lock_user_string(arg2); + if (p && n) { + ret = get_errno(setxattr(p, n, v, arg4, arg5)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + unlock_user(v, arg3, 0); + return ret; +} +#endif + #ifdef TARGET_NR_sigaction IMPL(sigaction) { @@ -12203,168 +12464,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef CONFIG_ATTR -#ifdef TARGET_NR_setxattr - case TARGET_NR_listxattr: - case TARGET_NR_llistxattr: - { - void *p, *b = 0; - if (arg2) { - b = lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!b) { - return -TARGET_EFAULT; - } - } - p = lock_user_string(arg1); - if (p) { - if (num == TARGET_NR_listxattr) { - ret = get_errno(listxattr(p, b, arg3)); - } else { - ret = get_errno(llistxattr(p, b, arg3)); - } - } else { - ret = -TARGET_EFAULT; - } - unlock_user(p, arg1, 0); - unlock_user(b, arg2, arg3); - return ret; - } - case TARGET_NR_flistxattr: - { - void *b = 0; - if (arg2) { - b = lock_user(VERIFY_WRITE, arg2, arg3, 0); - if (!b) { - return -TARGET_EFAULT; - } - } - ret = get_errno(flistxattr(arg1, b, arg3)); - unlock_user(b, arg2, arg3); - return ret; - } - case TARGET_NR_setxattr: - case TARGET_NR_lsetxattr: - { - void *p, *n, *v = 0; - if (arg3) { - v = lock_user(VERIFY_READ, arg3, arg4, 1); - if (!v) { - return -TARGET_EFAULT; - } - } - p = lock_user_string(arg1); - n = lock_user_string(arg2); - if (p && n) { - if (num == TARGET_NR_setxattr) { - ret = get_errno(setxattr(p, n, v, arg4, arg5)); - } else { - ret = get_errno(lsetxattr(p, n, v, arg4, arg5)); - } - } else { - ret = -TARGET_EFAULT; - } - unlock_user(p, arg1, 0); - unlock_user(n, arg2, 0); - unlock_user(v, arg3, 0); - } - return ret; - case TARGET_NR_fsetxattr: - { - void *n, *v = 0; - if (arg3) { - v = lock_user(VERIFY_READ, arg3, arg4, 1); - if (!v) { - return -TARGET_EFAULT; - } - } - n = lock_user_string(arg2); - if (n) { - ret = get_errno(fsetxattr(arg1, n, v, arg4, arg5)); - } else { - ret = -TARGET_EFAULT; - } - unlock_user(n, arg2, 0); - unlock_user(v, arg3, 0); - } - return ret; - case TARGET_NR_getxattr: - case TARGET_NR_lgetxattr: - { - void *p, *n, *v = 0; - if (arg3) { - v = lock_user(VERIFY_WRITE, arg3, arg4, 0); - if (!v) { - return -TARGET_EFAULT; - } - } - p = lock_user_string(arg1); - n = lock_user_string(arg2); - if (p && n) { - if (num == TARGET_NR_getxattr) { - ret = get_errno(getxattr(p, n, v, arg4)); - } else { - ret = get_errno(lgetxattr(p, n, v, arg4)); - } - } else { - ret = -TARGET_EFAULT; - } - unlock_user(p, arg1, 0); - unlock_user(n, arg2, 0); - unlock_user(v, arg3, arg4); - } - return ret; - case TARGET_NR_fgetxattr: - { - void *n, *v = 0; - if (arg3) { - v = lock_user(VERIFY_WRITE, arg3, arg4, 0); - if (!v) { - return -TARGET_EFAULT; - } - } - n = lock_user_string(arg2); - if (n) { - ret = get_errno(fgetxattr(arg1, n, v, arg4)); - } else { - ret = -TARGET_EFAULT; - } - unlock_user(n, arg2, 0); - unlock_user(v, arg3, arg4); - } - return ret; - case TARGET_NR_removexattr: - case TARGET_NR_lremovexattr: - { - void *p, *n; - p = lock_user_string(arg1); - n = lock_user_string(arg2); - if (p && n) { - if (num == TARGET_NR_removexattr) { - ret = get_errno(removexattr(p, n)); - } else { - ret = get_errno(lremovexattr(p, n)); - } - } else { - ret = -TARGET_EFAULT; - } - unlock_user(p, arg1, 0); - unlock_user(n, arg2, 0); - } - return ret; - case TARGET_NR_fremovexattr: - { - void *n; - n = lock_user_string(arg2); - if (n) { - ret = get_errno(fremovexattr(arg1, n)); - } else { - ret = -TARGET_EFAULT; - } - unlock_user(n, arg2, 0); - } - return ret; -#endif -#endif /* CONFIG_ATTR */ #ifdef TARGET_NR_set_thread_area case TARGET_NR_set_thread_area: #if defined(TARGET_MIPS) @@ -13253,9 +13352,17 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fcntl64); #endif SYSCALL(fdatasync); +#ifdef CONFIG_ATTR + SYSCALL(fgetxattr); + SYSCALL(flistxattr); +#endif SYSCALL(flock); #ifdef TARGET_NR_fork SYSCALL(fork); +#endif +#ifdef CONFIG_ATTR + SYSCALL(fremovexattr); + SYSCALL(fsetxattr); #endif SYSCALL(fstat); #ifdef TARGET_NR_fstat64 @@ -13354,6 +13461,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_getuid32 SYSCALL(getuid32); #endif +#ifdef CONFIG_ATTR + SYSCALL(getxattr); +#endif #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA) SYSCALL(getxgid); #endif @@ -13374,17 +13484,30 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_lchown32 SYSCALL(lchown32); #endif +#ifdef CONFIG_ATTR + SYSCALL(lgetxattr); +#endif #ifdef TARGET_NR_link SYSCALL(link); #endif SYSCALL(linkat); +#ifdef CONFIG_ATTR + SYSCALL(listxattr); + SYSCALL(llistxattr); +#endif #ifdef TARGET_NR_listen SYSCALL(listen); #endif #ifdef TARGET_NR_llseek SYSCALL(llseek); +#endif +#ifdef CONFIG_ATTR + SYSCALL(lremovexattr); #endif SYSCALL(lseek); +#ifdef CONFIG_ATTR + SYSCALL(lsetxattr); +#endif #ifdef TARGET_NR_lstat SYSCALL(lstat); #endif @@ -13498,6 +13621,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_recvmsg SYSCALL(recvmsg); #endif +#ifdef CONFIG_ATTR + SYSCALL(removexattr); +#endif #ifdef TARGET_NR_rename SYSCALL(rename); #endif @@ -13629,6 +13755,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_setuid32 SYSCALL(setuid32); #endif +#ifdef CONFIG_ATTR + SYSCALL(setxattr); +#endif #ifdef TARGET_NR_sigaction SYSCALL(sigaction); #endif From patchwork Sun Jun 10 03:02:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138165 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2609726lji; Sat, 9 Jun 2018 21:07:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKEmfjQTF9619GBosTayOTz7iU0+qzHkcWpEfvZKVJxaO7J2mY+t9J906ZEgV+5ii5C2KyO X-Received: by 2002:a37:1828:: with SMTP id j40-v6mr10242943qkh.11.1528603630107; Sat, 09 Jun 2018 21:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603630; cv=none; d=google.com; s=arc-20160816; b=i6czX/T9RoKGXjFmXcMmm4wBcFEGlXVmHZH05U4RX6lXsVdTM4UKD9WLHx/8hpca+t CbxsXvg7cF5/S9h6BjhzkJWjbsJM1RV6CstxzOWb8UU/NNtGr5Ly89CX472RNcSI3nCP pttxJa/lXg/F96taMA7KaRyqcMLX4tpJzkFeXa5D1h5gZn/28KMspwv/dN+Jof/j1aoa MymfJj0BNG+csvU2f++GD8c5PQBYuYAVqCCd/ZWQqDlqT/9fhEVhqOXp6PazcsVF+8jg 4J/JKLC4+8qa3z1AaxXH3cg7mK1kqF2ZOyamdAy6WoBczjpYQyUScaOgml2cmv/m2fwq zo/A== 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:arc-authentication-results; bh=2+oq9sV0JJybo2xdAK23iHVaq5gw1X5Q+4LvwRCYT44=; b=kwXUGPrmpfB2vAoi3340GZDM2wT4iWi49JGNoz2d75HujR4ccCw8J7MhvyHNMX14Xl HNJdzEJpapAOkGZum+/MNDEtmrkLoirAvPIk6mi7xXFlihXhn7C6c9HuatgoKr6UDIzA OIrELZDpqYNeNI0QHW65Z/popJGuMDi8QY5ppRSxqGZ/GZHllnDimnBCWCcNByJrpbm+ 8X1+/KkWlPh7H+vEaX3AsN8F4CO6ZjJzwXV+kMrh3LFT0wNFqUnKMRhrPzW86Ix7j1zS wjmyNPFFgohl15yHQC3cL10Z/U6NleKFlFRN1lrpM1FXZJKrDudf+g1S8g7UxQhLsKBs TYPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gcWhpojH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k33-v6si568312qta.311.2018.06.09.21.07.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gcWhpojH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrdF-0001o8-FV for patch@linaro.org; Sun, 10 Jun 2018 00:07:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfd-0004KN-LA for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfa-0004aS-6F for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:33 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:44111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfZ-0004ZG-UL for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:30 -0400 Received: by mail-pl0-x241.google.com with SMTP id z9-v6so10387849plk.11 for ; Sat, 09 Jun 2018 20:05:29 -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=2+oq9sV0JJybo2xdAK23iHVaq5gw1X5Q+4LvwRCYT44=; b=gcWhpojH64/t7ub6zkJ37k1w0FAK0z65gNuyuYyGlag9A2+9fR2OrKL7Tm5BSwjPAt OHpDJlZcsYFPEqe8Je384ajS8R41cEYQ91JW3XWk6y8lwS3cx8VAQIcuM8+LXQC5xlPR geg0G5jG/Ys9tvPUonXZHBTCJ6fYlOD//nv9w= 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=2+oq9sV0JJybo2xdAK23iHVaq5gw1X5Q+4LvwRCYT44=; b=gJVdMelGi15rq3Cm9/vSUMvRu1gZh+CqRq9tOteA58/7VMWTTYZ96275fVYbOl+7gb X0z3iWyUUr2z3MokJxWWYiDyulq3e6prjL5dziv0atYegSa8alWkU2LQTZr+8XhejRz3 mo49I9QvCU2K+zch/IzLyklyUnLwIxla/Iy9SBpGwy4p6RJVv6Zu3O8M7fM7gH9ZqkIa qkleyp+8FQBWJ7IPzDxUNUSLRjGLec1RMch0Pth4YnNyzRSJa2TEul+dHl2Pjl3TpfJ5 ZZ7RoX9rK0TSCuQfHUfyl0UCtDkw6GnoWmUnIzYQ2oZFy6J4RiGpXpsb2I4d+3vLPWEe bnlg== X-Gm-Message-State: APt69E1I2mh0S88g8+UHzcrq6Kk/dALCkwLL48/MlGtGQqFQ7/H2HFEL qHs2NIqLNxVdZyIGAheKErWTDRlFavg= X-Received: by 2002:a17:902:760e:: with SMTP id k14-v6mr12934140pll.310.1528599928752; Sat, 09 Jun 2018 20:05:28 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:00 -1000 Message-Id: <20180610030220.3777-89-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 088/108] linux-user: Split out getdomainname, get_thread_area, set_thread_area 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 | 92 +++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 43 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c37af32bb6..285612dfe5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9029,6 +9029,21 @@ IMPL(getsockopt) } #endif +#ifdef TARGET_NR_get_thread_area +IMPL(get_thread_area) +{ +# if defined(TARGET_I386) && defined(TARGET_ABI32) + 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; +# else + return -TARGET_ENOSYS; +# endif +} +#endif + IMPL(gettid) { return get_errno(gettid()); @@ -11480,6 +11495,31 @@ IMPL(setsockopt) } #endif +#ifdef TARGET_NR_set_thread_area +IMPL(set_thread_area) +{ +# if defined(TARGET_MIPS) + ((CPUMIPSState *) cpu_env)->active_tc.CP0_UserLocal = arg1; + return 0; +# elif defined(TARGET_CRIS) + if (arg1 & 0xff) { + return -TARGET_EINVAL; + } + ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1; + return 0; +# elif defined(TARGET_I386) && defined(TARGET_ABI32) + 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; +# else + return -TARGET_ENOSYS; +# endif +} +#endif + IMPL(settimeofday) { struct timeval tv; @@ -12464,49 +12504,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_set_thread_area - case TARGET_NR_set_thread_area: -#if defined(TARGET_MIPS) - ((CPUMIPSState *) cpu_env)->active_tc.CP0_UserLocal = arg1; - return 0; -#elif defined(TARGET_CRIS) - if (arg1 & 0xff) - ret = -TARGET_EINVAL; - else { - ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1; - ret = 0; - } - return ret; -#elif defined(TARGET_I386) && defined(TARGET_ABI32) - return do_set_thread_area(cpu_env, arg1); -#elif defined(TARGET_M68K) - { - TaskState *ts = cpu->opaque; - ts->tp_value = arg1; - return 0; - } -#else - return -TARGET_ENOSYS; -#endif -#endif -#ifdef TARGET_NR_get_thread_area - case TARGET_NR_get_thread_area: -#if defined(TARGET_I386) && defined(TARGET_ABI32) - return do_get_thread_area(cpu_env, arg1); -#elif defined(TARGET_M68K) - { - TaskState *ts = cpu->opaque; - return ts->tp_value; - } -#else - return -TARGET_ENOSYS; -#endif -#endif -#ifdef TARGET_NR_getdomainname - case TARGET_NR_getdomainname: - return -TARGET_ENOSYS; -#endif - #ifdef TARGET_NR_clock_settime case TARGET_NR_clock_settime: { @@ -13391,6 +13388,9 @@ static impl_fn *syscall_table(unsigned num) #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) SYSCALL(getdents64); #endif +#ifdef TARGET_NR_getdomainname + SYSCALL_WITH(getdomainname, enosys); +#endif #ifdef TARGET_NR_getegid SYSCALL(getegid); #endif @@ -13452,6 +13452,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_getsockopt SYSCALL(getsockopt); +#endif +#ifdef TARGET_NR_get_thread_area + SYSCALL(get_thread_area); #endif SYSCALL(gettid); SYSCALL(gettimeofday); @@ -13748,6 +13751,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(setrlimit); #ifdef TARGET_NR_setsockopt SYSCALL(setsockopt); +#endif +#ifdef TARGET_NR_set_thread_area + SYSCALL(set_thread_area); #endif SYSCALL(settimeofday); SYSCALL(setsid); From patchwork Sun Jun 10 03:02:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138166 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2610612lji; Sat, 9 Jun 2018 21:08:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJXsAl3STZjTPSAE2dU45+PAv/63sLrswIX7u3KeR7wskUevPqvUrVQfFXgU/rUPSdtSs8n X-Received: by 2002:ac8:18d7:: with SMTP id o23-v6mr11830321qtk.28.1528603720018; Sat, 09 Jun 2018 21:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603720; cv=none; d=google.com; s=arc-20160816; b=WRKdd54G9eSpaPo0h8f3kP+fCVHdwgxgBdQ74T6/3wo9e+ekjJi6+zDOXuzAPZzW51 ZuAxEWewWaqtmHgE5jYA7xg9y7RQNbPBXFYnZawiVyuce2qyJlW6LjItDmlWnCEK0Gt1 67f7rnTuUW6SUw24HDIE7AB/VdOy0KeNnDDTIP4uHTspkVmH3eFRkUdxFQUGqoX8a3dY hNN9YKlUPgpcThCM9slgjIf1nOkDnWCSBy8we/5Ko3pn4Ha8QueHq5qsZMeYLxH9QxA2 2qCXss5h7062pg9bIPGnTFfCkQ5AOTHuFuMWC8E4LmW6sfSTqJtTmsNDBaiFGRPeNLjv ntpQ== 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:arc-authentication-results; bh=3LyIbHTjQGN5bnL/kExH2mN76H+cGaaU2z9AwSujrBM=; b=acACs1kKbXohibbAxA1yZjAlamryIW3eK4csk4DBkl6LGh344N2FhsGr1Fy19lv+PS FDCf42tYd2o8lVbeSk0UaTaB9YDt6aewgcuumVGVW+ce/rWy9VTtM/7lOdiG3qJb+yBP 5fKdLEW7IhKrFrKFd/np7U3Wxrj9u8RRt+TxydvvTzuX8x9Z5+MhjuipPCP/QZbvdK5u hywYOPPvSyJQ5IKcp3foscfvtl2J/GNXGXXDuHq52TCOdBl9JE4+5Bsa0q2bolDTXTLR 94w60OVnD7BLq816Gz0EREpOuCu3t4tiHoRTnBacoaJR/Xe49H8XdKChhkhPgGVcqWpM 2/2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dtUKLZGV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 8-v6si1750675qvs.51.2018.06.09.21.08.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:08:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dtUKLZGV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRreh-0003Bf-D7 for patch@linaro.org; Sun, 10 Jun 2018 00:08:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfd-0004KM-Kl for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfb-0004c2-L7 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:33 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:40343) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfb-0004b4-ET for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:31 -0400 Received: by mail-pl0-x241.google.com with SMTP id t12-v6so10377377plo.7 for ; Sat, 09 Jun 2018 20:05: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=3LyIbHTjQGN5bnL/kExH2mN76H+cGaaU2z9AwSujrBM=; b=dtUKLZGV9VkkE4I1XDfhIw0iLUwfF2M465W4hWFN7v1UoVfX1o5yX4oeJ/DqXV1KuS qtcD+v6DMKnV8/9RHqpzy8/s6UFjVXWkMJrQVD3cWlC5tw8IocKY/og91QZrMdOzqLYq AGTCpmt7DBLxt1jUC4DdvvF1SJjDjw3ZGrvAc= 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=3LyIbHTjQGN5bnL/kExH2mN76H+cGaaU2z9AwSujrBM=; b=JuerZ/bZN/dWomZg540x2O83wCQpASdCkbQsYMoLveIqY/mLsgpflkkFY1kyiNEcyW q9nIm/hX4tc8qV8Gt9ZH2kIyvRq3T3UD6WQFCkg/FOBHU3okuZXTMcnxVOoSjr8PmolP 3sd7oHp160VE2mzwp16XtXjPPOhSW6qokI2hcn61xT3GeEZspFWPYQHgbakhJ3Y1LztC sBQ3y6N+B4YaB9Zy0mKFkNTLrWKBqVqbD4LyEfvTh3gOfKWGPNI9Ic9Q0BsfyXicGhe7 h49/SAeP1VjLctBxQFpjHnPTUdbC7ymMZeAQQp247I3yywp5LXGZKseXcGO0Ek3IyiMJ NalQ== X-Gm-Message-State: APt69E2cXruA0Mvgv7SmV4CqlRjmXVcGpq1Y+4q79syO4qZaZDuGNVu/ PfsLRw3dcllwdKkdTwF3kI0inJnrq8w= X-Received: by 2002:a17:902:aa01:: with SMTP id be1-v6mr12814921plb.296.1528599930321; Sat, 09 Jun 2018 20:05:30 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:01 -1000 Message-Id: <20180610030220.3777-90-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 089/108] linux-user: Split out clock 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 clock_getres, clock_gettime, clock_nanosleep, clock_settime. All targets define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 115 ++++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 55 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 285612dfe5..6f19f75c67 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7855,6 +7855,62 @@ IMPL(clock_adjtime) } #endif +IMPL(clock_getres) +{ + struct timespec ts; + abi_long ret; + + ret = get_errno(clock_getres(arg1, &ts)); + if (!is_error(ret)) { + ret = host_to_target_timespec(arg2, &ts); + } + return ret; +} + +IMPL(clock_gettime) +{ + struct timespec ts; + abi_long ret; + + ret = get_errno(clock_gettime(arg1, &ts)); + if (!is_error(ret)) { + ret = host_to_target_timespec(arg2, &ts); + } + return ret; +} + +IMPL(clock_nanosleep) +{ + struct timespec ts; + abi_long ret; + + target_to_host_timespec(&ts, arg3); + ret = get_errno(safe_clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); + if (arg4) { + host_to_target_timespec(arg4, &ts); + } +#if defined(TARGET_PPC) + /* clock_nanosleep is odd in that it returns positive errno values. + * On PPC, CR0 bit 3 should be set in such a situation. */ + if (ret && ret != -TARGET_ERESTARTSYS) { + ((CPUPPCState *)cpu_env)->crf[0] |= 1; + } +#endif + return ret; +} + +IMPL(clock_settime) +{ + struct timespec ts; + abi_long ret; + + ret = target_to_host_timespec(&ts, arg2); + if (!is_error(ret)) { + ret = get_errno(clock_settime(arg1, &ts)); + } + return ret; +} + IMPL(clone) { /* Linux manages to have three different orderings for its @@ -12504,61 +12560,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_clock_settime - case TARGET_NR_clock_settime: - { - struct timespec ts; - - ret = target_to_host_timespec(&ts, arg2); - if (!is_error(ret)) { - ret = get_errno(clock_settime(arg1, &ts)); - } - return ret; - } -#endif -#ifdef TARGET_NR_clock_gettime - case TARGET_NR_clock_gettime: - { - struct timespec ts; - ret = get_errno(clock_gettime(arg1, &ts)); - if (!is_error(ret)) { - ret = host_to_target_timespec(arg2, &ts); - } - return ret; - } -#endif -#ifdef TARGET_NR_clock_getres - case TARGET_NR_clock_getres: - { - struct timespec ts; - ret = get_errno(clock_getres(arg1, &ts)); - if (!is_error(ret)) { - host_to_target_timespec(arg2, &ts); - } - return ret; - } -#endif -#ifdef TARGET_NR_clock_nanosleep - case TARGET_NR_clock_nanosleep: - { - struct timespec ts; - target_to_host_timespec(&ts, arg3); - ret = get_errno(safe_clock_nanosleep(arg1, arg2, - &ts, arg4 ? &ts : NULL)); - if (arg4) - host_to_target_timespec(arg4, &ts); - -#if defined(TARGET_PPC) - /* clock_nanosleep is odd in that it returns positive errno values. - * On PPC, CR0 bit 3 should be set in such a situation. */ - if (ret && ret != -TARGET_ERESTARTSYS) { - ((CPUPPCState *)cpu_env)->crf[0] |= 1; - } -#endif - return ret; - } -#endif - #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) case TARGET_NR_set_tid_address: return get_errno(set_tid_address((int *)g2h(arg1))); @@ -13292,6 +13293,10 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_CLOCK_ADJTIME SYSCALL(clock_adjtime); #endif + SYSCALL(clock_getres); + SYSCALL(clock_gettime); + SYSCALL(clock_nanosleep); + SYSCALL(clock_settime); SYSCALL(clone); SYSCALL(close); SYSCALL(chdir); From patchwork Sun Jun 10 03:02:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138172 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2613487lji; Sat, 9 Jun 2018 21:13:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJxOMcSG1KjQ/BwqQiUHgwdkO7quHpBGipMws7AHw0Et1fO2NkYBDaa4I5vz3F3OwgIiPq X-Received: by 2002:a37:7285:: with SMTP id n127-v6mr10422930qkc.115.1528604021531; Sat, 09 Jun 2018 21:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604021; cv=none; d=google.com; s=arc-20160816; b=IE1ImgCwvyV5dIQ+oCEKpVjmp3bZ59A9MZaJ5NK7RdvSHk9V6at9f5UjA+Q8SipU/w V1Y8jJ1xIzlxa1+za5ch4UkECuLcSD+xUbvqTnFDBXm+i47ugZN8b5nBO6Ut2rdsir8d PjmyfQj1/SlzfPih0YSyyEQL7lou4F7ARholdcDd5yqyym+IUdxgH540slUZMhx+/osd OWZkJbBXMZqXCmz2i2H0doS1bDrMVNTNkxj9X0qdtG0QSCz2EPFreRwVv3A+nR+BiHjL 3veQ/WRaBsOHazwleRsfUOJzoRYMAbEgOCvD/auVKYldiHxsvxYDSqUSKPOOyhivv32T 9WXg== 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:arc-authentication-results; bh=8Y8kZFXegldiuJhWMbnQBcSjLznnrPjyMoEA0SOXIxM=; b=LuvTD7CGllnEl8qTnYb+xCP77n4plav94tEHWy+prGt84zdzKbhIJCyW0iOe/IJxyp v4HXo0OAtyR2x5jXI/ygMqliw6dU1uTcJ7ee4C7P6NaROYQUQ6/ZDQmb7u+KJB8mmTbc mvjterya2O/mfQUsretmC5dmeZNYMKLYr//U9uKnYnz8qYxVX4v3cfBezQtqtpoOVdaO gFv6goOwOEGAEKu27y3PgGDI2B+mdMKY+e1a07/Ep8a1LK1CkJKTXAEKn9u+V8sZolg/ Oy/p4WC5EVzDkLhRck7QlJk1Xy9UBmSkO3Jqo0ADExlvSISnrDmRZBsngDnjX8JH945C gnDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ct+1fZPL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 19-v6si3940797qvh.164.2018.06.09.21.13.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ct+1fZPL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrjZ-0007v1-0B for patch@linaro.org; Sun, 10 Jun 2018 00:13:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfg-0004LR-28 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfe-0004eh-1Y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:35 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:46239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfd-0004dh-RS for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:33 -0400 Received: by mail-pl0-x241.google.com with SMTP id 30-v6so10377909pld.13 for ; Sat, 09 Jun 2018 20:05: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=8Y8kZFXegldiuJhWMbnQBcSjLznnrPjyMoEA0SOXIxM=; b=Ct+1fZPLqhdNSI8sq9W/MvvS9ROLxs5vxipxzEHEqx1FZAt4RqVO0V4XrWRc+YVzXq 0f6XXG9cpJjNGcktaMmCqp6x1tRko22eDVglM9Dvs02APGCRnnY4fsAuH4S9ou4OesRb TQBcwz4iAN73pi2ADkJmc777OCHw/Jn9wbzP0= 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=8Y8kZFXegldiuJhWMbnQBcSjLznnrPjyMoEA0SOXIxM=; b=ozjeqz111XdnjYH6z0hfoUFUcDGOITvP9fYJTg/h64xO8xuU5eCk5WdD4vVgBtSo4T EsCmXQaJqKspl2aWdtuzdBaIm8SgYY3hToqbc0L/GMQk9Ic1Qvplq4VH/3DZlBBtYrpm Q2V0HQkjHoZGpomltUhuLLjJD8gmVDSdmTnQQlNSVbEyEBVHDhfN19hRooEOj1tAsSAS 9e20qMifS0573r+m3jtp7Qh63GwNFxTaaCzjeTbQcwKMUT2AlIgUfMEXBuObLvLBxrB2 0tkZ1KP68yZRUHj+Cthlrb65A2V/5G8FX1BhC3HfqSOIbd4TN0l1/FJGosujKeJ3T88i 5uAg== X-Gm-Message-State: APt69E1+LRwO3P4Zi/0zmrGgiD0L2I9d6u2SLS9yCncFJPjZnxKgjm0h jwYswhk52+OPPdqtCPJqUYk5vC5xNMw= X-Received: by 2002:a17:902:9f84:: with SMTP id g4-v6mr12924340plq.339.1528599932656; Sat, 09 Jun 2018 20:05:32 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:02 -1000 Message-Id: <20180610030220.3777-91-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 090/108] linux-user: Fix clock_nanosleep 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" When we switched from using clock_nanosleep to safe_clock_nanosleep, we changed from the user-level API to the kernel-level ABI. These have different senses of the errno value. The special handling for PowerPC is not requied while we're following the kernel ABI. Fixes: 9e518226f43 Signed-off-by: Richard Henderson --- linux-user/syscall.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6f19f75c67..1c1e05dc26 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7884,18 +7884,20 @@ IMPL(clock_nanosleep) struct timespec ts; abi_long ret; - target_to_host_timespec(&ts, arg3); - ret = get_errno(safe_clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); - if (arg4) { - host_to_target_timespec(arg4, &ts); + /* Note that while the user-level api for clock_nanosleep + * returns a positive errno values, the kernel-level api + * continues to return negative errno values. Also note + * that safe_clock_nanosleep mirrors the kernel api. + */ + ret = target_to_host_timespec(&ts, arg3); + if (ret == 0) { + ret = safe_clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL); + if (ret) { + ret = -host_to_target_errno(-ret); + } else if (arg4) { + ret = host_to_target_timespec(arg4, &ts); + } } -#if defined(TARGET_PPC) - /* clock_nanosleep is odd in that it returns positive errno values. - * On PPC, CR0 bit 3 should be set in such a situation. */ - if (ret && ret != -TARGET_ERESTARTSYS) { - ((CPUPPCState *)cpu_env)->crf[0] |= 1; - } -#endif return ret; } From patchwork Sun Jun 10 03:02:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138170 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2612546lji; Sat, 9 Jun 2018 21:12:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ9hJTa9iu6bTzqD9ftStPgUEUnqWR5/gjG6RaTTx7WQYv7xeMfWT30/8E0lMGnKV52Qa8R X-Received: by 2002:a37:76c3:: with SMTP id r186-v6mr10597491qkc.409.1528603922559; Sat, 09 Jun 2018 21:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603922; cv=none; d=google.com; s=arc-20160816; b=cnzwHb9TzD09maOJ2VDOlCf5FlUoREMq/VxPHifuQ0vjGpoimBIakQZmOMCpSXYS95 BnoRBiAPSxHr4cfILjb2g7kBWXqZMK54AOVifMSexDVsmmM0v70YBigN8ThNVGn6u5I4 v77dNZOda7IkiKmio7DAQHLfSPt7F1IFR0w7Zq06cgTbhkpKR12oKb6iDh4RuDZ+DWkf k+4hXja1PqncMLfDLr3fvGDsW1f6KHeNeKDjHwQXgn3h+0TRFIS4c1wBL2muCISrZHkZ 1BthGXMgC8lxmfcQxd7xYaNnvEpTF/n4e7jm5M2ztfK6Gl0BYQN27kiUWmclz9x4p8Zs pLSQ== 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:arc-authentication-results; bh=8tu6OgeglohkggMq2uPZwP09LlUOjWkkuYF//UVbFN4=; b=a/iBXBb/jCCBGA4ie9ZvyVGCnGN2BTJdoORksA1Yh3asto/+XhBeLqwfpnNGDi3QXv jh6Tjc7mwb5T/6gP248E/IEuSqYe6r/7ipPErUq9FIHUkV1Dq4JWQ6J5rIpKLIssz+N6 cHcbND7tUSC6Fqw1cXWI/5NcW/wubMf1yEm8T95r3S0hoxb8ci7UPyaK4myZnLai9MNK dGxD8TrslW8rRFJY7gxclQzrIdiO48wua4agohgA0iKz7JjXcKXl2ZS6/oKPgkcyHEqM jTc5FZ7ZRCSEx6SkW4IFceC1+Gxy7DinLobdEGoOVWkYk6nqzdMwHZDkoC04AqCxEznC HYPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dO1fS8+T; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u6-v6si912927qkc.122.2018.06.09.21.12.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dO1fS8+T; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrhy-0006T5-0H for patch@linaro.org; Sun, 10 Jun 2018 00:12:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfg-0004LU-Jh for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqff-0004fX-JV for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:36 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:33747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqff-0004fJ-D1 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:35 -0400 Received: by mail-pl0-x241.google.com with SMTP id n10-v6so10392216plp.0 for ; Sat, 09 Jun 2018 20:05: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=8tu6OgeglohkggMq2uPZwP09LlUOjWkkuYF//UVbFN4=; b=dO1fS8+TzzyJvqDrJEXr6E4oZjpSGcv+g4ZW859sigeF4nWw+OXgjnGVoV7b+NiKee eoMbjY5B1uE+yXU9GioPphaJvOt2Lu/SoIHvECY2yktgmhLyysGF/OplALNd8LQDW0qc OmgwQwBIG7CfeXR36iZl67sVP+mT1yyQveN2c= 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=8tu6OgeglohkggMq2uPZwP09LlUOjWkkuYF//UVbFN4=; b=Vr0m4u/DbNzvjfL8KKt2IFc/Pv5Zt6Awq73PhzumXaJ/ATKeL9CA6O3dcaBDpaurOy qjjpIsUeq+mTcRSAF/XK/gRRodFVLIqOSofzEMhG1X/Txe4IS5dRqcKY25Bu0Cn7fTBR FrOTmMT17rJ4dyk1J1raS4mSO1IzV/ip5Ub7zy5piYK60LBavPJ371qigjU/Di5A9+Fj aFHVTxzqkToxBEjNZX98c+Mp7rzRJWJLLk+tpYf8h/49h66Pz2hQGqHx4XQ3puTQgBbi PFk2lHBgdDZhY029gkgyeQchkTowByMDt3dtEN5jN0uCwE9HhbKcpOs7yMEwmB8Ev7n1 Iexw== X-Gm-Message-State: APt69E1TtU+9067x0OdYQOwCXjPXjOHF+k0Z0gYJ5C4cK/RjyX40B9kq fLF/S8ULS10M4yIo7XcaLoaTvXtvywM= X-Received: by 2002:a17:902:8e87:: with SMTP id bg7-v6mr12899143plb.129.1528599934246; Sat, 09 Jun 2018 20:05:34 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:03 -1000 Message-Id: <20180610030220.3777-92-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 091/108] linux-user: Split out set_tid_address, tgkill, tkill 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 define set_tid_address; remove the ifdef. Use the bogus syscall method to supply the host syscall. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1c1e05dc26..8406b9d8d3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -250,6 +250,9 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #ifndef __NR_gettid #define __NR_gettid -1 #endif +#ifndef __NR_set_tid_address +#define __NR_set_tid_address -1 +#endif _syscall0(int, gettid) @@ -278,9 +281,7 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len) #ifdef __NR_exit_group _syscall1(int,exit_group,int,error_code) #endif -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) _syscall1(int,set_tid_address,int *,tidptr) -#endif #if defined(TARGET_NR_futex) && defined(__NR_futex) _syscall6(int,sys_futex,int *,uaddr,int,op,int,val, const struct timespec *,timeout,int *,uaddr2,int,val3) @@ -11578,6 +11579,11 @@ IMPL(set_thread_area) } #endif +IMPL(set_tid_address) +{ + return get_errno(set_tid_address((int *)g2h(arg1))); +} + IMPL(settimeofday) { struct timeval tv; @@ -12210,6 +12216,12 @@ IMPL(syslog) } } +IMPL(tgkill) +{ + return get_errno(safe_tgkill((int)arg1, (int)arg2, + target_to_host_signal(arg3))); +} + #ifdef TARGET_NR_time IMPL(time) { @@ -12244,6 +12256,11 @@ IMPL(times) return host_to_target_clock_t(ret); } +IMPL(tkill) +{ + return get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2))); +} + IMPL(truncate) { char *p = lock_user_string(arg1); @@ -12562,19 +12579,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address) - case TARGET_NR_set_tid_address: - return get_errno(set_tid_address((int *)g2h(arg1))); -#endif - - case TARGET_NR_tkill: - return get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2))); - - case TARGET_NR_tgkill: - return get_errno(safe_tgkill((int)arg1, (int)arg2, - target_to_host_signal(arg3))); - - #if defined(TARGET_NR_utimensat) case TARGET_NR_utimensat: { @@ -13762,6 +13766,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_set_thread_area SYSCALL(set_thread_area); #endif + SYSCALL(set_tid_address); SYSCALL(settimeofday); SYSCALL(setsid); SYSCALL(setuid); @@ -13827,10 +13832,12 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(sysinfo); SYSCALL(syslog); + SYSCALL(tgkill); #ifdef TARGET_NR_time SYSCALL(time); #endif SYSCALL(times); + SYSCALL(tkill); SYSCALL(truncate); #ifdef TARGET_NR_truncate64 SYSCALL(truncate64); From patchwork Sun Jun 10 03:02:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138173 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2613787lji; Sat, 9 Jun 2018 21:14:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIk2jv5jJfgHpXtiefGt36zmfFTmrVc/jgAzAQ/e05OiFhYpQDd9jlKkuQd5ZlVn/w4k90n X-Received: by 2002:aed:3601:: with SMTP id e1-v6mr11679660qtb.23.1528604050557; Sat, 09 Jun 2018 21:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604050; cv=none; d=google.com; s=arc-20160816; b=fFPSM9brZDk8jA9YozZGBThdEOTbMz0HJPJ9+h9KSWT/S2FnOpV20gAPry485rtqfw FpoaiYbZJvQcoLe83it2W5wq6+p7llPtXbrqQRSQCenwnIms5+/fdS6vVo/vOw6ExpbC NtVMzdecejMe3wdv2ZaoeC0yG3nnEbL0+mhOTKePHsP1lBXbJke1F2dc1XU6tyYLGV4I SAPbRLUv7FzyX9vOt7CzBljg/3DEfpm+0k/I7ikdviKUVSgXob+RKGdHVJ87Au5+Mybi G35na2CRvJufuM6wexqbRvj3//DMoiy42aDPoye4gAJ9o7uYvYWLIq6HJVTUKmhIu9qT tSqQ== 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:arc-authentication-results; bh=4wG+S4fZiyUq1Pu/Hlt9nQvToX/s4he+oqXriYQ+nrE=; b=JGOuVv+JOvpYLG2LvzfCCpEawYDOPxl04xeEzb8VtLFnW57+3AFm3vYaJth39ORgco C4tCw5HU24tDao2QNcfP1QtjnblF1DEWgVJQLehp8E+8szdoBuSH6J7dIs67PC6EeVac pB4ogLpTToCYT3g1UN4O6pXIFlgXGZJ3TnaKKHlGDMuj1QtLv5AAoVGeCt8SdJqSgVGH xDBhg7PnG/ghyB3TGyCpG+HWQ3c4umjQlLYdl8t0JrigtRCHn/BVuz0dhEwETcXeH+Tv 9TdcG9LAcMTfr3fa71rookQaRqWERuoy0EH2TLhLqOo5h/bWGcf1biNC6AWMmQFhkG/B tIeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i6XtmTyV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f186-v6si270692qkc.404.2018.06.09.21.14.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i6XtmTyV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrk1-0007zO-WD for patch@linaro.org; Sun, 10 Jun 2018 00:14:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfi-0004NI-QZ for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfh-0004g0-F0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:38 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:42799) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfh-0004fp-5y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:37 -0400 Received: by mail-pl0-x243.google.com with SMTP id w17-v6so10391244pll.9 for ; Sat, 09 Jun 2018 20:05: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=4wG+S4fZiyUq1Pu/Hlt9nQvToX/s4he+oqXriYQ+nrE=; b=i6XtmTyVqXw4eTIoQI9ep+OTk2pINavCKlfYCesPml+ns+oy4zDqCQeYJVwSH4HFHu KVk/YIuoHNilln7YDB71hK4/oqzygRdPMvzQb8WJfbgu/soJwiwE5GADWvyQk1lnoDnf yAeI1q410NzvXl3cfWvAakUI8bSo5OvDfyEVw= 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=4wG+S4fZiyUq1Pu/Hlt9nQvToX/s4he+oqXriYQ+nrE=; b=LMzyMo3aKkaM6wksJ0hG5XBbUpNpXSFr63QBXYaJFu/fIftLDEudyVH4TBETX1pVD4 aTUQgx/KpDSAKAHqJMhFun3/Zx2EDEgWk4KBjzpcl1yt+h03dMAsKTz2QhB3I4WFwqxC cjaQ2eTzbrhfJCgvhGopnGxCDlsEi7q/yE1H76eN1TYU4ZlfjzDdj6nmSff+2xCN/FKt vr2MnAuAJPDu/2ble7VO9UfQKGgaOEK23t0CLJR7b235NPU3FKftpfdGNJ1R7yDJU40p rJDG9ccz1ZDcrbf6og09uri+m7Eqi1othkSBtFU92G57SV4mWD8HsI03lw6ZQ1Qny95n cV+Q== X-Gm-Message-State: APt69E0klsnd+0pPotxRdpZEfWJquRfTzMyemVHaiZO0lrKt5SjG2qoS w8PcVmebiBjU6EWlxxvn4A53iMip4jI= X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr2225164plb.255.1528599936004; Sat, 09 Jun 2018 20:05:36 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:04 -1000 Message-Id: <20180610030220.3777-93-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 092/108] linux-user: Split out futex, utimensat 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" At the same time, merge do_futex into the new function. All targets define utimensat; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 161 ++++++++++++++++++++++--------------------- 1 file changed, 81 insertions(+), 80 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8406b9d8d3..800b79276f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -602,8 +602,7 @@ static int sys_getcwd1(char *buf, size_t size) return strlen(buf)+1; } -#ifdef TARGET_NR_utimensat -#if defined(__NR_utimensat) +#ifdef __NR_utimensat #define __NR_sys_utimensat __NR_utimensat _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, const struct timespec *,tsp,int,flags) @@ -615,7 +614,6 @@ static int sys_utimensat(int dirfd, const char *pathname, return -1; } #endif -#endif /* TARGET_NR_utimensat */ #if defined(__NR_renameat2) #define __NR_sys_renameat2 __NR_renameat2 @@ -7024,58 +7022,6 @@ static abi_long host_to_target_statfs64(abi_ulong target_addr, } #endif -/* ??? Using host futex calls even when target atomic operations - are not really atomic probably breaks things. However implementing - futexes locally would make futexes shared between multiple processes - tricky. However they're probably useless because guest atomic - operations won't work either. */ -static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, - target_ulong uaddr2, int val3) -{ - struct timespec ts, *pts; - int base_op; - - /* ??? We assume FUTEX_* constants are the same on both host - and target. */ -#ifdef FUTEX_CMD_MASK - base_op = op & FUTEX_CMD_MASK; -#else - base_op = op; -#endif - switch (base_op) { - case FUTEX_WAIT: - case FUTEX_WAIT_BITSET: - if (timeout) { - pts = &ts; - target_to_host_timespec(pts, timeout); - } else { - pts = NULL; - } - return get_errno(safe_futex(g2h(uaddr), op, tswap32(val), - pts, NULL, val3)); - case FUTEX_WAKE: - return get_errno(safe_futex(g2h(uaddr), op, val, NULL, NULL, 0)); - case FUTEX_FD: - return get_errno(safe_futex(g2h(uaddr), op, val, NULL, NULL, 0)); - case FUTEX_REQUEUE: - case FUTEX_CMP_REQUEUE: - case FUTEX_WAKE_OP: - /* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the - TIMEOUT parameter is interpreted as a uint32_t by the kernel. - But the prototype takes a `struct timespec *'; insert casts - to satisfy the compiler. We do not need to tswap TIMEOUT - since it's not compared to guest memory. */ - pts = (struct timespec *)(uintptr_t) timeout; - return get_errno(safe_futex(g2h(uaddr), op, val, pts, - g2h(uaddr2), - (base_op == FUTEX_CMP_REQUEUE - ? tswap32(val3) - : val3))); - default: - return -TARGET_ENOSYS; - } -} - #if defined(TARGET_NR_signalfd) || defined(TARGET_NR_signalfd4) /* signalfd siginfo conversion */ @@ -8574,6 +8520,58 @@ IMPL(ftruncate64) } #endif +IMPL(futex) +{ + target_ulong uaddr = arg1; + int op = arg2; + int val = arg3; + target_ulong timeout = arg4; + target_ulong uaddr2 = arg5; + int val3 = arg6; + struct timespec ts, *pts; + int base_op; + + /* ??? We assume FUTEX_* constants are the same on both host + and target. */ +#ifdef FUTEX_CMD_MASK + base_op = op & FUTEX_CMD_MASK; +#else + base_op = op; +#endif + switch (base_op) { + case FUTEX_WAIT: + case FUTEX_WAIT_BITSET: + if (timeout) { + pts = &ts; + target_to_host_timespec(pts, timeout); + } else { + pts = NULL; + } + return get_errno(safe_futex(g2h(uaddr), op, tswap32(val), + pts, NULL, val3)); + case FUTEX_WAKE: + return get_errno(safe_futex(g2h(uaddr), op, val, NULL, NULL, 0)); + case FUTEX_FD: + return get_errno(safe_futex(g2h(uaddr), op, val, NULL, NULL, 0)); + case FUTEX_REQUEUE: + case FUTEX_CMP_REQUEUE: + case FUTEX_WAKE_OP: + /* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the + TIMEOUT parameter is interpreted as a uint32_t by the kernel. + But the prototype takes a `struct timespec *'; insert casts + to satisfy the compiler. We do not need to tswap TIMEOUT + since it's not compared to guest memory. */ + pts = (struct timespec *)(uintptr_t) timeout; + return get_errno(safe_futex(g2h(uaddr), op, val, pts, + g2h(uaddr2), + (base_op == FUTEX_CMP_REQUEUE + ? tswap32(val3) + : val3))); + default: + return -TARGET_ENOSYS; + } +} + #ifdef TARGET_NR_futimesat IMPL(futimesat) { @@ -12425,6 +12423,32 @@ IMPL(utime) } #endif +IMPL(utimensat) +{ + struct timespec *tsp = NULL, ts[2]; + abi_long ret; + char *p; + + if (arg3) { + if (target_to_host_timespec(&ts[0], arg3) || + target_to_host_timespec(&ts[1], arg3 + + sizeof(struct target_timespec))) { + return -TARGET_EFAULT; + } + tsp = ts; + } + if (!arg2) { + return get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); + unlock_user(p, arg2, 0); + return ret; +} + #ifdef TARGET_NR_utimes IMPL(utimes) { @@ -12579,31 +12603,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_utimensat) - case TARGET_NR_utimensat: - { - struct timespec *tsp, ts[2]; - if (!arg3) { - tsp = NULL; - } else { - target_to_host_timespec(ts, arg3); - target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec)); - tsp = ts; - } - if (!arg2) - ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4)); - else { - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4)); - unlock_user(p, arg2, 0); - } - } - return ret; -#endif - case TARGET_NR_futex: - return do_futex(arg1, arg2, arg3, arg4, arg5, arg6); #if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) case TARGET_NR_inotify_init: ret = get_errno(sys_inotify_init()); @@ -13388,6 +13387,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_ftruncate64 SYSCALL(ftruncate64); #endif + SYSCALL(futex); #ifdef TARGET_NR_futimesat SYSCALL(futimesat); #endif @@ -13858,6 +13858,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_utime SYSCALL(utime); #endif + SYSCALL(utimensat); #ifdef TARGET_NR_utimes SYSCALL(utimes); #endif From patchwork Sun Jun 10 03:02:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138176 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2616145lji; Sat, 9 Jun 2018 21:18:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIP5B1ZF7+uDbPS1ZbJ9dpfDg371a/EQNtTF7PivQZdcsiXTT7LL28O2gfaC5gJ3UY8Qbj3 X-Received: by 2002:ac8:1692:: with SMTP id r18-v6mr11428288qtj.206.1528604293503; Sat, 09 Jun 2018 21:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604293; cv=none; d=google.com; s=arc-20160816; b=uFN4yRKswirDrHScKCPVmBo+UBdmqjOT/pPBHgexJbgz5O28guMngBY7XEdQ3k9mIL PCpfdpyWWG/wgOIEU784Dc0KdMhhxlZavG8gD1YbNnDVfYry2wqGpzZ9fP0AJpJERw6a bfZIKJhd5HOe3BCIwI8VdcKzw6iFswAQyYuiXMea1OCVzMa36TlolsXWb2plVHZnRBkg woDq+kxHix5bVbKKB9crc6gqLYJZaNww5kz1G8rYaND/AT8yaG3n1JXw0n6cf/tDuTyj FTP/Sl9uUrYv6JwSvO5jw2UmHrwXWFmYQX8EkbkgAKS8DtNz1kLBf9CvuTC1fgx9bX77 /0PA== 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:arc-authentication-results; bh=QlVeTj1rlHQ3B8Bg6f76ot99hBRRJdf8tWoYw/ajFPU=; b=Zsn5qsMrfy5qydj7HHHE1spljipCsDUHydx93fL8zTg1nS2Z8i3Ge8MG1sqqAeIpJ0 pOOL97umx1TM12snlqLuSp+27i33aptXE5R5KyR4DXc/fEVfQlNtKF4QGk4RICaEyrYm HFT1PshIOWaAka6gKN6+sbLGMu2j8FlOrU6hrtVOISyheuTj4XLNF6pwkoo8yrPgoWgn yk8GXWtnc6jEyEDMmNxVdoAQebfTLnYlRtAJV51rmjpSrExlvqCHY9crTgqEqo/QBL9J rwUk1uxy5My5Awx2zbdY4FR8kg1ydrzjCC2IvBcYiRb5rzvvkcFAUDjGiPQYaLngzY6O cyVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=P4EhAJEW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o133-v6si5182609qke.209.2018.06.09.21.18.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:18:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=P4EhAJEW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrnx-0003bp-0G for patch@linaro.org; Sun, 10 Jun 2018 00:18:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfm-0004QN-26 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfj-0004gd-AB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:42 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:42524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfj-0004gJ-5O for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:39 -0400 Received: by mail-pg0-x241.google.com with SMTP id c10-v6so2509671pgu.9 for ; Sat, 09 Jun 2018 20:05: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=QlVeTj1rlHQ3B8Bg6f76ot99hBRRJdf8tWoYw/ajFPU=; b=P4EhAJEWXOpjZezoXPqWzZx8wc/6s4NUU/Ka5N41b2F5HnfUINzwZfqFG6evgMine/ scdSvjll82KrE8pouKbEfYcVz5gHcvozrJTM0pZxDB/A/mHwJTRiuv4H4huWSKF3T4ik YxChzumpoP7vxg4Dy4l+mLaP6NHWEiQRF2Dw4= 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=QlVeTj1rlHQ3B8Bg6f76ot99hBRRJdf8tWoYw/ajFPU=; b=aSYejBCO3fwKeVHhsgBymxmtdw8Ka0KZM6O1vL/6mkl0oT6BSo4CzIGQdFKYIxWNC+ VkBSUsk45zcB48CsfM6wQRLrPAuhZmVESH40ag8gHmeTi1bSV+dKh8tAfB6+XTbj1Lfq GKEUmNrlCsx8jemSh92xN/DMi7p2JUtqyeGuXOin88r3JxIeDoo2Abf6APrJJ/b6/s33 5MM+kiLy2Rg9SRMauoy+hU6lNxd3BJMbjqP8mLoQJP4zQzFDPfFz6VnIOElhJHQR9CHm EFXmqnX9lzk650sFyFNTJgc8vazm7qy2NKMDNIyoSGqxS464fCfbB9uBG0hpYNsvm/x6 cO9Q== X-Gm-Message-State: APt69E0aZP576V36nofL+wx4c00jfD+LimUCgY7s1scOzRyJH/FIQhtJ U7ayDqRYfipJ5oE+uprTFcbO4x8FPm4= X-Received: by 2002:a62:cc51:: with SMTP id a78-v6mr12097455pfg.219.1528599937941; Sat, 09 Jun 2018 20:05:37 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:05 -1000 Message-Id: <20180610030220.3777-94-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 093/108] linux-user: Remove sys_futex 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" We can use safe_futex in the one place that used sys_futex; no need to define them both. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 800b79276f..95b30adea2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -235,7 +235,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo #define __NR_sys_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo #define __NR_sys_syslog __NR_syslog -#define __NR_sys_futex __NR_futex #define __NR_sys_inotify_init __NR_inotify_init #define __NR_sys_inotify_add_watch __NR_inotify_add_watch #define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch @@ -282,10 +281,6 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len) _syscall1(int,exit_group,int,error_code) #endif _syscall1(int,set_tid_address,int *,tidptr) -#if defined(TARGET_NR_futex) && defined(__NR_futex) -_syscall6(int,sys_futex,int *,uaddr,int,op,int,val, - const struct timespec *,timeout,int *,uaddr2,int,val3) -#endif #define __NR_sys_sched_getaffinity __NR_sched_getaffinity _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr); @@ -8079,8 +8074,8 @@ IMPL(exit) TaskState *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); + safe_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX, + NULL, NULL, 0); } thread_cpu = NULL; object_unref(OBJECT(cpu)); From patchwork Sun Jun 10 03:02:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138169 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2612312lji; Sat, 9 Jun 2018 21:11:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJw7LGsb/nnEZPNJX6H9E0Yf1qe4hgxwD0tNG49cpYxqUaZHLzPxzTC/HrKwM2/KDQanhBa X-Received: by 2002:a37:9d13:: with SMTP id g19-v6mr10354385qke.217.1528603895881; Sat, 09 Jun 2018 21:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603895; cv=none; d=google.com; s=arc-20160816; b=L/pYaFToUJTiMeEkEpoirNLJeFmZMbBZoyx3PWQFKZFO7l39Wv5eIyIqiY9Ypl7/Pl dhowMZQBdudvONCD4EmWmhgeRzVfvTjUzDqPEHktQYSt1nCE1tqtqcJH+3+cSFGTkdQf sLVj6hEpKBAHpY3rYJdTFrC6MNNIhCb9JQnqQuqYMRRuR7s0LItJzg/nXusCakqDhuoi 8gKLfc+4C2lqr4b6GKQXCa3Bxjr4pkcF8CiIdYxCRHYk50TOwaIVE+KoMVlyXc9ElvUE bejXjiL0VGEBkbPE9pIxgu+J7Ui8faqbOSUfSWq9IFKCFVy6HHdLE9U4iztv68btx5g+ /g+g== 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:arc-authentication-results; bh=BHOdXervprw5sz9D/vM6jCzatyaAU1e4HSS2ZXnR4XQ=; b=gsOmFQp/9R1jpxYqPkgC0eCORsvzA0CgpR+xC9l3i4vsc4UPsnl2S6FqLh8kkCMnB7 iW1Q8NFfFG8IDvSRs/0fKjdEgqcEXMisudMMTKQlMfnlUMtl0mu8yFv7XZBmlOLeV9di +csZ882hXH+yKjv71H0lgPQ6u5a/+tETdfn31Og0CfCqUx/re3G0NxFAdybKaJgN3Yma M+ET35d7t/2UWsl9wFbSU8I/RGBJ5VeQqrPWuzQMyaekZ6kgTniSP6DWCtC9IpbGiezE WuirbLEQN9illROK8nhjl1x9G3Ny5nQd8ckuhekaWRE0yR5FgQ5/J2/i/VAxQdSX0oKr xWVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lrl4Z6rL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 29-v6si13788397qto.253.2018.06.09.21.11.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lrl4Z6rL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrhX-0005nV-9M for patch@linaro.org; Sun, 10 Jun 2018 00:11:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfm-0004R1-Hz for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfl-0004gv-22 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:42 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:47037) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfk-0004gp-QF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:40 -0400 Received: by mail-pg0-x243.google.com with SMTP id d2-v6so8130646pga.13 for ; Sat, 09 Jun 2018 20:05: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=BHOdXervprw5sz9D/vM6jCzatyaAU1e4HSS2ZXnR4XQ=; b=Lrl4Z6rL/lprdYgZrZHDirA6BUcdcFYu0qkwYVftci9bsb7Ki37pEEfr8u+HvDf4kT ouM4OVm0hNg7P9KY89Eb1JH9YGoZcczVzj/9jGJTHvLmVZjCTYlySAR8MRbPEq5EC5UA Qp+r88Y024QlEk4PU3zFhGWkLPwv7T9h3s+mQ= 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=BHOdXervprw5sz9D/vM6jCzatyaAU1e4HSS2ZXnR4XQ=; b=VuMTEdp0Qz/NAhSKjf39Ud+bMkd+wwZCJfUnCJQ/LwZrFKAgdAS9iVX+S9oJitWE0q WA8WocYPep1hULnea2kjqKfISYdQpnmpN8gCqy8UV48qn5YgWRK9UoxE8phsTSjpXQ4w Nqxy/l6EKgRumlDmasjDSc+C0OANdKwwEzqs+WGhdHWIYNGTROIDY+E4CshAOSrP9iWU 2CgDYESUVekYageXjn1a9QS050NSgzgMzwPdIialBhtdRZhSe97QbIQQItMTQ3NNsnbO 9DL1jBYCkFAF9V8dtGRInxGbNAZt4It+K4GVKlzJqS8yKs94mybbD+QPW63wbgSAydqW 5r+w== X-Gm-Message-State: APt69E0xbVJzazUvbkKbjvzH2sClV7yTaef+FGswYTvBrDxZFZX9hT1X WQY28Zxov7HJoGlHoSJ1IloVtUwIjMk= X-Received: by 2002:a62:2281:: with SMTP id p1-v6mr12186141pfj.53.1528599939642; Sat, 09 Jun 2018 20:05:39 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:06 -1000 Message-Id: <20180610030220.3777-95-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 094/108] linux-user: Split out inotify 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 inotify_add_watch, inotify_init, inotify_init1, and inotify_rm_watch. At the same time, merge in the useless wrappers around the libc functions. If host inotify_init1 is not available, use inotify_init if flags == 0. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 139 ++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 74 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 95b30adea2..a540c1455b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -74,6 +74,9 @@ #ifdef CONFIG_SENDFILE #include #endif +#ifdef CONFIG_INOTIFY +#include +#endif #define termios host_termios #define winsize host_winsize @@ -235,9 +238,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo #define __NR_sys_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo #define __NR_sys_syslog __NR_syslog -#define __NR_sys_inotify_init __NR_inotify_init -#define __NR_sys_inotify_add_watch __NR_inotify_add_watch -#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch /* These definitions produce an ENOSYS from the host kernel. * Performing a bogus syscall is lazier than boilerplating @@ -626,43 +626,6 @@ static int sys_renameat2(int oldfd, const char *old, } #endif -#ifdef CONFIG_INOTIFY -#include - -#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) -static int sys_inotify_init(void) -{ - return (inotify_init()); -} -#endif -#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) -static int sys_inotify_add_watch(int fd,const char *pathname, int32_t mask) -{ - return (inotify_add_watch(fd, pathname, mask)); -} -#endif -#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) -static int sys_inotify_rm_watch(int fd, int32_t wd) -{ - return (inotify_rm_watch(fd, wd)); -} -#endif -#ifdef CONFIG_INOTIFY1 -#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) -static int sys_inotify_init1(int flags) -{ - return (inotify_init1(flags)); -} -#endif -#endif -#else -/* Userspace can usually survive runtime without inotify */ -#undef TARGET_NR_inotify_init -#undef TARGET_NR_inotify_init1 -#undef TARGET_NR_inotify_add_watch -#undef TARGET_NR_inotify_rm_watch -#endif /* CONFIG_INOTIFY */ - #if defined(TARGET_NR_prlimit64) #ifndef __NR_prlimit64 # define __NR_prlimit64 -1 @@ -7421,9 +7384,7 @@ static TargetFdTrans target_eventfd_trans = { .target_to_host_data = swap_data_eventfd, }; -#if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \ - (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \ - defined(__NR_inotify_init1)) +#ifdef CONFIG_INOTIFY static abi_long host_to_target_data_inotify(void *buf, size_t len) { struct inotify_event *ev; @@ -9177,6 +9138,59 @@ IMPL(getxuid) } #endif +#ifdef CONFIG_INOTIFY +IMPL(inotify_add_watch) +{ + char *p; + abi_long ret; + + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(inotify_add_watch(arg1, path(p), arg3)); + unlock_user(p, arg2, 0); + return ret; +} + +# ifdef TARGET_NR_inotify_init +IMPL(inotify_init) +{ + abi_long ret = get_errno(inotify_init()); + if (!is_error(ret)) { + fd_trans_register(ret, &target_inotify_trans); + } + return ret; +} +# endif + +IMPL(inotify_init1) +{ + int flags = target_to_host_bitmask(arg1, fcntl_flags_tbl); + abi_long ret; + +# ifdef CONFIG_INOTIFY1 + ret = inotify_init1(flags); +# else + if (arg1 == 0) { + ret = inotify_init(); + } else { + return -TARGET_ENOSYS; + } +# endif + ret = get_errno(ret); + if (!is_error(ret)) { + fd_trans_register(ret, &target_inotify_trans); + } + return ret; +} + +IMPL(inotify_rm_watch) +{ + return get_errno(inotify_rm_watch(arg1, arg2)); +} +#endif /* CONFIG_INOTIFY */ + /* ??? Implement proper locking for ioctls. */ IMPL(ioctl) { @@ -12598,37 +12612,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init) - case TARGET_NR_inotify_init: - ret = get_errno(sys_inotify_init()); - if (ret >= 0) { - fd_trans_register(ret, &target_inotify_trans); - } - return ret; -#endif -#ifdef CONFIG_INOTIFY1 -#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1) - case TARGET_NR_inotify_init1: - ret = get_errno(sys_inotify_init1(target_to_host_bitmask(arg1, - fcntl_flags_tbl))); - if (ret >= 0) { - fd_trans_register(ret, &target_inotify_trans); - } - return ret; -#endif -#endif -#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) - case TARGET_NR_inotify_add_watch: - p = lock_user_string(arg2); - ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3)); - unlock_user(p, arg2, 0); - return ret; -#endif -#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) - case TARGET_NR_inotify_rm_watch: - return get_errno(sys_inotify_rm_watch(arg1, arg2)); -#endif - #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) case TARGET_NR_mq_open: { @@ -13481,6 +13464,14 @@ static impl_fn *syscall_table(unsigned num) #endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA) SYSCALL(getxuid); +#endif +#ifdef CONFIG_INOTIFY + SYSCALL(inotify_add_watch); +# ifdef TARGET_NR_inotify_init + SYSCALL(inotify_init); +# endif + SYSCALL(inotify_init1); + SYSCALL(inotify_rm_watch); #endif SYSCALL(ioctl); #ifdef TARGET_NR_ipc From patchwork Sun Jun 10 03:02:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138178 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2617130lji; Sat, 9 Jun 2018 21:19:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLybFj99ARbA+GM2ZMA6YvbRx+EW/yqnO/Orx2OoMiWNq4sDO47WIBb3V3OhRN7DbbN0CZC X-Received: by 2002:a37:6e83:: with SMTP id j125-v6mr6881046qkc.237.1528604394274; Sat, 09 Jun 2018 21:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604394; cv=none; d=google.com; s=arc-20160816; b=nFwIk09jHEZObJS6ydfy15LrF/q7ufKw7U5dE00v87uQ6+8ZRrsO2Yf8aku3RDZjB/ xBCnHFg6M60TJ3kUpIZyn+89f7SmHEEmsTK6E7kdwO77Kdidn9kvU83+LvEoDm/e00Qe b8BmpuiSsKc1WD3AAhmH/fPEfCwq9SyJRMfe/8ZVneoDSrh03MWQWpsZVYT9eYj7ZaEr m+Jbcgl7RZprEbXkHk1SNnzSfC3/yn8lDKI+Q20rOMObBO51fx6ElKMw6fJ+ZnMpcqJy baSQlC2mbqtNQLYdsSJ8P6Ju5jt/I5wKeIe/7UWwZJNILzzAoYVjCAtBf4uSVUoZP0+O zWMw== 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:arc-authentication-results; bh=FSpu2eU4yP7W5bv4XVKK/hTWwA7/qFdooXWRU7ozHlQ=; b=SmYnI1Td4gDGuLu2hL5etfN1rJzMT/mYnaob1iNdoIJT38eawRuv1oiDLcGYCJVM1q TWeOdhebYTb8PYqoOngfHfw9rc7B/Ee+b/UNsBCEsFnMBLbYtx3So1s6e71jwUaxLF3V y+Jj+4hva+T+a/LrrY6FJAiqLC1UgzPeOFI/mog8ScfXrxEflvuMKJmULXzsAoND5nDB EWiC3I9GHZrVGDGEP94MYd87jQCscAmkudHpccvgd/tn4VaNcemzcXb9AyYlp0mOKpIC +UBFgIIc0xr/43YlTVqjPqr8QFCyZTGus2iySaTy7SMP399B6pfBwqwJGd0loVsjuiXC rYmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EBGDYVS1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w13-v6si3800732qto.294.2018.06.09.21.19.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:19:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EBGDYVS1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrpZ-0004xt-P1 for patch@linaro.org; Sun, 10 Jun 2018 00:19:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfo-0004Su-Cn for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfm-0004hU-V3 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:44 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:38123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfm-0004hC-MX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:42 -0400 Received: by mail-pf0-x242.google.com with SMTP id b74-v6so8494801pfl.5 for ; Sat, 09 Jun 2018 20:05: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=FSpu2eU4yP7W5bv4XVKK/hTWwA7/qFdooXWRU7ozHlQ=; b=EBGDYVS1oA8sAF2dA9p+kgFknnzOJziBKAYgLAdgsz3WRYHg/Q57luM9wEr8cf8oZV J/c5LyB2QhRMjbeehxK0yLHxICi2WXKhnNArGCcZkTlFeY5aGANoBSGK41lTo98L0GlJ w2PY8gN8hpi0TbUmFBEKIFa5IX13wzoLrPH9s= 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=FSpu2eU4yP7W5bv4XVKK/hTWwA7/qFdooXWRU7ozHlQ=; b=Tx1lfDqpKjUB3bQPei6ZKd5t/l+A/E2Lk2uWKNaXFqUeJ119SHbi2/5XPtkI0DRt7d j66wmH9J/l8MuBOs+u0+cS1HHoUweZ5OPrYZSclG49WNs9jZ4GtDKj5rOTYMBvJIcT61 8EUxcgDlWEwIs1ubnRbl93hA78/ZSuo9VLUi92QN+xjD4UyQF7NvzujOEkWWQI9u+V5L tYK84TcdZaCW2mxQIhKGf66olx7EuuBFcU9S0KrP0fXnTzjNCu97s8BBLgwkUJZbOrbl 3JKIPRN/qtvoBE361b9Bteom0+SKN5EHmYuJpO+kBJr8MMYr0RmhJ0oEEY946VmjN4RW vO6Q== X-Gm-Message-State: APt69E2DZlhaeFKJlUXB63RtKZa3NBpr72TkO3dAHSq4dfrEvI6KWg16 Ksb5SgIfJbkQiGTPq+FHcrcB4wa+KXY= X-Received: by 2002:a62:3e11:: with SMTP id l17-v6mr12304343pfa.18.1528599941462; Sat, 09 Jun 2018 20:05:41 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:07 -1000 Message-Id: <20180610030220.3777-96-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 095/108] linux-user: Split out mq 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 mq_getsetattr, mq_open, mq_timedreceive, mq_timedsend, and mq_unlink. All targets define these syscalls; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 211 +++++++++++++++++++++++-------------------- 1 file changed, 112 insertions(+), 99 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a540c1455b..0c312cd156 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -77,6 +77,7 @@ #ifdef CONFIG_INOTIFY #include #endif +#include #define termios host_termios #define winsize host_winsize @@ -1000,12 +1001,10 @@ static int safe_semtimedop(int semid, struct sembuf *tsops, unsigned nsops, (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) safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, len, unsigned *, prio, const struct timespec *, timeout) -#endif /* 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. @@ -1382,9 +1381,6 @@ static inline abi_long copy_from_user_timezone(struct timezone *tz, return 0; } -#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) -#include - static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr, abi_ulong target_mq_attr_addr) { @@ -1422,7 +1418,6 @@ static inline abi_long copy_to_user_mq_attr(abi_ulong target_mq_attr_addr, return 0; } -#endif #if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) /* do_select() must return target values and target errnos. */ @@ -9836,6 +9831,112 @@ IMPL(mprotect) return get_errno(target_mprotect(arg1, arg2, arg3)); } +IMPL(mq_getsetattr) +{ + struct mq_attr in, out; + abi_long ret = 0; + + if (arg2 != 0) { + ret = copy_from_user_mq_attr(&in, arg2); + if (ret) { + return ret; + } + ret = get_errno(mq_setattr(arg1, &in, &out)); + } else if (arg3 != 0) { + ret = get_errno(mq_getattr(arg1, &out)); + } + if (ret == 0 && arg3 != 0) { + ret = copy_to_user_mq_attr(arg3, &out); + } + return ret; +} + +IMPL(mq_open) +{ + struct mq_attr posix_mq_attr; + struct mq_attr *pposix_mq_attr; + int host_flags; + abi_long ret; + char *p; + + host_flags = target_to_host_bitmask(arg2, fcntl_flags_tbl); + pposix_mq_attr = NULL; + if (arg4) { + if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) { + return -TARGET_EFAULT; + } + pposix_mq_attr = &posix_mq_attr; + } + p = lock_user_string(arg1 - 1); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr)); + unlock_user(p, arg1, 0); + return ret; +} + +IMPL(mq_timedreceive) +{ + struct timespec ts; + unsigned int prio; + abi_long ret; + void *p; + + p = lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 != 0) { + ret = target_to_host_timespec(&ts, arg5); + if (ret == 0) { + ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, &ts)); + if (ret == 0) { + ret = host_to_target_timespec(arg5, &ts); + } + } + } else { + ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, NULL)); + } + unlock_user(p, arg2, arg3); + if (ret == 0 && arg4 != 0) { + ret = put_user_u32(prio, arg4); + } + return ret; +} + +IMPL(mq_timedsend) +{ + struct timespec ts; + abi_long ret; + void *p; + + p = lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 != 0) { + ret = target_to_host_timespec(&ts, arg5); + if (ret == 0) { + ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &ts)); + if (ret == 0) { + ret = host_to_target_timespec(arg5, &ts); + } + } + } else { + ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, NULL)); + } + unlock_user(p, arg2, arg3); + return ret; +} + +IMPL(mq_unlink) +{ + char *p = lock_user_string(arg1 - 1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mq_unlink(p)); + unlock_user(p, arg1, 0); + return ret; +} + IMPL(mremap) { return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); @@ -12609,101 +12710,8 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, { CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); abi_long ret; - void *p; switch(num) { -#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) - case TARGET_NR_mq_open: - { - struct mq_attr posix_mq_attr; - struct mq_attr *pposix_mq_attr; - int host_flags; - - host_flags = target_to_host_bitmask(arg2, fcntl_flags_tbl); - pposix_mq_attr = NULL; - if (arg4) { - if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) { - return -TARGET_EFAULT; - } - pposix_mq_attr = &posix_mq_attr; - } - p = lock_user_string(arg1 - 1); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr)); - unlock_user (p, arg1, 0); - } - return ret; - - case TARGET_NR_mq_unlink: - p = lock_user_string(arg1 - 1); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(mq_unlink(p)); - unlock_user (p, arg1, 0); - return ret; - - case TARGET_NR_mq_timedsend: - { - struct timespec ts; - - p = lock_user (VERIFY_READ, arg2, arg3, 1); - if (arg5 != 0) { - target_to_host_timespec(&ts, arg5); - ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &ts)); - host_to_target_timespec(arg5, &ts); - } else { - ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, NULL)); - } - unlock_user (p, arg2, arg3); - } - return ret; - - case TARGET_NR_mq_timedreceive: - { - struct timespec ts; - unsigned int prio; - - p = lock_user (VERIFY_READ, arg2, arg3, 1); - if (arg5 != 0) { - target_to_host_timespec(&ts, arg5); - ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, - &prio, &ts)); - host_to_target_timespec(arg5, &ts); - } else { - ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, - &prio, NULL)); - } - unlock_user (p, arg2, arg3); - if (arg4 != 0) - put_user_u32(prio, arg4); - } - return ret; - - /* Not implemented for now... */ -/* case TARGET_NR_mq_notify: */ -/* break; */ - - case TARGET_NR_mq_getsetattr: - { - struct mq_attr posix_mq_attr_in, posix_mq_attr_out; - ret = 0; - if (arg2 != 0) { - copy_from_user_mq_attr(&posix_mq_attr_in, arg2); - ret = get_errno(mq_setattr(arg1, &posix_mq_attr_in, - &posix_mq_attr_out)); - } else if (arg3 != 0) { - ret = get_errno(mq_getattr(arg1, &posix_mq_attr_out)); - } - if (ret == 0 && arg3 != 0) { - copy_to_user_mq_attr(arg3, &posix_mq_attr_out); - } - } - return ret; -#endif - #ifdef CONFIG_SPLICE #ifdef TARGET_NR_tee case TARGET_NR_tee: @@ -13537,6 +13545,11 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(mount); SYSCALL(mprotect); + SYSCALL(mq_getsetattr); + SYSCALL(mq_open); + SYSCALL(mq_timedreceive); + SYSCALL(mq_timedsend); + SYSCALL(mq_unlink); SYSCALL(mremap); #ifdef TARGET_NR_msgctl SYSCALL(msgctl); From patchwork Sun Jun 10 03:02:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138174 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2613964lji; Sat, 9 Jun 2018 21:14:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJU784QSqipXkaZHJdubEnqNQyMSyET3wzGwqoSLaQ16Om6aMj6nnFphcl3zN0GkCiCXF8f X-Received: by 2002:ac8:1090:: with SMTP id a16-v6mr3161184qtj.307.1528604067338; Sat, 09 Jun 2018 21:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604067; cv=none; d=google.com; s=arc-20160816; b=wJKVAa7+/v7m8LXLq4IHw4Jis8SpZG+7AxvNHco2w+fhuGgZGzyDdO0E1Pedh4HgoX mFZ/613aP9kUHxM3AGAr+9QyMz2tPdURPGEd1DnxX3gMktY+ukXCIhTj0IF4aI72AqqZ KUATWGzoFxMTh+/y3viTUV0f5zSUFND4ic8fCpA/iPvXwmbautGLAa3lhs6sZNGeJFoZ Ow2LbxGDb68KGbgZojZelySUfFyYI29SkfwQvKz8PUFz1Zv6OZ7Yl6tc1VMQt0ZTAjQu 4U3/eavy/pggj/OTxF9CS/cVs7b6RRTeeuL01dVFu3Ikuc0Ky7mbJxzC2wK0VeRwYuro N16g== 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:arc-authentication-results; bh=Q3hyNEKTYkeV+S5YR7K8UJIocovN8V+pUIR4pcFGMyQ=; b=pcRl7J1MUkBRDWlu5dTYbOFMuxLfWfgFy6WmbfUX8MUmLP0KSlYXdwCECnS/s2rnJP p04qZ7e4dSulWoksXXp5FYln9UzOSjdXsWHu3b2x7ZeUn2a1/NNKTBx+ED3GEmDmcxlG nTdy3QNr17WqoIr6m8pHWI9xUrkteyYgobdD47/ISIkwrcdyDFieTttUAPoCVC6WlMaK RWauKl1MnXWViKb6660r+6n02Xd1PiV2xtr1M81ccKeKSkh3pj4EpgzwU1ghJwmM8RnT eX5nV4pu6J+WoLEpK9jvdLhi5vv5rJQlLPB9cV9Jkbk8xw6wlAE9gc+gOUISHpRoyFbr xjLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N+hKJ6Eg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u21-v6si8602119qvc.168.2018.06.09.21.14.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:14:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N+hKJ6Eg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrkI-0008Da-OE for patch@linaro.org; Sun, 10 Jun 2018 00:14:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfp-0004UN-MA for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfo-0004hw-Lm for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:45 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:40580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfo-0004hh-DE for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:44 -0400 Received: by mail-pf0-x241.google.com with SMTP id z24-v6so8491736pfe.7 for ; Sat, 09 Jun 2018 20:05: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=Q3hyNEKTYkeV+S5YR7K8UJIocovN8V+pUIR4pcFGMyQ=; b=N+hKJ6Egc/yxBRwMM7ZRomqksFJpij04D/WA2GRewN6M9hi4jotyYCtYPV8YLDQ/Rt wTmgk11QlaAJj8cD+eZNmdxqfi55dNc/7o2tM+rl49OjUEzeS5zB9GUINNH9iNbIh5LJ YkGwUt34zqI5Xr8cAzkLKrHYy5Y+2ewGI2mWA= 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=Q3hyNEKTYkeV+S5YR7K8UJIocovN8V+pUIR4pcFGMyQ=; b=SKulJqtAFJCdrpjneYS7JHd87H/9PNJFBiLQznrUl/0mssq8DuY9cQFm29kboGIHQJ PyIMGsg/3xaAWOivZOSm1xrLiGsta1smKor+QKd+dnQLCVXrd+mGSrKoslmr10FwCpx3 nmElgobqCyJLIRDDLNMzLEDLobn3To/KbP21FRhM6FwcZhkUQy0YyCq60ypRMysWexbz tOsSIbj5H5gzET1F4fHmWRJdrsrtuqeOqyRrpSOIqyqMqPGvRHhtyUN/TdGmOQZ8IFMw ArQLUdz0t/abGvzj7kmmZdineMqcMBfLxmfDuMD17lmcA8uwRnjnAknUh5r0H+BkcHep jq4w== X-Gm-Message-State: APt69E3QvtfjTkFg7cawVbjfAxHBAktC4jAbrnK/Fdo0JfQ94P1DKw54 2xKwDo4LvlNhXl9tOE+v0WAJS71/Xnk= X-Received: by 2002:a62:3b5d:: with SMTP id i90-v6mr12354873pfa.24.1528599943165; Sat, 09 Jun 2018 20:05:43 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:08 -1000 Message-Id: <20180610030220.3777-97-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 096/108] linux-user: Split out splice, tee, vmsplice 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 define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 117 +++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 53 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0c312cd156..8548f113d1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12075,6 +12075,39 @@ IMPL(socketpair) } #endif +#ifdef CONFIG_SPLICE +IMPL(splice) +{ + loff_t loff_in, loff_out; + loff_t *ploff_in = NULL, *ploff_out = NULL; + abi_long ret; + + if (arg2) { + if (get_user_u64(loff_in, arg2)) { + return -TARGET_EFAULT; + } + ploff_in = &loff_in; + } + if (arg4) { + if (get_user_u64(loff_out, arg4)) { + return -TARGET_EFAULT; + } + ploff_out = &loff_out; + } + ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6)); + if (arg2) { + if (put_user_u64(loff_in, arg2)) { + return -TARGET_EFAULT; + } + } + if (arg4) { + if (put_user_u64(loff_out, arg4)) { + return -TARGET_EFAULT; + } + } + return ret; +} +#endif #ifdef TARGET_NR_ssetmask IMPL(ssetmask) { @@ -12324,6 +12357,13 @@ IMPL(syslog) } } +#ifdef CONFIG_SPLICE +IMPL(tee) +{ + return get_errno(tee(arg1, arg2, arg3, arg4)); +} +#endif + IMPL(tgkill) { return get_errno(safe_tgkill((int)arg1, (int)arg2, @@ -12603,6 +12643,21 @@ IMPL(vm86) } #endif +#ifdef CONFIG_SPLICE +IMPL(vmsplice) +{ + struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); + abi_long ret; + + if (vec == NULL) { + return -host_to_target_errno(errno); + } + ret = get_errno(vmsplice(arg1, vec, arg3, arg4)); + unlock_iovec(vec, arg2, arg3, 0); + return ret; +} +#endif + IMPL(wait4) { int status; @@ -12712,59 +12767,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef CONFIG_SPLICE -#ifdef TARGET_NR_tee - case TARGET_NR_tee: - { - ret = get_errno(tee(arg1,arg2,arg3,arg4)); - } - return ret; -#endif -#ifdef TARGET_NR_splice - case TARGET_NR_splice: - { - loff_t loff_in, loff_out; - loff_t *ploff_in = NULL, *ploff_out = NULL; - if (arg2) { - if (get_user_u64(loff_in, arg2)) { - return -TARGET_EFAULT; - } - ploff_in = &loff_in; - } - if (arg4) { - if (get_user_u64(loff_out, arg4)) { - return -TARGET_EFAULT; - } - ploff_out = &loff_out; - } - ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6)); - if (arg2) { - if (put_user_u64(loff_in, arg2)) { - return -TARGET_EFAULT; - } - } - if (arg4) { - if (put_user_u64(loff_out, arg4)) { - return -TARGET_EFAULT; - } - } - } - return ret; -#endif -#ifdef TARGET_NR_vmsplice - case TARGET_NR_vmsplice: - { - struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); - if (vec != NULL) { - ret = get_errno(vmsplice(arg1, vec, arg3, arg4)); - unlock_iovec(vec, arg2, arg3, 0); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; -#endif -#endif /* CONFIG_SPLICE */ #ifdef CONFIG_EVENTFD #if defined(TARGET_NR_eventfd) case TARGET_NR_eventfd: @@ -13800,6 +13802,9 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_socketpair SYSCALL(socketpair); #endif +#ifdef CONFIG_SPLICE + SYSCALL(splice); +#endif #ifdef TARGET_NR_ssetmask SYSCALL(ssetmask); #endif @@ -13831,6 +13836,9 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(sysinfo); SYSCALL(syslog); +#ifdef CONFIG_SPLICE + SYSCALL(tee); +#endif SYSCALL(tgkill); #ifdef TARGET_NR_time SYSCALL(time); @@ -13867,6 +13875,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(vhangup); #if defined(TARGET_I386) && !defined(TARGET_X86_64) SYSCALL(vm86); +#endif +#ifdef CONFIG_SPLICE + SYSCALL(vmsplice); #endif SYSCALL(wait4); SYSCALL(waitid); From patchwork Sun Jun 10 03:02:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138179 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2617319lji; Sat, 9 Jun 2018 21:20:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKFTss6y+IhKOg/RayOiA/3yae6u1cwhttQEQOt2ypgklRU82NknDtZzfqOxkJBOmMDtilg X-Received: by 2002:a37:e102:: with SMTP id c2-v6mr10118098qkm.18.1528604412339; Sat, 09 Jun 2018 21:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604412; cv=none; d=google.com; s=arc-20160816; b=bMX3CaSixfybEuf+nxhD2biGoFPMiMEmamO2DBCBLdHVr1iuPkl+RW/v4gswYAYV3Z 4YYTgPe4z6LPtk65/GfmI3kWpcrpbsfRmfaX/Az80n8V+qfiprUD6R5rQ9xlzJq41N95 VlYCxDxK1QmPLtUvYLr9DVgzFfqL0ZRgOCcPMXjN5uFrg+hpCxRAzBBcaJtQJFOfpWEk 7PUVmzexDqGSUqDtT93w9M/h5xle5g+NpyZCNFeZhlsewK/Lg3RbkptAWacKIbFy76P+ ymmi1KLGloj4oK1IRIxHKZPymLWsZkfXrp2cpsWFcBubV2omFQ+YoKz5a2SzQNcZKpqa 8/aA== 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:arc-authentication-results; bh=+vtsSTxRB60MNVp1ZyA7bfX5Ze3pHyo+t2dzlL0HpHg=; b=Ss7XhMyjFJrchlWfnEfdtg0PqhtU0uP37ieheMVLSaQhwaa1aHZG3mUj2nwos95O9n hPk93EoiygcdEhzkV8FKwbSD/IUj+EzsAGVSD4y7xODWujQU3WiCiMMaG1QilkPKjx2+ flm61jNyuO3VhRXaW3Rl38mcXBsF2BzhucQcmNa/mgQa3w4QCSb0PSRO4rwFrIQygJdG QL+uye9z327OiutqU+9afTsqbGG1gSfgjY6huG2aJTe2O0kkIhcqjHqI/It+E+uxacqu 55wmOaHXSkzkQC+XKvusf2PsZ34GJVJEJ0C/1R5QfBf2v2nQiyMf099QP2LJt34fx3A2 GEdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PA6bi8eV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e67-v6si3687458qkd.66.2018.06.09.21.20.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:20:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PA6bi8eV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrpr-000509-SD for patch@linaro.org; Sun, 10 Jun 2018 00:20:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfr-0004Vf-F7 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfq-0004iR-Cy for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:47 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:45645) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfq-0004i9-6A for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:46 -0400 Received: by mail-pf0-x243.google.com with SMTP id a22-v6so8480880pfo.12 for ; Sat, 09 Jun 2018 20:05: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=+vtsSTxRB60MNVp1ZyA7bfX5Ze3pHyo+t2dzlL0HpHg=; b=PA6bi8eVCF4ArxTp5mrE59+zpCWOPzh6dobduWMVsXuGTDKeUPzGZzOxaBE1PSYi1F qeNHTrBs8gSZUqfmm04e8LCAwY66Jt0RUVBFxVktIFf/f+j88dj7bF7SRcMvxxqJF+YF R2zWoIMQKquQkQE6KlT/mMTjSeLAocpQGB9cE= 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=+vtsSTxRB60MNVp1ZyA7bfX5Ze3pHyo+t2dzlL0HpHg=; b=nCJb8tw723bf7zyJArjH5HTFVPStOBDzJgosC5U9F1tXPxbyDjRLEWkIkH3BBfgLBz 6CWkRvNY/XFaTDEw4auGxQtTC2XW1uN1mMluvps+yqGMs3fISGxlrhDMKrCvW8QdgHXz 7Y9EeLh7OdsIXnEtTWTRDxx4wIJyTms8UW36+0lLViMZ4PJyPs7UunKo1SYfu6ybBZgE M3jeHvitcN9jjCn+OiFVrXs6n8SJb1Hsy74ZLDPHAA8aHe7G72w35Rjp1bGkRR7ihXWY 9OqekpTje0m0i4LQJQ/Od+7cW1RIfOoQ/QOQ0+bBBH+VofMXTXd7XSXOxT++WGTR/ikM ZQeA== X-Gm-Message-State: APt69E0b1YKM1XxOkvaWYQqpb0Y65oe2RfUCkT+kYVaNJ+jZ3aNPfe9H WRqI0lctJuxFa37sMp73ACGmtgNbWis= X-Received: by 2002:a62:5c06:: with SMTP id q6-v6mr12205885pfb.118.1528599944880; Sat, 09 Jun 2018 20:05:44 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:09 -1000 Message-Id: <20180610030220.3777-98-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 097/108] linux-user: Split out eventfd, eventfd2 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 define eventfd2; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 64 +++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8548f113d1..1158afde27 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7903,6 +7903,37 @@ IMPL(dup3) return ret; } +#ifdef CONFIG_EVENTFD +# ifdef TARGET_NR_eventfd +IMPL(eventfd) +{ + abi_long ret = get_errno(eventfd(arg1, 0)); + if (ret >= 0) { + fd_trans_register(ret, &target_eventfd_trans); + } + return ret; +} +# endif + +IMPL(eventfd2) +{ + int host_flags = arg2 & (~(TARGET_O_NONBLOCK | TARGET_O_CLOEXEC)); + abi_long ret; + + if (arg2 & TARGET_O_NONBLOCK) { + host_flags |= O_NONBLOCK; + } + if (arg2 & TARGET_O_CLOEXEC) { + host_flags |= O_CLOEXEC; + } + ret = get_errno(eventfd(arg1, host_flags)); + if (ret >= 0) { + fd_trans_register(ret, &target_eventfd_trans); + } + return ret; +} +#endif /* CONFIG_EVENTFD */ + IMPL(execve) { abi_ulong *guest_ptrs; @@ -12767,33 +12798,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef CONFIG_EVENTFD -#if defined(TARGET_NR_eventfd) - case TARGET_NR_eventfd: - ret = get_errno(eventfd(arg1, 0)); - if (ret >= 0) { - fd_trans_register(ret, &target_eventfd_trans); - } - return ret; -#endif -#if defined(TARGET_NR_eventfd2) - case TARGET_NR_eventfd2: - { - int host_flags = arg2 & (~(TARGET_O_NONBLOCK | TARGET_O_CLOEXEC)); - if (arg2 & TARGET_O_NONBLOCK) { - host_flags |= O_NONBLOCK; - } - if (arg2 & TARGET_O_CLOEXEC) { - host_flags |= O_CLOEXEC; - } - ret = get_errno(eventfd(arg1, host_flags)); - if (ret >= 0) { - fd_trans_register(ret, &target_eventfd_trans); - } - return ret; - } -#endif -#endif /* CONFIG_EVENTFD */ #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) case TARGET_NR_fallocate: #if TARGET_ABI_BITS == 32 @@ -13314,6 +13318,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(dup2); #endif SYSCALL(dup3); +#ifdef CONFIG_EVENTFD +# ifdef TARGET_NR_eventfd + SYSCALL(eventfd); +# endif + SYSCALL(eventfd2); +#endif SYSCALL(execve); SYSCALL(exit); #ifdef __NR_exit_group From patchwork Sun Jun 10 03:02:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138157 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2607040lji; Sat, 9 Jun 2018 21:03:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJkxcdVeUKrE2InYpwjABtbEkz8PubmGw/Ily1p/EMIv+VyiZepiYiPa/q0/W9vSMD2osmI X-Received: by 2002:ae9:e118:: with SMTP id g24-v6mr10084643qkm.99.1528603381891; Sat, 09 Jun 2018 21:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603381; cv=none; d=google.com; s=arc-20160816; b=XuvljiFMIcmsEOxHTjYxaW53NjQv/trM+mAx1MY5CJZI730OGs1TfwuJlJsw0Y4FT5 q7mfgo7JhcrOQCTh8p0hGth3tppE1zQcJyVakqOBDTM6di0DIIxCNTnJfSgWlJoOlXHd JADJRAUUcFCQA3g6oetQPfpYYt1RReD9wI772k2OdWoP0UTPqMSUloEk62vc7oVatj3w ZG+WmqeBx10qMfhExfxrWz4Cq7OksUoxhWDFO2+ncDEO3AdSYvtGZpdX641WyiQtn+lz 2aSzK5TQ79Ri1AXF+Dq+F0WlyCpm5hwwN3HQbUIEOR7XTlRTra+D8PLBn3MKBDgQ1GVC au1Q== 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:arc-authentication-results; bh=Zm91lsDlU3436di8f4ZHPG4Jj38ACT/W7U0hQR/idPk=; b=FVMAuLg4RbxzbnFc2o9JLlecTJx5Q3OrmA4f4lYVQEnbYDNX4vJHfYSBzpZRkdnjUl O9qOXbr7w1X5rsi90y8AZXHUwlhVlKbcM+iKApxJCoBQuproj0zIm5krxOyS7KvnqH2a DtZlM13w2HSsnW/GipARZq8HN7gHCtAu4D/f/CRhFYAZwjmHg2oETVBjAWvt2GCArxob 8JBE+bi4K613j+sjWXn4LPFXZsymSTk+LT+8rOVxO078Lcw9cAsAi5pSF+HiE60P5urV ct9OnZCdyfWOw3jJhUmsQX7GraGo9K3uxvBPuA6gSb50jiwU6KY7QWdqZdaGPUmDD8S1 pDFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Da3EBISb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y26-v6si8975894qtf.222.2018.06.09.21.03.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:03:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Da3EBISb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZF-0006yx-A0 for patch@linaro.org; Sun, 10 Jun 2018 00:03:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfv-0004ZV-2L for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfs-0004jK-21 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:51 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:43603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfr-0004it-ST for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:47 -0400 Received: by mail-pl0-x241.google.com with SMTP id c41-v6so10386204plj.10 for ; Sat, 09 Jun 2018 20:05: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=Zm91lsDlU3436di8f4ZHPG4Jj38ACT/W7U0hQR/idPk=; b=Da3EBISbpzmMRlO/WxgaICOojtbJJpCI5E/2B5NAilzs9GnOOjFKSiZTiPF4Tg+clb 6q9uxA081AtkT++tT61V5KjwCwrWJnK5EXDoYINEastBwg31/7lAe+tt5VLViTXsFCvR I9rdWec2bEEgSddsOqcVJyOf+OU5lrTJvt1I4= 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=Zm91lsDlU3436di8f4ZHPG4Jj38ACT/W7U0hQR/idPk=; b=L54/4uxk19yuKbaff+q5jdESiAXlxXfS68H8eip7ibf4anT8XbKvP0sIu2Ur9E1gLf uHVyMgpZzePFD4SndT4bxMUHN96J9SevrAVuxixhViL121lqL2M0Fw9RrAO712bFgv+2 QOBl1Y484wahtJjOL2f6wG9RRJDDPFC8JxBMnczviQx0zKv7zvJThUdTgkgc9KNrlo5C eY78o7gdoMjYiuFmJOrQhjRBAZW1nIH8h8fkSmSN3jOvCr/RviuBtIq/6xiDr7UOCWS/ yKJBgaxOc28ABqVz6NrKLKUcGRWGNH0+6l10KnZ8395/C7hv3ZCGkl7YoP32DKgf++tn lKdw== X-Gm-Message-State: APt69E34Mq22wTZqbpjoRI/fZ60u2X+S9In/JioeizBL0Xpg+WA14sVe Aby4vsS4LR9ZL1rCUrHqHbv6FagwAEc= X-Received: by 2002:a17:902:784d:: with SMTP id e13-v6mr12980671pln.197.1528599946649; Sat, 09 Jun 2018 20:05:46 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:10 -1000 Message-Id: <20180610030220.3777-99-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 098/108] linux-user: Split out fallocate, sync_file_range/2 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 define fallocate; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 101 +++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 38 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1158afde27..5edcb39b73 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8208,6 +8208,18 @@ IMPL(fadvise64) # endif #endif /* end fadvise64 handling */ +#ifdef CONFIG_FALLOCATE +IMPL(fallocate) +{ +# if TARGET_ABI_BITS == 32 + return get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4), + target_offset64(arg5, arg6))); +# else + return get_errno(fallocate(arg1, arg2, arg3, arg4)); +# endif +} +#endif + IMPL(fchdir) { return get_errno(fchdir(arg1)); @@ -12310,6 +12322,46 @@ IMPL(syncfs) } #endif +#ifdef CONFIG_SYNC_FILE_RANGE +# ifdef TARGET_NR_sync_file_range +IMPL(sync_file_range) +{ + uint64_t off, len; + unsigned flags; + +# if TARGET_ABI_BITS == 32 + if (regpairs_aligned(cpu_env, TARGET_NR_sync_file_range)) { + off = target_offset64(arg3, arg4); + len = target_offset64(arg5, arg6); + flags = arg7; + } else { + off = target_offset64(arg2, arg3); + len = target_offset64(arg4, arg5); + flags = arg6; + } +# else + off = arg2; + len = arg3; + flags = arg4; +# endif + return get_errno(sync_file_range(arg1, off, len, flags)); +} +# endif + +# ifdef TARGET_NR_sync_file_range2 +IMPL(sync_file_range2) +{ + /* This is like sync_file_range but the arguments are reordered */ +# if TARGET_ABI_BITS == 32 + return get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), + target_offset64(arg5, arg6), arg2)); +# else + return get_errno(sync_file_range(arg1, arg3, arg4, arg2)); +# endif +} +# endif +#endif /* CONFIG_SYNC_FILE_RANGE */ + #ifdef TARGET_NR__sysctl IMPL(_sysctl) { @@ -12798,44 +12850,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) - case TARGET_NR_fallocate: -#if TARGET_ABI_BITS == 32 - ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4), - target_offset64(arg5, arg6))); -#else - ret = get_errno(fallocate(arg1, arg2, arg3, arg4)); -#endif - return ret; -#endif -#if defined(CONFIG_SYNC_FILE_RANGE) -#if defined(TARGET_NR_sync_file_range) - case TARGET_NR_sync_file_range: -#if TARGET_ABI_BITS == 32 -#if defined(TARGET_MIPS) - ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), - target_offset64(arg5, arg6), arg7)); -#else - ret = get_errno(sync_file_range(arg1, target_offset64(arg2, arg3), - target_offset64(arg4, arg5), arg6)); -#endif /* !TARGET_MIPS */ -#else - ret = get_errno(sync_file_range(arg1, arg2, arg3, arg4)); -#endif - return ret; -#endif -#if defined(TARGET_NR_sync_file_range2) - case TARGET_NR_sync_file_range2: - /* This is like sync_file_range but the arguments are reordered */ -#if TARGET_ABI_BITS == 32 - ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), - target_offset64(arg5, arg6), arg2)); -#else - ret = get_errno(sync_file_range(arg1, arg3, arg4, arg2)); -#endif - return ret; -#endif -#endif #if defined(TARGET_NR_signalfd4) case TARGET_NR_signalfd4: return do_signalfd4(arg1, arg2, arg4); @@ -13341,6 +13355,9 @@ static impl_fn *syscall_table(unsigned num) # else SYSCALL_WITH(fadvise64_64, fadvise64); # endif +#endif +#ifdef CONFIG_FALLOCATE + SYSCALL(fallocate); #endif SYSCALL(fchdir); SYSCALL(fchmod); @@ -13841,6 +13858,14 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_SYNCFS SYSCALL(syncfs); #endif +#ifdef CONFIG_SYNC_FILE_RANGE +# ifdef TARGET_NR_sync_file_range + SYSCALL(sync_file_range); +# endif +# ifdef TARGET_NR_sync_file_range2 + SYSCALL(sync_file_range2); +# endif +#endif #ifdef TARGET_NR__sysctl SYSCALL(_sysctl); #endif From patchwork Sun Jun 10 03:02:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138180 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2618048lji; Sat, 9 Jun 2018 21:21:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTnmhiYMbXqm9SjbmIpAAefvT+pNnEXmfFGCXBM6LGFAbNkKhIT28Px4pxu4yjBv4KfYi8 X-Received: by 2002:ac8:7159:: with SMTP id h25-v6mr11789754qtp.41.1528604488683; Sat, 09 Jun 2018 21:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604488; cv=none; d=google.com; s=arc-20160816; b=zhBC0rjhgHbV5QbK8tKza37vm8V4GTLwi/RNrYnpZc5JxImg1SDeh3wYqu7yhRrrLw gPyi8Wgk9LqAtvSV3fcoLJFu37bqDmiznnVl14ac+IcSW8FaE+9Kh/f9oLZ6pGVXSEex E3Q3Np0r7eogneswze33p4F5AIRw++2LusgVL4kYw3VYbAbwPyhor+mMVijFA7aNaVtG JE7pIGf8qrh5PAvnqAc8+caCgK6ueeCOsenDyybBh6m91uaoRPBsWx1Ei2oNbdESDEDV aZvyuTVbKhVJIL3ic5yfKP9L0BmeZYz43NCaOl//G57SlHnwQ6bnaO4QLWGKsOjdt9KE /s2g== 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:arc-authentication-results; bh=9SHjCyudDplJJKhsvCL5EBrclmSvQ/P/jBgFLd2La54=; b=XtpYbz8Ww74dVe70ykKg63Kf4mFffLnXBqbfImNlBpEIiQYf6zlozns3A5fP0B/fSf mcqigqvUJzNOx34E0BXfr+EkSZBHA3bC2I06o+l3npE9F4uD3jCLl1GPY3Pn6i4V/Bk0 Z36c4AxD3F+TzkgGcj6BSHMp/D3yqH7FeFyG59oNtku8PPw+rXeKzlnYySS6ZWk9ENvw BHZJJg5gahuAiaZ54xJ/7VHy06H5dxdQ+Ypa3y6WQxMOnJQeftLXDzKgCNKAh1vYt268 J6LRl4hr+N6wfWEjYNnf5gqX2dx0uIOzX8eb+cAlYv7bc485lZR75KYsaGp9m38V01da lE1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O6M+WlOg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p50-v6si28711qtk.213.2018.06.09.21.21.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O6M+WlOg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrr6-0006Mx-7P for patch@linaro.org; Sun, 10 Jun 2018 00:21:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfv-0004ZS-27 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqft-0004js-Kd for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:51 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:46990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqft-0004jh-E8 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:49 -0400 Received: by mail-pf0-x244.google.com with SMTP id q1-v6so8483697pff.13 for ; Sat, 09 Jun 2018 20:05: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=9SHjCyudDplJJKhsvCL5EBrclmSvQ/P/jBgFLd2La54=; b=O6M+WlOg5xkW0XLqP1xRprGNWgWHNyxjexYugV+yySEQvGEMko+CvYQd3JAdbcwoh+ QGSdOHr75/M3ON79kb291Ti6GC5Nyv1eKQ3VEGEWTxsnzz2Gri2fyv/jc2eu0NWZHlS2 3rmLinMsSMThHyr8wmNeveFZplQcscsUV4xcQ= 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=9SHjCyudDplJJKhsvCL5EBrclmSvQ/P/jBgFLd2La54=; b=oVG/w6WhRfMDjpCbbWvIoKTHa/zhz2JVw+OYn+Yf0Adtpk6yr1E6/2qpEBnmxIXWSh pI2/MJaBILrm3T1W/2IX/T+sl12lnVO5B4s80A71ImSqZRsf/tvqw0rFoniNsXTIoH3y o1TmGrsNa9HUVHz4m8k4vxZCMFUUUmAXE3CeSVoV2DLev187OeU8ITMZm6YQKLm8IsuM eaMr+tgfoqbUSfjECwOxVz1WTzrUiSA1xsoSQVR/DfIlHyx1WN1Ci4cU4nv5tD6EteN6 2+Eo1bI/G7CE1WMXMieo9aQXlLIUrT19sTLshU3UIbQKWy6mHQGZWQbTqcADF0fod2ih l9gg== X-Gm-Message-State: APt69E0tPpQF1dErOS94g6EDMJQxhPCiz0b+xEigotTe75islFX9rdpN FCfpq5zWt9CgXnllYJ0LAlatBYYNZaU= X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr10426832pgp.221.1528599948291; Sat, 09 Jun 2018 20:05:48 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:11 -1000 Message-Id: <20180610030220.3777-100-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 099/108] linux-user: Split out signalfd, signalfd4 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 define signalfd4; remove the ifdefs. In do_signalfd4, unlock the target sigmask earlier and use is_error. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5edcb39b73..e630a43f97 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6975,8 +6975,6 @@ static abi_long host_to_target_statfs64(abi_ulong target_addr, } #endif -#if defined(TARGET_NR_signalfd) || defined(TARGET_NR_signalfd4) - /* signalfd siginfo conversion */ static void @@ -7045,21 +7043,17 @@ static abi_long do_signalfd4(int fd, abi_long mask, int flags) if (!lock_user_struct(VERIFY_READ, target_mask, mask, 1)) { return -TARGET_EFAULT; } - target_to_host_sigset(&host_mask, target_mask); + unlock_user_struct(target_mask, mask, 0); host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl); ret = get_errno(signalfd(fd, &host_mask, host_flags)); - if (ret >= 0) { + if (!is_error(ret)) { fd_trans_register(ret, &target_signalfd_trans); } - - unlock_user_struct(target_mask, mask, 0); - return ret; } -#endif /* Map host to target signal numbers for the wait family of syscalls. Assume all other status bits are the same. */ @@ -11884,6 +11878,18 @@ IMPL(sigaltstack) return do_sigaltstack(arg1, arg2, get_sp_from_cpustate(cpu_env)); } +#ifdef TARGET_NR_signalfd +IMPL(signalfd) +{ + return do_signalfd4(arg1, arg2, 0); +} +#endif + +IMPL(signalfd4) +{ + return do_signalfd4(arg1, arg2, arg4); +} + #ifdef TARGET_NR_sigpending IMPL(sigpending) { @@ -12850,14 +12856,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#if defined(TARGET_NR_signalfd4) - case TARGET_NR_signalfd4: - return do_signalfd4(arg1, arg2, arg4); -#endif -#if defined(TARGET_NR_signalfd) - case TARGET_NR_signalfd: - return do_signalfd4(arg1, arg2, 0); -#endif #if defined(CONFIG_EPOLL) #if defined(TARGET_NR_epoll_create) case TARGET_NR_epoll_create: @@ -13808,6 +13806,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(sigaction); #endif SYSCALL(sigaltstack); +#ifdef TARGET_NR_signalfd + SYSCALL(signalfd); +#endif + SYSCALL(signalfd4); #ifdef TARGET_NR_sigpending SYSCALL(sigpending); #endif From patchwork Sun Jun 10 03:02:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138177 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2616229lji; Sat, 9 Jun 2018 21:18:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLe2Fm7KDhkydVYsgSn0hbHCiLWA6ya7SqKnqokJ0MKeFU0YKUn7H+k45zvJpJyeiySu5bc X-Received: by 2002:ac8:3548:: with SMTP id z8-v6mr11149535qtb.161.1528604302382; Sat, 09 Jun 2018 21:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604302; cv=none; d=google.com; s=arc-20160816; b=GW0BGMcDBhhFiXnr+lca3JLP56l+6bClhvFDF+AZ/tR4gjpmWgB4XcrIpcUBMzl7nn D+rWRHiPK5vkFlE5bQSWAdvRFVDs2bv7/sezmYEvVXmfpHxtLwxU259bf4vbuq6toIOh dLDDjYuk35cWC+J3xsSfL9bECTOEW+ZkMkNbOSz/4ePSR25JSA51ePlyZy0L0P+69vA8 wfizOiDJWqJYQgNqRADjUmFYvOMZamt8HYez+pggqlNm0/eS/Xno+GgB3aYuOdXzwCd9 y0jbHafiW3vHdVkNcMnSoQRP/IxxESzSnt6QSq+xTB9eZh4Dz8wZMIzIlMmXv0uQO4Rt DV6w== 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:arc-authentication-results; bh=CII5PWAJCoKDXZtRNhlraOIcAUh9jlthYVTcnyEYQws=; b=wirqG1HInZI3farx17zYF1+rzTApkIMLGS4Q18zybKXEvqUuURpDCyqKHEXH2iTuI2 M7BFroHPR5QODfCvgCtr7BgW/Qz7EBW/OeNuFm1HwWAEyp03tpR7qjoe0wkucV0WRdn6 2nTuH9oLqMr1nxygnfmNDm/1rJ2RmFYfcxVGxvk3rN5XsiPFelG9ETZoxKepXckjPMWH GChkg1UazBxTww6MOR5jxOFEo/wtIkFFfMAGujQgpHfg5mZuhAKTB5WjMVOBL3zSHSbW aUU0Sca6B8/P9CbWf4Am0hBcN+gnrbNT9H+VbTUkdj8V8SyswPYVJ7jKXX+fslnTbUPV +34A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RFHvoowx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t74-v6si1286008qkl.41.2018.06.09.21.18.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:18:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RFHvoowx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRro5-0003jQ-S8 for patch@linaro.org; Sun, 10 Jun 2018 00:18:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfw-0004b2-HI for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfv-0004kU-Ax for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:52 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:33749) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfv-0004k3-2B for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:51 -0400 Received: by mail-pl0-x243.google.com with SMTP id n10-v6so10392412plp.0 for ; Sat, 09 Jun 2018 20:05: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=CII5PWAJCoKDXZtRNhlraOIcAUh9jlthYVTcnyEYQws=; b=RFHvoowxr7P9LqNNq53yWWIxv4Ty2nABCQZKQDuG9bbZ0UHvQIEzOsls2wpVTD9FWh 6S2EPxPiFsKAkk3YH92t0NIvmklkjHYe9ud8tOJonWjB/Y5I8BiYKridf8z1cHQnfvAe EL6DNFPIsQgrFFBbj0dmign5wYvz2fQZNZuGo= 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=CII5PWAJCoKDXZtRNhlraOIcAUh9jlthYVTcnyEYQws=; b=O8l+GTTMJe44lhyrQ7y4+G1sD7wd/mdwfGncEoOEX2ML5jbIyYzl8MQAkwJMVmuKgW 9FBd5V4DZOuLBQ0gXssgKvb1GLFC7e/WLfGXRUDmGIVWfYcjhvQ90A7K5/3OIovXSM7w uBtcsKquWXkKpwCu6AGqg2SzmHVVHrOrDA+8AjHEN1ePBRq1PzYha6FqDuw10xews+jl GwJJrDRi6wt66RU/Bm6qTSrBX8ncEEV4RyiiwIOw3RU5tS5qlroBvUvzjWEpGI7Sw0nx t8NGOcD/IbtRVwas9/QRgrAtaKcizTSmSYwVXB18r5iw6Ti9wcnKijzVmW/EbGhWxD7s o1yw== X-Gm-Message-State: APt69E0LbCV8Abo1j/UREBIz3yu6nYJdVOpdXxvvNyAb1yCLcwiUpYqG 6OUzMCyjqhDf2GE4ZTUnwYgVReztMY4= X-Received: by 2002:a17:902:1029:: with SMTP id b38-v6mr12795421pla.277.1528599949896; Sat, 09 Jun 2018 20:05:49 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:12 -1000 Message-Id: <20180610030220.3777-101-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 100/108] linux-user: Split out epoll 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 epoll_create, epoll_create1, epoll_ctl, epoll_pwait, epoll_wait. All targets define epoll_create1, epoll_ctl, epoll_pwait; remove those ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 244 +++++++++++++++++++++++-------------------- 1 file changed, 128 insertions(+), 116 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e630a43f97..9ce37c1119 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7897,6 +7897,123 @@ IMPL(dup3) return ret; } +#ifdef CONFIG_EPOLL +# ifdef TARGET_NR_epoll_create +IMPL(epoll_create) +{ + return get_errno(epoll_create(arg1)); +} +# endif + +IMPL(epoll_create1) +{ +# ifdef CONFIG_EPOLL_CREATE1 + return get_errno(epoll_create1(arg1)); +# else + /* If flags are 0, we can emulate with epoll_create. + * The size argument is ignored after linux 2.6.8, + * other than verifying that it is positive. + */ + if (arg1 == 0) { + return get_errno(epoll_create(1)); + } + return -TARGET_ENOSYS; +# endif +} + +IMPL(epoll_ctl) +{ + struct epoll_event ep; + struct epoll_event *epp = 0; + + if (arg4) { + struct target_epoll_event *target_ep; + if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { + return -TARGET_EFAULT; + } + ep.events = tswap32(target_ep->events); + /* The epoll_data_t union is just opaque data to the kernel, + * so we transfer all 64 bits across and need not worry what + * actual data type it is. + */ + ep.data.u64 = tswap64(target_ep->data.u64); + unlock_user_struct(target_ep, arg4, 0); + epp = &ep; + } + return get_errno(epoll_ctl(arg1, arg2, arg3, epp)); +} + +IMPL(epoll_pwait_wait) +{ + struct target_epoll_event *target_ep; + struct epoll_event *ep; + int epfd = arg1; + int maxevents = arg3; + int timeout = arg4; + abi_long ret; + + if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) { + return -TARGET_EINVAL; + } + + target_ep = lock_user(VERIFY_WRITE, arg2, + maxevents * sizeof(struct target_epoll_event), 1); + if (!target_ep) { + return -TARGET_EFAULT; + } + + ep = g_try_new(struct epoll_event, maxevents); + if (!ep) { + unlock_user(target_ep, arg2, 0); + return -TARGET_ENOMEM; + } + + switch (num) { + default: /* TARGET_NR_epoll_pwait */ + if (arg5) { + target_sigset_t *target_set; + sigset_t set; + + if (arg6 != sizeof(target_sigset_t)) { + ret = -TARGET_EINVAL; + break; + } + target_set = lock_user(VERIFY_READ, arg5, + sizeof(target_sigset_t), 1); + if (!target_set) { + ret = -TARGET_EFAULT; + break; + } + target_to_host_sigset(&set, target_set); + unlock_user(target_set, arg5, 0); + + ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout, + &set, SIGSET_T_SIZE)); + break; + } + /* fallthru */ +# ifdef TARGET_NR_epoll_wait + case TARGET_NR_epoll_wait: +# endif + ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, + timeout, NULL, 0)); + break; + } + if (!is_error(ret)) { + int i; + for (i = 0; i < ret; i++) { + target_ep[i].events = tswap32(ep[i].events); + target_ep[i].data.u64 = tswap64(ep[i].data.u64); + } + unlock_user(target_ep, arg2, ret * sizeof(struct target_epoll_event)); + } else { + unlock_user(target_ep, arg2, 0); + } + g_free(ep); + return ret; +} +#endif /* CONFIG_EPOLL */ + #ifdef CONFIG_EVENTFD # ifdef TARGET_NR_eventfd IMPL(eventfd) @@ -12856,122 +12973,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#if defined(CONFIG_EPOLL) -#if defined(TARGET_NR_epoll_create) - case TARGET_NR_epoll_create: - return get_errno(epoll_create(arg1)); -#endif -#if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1) - case TARGET_NR_epoll_create1: - return get_errno(epoll_create1(arg1)); -#endif -#if defined(TARGET_NR_epoll_ctl) - case TARGET_NR_epoll_ctl: - { - struct epoll_event ep; - struct epoll_event *epp = 0; - if (arg4) { - struct target_epoll_event *target_ep; - if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) { - return -TARGET_EFAULT; - } - ep.events = tswap32(target_ep->events); - /* The epoll_data_t union is just opaque data to the kernel, - * so we transfer all 64 bits across and need not worry what - * actual data type it is. - */ - ep.data.u64 = tswap64(target_ep->data.u64); - unlock_user_struct(target_ep, arg4, 0); - epp = &ep; - } - return get_errno(epoll_ctl(arg1, arg2, arg3, epp)); - } -#endif - -#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait) -#if defined(TARGET_NR_epoll_wait) - case TARGET_NR_epoll_wait: -#endif -#if defined(TARGET_NR_epoll_pwait) - case TARGET_NR_epoll_pwait: -#endif - { - struct target_epoll_event *target_ep; - struct epoll_event *ep; - int epfd = arg1; - int maxevents = arg3; - int timeout = arg4; - - if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) { - return -TARGET_EINVAL; - } - - target_ep = lock_user(VERIFY_WRITE, arg2, - maxevents * sizeof(struct target_epoll_event), 1); - if (!target_ep) { - return -TARGET_EFAULT; - } - - ep = g_try_new(struct epoll_event, maxevents); - if (!ep) { - unlock_user(target_ep, arg2, 0); - return -TARGET_ENOMEM; - } - - switch (num) { -#if defined(TARGET_NR_epoll_pwait) - case TARGET_NR_epoll_pwait: - { - target_sigset_t *target_set; - sigset_t _set, *set = &_set; - - if (arg5) { - if (arg6 != sizeof(target_sigset_t)) { - ret = -TARGET_EINVAL; - break; - } - - target_set = lock_user(VERIFY_READ, arg5, - sizeof(target_sigset_t), 1); - if (!target_set) { - ret = -TARGET_EFAULT; - break; - } - target_to_host_sigset(set, target_set); - unlock_user(target_set, arg5, 0); - } else { - set = NULL; - } - - ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout, - set, SIGSET_T_SIZE)); - } -#endif -#if defined(TARGET_NR_epoll_wait) - case TARGET_NR_epoll_wait: - ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout, - NULL, 0)); - break; -#endif - default: - ret = -TARGET_ENOSYS; - } - if (!is_error(ret)) { - int i; - for (i = 0; i < ret; i++) { - target_ep[i].events = tswap32(ep[i].events); - target_ep[i].data.u64 = tswap64(ep[i].data.u64); - } - unlock_user(target_ep, arg2, - ret * sizeof(struct target_epoll_event)); - } else { - unlock_user(target_ep, arg2, 0); - } - g_free(ep); - return ret; - } -#endif -#endif #ifdef TARGET_NR_prlimit64 case TARGET_NR_prlimit64: { @@ -13330,6 +13331,17 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(dup2); #endif SYSCALL(dup3); +#ifdef CONFIG_EPOLL +# ifdef TARGET_NR_epoll_create + SYSCALL(epoll_create); +# endif + SYSCALL(epoll_create1); + SYSCALL(epoll_ctl); + SYSCALL_WITH(epoll_pwait, epoll_pwait_wait); +# ifdef TARGET_NR_epoll_wait + SYSCALL_WITH(epoll_wait, epoll_pwait_wait); +# endif +#endif #ifdef CONFIG_EVENTFD # ifdef TARGET_NR_eventfd SYSCALL(eventfd); From patchwork Sun Jun 10 03:02:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138160 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2607391lji; Sat, 9 Jun 2018 21:03:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJX2VPNqjzHCJCstSWKamUknVkHvYsppqXOEDXY7C8khoNTXU6370YfSUPTO6wQNf+5jEQB X-Received: by 2002:a37:4249:: with SMTP id p70-v6mr10156994qka.297.1528603413126; Sat, 09 Jun 2018 21:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603413; cv=none; d=google.com; s=arc-20160816; b=KVbnIZwy8u5aJBsiWGAOVHnSm5itTXujwBAI+Egtyd9CNFAMSbNEvFaaCf0hDoApfS fUHtvXZpWmGBv3gp6xsNYhZH3x264OreId1hePEC6qGT1TSTJPqzocjpL7Xq6dXpN5yP PT4duoih7sG4lU7edU4bMsAuGFyu4I2qVJWhaKl0acnoYvpYlcXerukmVYAiG0gLSw9D 3HXfFWxa/toWpAR61Zs1Lu0BRm+Aair++pKinK09z07eDiYeXRGDS9sw4IWvv4Wc8szA O2K4Eb8XSfpUEQ5Hy63Qfh2qq4hOXizuXmgIL2wBiZLTjgDfuMQ3RnfxzhRUhUqMtn+9 IQ8Q== 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:arc-authentication-results; bh=WZNUfXoRoL9vKNtJeGiznUyoX3XtiiI2rLnPIeY6Qo8=; b=IUJKeC73Spa1lN/epRmKN+9XmEgScHL6NVdtOacmb4RHnzCaFGFdzQOAf7tNw/tkYQ lRzTGNJvaty1JnL9jBELK9vHlGwi5I9lGpGPl7UJBAe3dSL4f/80MWuA8TFtFh2AB3Uk tvd8DFz+yK51y4GuhOnigojzyzBuXlW2WiB8iyvdrp06yNVuSGvFpEfbn/MAW4WWMvDd jRtsqzg7Dvykrvg+T2HbAqorpbIjPG/xev0HfQDNgRO3hYXoK96go59YJ47OGT1dSXoi hKyyos19oB5Gp5S3X+krzkYRYM4qJnE19ULvTALOhxW/vlQtbCwQLZA6EZXyrfifPk05 Vt4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kG1RL1CB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k11-v6si24591682qvo.167.2018.06.09.21.03.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kG1RL1CB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZk-00074h-KP for patch@linaro.org; Sun, 10 Jun 2018 00:03:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfy-0004cn-4i for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfx-0004l1-3I for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:54 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:35912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfw-0004kj-Sl for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:53 -0400 Received: by mail-pl0-x243.google.com with SMTP id a7-v6so7900703plp.3 for ; Sat, 09 Jun 2018 20:05: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=WZNUfXoRoL9vKNtJeGiznUyoX3XtiiI2rLnPIeY6Qo8=; b=kG1RL1CBjlqdd+zDtlFmgHXD1O47onu7kuoQ0BYm6fpd5K4wXhFR28XmdVLXThCnWV weIQq/jmCF+N8xUXYR2H6qEcrTDHKeirpOqUQuiFIMRb/0igkmsgXahMFkJ0NdamL/Rv G2MEWHaga68pNKkJcve2Lk72PC5XTMZnAPUBA= 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=WZNUfXoRoL9vKNtJeGiznUyoX3XtiiI2rLnPIeY6Qo8=; b=bmT0bP/brdTygFM/5PK1ZAOlGtINju8msZ2yD/Bz60Mr6w9YJiQohOWCpOkPDmFODd 9+meLggDkSgorsOdLmTF6AikkQV2YeylIfZYMC/xWkLIAID6tM5ZLdr2gXTxc6PjRjRF J5Gb8Ahw6Ep/0DHY/t9JLcMfrvoo0Vb6qabKcvDFGD3MkZr1Qb8MWD10GF/jalOP/R+v sOCOetNdrtmqUievEbHkrT9zvSYvaZryKqcTvKY41/Ogqe+2LvBWaoJQ5O2ExqqcG6tj S22tkA1Cj17ONINoSRQy2A0ZQJtVvXKDsnyF1qFmbLqpyNVUvO1R0w2lzK7SkF39MLqk 4kKQ== X-Gm-Message-State: APt69E26MxB/pYwEd1yn31NTxoxoAa55cN9JrhnfL2PSCEqylBTuVKE5 JH2vIwXHX9i+EzftrNW7HKcdw/75Ad4= X-Received: by 2002:a17:902:7604:: with SMTP id k4-v6mr12747799pll.13.1528599951773; Sat, 09 Jun 2018 20:05:51 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:13 -1000 Message-Id: <20180610030220.3777-102-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v2 101/108] linux-user: Split out prlimit64 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 define prlimit64; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 65 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 32 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9ce37c1119..91d90c7417 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -627,7 +627,6 @@ static int sys_renameat2(int oldfd, const char *old, } #endif -#if defined(TARGET_NR_prlimit64) #ifndef __NR_prlimit64 # define __NR_prlimit64 -1 #endif @@ -640,8 +639,6 @@ struct host_rlimit64 { _syscall4(int, sys_prlimit64, pid_t, pid, int, resource, const struct host_rlimit64 *, new_limit, struct host_rlimit64 *, old_limit) -#endif - #if defined(TARGET_NR_timer_create) /* Maxiumum of 32 active POSIX timers allowed at any one time. */ @@ -10713,6 +10710,38 @@ IMPL(preadv) return ret; } +IMPL(prlimit64) +{ + /* args: pid, resource number, ptr to new rlimit, ptr to old rlimit */ + struct host_rlimit64 rnew, rold; + int resource = target_to_host_resource(arg2); + abi_long ret; + + if (arg3) { + struct target_rlimit64 *target_rnew; + if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { + return -TARGET_EFAULT; + } + rnew.rlim_cur = tswap64(target_rnew->rlim_cur); + rnew.rlim_max = tswap64(target_rnew->rlim_max); + unlock_user_struct(target_rnew, arg3, 0); + } + + ret = get_errno(sys_prlimit64(arg1, resource, arg3 ? &rnew : NULL, + arg4 ? &rold : NULL)); + + if (!is_error(ret) && arg4) { + struct target_rlimit64 *target_rold; + if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { + return -TARGET_EFAULT; + } + target_rold->rlim_cur = tswap64(rold.rlim_cur); + target_rold->rlim_max = tswap64(rold.rlim_max); + unlock_user_struct(target_rold, arg4, 1); + } + return ret; +} + IMPL(pselect6) { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; @@ -12973,35 +13002,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef TARGET_NR_prlimit64 - case TARGET_NR_prlimit64: - { - /* args: pid, resource number, ptr to new rlimit, ptr to old rlimit */ - struct target_rlimit64 *target_rnew, *target_rold; - struct host_rlimit64 rnew, rold, *rnewp = 0; - int resource = target_to_host_resource(arg2); - if (arg3) { - if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { - return -TARGET_EFAULT; - } - rnew.rlim_cur = tswap64(target_rnew->rlim_cur); - rnew.rlim_max = tswap64(target_rnew->rlim_max); - unlock_user_struct(target_rnew, arg3, 0); - rnewp = &rnew; - } - - ret = get_errno(sys_prlimit64(arg1, resource, rnewp, arg4 ? &rold : 0)); - if (!is_error(ret) && arg4) { - if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { - return -TARGET_EFAULT; - } - target_rold->rlim_cur = tswap64(rold.rlim_cur); - target_rold->rlim_max = tswap64(rold.rlim_max); - unlock_user_struct(target_rold, arg4, 1); - } - return ret; - } -#endif #ifdef TARGET_NR_gethostname case TARGET_NR_gethostname: { @@ -13650,6 +13650,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(prctl); SYSCALL(pread64); SYSCALL(preadv); + SYSCALL(prlimit64); SYSCALL(pselect6); SYSCALL(pwrite64); SYSCALL(pwritev); From patchwork Sun Jun 10 03:02:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138164 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2609256lji; Sat, 9 Jun 2018 21:06:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIcfnsdeFfxJvD78pZusywXA6NkWAAKZle+V7h/ejqqVM67UrZilQDONiroVIRjqqjCRmk6 X-Received: by 2002:aed:24fa:: with SMTP id u55-v6mr11035933qtc.400.1528603582329; Sat, 09 Jun 2018 21:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603582; cv=none; d=google.com; s=arc-20160816; b=ftQKH5GdHnJxQYUxcWfZHCV5kbVeGp1RPXsnlG9ghMW0dbqvauZzBg34khoing2A8O soe9BStu/eKDaYBhPLy3Sh/E/IHOBs3MREeYWY2/Qy24shUwCE8/bJGeUzwkP2E3wNry R4ra0qQ58ilkhiec0PjE4HlnqRWYJ6WAdAAoA1keA2hSeQBF3pDlTVJPRHoYiYgSvyZ3 yIvC3ULbn6ROahzVoTg5msK3al+MtyJchuD7QuFAbdHtT7jC3oggSHvOAR2i8KvQLdYM cQNxMbeZ+9fulY5qNFiYviSKDH3rzPI47fBpMSxqaHiBr7fHNUy2N/QwbLxE50YvWfA0 7Syw== 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:arc-authentication-results; bh=jLLvyOyCR9sBDrjnbBlwTEKWtAmf/X2N+TUmW3BbCpw=; b=jASa+ScNNVeSDzSB12oLXN1zwzTquyu1t7eSCRrvOHBX/lZASQQmiM6I9Y0UlyyPHg Al/AN5zcbLjWm7A2bMUbgiVbihhNSRxEjJ1AbkPNSiIPlrIiks8wSph9P0VyweJhkOLp zgP0lJ1StL+p7KQJ9270LWn6MRolkhVIRV/55dlJ2i8+3jmZ6ZTknS6eB74VUHOnfBth yUuHPMa189hHnW/ug6TpG9AShJUGYF9mP1Wi2X9ja+L1+lrU3xFTFxz1/rpcnnKhgZEQ fW4BNwBtiF2QmFJamC7XGYgARvEWouzmXbIOcJlrDe9mFQdnsLhDUVXXUiqZ0s5JzDnR OhcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h17X9WjU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z46-v6si8101052qvg.249.2018.06.09.21.06.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h17X9WjU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrcT-000157-OI for patch@linaro.org; Sun, 10 Jun 2018 00:06:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfz-0004eh-RP for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfy-0004mh-Qr for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:55 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:41590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfy-0004ln-KX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:54 -0400 Received: by mail-pl0-x242.google.com with SMTP id az12-v6so10381429plb.8 for ; Sat, 09 Jun 2018 20:05: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=jLLvyOyCR9sBDrjnbBlwTEKWtAmf/X2N+TUmW3BbCpw=; b=h17X9WjUghIqpdISGSsrdPG1AKvOUU788vZfLTOZULr7a2bWlZpbOnU5/7NNFlHGEW 0ACddkpMo7bssuFPMl9qSEAjqHyvBVstFijC28ccIH57SJHTB0Nwqd0usvyRjsRXO+K5 /CK2wHEM+NYizTzjlwbp0d0Vtb/bM/kcUJlic= 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=jLLvyOyCR9sBDrjnbBlwTEKWtAmf/X2N+TUmW3BbCpw=; b=dDrvXuiLm/doKLlBoAj+t0L9yIol/iJ/uYl42QCq9sV2UUPsRN9Yiq3GhBhD0cR+DD EG/npfjERluZY6vVeLmC/Qp1RYdcJL7kDclYKDJYRVncIYurtea9SEZmA2r08GVTcR1f jmTWrgkI+OuK9TuqASpjwGDEM4S51h1nrO/THqkbats4yJuCuNVFQK3S7GQMuRpT9Df7 aCjju6LbAO0eQCpmm2CdTC6z+EqfqYU555veMGc+cnRNnnb8MazkkX/QQZqcE1MCM89T B9gPAVSliDGYqZilys2uSK0iskO7qNCifqxRuyi4Zcyg5ieKCz6HTri2PAwG7lP3A+GQ dHdw== X-Gm-Message-State: APt69E1G3GDXx1hJbnd3cqjTQBRFMaylvBu9aYRglmvfU+dsEuGkUF6Y 6k9JogPn0N1paAodK2oKMYgKgBDQ7NE= X-Received: by 2002:a17:902:3303:: with SMTP id a3-v6mr12939985plc.209.1528599953514; Sat, 09 Jun 2018 20:05:53 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:14 -1000 Message-Id: <20180610030220.3777-103-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 102/108] linux-user: Split out atomic_barrier, gethostname 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 | 49 ++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 91d90c7417..f898e70e98 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7552,6 +7552,14 @@ IMPL(arch_prctl) } #endif +#ifdef TARGET_NR_atomic_barrier +IMPL(atomic_barrier) +{ + /* Like the kernel implementation and the qemu arm barrier, no-op this. */ + return 0; +} +#endif + #ifdef TARGET_NR_bind IMPL(bind) { @@ -8987,6 +8995,21 @@ IMPL(getgroups32) } #endif +#ifdef TARGET_NR_gethostname +IMPL(gethostname) +{ + char *name = lock_user(VERIFY_WRITE, arg1, arg2, 0); + abi_long ret; + + if (!name) { + ret = -TARGET_EFAULT; + } + ret = get_errno(gethostname(name, arg2)); + unlock_user(name, arg1, arg2); + return ret; +} +#endif + IMPL(getitimer) { struct itimerval value; @@ -13002,19 +13025,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#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: { @@ -13036,13 +13046,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, return mem_value; } #endif -#ifdef TARGET_NR_atomic_barrier - case TARGET_NR_atomic_barrier: - /* Like the kernel implementation and the - qemu arm barrier, no-op this? */ - return 0; -#endif - #ifdef TARGET_NR_timer_create case TARGET_NR_timer_create: { @@ -13293,6 +13296,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_bind SYSCALL(bind); +#endif +#ifdef TARGET_NR_atomic_barrier + SYSCALL(atomic_barrier); #endif SYSCALL(brk); #ifdef TARGET_NR_cacheflush @@ -13448,6 +13454,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getgroups); #ifdef TARGET_NR_getgroups32 SYSCALL(getgroups32); +#endif +#ifdef TARGET_NR_gethostname + SYSCALL(gethostname); #endif SYSCALL(getitimer); #ifdef TARGET_NR_getpagesize From patchwork Sun Jun 10 03:02:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138171 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2612825lji; Sat, 9 Jun 2018 21:12:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdSuXNHKfloDV32y+qiVGI0PMvRAZRBCLRdGMP27qcLC9BCg8mf96ayJtLsR2uxm1B98FG X-Received: by 2002:ac8:3661:: with SMTP id n30-v6mr11935414qtb.1.1528603952363; Sat, 09 Jun 2018 21:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603952; cv=none; d=google.com; s=arc-20160816; b=e3+jtJAwS75wtfzhm8fvp1/cqUIN5My/wYW+hx2LRpAt8DepK4k8MQx1dgqkbWuGFb Bydu73GY9325UEBYrCLImmkZmmMHVxhVy3TWXfJyM2nmmfnYVZg2hSeNxYmsUP5z01LO gxSgZHRKyhMTJlqI3PS7LieDRd9PQ5Jx4MhWQ3MwHHlIpGvDOXKp/fkMr/ocnnnSAK1c 7Cb3FC0uHZ5UppgO4pEfG06WgUKr+Jpz1qR0eEXA2xLktDLsBE0F83YEXhUmdiOcLUqf vbRjkvcLIyDCYYt4rLVp0h2Zr2biD5NaGG4I69jgYE5chldWORGbSvTnay3yifygl3WR 1uuw== 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:arc-authentication-results; bh=Lfa2pn83aPZbc52/Wivj+feIFqE3KUpBhvVF4IQuv4Q=; b=od53ZOY5Ovv9W27wCnUy00/73nvY7+wHoWSajc40sNb4SZBTQHpg80lGgDpbJSuws2 OPCyQuuIrixugPfwkEasVmUkARC6J9GUbtYLmJMlHqUo6f+/ylt/77q+JQqjbDHPMOq1 c1Pa/SIg7aUWwJJU+k3k25ZgJlQn3oeZHkcqwrC+fDDFgqjoz+SP6YXKM+xaj8JjEsCN be+6o7AO6TkMk5sz8ZAhdW79pvUSTNNqbBY+uSLueSbh5MMGvYCY2WFJ4COxCm9EvW82 KB+D4eksHOEcZav6JYEbPk2Bd6qgG0vjl7SeYwCYQtP6NixMuiRqsPcx1bhRQE8unfjN eRCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Mld8gU4+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w42-v6si233661qtc.68.2018.06.09.21.12.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:12:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Mld8gU4+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRriR-0006Yk-NU for patch@linaro.org; Sun, 10 Jun 2018 00:12:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg4-0004j4-3R for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqg0-0004oL-UM for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:00 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:38805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqg0-0004o4-Nw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:56 -0400 Received: by mail-pl0-x242.google.com with SMTP id b14-v6so10402273pls.5 for ; Sat, 09 Jun 2018 20:05: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=Lfa2pn83aPZbc52/Wivj+feIFqE3KUpBhvVF4IQuv4Q=; b=Mld8gU4+KSoNv8CdiXtrrUPovmKUxAAXhWoR9eqgX1r+yxUAtq2MFOcGr9Bx+H6i2X 692V9yTSXtXEN6XyQcqRlKJ3yv/Voxr6GQpTqfGAF9lkWK6t5+L65fWxnRi2Z4LfpbIb OQz+KPEVME/Pndh+6xAYo2kUBMSzLZiSt2MqE= 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=Lfa2pn83aPZbc52/Wivj+feIFqE3KUpBhvVF4IQuv4Q=; b=J1FD8ODq6MjNSF5pkudmH0jjscS261cdK9yErhQrzZNXW4PNmhyudPeAoniLMg1oBr MO9MVd1RADyPM6l9lUpmF5tAUlo0H3/N6mgR8cdhR2dJQYB5M9kfbshpCuY/mFz7q593 9YJYL/Z+F34f2OrlhuuriJrjKcTrDI+W5rWZjkyf58Pcl0MCTlmqgmHeP/pbqlV2uIgC WNgV3zvyZw28fhk9Kfkqck/boQaPWfUIzceRebvft8YvDVuUYOcE6aHmkgB7gicSur8r Xwec7enjGX8t5f94HM1w+ai9thWwv9ECMTYJN1k2k7VEMB00dkWWLJ/TTgPYVVrR6KVV f6gQ== X-Gm-Message-State: APt69E3MPWEs119BqIGfa5qsLLTaTWpI1oX3F1EaIQryWgRs2ioGf8Uz oFtP/8sODzcwIlsquYJG541PEDNzBXc= X-Received: by 2002:a17:902:aa01:: with SMTP id be1-v6mr12816038plb.296.1528599955660; Sat, 09 Jun 2018 20:05:55 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:15 -1000 Message-Id: <20180610030220.3777-104-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 103/108] linux-user: Split out atomic_cmpxchg_32 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" At the same time, make it atomic. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 47 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f898e70e98..5d60872587 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7560,6 +7560,29 @@ IMPL(atomic_barrier) } #endif +#ifdef TARGET_NR_atomic_cmpxchg_32 +IMPL(atomic_cmpxchg_32) +{ + /* This is m68k specific. */ + uint32_t newval = arg1; + uint32_t oldval = arg2; + abi_ulong target_addr = arg6; + uint32_t *host_addr; + + if (!access_ok(VERIFY_WRITE, target_addr, 4)) { + target_siginfo_t info; + info.si_signo = SIGSEGV; + info.si_errno = 0; + info.si_code = TARGET_SEGV_MAPERR; + info._sifields._sigfault._addr = target_addr; + queue_signal(cpu_env, info.si_signo, QEMU_SI_FAULT, &info); + return 0xdeadbeef; + } + host_addr = g2h(target_addr); + return atomic_cmpxchg(host_addr, oldval, newval); +} +#endif + #ifdef TARGET_NR_bind IMPL(bind) { @@ -13025,27 +13048,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef TARGET_NR_atomic_cmpxchg_32 - case TARGET_NR_atomic_cmpxchg_32: - { - /* should use start_exclusive from main.c */ - abi_ulong mem_value; - if (get_user_u32(mem_value, arg6)) { - target_siginfo_t info; - info.si_signo = SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = arg6; - queue_signal((CPUArchState *)cpu_env, info.si_signo, - QEMU_SI_FAULT, &info); - ret = 0xdeadbeef; - - } - if (mem_value == arg2) - put_user_u32(arg1, arg6); - return mem_value; - } -#endif #ifdef TARGET_NR_timer_create case TARGET_NR_timer_create: { @@ -13299,6 +13301,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_atomic_barrier SYSCALL(atomic_barrier); +#endif +#ifdef TARGET_NR_atomic_cmpxchg_32 + SYSCALL(atomic_cmpxchg_32); #endif SYSCALL(brk); #ifdef TARGET_NR_cacheflush From patchwork Sun Jun 10 03:02:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138181 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2618746lji; Sat, 9 Jun 2018 21:22:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI0uzfxGDAJh22bBpTqZIVlddLfSWQSlOVs0UWyA5N3lYieg0ZOxgOinxgqO17Nw6CXOFgx X-Received: by 2002:a0c:b665:: with SMTP id q37-v6mr11005603qvf.43.1528604557458; Sat, 09 Jun 2018 21:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604557; cv=none; d=google.com; s=arc-20160816; b=cHQpwQRd0xNWvayeHHadVECr4Hfyf7CCV+Kl8BL3kjb7109JfmqVkvbEGC282TSB2y 6ujRpleP2m25whb/9tRtrAgCTd2JEwIW63+Y6HA4M+TD1MprKj3BW1lEzZ5nq9+3qhXu PdzEzi6O86JL3fvhX10F4L/LKz/r7o1DtrZa7Y+67spiPdWxQT7WDs5NjK1LpaMdRUK5 yOQhLCPwIjJCZ0HBNX30/TqjNVg3utH9yYaqXcx2VM1Nwa4tHFMu0ry0AM7WcnRC6Wjg 77kpCncTp6pfsW+kQ3YDdl5bzk/hwzvEwMk9XvFzSj6vEJKIKgEDez8xjEDv/XG2X2dY w6bg== 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:arc-authentication-results; bh=7qCJP7ZHZAElHYDOl7dU420vTS9NMofEHdWiPaABl+E=; b=TEDZuorY9EpvrzNvHDqJklYbk0VgEbtFUFy0evvaU0lVvUCgRy09kwFR1HixNrO1cu 2193PsuI62hJehjMK9gF+O9LrXnjqSiMEYT1dqLSRwnTl2TneFhTSSzyO/AJYv+tPCuv aB3g/7JhMNH/b5kdewsh/3khgFVlEj1mXeg0/4eD8LdMM16lwSvTX4Gi2FD+taHM0h8K 6jgqWWDRuo4H5vUIszG9cZL/PiZmQinDe+ssJoIzyRzPgU45psFV8VSIDeXEXTxnRimg 0Hb2cFhjdXN38hf0gL/aiOjRKa5WdQ7NF1jicYWm2MmtCJvQwgzAcynyfdFDgryYl1Lb sJsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IU8yjdyt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v47-v6si4815295qtg.403.2018.06.09.21.22.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:22:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IU8yjdyt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrsC-0007OY-Vn for patch@linaro.org; Sun, 10 Jun 2018 00:22:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg4-0004jk-Ni for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqg3-0004pV-8L for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:00 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqg3-0004pD-0K for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:59 -0400 Received: by mail-pg0-x241.google.com with SMTP id p21-v6so8128974pgd.11 for ; Sat, 09 Jun 2018 20:05: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=7qCJP7ZHZAElHYDOl7dU420vTS9NMofEHdWiPaABl+E=; b=IU8yjdytTUiFcNsfX7Af1c3BVgaQZt10cYojRT39hCPqhMLSIz2L2uTSfGZQAQsJmB m1cimEWTry1t0firGY36+Lm3ZbPuj+rCiyRolPHn3zXfwlQxxXDFl+YAjuDDMAHtY4ww mnub3kTsUYuicP2Nz1vnGNCzvzFufwtwVKF74= 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=7qCJP7ZHZAElHYDOl7dU420vTS9NMofEHdWiPaABl+E=; b=XxxnqqtUoiNHH+etE3zHq5HBfjOA4IkqzLRe5RSglK6P4zHqxfMPtgXl9sDa1wdGtr 6kNyywoVvk2p+c7SYsbsPHbTCzMizfud7ArqkV0tM2w/0Bli2FogE26XNvpAEnLHXALu F7IhBWjban6OC+P2NG/+7KSrn8f5/a1qFThKfJjnaXOWsBgFkG9rkfc3lzdrbfwyuEir 37s4HbVAQbYrWgHJiR1nG5iwkRg9HvkwYivEFu9VADtrBly33Kq0BMaR45iXVTP8uCGc TR9qVoBdNZiiAlEDHElh13UHKx9l4w7XcKUR/V2rS3HIBfuNJ+v79frVNcEWLFMUDjoz UQ5Q== X-Gm-Message-State: APt69E3w9sEn6K0OYucwvXr0K0t9lFpu6rzsrY7q3i3+/8+Jle9VYKl2 SAOnmJhjjYUbtZHPNaGLsvKwGh4Abgk= X-Received: by 2002:a63:2b15:: with SMTP id r21-v6mr10438248pgr.269.1528599957847; Sat, 09 Jun 2018 20:05:57 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:16 -1000 Message-Id: <20180610030220.3777-105-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 104/108] linux-user: Split out timer 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 timer_create, timer_delete, timer_getoverrun, timer_gettime, and timer_settime. All targets define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 234 ++++++++++++++++++++----------------------- 1 file changed, 111 insertions(+), 123 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5d60872587..0f12a945ea 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -640,7 +640,6 @@ _syscall4(int, sys_prlimit64, pid_t, pid, int, resource, const struct host_rlimit64 *, new_limit, struct host_rlimit64 *, old_limit) -#if defined(TARGET_NR_timer_create) /* Maxiumum of 32 active POSIX timers allowed at any one time. */ static timer_t g_posix_timers[32] = { 0, } ; @@ -656,7 +655,6 @@ static inline int next_free_host_timer(void) } return -1; } -#endif /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ #ifdef TARGET_ARM @@ -12685,6 +12683,112 @@ IMPL(times) return host_to_target_clock_t(ret); } +IMPL(timer_create) +{ + /* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */ + struct sigevent host_sevp, *phost_sevp = NULL; + int clkid = arg1; + int timer_index; + timer_t *phtimer; + abi_long ret; + + timer_index = next_free_host_timer(); + if (timer_index < 0) { + return -TARGET_EAGAIN; + } + + phtimer = g_posix_timers + timer_index; + if (arg2) { + phost_sevp = &host_sevp; + ret = target_to_host_sigevent(phost_sevp, arg2); + if (ret != 0) { + return ret; + } + } + + ret = get_errno(timer_create(clkid, phost_sevp, phtimer)); + if (!ret && put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { + /* ??? Leak timer. */ + return -TARGET_EFAULT; + } + return ret; +} + +IMPL(timer_delete) +{ + /* args: timer_t timerid */ + target_timer_t timerid = get_timer_id(arg1); + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_delete(htimer)); + g_posix_timers[timerid] = 0; + return ret; +} + +IMPL(timer_getoverrun) +{ + /* args: timer_t timerid */ + target_timer_t timerid = get_timer_id(arg1); + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_getoverrun(htimer)); + fd_trans_unregister(ret); + return ret; +} + +IMPL(timer_gettime) +{ + /* args: timer_t timerid, struct itimerspec *curr_value */ + target_timer_t timerid = get_timer_id(arg1); + struct itimerspec hspec; + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_gettime(htimer, &hspec)); + if (!ret && host_to_target_itimerspec(arg2, &hspec)) { + ret = -TARGET_EFAULT; + } + return ret; +} + +IMPL(timer_settime) +{ + /* args: timer_t timerid, int flags, const struct itimerspec *new_value, + * struct itimerspec * old_value + */ + struct itimerspec hspec_new, hspec_old; + target_timer_t timerid = get_timer_id(arg1); + timer_t htimer; + abi_long ret; + + if (timerid < 0) { + return timerid; + } + if (target_to_host_itimerspec(&hspec_new, arg3)) { + return -TARGET_EFAULT; + } + htimer = g_posix_timers[timerid]; + ret = get_errno(timer_settime(htimer, arg2, &hspec_new, &hspec_old)); + if (!ret && arg4 && host_to_target_itimerspec(arg4, &hspec_old)) { + return -TARGET_EFAULT; + } + return ret; +} + IMPL(tkill) { return get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2))); @@ -13048,127 +13152,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#ifdef TARGET_NR_timer_create - case TARGET_NR_timer_create: - { - /* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */ - - struct sigevent host_sevp = { {0}, }, *phost_sevp = NULL; - - int clkid = arg1; - int timer_index = next_free_host_timer(); - - if (timer_index < 0) { - ret = -TARGET_EAGAIN; - } else { - timer_t *phtimer = g_posix_timers + timer_index; - - if (arg2) { - phost_sevp = &host_sevp; - ret = target_to_host_sigevent(phost_sevp, arg2); - if (ret != 0) { - return ret; - } - } - - ret = get_errno(timer_create(clkid, phost_sevp, phtimer)); - if (ret) { - phtimer = NULL; - } else { - if (put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) { - return -TARGET_EFAULT; - } - } - } - return ret; - } -#endif - -#ifdef TARGET_NR_timer_settime - case TARGET_NR_timer_settime: - { - /* args: timer_t timerid, int flags, const struct itimerspec *new_value, - * struct itimerspec * old_value */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else if (arg3 == 0) { - ret = -TARGET_EINVAL; - } else { - timer_t htimer = g_posix_timers[timerid]; - struct itimerspec hspec_new = {{0},}, hspec_old = {{0},}; - - if (target_to_host_itimerspec(&hspec_new, arg3)) { - return -TARGET_EFAULT; - } - ret = get_errno( - timer_settime(htimer, arg2, &hspec_new, &hspec_old)); - if (arg4 && host_to_target_itimerspec(arg4, &hspec_old)) { - return -TARGET_EFAULT; - } - } - return ret; - } -#endif - -#ifdef TARGET_NR_timer_gettime - case TARGET_NR_timer_gettime: - { - /* args: timer_t timerid, struct itimerspec *curr_value */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else if (!arg2) { - ret = -TARGET_EFAULT; - } else { - timer_t htimer = g_posix_timers[timerid]; - struct itimerspec hspec; - ret = get_errno(timer_gettime(htimer, &hspec)); - - if (host_to_target_itimerspec(arg2, &hspec)) { - ret = -TARGET_EFAULT; - } - } - return ret; - } -#endif - -#ifdef TARGET_NR_timer_getoverrun - case TARGET_NR_timer_getoverrun: - { - /* args: timer_t timerid */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else { - timer_t htimer = g_posix_timers[timerid]; - ret = get_errno(timer_getoverrun(htimer)); - } - fd_trans_unregister(ret); - return ret; - } -#endif - -#ifdef TARGET_NR_timer_delete - case TARGET_NR_timer_delete: - { - /* args: timer_t timerid */ - target_timer_t timerid = get_timer_id(arg1); - - if (timerid < 0) { - ret = timerid; - } else { - timer_t htimer = g_posix_timers[timerid]; - ret = get_errno(timer_delete(htimer)); - g_posix_timers[timerid] = 0; - } - return ret; - } -#endif - #if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_create: return get_errno(timerfd_create(arg1, @@ -13908,6 +13891,11 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(time); #endif SYSCALL(times); + SYSCALL(timer_create); + SYSCALL(timer_delete); + SYSCALL(timer_getoverrun); + SYSCALL(timer_gettime); + SYSCALL(timer_settime); SYSCALL(tkill); SYSCALL(truncate); #ifdef TARGET_NR_truncate64 From patchwork Sun Jun 10 03:02:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138182 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2619396lji; Sat, 9 Jun 2018 21:23:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKzSCS9uNExQ85fysGS29NlYSTluq8OdStNBzf29gF7lHqIMZOrpN/g1ZCVMozn74jUTCj0 X-Received: by 2002:a0c:e20f:: with SMTP id q15-v6mr10915115qvl.113.1528604621216; Sat, 09 Jun 2018 21:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604621; cv=none; d=google.com; s=arc-20160816; b=ZqZ07wNhaXUG7UIBJQg4pBjlJFSWbY7/gL9WDdr4TcQe6rq+6v7FcmXROxk/I5PVfG L6P7o3sQdV1BNkGI5NcR7zWUu6Ca9/hvOMjUNMORnKvpcqOZxcBeWFF3nporIYJUWUAN nLzUDTOVXbuPCJPq/hRHGpD0ylPUPNgbfQoZYVgqBaKRi8h3DlHsh0L9vJ6hROAWXoX0 x7j+BuRix7DQsMXw0KLK1LUeFH+tG69bOqB+SZ0ISvP2DEB8BfY/pgiy3zPOQ0K6OdUn tIviX3/Lx1IPN0s1DJctMlKsalRze+UpbZVGVC1fx3GBEnpz36/IRAizyfnJIyH2lJA1 8r4A== 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:arc-authentication-results; bh=lfU3/wFm4RJSWBYR/F7HbmhVB0Jxo3PgQWuS4SjQ/yM=; b=rqtvIKB4QUWWzcB1BA4LvweMXFo8cTLiZOYPW36WWxr3RN+HfP+ftIg88kYG4juuvt 7NTBU1AZZ1sAp+4IJ7MxkybH0kAVjierr8Dd7ULc4zOa1XQ78UNfASIQMdLqN2FDS6RN rNPgQMHHTheshQgTNQp8NrxZ9SJRLbgYYKQgVFwA2+X3N3SvQjnOdn1mPkFbQKsVvBUS sf9WrFSMmcjDKpa1wtQ3KiovQGCJTjZ58Skp4tqLC1Wi9jXYvYrLX6yqC7xda1X6OabW nFaZxOcI2TxrcRNVUWik6jyCHFDjDPHPwv46vdf8bbJZhibvCfDjlb+h3SfQWadTnNh4 BaKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IPKvYD3e; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v67-v6si5927257qkb.138.2018.06.09.21.23.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IPKvYD3e; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrtE-00083K-OC for patch@linaro.org; Sun, 10 Jun 2018 00:23:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg6-0004lM-5R for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqg5-0004rJ-7i for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:02 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:41358) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqg5-0004r8-2E for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:01 -0400 Received: by mail-pg0-x244.google.com with SMTP id l65-v6so8133692pgl.8 for ; Sat, 09 Jun 2018 20:06: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=lfU3/wFm4RJSWBYR/F7HbmhVB0Jxo3PgQWuS4SjQ/yM=; b=IPKvYD3eO8r07DZdaRx6x8CaM3CmMvHLZRYcXsAsDxv8wXmtv4nT6GVqYxHz4gD8pp DBVDcaCAgMfd0WRTAsDIUSVkyDIUwx8BbYuPY5/X7ka5U7H1rZFcL3qZnsZbD6ZqBLHg aB/vzCE0V/uYeBREo7vy8SQQHwbJPFeOcJK64= 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=lfU3/wFm4RJSWBYR/F7HbmhVB0Jxo3PgQWuS4SjQ/yM=; b=sfzZYBt/1B3VJ9KrEUyCi5Aa0aoD5s41OPbn4VNhcQi5DHe+UoeQecI/ZGzqtTUM55 Yxz5RO5zsOY4OsM1AYKsDPLdv8Z3+JGI+kzL2DjLmkv+4AXLxRaRbDHMOy/qfXtMiy5a r2Jj3as6oAdczDw+ssqbYSZMXZBk7oalCMjczQxh/9raqG8lTokvvSdBH3Y7fxva9fyO 74IBUHQdlewhJnEt10T+XYk/8+zcwPvMb1BuOM7ZpT+SrkjP9x9bP3hx0XeOmd043o4I xn33mCLK5Ej1sHfqlWpJGtK6QEswtN0xhqMwY+BfIGqIpD4blJGhn82kcLc0/NeyIoPX Pgfw== X-Gm-Message-State: APt69E0DIKW1xIe9l0eL7LBm3qoji0YAFB2mPHoPeeBrfZpiUnYILfuH PKHFQQnrFld7n5HTi8ZNt4PSlgKpPLg= X-Received: by 2002:a63:721d:: with SMTP id n29-v6mr10172147pgc.194.1528599959972; Sat, 09 Jun 2018 20:05:59 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:17 -1000 Message-Id: <20180610030220.3777-106-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 105/108] linux-user: Split out timerfd 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 timerfd_create, timerfd_gettime, timerfd_settime. All targets define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 83 +++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 43 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0f12a945ea..c0752ad6e0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12789,6 +12789,41 @@ IMPL(timer_settime) return ret; } +#ifdef CONFIG_TIMERFD +IMPL(timerfd_create) +{ + int host_flags = target_to_host_bitmask(arg2, fcntl_flags_tbl); + return get_errno(timerfd_create(arg1, host_flags)); +} + +IMPL(timerfd_gettime) +{ + struct itimerspec its_curr; + abi_long ret; + + ret = get_errno(timerfd_gettime(arg1, &its_curr)); + if (!ret && host_to_target_itimerspec(arg2, &its_curr)) { + return -TARGET_EFAULT; + } + return ret; +} + +IMPL(timerfd_settime) +{ + struct itimerspec its_new, its_old; + abi_long ret; + + if (target_to_host_itimerspec(&its_new, arg3)) { + return -TARGET_EFAULT; + } + ret = get_errno(timerfd_settime(arg1, arg2, &its_new, &its_old)); + if (!ret && arg4 && host_to_target_itimerspec(arg4, &its_old)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif /* CONFIG_TIMERFD */ + IMPL(tkill) { return get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2))); @@ -13152,49 +13187,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD) - case TARGET_NR_timerfd_create: - return get_errno(timerfd_create(arg1, - target_to_host_bitmask(arg2, fcntl_flags_tbl))); -#endif - -#if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD) - case TARGET_NR_timerfd_gettime: - { - struct itimerspec its_curr; - - ret = get_errno(timerfd_gettime(arg1, &its_curr)); - - if (arg2 && host_to_target_itimerspec(arg2, &its_curr)) { - return -TARGET_EFAULT; - } - } - return ret; -#endif - -#if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD) - case TARGET_NR_timerfd_settime: - { - struct itimerspec its_new, its_old, *p_new; - - if (arg3) { - if (target_to_host_itimerspec(&its_new, arg3)) { - return -TARGET_EFAULT; - } - p_new = &its_new; - } else { - p_new = NULL; - } - - ret = get_errno(timerfd_settime(arg1, arg2, p_new, &its_old)); - - if (arg4 && host_to_target_itimerspec(arg4, &its_old)) { - return -TARGET_EFAULT; - } - } - return ret; -#endif - #if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get) case TARGET_NR_ioprio_get: return get_errno(ioprio_get(arg1, arg2)); @@ -13896,6 +13888,11 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(timer_getoverrun); SYSCALL(timer_gettime); SYSCALL(timer_settime); +#ifdef CONFIG_TIMERFD + SYSCALL(timerfd_create); + SYSCALL(timerfd_gettime); + SYSCALL(timerfd_settime); +#endif SYSCALL(tkill); SYSCALL(truncate); #ifdef TARGET_NR_truncate64 From patchwork Sun Jun 10 03:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138168 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2611398lji; Sat, 9 Jun 2018 21:10:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKJcJTLMR+u7Huag2dIPZov160tGrJkua5axm5nDMujvSGYA/UwunShKNN4ZSxHpcZUcPep X-Received: by 2002:a0c:bd0e:: with SMTP id m14-v6mr10934469qvg.164.1528603802826; Sat, 09 Jun 2018 21:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528603802; cv=none; d=google.com; s=arc-20160816; b=wK3LMwaeavGHNBERaTUAxsP1wpAws3ihXPrzZk7U9Ssum/9/NXEPSMuuvQVIwKjKN1 gqHZs2A9JslfGUAMj7FMkl5cdy3kPozPtQwkryozqbrIG0eWgvZC0z+y+sjC8fKVgDZQ /cR5nYZME7Rw1CV9hjZyA5SUKaYTehVBNsZtlXFrQhiAwWSdVkDI2pNc38HyndHpQp+3 B6C9sD7Gr1Mheqm+OxNT6nsCW+FtAgdv/OtArkE4ibOuXtj6yuh5dnPx+oDlyDL5u7Sj Dt7H8DNbU1OLOaPaiEBXXHANxCNngp61+zVSEOrBnc/FUWi2wffz5+1kCvV0EEf2NnjJ oY5w== 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:arc-authentication-results; bh=u9W96ZAXur1A2wkYUJubq/xHWKIANi4SOo8++E6F+fc=; b=DC9uYJB64U4EWLNFUTrTh+xwJ+e6jniUyRcpMOik+gzo6K7Oi45LP32pHzilOHta5x r92QMvInMDjcyxyhQgLc8EGQ1IU/jJxlxu7/oZ3cdVYGm3AmfkfDbjC+wQ3eJDRfhJQh Jt0es+CEQOeojPl65eEYuC+8fsct7+xFmZG9q2IM0OmGwECsMfI7FlHY8iuXp7RxpZbB EUrxfgWftIzG99ZtN1vR2riKn3islh6O3ZIIT7OpAIKrtL2z0FB0aRc2ihJpRPMlDXJe 3faaD/PlCoL5IZvRAhwAaxsq8LUucg5VyYOcIryathU+ZxheeyuVp+bWNcFZCVlfS5oG /0Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ATKJyc3M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b11-v6si1846055qtp.303.2018.06.09.21.10.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:10:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ATKJyc3M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrg2-0004MP-7o for patch@linaro.org; Sun, 10 Jun 2018 00:10:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg8-0004oq-1L for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqg7-0004sk-3X for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:04 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:32941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqg6-0004s2-T2 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:03 -0400 Received: by mail-pf0-x244.google.com with SMTP id b17-v6so8496140pfi.0 for ; Sat, 09 Jun 2018 20:06: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=u9W96ZAXur1A2wkYUJubq/xHWKIANi4SOo8++E6F+fc=; b=ATKJyc3MaWk5AltpcgUJEZAp8t/i/HhMNENIKPuYTvzxkBlCp9Q9vYvgeco0SFhZK8 DC6A6pFwPoii4zT3rlJy8yr+FRe5ojnPSPkIYcU9YmBIhyvs5LYWKwmEdtgB8yHA+W62 Kx3TC/m0bW6RaQRh0/FQ5R6xlU2UKb2d4uMYs= 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=u9W96ZAXur1A2wkYUJubq/xHWKIANi4SOo8++E6F+fc=; b=FxQXsXq4BlymUmwNJiolJUM7gcfBI7KseOE/iRFYq4xpgIF8AtKnjxmVB20HISyIZY 3y8RkOqbOiyLagr19l7F6mIalbPysPOpE+XBdglQdf9fe/QrddkfKUM99DVtmJ2gB+Q6 eM5uORJ6OxpLgxFkycx8tlZU9NdWGVFQIX/JtIlri2bWFFtSG4CyhbzSqZ8eTXXEDYgJ 2MSqx2+52M8WgC6hbJPh1okTRDUvesjkYVt5h8TjWBz4iD544nxv6N8pF6vv76ST9vsv 5KQoMrzqLgKKAL3+Ov86GRwJoYDN0jpZxrPTGvEtr7LGwpSSnnbvJHnta41QN5VAqke+ vt5A== X-Gm-Message-State: APt69E3zyU7h9HwRyiOAmWPcUiJfX2PfO4UMaIIAwSvXGno1aL1WTYrX oUZqdbTidMG+OqmqmpXpr3OWhj1XV3M= X-Received: by 2002:a63:6742:: with SMTP id b63-v6mr10427189pgc.54.1528599961751; Sat, 09 Jun 2018 20:06:01 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.06.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:06:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:18 -1000 Message-Id: <20180610030220.3777-107-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 106/108] linux-user: Split out ioprio_get, ioprio_set, kcmp 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 define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 49 ++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c0752ad6e0..d15f994039 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -250,6 +250,15 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #ifndef __NR_gettid #define __NR_gettid -1 #endif +#ifndef __NR_ioprio_get +#define __NR_ioprio_get -1 +#endif +#ifndef __NR_ioprio_set +#define __NR_ioprio_set -1 +#endif +#ifndef __NR_kcmp +#define __NR_kcmp -1 +#endif #ifndef __NR_set_tid_address #define __NR_set_tid_address -1 #endif @@ -296,18 +305,11 @@ _syscall2(int, capget, struct __user_cap_header_struct *, header, struct __user_cap_data_struct *, data); _syscall2(int, capset, struct __user_cap_header_struct *, header, struct __user_cap_data_struct *, data); -#if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get) _syscall2(int, ioprio_get, int, which, int, who) -#endif -#if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set) _syscall3(int, ioprio_set, int, which, int, who, int, ioprio) -#endif _syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags) - -#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 static bitmask_transtbl fcntl_flags_tbl[] = { { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, @@ -9474,6 +9476,16 @@ IMPL(ioctl) return ret; } +IMPL(ioprio_get) +{ + return get_errno(ioprio_get(arg1, arg2)); +} + +IMPL(ioprio_set) +{ + return get_errno(ioprio_set(arg1, arg2, arg3)); +} + #ifdef TARGET_NR_ipc IMPL(ipc) { @@ -9553,6 +9565,11 @@ IMPL(ipc) } #endif +IMPL(kcmp) +{ + return get_errno(kcmp(arg1, arg2, arg3, arg4, arg5)); +} + IMPL(kill) { return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); @@ -13187,16 +13204,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long ret; switch(num) { -#if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get) - case TARGET_NR_ioprio_get: - return get_errno(ioprio_get(arg1, arg2)); -#endif - -#if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set) - case TARGET_NR_ioprio_set: - return get_errno(ioprio_set(arg1, arg2, arg3)); -#endif - #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS) case TARGET_NR_setns: return get_errno(setns(arg1, arg2)); @@ -13205,11 +13212,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, case TARGET_NR_unshare: return get_errno(unshare(arg1)); #endif -#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp) - case TARGET_NR_kcmp: - return get_errno(kcmp(arg1, arg2, arg3, arg4, arg5)); -#endif - default: gemu_log("qemu: Unsupported syscall: %d\n", num); return -TARGET_ENOSYS; @@ -13510,9 +13512,12 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(inotify_rm_watch); #endif SYSCALL(ioctl); + SYSCALL(ioprio_get); + SYSCALL(ioprio_set); #ifdef TARGET_NR_ipc SYSCALL(ipc); #endif + SYSCALL(kcmp); SYSCALL(kill); #ifdef TARGET_NR_lchown SYSCALL(lchown); From patchwork Sun Jun 10 03:02:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138175 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2614394lji; Sat, 9 Jun 2018 21:15:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxulGKqjyO7J76jWZS0TvDrNuUu3yIWg5sQqTnIOX0kAd8hz8W986SgTsrKYxPV12bd0k+ X-Received: by 2002:ac8:19ca:: with SMTP id s10-v6mr11316397qtk.303.1528604112882; Sat, 09 Jun 2018 21:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604112; cv=none; d=google.com; s=arc-20160816; b=thSECNosUXmNUkJ5yuCc5kEuTIhau4PhAZMq3MYor/sIgzroHIHKzHzTYyE7GXt7dK Nc+H58r0t7lhZjXiq8VpUB2tA+L45JIVGCTic7840QEevZIYeo0973OlY7LHwFNxaY5r 8ZE4wDWlrc0Dt/JfxZCJXGDlTjQ82wCJpJum38OyVIobSepHDMkHhJ4osrWcrINUJYjF Sg6BAcmE9lGr0uWyQvRLbyW7z6Mclcf423kYfRbyHpkVcT7rsmaWD6wz8IXhZoKQF5oB WDDGswQrNYmQOp/KpdiFUp3ZBkhub3ISwXE8umlvdZUMzyisPfWwZrXzsq3fbPSELPjz kCgg== 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:arc-authentication-results; bh=adMwfCkzxxgDCaSwfwdUiLouzVMAs8jpoMo27JEfzP0=; b=PavrWZAmBj2KSrrDIqmn3lW9J1qnXEwmjL5qFw5hzIjlMkNJbOFds32qakZNaYBO+v ElZVjUWJKmbmAMIYInGAQs4hl/zcAU6uB0tzk8DNWbNmO8fSBIRGJLuT4FTWojD2X3Yl hWmGkwNnfwzX397X5Lqw0moGcvDjS5do6bk+TJXz4Bui+3k8Bbty2HKWsa3knIBwMJ7Q nH/beg1HhdYReYxU7v2fUVx7ukAX2abKWLiDawGZo+13sSOwpQURaJosaylzNF9jq2dz 5nm1U3fnAeWXPfOGTydxG5a5/JgAwtkXbiraeZNzHxHvpkfHaCVcPK5isfoH5YsYwRdg PkVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IJPFZxjw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g49-v6si15216975qvg.7.2018.06.09.21.15.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IJPFZxjw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrl2-0000Zj-Ag for patch@linaro.org; Sun, 10 Jun 2018 00:15:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqg9-0004qP-HV for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqg8-0004u7-MF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:05 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:45907) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqg8-0004tK-Fy for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:04 -0400 Received: by mail-pl0-x241.google.com with SMTP id c23-v6so10385837plz.12 for ; Sat, 09 Jun 2018 20:06:04 -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=adMwfCkzxxgDCaSwfwdUiLouzVMAs8jpoMo27JEfzP0=; b=IJPFZxjw1qsv02A1JS8dTjZzQ0AaaW6fHeraNtP6KmhkSdQBAsg8OJ6PbDVuf/XhaF SrHZabpeAqIDVzkltCg1PNy/GKEfFWWo9jE4jsE8f70g4wiQuEkWmnhHzoNHW5XuBEob QsDFnRCzzqQM4tanUPFlGakP8mP4ynz+itCtg= 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=adMwfCkzxxgDCaSwfwdUiLouzVMAs8jpoMo27JEfzP0=; b=Ae9zTgKB+X2NCY65pZzIY0RxNRwOurvZieWRRirXuF1y7nd+cBXg9VcvoCspvAKOAq UutCfXQrycJygfkoiGv6T3DnvL6SgPO7PI5F55e8fmX1c1Qi74Dfz6y83cslMr+esJ0B 28eJskDnD/FCBIMYvR3OCgunvW+CBGZx2iUtXPe1TINj3eXI4W3I7Ty85KfZ7qloE6tg 2RZZF3+kB8LUOOtSHZpXhpieQYSYvZXkTbiakABj0YjMDuzGXy6dM0y6S01rMlBVrTzb Lb4YFqbpRoChHmzPIpK81usVuOGOhssHiKfZPyYDRlLn4PBgVs8foafcInu1xJFUWh4A OVGA== X-Gm-Message-State: APt69E00JWX4GSs8NhQ7QiM7l70YIUyXc5oJfeldLtJoJ10Av8kLjBtb SecBsZuUdl9YjwBPRSkbp/mGVHfFCPA= X-Received: by 2002:a17:902:e3:: with SMTP id a90-v6mr3930433pla.227.1528599963398; Sat, 09 Jun 2018 20:06:03 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.06.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:06:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:19 -1000 Message-Id: <20180610030220.3777-108-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 107/108] linux-user: Split out setns, unshare 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 define both of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d15f994039..7a94a0b0e9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11820,6 +11820,13 @@ IMPL(setitimer) return ret; } +#ifdef CONFIG_SETNS +IMPL(setns) +{ + return get_errno(setns(arg1, arg2)); +} +#endif + IMPL(setpgid) { return get_errno(setpgid(arg1, arg2)); @@ -12984,6 +12991,13 @@ IMPL(unlinkat) return ret; } +#ifdef CONFIG_SETNS +IMPL(unshare) +{ + return get_errno(unshare(arg1)); +} +#endif + #ifdef TARGET_NR_utime IMPL(utime) { @@ -13200,23 +13214,11 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { - CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); - abi_long ret; - switch(num) { -#if defined(TARGET_NR_setns) && defined(CONFIG_SETNS) - case TARGET_NR_setns: - return get_errno(setns(arg1, arg2)); -#endif -#if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS) - case TARGET_NR_unshare: - return get_errno(unshare(arg1)); -#endif default: gemu_log("qemu: Unsupported syscall: %d\n", num); return -TARGET_ENOSYS; } - return ret; } /* The default action for a syscall not listed in syscall_table is to @@ -13770,6 +13772,9 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(sethostname); SYSCALL(setitimer); +#ifdef CONFIG_SETNS + SYSCALL(setns); +#endif SYSCALL(setpgid); SYSCALL(setpriority); SYSCALL(setregid); @@ -13916,6 +13921,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(unlink); #endif SYSCALL(unlinkat); +#ifdef CONFIG_SETNS + SYSCALL(unshare); +#endif #ifdef TARGET_NR_utime SYSCALL(utime); #endif From patchwork Sun Jun 10 03:02:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138183 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2619976lji; Sat, 9 Jun 2018 21:24:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIT7J8e4HE71v1IxKjiNFBjydydywmjFf5TyBgJNk6PXSbk/Z8Qlr5GgwUyoeMXgMz2eycr X-Received: by 2002:a0c:c309:: with SMTP id f9-v6mr10811818qvi.104.1528604685960; Sat, 09 Jun 2018 21:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604685; cv=none; d=google.com; s=arc-20160816; b=t2Bgi1jBiuIwmaUTQQ7HIROkTIyHnHWeoE8imvI/UNHigPeNBdjGIWOUWM+KgBm1zL dSjkE1DYtoGwlZBufB5ObWhzwZxmeNuGFIezfdMLZd22u18MYaxfUFlxyj1lBTA6cPTj m6nP0RxBtm3lQBYEm0k67AnPU1TWLOXyOPGNfDSfvK8FZUhoBOft9gdeZ7xPbSFgFLJo 1PIUxabRozYGRp7hrgR2hbpgNy816o1zd2AkpZyqxCiL+7il9IPWITJYqINnWf4g6CdG FyLI0D5juHSBkm630gEIt9aDxQeTohUVMOktnSDhfdBIljCd4WN2x6CzCsJeDuSbmyf0 Bjqg== 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:arc-authentication-results; bh=HpJ6XMVk+RpX6IKeuZWr2xgxzI79L+on1POkolu0Lgw=; b=A6JVupYB1fHClIpWeRej5DAZr3lHVzv+MtD8gLO0Du3Oq645gEtgcGG5swAz1iGb8l +MAZCSxo9nEioqz3Wd0/wFBSJQfC2e68HsWooFPPwWSXK9Bfg6M4WdjLaQHocy1eitUu LqPxhKMzVsfDAY+aAv2rUj6OyGN6qUmQU7yQ+g+1dCNSEp81jCwFNENX878gefjnDcOG OndPbeUO/wuO3xBv89Aam+cAsEU2YNgTTKGf4ITljxlAkUbry83EFLDij/FlYozcf4zG 2eiLbNrp2LQlLaKHWl6sC9EJJ4CMosalCGSeOJ6rCixCnH5Lo0b1dT+ouMXCCm/x/CcY /diw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TlX5mRgM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m7-v6si17644992qvo.247.2018.06.09.21.24.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TlX5mRgM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRruH-0000Gn-GN for patch@linaro.org; Sun, 10 Jun 2018 00:24:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqgD-0004uI-OU for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqgA-0004v6-Jt for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:09 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:36356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqgA-0004ug-E1 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:06:06 -0400 Received: by mail-pg0-x241.google.com with SMTP id m5-v6so8138272pgd.3 for ; Sat, 09 Jun 2018 20:06: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=HpJ6XMVk+RpX6IKeuZWr2xgxzI79L+on1POkolu0Lgw=; b=TlX5mRgMPQMMOORXqcwribevC7prVKGvp5jgIDXXq0hS0K8hOf3300RQhMJM93V5hw 0iRvunwDUJLiBsH50M453o6av/t6px8FHnNnq8N55sYLMmquGY9z+nATgDGR9C06KZwt Si9lvYSJQDATPclhbf4DpRDMYPlZOe3tmfRpc= 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=HpJ6XMVk+RpX6IKeuZWr2xgxzI79L+on1POkolu0Lgw=; b=Q2NMxzNM4MudsUoWPxG+OcIKh7IDu7n0A7eI1vxVEnFYZWtbdKplR7BnJa394cF8rs c+eDR9TwfYt01uJkwFZ1AMGC+1J2mW/m4vmjsMCxjNIqKw509BeuKVgWNXFpdzfkISJy jQEsVT9futu9d8XZtZjzZ/VouDUfaYtsUk3alwHIHkBENkp/kDG9v8nB1CrAnhIhref/ 1NCvJYECat7KqDGQDqFWjYP20lrFUp+ZkEIlOtJ+A7Uem2iND1M0/45EqBzk0fpC5En2 fV37bunoqt5RFCEmm3qk03FDAyZbi54ATr2oqPp3Ax4nTRvEcvatM2ox2t6HD2MUbwYM s3Zg== X-Gm-Message-State: APt69E3Rdx5bBgdnuoBX8b6acnMSg9/EAtyaXfrxkUIdTLcWQhHsKKRa lHopDI/Bcy4abJaoDxp09Te+nYy8wfM= X-Received: by 2002:a63:9041:: with SMTP id a62-v6mr10312069pge.191.1528599965276; Sat, 09 Jun 2018 20:06:05 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.06.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:06:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:20 -1000 Message-Id: <20180610030220.3777-109-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v2 108/108] linux-user: Fold away do_syscall1 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 | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7a94a0b0e9..a4cef22436 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -13204,23 +13204,6 @@ IMPL(writev) return ret; } -/* This is an internal helper for do_syscall so that it is easier - * to have a single return point, so that actions, such as logging - * of syscall results, can be performed. - * All errnos that do_syscall() returns must be -TARGET_. - */ -static abi_long do_syscall1(void *cpu_env, unsigned 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) -{ - switch(num) { - default: - gemu_log("qemu: Unsupported syscall: %d\n", num); - return -TARGET_ENOSYS; - } -} - /* The default action for a syscall not listed in syscall_table is to * log the missing syscall. If a syscall is intentionally emulated as * not present, then list it with impl_enosys as the implementation, @@ -13953,8 +13936,8 @@ static impl_fn *syscall_table(unsigned num) #undef SYSCALL #undef SYSCALL_WITH - /* After do_syscall1 is fully split, this will be impl_enosys. */ - return do_syscall1; + gemu_log("qemu: Unsupported syscall: %u\n", num); + return impl_enosys; } abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,