From nobody Fri Nov 7 13:00:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547849862679867.1818116609071; Fri, 18 Jan 2019 14:17:42 -0800 (PST) Received: from localhost ([127.0.0.1]:48063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkcSF-0007VH-HF for importer@patchew.org; Fri, 18 Jan 2019 17:17:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbll-0006AN-PE for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkblj-0006HU-Vt for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:41 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44931) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbli-0005ob-4g for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:39 -0500 Received: by mail-pg1-x542.google.com with SMTP id t13so6635893pgr.11 for ; Fri, 18 Jan 2019 13:33:18 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.33.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:33:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9nUzq8HAn9hIBb4vo9SImCmbGSK+P9J37KbeA0FCTpI=; b=crFywOamw5KY1TeqoRgeTd3sw7qu8VC5qYjUIzsSmDFgv6p+KMbRGf/99YyWgfx9Dd Yp04s2yTBZTVAEJRQYqKWGMY3FuuempFUxW74zsC1GdSTDDPWQ3EvpnxdlY70fn/V3Vd v5xhS4vUNuW4cbBb3gW+FEu02Rk8WYZaBNIIs= 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=9nUzq8HAn9hIBb4vo9SImCmbGSK+P9J37KbeA0FCTpI=; b=RGde5hEOJUzVdRFXDg4pQbnrOMFYrBMX/9MFGs0Fqfv3rZqB2/dFsAFCCQU/c6gjSi tXBUvsWwPXBnpC4ZfeyO9qLBltMvbWqz9fNyrCwKXvit804TQu+mci5dVfCvcQjIKml/ Fx0itBxMXCovn6xmauuxX8fpXU9pgajhM2+Zf5JWuqzCx/pcZq1TkY4EYWcuGPrZd65p yhc8N3cHtmho68In7MVU18VO943Zor07hhuZ6c1OFq1bwKEl7nQ2xSx+PQ0oVK3muX/T F8Tvp/szhGyucsCthcm5qZRKk1UAwgJexCmeKDAMt6vZNCdXkAu6U3KL0dGOND3GpGvA ssKA== X-Gm-Message-State: AJcUukehBo2XCcAbHMsrYuq6MPqmL3w0Ye0po5g2T3oTNhZFhc7bu71B 5opZFDUckA+8Tfy4cx6nAv3GC9zijHg= X-Google-Smtp-Source: ALg8bN4RaXz2x1+ZrGDcCbmG1NepGyABvx4O+dxicEqYFzCsVuVFXiCVB/vlHwBWQRFtBHtVqrtwdA== X-Received: by 2002:a63:24c2:: with SMTP id k185mr18909967pgk.406.1547847197036; Fri, 18 Jan 2019 13:33:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:20 +1100 Message-Id: <20190118213122.22865-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v6 47/49] linux-user: Move syscall_init to the end 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No functional change. This will aid moving everything related to ioctls to a separate file. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 113 +++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 52 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 33d536262f..82b7267b20 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4778,58 +4778,6 @@ _syscall1(int, sys_setgid, gid_t, gid) _syscall3(int, sys_setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) _syscall3(int, sys_setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) =20 -void syscall_init(void) -{ - IOCTLEntry *ie; - const argtype *arg_type; - int size; - int i; - - thunk_init(STRUCT_MAX); - -#define STRUCT(name, ...) thunk_register_struct(STRUCT_ ## name, #name, st= ruct_ ## name ## _def); -#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name,= #name, &struct_ ## name ## _def); -#include "syscall_types.h" -#undef STRUCT -#undef STRUCT_SPECIAL - - /* Build target_to_host_errno_table[] table from - * host_to_target_errno_table[]. */ - for (i =3D 0; i < ERRNO_TABLE_SIZE; i++) { - target_to_host_errno_table[host_to_target_errno_table[i]] =3D i; - } - - /* we patch the ioctl size if necessary. We rely on the fact that - no ioctl has all the bits at '1' in the size field */ - ie =3D ioctl_entries; - while (ie->target_cmd !=3D 0) { - if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMAS= K) =3D=3D - TARGET_IOC_SIZEMASK) { - arg_type =3D ie->arg_type; - if (arg_type[0] !=3D TYPE_PTR) { - fprintf(stderr, "cannot patch size for ioctl 0x%x\n", - ie->target_cmd); - exit(1); - } - arg_type++; - size =3D thunk_type_size(arg_type, 0); - ie->target_cmd =3D (ie->target_cmd & - ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIF= T)) | - (size << TARGET_IOC_SIZESHIFT); - } - - /* automatic consistency check if same arch */ -#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) |= | \ - (defined(__x86_64__) && defined(TARGET_X86_64)) - if (unlikely(ie->target_cmd !=3D ie->host_cmd)) { - fprintf(stderr, "ERROR: ioctl(%s): target=3D0x%x host=3D0x%x\n= ", - ie->name, ie->target_cmd, ie->host_cmd); - } -#endif - ie++; - } -} - static inline uint64_t target_offset64(abi_ulong word0, abi_ulong word1) { #if TARGET_ABI_BITS =3D=3D 64 @@ -8983,3 +8931,64 @@ abi_long do_syscall(void *cpu_env, int num, abi_long= arg1, trace_guest_user_syscall_ret(cpu, num, ret); return ret; } + +void syscall_init(void) +{ + IOCTLEntry *ie; + const argtype *arg_type; + int size; + int i; + + thunk_init(STRUCT_MAX); + +#define STRUCT(name, ...) \ + thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def); +#define STRUCT_SPECIAL(name) \ + thunk_register_struct_direct(STRUCT_ ## name, #name, \ + &struct_ ## name ## _def); + +#include "syscall_types.h" + +#undef STRUCT +#undef STRUCT_SPECIAL + + /* + * Build target_to_host_errno_table[] table from + * host_to_target_errno_table[]. + */ + for (i =3D 0; i < ERRNO_TABLE_SIZE; i++) { + target_to_host_errno_table[host_to_target_errno_table[i]] =3D i; + } + + /* + * We patch the ioctl size if necessary. We rely on the fact that + * no ioctl has all the bits at '1' in the size field. + */ + ie =3D ioctl_entries; + while (ie->target_cmd !=3D 0) { + if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMAS= K) =3D=3D + TARGET_IOC_SIZEMASK) { + arg_type =3D ie->arg_type; + if (arg_type[0] !=3D TYPE_PTR) { + fprintf(stderr, "cannot patch size for ioctl 0x%x\n", + ie->target_cmd); + exit(1); + } + arg_type++; + size =3D thunk_type_size(arg_type, 0); + ie->target_cmd =3D (ie->target_cmd & + ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIF= T)) | + (size << TARGET_IOC_SIZESHIFT); + } + + /* automatic consistency check if same arch */ +#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) |= | \ + (defined(__x86_64__) && defined(TARGET_X86_64)) + if (unlikely(ie->target_cmd !=3D ie->host_cmd)) { + fprintf(stderr, "ERROR: ioctl(%s): target=3D0x%x host=3D0x%x\n= ", + ie->name, ie->target_cmd, ie->host_cmd); + } +#endif + ie++; + } +} --=20 2.17.2