From patchwork Fri Jun 1 07:30: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: 137464 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp605986lji; Fri, 1 Jun 2018 00:34:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLZTFh8s8kbVwgplxHMiksuR4VeSHNnSSp/1fVmkejq8D5wP5zkQ3YzyxLlMq+QcnlE4C2V X-Received: by 2002:aed:39e6:: with SMTP id m93-v6mr9266093qte.328.1527838488289; Fri, 01 Jun 2018 00:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838488; cv=none; d=google.com; s=arc-20160816; b=K0ZoFCFp4YfQTBRUnufPkbhXSKl3DwI2C+flsK7DvJVBxhQNTK1Crs3jMO0UGbiwML am28sdzJOjW97AHxLulkzdRW9sQnaeaNEiMvkzxjjiiqTGh0jFe1MME6zX/J4HyMuIHW Ado45SMPXG6utGpqt0o//ZBcmpiiWTj/OUSiBEZqxePUzIr9hv63ZHvNjHW6csspjLbg S8AYb/Z3NE/We8/27yhF+cg6VcEKIU+0Ecxt+X3ygowMLQJwgmRS2fMqnVrtxysDpRXh YaxjyKIQ1xffTqUN3m0nHYJvqN/pAqX70yqGR4rIoVnWqhaHMXuYD1ycK1B1wHUkA5nA Hs2w== 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=jiV3ryV7bNwrqAaXgi+PnuEbFIblWYhP1BSR8J6DhRw=; b=or8M0X46Q5uiMLw7kjFRkO8CRBdGdttplL/tCU+LcER+yEm5QKTByn8SuLU1MRbfZP TaELSqPknC6PZF/PckUyaP9Sk4rb2HQPa1W1+cNhVxNQV529ULCK24qcH+HTLk7tYwGn F24+qa99qDFjPPp3mkcZwNxhKhPb6lhEYGDjnaz+GR35GEjENk9A0wQC218yZOWAHVUV K61wugOcz0gJ1ox+qISxCnkALZyFq+o3WVsMsQL2xH0Ql1E5PUY3Egrhd/FP4wXcBW66 2/+k1K4PRhzQ/oJmBqO9s/DCB/jJ/Y7xagY9brGbJxpN+RV9vuW2oYuAzsTvG3hLehSL UMZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TVzZ+bqT; 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 k5-v6si9229078qvb.37.2018.06.01.00.34.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:34: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=TVzZ+bqT; 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]:47820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeaF-0007jO-LN for patch@linaro.org; Fri, 01 Jun 2018 03:34:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWY-0005N0-LX for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWV-0000AK-VC for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:30:58 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:39304) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWV-00009i-PN for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:30:55 -0400 Received: by mail-pl0-x243.google.com with SMTP id f1-v6so14382499plt.6 for ; Fri, 01 Jun 2018 00:30: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=jiV3ryV7bNwrqAaXgi+PnuEbFIblWYhP1BSR8J6DhRw=; b=TVzZ+bqTpo9gtK+zwDHgfVCX3V1FOYAaovv9i4KT7/YCyULiaS8MBMxFywRhi2dAaV izfWVZa+4MiIiVl8RMTPQlsjLWOpqLsP9snQFuRog4oxWjQIlOatDbUj2REVFYYbmlbm WzDKRVuHbC/oM9bJQBKQ9UtjhpmN9C/paamHo= 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=jiV3ryV7bNwrqAaXgi+PnuEbFIblWYhP1BSR8J6DhRw=; b=WriKzvkffXN9ezzM9rWQrZ+iRGptJI2kRVxqGRW2QYqULFE0AbSRkZnmT3JE3LsT7c ceX7hPWaaiZYoXttIi0scC10R1T8t5aahr6C7pu8in+blz4m1NxBIo/17qbGBP+jLYnY zNebCfqAh7vxfSWNIYfQ8lyBZ7DxUU2JXkGBkSPMYyQmNxMKCzzCHe+RIp0WijYnCpFP 99H05sn3N1LD/hdZ6/WBy3Duo3CZL4QBVDn0sqIYA2fV5FyTbTM5uc3Gpp8Rym3xVRNC Bl119Y7Hew7ga3QCdT+SlZOhIhIBP8o2BScRas4t1O5tFkgK79W07SPZLJa7+ZZ3PPFK 8Xew== X-Gm-Message-State: ALKqPwe5EOon9MjBZGbP28kOJgcUkKKpJN/6at1rGjGtNyorFm1vaOWR EjGUzRjk6SNAHbr0A55ztWm8TBTEuWM= X-Received: by 2002:a17:902:4301:: with SMTP id i1-v6mr10106217pld.280.1527838254504; Fri, 01 Jun 2018 00:30:54 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.30.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:30:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:18 -0700 Message-Id: <20180601073050.8054-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 01/33] 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. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 89 +++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 35 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b75dd9a5bc..ebaefebcc2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7962,13 +7962,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; @@ -7977,28 +7979,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, void *p; char *fn; -#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 - -#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); - switch(num) { case TARGET_NR_exit: /* In old applications this may be used to implement _exit(2). @@ -13101,12 +13081,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); return ret; efault: ret = -TARGET_EFAULT; @@ -13115,3 +13089,48 @@ ebadf: ret = -TARGET_EBADF; 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; + +#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 bool flag; + flag = !flag; + if (flag) { + return -TARGET_ERESTARTSYS; + } + } +#endif +#ifdef DEBUG + gemu_log("syscall %d", num); +#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); + } + +#ifdef DEBUG + gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); +#endif + trace_guest_user_syscall_ret(cpu, num, ret); + return ret; +} From patchwork Fri Jun 1 07:30: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: 137473 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp610860lji; Fri, 1 Jun 2018 00:41:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKInBE2TYYTfQUv13z3i0K5A3sPI33hKsjAAye4ez+Z3BrVP0aKE+sExv9ryXVPXpj7i+Hl+ X-Received: by 2002:a0c:8cc5:: with SMTP id q5-v6mr9509482qvb.60.1527838876178; Fri, 01 Jun 2018 00:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838876; cv=none; d=google.com; s=arc-20160816; b=Qj/3C9RZDf+6ZrPXVX4XJnnzMFrVy21q7/U+nAmv9Kl+UmaUjXuZG9NTXSPczWZRJc MvoTEQV5DPPVz9Z77sP0z8ASNh7dOyrdT5MdxzQV2mtM/reEi/hhVXvw9fQXdFS5vRa7 A5kQv/1JSkn1yKgpY/4JsXKnVxEQm8/obldKBZrV9sXmnPsnoeLE+sMGTfhEHGkfBrUZ JcSyS2pIUD5JQtFhKco414QLz8b10Kmh++iaT6zwPcHe0lwvyNW+BBgvHm6GfSUApwMj 19uAdby3X+BWBueKb/F8czVGDURlpXMsRbL41WlYMdq1vB6MTeE2z4LbqkIWwBPa/eQH 44JQ== 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=yvWoYljc5bmaBxsgz/ekV+QimdOcDqNpmLqy+DbsfB8=; b=iE+KioKCaaHE2MX0tySERe/D3Pd0fTHr8QKulLuFLceTTCpaDMgPfyPHPFZremdlwa j4VJoP9My9+jntIe2wBaWchUSpMS7isi2CseoOBfXIpP6DspzpeKAXRCiw43MQQAFU7m 4JXfcGkRlDOHxY7BStVRIbnoQ4TuLJbCNFWJnphZ6iWadqygV9DwxNhtDf1Ior0GavMu 3BzhQFfmmeFzmT0DUFD0Y7pBTq4uOQoB2V1mhxHrx9LUsCojgEnxnrb8OB6YZsPn/0vx 0+Yl3QR/HvygBwvlpTrd+RBn79FE/vRcd10xxeSqeDOcpE2TGjJ0gvNlYBIlI6wCir4H Jm3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HXm70G9/; 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 y28-v6si11317884qtm.194.2018.06.01.00.41.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:41: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=HXm70G9/; 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]:47861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOegV-0004QY-DN for patch@linaro.org; Fri, 01 Jun 2018 03:41:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWi-0005ST-7w for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWZ-0000EJ-AV for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:08 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:36004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWY-0000DG-PI for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:30:59 -0400 Received: by mail-pl0-x241.google.com with SMTP id v24-v6so14817753plo.3 for ; Fri, 01 Jun 2018 00:30: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=yvWoYljc5bmaBxsgz/ekV+QimdOcDqNpmLqy+DbsfB8=; b=HXm70G9/UwJe/5+Sp9Nc3/O0naV47tkcpwElrQReEaadLM0XualxtiX0Clu2y9cy4f V8e46pDcwSMiWEZ4BRh0NxRhYcqAtttaYwsodaLe7ZTs2Z8SXNVyhbBjW7uVR/ftTeUe bs+5XRlORI5DdNmtfukdoJUcB3XsIT846jbqw= 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=yvWoYljc5bmaBxsgz/ekV+QimdOcDqNpmLqy+DbsfB8=; b=gyjc+XRy4++gNAwvfDPix7oiWJglMr3b5vJyyyZnR22T2TL/mzPLyIzniwwN8R1vw6 WuWToUiJgQA7wYMjjBg7Ykz3t+b3flw8Ha+QNbnMkF2koe/ClYIkfv/FwvlRZV+20BiE BUYN5ydRYrqEXc1iTQyf/Z/9MaTvkJe85ec0JaiPu3NjIyv01S5f+zBxtKqXVStf+hod v5DDjpSRmwZHjch7kWjjLoI0D68LYTJWSBW3QXu8mPUi1cXXzr9digDwo9AUhBuq3Zgq r2SOlBXRz9gNLShU3lO5dWsreIqkV04VJ2EW8xnewTXBjFmtCQ6mO2fi2X13/PJfCGBA HxCA== X-Gm-Message-State: ALKqPwdvgWRqMv4mwvNJaTb7kSv7QarRB0hEGIZLu6HeVRe1jXOulEUq EiOtvWV388teRjF5gHbjooYCw4llsvs= X-Received: by 2002:a17:902:b418:: with SMTP id x24-v6mr10034719plr.2.1527838256221; Fri, 01 Jun 2018 00:30:56 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.30.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:30:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:19 -0700 Message-Id: <20180601073050.8054-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 02/33] 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. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 969 +++++++++++++++++-------------------------- 1 file changed, 390 insertions(+), 579 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ebaefebcc2..258aff0411 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7987,8 +7987,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(); @@ -8020,12 +8019,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 (is_hostfd(arg1)) { goto ebadf; } @@ -8038,7 +8036,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 (is_hostfd(arg1)) { goto ebadf; @@ -8057,7 +8055,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))) @@ -8067,7 +8066,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 (is_hostfd(arg1)) { @@ -8080,14 +8079,14 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } 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: @@ -8096,22 +8095,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } ret = do_open_by_handle_at(arg1, arg2, arg3); fd_trans_unregister(ret); - break; + return ret; #endif case TARGET_NR_close: if (is_hostfd(arg1)) { goto ebadf; } 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: @@ -8122,7 +8119,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: @@ -8137,7 +8134,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: @@ -8146,7 +8143,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: @@ -8161,7 +8158,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: @@ -8180,7 +8177,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: @@ -8188,7 +8185,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: @@ -8199,7 +8196,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: { @@ -8297,13 +8294,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: { @@ -8314,7 +8311,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: @@ -8322,7 +8319,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: @@ -8333,7 +8330,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: @@ -8341,7 +8338,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: @@ -8355,19 +8352,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (is_hostfd(arg1)) { goto ebadf; } - 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: { @@ -8423,14 +8417,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: @@ -8438,16 +8432,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: @@ -8458,8 +8450,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: @@ -8481,7 +8472,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: @@ -8501,7 +8492,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: @@ -8527,7 +8518,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(ret); unlock_user(fn, arg2, 0); } - break; + return ret; #endif #ifdef TARGET_NR_stty case TARGET_NR_stty: @@ -8547,7 +8538,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, access(fn, arg2)); ret = get_errno(ret); unlock_user(fn, arg1, 0); - break; + return ret; #endif #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) case TARGET_NR_faccessat: @@ -8562,12 +8553,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, faccessat(arg1, fn, arg3, 0)); ret = get_errno(ret); unlock_user(fn, 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: @@ -8575,16 +8565,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: { @@ -8598,7 +8585,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: @@ -8615,7 +8602,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: @@ -8633,7 +8620,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: @@ -8641,7 +8628,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: @@ -8652,7 +8639,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: @@ -8660,7 +8647,7 @@ 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: if (is_hostfd(arg1)) { @@ -8670,17 +8657,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long 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: { @@ -8699,7 +8684,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; @@ -8719,34 +8704,31 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(ret); unlock_user(fn, 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; @@ -8756,14 +8738,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; @@ -8777,7 +8758,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: @@ -8795,22 +8776,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: { @@ -8894,7 +8872,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #endif } - break; + return ret; #endif case TARGET_NR_rt_sigaction: { @@ -8911,8 +8889,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)) @@ -8944,8 +8921,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)) { @@ -8972,7 +8948,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: { @@ -8984,7 +8960,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: @@ -8998,7 +8974,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: @@ -9068,7 +9044,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #endif } - break; + return ret; #endif case TARGET_NR_rt_sigprocmask: { @@ -9076,8 +9052,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) { @@ -9112,7 +9087,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: { @@ -9125,7 +9100,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: { @@ -9137,8 +9112,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)); @@ -9149,7 +9123,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: { @@ -9169,15 +9143,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; @@ -9189,7 +9162,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; @@ -9197,8 +9170,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))) @@ -9226,7 +9198,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; @@ -9239,7 +9211,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; @@ -9252,7 +9224,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()) { @@ -9260,21 +9232,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); @@ -9285,9 +9256,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); @@ -9303,7 +9273,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; @@ -9312,7 +9282,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; @@ -9322,7 +9292,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; @@ -9342,9 +9312,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) @@ -9357,7 +9326,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: @@ -9466,7 +9435,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: @@ -9481,7 +9450,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: @@ -9498,7 +9467,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: @@ -9537,7 +9506,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg2, ret); unlock_user(fn, arg1, 0); } - break; + return ret; #endif #if defined(TARGET_NR_readlinkat) case TARGET_NR_readlinkat: @@ -9563,7 +9532,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p2, arg3, ret); unlock_user(fn, arg2, 0); } - break; + return ret; #endif #ifdef TARGET_NR_uselib case TARGET_NR_uselib: @@ -9575,7 +9544,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) { @@ -9589,7 +9558,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; @@ -9628,7 +9597,7 @@ 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: @@ -9638,15 +9607,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (is_hostfd(arg5)) { goto ebadf; } - 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; @@ -9659,57 +9626,48 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - ret = get_errno(ftruncate(arg1, arg2)); - break; + return get_errno(ftruncate(arg1, arg2)); case TARGET_NR_fchmod: if (is_hostfd(arg1)) { goto ebadf; } - ret = get_errno(fchmod(arg1, arg2)); - break; + return get_errno(fchmod(arg1, arg2)); #if defined(TARGET_NR_fchmodat) case TARGET_NR_fchmodat: if (is_hostfd(arg1)) { @@ -9719,7 +9677,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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 @@ -9727,8 +9685,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. */ @@ -9737,10 +9694,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; @@ -9777,7 +9733,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: if (is_hostfd(arg1)) { goto ebadf; @@ -9812,7 +9768,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: if (is_hostfd(arg1)) { goto ebadf; @@ -9826,142 +9782,124 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_accept4(arg1, arg2, arg3, 0); - break; + return do_accept4(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_accept4 case TARGET_NR_accept4: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_accept4(arg1, arg2, arg3, arg4); - break; + return do_accept4(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_bind(arg1, arg2, arg3); - break; + return do_bind(arg1, arg2, arg3); #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_connect(arg1, arg2, arg3); - break; + return do_connect(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_getpeername(arg1, arg2, arg3); - break; + return do_getpeername(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_getsockname(arg1, arg2, arg3); - break; + return do_getsockname(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: if (is_hostfd(arg1)) { goto ebadf; } - 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: if (is_hostfd(arg1)) { goto ebadf; } - ret = get_errno(listen(arg1, arg2)); - break; + return get_errno(listen(arg1, arg2)); #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: if (is_hostfd(arg1)) { goto ebadf; } - 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: if (is_hostfd(arg1)) { goto ebadf; } - 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: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_sendrecvmsg(arg1, arg2, arg3, 0); - break; + return do_sendrecvmsg(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_send case TARGET_NR_send: if (is_hostfd(arg1)) { goto ebadf; } - 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: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_sendrecvmsg(arg1, arg2, arg3, 1); - break; + return do_sendrecvmsg(arg1, arg2, arg3, 1); #endif #ifdef TARGET_NR_sendmmsg case TARGET_NR_sendmmsg: if (is_hostfd(arg1)) { goto ebadf; } - ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); - break; + return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); case TARGET_NR_recvmmsg: if (is_hostfd(arg1)) { goto ebadf; } - 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: if (is_hostfd(arg1)) { goto ebadf; } - 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: if (is_hostfd(arg1)) { goto ebadf; } - 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: @@ -9971,25 +9909,22 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - 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: @@ -10005,10 +9940,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 */ @@ -10019,7 +9951,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } ret = 0; if (len == 0) { - break; + return ret; } p = lock_user(VERIFY_WRITE, arg2, arg3, 0); if (!p) { @@ -10029,10 +9961,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; @@ -10059,7 +9990,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; @@ -10073,7 +10004,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 (!(fn = lock_user_string(arg1))) { @@ -10128,7 +10059,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; @@ -10138,17 +10069,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: { @@ -10176,14 +10105,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: { @@ -10211,73 +10140,60 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - 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 @@ -10294,7 +10210,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: @@ -10302,15 +10218,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 */ { @@ -10331,17 +10246,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: @@ -10358,7 +10271,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: { @@ -10374,7 +10287,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: @@ -10388,14 +10301,12 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - 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; @@ -10405,8 +10316,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; @@ -10431,7 +10341,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: @@ -10566,7 +10476,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: @@ -10596,12 +10506,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 @@ -10620,8 +10529,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, @@ -10666,8 +10574,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); @@ -10689,7 +10596,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 @@ -10706,8 +10613,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: @@ -10721,7 +10627,7 @@ 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 @@ -10729,8 +10635,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (is_hostfd(arg1)) { goto ebadf; } - ret = get_errno(safe_flock(arg1, arg2)); - break; + return get_errno(safe_flock(arg1, arg2)); case TARGET_NR_readv: if (is_hostfd(arg1)) { goto ebadf; @@ -10743,7 +10648,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: if (is_hostfd(arg1)) { goto ebadf; @@ -10756,7 +10661,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: if (is_hostfd(arg1)) { @@ -10773,7 +10678,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: @@ -10791,25 +10696,22 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - 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: { @@ -10821,8 +10723,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); @@ -10841,8 +10742,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; } @@ -10852,7 +10752,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; @@ -10863,20 +10763,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; @@ -10893,7 +10791,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; @@ -10906,9 +10804,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; @@ -10925,7 +10822,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; @@ -10937,21 +10834,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; @@ -10960,7 +10852,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; @@ -10970,7 +10862,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; @@ -10989,7 +10881,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: @@ -11001,7 +10893,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: { @@ -11012,7 +10904,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 @@ -11033,32 +10925,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 @@ -11076,7 +10965,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 (is_hostfd(arg1)) { goto ebadf; @@ -11089,14 +10978,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: { @@ -11165,11 +11054,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: @@ -11183,7 +11072,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; } @@ -11194,7 +11083,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: @@ -11208,7 +11097,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; } @@ -11219,7 +11108,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = ret2; } } - break; + return ret; } #endif #else @@ -11240,10 +11129,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: @@ -11259,7 +11147,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 @@ -11268,15 +11156,14 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - 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: @@ -11290,7 +11177,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(fn, 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: @@ -11304,7 +11191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(fn, 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: @@ -11314,7 +11201,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, 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 @@ -11336,7 +11223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(fn, arg2, 0); 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: @@ -11344,34 +11231,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; @@ -11382,7 +11263,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) @@ -11392,7 +11273,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; @@ -11411,12 +11292,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 (is_hostfd(arg1)) { @@ -11427,14 +11306,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: @@ -11448,14 +11326,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: @@ -11469,7 +11346,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: @@ -11477,20 +11354,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: @@ -11498,12 +11371,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) @@ -11514,8 +11386,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 */ @@ -11525,8 +11396,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 */ @@ -11564,7 +11434,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 */ @@ -11655,7 +11525,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. */ @@ -11687,33 +11557,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: @@ -11726,7 +11591,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) { @@ -11738,7 +11603,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: @@ -11757,22 +11622,19 @@ 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: if (is_hostfd(arg1)) { goto ebadf; } - 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: @@ -11786,12 +11648,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: @@ -11805,7 +11666,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: @@ -11813,27 +11674,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: @@ -11857,7 +11714,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: @@ -11872,8 +11729,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 @@ -11902,11 +11758,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 @@ -11922,10 +11776,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 */ @@ -11948,8 +11800,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 */ @@ -11959,8 +11810,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: @@ -11982,8 +11832,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) { @@ -12010,14 +11859,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: @@ -12025,12 +11873,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 @@ -12043,7 +11889,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 @@ -12054,8 +11900,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); @@ -12070,7 +11915,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: { @@ -12078,13 +11923,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: @@ -12093,8 +11937,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); @@ -12112,7 +11955,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_fsetxattr: if (is_hostfd(arg1)) { goto ebadf; @@ -12121,8 +11964,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; } } n = lock_user_string(arg2); @@ -12134,7 +11976,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: { @@ -12142,8 +11984,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); @@ -12161,7 +12002,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_fgetxattr: if (is_hostfd(arg1)) { goto ebadf; @@ -12170,8 +12011,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; } } n = lock_user_string(arg2); @@ -12183,7 +12023,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: { @@ -12202,7 +12042,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: if (is_hostfd(arg1)) { goto ebadf; @@ -12216,15 +12056,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; @@ -12232,16 +12071,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; @@ -12250,13 +12087,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; @@ -12276,7 +12111,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 @@ -12287,7 +12122,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 @@ -12298,7 +12133,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 @@ -12318,24 +12153,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: @@ -12381,18 +12213,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(fn, 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) @@ -12402,7 +12233,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) @@ -12416,15 +12247,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, TRY_INTERP_PATH(ret, fn, sys_inotify_add_watch(arg1, fn, arg3)); ret = get_errno(ret); unlock_user(fn, arg2, 0); - break; + return ret; #endif #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: if (is_hostfd(arg1)) { goto ebadf; } - 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) @@ -12449,17 +12279,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: { @@ -12475,7 +12304,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: { @@ -12496,7 +12325,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: */ @@ -12517,7 +12346,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 @@ -12528,7 +12357,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { ret = get_errno(tee(arg1,arg2,arg3,arg4)); } - break; + return ret; #endif #ifdef TARGET_NR_splice case TARGET_NR_splice: @@ -12561,7 +12390,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: @@ -12576,7 +12405,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 @@ -12586,7 +12415,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: @@ -12602,7 +12431,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 */ @@ -12617,7 +12446,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) @@ -12636,7 +12465,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: @@ -12650,7 +12479,7 @@ 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) @@ -12658,27 +12487,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (is_hostfd(arg1)) { goto ebadf; } - ret = do_signalfd4(arg1, arg2, arg4); - break; + return do_signalfd4(arg1, arg2, arg4); #endif #if defined(TARGET_NR_signalfd) case TARGET_NR_signalfd: if (is_hostfd(arg1)) { goto ebadf; } - 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: @@ -12703,8 +12528,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 @@ -12726,8 +12550,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto ebadf; } if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) { - ret = -TARGET_EINVAL; - break; + return -TARGET_EINVAL; } target_ep = lock_user(VERIFY_WRITE, arg2, @@ -12739,8 +12562,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) { @@ -12770,7 +12592,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) @@ -12794,7 +12615,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 @@ -12824,7 +12645,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 @@ -12837,7 +12658,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 @@ -12858,17 +12679,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 @@ -12890,7 +12708,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; } } @@ -12903,7 +12721,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } - break; + return ret; } #endif @@ -12931,7 +12749,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } - break; + return ret; } #endif @@ -12954,7 +12772,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -TARGET_EFAULT; } } - break; + return ret; } #endif @@ -12971,7 +12789,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 @@ -12988,15 +12806,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) @@ -13012,7 +12829,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) @@ -13037,19 +12854,17 @@ 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) @@ -13057,18 +12872,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (is_hostfd(arg1)) { goto ebadf; } - 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: @@ -13077,8 +12889,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 Fri Jun 1 07:30: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: 137462 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp603347lji; Fri, 1 Jun 2018 00:31:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIxxRqkJi0Fl2d6NU6kEG5NwXBmlpLPmXJHOiFFsltBJcALWdt318zgBTYPwLkmL959Sd0E X-Received: by 2002:a37:cc10:: with SMTP id r16-v6mr8929014qki.95.1527838298278; Fri, 01 Jun 2018 00:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838298; cv=none; d=google.com; s=arc-20160816; b=TqC9t8s8xAMfR3ja0mQhNxdQM4tXPZyEoBLrONb5XUJeG1Wq37DbEWeUwfTWVL4Z1B VSF1U8+koYyS3EvVJVLABmIRqLXzgJ9WKyCBw5KVJVqnA37YN1Y4MrZ3UICgOahmL2cA txGeMRSNfhnH5obx1HRuJk0OozJ131qyoTYCZmpjD9VIauHt2A1odXNE1UxgmPZfoK+y iYCNouHTWYA8xHbfuSonlYCGnIpCX9Rm43LbCxQFZ3sMjF6zsVOELMaGyEik/7LZYlsj FOvFEe2BlSifFfz1Ux3qtZE0hBtQyp0jBkxWVKpRFAJhuzlCikbHzyGNUfJngJkDytXX xX0w== 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=y9SH0HXqDX3GsEA1dtFZQxYpaQKqyU0SiTbdpkkYm/w=; b=eictNcVgz3mQMBVkGOCkC084JkDn1T3kY56dZZn3ipTFIZnCX5kGWI5D6ixVL0mXMp ps3hkKfF0ID3SGyA87waALESsYW2M6lEYjjRoEys1zX7BfSjZIYbmoBTcewve1ac6wKB L5atRGnRODxQxZACjxwKcHrZjWbtJjyKhFuXuWOoJDTNEcjrzTHhnaPsRZy+LzscxYxT duhbWv9levldIjkEJcg0japVcSNhUcuOaLYe4S0Rdi9Fb2GltOz959y5JEMHYfDlBF+s xz0AcFq7KC3ti5tfq4KrXVbkBtPZYL2uht2gJnq2L1T2LmgvtPnAwT3Ml+AdYcn37fpo sxqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H1+tD2Mw; 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 c85-v6si10447470qkj.206.2018.06.01.00.31.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:31:38 -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=H1+tD2Mw; 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]:47811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXB-0005TL-M1 for patch@linaro.org; Fri, 01 Jun 2018 03:31:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWc-0005PS-L3 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWZ-0000EP-B0 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:02 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:35482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWZ-0000DK-07 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:30:59 -0400 Received: by mail-pl0-x244.google.com with SMTP id i5-v6so14819939plt.2 for ; Fri, 01 Jun 2018 00:30: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=y9SH0HXqDX3GsEA1dtFZQxYpaQKqyU0SiTbdpkkYm/w=; b=H1+tD2Mwc87Z0uX0F2Z47UdZd+7x93RN7ZaAnrgU4+0lEnNMm9QGVKjj/VDAl693rt nOpw2HiWH5G2ZSyw+R/zF9PgTJiBq0gxgU0mHYVG1VWBiwk2vtMq+R4H+xVZanJ/Gn/Y 5iaJJrgPRpkzrUeBmezYZ9sRrXXzFtFPsSnbM= 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=y9SH0HXqDX3GsEA1dtFZQxYpaQKqyU0SiTbdpkkYm/w=; b=keDonHk4zink9EpDZd+l1u7LOCcpHGvlVhYT9m5KzqCZAyuDIoONYlH+AKr9IJOlAl zqNLV4E+H/92DwKKLlTREHyAhfDpNMENudD1nnvlONtPuI8jXo2se1XvC393nCia4EBN o/M9MV3+YpfQLAA+3eSq20X5DiwuKOvzzUqghDVdo7uSIzOQK2hC2Iq2RQBbVmksjwlu xYyLoB3XSH54rfpJOGsM39nJJB2HVkosNp3NQvPzzpC9NMwwdTmyJYsIOaVqc6mg/09T sg4+JYmiWZorImhbbWaqcebaLCOmU8Mpev34JRDDILwG/mg/OW2OSuk2oCTLvClJrtxy Cgcw== X-Gm-Message-State: ALKqPwcJD//WsPNbP/tIBXYCNWvYXL+/+9DSL7cddGWsqEo3BR+GH6+e YELeh7wIRebqXNSLPnW7ncn6/uYCxK4= X-Received: by 2002:a17:902:6ac6:: with SMTP id i6-v6mr10386294plt.31.1527838257436; Fri, 01 Jun 2018 00:30:57 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.30.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:30:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:20 -0700 Message-Id: <20180601073050.8054-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 03/33] linux-user: Propagate goto ebadf 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 187 +++++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 95 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 258aff0411..d0bf650c62 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8025,7 +8025,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return 0; } else { if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; @@ -8039,7 +8039,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_write: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; @@ -8070,7 +8070,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_openat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8083,7 +8083,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_name_to_handle_at: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5); return ret; @@ -8091,7 +8091,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) case TARGET_NR_open_by_handle_at: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = do_open_by_handle_at(arg1, arg2, arg3); fd_trans_unregister(ret); @@ -8099,7 +8099,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_close: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } fd_trans_unregister(arg1); return get_errno(close(arg1)); @@ -8163,7 +8163,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_linkat) case TARGET_NR_linkat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void * p2 = NULL; if (!arg2 || !arg4) @@ -8190,7 +8190,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_unlinkat) case TARGET_NR_unlinkat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8324,7 +8324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_mknodat) case TARGET_NR_mknodat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8350,7 +8350,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_lseek: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(lseek(arg1, arg2, arg3)); #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) @@ -8497,7 +8497,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_futimesat) case TARGET_NR_futimesat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct timeval *tvp, tv[2]; if (arg3) { @@ -8543,7 +8543,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) case TARGET_NR_faccessat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { goto efault; @@ -8590,7 +8590,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_renameat) case TARGET_NR_renameat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; p = lock_user_string(arg2); @@ -8607,7 +8607,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_renameat2) case TARGET_NR_renameat2: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; p = lock_user_string(arg2); @@ -8633,7 +8633,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_mkdirat) case TARGET_NR_mkdirat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -8651,7 +8651,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_dup: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(dup(arg1)); if (ret >= 0) { @@ -8752,7 +8752,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_dup2 case TARGET_NR_dup2: if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(dup2(arg1, arg2)); if (ret >= 0) { @@ -8766,7 +8766,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int host_flags; if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } if ((arg3 & ~TARGET_O_CLOEXEC) != 0) { return -EINVAL; @@ -9370,7 +9370,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (contains_hostfd(&rfds) || contains_hostfd(&wfds) || contains_hostfd(&efds)) { - goto ebadf; + return -TARGET_EBADF; } /* @@ -9455,7 +9455,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_symlinkat) case TARGET_NR_symlinkat: if (is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; p = lock_user_string(arg1); @@ -9511,7 +9511,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_readlinkat) case TARGET_NR_readlinkat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *p2; fn = lock_user_string(arg2); @@ -9582,7 +9582,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, v6 = tswapal(v[5]); unlock_user(v, arg1, 0); if (is_hostfd(v5)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), @@ -9590,7 +9590,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #else if (is_hostfd(arg5)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), @@ -9605,7 +9605,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #define MMAP_SHIFT 12 #endif if (is_hostfd(arg5)) { - goto ebadf; + return -TARGET_EBADF; } ret = target_mmap(arg1, arg2, arg3, target_to_host_bitmask(arg4, mmap_flags_tbl), @@ -9660,18 +9660,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_ftruncate: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(ftruncate(arg1, arg2)); case TARGET_NR_fchmod: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fchmod(arg1, arg2)); #if defined(TARGET_NR_fchmodat) case TARGET_NR_fchmodat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -9736,7 +9736,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fstatfs: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs; @@ -9771,7 +9771,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fstatfs64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; @@ -9787,117 +9787,117 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_accept case TARGET_NR_accept: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_accept4(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_accept4 case TARGET_NR_accept4: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_accept4(arg1, arg2, arg3, arg4); #endif #ifdef TARGET_NR_bind case TARGET_NR_bind: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_bind(arg1, arg2, arg3); #endif #ifdef TARGET_NR_connect case TARGET_NR_connect: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_connect(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getpeername case TARGET_NR_getpeername: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_getpeername(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockname case TARGET_NR_getsockname: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_getsockname(arg1, arg2, arg3); #endif #ifdef TARGET_NR_getsockopt case TARGET_NR_getsockopt: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_getsockopt(arg1, arg2, arg3, arg4, arg5); #endif #ifdef TARGET_NR_listen case TARGET_NR_listen: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(listen(arg1, arg2)); #endif #ifdef TARGET_NR_recv case TARGET_NR_recv: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_recvfrom(arg1, arg2, arg3, arg4, 0, 0); #endif #ifdef TARGET_NR_recvfrom case TARGET_NR_recvfrom: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_recvmsg case TARGET_NR_recvmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmsg(arg1, arg2, arg3, 0); #endif #ifdef TARGET_NR_send case TARGET_NR_send: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendto(arg1, arg2, arg3, arg4, 0, 0); #endif #ifdef TARGET_NR_sendmsg case TARGET_NR_sendmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmsg(arg1, arg2, arg3, 1); #endif #ifdef TARGET_NR_sendmmsg case TARGET_NR_sendmmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); case TARGET_NR_recvmmsg: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); #endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); #endif #ifdef TARGET_NR_shutdown case TARGET_NR_shutdown: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(shutdown(arg1, arg2)); #endif @@ -9922,7 +9922,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_setsockopt case TARGET_NR_setsockopt: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5); #endif @@ -10031,7 +10031,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_fstat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { ret = get_errno(fstat(arg1, &st)); #if defined(TARGET_NR_stat) || defined(TARGET_NR_lstat) @@ -10191,7 +10191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_fsync: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fsync(arg1)); case TARGET_NR_clone: @@ -10304,7 +10304,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fchdir(arg1)); #ifdef TARGET_NR_bdflush /* not on x86_64 */ @@ -10324,7 +10324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR__llseek /* Not on alpha */ case TARGET_NR__llseek: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { int64_t res; #if !defined(__NR_llseek) @@ -10346,7 +10346,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_getdents case TARGET_NR_getdents: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #ifdef EMULATE_GETDENTS_WITH_GETDENTS #if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64 @@ -10481,7 +10481,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64) case TARGET_NR_getdents64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct linux_dirent64 *dirp; abi_long count = arg3; @@ -10633,12 +10633,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, /* NOTE: the flock constant seems to be the same for every Linux platform */ if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(safe_flock(arg1, arg2)); case TARGET_NR_readv: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); if (vec != NULL) { @@ -10651,7 +10651,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_writev: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); if (vec != NULL) { @@ -10665,7 +10665,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_preadv) case TARGET_NR_preadv: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); if (vec != NULL) { @@ -10683,7 +10683,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_pwritev) case TARGET_NR_pwritev: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); if (vec != NULL) { @@ -10703,7 +10703,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */ case TARGET_NR_fdatasync: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fdatasync(arg1)); #endif @@ -10955,7 +10955,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_pread64 case TARGET_NR_pread64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (regpairs_aligned(cpu_env, num)) { arg4 = arg5; @@ -10968,7 +10968,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_pwrite64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (regpairs_aligned(cpu_env, num)) { arg4 = arg5; @@ -11067,7 +11067,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, off_t off; if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } if (arg3) { ret = get_user_sal(off, arg3); @@ -11092,7 +11092,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, off_t off; if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } if (arg3) { ret = get_user_s64(off, arg3); @@ -11161,7 +11161,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_ftruncate64 case TARGET_NR_ftruncate64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); #endif @@ -11196,7 +11196,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fstat64 case TARGET_NR_fstat64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = get_errno(fstat(arg1, &st)); if (!is_error(ret)) @@ -11211,7 +11211,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_newfstatat: #endif if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { goto efault; @@ -11299,7 +11299,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_fchownat) case TARGET_NR_fchownat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(p = lock_user_string(arg2))) goto efault; @@ -11628,7 +11628,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fchown32 case TARGET_NR_fchown32: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(fchown(arg1, arg2, arg3)); #endif @@ -11725,7 +11725,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, * pairs of 32-bit registers. */ if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } ret = posix_fadvise(arg1, target_offset64(arg3, arg4), target_offset64(arg5, arg6), arg2); @@ -11737,7 +11737,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fadvise64_64 case TARGET_NR_fadvise64_64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if defined(TARGET_PPC) || defined(TARGET_XTENSA) /* 6 args: fd, advice, offset (high, low), len (high, low) */ @@ -11766,7 +11766,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_fadvise64 case TARGET_NR_fadvise64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } /* 5 args: fd, offset (high, low), len, advice */ if (regpairs_aligned(cpu_env, num)) { @@ -11789,7 +11789,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_fadvise64: #endif if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #ifdef TARGET_S390X switch (arg4) { @@ -11815,7 +11815,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if TARGET_ABI_BITS == 32 case TARGET_NR_fcntl64: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } { int cmd; @@ -11958,7 +11958,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fsetxattr: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *n, *v = 0; if (arg3) { @@ -12005,7 +12005,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fgetxattr: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *n, *v = 0; if (arg3) { @@ -12045,7 +12045,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_fremovexattr: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { void *n; n = lock_user_string(arg2); @@ -12190,7 +12190,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_utimensat) case TARGET_NR_utimensat: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct timespec *tsp, ts[2]; if (!arg3) { @@ -12239,7 +12239,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch) case TARGET_NR_inotify_add_watch: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { goto efault; @@ -12252,7 +12252,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch) case TARGET_NR_inotify_rm_watch: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(sys_inotify_rm_watch(arg1, arg2)); #endif @@ -12353,7 +12353,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_tee case TARGET_NR_tee: if (is_hostfd(arg1) || is_hostfd(arg2)) { - goto ebadf; + return -TARGET_EBADF; } else { ret = get_errno(tee(arg1,arg2,arg3,arg4)); } @@ -12362,7 +12362,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_splice case TARGET_NR_splice: if (is_hostfd(arg1) || is_hostfd(arg3)) { - goto ebadf; + return -TARGET_EBADF; } else { loff_t loff_in, loff_out; loff_t *ploff_in = NULL, *ploff_out = NULL; @@ -12395,7 +12395,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_vmsplice case TARGET_NR_vmsplice: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); if (vec != NULL) { @@ -12438,7 +12438,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) case TARGET_NR_fallocate: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if TARGET_ABI_BITS == 32 ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4), @@ -12452,7 +12452,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_sync_file_range) case TARGET_NR_sync_file_range: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if TARGET_ABI_BITS == 32 #if defined(TARGET_MIPS) @@ -12471,7 +12471,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_sync_file_range2: /* This is like sync_file_range but the arguments are reordered */ if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } #if TARGET_ABI_BITS == 32 ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4), @@ -12485,14 +12485,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_signalfd4) case TARGET_NR_signalfd4: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_signalfd4(arg1, arg2, arg4); #endif #if defined(TARGET_NR_signalfd) case TARGET_NR_signalfd: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return do_signalfd4(arg1, arg2, 0); #endif @@ -12512,7 +12512,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, struct epoll_event *epp = 0; if (is_hostfd(arg1) || is_hostfd(arg3)) { - goto ebadf; + return -TARGET_EBADF; } if (arg4) { struct target_epoll_event *target_ep; @@ -12547,7 +12547,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, int timeout = arg4; if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) { return -TARGET_EINVAL; @@ -12819,7 +12819,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_gettime: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct itimerspec its_curr; @@ -12835,7 +12835,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD) case TARGET_NR_timerfd_settime: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } else { struct itimerspec its_new, its_old, *p_new; @@ -12870,7 +12870,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS) case TARGET_NR_setns: if (is_hostfd(arg1)) { - goto ebadf; + return -TARGET_EBADF; } return get_errno(setns(arg1, arg2)); #endif @@ -12896,9 +12896,6 @@ fail: efault: ret = -TARGET_EFAULT; goto fail; -ebadf: - ret = -TARGET_EBADF; - goto fail; } abi_long do_syscall(void *cpu_env, int num, abi_long arg1, From patchwork Fri Jun 1 07:30: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: 137474 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp613105lji; Fri, 1 Jun 2018 00:44:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5+iRuwDKfHhudaoJZeF2nNMTngkCiyml7WyyOdFqTmDjRzmTcHgE32Iwe6SxrBu6IFLUz X-Received: by 2002:a37:7d1:: with SMTP id 200-v6mr9443521qkh.393.1527839069267; Fri, 01 Jun 2018 00:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839069; cv=none; d=google.com; s=arc-20160816; b=hpaIG+eQvWpj9wBbHHSbjQv9Bg3x7iyxTjVKigfPY5uJpw6Td30qXfmDbY4hQTQ7OO gJ96u8Mx6xBKOAch2OZHNbyptjn/nRy42wgGAc8LDCnsfrZcrhkMp80QLBhfwLgTLywj 8jXOqeThEOaxk/T15TCBZSjxp+QarUxQnKI7UhruXctaz0nDARdBHzq1u8YexlwiNHYY RLdK/4vEyZefHzk/htSgtTP6ALUNYkVp9l5gthfh4foOTWesxisQwnf0oNNsn67oWYom Scrx2Yhi4gKdFp983pvNF5IrBnrqjjTpX8F6AKw6kThYMHk6yRowxwyxa8c8YU2RcCh+ nsmQ== 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=Sv/HXj68hxiSd+sV+uqvHUEuE9od2GX61pGLxEHOfW8=; b=HxeIm+9nvfQGGr61w5qrAxC98YdK8Z2rwDlerI410Bta80JfMQtOu+um24BrZRWlwd smOJhLmjNQY1MwKZMx93DOk5V+i9wBRYY7UBG302jYhxQl9/iSSvqRJRmIc4QBhEeMhB sI1PjndqBwYU3jyQX9z4hr1u3PhVkkH0eihj352Urk+nADn0CqkyvJhTIZBAw9gUOMGK L+o6liRdnHCLQGOnb+Eyetb/fNHwzcTgTsb48Z3uxRdv9tqR1OfkNCBuHZfrONxKIp3s EGtVKi4agm4LBPvN3MQRgfnpmMRy0QhJBI9/FmMp8s1I7zuiWoLQneDEnAbqgCi07WA+ gzUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ka1cDKN9; 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 k189-v6si1898456qkf.39.2018.06.01.00.44.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:44: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=ka1cDKN9; 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]:47879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOejc-0007Ve-HY for patch@linaro.org; Fri, 01 Jun 2018 03:44:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWg-0005Qo-1A for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWb-0000Gi-Cl for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:06 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:43950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWa-0000Fg-UL for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:01 -0400 Received: by mail-pl0-x243.google.com with SMTP id c41-v6so14803208plj.10 for ; Fri, 01 Jun 2018 00:31: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=Sv/HXj68hxiSd+sV+uqvHUEuE9od2GX61pGLxEHOfW8=; b=ka1cDKN9HgqwvlPwpXvaQ6tEAssY60qL6UjpxNdah79UiIxDChxaoKgFD2JsLj9jUp B2W+meNTAjzXg5GKa3UjEyLg71bUknTO16u7ZViArixOKpqt69iFkknxYQGFz2WI8mVG pINXvP0IvG+cD3KN+aQiXdkZ8/fc5nLz0cOx8= 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=Sv/HXj68hxiSd+sV+uqvHUEuE9od2GX61pGLxEHOfW8=; b=LfVfQFJpAp30yWf4wbr/a3FKZphT2RqT4zVucS+C8bIgQIUzCvI6hxEXer9CPnKNZx CeutvNprz6GYdVPUzUsw8C7WszH4nElbhsYZaX6GucPwJ/R/PxsePnUgrrrhNEbyQ3BU eCqUg8NTUbQnAAQcXyplFA9GiRfxHAQma2E18OqUYOv/oMVD5lxpug763XJ4EaWhdn9H slzyfEkAFN2Kzce9PZ8sRh0jSmkdBcnGlZogWfnETbGkhF+fJHPCDwwtTAMwA9eDIWaA MWCYeWodHnrJPmu5RbpE9VROZ+U5dR5mJhuwW3AZCef5aYMoQw+qZLU8OPYjlIxVrDqj PDgg== X-Gm-Message-State: ALKqPwc24VOMv/B17pSO0INUYXeZ3t1pMkUES3zX7UWISoxgLUfeoOcB n3GESj0v3schFEFI8bbejaMeNKNXgOs= X-Received: by 2002:a17:902:a508:: with SMTP id s8-v6mr1513017plq.223.1527838259104; Fri, 01 Jun 2018 00:30:59 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.30.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:30:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:21 -0700 Message-Id: <20180601073050.8054-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 04/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 311 +++++++++++++++++++++---------------------- 1 file changed, 154 insertions(+), 157 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d0bf650c62..8ea2099001 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8028,7 +8028,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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)) { @@ -8042,7 +8042,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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); @@ -8060,7 +8060,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)); @@ -8073,7 +8073,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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)); @@ -8117,7 +8117,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 @@ -8129,7 +8129,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)); } @@ -8139,7 +8139,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); @@ -8167,7 +8167,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { void * p2 = NULL; if (!arg2 || !arg4) - goto efault; + return -TARGET_EFAULT; p = lock_user_string(arg2); p2 = lock_user_string(arg4); if (!p || !p2) @@ -8182,7 +8182,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; @@ -8193,7 +8193,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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; @@ -8213,7 +8213,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++; @@ -8222,7 +8222,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++; @@ -8297,7 +8297,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; @@ -8309,14 +8309,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; @@ -8327,7 +8327,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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; @@ -8335,7 +8335,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; @@ -8371,7 +8371,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; @@ -8382,7 +8382,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) { @@ -8392,7 +8392,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; @@ -8421,7 +8421,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; @@ -8431,7 +8431,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 @@ -8459,7 +8459,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); @@ -8468,7 +8468,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); } @@ -8482,13 +8482,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); } @@ -8504,13 +8504,13 @@ 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 (!(fn = lock_user_string(arg2))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, futimesat(interp_dirfd, fn + 1, tvp), @@ -8531,7 +8531,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_access case TARGET_NR_access: if (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, faccessat(interp_dirfd, fn + 1, arg2, 0), @@ -8546,7 +8546,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, faccessat(interp_dirfd, fn + 1, arg3, 0), @@ -8625,7 +8625,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; @@ -8636,7 +8636,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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; @@ -8644,7 +8644,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; @@ -8675,7 +8675,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)); @@ -8698,7 +8698,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(acct(NULL)); } else { if (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_PATH(ret, fn, acct(fn)); ret = get_errno(ret); @@ -8708,7 +8708,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; @@ -8741,7 +8741,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; @@ -8797,7 +8797,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; @@ -8808,7 +8808,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; @@ -8819,7 +8819,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; @@ -8833,7 +8833,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]; @@ -8847,7 +8847,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; @@ -8863,7 +8863,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; @@ -8893,7 +8893,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; @@ -8904,7 +8904,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; @@ -8925,7 +8925,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; @@ -9027,7 +9027,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; @@ -9038,7 +9038,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)); } @@ -9071,7 +9071,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; @@ -9082,7 +9082,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)); } @@ -9095,7 +9095,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)); } @@ -9118,7 +9118,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)); } @@ -9133,7 +9133,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 @@ -9153,7 +9153,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, @@ -9174,7 +9174,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) { @@ -9190,7 +9190,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)); @@ -9205,7 +9205,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); @@ -9218,7 +9218,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); @@ -9242,7 +9242,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; @@ -9252,7 +9252,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); @@ -9267,7 +9267,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); @@ -9289,7 +9289,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; @@ -9300,14 +9300,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; } @@ -9379,7 +9379,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 { @@ -9393,7 +9393,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]); @@ -9409,7 +9409,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); @@ -9425,14 +9425,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; @@ -9541,7 +9541,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; @@ -9551,7 +9551,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); @@ -9573,7 +9573,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]); @@ -9654,7 +9654,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; @@ -9674,7 +9674,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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; @@ -9703,7 +9703,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_statfs: if (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_PATH(ret, fn, statfs(fn, &stfs)); ret = get_errno(ret); @@ -9713,7 +9713,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); @@ -9743,7 +9743,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_statfs64 case TARGET_NR_statfs64: if (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_PATH(ret, fn, statfs(fn, &stfs)); ret = get_errno(ret); @@ -9753,7 +9753,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); @@ -9905,7 +9905,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); @@ -9977,7 +9977,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; } @@ -9987,7 +9987,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; @@ -10001,14 +10001,14 @@ 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 (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, fstatat(interp_dirfd, fn + 1, &st, 0), @@ -10020,7 +10020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_lstat case TARGET_NR_lstat: if (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, fstatat(interp_dirfd, fn + 1, &st, AT_SYMLINK_NOFOLLOW), @@ -10041,7 +10041,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); @@ -10095,7 +10095,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); @@ -10109,7 +10109,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; @@ -10122,7 +10122,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]); @@ -10222,7 +10222,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; @@ -10232,7 +10232,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 @@ -10262,12 +10262,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; } } } @@ -10278,12 +10278,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; } } } @@ -10338,7 +10338,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; @@ -10372,7 +10372,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; @@ -10400,7 +10400,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; @@ -10429,7 +10429,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)) { @@ -10486,7 +10486,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; @@ -10535,7 +10535,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; } ret = 0; @@ -10565,7 +10565,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; @@ -10580,7 +10580,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 { @@ -10748,7 +10748,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; } } } @@ -10785,10 +10785,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; @@ -10801,7 +10801,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)); @@ -10817,7 +10817,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); } @@ -10831,7 +10831,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)); @@ -10879,7 +10879,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; } @@ -10888,7 +10888,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)); @@ -10899,7 +10899,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)); @@ -10962,7 +10962,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; @@ -10975,14 +10975,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; @@ -10998,7 +10998,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); @@ -11018,7 +11018,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) { @@ -11142,7 +11142,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); @@ -11153,7 +11153,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; @@ -11168,7 +11168,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: if (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, fstatat(interp_dirfd, fn + 1, &st, 0), @@ -11182,7 +11182,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_lstat64 case TARGET_NR_lstat64: if (!(fn = lock_user_string(arg1))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, fstatat(interp_dirfd, fn + 1, &st, AT_SYMLINK_NOFOLLOW), @@ -11214,7 +11214,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, fstatat(interp_dirfd, fn + 1, &st, arg4), @@ -11228,7 +11228,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; @@ -11267,7 +11267,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)); @@ -11302,7 +11302,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } 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); @@ -11323,7 +11323,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; @@ -11343,7 +11343,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; @@ -11351,7 +11351,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; @@ -11368,7 +11368,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; @@ -11419,7 +11419,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; @@ -11446,7 +11446,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; @@ -11473,7 +11473,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); @@ -11645,7 +11645,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; @@ -11663,7 +11663,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; @@ -11671,7 +11671,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; @@ -12204,7 +12204,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 (!(fn = lock_user_string(arg2))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_FD(ret, fn, sys_utimensat(interp_dirfd, fn + 1, tsp, arg4), @@ -12242,7 +12242,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return -TARGET_EBADF; } if (!(fn = lock_user_string(arg2))) { - goto efault; + return -TARGET_EFAULT; } TRY_INTERP_PATH(ret, fn, sys_inotify_add_watch(arg1, fn, arg3)); ret = get_errno(ret); @@ -12268,13 +12268,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); @@ -12368,25 +12368,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; } } } @@ -12517,7 +12517,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, @@ -12556,7 +12556,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); @@ -12628,7 +12628,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); @@ -12639,7 +12639,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); @@ -12717,7 +12717,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; } } } @@ -12741,12 +12741,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; @@ -12826,7 +12826,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; @@ -12841,7 +12841,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 { @@ -12851,7 +12851,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; @@ -12893,9 +12893,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 Fri Jun 1 07:30: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: 137461 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp603342lji; Fri, 1 Jun 2018 00:31:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCeLs+n7pOA4pb/Rk86Znm3WNhKw7kLKUvWPSmTyVJz4TRzxhXcFCSPTAd4FXYMg5FxGAL X-Received: by 2002:ac8:92c:: with SMTP id t41-v6mr10182248qth.292.1527838297850; Fri, 01 Jun 2018 00:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838297; cv=none; d=google.com; s=arc-20160816; b=yGInulWLcbhLRwKLL0QCyDP5pT+4TD5jx238JjaJlupXFXwYKPdenCVZ4OIUeEmkSK 9NTl0fc9h6Lga9x6Ytr7xkdOh9ax71b4tVbeqjOIZcrjlVlGnkKOcoXTzZzxxrPl4KhS /NOoHa0/iG08rm0BLJ0Oge4sUBksUf+PfQBCGW3DiraO9YUsbXgN9Rg3drnn47qt+kw4 /zGvwaF25pTXsLrIRx2C436GXw9qifvKRo8lENsRqPXlKuk9HPD/NoLDQgKvBJS/iTAg 3YvlHeex1GmEvag/c4BFQd8I9jD/5z/0PwGcIXIjEL0EIqq34thVv+te4t1N8r5v6WHi J14g== 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=5v7tsPOalOaMv3UFLZQO/mNC/DMMo/KuC3MiFTwGPDU=; b=0i7iSB9MHN9hk+QDqhfrEmSICMkK15g5Xt4qLg01zy+LqmEMDetlglG2IinKM/nGFx S8EASbd8bUr1/1cV3t0wBEDe9KSRwny1Wrda7KVjeTVQ4HxZPzCIoFeRnPbq75JjtNm0 7ONPd2DO/slhzuIligf60hkVNszhS7E+Qxr8G3RHVD6KGXJgNwa8eC2rRElk1ICkt/Z/ ecs4LAUfob7vTvRIcgLvPvkfeS/wwruj1Mz39I9vZK6kbJFvXr16Di97Qt/0XJk3q/qC XMTwrjegGbIGbiMYpb94ftAvxB191FtDgRCjMlrr0bTZAsHOar/u8IrDVATLVR3nRlvX iiyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TKUR0y/7; 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 62-v6si5961602qvc.255.2018.06.01.00.31.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:31: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=TKUR0y/7; 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]:47810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXB-0005T5-6p for patch@linaro.org; Fri, 01 Jun 2018 03:31:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWd-0005PZ-5a for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWc-0000HT-3u for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:03 -0400 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:43316) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWb-0000Gg-TQ for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:02 -0400 Received: by mail-pf0-x22b.google.com with SMTP id j20-v6so12076532pff.10 for ; Fri, 01 Jun 2018 00:31: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=5v7tsPOalOaMv3UFLZQO/mNC/DMMo/KuC3MiFTwGPDU=; b=TKUR0y/7EfIIvvNMCnS62jlEld1Ay+B85SH/N6n39ep8C9HZBNJJh4Z6ckQ6HQgvoU uK76E6QAVGd3kRSXb3KtvfA3Wnu8FPXWoEy+gNUUkKhnT0hfxdihnYOVTLKmkCIS2glr Yb5UIb8xmu16we4d5yns9kmpY4VcNFMeOxa2o= 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=5v7tsPOalOaMv3UFLZQO/mNC/DMMo/KuC3MiFTwGPDU=; b=aZv4rLAr8ZTuC73g68AVFeJTP9vMc2/7gEFwu/vB/ntybVAUykCwc5WgfCADYX3CBc LxVZTAiXnZoU496x5AHgoOYdR80Tn7jQBYxVLVaP1E5QkE+zjzbGQquD5iDcz8PpK19K oFW7iTPQpcFZ8ND8Fvpy8bFxw6DM/MW0iFxNRK9sfufpFw3/UEslReohxJEonu8tOlJR dAl9k+BZW5vy5I82akNR6OXY/fHUNltwEfkmdH6qFXgFZ/f6cpFRdAAHAipcfnryyZpP JYTj72VClwqzSyRVjpa4sjAthUW5ulTRVZDYGC4ptxhgqB+kzpRQTBfzgoFDFQ6Nha1M ahEg== X-Gm-Message-State: ALKqPwe3p/6APpA26EP7iGTqL38xY6FQSx8KyY+Ql664ZfPuMtRb0M3G vWbwfhJQbdusNjAnvCpJzGzeVxiXejk= X-Received: by 2002:a62:249b:: with SMTP id k27-v6mr9853797pfk.143.1527838260587; Fri, 01 Jun 2018 00:31:00 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.30.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:30:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:22 -0700 Message-Id: <20180601073050.8054-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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::22b Subject: [Qemu-devel] [PATCH 05/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8ea2099001..f7b7051c1c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -12081,7 +12081,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 @@ -12094,12 +12094,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 @@ -12184,7 +12184,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) @@ -12886,9 +12886,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 Fri Jun 1 07:30: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: 137468 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp609335lji; Fri, 1 Jun 2018 00:39:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLi8PXJzCODWZGkgSuAX3W6sXyF74NB8uqvW95VvHId7SJVR8Zig67W9UsckhA7WRXODsYr X-Received: by 2002:a0c:cb13:: with SMTP id o19-v6mr9295243qvk.216.1527838749393; Fri, 01 Jun 2018 00:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838749; cv=none; d=google.com; s=arc-20160816; b=g3SUsfYMqdkMzrnoukHNu4jGdh7Ao/00cdmsfUZk87g6FOYAYx740YceipNxlj4WpU ilU4h8+edTJr9QRCOFnOZn18h2xYyn6PnlfrNcK8SaTj7Dvw2s/pU0qMGKa7E8+oiMqI Vx+U9ar3jh3McIOf97TalqhpiTzCzgp80AYIHNV8N14CpLNam9tJYISCJMUF7O72FZbd d91Lu9QMUQlDmulsxkfBrqKVQv3hflHX/boAAWU2+IMiDpLNABmk+gdKGo+5lfKEg2Gv AH+xs2i1XeA7RDg8jbb7l66k9/avh7/jHGiYSzzNS3kthYSXCM5BEylH41G44JZU+LCN oAGQ== 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=+VLu9ud8UPCypio6yV1SHgwWP7XnngZ6wMGL8Wb+pgk=; b=gJ7ESP46iJTineE3v5oAszQW4SFq8p+Nd7Iaqjht4giGQRpv8Y+JvQVIbwDrZV1YT8 tf6Cszdb7/qHn1A/KhW0b549G1U230wsN3yyOA0b5JpPOSHxFHo9F32VKWwnXP4pu2gk VOfoVHXeZffUFIkaZKqc8D1RUsLKsFkqPCB7vnCsdhktcsc7OoQNlZilQ43/xEQfcLIQ iMiYE8bsSMU8DY8f/dZSa3asF3khJQUgPFT+9UJcv4lp11uOA22uvqg9AiWMnbvbijyn YMcJpkMbqy1ieq17mAz9ba6si08qkiyXg1ZPO1jmgmCz5SzAfVoV49hnJcIrznvL8kbH rk5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ud0Rv9cY; 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 i44-v6si841136qte.148.2018.06.01.00.39.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:39: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=Ud0Rv9cY; 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]:47846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeeS-0002ch-PB for patch@linaro.org; Fri, 01 Jun 2018 03:39:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWi-0005Sf-Ek for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWe-0000JR-G8 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:08 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:42873) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWe-0000Iw-8S for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:04 -0400 Received: by mail-pg0-x241.google.com with SMTP id p9-v6so10862763pgc.9 for ; Fri, 01 Jun 2018 00:31: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=+VLu9ud8UPCypio6yV1SHgwWP7XnngZ6wMGL8Wb+pgk=; b=Ud0Rv9cYi6IsLu+XwXmjwbarkWjxyOqMVhORg1/DNSymDiA0NVLBLy/KdKGz8o5V9m NCwBMIk5EkF5Z5qI4IN11htsJe9VA+pvIHwx+ye3OxFhIsRPlmNZPuWKC3tgV8f7105a cBO/Fung+3yGKGfEfRZ+bOV3lrdDjUmdNReYg= 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=+VLu9ud8UPCypio6yV1SHgwWP7XnngZ6wMGL8Wb+pgk=; b=Ke2PQXZeHrVRrl+LTMCv0efopmYjpo781Qc3MKTcUhZE3wstT8zGkJ4pJN5xWSkmbp +XkYKau8EuLp5dEM7lCyCT5wTUJiAmQGE7hpK1O2BvvSzH5sSpQTOy+2oRwGv8lh1mHx TFzFoUbcTb76MjEqW7i46T45aFBEUO2HpEzsUxbJ6bvC/4fAys021jtOCXsa4bBhBMbn xsjDmzU78ofVFXq6316cTfjBBfW7REIuQlgQ7rhfWwlN8Kj1X+z2AsEKO9zrJMhpyZZM DXYHVDEsyTE9KEXOGEMMKU9FHZSCoFhtrTkdamYxDFz1ekPzEf1mVT+lYsarWNBW+8pe ydUw== X-Gm-Message-State: ALKqPwejsCn0F3zfoAUEQzvblxMgOfUjvXVm1yrjCt1rO3g4RihzDLOR M6aBRHchu5a/Tc2TWO5ya74Y8wkWZvE= X-Received: by 2002:a62:b509:: with SMTP id y9-v6mr7557972pfe.121.1527838262170; Fri, 01 Jun 2018 00:31:02 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:23 -0700 Message-Id: <20180601073050.8054-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 06/33] linux-user: Split out goto unimplemented to do_unimplemented 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, 43 insertions(+), 39 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f7b7051c1c..4269ec2c23 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7962,6 +7962,12 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask, return 0; } +static abi_long do_unimplemented(int num) +{ + gemu_log("qemu: Unsupported syscall: %d\n", num); + return -TARGET_ENOSYS; +} + /* 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. @@ -8342,11 +8348,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_break case TARGET_NR_break: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_oldstat case TARGET_NR_oldstat: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_lseek: if (is_hostfd(arg1)) { @@ -8436,14 +8442,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } #endif case TARGET_NR_ptrace: - goto unimplemented; + return do_unimplemented(num); #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; + return do_unimplemented(num); #endif #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: @@ -8522,11 +8528,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_stty case TARGET_NR_stty: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_gtty case TARGET_NR_gtty: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_access case TARGET_NR_access: @@ -8561,7 +8567,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_ftime case TARGET_NR_ftime: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_sync: sync(); @@ -8687,11 +8693,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; #ifdef TARGET_NR_prof case TARGET_NR_prof: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_signal case TARGET_NR_signal: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_acct: if (arg1 == 0) { @@ -8715,7 +8721,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_lock case TARGET_NR_lock: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_ioctl: return do_ioctl(arg1, arg2, arg3); @@ -8725,17 +8731,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_mpx case TARGET_NR_mpx: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_setpgid: return get_errno(setpgid(arg1, arg2)); #ifdef TARGET_NR_ulimit case TARGET_NR_ulimit: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_oldolduname case TARGET_NR_oldolduname: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_umask: return get_errno(umask(arg1)); @@ -8747,7 +8753,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; #ifdef TARGET_NR_ustat case TARGET_NR_ustat: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_dup2 case TARGET_NR_dup2: @@ -9471,7 +9477,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_oldlstat case TARGET_NR_oldlstat: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_readlink case TARGET_NR_readlink: @@ -9536,7 +9542,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_uselib case TARGET_NR_uselib: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: @@ -9561,7 +9567,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; #ifdef TARGET_NR_readdir case TARGET_NR_readdir: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: @@ -9699,7 +9705,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(setpriority(arg1, arg2, arg3)); #ifdef TARGET_NR_profil case TARGET_NR_profil: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_statfs: if (!(fn = lock_user_string(arg1))) { @@ -9778,7 +9784,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_ioperm case TARGET_NR_ioperm: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: @@ -10062,17 +10068,17 @@ 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; + return do_unimplemented(num); #endif #ifdef TARGET_NR_iopl case TARGET_NR_iopl: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_vhangup: return get_errno(vhangup()); #ifdef TARGET_NR_idle case TARGET_NR_idle: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: @@ -10252,7 +10258,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return do_modify_ldt(cpu_env, arg1, arg2, arg3); #if !defined(TARGET_X86_64) case TARGET_NR_vm86old: - goto unimplemented; + return do_unimplemented(num); case TARGET_NR_vm86: return do_vm86(cpu_env, arg1, arg2); #endif @@ -10297,9 +10303,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_get_kernel_syms case TARGET_NR_get_kernel_syms: #endif - goto unimplemented; + return do_unimplemented(num); case TARGET_NR_quotactl: - goto unimplemented; + return do_unimplemented(num); case TARGET_NR_getpgid: return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: @@ -10309,17 +10315,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return get_errno(fchdir(arg1)); #ifdef TARGET_NR_bdflush /* not on x86_64 */ case TARGET_NR_bdflush: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_sysfs case TARGET_NR_sysfs: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_personality: return get_errno(personality(arg1)); #ifdef TARGET_NR_afs_syscall case TARGET_NR_afs_syscall: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR__llseek /* Not on alpha */ case TARGET_NR__llseek: @@ -10865,11 +10871,11 @@ 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; + return do_unimplemented(num); #endif #ifdef TARGET_NR_nfsservctl case TARGET_NR_nfsservctl: - goto unimplemented; + return do_unimplemented(num); #endif case TARGET_NR_prctl: switch (arg1) { @@ -10949,7 +10955,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; + return do_unimplemented(num); #endif #endif #ifdef TARGET_NR_pread64 @@ -11116,16 +11122,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_sendfile64 case TARGET_NR_sendfile64: #endif - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_getpmsg case TARGET_NR_getpmsg: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_putpmsg case TARGET_NR_putpmsg: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: @@ -11694,7 +11700,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_pivot_root: - goto unimplemented; + return do_unimplemented(num); #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { @@ -11869,7 +11875,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_security case TARGET_NR_security: - goto unimplemented; + return do_unimplemented(num); #endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: @@ -12884,9 +12890,7 @@ 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; + return do_unimplemented(num); } fail: return ret; From patchwork Fri Jun 1 07:30: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: 137465 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp606142lji; Fri, 1 Jun 2018 00:35:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJY05qEeZY/O5+4h9snF+dgvOOA0qObEvdr75dWdRjJvEfzLsPJVjZd3+U6mcV36FaT8IIr X-Received: by 2002:a37:8202:: with SMTP id e2-v6mr9066608qkd.443.1527838500494; Fri, 01 Jun 2018 00:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838500; cv=none; d=google.com; s=arc-20160816; b=vCBUHBST4YwJkPDlYQbUhMzgY6mWYxmIxPxwBEo6jUHlhMXOvXHYZ4eEuvQFql6PZT ewOMHtrqoB2FGLP7LCBnvTaERvzkZkEdJct9NQ5py2zLON0U3XqZ4iP5WD8KLTy/TLLK bB2Sq4w6VV4xu9C+9TnQecs1tipj5922KKMPTx5h62uWuMjaOz68NPcKHknD6EnD70wE 8DcndjXwBsWm2mGdeM3Aa+LPkFf2ua+2pv8oK4m9vUUqTj/4DePB205TOztEecEbCFNv HVcuvKM9k0nZSIdBhVqgURUR/ZSTUfN0VAXpiHjuQgHLE5M7fiBP2Vr4CIhPOIvpEW48 TA5g== 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=JPDnsWlYy9UfPdOsrq8gRR1ypAHP3lXh1lxw9PWYk6Y=; b=aWl8x06HutQqYX7aa+Ia2FNpn0qsK+sqgsx3vcYEnfDOI5JFpUbf3ZXfMc5skBm6yb u6Z+hifQFVm7k9aIjXYi4ruQbIcVhaZy8VR2kJcNBmS4sNjCn1Wg/hbzgrhg2rSJ2QGx 1zVF++nDN1i06Ntigp/z/5xsL7vsBb8Zu2Kj/EkSN174ZoSzaHh1PBXfm/8WUd9LUJDv sUU/Rx84CrH4uovIQTEUXPU7DKe3xlrU6OKvRWaoaesha0CvMNUCDwnCPvPG0d7i47p/ frFjMtjLemMS2R2Sr+ZtafsRHf8nN8urGzyRPU1SMnX2mcZQ1igb/Lf4ooRohO4avmi4 NXqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MbVVW7DO; 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 d14-v6si2709873qtb.70.2018.06.01.00.35.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:35:00 -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=MbVVW7DO; 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]:47823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeaR-0007vG-U3 for patch@linaro.org; Fri, 01 Jun 2018 03:34:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWi-0005Si-Fw for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWf-0000Jq-1S for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:08 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:39728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWe-0000JJ-Q8 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:04 -0400 Received: by mail-pg0-x244.google.com with SMTP id w12-v6so9663034pgc.6 for ; Fri, 01 Jun 2018 00:31: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=JPDnsWlYy9UfPdOsrq8gRR1ypAHP3lXh1lxw9PWYk6Y=; b=MbVVW7DOX2TKxXhsDjQIQ1iY8ekvSvVo0tEtZ9jLWOuIhTi/Qm4fwEju4mANbaJty2 zVe1XKliwGZyAng/eEroJj1MkJxPiMtfxbH8BRmIKaevsOC4bwzt9tf9uTFeFpvdjBkQ rKJ3YUA8lAlMbxUED5PErG4q0Qt8585xe+gRM= 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=JPDnsWlYy9UfPdOsrq8gRR1ypAHP3lXh1lxw9PWYk6Y=; b=XNyA4yH12khLtyZtmSe0lAk6jpWvxloABvH1GOUGhV0JgNWlmrzRHyhM+TQt/7iqn2 lWCFAaWUHpliO1zH2KuMKoBlWXqw+7HjaXfsQgb7UiutfjcNHnjfpocisUUULIyGYRS2 LzzBHE2Nz1nWhDwQBHJTFdJJygdXemkmO36ghS4DnHUDN1Ry4gUrSuZubTNXFjy7qMIq 9dtxkXFUhUqJpENxhKA/XNDBbu9+dC6/lEv8oGzQqugM70/m+dj6iqh1zOJmUyTTLGyF buPOm2O0ynO6uw/c8XplHO+OGIoGRGVPT/BLfrVESGTcudMdcJ66Mvw4SjaQDkN3egVc ctgQ== X-Gm-Message-State: ALKqPwdFgv0Vf8/RUNI4h64rl0nK4nrsSR1ptXEmO6BB8tj7GwQM2fw8 kYNS1fS2lXEbjhN7BWLYYuxSRV8J+rY= X-Received: by 2002:a62:a30e:: with SMTP id s14-v6mr9641176pfe.168.1527838263495; Fri, 01 Jun 2018 00:31:03 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:24 -0700 Message-Id: <20180601073050.8054-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 07/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 62 ++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4269ec2c23..a413aad658 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9001,8 +9001,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); @@ -9029,8 +9028,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; @@ -9073,8 +9071,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; @@ -9363,15 +9360,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; } if (contains_hostfd(&rfds) || contains_hostfd(&wfds) || @@ -9409,8 +9406,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); @@ -9951,18 +9947,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; } - ret = 0; if (len == 0) { - return ret; + 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); @@ -10363,8 +10356,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)); @@ -10556,7 +10548,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (ret < 0) { unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds); - goto fail; + return ret; } } @@ -10788,7 +10780,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; @@ -11290,8 +11282,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])); @@ -11552,8 +11543,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); @@ -11601,8 +11591,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]); @@ -11622,8 +11611,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]); @@ -11704,20 +11692,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; @@ -12892,7 +12877,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, default: return do_unimplemented(num); } -fail: return ret; } From patchwork Fri Jun 1 07:30: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: 137463 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp605764lji; Fri, 1 Jun 2018 00:34:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIvOVitV2B8eIJYMEez4tluYtjeGfZKLhWhUqClP2XNYXxOpZPbpahcsuiIX5WR36yP33Ry X-Received: by 2002:a37:c5cb:: with SMTP id k72-v6mr9465387qkl.316.1527838469567; Fri, 01 Jun 2018 00:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838469; cv=none; d=google.com; s=arc-20160816; b=RHzzU7pjdRD367wvxKwjE8KbJJ0JYgKSzqGTlitlDwTIXo0iZsXO4xV600DfEmkPNf LtTQG/9GNAGtl7bqjXHTjshLYk+LkuuFuVDDclGMmElVy87Mxc8N0aVt+Ur1toOgNeO1 5rrmKbhdUIDq2V/pWbAjQvf6S2ZxQF29W+gv51tRy/7K/XI8LA+vnOg/XwDxYHCJzW0d zQiOMNoy9B47eBxOWU8JkzZQPZTvGFVhoPZX/mdh79m6wBEG8Mpxp5BxGlKuAWPqrXnM szbpwJPQr2XOIdkzNxw5vz/9QjEtgs/YFGDkSxhdV2pueo/77mcwLSIXoqMOZwgbt0qV DkWw== 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=wxqnj7D2GYVj34jO4GIckTq9Mg+xYbuJxEbNpwXMqhU=; b=hGyckeeaina/qz/Oc8KmkaD8a6co6nWlj80j3b2qIXgNPn5TForY9MgP17X6uHiSSS JCccJNz/ft+bBER/EpNGbjTHWuEeZMlJRyE1Cw3p8aeGrfx8kJMI1dzpxcUkhetN4CZ3 DpTWhXfbE8gX1ydmQ11B+S/+/XQUkHIGuHUL38177hs1g5cTwRJMXiNn3p9W57yShBfa IboMHEbGHVSRDa9g4JbwJqXhAViVKzSZzmnlyukULi7CGTMT2Ti/gIH3+UJr7IYk0hTg sKBZEHFnZkr1qFfTaReREttX7SLF6NQw2yFFVHi6zKP4yEhNC5BJX3s/KVB1oWE/6/Is QRig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XX4MCZpp; 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 d19-v6si98210qka.202.2018.06.01.00.34.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:34: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=XX4MCZpp; 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]:47816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeZw-0006j7-Uo for patch@linaro.org; Fri, 01 Jun 2018 03:34:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWi-0005Sh-FM for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWg-0000LO-AC for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:08 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:47103) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWg-0000Kc-5G for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:06 -0400 Received: by mail-pl0-x243.google.com with SMTP id 30-v6so14801187pld.13 for ; Fri, 01 Jun 2018 00:31: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=wxqnj7D2GYVj34jO4GIckTq9Mg+xYbuJxEbNpwXMqhU=; b=XX4MCZpp8GokcVV8z64X9iaD/qELL3lfH6EejcDWREnlCJESOp0NO/kE6hPM1j9Xe5 6AX3uvaKjpWrdTlelIbiAnVP0EJm9jS822C4RCTifRhYV8bbCCSc6InQ91JBBu3nqFh+ DigxfcZXoJqF2owUSK5/Ey2KoPpcVoJDUo6AY= 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=wxqnj7D2GYVj34jO4GIckTq9Mg+xYbuJxEbNpwXMqhU=; b=sDRig5IAwRfI+HsT6tTEbrTY28ZJAGSgg/xW2k0/WgWINwysZT1YdP3dWIcbD4062X 2O56w4vGjG2SIpqGvn7SwU5O/zf9fGLKMRrsohAo/gU2Yi2LpXm1kdPlkcpTSCLHldE/ xy18KEe381JMM0+Brt/xLuZqkEcI8An4LVZ74pS6zh+U9Xyu+cppa9wjWiWOJXnqwVLb 0bMDVXi/H964uTq9xR8vapgBWnZDDcBmi39SbCMlAQpJXu2SGXj+r4NDJF7uMmli/qIm 544bK+Yb6HOs7ggzZ7cOoYO6Gyh5gBVpbkeRBtnjUDKGThOr3anAHZA58tgqND8ngo8Z Ok9g== X-Gm-Message-State: ALKqPwdPVbPwmcnXC6HWvCj2cNptvNHbIe7nU7vNfr0C0r5RW72CwRk+ GM5ox7KrgM3gUYWJxNf0ZPnfgTeHnX0= X-Received: by 2002:a17:902:422:: with SMTP id 31-v6mr10336786ple.320.1527838264880; Fri, 01 Jun 2018 00:31:04 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:25 -0700 Message-Id: <20180601073050.8054-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 08/33] 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" Signed-off-by: Richard Henderson --- linux-user/qemu.h | 2 +- linux-user/syscall.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 05a82a3628..623a8d8b7a 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -231,7 +231,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 a413aad658..e2e2d58e84 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 @@ -7962,9 +7962,9 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask, return 0; } -static abi_long do_unimplemented(int num) +static abi_long do_unimplemented(unsigned num) { - gemu_log("qemu: Unsupported syscall: %d\n", num); + gemu_log("qemu: Unsupported syscall: %u\n", num); return -TARGET_ENOSYS; } @@ -7973,7 +7973,7 @@ static abi_long do_unimplemented(int num) * 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) @@ -12880,7 +12880,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 Fri Jun 1 07:30: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: 137467 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp606385lji; Fri, 1 Jun 2018 00:35:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpbAEPyrtzLw2NFblDODWet39JdHfT9JTnwchiPDdR6dyJYZHmJS4GGA0nT6cFePQpU3XY X-Received: by 2002:a0c:9aed:: with SMTP id k45-v6mr9307506qvf.68.1527838518178; Fri, 01 Jun 2018 00:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838518; cv=none; d=google.com; s=arc-20160816; b=Qp10i3mPidVT6ajxBNpPAFGYoWD8tyBuLXgr1tnj74Qncf5xztLnD1dLNLNQFc1PYm DNGKWc2GwfVqqN2eyPcDiwFEXFtq1ZTwojMtEbDYX6/6gKwJZrSlq/17jlSa0Eiu5rFJ 3k5sI6wRQTI+nYwppkgLkWxhg3sjtqeBUX6ExlTSLS5hEFkuy/zDy4FAVQnMAle5cuRw M0hRfejYZkxxOG1yDmyPeOy9SngnrOFkt7jUYHywFnXEFDB/B3WH/M9q55TLlhrND4Lj 3xo5MqMJBhANNEDJkMhT9Wg5wpr9UGo3WnhqqQJhNfHnK+eIyt5wmBJLoIV8sMbyKfY2 7mpA== 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=sZ9U7mrKQc0Udhf4pBQPaMd9gIDivzCqt5pU2ViIhAY=; b=R2W/ez65Uf7qRWLqyMvAgguRaMpHgy/XuDU8FjGWpkrlFogrJlLSylPsSZMP+j3lmp JqIzgpEDWYClcyAvEi6PEhFTEsNrM0tXVBWdTbj3M5m2qXWoqWr8rY55NoH2gDO2ntnc 9aiiqz4iEw2qO6j3F4kUhe/anjIRbQJhAq3WRPl+z00isA1jKOzqddf8+7GvENqB1KUw KAofWq7kThUEZHGa6GRRq+Cnqyoq2iknbCBcfg8MoWQko3SZZBHIGseoGmOSXTvSq3d/ zBymEWaufTmhp2OrghMB/Y/NAhxA46sKK1RpKy0fIn7/mSoNOCEtq2BPqmZ0Dqf0Duep EAQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OLzl/ixa; 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 w33-v6si5706632qtb.152.2018.06.01.00.35.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00: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=OLzl/ixa; 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]:47827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeaj-00083i-K1 for patch@linaro.org; Fri, 01 Jun 2018 03:35:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWi-0005T3-OT for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWh-0000MY-NL for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:08 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:43953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWh-0000M0-ID for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:07 -0400 Received: by mail-pl0-x244.google.com with SMTP id c41-v6so14803393plj.10 for ; Fri, 01 Jun 2018 00:31: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=sZ9U7mrKQc0Udhf4pBQPaMd9gIDivzCqt5pU2ViIhAY=; b=OLzl/ixacElFn+L+lv2Se1u7umnxxd4z6+zdpb2eMM9LX0QRfKhpSlmE1fQIAQuUzz ryKGLHfxlXE6Zw1zutsZAyu8LmjXKOCm3Wpry3pyHH6LpPKQfBkdFY327d2D4rezdtjU 4jYpDy7IuvGOIWp8XpWFSYtm1jwPB1sq32wW8= 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=sZ9U7mrKQc0Udhf4pBQPaMd9gIDivzCqt5pU2ViIhAY=; b=Asu5eidb5BmMEr+fBrOCxoI/GJ6oO5/f3IciCZDohoXMZK5YVcFgDZ2cRy8x1wRvCQ NAd15UWXEb6GarqkkWffqOgTAmFblu3H6xZrHA6rjeKCZzciadpQXOtzyVapFa2cf0kU CeJqcm797TFEQ2S1ZDROkm04zQMUBrmJTO6RGsRkvaxPuEoENfTIDyvpQjWu7LphkNIs 26SkGEXbx4ZrLrDJJsO3L3ex/mZ6+PpWqEuaXS89GRGH33UNtiWgD3d1yInjHQILZjwm BzVKJEA4fWCCv6JhAIvA5lAnMXoc2GlimX2pPUYjkzQxjOWGpYW/yYxD+avBLIERB+7X ZxjA== X-Gm-Message-State: ALKqPwepbIZVSpA+zl/L/tCBvcBweYa2BKGvGvJe/Ltx8DF0TCLmVyrp XZ8uFbK9uVOzSzjJTme4+9CSoJ9JdDs= X-Received: by 2002:a17:902:274a:: with SMTP id j10-v6mr10253718plg.393.1527838266317; Fri, 01 Jun 2018 00:31:06 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:26 -0700 Message-Id: <20180601073050.8054-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 09/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) -- 2.17.0 Reviewed-by: Laurent Vivier diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e2e2d58e84..fc3dc3f40d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7962,21 +7962,34 @@ 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); + static abi_long do_unimplemented(unsigned num) { gemu_log("qemu: Unsupported syscall: %u\n", num); return -TARGET_ENOSYS; } +#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) + +IMPL(enosys) +{ + return do_unimplemented(num); +} + /* 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) +IMPL(everything_else) { CPUState *cpu = ENV_GET_CPU(cpu_env); abi_long ret; @@ -12880,6 +12893,10 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, return ret; } +static impl_fn * const syscall_table[] = { + impl_everything_else, +}; + 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, @@ -12908,14 +12925,23 @@ 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); + /* ??? After impl_everything_else is fully split, initialize with NULL. */ + impl_fn *fn = impl_everything_else; + if (num < ARRAY_SIZE(syscall_table)) { + fn = syscall_table[num]; + } + if (fn == NULL) { + fn = impl_enosys; + } + 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); } #ifdef DEBUG From patchwork Fri Jun 1 07:30: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: 137471 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp610439lji; Fri, 1 Jun 2018 00:40:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5k4pVMwEJ+LCcjFjegzMCumcO4P1CLnJIsOZYcSCEqdtCnuUvK+7nDjlVPzxb49PzKu7x X-Received: by 2002:ac8:607:: with SMTP id d7-v6mr9350406qth.242.1527838840108; Fri, 01 Jun 2018 00:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838840; cv=none; d=google.com; s=arc-20160816; b=uCVocxrHHBAyKH97C/at23rUY4aKQFtaold/UI0a7HM9/P59vp/vFDbGi5Itlr66QP YXq4JWbDFyZ0TbhO/QtwyRnYNncIHAbt30OzIA+XfiZ5YrJD80K7mbKRMEJ9ZzlJdsXI wkXVZom/45NhuZtBly1LY+Od7tEZkntxC14DUcG8E481PXp6uDFYegJKvSaxW1Bdqj8W m5ynKsmDpGBn4SYEY6xr+g5VEihuX4MDQ6k5N6aU+JAMl7PLAJcPd3XVWo9WmaScF5Pp +7wTcJfdAUWQ0uk0I4YJ//L+44Pa8UtEUuwJqcTXXkYzdOX2ilE+dTVWzak3Y1720ZhR vphA== 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=sBkEds3zu+lhVLkIVyOM0TUUxvdaBfVFV4ENXOsunws=; b=iCRkgRKb4uni0wxT+Rpb6+GZ76j/vyeoh7jzx0RynFOvZ1EQIrZxDiilJtyQ0n4REK BAegM3v0UQh56wWyOmgMdAcdH7gZlzRoWwWtc2mYDT8TCPwU4NokuNQerZjV1xQa1q8V T19YPH72kDJFFCluxn4M54m1BHj+KGBQ06iUat9W3oR1ddHdwmeIcDdTZJzUSbqg3GRl VZv8XVik4LqmR9tDSvqB6O56BHrUNI4h8lbtsDV2hrrWaOcDdz07NMfCWlh6xZBBkqMB apBpYBqW4M2eu7+fekM8/7fTN2zNqyilqja1Xep5FO0TezetqwWKuHz4qTIEQYGa6YQU GX1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CmThZj37; 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 k30-v6si5840576qtk.393.2018.06.01.00.40.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:40: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=CmThZj37; 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]:47859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOefv-0004KS-FP for patch@linaro.org; Fri, 01 Jun 2018 03:40:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWk-0005Ue-IS for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWj-0000OY-9H for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:10 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:38620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWj-0000Nm-0x for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:09 -0400 Received: by mail-pl0-x243.google.com with SMTP id c11-v6so14817025plr.5 for ; Fri, 01 Jun 2018 00:31: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=sBkEds3zu+lhVLkIVyOM0TUUxvdaBfVFV4ENXOsunws=; b=CmThZj37KlNM3qu2Q5R0S5E7Zs7U8AV1ACe/qbZ9HivrLROuuIdC0gx9GRQ/QlxnN9 WbYjTRHF1KOPYkDCg1ab5WP/xoEPgGH3PS9MkRgRIXajiNpEz46K3/kLjA0jZKxWIRK9 to4AwCpJyTtE6THqBBIyD0IWWco4D/Z8YAGu4= 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=sBkEds3zu+lhVLkIVyOM0TUUxvdaBfVFV4ENXOsunws=; b=EUuaf/bta2AzWFhQ/cZ6Lps7K+CuQZbgryLCmeN7xAAPLcisrvCGN2JdHZkeOBvo3Y zduRFSEszZIQDJ18PKd09agAh8Lw1dB4zHIyro65+LwqztuoiWlw5jAbxOoZriQYUF+2 yP5ZDbXjUXPRMDtRTl31WWPImRMgq7y0FhSl2fBciAk61ltOIpnsFwrQLorH/rgu8Kfm 4KPfPR6Sg3JnpwK2Rn9Ua39F9/qrSVZ4YG+T01RSpxCN0jicCDoLtVtyo5M7PVDw5vSR /kkefs2XLrGYqRqpPWmzlD4+prTzZJW/UVCEHTs6Lbeh76uCXJ1o0LsqR5AZDwOs1QO5 dIhw== X-Gm-Message-State: ALKqPwdVDgDFUmDVny3IykhiqiWc0pPzyYvp2Kkz3UpsPApRIPDS4ttU 1y1Ii9dZjI/QZ4/qEz7s8UU8ce/i4VE= X-Received: by 2002:a17:902:a986:: with SMTP id bh6-v6mr10277280plb.245.1527838267794; Fri, 01 Jun 2018 00:31:07 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:27 -0700 Message-Id: <20180601073050.8054-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 10/33] 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 | 198 ++++++++++++++++++++++++------------------- 1 file changed, 111 insertions(+), 87 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fc3dc3f40d..b0d268dab7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7984,6 +7984,112 @@ IMPL(enosys) return do_unimplemented(num); } +IMPL(brk) +{ + return do_brk(arg1); +} + +IMPL(close) +{ + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + 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 *fn; + + if (arg3 == 0) { + return 0; + } + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + fn = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!fn) { + return -TARGET_EFAULT; + } + ret = get_errno(safe_read(arg1, fn, arg3)); + if (ret >= 0 && fd_trans_host_to_target_data(arg1)) { + ret = fd_trans_host_to_target_data(arg1)(fn, ret); + } + unlock_user(fn, arg2, ret); + return ret; +} + +IMPL(write) +{ + abi_long ret; + char *fn; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + fn = lock_user(VERIFY_READ, arg2, arg3, 1); + if (!fn) { + return -TARGET_EFAULT; + } + if (fd_trans_target_to_host_data(arg1)) { + void *copy = g_malloc(arg3); + memcpy(copy, fn, 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, fn, arg3)); + } + unlock_user(fn, 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. @@ -7999,83 +8105,6 @@ IMPL(everything_else) char *fn; 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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))) @@ -8116,15 +8145,6 @@ IMPL(everything_else) fd_trans_unregister(ret); return ret; #endif - case TARGET_NR_close: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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)); @@ -12894,7 +12914,11 @@ IMPL(everything_else) } static impl_fn * const syscall_table[] = { - impl_everything_else, + [TARGET_NR_brk] = impl_brk, + [TARGET_NR_close] = impl_close, + [TARGET_NR_exit] = impl_exit, + [TARGET_NR_read] = impl_read, + [TARGET_NR_write] = impl_write, }; abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1, From patchwork Fri Jun 1 07:30: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: 137466 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp606270lji; Fri, 1 Jun 2018 00:35:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKMOkaNPkMhzWTbM7TTRIHrOfm7R75BWsvRKo88djgS0eVHFPBdleVOefB3kDY3lg9UIBox X-Received: by 2002:a37:c31d:: with SMTP id a29-v6mr9059885qkj.213.1527838508344; Fri, 01 Jun 2018 00:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838508; cv=none; d=google.com; s=arc-20160816; b=VuzElaiMtbJ2ni3bYsLCoImcDdmfIT3ngG/mcVyGw8mXxvmM70MS0hpgY+fSNnWjpo 1TwS03Gqfm471BTxOJQbDxXuG59w2ThPrQBwPtSqXQ+lNDYma0aApImdtS/ARkbEmuBW mpBI0Qu2MbbDNEEuaa02kpUydrupHv5VMhWbtW+onHJvQRhT3tiMD07AaT2ER+TOu13/ iN07gk8jMCk30nxoLKEci6509U4biW1kPN4cgXWzgq9SIlD3MvwD5qJAqw1BUkM7Z6sU +M7dl+ID8OWhP0iqOYSeUcyH7WkDtDF+ikr9ENk6s+9cPPbWk59jhZqvzKjBZcBGP86g Yl8A== 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=RPrIDkYfAKFWJaaTRA6onq1Qh07sa6uq89O2i6nWx8M=; b=t567WJ2isJaYvWVDRI7mqsF1Q2Qwms6l+uALmfHdZLbsfYn8DFueIM5CpVr5v1u/XO qiBo9H6Rk/1oSWPy/JJq82ixBmsaL7Y1ykEa7mo9VqlUe4KsWvgOvilN9RtOzPNMjucK nZ72/ZBmE45LtiI/oCyLkz2YFUkJguSWYGeVuJNTf7fmbupnPZhRpVsO8AcNKlZhipMP 6ij7YNqOATTH8MZKUaYaFJG6T3U7e0gxeAGtRJ/AI0p5V4g0fVW0nytE4DrS88KQPNcM TTNfK8SdR9TnWlOGoUdPDus0/uh8QPEfpQUO76JYLs4j16eZzKTE8q2MIlfv8J/Dvhn/ NEdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SHCLakwS; 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 q11-v6si6285575qtq.38.2018.06.01.00.35.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:35: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=SHCLakwS; 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]:47824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeaW-0007vw-Gl for patch@linaro.org; Fri, 01 Jun 2018 03:35:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWm-0005VL-0N for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWk-0000Q9-OT for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:12 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:41500) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWk-0000PO-Gw for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:10 -0400 Received: by mail-pl0-x244.google.com with SMTP id az12-v6so14819013plb.8 for ; Fri, 01 Jun 2018 00:31: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=RPrIDkYfAKFWJaaTRA6onq1Qh07sa6uq89O2i6nWx8M=; b=SHCLakwSSQp8naUpcWTUPqSPxdWq468yH7aKimOUznHZqcV7ZYiI6qHdVJZ1W1tA1i /3m12q4OjE0WDRYFP1a2Z/mCdKxHtw0nqIaQrJ6Idp91m+MWkpO4mJGv1j8ZVQVGCwgB qS91yexo4GQPIuotUTGAsWnVpS6rQEiwHbqfY= 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=RPrIDkYfAKFWJaaTRA6onq1Qh07sa6uq89O2i6nWx8M=; b=XHs9vv+QcTtTuP1+t8iLXZPDcC78bXNlITMXAyuR/34IxW7ibj+JfHe+F30PbHfRTa +KcRdEvKQ7SGZGy0h4CZo55NmIlXOKqJVUFfJ085SkeKTdMeFYernL6mTGXKNXZujNw+ fgCcb1o5NBgVRERQSx94jXGe07Kt4+eVupFPPQWi6Ec0e02XU4H9AD1icmm/EGX63dW2 V2qojmtv54BNK/236mLKV0QG05O6GS/o2ALfq9RFM6MoA7obOwtut+drSH0AoLm+aLua mAheIx83zzOzxuNBGEVAPXrGU8v/QB/iM9JBQaWjR5B+9J/4us+zvhPyE1unQpqeR/AM vCuA== X-Gm-Message-State: ALKqPwf8NKP73OwFqiGm3x/6ERq1QJgvPgqmum1bVdm5qg8AOxdNy61w /QRDM9AJ2imK6Q12zw7TPT/NK31YorI= X-Received: by 2002:a17:902:4b:: with SMTP id 69-v6mr10292077pla.178.1527838269282; Fri, 01 Jun 2018 00:31:09 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:28 -0700 Message-Id: <20180601073050.8054-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 11/33] 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.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b0d268dab7..a9b59a8658 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7998,6 +7998,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); @@ -8237,103 +8342,6 @@ IMPL(everything_else) 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; @@ -12916,6 +12924,7 @@ IMPL(everything_else) static impl_fn * const syscall_table[] = { [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, + [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, [TARGET_NR_read] = impl_read, [TARGET_NR_write] = impl_write, From patchwork Fri Jun 1 07:30: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: 137470 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp610390lji; Fri, 1 Jun 2018 00:40:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKrrb84aWOUzpB0WWCgCfuCrZmlLXSvoatDMYwxNJQmyZkerssmqgfO1wXn3fvfC0GD+QBs X-Received: by 2002:a37:b0c5:: with SMTP id z188-v6mr9539868qke.133.1527838835646; Fri, 01 Jun 2018 00:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838835; cv=none; d=google.com; s=arc-20160816; b=AFI/Is+4TgrhH6zzJyyaYXfCotCA6H5xvhb374O+J20OAuERkqz8Gk1ze13MT7V3pG nPikKU3Dte5VOLaVws1ZZ26z0TuMCze5yDudxHhRwRaYniAFqrYSALc+yTIAn1UuOVAQ WB3IzADeAxakMLq12FxZq1c9LBAMOAhFIlpMnkKC/aLCSpIgnuNMwRyCnAw/pbKakydh 2RwD9LS+Ty2ojo5kRZfIsqc09jshqPO7aEFCbrogqblhD/1iINy9wL/KNQCoqXmZOQCq Xni2xdDvKXfCjf/0ihBKBjTw4HBcmWJuwFCN0pWxTVzKIo58a/gu471ZH7pisFsPbbnx rNdQ== 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=OBnyU53YCatMcb4pWKJZWeViNHMHWGdsDbXD+xY0RYk=; b=udc26Sb/nKO41+FE7416psy2GyvqDaN72s0ZAUW08TRWolXJwiwzKQSRRAOeOp4pZN DBqCkZg3B17Cuh/0USIk023IaKb+rV2XdNjhcq8RIAkYZpHJNsuTYLKPfBfoxQPE1epm HpR/md5KKVXsST1ppw3v4S62grqN1U1l5qmBsM07A3kAPQE/rklAmT5z2oaEJk65GRbD 52OpHH91EWNaFWU/ej5Mitz47f2at3O9+/TqC9FDHadwX1ddmo7HI9UByTJVlCPJnx3R 2ARmr0dIoA2Xh/Fo6pR3VezNJi86e2x6JX90YoGzNT0S256PJrjZcrr1UBKr8zd3APCK cQcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NivypzK9; 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-v6si5053525qtb.376.2018.06.01.00.40.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:40: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=NivypzK9; 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]:47848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOefr-000303-29 for patch@linaro.org; Fri, 01 Jun 2018 03:40:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWn-0005WM-0n for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWm-0000RT-2w for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:13 -0400 Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]:45842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWl-0000Qs-Te for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:12 -0400 Received: by mail-pg0-x22b.google.com with SMTP id z1-v6so3946144pgv.12 for ; Fri, 01 Jun 2018 00:31: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=OBnyU53YCatMcb4pWKJZWeViNHMHWGdsDbXD+xY0RYk=; b=NivypzK9VQ/AkFkKjARzuXENVGVDc+mW8TScorclWc/8UlW/VCikgrw8frXXI0lazf gL4eGgNYRs0swFbF5l7gKlyu0TO5MlvgwMtlJS8TF1Twq8ZG8hQd3XWDi1TENwIpGDxG vGaXgRGIVC28RyTIWkNEUVrr/JNw8yuFN45FM= 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=OBnyU53YCatMcb4pWKJZWeViNHMHWGdsDbXD+xY0RYk=; b=F29EhLooSB/QVGrRu4EGzRP32dbZaB0uHRau+ZP8U/GkMIqySI0hIuZG1RWa29IjRO JMUfI4Vk21FDoqXeffqMm7wdRSyAW89jkdHm/n/JjTGPi1xxx9qnMt61j2gGrfqXMgCs YsY+Yr4U6oopiBPrWRgax0DFnZ9mXEXASLPFOSpiAkiESJTh0O8Mm2i33pLMj+E1hxNP eGV2Toy+SmBX46REg2lvENaI88T5Z31zCmP/s0oH0ocxoM1+Lod7P3ApGlTEobuLAj2o +OqycICH3MAGYAccx0ugwyHL1I5XOAaN+Tty5MG0FZ+Mf2NH/8wteFFDCqlUWFxnNWea WuPg== X-Gm-Message-State: ALKqPwcL3nr54wyVwU7zO4R2So2Z3m8gNw/gk6t+BN+149kxl5GmuKB3 Ky5v/J6ApGWA9JiUIbs3/IxWEeE1wcU= X-Received: by 2002:a63:648:: with SMTP id 69-v6mr8002948pgg.205.1527838270588; Fri, 01 Jun 2018 00:31:10 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:29 -0700 Message-Id: <20180601073050.8054-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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::22b Subject: [Qemu-devel] [PATCH 12/33] 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 | 65 ++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 23 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a9b59a8658..fb1a8a4e7e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8145,6 +8145,44 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_open +IMPL(open) +{ + char *fn = lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, AT_FDCWD, fn, + target_to_host_bitmask(arg2, fcntl_flags_tbl), + arg3)); + fd_trans_unregister(ret); + unlock_user(fn, arg1, 0); + return ret; +} +#endif + +IMPL(openat) +{ + char *fn; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + fn = lock_user_string(arg2); + if (!fn) { + return -TARGET_EFAULT; + } + ret = get_errno(do_openat(cpu_env, arg1, fn, + target_to_host_bitmask(arg3, fcntl_flags_tbl), + arg4)); + fd_trans_unregister(ret); + unlock_user(fn, arg2, 0); + return ret; +} + IMPL(read) { abi_long ret; @@ -8210,29 +8248,6 @@ IMPL(everything_else) char *fn; 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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: if (is_hostfd(arg1)) { @@ -12926,6 +12941,10 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_close] = impl_close, [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#ifdef TARGET_NR_open + [TARGET_NR_open] = impl_open, +#endif + [TARGET_NR_openat] = impl_openat, [TARGET_NR_read] = impl_read, [TARGET_NR_write] = impl_write, }; From patchwork Fri Jun 1 07:30: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: 137469 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp609592lji; Fri, 1 Jun 2018 00:39:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1g+2EtsIHQF84AF3SMGSc2r6BJe3hvE+LNEvhm6Ek+TXCc3WJeKu5vS3Are1Om0x6RPg4 X-Received: by 2002:ac8:5293:: with SMTP id s19-v6mr9443421qtn.311.1527838768529; Fri, 01 Jun 2018 00:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838768; cv=none; d=google.com; s=arc-20160816; b=Rm6a2SF8H13GZA6lTtSOYsENWQY0WsziD1iBlkDjrZenpiQ2g+b1x4VW0dKfthefkx PPzwpgLKUirik54Sy/qtgcBCRR9ohm65tH9CbHUNSWLUC5tIPFkm7Wf9LP4zMa6NJRay SuuEEnMdnvCnAWsC7J7kK5KyZsDL9rTDU/zCjftUEYW+qgrUFQcq6oGbOJLLE1N153VZ qK0qlFyMs80NZkfTTNfHQZNveP5fWV48wqTeSzQ9PlU4thf65Ll+AYbQeMS2oqOO8HTb ahL87muVLzLegtfi6txZ0Ai8gfwl2eaaGNpNoOQ6WYWPdLgr7jgh+yT3VIarXM7FDUfp H0rA== 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=kk3pbw60RM5oFWEwEGqSGPVEZ2Ll5xAazQA92/YvOx8=; b=Mm6ZIuEHoLphcIoXCakIeDGlxsJd6H1PB4d1b8A/nEEq4vVDwaey2bJO/9cKue0jEx e7VuoWIwBCcyS9vYFp+lvvjr2iGTQlQWE0iXjrCdSqOorFz60HQzNsS94oyYI+OB7n5k PS9br3aTJWKcmzBpYqPfpSqWzc1Wcd0SWgFlKzAjWfvB1EtSXUHvuD3I7nrlTLR7/1B3 RmGYHs22dADt2+jaDpw2DVjIeCQ9O1cj89t/BmcTOwL5ePi3YWzVpKq/XLkm7FsSDKx+ 3+EIs9XE1IwLyj9bj2t+lKtDJZ86eFd3LCMejaiYl2j02iQ/daJg9M4+PBFm9j2BeOdn hWAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XbVZmEon; 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 t3-v6si7293097qvl.124.2018.06.01.00.39.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:39: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=XbVZmEon; 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]:47847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeem-0002sI-0v for patch@linaro.org; Fri, 01 Jun 2018 03:39:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWo-0005XT-LM for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWn-0000Sw-IK for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:14 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:35167) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWn-0000S5-AJ for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:13 -0400 Received: by mail-pg0-x243.google.com with SMTP id 15-v6so10552560pge.2 for ; Fri, 01 Jun 2018 00:31: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=kk3pbw60RM5oFWEwEGqSGPVEZ2Ll5xAazQA92/YvOx8=; b=XbVZmEoncRsNgTCILcWriOyY2MMIIPfKj2eCR1lDK/TjAeMo1/l10gemDoEpYNg1VG 1YxkGZzqRBmUOIF+mlOYgHN6H6CD/6BxJVFAPgTtXrRteh7uysDRnEe8RmG2PIUpy1ef GJs0qc62512LDolTZKgiNE1CLMQmUZIUPpKW0= 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=kk3pbw60RM5oFWEwEGqSGPVEZ2Ll5xAazQA92/YvOx8=; b=OadaoteZv5aXKwPrdoa58keNDVJkgjw84QzIL377PwVrbNdKzOPHNSIKQdO4YB2k1b EFBcNFnhI+toY1TYAt5XKeVBCnlydmT6rDl1rQ3P33f8WqvuieTsdDAi0u85BHUQAGEW VrW34DRBH8c2Y/N1/DcSI9nx5ZThpHqnk7vzyNVeYa0RVEyJTaOxo0Dvm+isd0HfNJoE GIQCHotmy40nwOIybOkAZxao2AFj9nGIqdg1RSDfjSE+LtIrHhcMG8CYDFMMqlFKu4N0 9le1+YUklJhow2mOlHOuF7opekX3XUgmY06u0QmWAMHYx/OmpzMpe1QHkhzid4B59G2o CnDg== X-Gm-Message-State: ALKqPweLur8sOp2IIIIpPh0Rm0UMEyA8KJPP8pg4X8nh0dJ9DjQTgL64 dBzSzJf/CMQK3M0L1X4kKfyLb7Lu+4Y= X-Received: by 2002:a63:a557:: with SMTP id r23-v6mr7994953pgu.336.1527838271987; Fri, 01 Jun 2018 00:31:11 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:30 -0700 Message-Id: <20180601073050.8054-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 13/33] 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. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 129 +++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 65 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fb1a8a4e7e..4afc22c20c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7369,63 +7369,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; - - TRY_INTERP_FD(ret, name, - name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flags), - name_to_handle_at(dirfd, name, fh, &mid, flags)); - ret = get_errno(ret); - unlock_user(name, pathname, 0); - - /* man name_to_handle_at(2): - * Other than the use of the handle_bytes field, the caller should treat - * the file_handle structure as an opaque data type - */ - - memcpy(target_fh, fh, total_size); - target_fh->handle_bytes = tswap32(fh->handle_bytes); - target_fh->handle_type = tswap32(fh->handle_type); - g_free(fh); - unlock_user(target_fh, handle, total_size); - - if (put_user_s32(mid, mount_id)) { - return -TARGET_EFAULT; - } - - return ret; - -} -#endif - #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle, abi_long flags) @@ -8145,6 +8088,67 @@ IMPL(exit) g_assert_not_reached(); } +#if defined(TARGET_NR_name_to_handle_at) && defined(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 (is_hostfd(dirfd)) { + return -TARGET_EBADF; + } + 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; + + TRY_INTERP_FD(ret, name, + name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flags), + name_to_handle_at(dirfd, name, fh, &mid, flags)); + ret = get_errno(ret); + 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) { @@ -8248,14 +8252,6 @@ IMPL(everything_else) char *fn; switch(num) { -#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) - case TARGET_NR_name_to_handle_at: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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: if (is_hostfd(arg1)) { @@ -12941,6 +12937,9 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_close] = impl_close, [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) + [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, +#endif #ifdef TARGET_NR_open [TARGET_NR_open] = impl_open, #endif From patchwork Fri Jun 1 07:30: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: 137477 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp614904lji; Fri, 1 Jun 2018 00:46:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvoWRzAY10Sawr/FV9I9D2RurWIhUotVckU/LIBY7oaxh57VTxNSW0vEU0mN4SSSfMdYHq X-Received: by 2002:a37:cbc8:: with SMTP id u69-v6mr9342674qkl.242.1527839200257; Fri, 01 Jun 2018 00:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839200; cv=none; d=google.com; s=arc-20160816; b=wC9x27D6lHk+0evT36r5q+BwRD0iPFtVDdNt6DOg7rgHNA1FpN6NIhl7UitYFFv7zL 6hSAFmu+YAZBTQR+PYLcWWHYC/oFGa84+17gWVbKMKnvAC1YTo1+W7nqerCn/GTT7MsU 2Jpzxb5LxJiJ3dM1WbTNP0puANWwNDHmxCtHAVTMJIzvMXhRj6+ZK0O8R6BukH/4279Y WYYVNVGoHn3gTZ9qe4MYlwVDu+21Og4EupPlI0YkhU3hZfqNqgFv80czZ11I7g5BkVwa l+iVNKN9qk6qdJbCG08Wi6GJVgTxGZtiTyLt5MN9+oht5BX+FBL1Gv9oKtJsso38UpTR ab7g== 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=tC4DvAB14lOIqJsL1xleYuXscQUSfYhJROofvlBpgL4=; b=MN4f18IWP45TBQPcvFGitDvRGwjetrveH2TWA6ZPP7cCaJKvUB7mtciEU3c+abW9QJ xJJPYYpU9URHs+7LK0MkdZDZkFDcvkeV27zYFckqdIi0Dm/P4YJBGEitOumd2LxM2nst dLmG+dBsmsoHRwpQNaMHB9BfY35RCxtxEcGr9i9NvoeqN7JFaJ72tIAMsIgEYTU+Wj55 PgIivBF6nEuff581BnQ28WIFFzH74/86uZJPl7ZpkW63qgVOHSyimjD7NbeNCO9HSakO RdTOftCyMMLygOSXjIZxGKcF2uKu1NEuMp7y/B7LEqha2hVn3YwjJ1I46GJnWBa2FB1E b2HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Az+jrVuo; 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-v6si6123033qkq.37.2018.06.01.00.46.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00: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=Az+jrVuo; 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]:47890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOelh-0008CN-U5 for patch@linaro.org; Fri, 01 Jun 2018 03:46:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWs-0005a5-Mt for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWo-0000U0-Vz for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:35167) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWo-0000TL-PE for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:14 -0400 Received: by mail-pg0-x242.google.com with SMTP id 15-v6so10552596pge.2 for ; Fri, 01 Jun 2018 00:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tC4DvAB14lOIqJsL1xleYuXscQUSfYhJROofvlBpgL4=; b=Az+jrVuo/ifL+QonxFPHxGp+Wms1EY5W+TY9x9yiwR2FPa7+JlO1enAfyVF3/Cl08S M+sGaJCvGyfzN/5R8QD+kznfBdsRhJJK8ukX1p8IQ/wqvIjUIxCjAWigpAnE7KsNOaUz EFZzdomra3nOcep2SczqiRYpKJeRyArZvfa9k= 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=tC4DvAB14lOIqJsL1xleYuXscQUSfYhJROofvlBpgL4=; b=CA5wvv5dxhGphQB2TC+MUGYm2kt6hogj8MEI7rByprk0k9w4u/XeXQCpOFEesBWqh3 HL3hrssm1nxTxhjKzlj7ZldhcIfnHrLQf6iFu+xXh7nqBh4XURhaDLnEOWc9w66TfRIx aYuolTNVzvcxrSMRhSL1s2jDxa3c6NKe/RYojDVxUWpPGWNmUxPu/KG1WPxI0e2JNPAc sBMemCoP3xBO+HrwxN6lXR78FfOjjwscNBCNuetHYWe95oF0mIhMGVx+cHBFzLdrNn6w c3TZcwcWU+Ppwxa1MDUbg09iU+bvkEUP79Yuqru358BrlyZ5eh4+lcUjpGd2B/TaoX/n GBPQ== X-Gm-Message-State: ALKqPwfqPQR+IDv9qiitNq32CvTTZWyhPdH5cNAL6qA9SEo/yz5H7WXt 4eQVB0Tz766LAqn2eCzk85cdncTj/mw= X-Received: by 2002:a63:a00a:: with SMTP id r10-v6mr8078620pge.222.1527838273488; Fri, 01 Jun 2018 00:31:13 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:31 -0700 Message-Id: <20180601073050.8054-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 14/33] 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. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 84 ++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 42 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4afc22c20c..48bb1c0231 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7369,39 +7369,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, return -TARGET_ENOSYS; } } -#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) @@ -8187,6 +8154,45 @@ IMPL(openat) return ret; } +#if defined(TARGET_NR_open_by_handle_at) && defined(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 (is_hostfd(mount_fd)) { + return -TARGET_EBADF; + } + 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); + + fd_trans_unregister(ret); + return ret; +} +#endif + IMPL(read) { abi_long ret; @@ -8252,15 +8258,6 @@ IMPL(everything_else) char *fn; switch(num) { -#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) - case TARGET_NR_open_by_handle_at: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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)); @@ -12944,6 +12941,9 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_open] = impl_open, #endif [TARGET_NR_openat] = impl_openat, +#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) + [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, +#endif [TARGET_NR_read] = impl_read, [TARGET_NR_write] = impl_write, }; From patchwork Fri Jun 1 07:30: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: 137476 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp614430lji; Fri, 1 Jun 2018 00:46:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIbIcpWG2P+TTLxaRCZy6oTYzZabLyJL/+e/gBIjr6szzlssZDIHNejVhFi7CDt82Zcaasx X-Received: by 2002:a37:f60e:: with SMTP id y14-v6mr9226759qkj.374.1527839167182; Fri, 01 Jun 2018 00:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839167; cv=none; d=google.com; s=arc-20160816; b=PL/H5h63QUcGUUdD0yC5zJ+n5uaSWuLzJ7+zhGhA5Pf/thQWym5kYi3FnuLdB/zYuD uDh7ElqsndIowf1ge9Qp9Vx67XgCdCtF6qczntZbJSCl0fqVPYsXx7WF/kvXqQX8hZlD FvHjdGZv7qRLWFswPndAVS9HhV770ilXHiLBJIsjD27y2hEfjkmdFuSwBh1aZUZYMs+y 2iNMaUq83sejnCLuAZoAjkliz8nzrtM7BeqCXkuR4QHjswgvyIsV8IxdkJkPwuKg2NVx oqvp/kqtUyo4GoHf7Bi1luMGLsh0/eE042T6FukdK3XVPOdvQb3cRi1q8S0Q8UcgxGtu KS1g== 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=Gd3OrgaRytojWAKBUPZdGXy3p/dEUecwW8tJ9jzjJ4A=; b=smMesdrcJKs6oXsgSwZ5P5duc7IiQ1KVw+RITj3AHlfNOqfxbmMx5hZCPVHqPyb085 IsXarNCRZth29a8xFCDprkUoSMG6MSFyjhb4Wm4UsABTMBnpJlhwZYLK4c+XjlyK2mv1 SImr0cf/5g0kMMENv1jI0XQ3c3tWeqKbHZkY9ki7w39qDxcIamP9WCQQa4/KTDeh47rg H0YI4A9PGxaVBxxLGwmqJqdyHh1A25JktLJRxhaAInTrWamrn9T4bjr7w792Y2OnyiBd n2O3KABScfOLaycjxWf5Fs9mCqcBNmBNIhT+fJ50Yt9Zrf+X265UUKeLah/sX/oeZTxM m/2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kyfZaZ9+; 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 z67-v6si1570721qkd.318.2018.06.01.00.46.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:46: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=kyfZaZ9+; 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]:47883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOelC-0007i9-H1 for patch@linaro.org; Fri, 01 Jun 2018 03:46:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWs-0005a6-N0 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWq-0000VF-CA for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44909) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWq-0000Um-6D for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:16 -0400 Received: by mail-pg0-x241.google.com with SMTP id p21-v6so10876647pgd.11 for ; Fri, 01 Jun 2018 00:31: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=Gd3OrgaRytojWAKBUPZdGXy3p/dEUecwW8tJ9jzjJ4A=; b=kyfZaZ9+mlUY58tbSDbpL44da5+rsDKxt3xTL0m9hQ18Jp61WZ6N1DNPvFHIpnSCna 1nUaOxZMpcecgbGZE9L/9pVh7Qv2MR/X6r6KL1/Bn73iF21/qqxIL/c/Gn+cWlyQcn6h rQk4ReHvV4xQ5RGAGJWb4RyZPF00YBwoKv/Uw= 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=Gd3OrgaRytojWAKBUPZdGXy3p/dEUecwW8tJ9jzjJ4A=; b=EJiuSNBsrWhf7pkYP2azLOIUc1ogd8ziUFh+4uHPz4LwzWg5k49yEkcnKjFcn7U+Iw OH9m5EpkPOGcb5DY+gD7a4+Ofo5iCe9q1zpmEhoN4tDDAyc8hICTneiQog2FSiFkOI7j 0CFvhQab1EnWYYysxZk0XzUUxJfaziGOzLkgcJ2m3fZkH42NumofA6AAupCdPqVKzjPa qy0mASuAFGgxSmXjgwkpxUA0nv3SpAMdFJzXrjrAHpUfSluc0gyorUnVrmNEz9pTjaON tkNlptvu+0hEmKdcsnzkFSdJB76tHuAvuXhE78Jvb28rK7YHqU/KjFB/5Yo+FOuQFSzg Zdrg== X-Gm-Message-State: ALKqPwfNf9n+sZOozNFv58oCeQwD84SoG0W69gcG8td2FEopQVsCShO0 Qd5nS27SLluqVSvbrK+vpkeL1aCELw8= X-Received: by 2002:a63:7f15:: with SMTP id a21-v6mr7963255pgd.21.1527838274951; Fri, 01 Jun 2018 00:31:14 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:32 -0700 Message-Id: <20180601073050.8054-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 15/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 108 +++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 39 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 48bb1c0231..e208f8647a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7908,6 +7908,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; @@ -8055,6 +8071,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 + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8216,6 +8239,40 @@ IMPL(read) return ret; } +#ifdef TARGET_NR_waitid +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; +} +#endif + +#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; @@ -8258,45 +8315,6 @@ IMPL(everything_else) char *fn; 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: { @@ -12932,8 +12950,14 @@ IMPL(everything_else) static impl_fn * const syscall_table[] = { [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, +#ifdef TARGET_NR_creat + [TARGET_NR_creat] = impl_creat, +#endif [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#ifdef TARGET_NR_fork + [TARGET_NR_fork] = impl_fork, +#endif #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif @@ -12945,6 +12969,12 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_waitid + [TARGET_NR_waitid] = impl_waitid, +#endif +#ifdef TARGET_NR_waitpid + [TARGET_NR_waitpid] = impl_waitpid, +#endif [TARGET_NR_write] = impl_write, }; From patchwork Fri Jun 1 07:30: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: 137472 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp610748lji; Fri, 1 Jun 2018 00:41:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL253wQ+OW7tbmvFQu6lcNzBokzVWoWC6+YWrfz5gB2Gc/6qx/SNPL5tpTv8fBMHkRhs9UR X-Received: by 2002:ac8:3415:: with SMTP id u21-v6mr10096584qtb.356.1527838865254; Fri, 01 Jun 2018 00:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838865; cv=none; d=google.com; s=arc-20160816; b=WbiROcvtA2cduueG+wfqryJS/e15UEDJ0lTAhiuBRtX/1R/PIj55bSTd3Ss/6v/TP6 9pXLVeIBa7+7847fT6q7OptDTMAq9WlW1/JoAjxlgfxlY0YF0FlkW/kVgpeL8XWC2FRo LSg61fnKg+R1V5umLSWdxAy2aWrIExsorec+WQT9WPE79fOcpaWxcwdYfQJVmHWyF8GU hxZIoyqkvNQ3nKRNAT2LaJuFrFIrU1Hi05xN/v1h1p2FFi1EtnKVOovQYxJWJsKMyomk 6TXYz3o5M6p50+lr6PyHHdC9XWMYIHvlEDQdPOgRgwBOaN6T5Ul0BFnri+Pk1rStiGGj okzg== 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=wRUrfTonuJ/mCXPMxPqhtS3ySI2PW3F2ScDJa0nWJZ8=; b=smMgxw4JbU4FItWg+bw0q9PMeAnZeLdbVzCO5WpdkhFyqHt2ku+Gg7AFYeHwRDcrQU kJYWCUpImbcWUaVtSEGghb5h3L/Gh2PXqyu3UhSI4YKlH1yt0hEsXUmmPloADJe0vwDq +U9GWG2tGlAU8gGSY9Bu8Dwqy4T/dQDwQQXGZ3dj3Z+9HAbe2DDs3TgiF/2fjXlfBZSa p8RsRyWCg2dtKptyVRECZXub30HV4MwWa/ii/xjA/LYfKVYApcrmcNl9XyK2Vljz/UsY WUBMYF7F4qIqRQoUfr7yjdrLSosB/KQ8rK4XRbFtcMeALmx9cmjTmFmHBHbumeD1cNMv zn4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SPjjsOPc; 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 o63-v6si252809qtd.270.2018.06.01.00.41.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:41: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=SPjjsOPc; 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]:47858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOegK-0004K7-JT for patch@linaro.org; Fri, 01 Jun 2018 03:41:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWs-0005a9-Ob for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWr-0000Wb-SB for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWr-0000Vo-MH for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:17 -0400 Received: by mail-pf0-x242.google.com with SMTP id x9-v6so12086132pfm.2 for ; Fri, 01 Jun 2018 00:31: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=wRUrfTonuJ/mCXPMxPqhtS3ySI2PW3F2ScDJa0nWJZ8=; b=SPjjsOPc7b8qlFc/fVVXJqXw1+fzWboMP1QJDxRyfq2HK6QNN0iJVsuAomGry2r+2o udqE3dR/1Xaoeni3ml8FQWVLLCkhlamAQMslKP9Lo6e1aqaco+Cpca4k2kvZ/ZNh/91s g6APtJkMkTH+5wZed0KzyJD+B+AF3YAaikjvs= 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=wRUrfTonuJ/mCXPMxPqhtS3ySI2PW3F2ScDJa0nWJZ8=; b=YUs2fQI9BJRc0kPMHi3C10IOU3nmaO4gV09Kbp6P+ym2Vk6R2xFuoYi9M9bIptHZpA IGnFK7yMcVjKE8N+IKKxfysWXqykKwgXM0WTxKp+dQVvrFQgTzKlE1GZ7FDTi4xsDKQn DlQdNy5wugIVp0S/N0UH/IPNNAb3x9804HAQ/9QLA04+2BwZTwlJffjW5eGKIrFipKde dV8b0tl+wK/nmgVfTbnoSggu+oF/KoCo+YC9fUW9QvFAr/fAAA6dUBCFEqQXb/bZweHG Qa3CT6nxCbTnrIDp8+JIGguiINRR4llBOTQgW7TxD4kAY0BpAfTwgPxOio2DjHl1zCeH op3Q== X-Gm-Message-State: ALKqPwdGwv8zjnp0MqnUIFkWNH5QVD2+KDVL2uPAIll7Gijdtc+InuDu GeXGpM0EPqcZ/7b/6OuHZQBs2iyMlPM= X-Received: by 2002:a65:498e:: with SMTP id r14-v6mr7781893pgs.78.1527838276415; Fri, 01 Jun 2018 00:31:16 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:33 -0700 Message-Id: <20180601073050.8054-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 16/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 77 +++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 34 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e208f8647a..b5736436f8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8078,6 +8078,43 @@ 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 + +#if defined(TARGET_NR_linkat) +IMPL(linkat) +{ + char *p1, *p2; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p1 = lock_user_string(arg2); + p2 = lock_user_string(arg4); + 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; +} +#endif + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8315,40 +8352,6 @@ IMPL(everything_else) char *fn; 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: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - 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))) @@ -12958,6 +12961,12 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_fork [TARGET_NR_fork] = impl_fork, #endif +#ifdef TARGET_NR_link + [TARGET_NR_link] = impl_link, +#endif +#if defined(TARGET_NR_linkat) + [TARGET_NR_linkat] = impl_linkat, +#endif #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif From patchwork Fri Jun 1 07:30: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: 137479 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp615574lji; Fri, 1 Jun 2018 00:47:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKCyw0b/nxoOmw2si0b+lU5H1eDhGvWdvvE5RLN8dOHMjl1wYRs+oi0kwz3O0ACEr2ZQ+lr X-Received: by 2002:ac8:30b1:: with SMTP id v46-v6mr10099218qta.353.1527839249955; Fri, 01 Jun 2018 00:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839249; cv=none; d=google.com; s=arc-20160816; b=SEI8PdknF7IEK/eP9thaNhHG4M/wSmYn56rb52aARhfrlAOi+b+OoDUfyAOXSvDos0 XcBKXeAYgzUj6r//xWowhpx8ejnbLe4STrKCYPwSJEcP2vclp+/yUFWCa9kUDeYHiZP5 zTGVePojV8BxI1hrQPSCD/j2p85RLlKspm+NomSTp5vIdq+9yzsuhGHMHmRw7D2rJljP lLtiIuWA1K52YbxVkly+0VqvPdUTHtS/04aR1lyjMWOqQ3qpewPV/kIuZ0fqqvv684Dv xbTPrn9cbQjYJvTZ9flEJIDBzVn8yWi+slOM23zheQbtguBEscghW7X7oWcN0E1kBSrM Qc3A== 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=DJHyjL+tq2NbJ5wT/xWlzt5ykrkXQ2pykteKcZn2KLM=; b=EiaehIxgQtAQgJGjtntlzm2A/QCy47R9ffIeIu2v5raHXn/ykFrF2h1nmV+u+jpjU3 uUL/Eg5XFJSgmT3TisRNxBtI1+7hRRJ2Klr/RjYkFTzs8JQtsdwSRIwNiJSmPofQdP5e 9rWR92aLYT1Z9pNZUiMJ7Cts3F7NjUdX+We/x5Nv3dhgDWh6ppjEwSEpQQolQQHaHfL9 xy4AiXXopufNWzcL2+EUBfvFB8tcXSYcQlyYVh4CwoEliF6vuv78uPCQI4aJToOqBduh 7Zauv01zC1EA4Egk4laSPVsCLsitLDlBiyiw61RNpeEh1z0GafsOHFa+FNWeJ6d/51OP m2SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=exp9jqN6; 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 n64-v6si5505953qkf.210.2018.06.01.00.47.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:47: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=exp9jqN6; 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]:47898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOemX-0001VG-EB for patch@linaro.org; Fri, 01 Jun 2018 03:47:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWu-0005bg-07 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWt-0000Xv-37 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:36696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWs-0000X1-TL for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: by mail-pf0-x22f.google.com with SMTP id w129-v6so12092166pfd.3 for ; Fri, 01 Jun 2018 00:31: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=DJHyjL+tq2NbJ5wT/xWlzt5ykrkXQ2pykteKcZn2KLM=; b=exp9jqN6xtuE2CnKloiKnxz05GgmCjjvgnZAi78f9/GHYwAmDu9abrvH7dhPMWIObg vykkttvqsmr3IYEbfFZ1uY1aZmleHy5KIJQQgsLklGwIcPan83EKKh7AFxdiCXQ4XpEn qAczLEN4zN5yoyfqe4c3qpLfnSu2aQXzlzSEw= 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=DJHyjL+tq2NbJ5wT/xWlzt5ykrkXQ2pykteKcZn2KLM=; b=gvIONJ8mTZS6NqIx9nn2+c3rfBiz9xpGang60DZ06679uSYt1iKB0ofoApXC0u74Pn ZoyQ11RHCfm4cWUWyRTpXdkUoizWFQKwZbwFOMCVZpTjbzFAmzOtumgl9izqDrqA3VJZ qbZ+uxCN/ZWZsPDvAMLINPr5Zx1kLY9ojrW03/WA6xA9rRWnK6UPe7jTbMvNzq7i28gO JFHUDLuE+HchM5cT8/3PXyf3UCQYrIx/8/eDgkORQWuzLdLCf6mJFGbsEMRwy+Zpp5dW Ii+CNO/GsHLTJRyyOTYpIAddQPoiumTU7+5Rh8vtYnUvrakvbWugq8nOAx9sy7EMCQyy qHlQ== X-Gm-Message-State: ALKqPwe5DGv0oZ1240tk9TjEkcf/XgaKby27z5LyS4+wL/fKQKzsGM/6 oNIWbsjZvi42pC7qkcPN+6c3ITmaR+s= X-Received: by 2002:a65:6354:: with SMTP id p20-v6mr8085837pgv.437.1527838277660; Fri, 01 Jun 2018 00:31:17 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:34 -0700 Message-Id: <20180601073050.8054-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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::22f Subject: [Qemu-devel] [PATCH 17/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 59 ++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b5736436f8..bbe9d6d9fb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8276,6 +8276,40 @@ 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 + +#ifdef TARGET_NR_unlinkat +IMPL(unlinkat) +{ + char *p; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(unlinkat(arg1, p, arg3)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_waitid IMPL(waitid) { @@ -8352,25 +8386,6 @@ IMPL(everything_else) char *fn; 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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; @@ -12978,6 +12993,12 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_unlink + [TARGET_NR_unlink] = impl_unlink, +#endif +#if TARGET_NR_unlinkat + [TARGET_NR_unlinkat] = impl_unlinkat, +#endif #ifdef TARGET_NR_waitid [TARGET_NR_waitid] = impl_waitid, #endif From patchwork Fri Jun 1 07:30: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: 137482 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp617275lji; Fri, 1 Jun 2018 00:50:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlD7to23PCUcJm4xif5EaM5znH3UuJRDw+fHiie9H2IkYY9g1sOPOTHPDHzEBdMOKXyH1h X-Received: by 2002:ac8:903:: with SMTP id t3-v6mr9798999qth.13.1527839401887; Fri, 01 Jun 2018 00:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839401; cv=none; d=google.com; s=arc-20160816; b=b61u6II6FEg/RXCoO8km5hS20foh6B23WbAGdaVHULl/dvhl2Jhmdai4CA7WgSgjRx xmZtlo82aIaZsnVLUklLwA3uMW+VQdzTeBN6e1oAgVKjlgRYRUwFYgdM+A+t3/fQL8MA TV2Ax9lLX6fNd3ufHf3CpbTJvBAh917Eu6Z6mailAbCkoaSam+08uZADDPTNyeJLxtqy N4EG92/KpkFB+zsBB8afClKgJrr/XoI3Q/Q/oMIeW92Jh8FQOSlIB8Uv1O3/uBw+SOFC jvPzv8fO+PQQ2VL+nStdp6KWPXaUQb8+5UvybB9rD3cHOQlq7rZIJHzObQVYghFXB76g bb8w== 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=NfK2ULHt59OsEZX575iSOsaHZgk6G06nDKHtF+dJs3c=; b=Ijrnh7z+a+uoVRHj9Cit/PMj1H2wWIZOcmKr3lW6dXZpjym2AlE98PEt7+HB/JUHak aDNuUgaavTAriFpNeDAHEa5l35eBAtVp0L+iB+qGKF7zGwiTXXKo5JQna2k20QTFmYTi a9mnOnH7Ti5C4KK1UrxRqWCUppOvYgA1ugLY3USJ4MuCI4efL1Uo/ce1s87PyslDozao 9JdRljZxGAAnoL0wGUrMGTfMD20Crds5tDINV3t6T8Qlr3g33RUROtWI87QSHH+UqI1t MUOBK/e7mf+Vwknp3rU88mbHXBoDafyYqmhmO5+E8ep2Jb8WtR31X00O+cH1QKiJTkP/ ofxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YohMcLNG; 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-v6si1476735qtg.224.2018.06.01.00.50.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:50: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=YohMcLNG; 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]:47903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeoz-000262-AH for patch@linaro.org; Fri, 01 Jun 2018 03:50:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWv-0005dJ-IO for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWu-0000ZA-Ku for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:21 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35084) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWu-0000Ya-DS for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:20 -0400 Received: by mail-pf0-x243.google.com with SMTP id x9-v6so12086226pfm.2 for ; Fri, 01 Jun 2018 00:31: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=NfK2ULHt59OsEZX575iSOsaHZgk6G06nDKHtF+dJs3c=; b=YohMcLNGy+o3QjE9srFUHHl2DDWKTy/BDh14Vnmq912V1SALc24oeVEcJ1piT+HBVB xPtv04ls+oIB3D2vaUPuPBrfZV7JGBx0NIJSLruKRGctQ053NZ0bkrIGj+TbZJE2Fbzz yR+mJFaQTjG9zkZSbGaxfM6mCTyyr2J2aWam8= 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=NfK2ULHt59OsEZX575iSOsaHZgk6G06nDKHtF+dJs3c=; b=GNv/leeeiHKz7hZ/Xim/Yxogu0e2NjxTy1Dsql4/u8OYiKS39E7L0UYi+NjMNJLUeQ eq9ZGv+v7bwFJocMcLXDMkcFPZY/xmbYFqhGwjAmBajpYA529pz1IZIrbppuXoTqG7Pe vGJn01JjzLZQrGwbU7lZb8AdegCbK0uQ/vIc8m8Ivc7ZydxwBaMN4/5Ra1R2+LCuO1Y+ izWLkpFgr4+JSWDnmrURtcOsVBFnwIuYtHXl3mJFrEPZxO77eRfwxwTikzCxjOz19BfD RhmVG/7t8ja8D7RC0StJ8lN97R7JNcRmuaZHCh3m0fYuQRSIgomKJVB4wEsqr7gNJD/h btvQ== X-Gm-Message-State: ALKqPwe65srvy+hCD5E29k8JnmjSK1XIOtdCNCxHwAq37eQA+ZsGlGM9 ff5SZFKRhawOPCmIkTqDg2FZCtYTxBI= X-Received: by 2002:a63:b257:: with SMTP id t23-v6mr5037123pgo.431.1527838279140; Fri, 01 Jun 2018 00:31:19 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:35 -0700 Message-Id: <20180601073050.8054-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 18/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 132 ++++++++++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 45 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bbe9d6d9fb..88e0da31ba 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7899,6 +7899,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) { if (is_hostfd(arg1)) { @@ -8115,6 +8143,40 @@ IMPL(linkat) } #endif +#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 + +#ifdef TARGET_NR_mknodat +IMPL(mknodat) +{ + char *p; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mknodat(arg1, p, arg3, arg4)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8276,6 +8338,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) { @@ -8386,51 +8460,6 @@ IMPL(everything_else) char *fn; 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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 #ifdef TARGET_NR_break case TARGET_NR_break: return do_unimplemented(num); @@ -12968,6 +12997,10 @@ IMPL(everything_else) static impl_fn * const syscall_table[] = { [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, + [TARGET_NR_chdir] = impl_chdir, +#ifdef TARGET_NR_chmod + [TARGET_NR_chmod] = impl_chmod, +#endif #ifdef TARGET_NR_creat [TARGET_NR_creat] = impl_creat, #endif @@ -12982,6 +13015,12 @@ static impl_fn * const syscall_table[] = { #if defined(TARGET_NR_linkat) [TARGET_NR_linkat] = impl_linkat, #endif +#ifdef TARGET_NR_mknod + [TARGET_NR_mknod] = impl_mknod, +#endif +#ifdef TARGET_NR_mknodat + [TARGET_NR_mknodat] = impl_mknodat, +#endif #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif @@ -12993,6 +13032,9 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_time + [TARGET_NR_time] = impl_time, +#endif #ifdef TARGET_NR_unlink [TARGET_NR_unlink] = impl_unlink, #endif From patchwork Fri Jun 1 07:30: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: 137478 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp614945lji; Fri, 1 Jun 2018 00:46:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKdj+/EJjkCJx1iq9twMen24kWZVpWRrNX4oZHFim0nP3KhlIcFPx8u1g/q/1Qsz5HPX3am X-Received: by 2002:ac8:27ce:: with SMTP id x14-v6mr9250593qtx.171.1527839203707; Fri, 01 Jun 2018 00:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839203; cv=none; d=google.com; s=arc-20160816; b=ro28xGLUUn14loTEJafsH0Gz8390dTNcNzcyDAUbHL22VI1rzLvUv7rU4vkJg0HLaW 8P4YJDCqxlEKwLVtfJ3ikt7JyBG+7BBGNB7BkUZyYU/rJ6iK0mEzUGHJZuCmb8OGh0bL zdrPEPKs183Py2MWOX4fgYJVTULszYOvTDkWN5IpaifQ6nec0kgRIv3jLgHlalwBIbyv LS4VV1eVVavBE4K28JMoHi+KkkvgvQfZ/WAUl3jN4p/Mkw0LPikCnYupgAUT1Meg+uzI y1bOdZidmuuYvft1zs8vNWk99Sj4cu+90rkoDd5UKygQEfmrpYCbNZPOJ3hFS86KQyJK VOZg== 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=eDDYKmMROVWD/d0Q2XV5jyBE9VfX9oJROc52warn9p4=; b=hG7TuArcvgNeali7EOW815shbGK3MhVbD8N7O3uSLPhze7KxcHI3LnS544B+eE4vFy cMOU0qwC3lvY3pW4l4aQmapWGOYXWXAO8D7Et83iJyNfjmfR1NLDXe7IHssOBq4OOnrB OBwdDVM4wqUmw4niBo3jgne8+ZTpoWqfM44Dx5mwQ3UciZB2Po5khIiv45+vhpe4Zcrs MVCQRvJRRn/VZCWNqd01i5L884DUroYWLN7KnuM5Bt/7O5lrNch8fvEVDWHzMgyyFhA9 3E6uQ9FJDu/gn2hrXQCBYk8MGoSKcLp0M5sSPDNX/QKptOSg+DglLCP6hAgE59dDF/pg p5tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TiiD0C3g; 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 k186-v6si728945qkf.286.2018.06.01.00.46.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:46: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=TiiD0C3g; 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]:47895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeln-0000a4-4b for patch@linaro.org; Fri, 01 Jun 2018 03:46:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWx-0005fN-Kp for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWw-0000ak-8C for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:23 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:35484) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWv-0000Zu-W2 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:22 -0400 Received: by mail-pl0-x242.google.com with SMTP id i5-v6so14820540plt.2 for ; Fri, 01 Jun 2018 00:31: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=eDDYKmMROVWD/d0Q2XV5jyBE9VfX9oJROc52warn9p4=; b=TiiD0C3ghlOJfarD3egpJBZ0xO4WJCnuL+hYj1Zr+jOCv38Unv03hVvCcBOvLFQiVf 1Ev9CPNpYlyJyq4N72Q/zgPRdtJzPE+1XR7GrlFmf7zHsr4CPQkUet6pTKuPViv26E1V ULqJ8eYZ5P0puKLtXshX1gNGegb9IkaE2sFFU= 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=eDDYKmMROVWD/d0Q2XV5jyBE9VfX9oJROc52warn9p4=; b=gh2VAxy/Fs4KeIxhoOjYDOt7Za2CvHxl3TLfwpd+r5dW1KSvB5nUdnD036p7npXvhR 7tJwepwvoOD6eF+n78LY5cWrEMDUB+xNUc9wmSGrl95PmPfm4tNifw59yXbGrhsLpct7 fECY8qr3t/Js7hBuVkBlqTrnrbXRt/F4cE6gxowEs7w5foL3SgHDNqm+2fjoP+1GHuG4 2+czi5cMlYi3sqMGv75ycD2WmIsxYEcxzXWBHECa8JTzStbTusEMdW0sTRDsEooDXa5n 1zi/tKn3S2NgmBRHzpYRxOZ3LmBYbrRuAnaQyvYYRx9a+jM9lhFLDoOuvRB6Ut8HaROV Ce7Q== X-Gm-Message-State: ALKqPweyZAhASKaIOJXkaFvQXER8/etTtNaUBmr5aUHlXLZ4qiFqU6NQ sPjB77bFPVxQ+8H9nJIup2F6yDvnUls= X-Received: by 2002:a17:902:b488:: with SMTP id y8-v6mr9900587plr.157.1527838280673; Fri, 01 Jun 2018 00:31:20 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:36 -0700 Message-Id: <20180601073050.8054-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 19/33] linux-user: Remove all unimplemented entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no reason to list these, since -ENOSYS is the default. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 140 ------------------------------------------- 1 file changed, 140 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 88e0da31ba..6a701ea8f6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8460,14 +8460,6 @@ IMPL(everything_else) char *fn; switch(num) { -#ifdef TARGET_NR_break - case TARGET_NR_break: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_oldstat - case TARGET_NR_oldstat: - return do_unimplemented(num); -#endif case TARGET_NR_lseek: if (is_hostfd(arg1)) { return -TARGET_EBADF; @@ -8555,16 +8547,10 @@ IMPL(everything_else) return get_errno(stime(&host_time)); } #endif - case TARGET_NR_ptrace: - return do_unimplemented(num); #ifdef TARGET_NR_alarm /* not on alpha */ case TARGET_NR_alarm: return alarm(arg1); #endif -#ifdef TARGET_NR_oldfstat - case TARGET_NR_oldfstat: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_pause /* not on alpha */ case TARGET_NR_pause: if (!block_signals()) { @@ -8640,14 +8626,6 @@ IMPL(everything_else) } return ret; #endif -#ifdef TARGET_NR_stty - case TARGET_NR_stty: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_gtty - case TARGET_NR_gtty: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_access case TARGET_NR_access: if (!(fn = lock_user_string(arg1))) { @@ -8678,10 +8656,6 @@ IMPL(everything_else) #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: - return do_unimplemented(num); #endif case TARGET_NR_sync: sync(); @@ -8805,14 +8779,6 @@ IMPL(everything_else) ret = host_to_target_clock_t(ret); } return ret; -#ifdef TARGET_NR_prof - case TARGET_NR_prof: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_signal - case TARGET_NR_signal: - return do_unimplemented(num); -#endif case TARGET_NR_acct: if (arg1 == 0) { ret = get_errno(acct(NULL)); @@ -8832,31 +8798,15 @@ IMPL(everything_else) ret = get_errno(umount2(p, arg2)); unlock_user(p, arg1, 0); return ret; -#endif -#ifdef TARGET_NR_lock - case TARGET_NR_lock: - return do_unimplemented(num); #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: - return do_unimplemented(num); #endif case TARGET_NR_setpgid: return get_errno(setpgid(arg1, arg2)); -#ifdef TARGET_NR_ulimit - case TARGET_NR_ulimit: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_oldolduname - case TARGET_NR_oldolduname: - return do_unimplemented(num); -#endif case TARGET_NR_umask: return get_errno(umask(arg1)); case TARGET_NR_chroot: @@ -8865,10 +8815,6 @@ IMPL(everything_else) ret = get_errno(chroot(p)); unlock_user(p, arg1, 0); return ret; -#ifdef TARGET_NR_ustat - case TARGET_NR_ustat: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_dup2 case TARGET_NR_dup2: if (is_hostfd(arg1) || is_hostfd(arg2)) { @@ -9585,10 +9531,6 @@ IMPL(everything_else) } return ret; #endif -#ifdef TARGET_NR_oldlstat - case TARGET_NR_oldlstat: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_readlink case TARGET_NR_readlink: { @@ -9650,10 +9592,6 @@ IMPL(everything_else) } return ret; #endif -#ifdef TARGET_NR_uselib - case TARGET_NR_uselib: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_swapon case TARGET_NR_swapon: if (!(p = lock_user_string(arg1))) @@ -9675,10 +9613,6 @@ IMPL(everything_else) ret = get_errno(reboot(arg1, arg2, arg3, NULL)); } return ret; -#ifdef TARGET_NR_readdir - case TARGET_NR_readdir: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_mmap case TARGET_NR_mmap: #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \ @@ -9813,10 +9747,6 @@ IMPL(everything_else) return ret; case TARGET_NR_setpriority: return get_errno(setpriority(arg1, arg2, arg3)); -#ifdef TARGET_NR_profil - case TARGET_NR_profil: - return do_unimplemented(num); -#endif case TARGET_NR_statfs: if (!(fn = lock_user_string(arg1))) { return -TARGET_EFAULT; @@ -9892,10 +9822,6 @@ IMPL(everything_else) ret = get_errno(fstatfs(arg1, &stfs)); goto convert_statfs64; #endif -#ifdef TARGET_NR_ioperm - case TARGET_NR_ioperm: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_socketcall case TARGET_NR_socketcall: return do_socketcall(arg1, arg2); @@ -10173,20 +10099,8 @@ IMPL(everything_else) } } return ret; -#ifdef TARGET_NR_olduname - case TARGET_NR_olduname: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_iopl - case TARGET_NR_iopl: - return do_unimplemented(num); -#endif case TARGET_NR_vhangup: return get_errno(vhangup()); -#ifdef TARGET_NR_idle - case TARGET_NR_idle: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_syscall case TARGET_NR_syscall: return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, @@ -10364,8 +10278,6 @@ IMPL(everything_else) case TARGET_NR_modify_ldt: return do_modify_ldt(cpu_env, arg1, arg2, arg3); #if !defined(TARGET_X86_64) - case TARGET_NR_vm86old: - return do_unimplemented(num); case TARGET_NR_vm86: return do_vm86(cpu_env, arg1, arg2); #endif @@ -10402,17 +10314,6 @@ IMPL(everything_else) } 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 - return do_unimplemented(num); - case TARGET_NR_quotactl: - return do_unimplemented(num); case TARGET_NR_getpgid: return get_errno(getpgid(arg1)); case TARGET_NR_fchdir: @@ -10420,20 +10321,8 @@ IMPL(everything_else) return -TARGET_EBADF; } return get_errno(fchdir(arg1)); -#ifdef TARGET_NR_bdflush /* not on x86_64 */ - case TARGET_NR_bdflush: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_sysfs - case TARGET_NR_sysfs: - return do_unimplemented(num); -#endif case TARGET_NR_personality: return get_errno(personality(arg1)); -#ifdef TARGET_NR_afs_syscall - case TARGET_NR_afs_syscall: - return do_unimplemented(num); -#endif #ifdef TARGET_NR__llseek /* Not on alpha */ case TARGET_NR__llseek: if (is_hostfd(arg1)) { @@ -10975,14 +10864,6 @@ IMPL(everything_else) } } return ret; -#ifdef TARGET_NR_query_module - case TARGET_NR_query_module: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_nfsservctl - case TARGET_NR_nfsservctl: - return do_unimplemented(num); -#endif case TARGET_NR_prctl: switch (arg1) { case PR_GET_PDEATHSIG: @@ -11223,21 +11104,6 @@ IMPL(everything_else) return ret; } #endif -#else - case TARGET_NR_sendfile: -#ifdef TARGET_NR_sendfile64 - case TARGET_NR_sendfile64: -#endif - return do_unimplemented(num); -#endif - -#ifdef TARGET_NR_getpmsg - case TARGET_NR_getpmsg: - return do_unimplemented(num); -#endif -#ifdef TARGET_NR_putpmsg - case TARGET_NR_putpmsg: - return do_unimplemented(num); #endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: @@ -11801,8 +11667,6 @@ IMPL(everything_else) return get_errno(setfsgid(arg1)); #endif - case TARGET_NR_pivot_root: - return do_unimplemented(num); #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { @@ -11972,10 +11836,6 @@ IMPL(everything_else) /* self-modifying code is handled automatically, so nothing needed */ return 0; #endif -#ifdef TARGET_NR_security - case TARGET_NR_security: - return do_unimplemented(num); -#endif #ifdef TARGET_NR_getpagesize case TARGET_NR_getpagesize: return TARGET_PAGE_SIZE; From patchwork Fri Jun 1 07:30: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: 137485 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp619492lji; Fri, 1 Jun 2018 00:53:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4ZnFaKu08h2CwkYXplGdsCZbb9QhIkS9wQCfNlDZxJOXxWjPeyhkhwezpHXEu0fm3Wjqj X-Received: by 2002:ac8:34f1:: with SMTP id x46-v6mr9791781qtb.135.1527839588768; Fri, 01 Jun 2018 00:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839588; cv=none; d=google.com; s=arc-20160816; b=qEPnwyHH38h3tX4ATfOOwpttdVW6bPOXOJLMudMqi/gNL54L58Jw+7ZryZnOkf7691 9KPoQSpl62sJlk06307oLETHFjmXQ4gtW7hjr3FtdlnfUOkPzRYIydz4pjh20jPkX6Gd 1RApZG7mOeBTZOpG6+cEJawEKfaX/EugplxNbyOvNiNZyksB8yjkiQc097SUqxQ3KdUk 8Rtrowffxlc2FFvMtlWNby1mwTIDCbVzlkUvHjN/405STVOJ5C11TevdDklfqE35vL3q wZaGPEkw1/OSRWoGYNasuPRuQ+MGTzcqT4zfdKgJaQ+hmt1GbmkV5PeXbPrsUSv5hOAe bp8Q== 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=0BslVQ5gJKshsDyU0oWNTmplcPAKwDJr0uW2lGkq6xE=; b=wjs1N0fJeihzL+LkvUKJF6Tj0Ql1UvUh7n4t5yelSArehk/Mv1Gw36WNRhbX7pR8Qt erI2KgOzlbqt9Kfuk+dp+kK2fj1Ls8DexEaynndg2XhRiO7RCt3N2yygmLkaDOk4ZzcU Xsqgvlvf7iCSnLkiQPRFXtNs6y2DnBV76rhjQP2iymdnhsu1/1azhNAo8rK6Pgkq34RA XJ33vg6Jiu1wOlluTKwX/SXZMGmJZXmf+/aSU/jjdm9w3S3aW8AHFI88PZSOh7YBws+b vjxyT9TItWcNNZ/DCN+HET3jyTFum64qvpagh5iuUKIqg4vBaz3Prr//4GSEuWYNkPqm OiCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JUdDgDh2; 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 f5-v6si1051561qvi.257.2018.06.01.00.53.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:53: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=JUdDgDh2; 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]:47920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOes0-0004b3-6v for patch@linaro.org; Fri, 01 Jun 2018 03:53:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWy-0005gQ-FH for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWx-0000c8-IC for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:24 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:33834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWx-0000bR-CD for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:23 -0400 Received: by mail-pl0-x243.google.com with SMTP id ay10-v6so14819429plb.1 for ; Fri, 01 Jun 2018 00:31: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=0BslVQ5gJKshsDyU0oWNTmplcPAKwDJr0uW2lGkq6xE=; b=JUdDgDh2h2DO5l0ItUYYNomc6VoVs6MdaB7EtjIKLs8gfpesuc8ievAtOS9hXWizC5 hNTbzmJCfSia+BlEC5mdSmL/yJ288GnvRt1RRDXDXOmE91+SvbriLeKECqD+eFXQgxIa qmGAJxoXJ9+CBQkHwqUdoxH0AHQgBV48JTt+k= 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=0BslVQ5gJKshsDyU0oWNTmplcPAKwDJr0uW2lGkq6xE=; b=lyet1L+n3IdfgEhNlKdNhFAVS8tYHxKisMEX2rHNhMKCWDDfXQcnZzSuRFbYqOV/tL xQy7iBYsWJUin6zYFVAYS6tSxdDLzglDQEZ6MfrmJwaEdjXQXWccAoBIYzive57x+Ava 0JJVGOI/7vhsCR5KYjcQoxYvcQcWtX2qGYtCTd0g5gc+InoNOkNAaW40YpNhLWGDiBpb 4zh4NV1Epf0DPVKp3w3m4GGQwKkX1V3QJmyreHOFuw5H+OSJnlXBp/4MPjQcSkUq5/F/ +fl7Y/vznkTtdkyMjsoQPsqtLeAwFa/pUNSlyWocehkQzwa0ftWvnZy7UfS4Q3j619O/ zz7A== X-Gm-Message-State: ALKqPwdFmsl1xwYJqiqFqnPNFMzdbFX4x7JZe9kYkRXicIlClKtNYmfQ PwM0RzUb9I+jDVM4oBq0wDmTymCWeeA= X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr10350070plb.24.1527838282110; Fri, 01 Jun 2018 00:31:22 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:37 -0700 Message-Id: <20180601073050.8054-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 20/33] 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 | 45 +++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6a701ea8f6..b568144369 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8106,6 +8106,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) { @@ -8143,6 +8158,14 @@ IMPL(linkat) } #endif +IMPL(lseek) +{ + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + return get_errno(lseek(arg1, arg2, arg3)); +} + #ifdef TARGET_NR_mknod IMPL(mknod) { @@ -8460,21 +8483,6 @@ IMPL(everything_else) char *fn; switch(num) { - case TARGET_NR_lseek: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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 */ @@ -12869,12 +12877,19 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_fork [TARGET_NR_fork] = impl_fork, #endif +#ifdef TARGET_NR_getpid + [TARGET_NR_getpid] = impl_getpid, +#endif +#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) + [TARGET_NR_getxpid] = impl_getxpid, +#endif #ifdef TARGET_NR_link [TARGET_NR_link] = impl_link, #endif #if defined(TARGET_NR_linkat) [TARGET_NR_linkat] = impl_linkat, #endif + [TARGET_NR_lseek] = impl_lseek, #ifdef TARGET_NR_mknod [TARGET_NR_mknod] = impl_mknod, #endif From patchwork Fri Jun 1 07:30: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: 137484 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp619210lji; Fri, 1 Jun 2018 00:52:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKfv0YA3rtctBRMn9wjXKd5/Fd7DfATy0g8y75Ge7UxV4PlIrQA35dWtpU2GCCVCJ/byLSh X-Received: by 2002:ac8:1692:: with SMTP id r18-v6mr955341qtj.206.1527839565159; Fri, 01 Jun 2018 00:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839565; cv=none; d=google.com; s=arc-20160816; b=Kwd4CL313qNGhddvScmIOwWGaxsKMZI1UY/XsJeSRJwzXKEI7uOyn4Jszq8LRp422F 8tHCVIT6lZvdINe0wCaxm3UcrDGQBXdh192SUiUpbwkbEJB4+zbe1acDIOXcEbvc4W/h C137VPS1UUaU4Hq4+v6xhi2K7h6pu6wGdI9KCm8poQUMnLDzfd5PvNIpCf694gsXjXM3 0MntiKSLMtwsIviI0xC/8OQMIIQCC6FSpAZ4wStNT9WH1WtDj05Epg/AFlxvRrzYGV8x dIw+AXZQ1mwmQ1DOq9hCQ3g/5wVhN/tDaKUFUHeXJmYF9KAHBXvnmJRvu/UIDvl/Dv6M +JzQ== 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=6aIIKw0F62oZ4iVHgfIp5ONtm83n+9yFZisRzs60xiU=; b=A8TUY8PaybuqpYZOQi2YrITRG2mdI1xBOc1QslfgreMeIZqPwHeCRW8bM2YPHAWlyC tagXeAcAkbfae3sMc2Q+7EIcyouNl05cyvSQAOgIF7N7Fyq32hQTGaT/T6gcypmDH8R/ i3C7PqXaYP5pXGDexG4Il82xknSYEqAlK+znSSKsuIrY5cmmLnhgYfuAsdqNx8YUhS2y RXkxyqCM6K5ISnD2YgIZfd1QV15rhrkpsK7vgOa4G4aE3rAB+oGt96+p4Bq7D16RrKBt Y0c3PnseFTyM9ceLz4I2ikbTNiKuis5Qqa4eefLYO6+PAcHZvEZSCqHAom0nA4qTCkgU LKlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dDpBvroR; 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-v6si9752991qkf.134.2018.06.01.00.52.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:52: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=dDpBvroR; 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]:47919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOerc-0004G7-Ix for patch@linaro.org; Fri, 01 Jun 2018 03:52:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX2-0005mO-He for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWy-0000dX-UD for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:28 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:36010) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWy-0000cy-Nn for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:24 -0400 Received: by mail-pl0-x244.google.com with SMTP id v24-v6so14818455plo.3 for ; Fri, 01 Jun 2018 00:31: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=6aIIKw0F62oZ4iVHgfIp5ONtm83n+9yFZisRzs60xiU=; b=dDpBvroR78DD3f3B7PdsuI+SBheovkYqMDOTOfbOt3zEuOgWucrleXYSxhkor1s/hd UN8vBI29bzKWjMWgyCQI7qTZG6hYufkwYCino1wa4OzMJGLaGR18XIhfdKifyzBXfPQv UU9EUk2OoyaktUakfJKqP2nP8hG471SHvxjS0= 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=6aIIKw0F62oZ4iVHgfIp5ONtm83n+9yFZisRzs60xiU=; b=n5xUOdBmUhluOTZLmARlOZu30zv8egJykEeyicq287ZF7JOSznwWEiXCGJfaEbxP7G EXtAyTnn4vpaNNXN13Y6uoQ8kUFi/8rs0W+jT6QyTGaExnrCybgTy7rPJcaUWgbwo6J0 tPX45K5EXSCfcVNQJFtjQX4mvi3OIjirb8EAGYo7VZ5BeHSS6opK/D/vKoSTCHh8FiGw jhmkN5pCT1SaUssce97AAra6I4eaB924Nfa1p3TjHesF/rvMeJ2dywnRyNHNms8kD7iF HQGs4zyCt1auuGLYW/3eapKfBn1YSJYfBBsnxB2Ml7kH6Pb8tj0d+8eYAV2YW5fjLM36 4P9A== X-Gm-Message-State: ALKqPwfU6pNZAn0U38xWIptWrCWBxnc2yQ//4vt9f/+hsY+zqlbB0rKZ 090lndQBjfsoYvS8bXFpViQdMGOwJ9k= X-Received: by 2002:a17:902:2966:: with SMTP id g93-v6mr10331817plb.250.1527838283518; Fri, 01 Jun 2018 00:31:23 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:38 -0700 Message-Id: <20180601073050.8054-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 21/33] 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 | 123 +++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 63 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b568144369..53eac58ec0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8200,6 +8200,47 @@ IMPL(mknodat) } #endif +IMPL(mount) +{ + char *p1 = NULL, *p2, *p3 = NULL; + abi_long ret = -TARGET_EFAULT; + + if (arg1) { + p1 = lock_user_string(arg1); + if (!p1) { + goto exit1; + } + } + 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); + + if (arg3) { + unlock_user(p3, arg3, 0); + } + exit3: + unlock_user(p2, arg2, 0); + exit2: + if (arg1) { + unlock_user(p1, arg1, 0); + } + exit1: + return ret; +} + #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) IMPL(name_to_handle_at) { @@ -8373,6 +8414,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) { @@ -8483,69 +8539,6 @@ IMPL(everything_else) char *fn; 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: { @@ -12896,6 +12889,7 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_mknodat [TARGET_NR_mknodat] = impl_mknodat, #endif + [TARGET_NR_mount] = impl_mount, #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif @@ -12910,6 +12904,9 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time, #endif +#ifdef TARGET_NR_umount + [TARGET_NR_umount] = impl_umount, +#endif #ifdef TARGET_NR_unlink [TARGET_NR_unlink] = impl_unlink, #endif From patchwork Fri Jun 1 07:30: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: 137487 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp619846lji; Fri, 1 Jun 2018 00:53:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKan1M+o1HyR9OUKbGY4ZUlxeTQZc271qpJ2FgxW0QsaG/UcWCZzA9vHqBKqBGmH9XBh3zG X-Received: by 2002:a0c:8cc5:: with SMTP id q5-v6mr9531012qvb.60.1527839621173; Fri, 01 Jun 2018 00:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839621; cv=none; d=google.com; s=arc-20160816; b=IIA0/k4AjwUSbiftFdM4a9Bg11nvtesjiKdhh7+cyNyGGVTpSFDjPFzGTrIS+EU9sU Ii2ENJ7Ql9JsyuwTOCkrjmfPp2b4vMqOLZReU59wsUqypD9fbOFXRBTaQ5aUv+Gvh+cN 0PpBzD/aOFUIzjKM5KRTFeX0ec+GEPdrF9V/z2TK0LWUbdy9Ve0kFEPaJeGKk7ljCVda ZFwp9GFVWF4gyzpWp0hNXTFQ2W9nvZh04saSsxcXDO9xUC7PlNfY+hHJ8xf4YbLkqxy0 2UvmOl+19UZB2A1mhStQs2IKGxkOyTBeC7oF6FuDLt2F6yrr1XoVZP8EH/SF/wpRGhdK YVgA== 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=ZvVg5wK8954hL+atm32Ly9+uBWGfMj4n89S+TMlRezQ=; b=Pn+jRw+E9y6L4VlE7TvniBDahHDliu78Z+2KT6meAajqHXte3XIPBbPIfUEpQ8unnZ 9hcuZflIZdvCvfRbUY2kNxQJekqMogMLXBLVZH/Pu1aIi1taBeSDEk80SaospgJCqAw7 01/5m/5tH6IINyJx+rYdxUGwohIFsP83mzlm0LcCvWcmV3bdgsMyRlvlbg/VcWRrAMa2 dIbX5o8elvaGpE0lNVqlNqccyBr2tyUU7lbUmvoEp4lo54QHv5tFoHQ2LgvjvsZtsrjq BJeUDd/ZC+VLj+g1DzviJMQ4cILvf3bNxCmKsO4RVAXTx14eNDXvxqMAVqhfyxslWjM8 isYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AJmfXCBP; 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 e37-v6si6936847qtb.5.2018.06.01.00.53.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:53: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=AJmfXCBP; 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]:47928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOesW-0005q4-KU for patch@linaro.org; Fri, 01 Jun 2018 03:53:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX2-0005mN-HM for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX0-0000fp-9G for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:28 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33008) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX0-0000eX-1q for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:26 -0400 Received: by mail-pg0-x244.google.com with SMTP id e11-v6so1684922pgq.0 for ; Fri, 01 Jun 2018 00:31: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=ZvVg5wK8954hL+atm32Ly9+uBWGfMj4n89S+TMlRezQ=; b=AJmfXCBPnQ4bWtRMWx+mMGJZYKu+RuKAo07SYb8PeUVDvZsboBUlok6eM0sD0sPlu3 kHeHz0OMqrIUMXNQca8TBfVTR8pLS1WEwp9MQ9U+/NoYoPxC4PreLTvBJxTgchg8BxaN oL4KA0JORINlfSc5RsfAVPWTqeIoK0chMLzoU= 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=ZvVg5wK8954hL+atm32Ly9+uBWGfMj4n89S+TMlRezQ=; b=KznbJY8BLtZ45c+XsaM+dH53+WJApH292X1Ne10c/CsoMmYXEAw5USPcyrU8GUIKyF svJLNaO+clHQ6MfHSR4YIUEEERT7Pjr5yz4Lv1/g4TJRhKsevZsjs6uSwfjtpD1A1ABW cmGEUi/j7TnFYgpXPcVxy0s3Dvht0z+fK7fmEFhOVBI/hfhs1qUil143CsElI2OvYhE9 dGHlESXmWXzWCMBd+hNtGZbn8j2yo1rgmQJwaGsEtf4hyjlDc7RoELvbav7RVYCHO9ez N45EIqHmnwP7odvOA+r8ybsxFWBB1a7D7NsDX/XGCyFgMMjl/ct9XzeT+IyzyPYp7VhD KvaA== X-Gm-Message-State: ALKqPwd05EnN77NARuT1uiLOfLN5EbdR+dNxnQGYIIUfrVmhMluy6Zud PoVh3+UB9MvnLwrhpx5bKtRcBMUzGZc= X-Received: by 2002:a62:4c04:: with SMTP id z4-v6mr9671130pfa.205.1527838284798; Fri, 01 Jun 2018 00:31:24 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:39 -0700 Message-Id: <20180601073050.8054-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 22/33] 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 | 156 ++++++++++++++++++++++++++----------------- 1 file changed, 94 insertions(+), 62 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 53eac58ec0..b3838c5161 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7894,6 +7894,13 @@ IMPL(enosys) return do_unimplemented(num); } +#ifdef TARGET_NR_alarm +IMPL(alarm) +{ + return alarm(arg1); +} +#endif + IMPL(brk) { return do_brk(arg1); @@ -8379,6 +8386,18 @@ IMPL(open_by_handle_at) } #endif +#ifdef TARGET_NR_pause +IMPL(pause) +{ + CPUState *cpu = ENV_GET_CPU(cpu_env); + + if (!block_signals()) { + sigsuspend(&((TaskState *)cpu->opaque)->signal_mask); + } + return -TARGET_EINTR; +} +#endif + IMPL(read) { abi_long ret; @@ -8402,6 +8421,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) { @@ -8463,6 +8493,55 @@ IMPL(unlinkat) } #endif +#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 + #ifdef TARGET_NR_waitid IMPL(waitid) { @@ -8539,68 +8618,6 @@ IMPL(everything_else) char *fn; 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: if (is_hostfd(arg1)) { @@ -12856,6 +12873,9 @@ IMPL(everything_else) } static impl_fn * const syscall_table[] = { +#ifdef TARGET_NR_alarm + [TARGET_NR_alarm] = impl_alarm, +#endif [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, [TARGET_NR_chdir] = impl_chdir, @@ -12899,8 +12919,14 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_openat] = impl_openat, #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at, +#endif +#ifdef TARGET_NR_pause + [TARGET_NR_pause] = impl_pause, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_stime + [TARGET_NR_stime] = impl_stime, +#endif #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time, #endif @@ -12913,6 +12939,12 @@ static impl_fn * const syscall_table[] = { #if TARGET_NR_unlinkat [TARGET_NR_unlinkat] = impl_unlinkat, #endif +#ifdef TARGET_NR_utime + [TARGET_NR_utime] = impl_utime, +#endif +#ifdef TARGET_NR_utimes + [TARGET_NR_utimes] = impl_utimes, +#endif #ifdef TARGET_NR_waitid [TARGET_NR_waitid] = impl_waitid, #endif From patchwork Fri Jun 1 07:30: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: 137483 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp618708lji; Fri, 1 Jun 2018 00:51:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJbD03qGT1DElNt1wM2PZlSyaBYVCE7tSmy7G8YxcgLnpe4APIMUqz4PBRXcLpsM9/r3l7r X-Received: by 2002:aed:2459:: with SMTP id s25-v6mr9742617qtc.289.1527839519701; Fri, 01 Jun 2018 00:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839519; cv=none; d=google.com; s=arc-20160816; b=H8ACRN3XhPY/zKlSdIWYdivDeRsRGZc32TLXJ/bZ8fCDZLX2IHpeLWGtcXrzHbyWyF mJiT5c554coiINXrh8ZarWz057xNz1LY9v/tRZSKEZWEa3OVUd+Bt3dVc6lfpcf3+wYI xcIsWVbtGH31KVyN5VIjeQdI//2g4l92FJdiP35hYl6U8UoCKEdoz+b1ejuEEJTe7aQW sZd/cmSaNXYc6jK89jk5V0xefrLfsW0Qc79/m9TDcaMkIyfQwoxAIHrPRjNHyhmm6TqM gGjpOWoYYuXwugnMkpafh2kSYp9DgKCFmCBXxB6R9P6DPh87oLhZdmogT/hOGd+IE9eq F/Qg== 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=GPs5t0l66EvKVvNNQI5eEapWRXFmwLFqtIpi2Zi6vkg=; b=aSC7UUi5z/ydI88yOhnQdkNYbs5engwlv04pLfiHsAtEzTlHoimf1ielGR1ks+Q/Y+ RsmQ+GoiiWMHzKuWowz6iIUzHuJLkykgONKKjIFjmLu1iroztL2Xt7MY5QdNDOuVTrCT rKTR730+HH3HcF4Ca8z5CO0bmWwxmPj1n8aJlCS7p3kr7W9GnNJL6ZlH8tIxqcT/JCQ2 GXroiZ/mi+x0u4FVAjIzhPdOobkuJ7z0UGs7ltFg1M/QbUvNro8lgid6MkIQIZxRmPho wPfr4JPxGmE+vHG+zd2Lz1+uMuSjYRcevrPg778hqwldK+Dzz1ks4RQ05K2dVr861iJB ENeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GzVaoyL7; 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 s13-v6si3997447qve.15.2018.06.01.00.51.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:51: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=GzVaoyL7; 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]:47921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeqt-0004rV-5Y for patch@linaro.org; Fri, 01 Jun 2018 03:51:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX3-0005mz-5m for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX1-0000hS-QX for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX1-0000gr-Iu for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:27 -0400 Received: by mail-pf0-x244.google.com with SMTP id x9-v6so12086382pfm.2 for ; Fri, 01 Jun 2018 00:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GPs5t0l66EvKVvNNQI5eEapWRXFmwLFqtIpi2Zi6vkg=; b=GzVaoyL7HWnaDxm7ukRwHElh580PUKoDU+y7T2edPq6ElyJ38vTquHkdBmjyOfNkJn A2IriDHbo9U2Sa6UPrWXvKkyZzaeMsReuUExEmkm95CpJmGifU2alHTv4AJVuzWktvtM avaNkcXphhJbKw23P8KsjRi+7H5bJvx9j/FdI= 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=GPs5t0l66EvKVvNNQI5eEapWRXFmwLFqtIpi2Zi6vkg=; b=Pgc7O0wmOqk8ZPklfcs3zYmyayLF8rXgX2YMITTvDrPYoGsbNbWMfuh9H4apk+Hxxa oL4cvLQzZdIfrBEBJX7W9KjPrYbae8XebMfsBbKiFOSWNUuBSPquwbzQJ8NuWyOPieBd Ff72Xc0HpM4XPpSk/El1ICRTqVQum8C4Mf0MOvKMv5ZriqKLtF9NaZvXX5jpFFaHcCQY vzDr76L8UqB0tg+WS04r3WF+NzfB+kXQost/vq1HxTgeDAfXYP78Ea5cWTusJ6vJt6S/ I1vF9ItiOXhyJrg8MWlEkZ1b3pKyQdaYTfUW80JCjCQDaQGdHv2dzMJ5lq1xsluHjdE2 Qw0A== X-Gm-Message-State: ALKqPwe+rgn9ThBVjy+e/lFyV67AzfMQk9Jhe2j+Ut+9/UKnLjRpmpLo VUXsz6DwsrEXbOt9tiubhxDuBfsDnUE= X-Received: by 2002:a62:808f:: with SMTP id j137-v6mr1568708pfd.91.1527838286242; Fri, 01 Jun 2018 00:31:26 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:40 -0700 Message-Id: <20180601073050.8054-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 23/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 179 +++++++++++++++++++++++++++---------------- 1 file changed, 113 insertions(+), 66 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b3838c5161..2a172e24eb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7894,6 +7894,24 @@ IMPL(enosys) return do_unimplemented(num); } +#ifdef TARGET_NR_access +IMPL(access) +{ + char *fn = lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_FD(ret, fn, + faccessat(interp_dirfd, fn + 1, arg2, 0), + access(fn, arg2)); + ret = get_errno(ret); + unlock_user(fn, arg1, 0); + return ret; +} +#endif + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8106,6 +8124,28 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef TARGET_NR_faccessat +IMPL(faccessat) +{ + char *fn; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + fn = lock_user_string(arg2); + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_FD(ret, fn, + faccessat(interp_dirfd, fn + 1, arg3, 0), + faccessat(arg1, fn, arg3, 0)); + ret = get_errno(ret); + unlock_user(fn, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_fork IMPL(fork) { @@ -8113,6 +8153,37 @@ IMPL(fork) } #endif +#ifdef TARGET_NR_futimesat +IMPL(futimesat) +{ + struct timeval tv[2], *tvp = NULL; + char *fn; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + 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; + } + fn = lock_user_string(arg2); + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_FD(ret, fn, + futimesat(interp_dirfd, fn + 1, tvp), + futimesat(arg1, fn, tvp)); + ret = get_errno(ret); + unlock_user(fn, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_getpid IMPL(getpid) { @@ -8128,6 +8199,11 @@ IMPL(getxpid) } #endif +IMPL(kill) +{ + return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); +} + #ifdef TARGET_NR_link IMPL(link) { @@ -8309,6 +8385,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) { @@ -8432,6 +8515,19 @@ IMPL(stime) } #endif +IMPL(sync) +{ + sync(); + return 0; +} + +#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) +IMPL(syncfs) +{ + return get_errno(syncfs(arg1)); +} +#endif + #ifdef TARGET_NR_time IMPL(time) { @@ -8618,72 +8714,6 @@ IMPL(everything_else) char *fn; switch(num) { -#if defined(TARGET_NR_futimesat) - case TARGET_NR_futimesat: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - 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 (!(fn = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - TRY_INTERP_FD(ret, fn, - futimesat(interp_dirfd, fn + 1, tvp), - futimesat(arg1, fn, tvp)); - ret = get_errno(ret); - unlock_user(fn, arg2, 0); - } - return ret; -#endif -#ifdef TARGET_NR_access - case TARGET_NR_access: - if (!(fn = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - TRY_INTERP_FD(ret, fn, - faccessat(interp_dirfd, fn + 1, arg2, 0), - access(fn, arg2)); - ret = get_errno(ret); - unlock_user(fn, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) - case TARGET_NR_faccessat: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - if (!(fn = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - TRY_INTERP_FD(ret, fn, - faccessat(interp_dirfd, fn + 1, arg3, 0), - faccessat(arg1, fn, arg3, 0)); - ret = get_errno(ret); - unlock_user(fn, 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: { @@ -12873,6 +12903,9 @@ IMPL(everything_else) } static impl_fn * const syscall_table[] = { +#ifdef TARGET_NR_access + [TARGET_NR_access] = impl_access, +#endif #ifdef TARGET_NR_alarm [TARGET_NR_alarm] = impl_alarm, #endif @@ -12887,15 +12920,22 @@ static impl_fn * const syscall_table[] = { #endif [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#ifdef TARGET_NR_faccessat + [TARGET_NR_faccessat] = impl_faccessat, +#endif #ifdef TARGET_NR_fork [TARGET_NR_fork] = impl_fork, #endif +#ifdef TARGET_NR_futimesat + [TARGET_NR_futimesat] = impl_futimesat, +#endif #ifdef TARGET_NR_getpid [TARGET_NR_getpid] = impl_getpid, #endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) [TARGET_NR_getxpid] = impl_getxpid, #endif + [TARGET_NR_kill] = impl_kill, #ifdef TARGET_NR_link [TARGET_NR_link] = impl_link, #endif @@ -12913,6 +12953,9 @@ static impl_fn * const syscall_table[] = { #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, #endif +#ifdef TARGET_NR_nice + [TARGET_NR_nice] = impl_nice, +#endif #ifdef TARGET_NR_open [TARGET_NR_open] = impl_open, #endif @@ -12926,6 +12969,10 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_read] = impl_read, #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, +#endif + [TARGET_NR_sync] = impl_sync, +#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS) + [TARGET_NR_syncfs] = impl_syncfs, #endif #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time, From patchwork Fri Jun 1 07:30: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: 137486 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp619565lji; Fri, 1 Jun 2018 00:53:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9ESaUVl61V8bWGj4ieGAvIvzlrX3gJo8FVi+gVhYIxfDdCoGV5Hf27RvfAPHg9Z+ae0kj X-Received: by 2002:ac8:686:: with SMTP id f6-v6mr10178016qth.348.1527839594999; Fri, 01 Jun 2018 00:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839594; cv=none; d=google.com; s=arc-20160816; b=YqfmEyJ1ikzCT4bXxzRipA9Viv6lBNcnNET4tleHOnf/KWaktOalNl6ZEqoX1Dzih+ cmzJjEj4p1YBFqJ+SyUcFdzGwbUGsXfLDoXg1nkKJUN4gUU7pSjGtM6i7hzclbWm26l3 CX6OkiBzCSv4oCS16C70jwmqq7zQxzGZOh2VM4dzqhV9DA3M8LtFt36AACzXQUB2IV2U 0bHsV4cOEVShC4XnJY8/JpZkQGSoxvHE9YNB+01FdXfDSsAFjqXLIgCETdsU+LajhupV lzScCNmyfEmyl+JwbUa71RKeEFu8AIE6Om5i1vwAZbI9CgWAB6VnOxMwKtNYTGBbGl5Z QOpA== 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=Y/6YpethMjyMjAPexK3JzdIUyBPsA29lqLFVZ4htKnA=; b=uTZ1VTe7NSWsnym6RbBnNHPkhJP60AbbXnYkIGzEsEdbO+SAMAbleKKJDbaJ6wy6Au wbaivL0zKpiB8hht7pgzgQmlu0Q4+DMi+EaGkGK45gxn3dUutNX54ojIToVpS1zEL6wY ZsRFBvQPDVhw1agV/mFBXxgleqcUc2GoeHFh0/Mg+UH4beADpn97YfieEkBC04LVNOBC pxft9/6fjeDZjVja9wn+kPiVECQHqzcNaln6zt9u7WXFjVYkmS2MavAbovw9AhPnImsp EyoZ1r7TRjAjsY6rE91hEjnXbuztAEY00pgXwOvfqs1c2UKykNvZYBvrOCqRfN4CB0d7 oYAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QyDRky5c; 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-v6si3248088qkb.380.2018.06.01.00.53.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:53: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=QyDRky5c; 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]:47926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOes6-0005WF-EB for patch@linaro.org; Fri, 01 Jun 2018 03:53:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX4-0005nz-3A for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX3-0000iZ-1j for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:30 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:43953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX2-0000hw-Sg for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:29 -0400 Received: by mail-pl0-x241.google.com with SMTP id c41-v6so14803978plj.10 for ; Fri, 01 Jun 2018 00:31: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=Y/6YpethMjyMjAPexK3JzdIUyBPsA29lqLFVZ4htKnA=; b=QyDRky5ca7M/l0voL2y8GED2oQJ8BBrkrjmocVyzz74orAKuaye7uzvckRZBBM38n7 8tnKusB+/0p6NjYOLwAyQ+IjRx6xhL6Wm6UMeBIkQZG90FKTsnbYoeBn71mWApNOEN1U 7SUajp0Yh2qdtDgxb4TPbcc3FubDMDz45bHes= 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=Y/6YpethMjyMjAPexK3JzdIUyBPsA29lqLFVZ4htKnA=; b=gTZ8+BqmUHmamU9fmFaLsY1Ls59RwM98oa1PZdmyv/HzP2Q8+NMeZBZpoLw5PfiMJE l9vSF6JRgV1XiZAGhdeoz3ThEMVXkzIPCDxA28vUylKPjep9et5wJIaxxuoveIYE8DnM /XI03nrvTErdwIoRizLdXY0o3f6XjOryjRxgQUpPyB+EambquaRDKSDvYH+obW5nva3n /SOxgHQqyGakpFdqHtimai5Z16OdV9DLgFS7HuNLNh/sIJbR71BFZsC5ZDgLM3asN3Vf 1b4HCil0Jo3sduzlHtsTa0QZ/v4+sDB4n7/BpnuKOg+NOsM5j0T9jbacWIOTBy+DIA0l AVQQ== X-Gm-Message-State: ALKqPwcGwOuLa5drtu3fILsuaz/0dn1z7kQZJXN2YfbHTau4qb0Fv8jo pzD4qzTVg7lIGJ5wdgP0ySj0WZJRN+Q= X-Received: by 2002:a17:902:64cf:: with SMTP id y15-v6mr10208924pli.53.1527838287638; Fri, 01 Jun 2018 00:31:27 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:41 -0700 Message-Id: <20180601073050.8054-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 24/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 113 ++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 50 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2a172e24eb..24514329b0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8504,6 +8504,60 @@ 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 + +#if defined(TARGET_NR_renameat) +IMPL(renameat) +{ + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + + 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 + +#ifdef TARGET_NR_renameat2 +IMPL(renameat2) +{ + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + + 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; +} +#endif + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8714,56 +8768,6 @@ IMPL(everything_else) char *fn; 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: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - 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: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } else { - 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))) @@ -12967,6 +12971,15 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_pause] = impl_pause, #endif [TARGET_NR_read] = impl_read, +#ifdef TARGET_NR_rename + [TARGET_NR_rename] = impl_rename, +#endif +#ifdef TARGET_NR_renameat + [TARGET_NR_renameat] = impl_renameat, +#endif +#ifdef TARGET_NR_renameat2 + [TARGET_NR_renameat2] = impl_renameat2, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif From patchwork Fri Jun 1 07:30: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: 137475 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp613146lji; Fri, 1 Jun 2018 00:44:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLCeIzn+P1kn0bKNJQqk1k0vo4RyXT3ImdUCj5Pd/+6WRVOBenXNyieiJfCC/VAdCKJ6rSz X-Received: by 2002:ac8:1798:: with SMTP id o24-v6mr10227743qtj.72.1527839073762; Fri, 01 Jun 2018 00:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839073; cv=none; d=google.com; s=arc-20160816; b=EWUusciJ68YMZfsVx5NmjfJRVC4OW86WkyhCLoVimJpGpZS/ojzOgOUOaaLFSC76ZW Hg36HlA7QKRmPCQPWtdq9W7v0OYvyD6AG4C1O+aXFbAWyH1KzG5gYhqI5v72ZyflrAF1 z6qVMqFIeQexdA/zTrxlxwFrvSU31nRKqHdGt1Tnrb89Od1ZhrAAd/SwCK7dbNYRc2m/ hWhMRLIVWHsclDlwHdtHhrgkGv4s4wyoV7pjlRsjPTjXc2unJy+Dp8IK3tj+YhM0+4jX POjgxRDRbYlPDKwwxuUKpsjColQq2S2xxiFubxEPnzu1EZaasQpUuhXaJgyCbHkp8CO3 kCVg== 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=7TG6NzpTpxsHJFgGfeNtYvgbvgcDYj1wa91hnUQOp/s=; b=jdzMBmzsOwA1fuVVtVTdBgj0n2jaxckciQExuNYZixaQSj7o7LZbTEHVywYMSsiXNw z7yYVPLYO7AzjLw6KaFfogCe2BVDcsZoxYZ5wy8a+BE6h/H1T2aZPcu9Kr3DySOiKQrQ x88vEAZknRXnTKpX7UiQDwBH/VBkZGOhqGgReT7jWDGV9YEC3XRXzGGZVtk2zzhxqCpP LPtHPwuSUdupOlsdKzgX41qthe45IAgDjQyY5e40T4rmmenRKQn5QIfifL821NpZRjtA 5KrYVqBQJXcMtLPR0x3yzKPgV94kOF+Ydqur15iLU7UaZxZNlVygefwFDJGcukC4mynv mLMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=das/cHMx; 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 w32-v6si1740374qtj.301.2018.06.01.00.44.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:44: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=das/cHMx; 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]:47872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOejg-0006Mi-3L for patch@linaro.org; Fri, 01 Jun 2018 03:44:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX5-0005p1-HH for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX4-0000jz-FG for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:31 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:37618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX4-0000jN-9T for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:30 -0400 Received: by mail-pf0-x241.google.com with SMTP id e9-v6so12083209pfi.4 for ; Fri, 01 Jun 2018 00:31: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=7TG6NzpTpxsHJFgGfeNtYvgbvgcDYj1wa91hnUQOp/s=; b=das/cHMxqXVkgfPWGUrJfLXn+eoe842KSVNr6eI+cY+p3fwY+ERBoNQODg7GZbHFtZ +aZcQVQCYUKUXtB9ydzLevK0Sho9ESTfUEXuKsXNf2lRa8x1uVGfO0gFuMLhrBkOiWIN dYny9X+BuezMB7REWBTTYVCKHMMyN5SiMLaaA= 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=7TG6NzpTpxsHJFgGfeNtYvgbvgcDYj1wa91hnUQOp/s=; b=QKPvoFifjzdZ7Gr4PkqdHf/n/Sd0XFRLq9ktn9769wqAP0L47zAlsfF86ZGElmt4Ca VqvmDSm607be/tG8rgGtgv4m3FBnOGFv9umG6mumG4dVDwlpnXDl1qWPuxYymJehob2b XvWCuOQYSeAwl9emN7551FRtwcdTh4KfqGvyPaRDX7D4dgfXvLXLeolh8T8jdjfiT77X ErJSsGIgX/gaf4M6a43QBe7BZjhdvzCcZsie/y7gMbx5aMgIPwQUp33OgF0ccijVAs6y /RsnIalR7UOcaXJ/k+IkuencjvsO+vSwKh4uxnDmSfS9epE9kG311JHkNOLMdYKlKJga Leow== X-Gm-Message-State: ALKqPwcUmZPNRVT/8o6Zfo9EmGl4lNPfyPWQywid7bTXtbPgafMrSjsf x9iUq2MdkNoALGh2MxkIUY4vCb4gKUY= X-Received: by 2002:a62:6c87:: with SMTP id h129-v6mr9741040pfc.179.1527838288950; Fri, 01 Jun 2018 00:31:28 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:42 -0700 Message-Id: <20180601073050.8054-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 25/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 109 +++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 36 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 24514329b0..36092d753d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7977,6 +7977,20 @@ IMPL(creat) } #endif +IMPL(dup) +{ + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + ret = get_errno(dup(arg1)); + if (ret >= 0) { + fd_trans_dup(arg1, ret); + } + return ret; +} + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8249,6 +8263,40 @@ 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 + +#ifdef TARGET_NR_mkdirat +IMPL(mkdirat) +{ + char *p; + abi_long ret; + + if (is_hostfd(arg1)) { + return -TARGET_EBADF; + } + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mkdirat(arg1, p, arg3)); + unlock_user(p, arg2, 0); + return ret; +} +#endif + #ifdef TARGET_NR_mknod IMPL(mknod) { @@ -8558,6 +8606,21 @@ IMPL(renameat2) } #endif +#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) { @@ -8768,42 +8831,6 @@ IMPL(everything_else) char *fn; 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 (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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); @@ -12922,6 +12949,7 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_creat [TARGET_NR_creat] = impl_creat, #endif + [TARGET_NR_dup] = impl_dup, [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, #ifdef TARGET_NR_faccessat @@ -12947,6 +12975,12 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_linkat] = impl_linkat, #endif [TARGET_NR_lseek] = impl_lseek, +#ifdef TARGET_NR_mkdir + [TARGET_NR_mkdir] = impl_mkdir, +#endif +#ifdef TARGET_NR_mkdirat + [TARGET_NR_mkdirat] = impl_mkdirat, +#endif #ifdef TARGET_NR_mknod [TARGET_NR_mknod] = impl_mknod, #endif @@ -12980,6 +13014,9 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_renameat2 [TARGET_NR_renameat2] = impl_renameat2, #endif +#ifdef TARGET_NR_rmdir + [TARGET_NR_rmdir] = impl_rmdir, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif From patchwork Fri Jun 1 07:30: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: 137491 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp623316lji; Fri, 1 Jun 2018 00:58:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLPGgwXFSikizQSz9P6v0b1Vmgz0GBLhJE2IicSKy+eUjDc1kt9RA8xjJGl1sHYgsl6py5l X-Received: by 2002:a37:cf0a:: with SMTP id e10-v6mr9602027qkj.37.1527839920258; Fri, 01 Jun 2018 00:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839920; cv=none; d=google.com; s=arc-20160816; b=xHam/bVJ2YAlfOYmRtL56Dhl5MWbtqfAJrkJSv18k6NdZ/H7ufynJfq+KZgErw0PVb cH1o27HDlexdMKGRrXfrD8xb0v9hdwdMi4BuGMWcJPty1OPWTl3AUWxGfiIQAmmLEVz/ BnG0R0v4OLf9Ciwqqr1jqHg3VSyNywzA1Sz6l4yYtUQHzLwPERIFWLMCwQyYd53KdrUN n7qT7eGZ9YLZwMt3JFPrEIlYTsrBUzmFsJhfPVVvgSr8IKXxV4yDQ08digETRRUipYKN y356X/VmLD2XLDRiSOhBt1w5oeOWQy8CYxNPKFbnUcpYOrOLniYJ06iD6maZmH9iAh8L YGnQ== 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=zFXkR0/GMurpt+VnW6VyFlUmRlhy8UEbvmcK/+NQ23A=; b=bxIEjjbh/O0RUrXH21ap1hcsUCvqhLQ9iujdrlBezsBvdfkk0d/s4y6B5bzGPKWgfY KcLmrD7rlMh6YkuWIV9YG7N9nqcm/T0cCbJ4GVBBFxj1bGoI2rreMivHPLUszQYnadws 6UCe6nWLVHyi8fnd2B9p5BBVtGD2VD2jnBOllqF02gXAa//1cHBGeeqjjwip6kQOpape Fq6/F/tunsIXgJfVRwyBkvRCDDS3WUtbtKYO2yfr+LFMdmCpfCn7c9wmh/DqlsyyOOXQ tEVx4ogQ29vUzZNnzyPYUWKfLMiw82KmYmxcSSo855/u1Saa+tTP2ucBwtBDEk8BIHPn Mwng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Egh3/7ko; 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 v129-v6si515926qka.94.2018.06.01.00.58.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:58: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=Egh3/7ko; 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]:47967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOexL-0001rg-JA for patch@linaro.org; Fri, 01 Jun 2018 03:58:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX7-0005pr-3W for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX6-0000lk-0N for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:33 -0400 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:39793) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX5-0000kx-P3 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:31 -0400 Received: by mail-pf0-x229.google.com with SMTP id r11-v6so4527377pfl.6 for ; Fri, 01 Jun 2018 00:31: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=zFXkR0/GMurpt+VnW6VyFlUmRlhy8UEbvmcK/+NQ23A=; b=Egh3/7kon8yiVu6LiIu1j/4o5BAu3FPTlhzQw8bsEVNDuxotkj8OX8A8eAZeCkuk5D rI7gZylV50FsAZIBaKYExZ9mUgBdie1Nh6Z556TY/EeQmTva9Wul4M3AXT0yVV3zpAMA yL4T2xY867Ba5k0yzcEXJdyu+h43dLDM1YYmk= 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=zFXkR0/GMurpt+VnW6VyFlUmRlhy8UEbvmcK/+NQ23A=; b=jb90JRRmgqaqGmuNtW6qmdX58b5ZRzC6PrZfxpz28LzXunKHYSbTGAYRh0jaB/pPog VDNSti/AWJe/SW+JTZffCxfeIMmEmHual6wcjBCSHDOT8pVOdF8DsApKtgX6Ukow/Qph WhO7bnh5Rc3KDDMZgt2J46L7wod2QjVOYw2e4+7coVwGmGiq6T9MAlMBwWjhutzHpiPc MHggyfJUUHsPdKIrQF9EfVqtAAbPVSHDOqqh2ovs/9BbvplYwnxidyY+mpTfe7Nki5en PWFo3d4c0qnV3jGFyBVxBP5tjz/IeIln2gTWZLmSWVZ8/hJI2WkY105afuAkgvZAiqRN 15aA== X-Gm-Message-State: ALKqPwcrzjk4LAJQ4YvkyACrznJytKnhAiAUtL69zNIximtxRT9ddxg3 LrHoUNZ6Uye1/KMBE2hThaPGfnpHsBE= X-Received: by 2002:a62:7105:: with SMTP id m5-v6mr9628674pfc.167.1527838290475; Fri, 01 Jun 2018 00:31:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:43 -0700 Message-Id: <20180601073050.8054-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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::229 Subject: [Qemu-devel] [PATCH 26/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 127 +++++++++++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 47 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 36092d753d..bde1f9872f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7912,6 +7912,24 @@ IMPL(access) } #endif +IMPL(acct) +{ + if (arg1 == 0) { + return get_errno(acct(NULL)); + } else { + char *fn = lock_user_string(arg1); + abi_long ret; + + if (!fn) { + return -TARGET_EFAULT; + } + TRY_INTERP_PATH(ret, fn, acct(fn)); + ret = get_errno(ret); + unlock_user(fn, arg1, 0); + return ret; + } +} + #ifdef TARGET_NR_alarm IMPL(alarm) { @@ -8529,6 +8547,21 @@ IMPL(pause) } #endif +#ifdef TARGET_NR_pipe +IMPL(pipe) +{ + return do_pipe(cpu_env, arg1, 0, 0); +} +#endif + +#ifdef TARGET_NR_pipe2 +IMPL(pipe2) +{ + return do_pipe(cpu_env, arg1, + target_to_host_bitmask(arg2, fcntl_flags_tbl), 1); +} +#endif + IMPL(read) { abi_long ret; @@ -8657,6 +8690,27 @@ IMPL(time) } #endif +IMPL(times) +{ + struct tms tms; + abi_long ret = get_errno(times(&tms)); + 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)); + } + if (!is_error(ret)) { + ret = host_to_target_clock_t(ret); + } + return ret; +} + #ifdef TARGET_NR_umount IMPL(umount) { @@ -8672,6 +8726,21 @@ IMPL(umount) } #endif +#ifdef TARGET_NR_umount2 +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; +} +#endif + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -8831,53 +8900,6 @@ IMPL(everything_else) char *fn; 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 (!(fn = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - TRY_INTERP_PATH(ret, fn, acct(fn)); - ret = get_errno(ret); - unlock_user(fn, 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 @@ -12937,6 +12959,7 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_access [TARGET_NR_access] = impl_access, #endif + [TARGET_NR_acct] = impl_acct, #ifdef TARGET_NR_alarm [TARGET_NR_alarm] = impl_alarm, #endif @@ -13003,6 +13026,12 @@ static impl_fn * const syscall_table[] = { #endif #ifdef TARGET_NR_pause [TARGET_NR_pause] = impl_pause, +#endif +#ifdef TARGET_NR_pipe + [TARGET_NR_pipe] = impl_pipe, +#endif +#ifdef TARGET_NR_pipe2 + [TARGET_NR_pipe2] = impl_pipe2, #endif [TARGET_NR_read] = impl_read, #ifdef TARGET_NR_rename @@ -13027,9 +13056,13 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_time [TARGET_NR_time] = impl_time, #endif + [TARGET_NR_times] = impl_times, #ifdef TARGET_NR_umount [TARGET_NR_umount] = impl_umount, #endif +#ifdef TARGET_NR_umount2 + [TARGET_NR_umount2] = impl_umount2, +#endif #ifdef TARGET_NR_unlink [TARGET_NR_unlink] = impl_unlink, #endif From patchwork Fri Jun 1 07:30: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: 137489 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp620771lji; Fri, 1 Jun 2018 00:55:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL6PZzQb8ngHl8NYqh9ad+F5GFbUv7ZXFj25aMzSo5Tu5H/d/eNe78aDpnuAAjgeu5Aq5KJ X-Received: by 2002:a0c:9dc3:: with SMTP id p3-v6mr9527337qvf.211.1527839703621; Fri, 01 Jun 2018 00:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839703; cv=none; d=google.com; s=arc-20160816; b=UfKpymY/7OV2fXttB1yKrNx5jBjI8iB2a0c0Mq6N5t2HcYQ5NhIuPDrpGecqlB1lng E6S+D1uRPMLRcrYcr2usfr/Qy3Nx/okAQxFNIWjBexDBPetwmW0f78YDl1cqAKGZ+FJv L0SoeJwajz5FYPOHKzrNEnzkAV9+iN+Ue9xZWe+4JcCm/h6qWmQgbQ11IkjDIBS5M7oS pb2Bp8lzZUm7AgReoWpPcVI1HxWPkHXn5rP922gkZIRsl55L14wnzz3U4cGSk34/8wTX 2NJhU2Iziz8PQJIrKaLzcnhmbM6b1SlYloxg0hgts/8y3GVJcIMsmuXmpdXy4bC0Y4b0 XEUQ== 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=rhNC+tuyWGWk68/inmnUnXY6rXJTo7UnP2hjcGmv20k=; b=VKV5bUDPkVrgnXFSf6t7v63No7f0qL+G+sukiSUTnPgY7Mu3Lr1vUKV7/InlmD9QYv QgUTZuYz+A805XybyknYQZIxhShmYp/mM1FGuCkBbjs4hmNGMELrX+51NGeDqyplts81 in4z1UV1qv9AGGU0sk/6DjlndiSSdZ4KMFYgXC5BfyQE8t8ZqYBY+dPQE7HkD1ZR8Crd 06N1Ljf8JP7FQNgtkEuSDu+hNek2Yo4N8ROj3xJLAJNKW0+KIXk7pAGmP+nXRNHBeb8V xb+FsCGnWbOOeUfrDLlhXyfSqrQf3xfSdsBDcB+5TIHcr+TON0nsooNWMvPj14TY4wcJ PU/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jm78qk9u; 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 v57-v6si3979286qtj.154.2018.06.01.00.55.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:55: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=jm78qk9u; 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]:47929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOetr-0006A0-3A for patch@linaro.org; Fri, 01 Jun 2018 03:55:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeX8-0005rZ-GY for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX7-0000mu-8K for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:34 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:37720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX7-0000m9-0h for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:33 -0400 Received: by mail-pg0-x244.google.com with SMTP id a13-v6so10873032pgu.4 for ; Fri, 01 Jun 2018 00:31: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=rhNC+tuyWGWk68/inmnUnXY6rXJTo7UnP2hjcGmv20k=; b=jm78qk9uMZ94ULY9jap3/5RdFRYfr6Ro8mL6KHUZpD0Jmf5KRZP/WnKTH987+f6wNC hgsrUxo5v+jrFmEtGv/z28iAKXELddvzyU79z2N7YeRsjnsPDsDVFVBcBnusyJIplGG4 wahQ+4VD1AMBiVK1ygzVlnTLDlKFqj60N1AnY= 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=rhNC+tuyWGWk68/inmnUnXY6rXJTo7UnP2hjcGmv20k=; b=pBn62IpVKQmYT+iL5mx3qM9fFhJzQ6nmQHFg65bK2D2rLZnP0e0ceXtTj+h3v67Cg/ uhfE2Xhk9BpwP/rXKaN8uvIN+17TkrXjSW2iGMQN75bfRncHLyfqLINh1fD0k6UOVlTO djqbdcwMOPDU8U7bcX5ScEXCrLJCcR4cnlUwg3S51WHYz4d+5EK7QjCCpTa7xfbtVn6F XmXD5O6QeJSN7XCKyp2t1VNQEBlVVrRSEiHCozCInYBXQbEsQ8ToMYCNMfU5rJ3xurYu RWCjSXSWtde/szjko6UM6rgEG/YCAUa6VTc+ss1xZOfmB2QTReVNYNp+HNBNDhX4WsOr qARg== X-Gm-Message-State: ALKqPwe7+YV+XS0e3oDRItben+W1RaMqnf0n6VxpVOngzPFMXuecLP8p S2fzkaiDSeeLq89r0DLL6i0jmZOdNPU= X-Received: by 2002:aa7:8009:: with SMTP id j9-v6mr9908674pfi.52.1527838291755; Fri, 01 Jun 2018 00:31:31 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:44 -0700 Message-Id: <20180601073050.8054-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 27/33] 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 | 190 ++++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 93 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bde1f9872f..4be71367fc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5759,97 +5759,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 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) { - /* 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 }, @@ -8231,6 +8140,102 @@ 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 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) { + /* 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))); @@ -8900,8 +8905,6 @@ IMPL(everything_else) char *fn; 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); @@ -12990,6 +12993,7 @@ static impl_fn * const syscall_table[] = { #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) [TARGET_NR_getxpid] = impl_getxpid, #endif + [TARGET_NR_ioctl] = impl_ioctl, [TARGET_NR_kill] = impl_kill, #ifdef TARGET_NR_link [TARGET_NR_link] = impl_link, From patchwork Fri Jun 1 07:30: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: 137492 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp623668lji; Fri, 1 Jun 2018 00:59:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK5bhqIAK7oU0kjg84drMCSumVffJt+XtFHM7wBf3zcqzxBhM9NiGsiu/MZikipXOvzRCVt X-Received: by 2002:a37:82c6:: with SMTP id e189-v6mr8816471qkd.322.1527839951166; Fri, 01 Jun 2018 00:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839951; cv=none; d=google.com; s=arc-20160816; b=Zec4IqCcme6xL5LEy0YwGb3OOFynG73MHj/SBMJuQRVCMgexsVVzHEr2Tpc6Ak5Ed+ xaxw02sbIqTrmyNdk3+Cq7ZDZ8sL3sD6maM80yTNuEmn/x18j8BQ6KXSXAb/qVd+9I4r vXIPvNSzfWDtSMtQWoEujTMutNvwTAgyUjLJXvMEWOdvGr9AWN/eWNdbxGtbcC/U0Jsk HBAP/fDPJjQ6j/5HXBVZsVnYu63/8BkkwexLraAaZppsbW7EaFyr1MUtBLJdL14K/29G JJrGHz41bpsLDfPqcenrSarCykkL8xI6ior7AUN3ldYOvVEgdIZJ2vIf+LB8d7pIAefQ B3Hg== 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=cFIM79gp+dF/NwbdEPIwKiJ9sLTkgusYgw7G++Ve26c=; b=qDsRYE9XALf17mgdsvujPiEn7zBkyfOs6ubzJ8KXNLbv2xPaGoKX3IU5qWoI4yexn5 d6yJ/1gG3DEaD+LqT4ol3emkQ1lqlDPoIqPqcHjhAaSTjJYRyUCL2KoZQnoUzJ4f2JEy BvOcPM/h8fVOiy4VGxqb6JSWdrIcxRnvjvMAHwh7Zhe9LbUoUPa7A1X5GCNEWuDJD1s7 W2w8kUzrb2Fx4bENnVk0KSpKavhVzzHIaYJFQ26BUMHjpmeb7mjibeJr9krPFAZddsYe e9/azUCyhd0HCeeLc2I6OmP/pW824tkETxNNVdGkr9ZVkuwYq8GIxjixTirwGPz6kK8g LHWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GLIbwcRq; 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 a42-v6si163913qtk.91.2018.06.01.00.59.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:59: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=GLIbwcRq; 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]:47969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOexq-0001vL-Kq for patch@linaro.org; Fri, 01 Jun 2018 03:59:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXC-0005vM-IO for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeX8-0000oF-Kh for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:38 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:41503) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX8-0000nb-CF for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:34 -0400 Received: by mail-pl0-x244.google.com with SMTP id az12-v6so14819689plb.8 for ; Fri, 01 Jun 2018 00:31: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=cFIM79gp+dF/NwbdEPIwKiJ9sLTkgusYgw7G++Ve26c=; b=GLIbwcRq7rRj57eWf3KtskQA9+s9/3/XtPXSjWUtVqQ6UAfVXHE3wHoBZlNr4hDq6A L7yYQjoKKQlQoKOQai0FLYaQJ39A2lIp6zBgTgEvzX3lZvlSYN8sHFcESI907TRCQRaV Ik0cF0EAhQHCHhrmDKyUS1BRF8PaGhNtBMXgU= 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=cFIM79gp+dF/NwbdEPIwKiJ9sLTkgusYgw7G++Ve26c=; b=asIrcILic3WCJhbeNOIC2ptn42zQwYeoqkg3iy7vO/hoPN113RsLlWm805BC2YDPSa HTxIDivHiu0yHLLlHyxyKBerp4NyatopCe2TjJg4p6IxONq9x9MWqa0NAnjI26p4owup Nv79mS0jdnp0Qx0ZcCN2fabKifOi1e6KJP/X/7PNM2T1ssACun33M/XN2RBf7pYiAp57 Pu+u7aTTv4OvflbsLSXILpka0kCfyxaK7y1/eT8wu1vMMQjUuCfUDsTdLgSPIyH41e+s llADG5QuFJRszyaLCyQSfO3iQhkPshYfDpDN/f753okPPyagTUxMZhrqDm2GkVv/rAj2 W+tw== X-Gm-Message-State: ALKqPweXsJEHvznpr6kd6Uh1E9UQM9ug84gLfB9YD54qgSnTmy6tsYjn XTNNHLaKaqMONw37oP0YejVU+YdV7rw= X-Received: by 2002:a17:902:ab8d:: with SMTP id f13-v6mr10101628plr.81.1527838293169; Fri, 01 Jun 2018 00:31:33 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:45 -0700 Message-Id: <20180601073050.8054-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 28/33] 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" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 123 +++++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 44 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4be71367fc..4d9b9cad6e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7879,6 +7879,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) { if (is_hostfd(arg1)) { @@ -7918,6 +7931,43 @@ IMPL(dup) return ret; } +#ifdef TARGET_NR_dup2 +IMPL(dup2) +{ + abi_long ret; + + if (is_hostfd(arg1) || is_hostfd(arg2)) { + return -TARGET_EBADF; + } + ret = get_errno(dup2(arg1, arg2)); + if (ret >= 0) { + fd_trans_dup(arg1, arg2); + } + return ret; +} +#endif + +#if defined(TARGET_NR_dup3) && defined(CONFIG_DUP3) +IMPL(dup3) +{ + int host_flags; + abi_long ret; + + if (is_hostfd(arg1) || is_hostfd(arg2)) { + return -TARGET_EBADF; + } + 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 + IMPL(execve) { abi_ulong *guest_ptrs; @@ -8087,6 +8137,13 @@ IMPL(faccessat) } #endif +#ifdef TARGET_NR_fcntl +IMPL(fcntl) +{ + return do_fcntl(arg1, arg2, arg3); +} +#endif + #ifdef TARGET_NR_fork IMPL(fork) { @@ -8659,6 +8716,11 @@ IMPL(rmdir) } #endif +IMPL(setpgid) +{ + return get_errno(setpgid(arg1, arg2)); +} + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8716,6 +8778,11 @@ IMPL(times) return ret; } +IMPL(umask) +{ + return get_errno(umask(arg1)); +} + #ifdef TARGET_NR_umount IMPL(umount) { @@ -8905,50 +8972,6 @@ IMPL(everything_else) char *fn; 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: - if (is_hostfd(arg1) || is_hostfd(arg2)) { - return -TARGET_EBADF; - } - 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 (is_hostfd(arg1) || is_hostfd(arg2)) { - return -TARGET_EBADF; - } - 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()); @@ -12969,6 +12992,7 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_brk] = impl_brk, [TARGET_NR_close] = impl_close, [TARGET_NR_chdir] = impl_chdir, + [TARGET_NR_chroot] = impl_chroot, #ifdef TARGET_NR_chmod [TARGET_NR_chmod] = impl_chmod, #endif @@ -12976,11 +13000,20 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_creat] = impl_creat, #endif [TARGET_NR_dup] = impl_dup, +#ifdef TARGET_NR_dup2 + [TARGET_NR_dup2] = impl_dup2, +#endif +#if defined(TARGET_NR_dup3) && defined(CONFIG_DUP3) + [TARGET_NR_dup3] = impl_dup3, +#endif [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, #ifdef TARGET_NR_faccessat [TARGET_NR_faccessat] = impl_faccessat, #endif +#ifdef TARGET_NR_fcntl + [TARGET_NR_fcntl] = impl_fcntl, +#endif #ifdef TARGET_NR_fork [TARGET_NR_fork] = impl_fork, #endif @@ -13050,6 +13083,7 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_rmdir [TARGET_NR_rmdir] = impl_rmdir, #endif + [TARGET_NR_setpgid] = impl_setpgid, #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif @@ -13061,6 +13095,7 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_time] = impl_time, #endif [TARGET_NR_times] = impl_times, + [TARGET_NR_umask] = impl_umask, #ifdef TARGET_NR_umount [TARGET_NR_umount] = impl_umount, #endif From patchwork Fri Jun 1 07:30: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: 137480 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp615608lji; Fri, 1 Jun 2018 00:47:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ7H123BxoNx2A4KCi2IeWyW6G7w4ZNoxsUQTaPJcFOauOBu6yPv6MwmfkCpW/D4m/zdTc+ X-Received: by 2002:a0c:e80c:: with SMTP id y12-v6mr9609421qvn.10.1527839253064; Fri, 01 Jun 2018 00:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839253; cv=none; d=google.com; s=arc-20160816; b=LNppoUEcNSPW+CyZoGrxlFuSFORbYnI6rqGdSIf/GthYYS9rI2I3roXA80EuM+7As4 OwW/gc20ITjv4yBT8mJBYXXumPiOAQlQzEd8oYI438XembCiE6O40urK4Jj0+zvlIcfZ Bpw9PHONEuf5Mk69bfH8YcMiycnCEObfMF8aT7K/7RGoeetFA/tKCxxStKLbUWabzRfe BJwGEZIhxlZNVo0NFVG6OOX7OFCr6QN7CK7Uy2hInHegSZkC7FC/het9xsBlU+mofCtO c6JK+AUJw8wYr7prQ5VbLd1Mwj255f3BuDiQ/VsqnLm0wj+zhOTko6qt6BK3ExpD8DKh wH3w== 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=YdvcRFu6fx8Wp+G4YhYTw71+KONQN1xb0dqsPpyOeQM=; b=CKKfLbzwYMwd8KJbq54O6J81/vulKESR4m4BYy4+yMmCmWCkNFE+fvgApcQT155HWG 6n0XHCNfF7aonaz1zHKUanG//htqPaQFxVG3llkmN6kTLdb46rKpVtm/vPvZne9HR90Y uEJQsKIf4Os2KVNK2aQK9ooKRki1G1IfQvXIPjFab2vJdVII2UiXdyCy55TNAufxMlzw iNLw8m+9H7LJvaulKSzO9H7BLvUKHdAeUPzyKGiu51lkYUjZs8sK0PvROEcFZhaRLRTu ME6qgyXY371/qxXE7xJCeZGFRiwtk8tQrDlxTQt1WhrnagFvOvzJ5Ln7sgjH7fXoSpXB 3Lcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eXqcZrk7; 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-v6si569532qkb.138.2018.06.01.00.47.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:47: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=eXqcZrk7; 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]:47899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOema-0001Xr-Dz for patch@linaro.org; Fri, 01 Jun 2018 03:47:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXC-0005vN-JB for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXA-0000pd-1r for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:38 -0400 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]:36963) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeX9-0000or-Rt for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:35 -0400 Received: by mail-pg0-x236.google.com with SMTP id a13-v6so10873101pgu.4 for ; Fri, 01 Jun 2018 00:31: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=YdvcRFu6fx8Wp+G4YhYTw71+KONQN1xb0dqsPpyOeQM=; b=eXqcZrk7a8kGU+q2K3TIw0V7jGEJB42unGgRzNxkda7VQZGoQJramsHJu3PVqBcPVU CAZf43SJXj4gI2juXY48GYOQbJXvDFlXLfEtd8eXH9npUU+WXHy0WEcshj2Hzn9WPwj3 ScLpTphdPEFVsb494nGCMtYhOrff35b6aclGc= 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=YdvcRFu6fx8Wp+G4YhYTw71+KONQN1xb0dqsPpyOeQM=; b=PGm59tvWFasoTX6mS32Fv4PO+kWo4a9STC5BSH2qlyRRsM5RvMpucVyGc3ZqYE9H/9 76nOnD5uUlnrvm9SJWMfJ9Tzp3fEYLqGpK664Tl8XhFAtin3uPV33aRqsF1oTQNFOljR fFrnp1BIHDj5QnwXuHWwStNxG11Nqaa/wYESLIPIX7HyLEior37PU6ncK/Lv3HMggUls 28iFKaz/9k0B8IBcGOXqpD2rANZ56Pp4BEE3hM86/c8TcInBTYHflc0z6rfIxJ+DU5gk mpGtbwksD8RV9q5ZN5GGag9R9rCia9dbYoys4IQd/3aQipbpAEMkY1nPH0OvT8gLMbBn 6t+w== X-Gm-Message-State: ALKqPwe9Z5IYAPmtiSUeyw/ExsKM5exU86sYyjAClE9DnfNb+9p36v2E pOOxq4qcIqRr6WepnRDnkk2Ib87fX+I= X-Received: by 2002:a65:644f:: with SMTP id s15-v6mr7987775pgv.228.1527838294592; Fri, 01 Jun 2018 00:31:34 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:46 -0700 Message-Id: <20180601073050.8054-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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::236 Subject: [Qemu-devel] [PATCH 29/33] 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.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4d9b9cad6e..3dfb77ac11 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8182,6 +8182,13 @@ IMPL(futimesat) } #endif +#ifdef TARGET_NR_getpgrp +IMPL(getpgrp) +{ + return get_errno(getpgrp()); +} +#endif + #ifdef TARGET_NR_getpid IMPL(getpid) { @@ -8189,6 +8196,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) { @@ -8721,6 +8735,11 @@ IMPL(setpgid) return get_errno(setpgid(arg1, arg2)); } +IMPL(setsid) +{ + return get_errno(setsid()); +} + #ifdef TARGET_NR_stime IMPL(stime) { @@ -8972,16 +8991,6 @@ IMPL(everything_else) char *fn; 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: { @@ -13020,9 +13029,15 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_futimesat [TARGET_NR_futimesat] = impl_futimesat, #endif +#ifdef TARGET_NR_getpgrp + [TARGET_NR_getpgrp] = impl_getpgrp, +#endif #ifdef TARGET_NR_getpid [TARGET_NR_getpid] = impl_getpid, #endif +#ifdef TARGET_NR_getppid + [TARGET_NR_getppid] = impl_getppid, +#endif #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) [TARGET_NR_getxpid] = impl_getxpid, #endif @@ -13084,6 +13099,7 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_rmdir] = impl_rmdir, #endif [TARGET_NR_setpgid] = impl_setpgid, + [TARGET_NR_setsid] = impl_setsid, #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif From patchwork Fri Jun 1 07:30: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: 137493 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp623676lji; Fri, 1 Jun 2018 00:59:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJIaSp3jhJBSD1uX4nfxe3LQpiQygF7sFwD9nLhMzKLUSkNc8EPvm8LMMUhLeN6eib30TyV X-Received: by 2002:a37:8ec4:: with SMTP id q187-v6mr9324407qkd.28.1527839951774; Fri, 01 Jun 2018 00:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839951; cv=none; d=google.com; s=arc-20160816; b=T621GmMaM0AlwzX8YIgr5yh6YYLmNrHcYllRv4lv4Jiasv6nsCDo283V4uiB47KcFV N8h27YbucFPC0Mjnzfee1JW2kw8fCr3xkomp2wqQ+Z36OL/bbZ+j02tY6GClh7DG+sIZ cb6cksEX5LtvF0Lio+mm7s0jdH3yvdRiczp7NeE/U9Z9bmnlX/IthgdGtP4BaTjHggQY 3/0JnP0DWUrkWBEPQKHp7clNhn1Wlxq3epikTje4cEpOCA+9u6G9Y2LZ2+YE6EeHU7Jw +FM0SLUhoMrEmF7iWYllTUAj4g/oeZExI00x5A4nJsT/D0jAuRiUeyoKcqy/Yx7I3mAa bUrQ== 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=cKH6v2qR8mpApdcxMm32cBdeITbb8RHNnTb6w+DTJXY=; b=c2VdxjSptnOMtFd8RJN393TyCbfxKMZ7ScuW4PpgwUI8GP7lcKwIzI50ZBvcarttor DYqz3MYM6fYRxj6MRVkaiycDZcXEDN96z6fYcxPeEhtGDiARdjPixNx048xam3CrOt4N aXM8QdgQGl9rLWDG20sMqldjqfDG0ZiC3/iJ43cC/O5DdYm89rkFcuK2X20vV5HpdRSG 3SJhd0uE8HG0uo9OvS+q/WetvU0ocC1Fm/xoL384PzgSYJUnlbBrHJDfHvq97HmPrIaR /tlwAA95QX/+kuvJ84nQ5lWqB6U7HNOyxF+hPojT1xWo8Sa3+FNbDIcQ6+KCvII7SPuJ pokg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LLE+Did7; 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 l37-v6si2901221qtl.321.2018.06.01.00.59.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:59: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=LLE+Did7; 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]:47972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOexr-0002FP-5L for patch@linaro.org; Fri, 01 Jun 2018 03:59:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXD-0005w5-Ce for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXB-0000r9-Jm for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:39 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:33007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeXB-0000qV-BB for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:37 -0400 Received: by mail-pg0-x241.google.com with SMTP id e11-v6so1685190pgq.0 for ; Fri, 01 Jun 2018 00:31: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=cKH6v2qR8mpApdcxMm32cBdeITbb8RHNnTb6w+DTJXY=; b=LLE+Did7PMitLFXCiN/62O+wzR8oFr2vNZRbwrliQYc9QyVa7cxOGTxLRVJdIgiz3h oiC20hshx0Q1ouR3SEIVHtH9R1hXS+CKBirmaVw1DW1WENODaSikhRXqz5aqMlPSZ8rE AJPKLeHl2RRCEZfQir1cfsKswqrRMkZTUAdj0= 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=cKH6v2qR8mpApdcxMm32cBdeITbb8RHNnTb6w+DTJXY=; b=WbVIXhUP2VtHNbQ3VTppxD9uWmIdCHDdUa/YyfeR/no8SWHCzKl+aybJ10lEhMI5Ym ERhQdGGoDk/8dCaAQ2Aa9T85vvi+syYuKH12vHnem8II/1rSTs+rk2IUQ36wl0r3Bh0c n5XsoiM3lc/zuorm4xnnI0TA/EMnJBypf/e9VEK0NjimvXS3uAtum1xqy/axU999vqDc YFbKde/g/BFhnG9wpcaIj0jytLiMnHSu0enfCzIt/EGPudh32g83VOSDd9YLf4b317cX P4pIkWtWM/WLu1Fke08BhtOUkWx5mtT6wsq0qcXBfhgo/I01H3ZzbUfsQqjHc9Dpwrdp OltQ== X-Gm-Message-State: ALKqPweDJdRhtfWlcH26UfddbD9tF0oqh6wesdJLYxteQuVrnGAYxaZi Stxw+JtSSa1YNM5qUuAGDNbmzrEZwvI= X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr7885437pgu.266.1527838296051; Fri, 01 Jun 2018 00:31:36 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:47 -0700 Message-Id: <20180601073050.8054-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 30/33] 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.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3dfb77ac11..36e2bb838e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8730,6 +8730,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)); @@ -8740,6 +8815,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) { @@ -8991,166 +9152,6 @@ IMPL(everything_else) char *fn; 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: { @@ -13098,8 +13099,12 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_rmdir [TARGET_NR_rmdir] = impl_rmdir, #endif + [TARGET_NR_rt_sigaction] = impl_rt_sigaction, [TARGET_NR_setpgid] = impl_setpgid, [TARGET_NR_setsid] = impl_setsid, +#ifdef TARGET_NR_sigaction + [TARGET_NR_sigaction] = impl_sigaction, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif From patchwork Fri Jun 1 07:30: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: 137481 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp615970lji; Fri, 1 Jun 2018 00:48:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLcwKHRwAg2j/kWccQzICHDtPH1nsuk6n0+cQ1OYChhafgji2wFToPYu04NtIRCTfDiGjXC X-Received: by 2002:a37:270b:: with SMTP id n11-v6mr8963176qkn.91.1527839286615; Fri, 01 Jun 2018 00:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839286; cv=none; d=google.com; s=arc-20160816; b=Y2QaeaYlR4+9/bCas3TpnzbA3b8NZvb5HiKZgpMf4rq1pQ9n33WBn4e0ZIT0T67BM/ gM6kg1m2yqXhyzlohF27Lmfw/C/LqeVOOTCtMoosnXllrKPBTeL77uWACTBcan9g130P 0jXLUR0MiD6fGcWdpuwufDFAy3tlghzBLqcqytZMUz53TBuLtrA9uEILWsdFIR2kY24u LtaZ1xrKEcLTtIF6PhlZAdFVBFbWt0RloHsTF1LeM1B5HhiGFxselKtZdi1eilOYEnZt 6fSLq7FhZc29AVe0ylYe6WXLfRR0JpplPLqxhBKg/1DHczvo4T0jWFVADegWlzBG60aU 4+vA== 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=hiJLD4p4JwSr5Y/m/dr4NhaF5UBKnU9K5eAUw6O8Xpg=; b=RcEEk7szAteayfSbAsRE5wJCOMQmeGp39VkEdo9xkTY3Yz8jDoSJFACCRwghniNrSG 3hwLp2HqeUraITXmf9A6JrGWA/BuPZUdqvuRIF8cNsthSebCG1JjPhUo6otutsefYJD3 RvtW55pxXmZjESLaqz9OkSl1XLVR/um3KmXN/zAwje2uLiBxqoDtNhr6nnFle4oLa0JC MWenOkkInhfwkdZ0eYxEo88ScUim4hGWKeAru8opi1HxEVHHXUzWIp3J6jJiUh7HcIMu DnB+OzuJHcQmYYQVpVSLMkkezT83iW1dSgUNcYT9E/MZCedR9O1yb14qxSV9VIyOzzK0 KrnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kNGo5tn8; 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 e75-v6si1695627qka.183.2018.06.01.00.48.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:48: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=kNGo5tn8; 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]:47901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOen7-0001cf-RH for patch@linaro.org; Fri, 01 Jun 2018 03:48:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXE-0005x0-Ai for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXD-0000sR-01 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:40 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:43585) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeXC-0000ro-P1 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:38 -0400 Received: by mail-pg0-x241.google.com with SMTP id p8-v6so10867837pgq.10 for ; Fri, 01 Jun 2018 00:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hiJLD4p4JwSr5Y/m/dr4NhaF5UBKnU9K5eAUw6O8Xpg=; b=kNGo5tn8Q0gUiJdQDku5aNfd2fWAuS7ZFmKfqiugLWUYW3hSuCCdmLUxAqhiezEGGw c28YGFAXY8stm32bq62INmWk/VB9uO2cQIJGiLv9azucIBSnVpPtLCUPHPregQKFwrkT YHiC2HX/o6+YYnzNBE2C34pIukoM7xnnhpQYE= 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=hiJLD4p4JwSr5Y/m/dr4NhaF5UBKnU9K5eAUw6O8Xpg=; b=Dd5jIebgWyvzf6BXxudN7PyKkSVM4/GQ1eOLbVdBKCONmz1ZgrBWKCmMe7Au9Rqwld S70SnsrHrhkWD7f0h7GI+p1D0GX4NfuDQQId3sk+G7hiFlhvx7nXvA5CxvJfY55vRJzh L3Rci56uwxNcoE2/LHo2Lu9EE/mGDLPDlrcYBFjScE4OioJASN/9ZM19svjy0dnFFb5Q DiU84AjRjqhaVAQQZW+Pmsg7kLnvYgxVr6BtYo6cjCq3N/Cp6KFTOVxtSfKtrSxT/l39 NyKxA/sstr3igmhmFx7KZ3q/jFbrhbI3BvKTLzWg1QMgiV7KRLQtYNIirx4SxfBPukIC 5cTQ== X-Gm-Message-State: ALKqPwfTRQ78zq6EVSV9PHB2fETEmAXTJAg+Vf4xPQRh36/NU8Qc2P8u cQ3gn8hlukGe60+IyoKJK0W+KIqN7Ao= X-Received: by 2002:a63:7b07:: with SMTP id w7-v6mr7694237pgc.199.1527838297544; Fri, 01 Jun 2018 00:31:37 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:48 -0700 Message-Id: <20180601073050.8054-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 31/33] 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.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 36e2bb838e..e37a3ab643 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8805,6 +8805,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)); @@ -8901,6 +8960,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) { @@ -9152,142 +9300,6 @@ IMPL(everything_else) char *fn; 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: { @@ -13100,11 +13112,21 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_rmdir] = impl_rmdir, #endif [TARGET_NR_rt_sigaction] = impl_rt_sigaction, + [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask, +#ifdef TARGET_NR_sgetmask + [TARGET_NR_sgetmask] = impl_sgetmask, +#endif [TARGET_NR_setpgid] = impl_setpgid, [TARGET_NR_setsid] = impl_setsid, #ifdef TARGET_NR_sigaction [TARGET_NR_sigaction] = impl_sigaction, #endif +#ifdef TARGET_NR_sigprocmask + [TARGET_NR_sigprocmask] = impl_sigprocmask, +#endif +#ifdef TARGET_NR_ssetmask + [TARGET_NR_ssetmask] = impl_ssetmask, +#endif #ifdef TARGET_NR_stime [TARGET_NR_stime] = impl_stime, #endif From patchwork Fri Jun 1 07:30: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: 137488 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp620047lji; Fri, 1 Jun 2018 00:53:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJV7keDYiMVFp0gcmLqca7VwKMgsz8plI9rWngCVHBgdUNvm+oJ7H+oG64q4De3WF1MXeTh X-Received: by 2002:a0c:e50b:: with SMTP id l11-v6mr4383064qvm.21.1527839639870; Fri, 01 Jun 2018 00:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839639; cv=none; d=google.com; s=arc-20160816; b=zQ8Voy15X39DVNfAgZrdI6AlQsiADbrE8t/lcykJLg/804+9w36yYYcpbr3I1st8OJ dFiETblLQTAAhIwTroRnVlZSvNLxIQ3CzroSFyfSoIE/JrmeAsNYc+rFJO4TgiALvKg4 EzNepVH7xQi0twV4zZRfV85wYiK0o+JMgn/43vzYKnbyBUePcP7uMLRXSOSBg2RaeQP4 lCOHmgsSOXxspiC4S7ozogzX+nJgn0jnZx284uVH0C1lm2p9m2jyOaTK6+qteCVsJdA0 zEBMxSxa3NMAy5EvJ8xaGnizr3M3Aj1S9tmilm+yjKOEJDELDCxJDNo5rxjA9BP6lcUm MkmA== 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=SWhn66moQqqde5/jyrtCgCwzTTXSKJJJph8rxnnlIYw=; b=ACquv8yvC0LQi2y77vE3F20MuawrlTlvGOYHrdF/YhjNVXVK50IDKCvUKjyW8Pe/gr AeklT6/14l7CYA3wh/+5ZrDaCiPMETKjR1ZsSrkhKMARf7d0SIxqrPq698gLUEzCTzfu bF8aInH/VL6EBeb44sdQ+65Om2sF0xCnPRN8h87i3xHxoIhBCoijCITFVFp91rlw0mRB yPVeugPlYTKMc0TxiUKuxeXQM+K23lUm1on861t4cvquLPTK1JK9I9cqM3dzFF8qFEO3 qk0i3lYu/UC4awkdi7WC2hY3dqMCApBKS4TnpcjaaT1nzVsO6cGDu+jXlQ+fUAtD5lRh SAJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jm771PR+; 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 d8-v6si1808388qkj.250.2018.06.01.00.53.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:53: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=Jm771PR+; 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]:47924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOesp-0005HN-8S for patch@linaro.org; Fri, 01 Jun 2018 03:53:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXF-0005y5-L1 for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXE-0000td-CP for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:41 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:34040) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeXE-0000t2-4l for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:40 -0400 Received: by mail-pg0-x241.google.com with SMTP id k2-v6so10883082pgc.1 for ; Fri, 01 Jun 2018 00:31: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=SWhn66moQqqde5/jyrtCgCwzTTXSKJJJph8rxnnlIYw=; b=Jm771PR+DQZVExiaOLimz/nfqJb7rFQWGLgF59tult7BBkIkKuymo8CSnJ0vyOGBC9 KgaRNhKCHC3oV+GmyGOySU7d09CbPaoVwfFU7NsGDARpkn5svGdM6Hj9phcslmwLYwK0 n61TKrl9VXR2HiIEvCsfEtcxmJjMBwXgDH3pU= 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=SWhn66moQqqde5/jyrtCgCwzTTXSKJJJph8rxnnlIYw=; b=AT5fzXFsiJYj+wYVy3/2I6Xlq66l0v1u8nemB/Qi56k8k3V37MgQRBMNpuiS9QQM+l EuVVCk525Mpl7EHkqcuBOkb9cwWOkq5VdbM6e76NiOvajeMzEvKsPCTIAz6u+7+MRTZ5 YGaeWTS28HBojxKYdeQWbooqdvcxJoIS5i5F3F+qgQxMfLyxldwQ2jXjyYjtOQPgoUI0 iRgeHZ9qBZ8D0uY2K8SPpgEwJUNsaljrIJ0dzyvYXROi92sQqIDqzKRI3E2F0SO07eav KIn40DGk/dIDUWS44mvSzF/6CrS9trwvfFDKF+7nPV5dpHP/RB/BytgIuHIKPZCfHFX5 JPIQ== X-Gm-Message-State: ALKqPwdrLrS1GpK0yRBIUWveyf7f5D/dWD0peTCPaKUDsEJDqpU1oA06 i89BFWwfLa+DxwOuqsGbGJE8zQH7k40= X-Received: by 2002:a63:7255:: with SMTP id c21-v6mr7717709pgn.99.1527838298845; Fri, 01 Jun 2018 00:31:38 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:49 -0700 Message-Id: <20180601073050.8054-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 32/33] 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.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e37a3ab643..c3bd625965 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8805,6 +8805,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; @@ -8850,6 +8876,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) { @@ -8960,6 +9009,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) { @@ -9032,6 +9099,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) { @@ -9300,81 +9393,6 @@ IMPL(everything_else) char *fn; 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; @@ -13112,7 +13130,9 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_rmdir] = impl_rmdir, #endif [TARGET_NR_rt_sigaction] = impl_rt_sigaction, + [TARGET_NR_rt_sigpending] = impl_rt_sigpending, [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask, + [TARGET_NR_rt_sigsuspend] = impl_rt_sigsuspend, #ifdef TARGET_NR_sgetmask [TARGET_NR_sgetmask] = impl_sgetmask, #endif @@ -13121,9 +13141,15 @@ static impl_fn * const syscall_table[] = { #ifdef TARGET_NR_sigaction [TARGET_NR_sigaction] = impl_sigaction, #endif +#ifdef TARGET_NR_sigpending + [TARGET_NR_sigpending] = impl_sigpending, +#endif #ifdef TARGET_NR_sigprocmask [TARGET_NR_sigprocmask] = impl_sigprocmask, #endif +#ifdef TARGET_NR_sigsuspend + [TARGET_NR_sigsuspend] = impl_sigsuspend, +#endif #ifdef TARGET_NR_ssetmask [TARGET_NR_ssetmask] = impl_ssetmask, #endif From patchwork Fri Jun 1 07:30: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: 137490 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp622079lji; Fri, 1 Jun 2018 00:56:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKAxNuIznAZGThn+QzvxMm/LX2r3SG1NBFVTYKhBi68ZkVzcu4poM/kWHBovAKJsno6Q+mq X-Received: by 2002:ac8:297b:: with SMTP id z56-v6mr9475928qtz.387.1527839816564; Fri, 01 Jun 2018 00:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839816; cv=none; d=google.com; s=arc-20160816; b=xPnOv2VpEhs7joCygKFjngCiarBSBQ5RetOtUC3wbsXJjYyxhgr1+sOE8BUQH3Wq5/ VrYLKYrhasSrbIp44SORt2KdlxqWVZKUMKhksyvtOayf5ri9+qLPsaBODKw5OWQPEXCu 6ZRkMTkBz5AvFkrNy1qezuVnIOIZ/U8ymTS3cZ95Ec7UQqI5sf42vaQLb+uqcHndUHOC TSTfQRvXK+3mhyDnEZ4nwtZQt/2fZtd4U3w0YlnouxIMBdY01utsD7JpsnN10n5HxaIt K3dUT7jdguhgoHhOMfeGpmGwS4Pxs2+vZ1GwMfOarFRufhDrenXbkuD5TOhj290qyrA/ 8rig== 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=GTf9MSiiJ4Qqy1WwqDmsIQJpuZBlo7vT5dRWz1aobAY=; b=repVkKldDH083I2R1i4xF0O6kUGsdUbVjszNjJ6q3p3DA1OXB0ni6eslkdAIpVRYI7 O/cUd0xh+1wcCL0V9hvMhufq1+pCIIWmQuIt3Dso3S+Qu5fI87IO6UF2bWgxRPPGlRrz qKgvOtKlj3u7wsivpIqD9i/Veg6+fed0BKKIlXW+Or/CqtXGMVMaAaM521VrfxgBYWo9 zbcbROavGYnKhQrbwcNyFTFQARW7HyJfCzT8Amfh7sSq49RsStY7iZgYuuXFJcLu9kWn 0wzoTFqoAx1PL32a3PcIsS7VutWqo44F0BekaHmtshUr76lZiE/YjdYK3tAtdKdoCvMQ C5kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cxn2ujVI; 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 e21-v6si501762qtp.63.2018.06.01.00.56.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:56: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=Cxn2ujVI; 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]:47941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOevf-0007qY-Ui for patch@linaro.org; Fri, 01 Jun 2018 03:56:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeXH-0005ye-MP for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeXF-0000vD-RL for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:42 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:37620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeXF-0000uX-Id for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:41 -0400 Received: by mail-pf0-x241.google.com with SMTP id e9-v6so12083458pfi.4 for ; Fri, 01 Jun 2018 00:31: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=GTf9MSiiJ4Qqy1WwqDmsIQJpuZBlo7vT5dRWz1aobAY=; b=Cxn2ujVIq38XK8o+y3/QwS8C535jNklmwc9oeIgs7yYa0iS3WRPHh6bVuJFbFGh6uK xBMWbsSmLbPTPSv1SAxaYMKtqS6HHQE7eJ/vgSXJM20iBMsv/R2yWBGy/ojVnlWRHxOs Bdv9ZLmcB63p4GMZ74C7eq0KpuCWMhUfMKmm8= 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=GTf9MSiiJ4Qqy1WwqDmsIQJpuZBlo7vT5dRWz1aobAY=; b=RQZEWNVpoQK5+Cbu9Mu9h82frRRVz0FqefQ6rmh/qZm3Z9x0pMrMu9kyL2YnkhsIWz 0lmisBhN1MRXv0HixFo2u7/Txx9DPY4kIv02PdRa68QQaZbgzU49/RgSvn0XMeRRgPAe peHt+ffoDjulrxtGoArlNjvK72e7DROWe3yeHtUsVQT6dYmqlBmG3Tg0qvpDVj32TqPH KD08gkVjT+Op0qN8xRVPldHvyERRlF3wOi72Ay0CVbjniDvkGQdgk176lxJanxSQ9nyX BL6DYliuu2FcaJZ+ykaf7+T24/r0W+wP1x+1cGZslKlDxxL8SjOlR7sqYlFWbcohpJ9W XyOw== X-Gm-Message-State: ALKqPweI17dgPrkuydGYbMIhIXL6CEnSjHqFd2PvUK4KORoIV2yUQdX6 /p45n6A6P9Z4WtJk8YDzJLl6ElmWsSU= X-Received: by 2002:a63:87c8:: with SMTP id i191-v6mr8094575pge.124.1527838300376; Fri, 01 Jun 2018 00:31:40 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:50 -0700 Message-Id: <20180601073050.8054-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-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 33/33] 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.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c3bd625965..b9e07c2d3f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8876,6 +8876,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); @@ -8899,6 +8913,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) { @@ -9393,68 +9457,6 @@ IMPL(everything_else) char *fn; 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()) { @@ -13132,7 +13134,10 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_rt_sigaction] = impl_rt_sigaction, [TARGET_NR_rt_sigpending] = impl_rt_sigpending, [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask, + [TARGET_NR_rt_sigqueueinfo] = impl_rt_sigqueueinfo, [TARGET_NR_rt_sigsuspend] = impl_rt_sigsuspend, + [TARGET_NR_rt_sigtimedwait] = impl_rt_sigtimedwait, + [TARGET_NR_rt_tgsigqueueinfo] = impl_rt_tgsigqueueinfo, #ifdef TARGET_NR_sgetmask [TARGET_NR_sgetmask] = impl_sgetmask, #endif