From patchwork Fri Jan 12 00:15:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 859414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zHjvm5NRvz9s4s for ; Fri, 12 Jan 2018 11:16:03 +1100 (AEDT) Received: from localhost ([::1]:55001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZn0q-0000OW-UB for incoming@patchwork.ozlabs.org; Thu, 11 Jan 2018 19:16:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZn0P-0000Nl-PM for qemu-devel@nongnu.org; Thu, 11 Jan 2018 19:15:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZn0O-0006BI-NU for qemu-devel@nongnu.org; Thu, 11 Jan 2018 19:15:33 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:34022) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZn0O-0006Ae-Ay for qemu-devel@nongnu.org; Thu, 11 Jan 2018 19:15:32 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 0295A1075F; Fri, 12 Jan 2018 01:15:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jDnL8ZxfG8Ts; Fri, 12 Jan 2018 01:15:29 +0100 (CET) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id DE29210445; Fri, 12 Jan 2018 01:15:29 +0100 (CET) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.90) (envelope-from ) id 1eZn0L-0003om-Ai; Fri, 12 Jan 2018 01:15:29 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 01:15:28 +0100 Message-Id: <20180112001528.14420-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.15.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a0c:e300::1 Subject: [Qemu-devel] [PATCHv3] linux-user: Add getcpu() support 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: Samuel Thibault , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Samuel Thibault --- Difference between v1 and v2: handle failure of put_user_u32 with goto efault; Difference between v2 and v3: handle failure of sys_getcpu system call --- linux-user/syscall.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 11c9116c4a..f8cfaf043a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -296,6 +296,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len, #define __NR_sys_sched_setaffinity __NR_sched_setaffinity _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr); +#define __NR_sys_getcpu __NR_getcpu +_syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache); _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd, void *, arg); _syscall2(int, capget, struct __user_cap_header_struct *, header, @@ -10403,6 +10405,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask)); } break; + case TARGET_NR_getcpu: + { + unsigned cpu, node; + ret = get_errno(sys_getcpu(arg1 ? &cpu : NULL, + arg2 ? &node : NULL, + NULL)); + if (ret < 0) { + goto fail; + } + if (arg1 && put_user_u32(cpu, arg1)) { + goto efault; + } + if (arg2 && put_user_u32(node, arg2)) { + goto efault; + } + } + break; case TARGET_NR_sched_setparam: { struct sched_param *target_schp;