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