From patchwork Sun Jun 10 03:01:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138142 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2600577lji; Sat, 9 Jun 2018 20:51:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZk01TJEaRayhkRr6qRf3jItmCdv3zWA6GoLgZTYQ/3d+dEb2GO2Cq9/vOTTc0N0a7d9lD X-Received: by 2002:a37:a047:: with SMTP id j68-v6mr10342193qke.126.1528602707552; Sat, 09 Jun 2018 20:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602707; cv=none; d=google.com; s=arc-20160816; b=MQziWhx4gKJUcoMuWT8Xwbq/J13krFV56l8Pe+7sHkoa7O2DPC7wMieg2RFeLh8Xxd QnCKW4w0wVEsIgVt+e52JD9sImW2YeEQYuzhUPizalxH06gFy1WG1VtwlEnvetv+ER1z TdBuwyzGycx8xCTf3KyJPj7ZPgcmA4q2GyVnND0/FkDyE7r3ksFz0DJjdiRuStrcmrz+ mQTzywI0L8AXubyMpsFhkr6BC5NYWxo3To3N39bQk9HqNDelaoZ1Gw5GZzlX6tPsgBp5 gfFUEal5pb1uZt7PcJahN7ZWKYl8SCzj0fgoLuiATaudn6E/IpBPPNu0slfn8Oq62KPx mEsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=WGFHAB/vN3arsGutgbAc0x4zLYG2uK6T4yTo+ScdTdc=; b=he/v5iHniCeOac7sLKXRPHQDFJLCUelBaCJZoDMO2ub/DGCdovPhXGG7VEn4dTqbDO hj9yfTL4vx1UXFxcRilrd0N5v0bzvt7AHYjG/dMKgoCg1GDq6ThDW5lkR75Kb9Jjl7Wu /9b9BOqPFKciXwRN0UAWv+IaDPhOaZEfeoZWCxiWmdGS388V7wU+iAthJ5GKcoHrdAiE DXe5NJMhxJ6t3/mlD/tj4XM8gAxP4YuK4zn+BAxypWbdroSP2Vu2NRQ/+3D10MWaWiis FHxeRoGsAVxkF/+IrmIIZk7V4anQtC1099FtqMuL9PBbyBI8NeBPv/Zk/UMvoUXRUjH7 +xMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HffRWYCj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i67-v6si1635582qkb.226.2018.06.09.20.51.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:51:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HffRWYCj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrOM-0004tH-W2 for patch@linaro.org; Sat, 09 Jun 2018 23:51:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqee-0003JH-QT for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqed-0003od-GC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:32 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:45642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqed-0003oP-8E for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:31 -0400 Received: by mail-pf0-x241.google.com with SMTP id a22-v6so8480163pfo.12 for ; Sat, 09 Jun 2018 20:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WGFHAB/vN3arsGutgbAc0x4zLYG2uK6T4yTo+ScdTdc=; b=HffRWYCjauKm47jwJiZRG2iqmWw8klx401UxwXB+6bGJQKgnn07qrH+a2woKp1FGM8 WkLsPAjVip+UW3d+B7p+71827XqqW2z1JsucE5T65ew8HbeM2907ALpV2hPOiRQXVKON WazQjuInbSGCZdcXpzF1XkyvH7A38Z/roBaeM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WGFHAB/vN3arsGutgbAc0x4zLYG2uK6T4yTo+ScdTdc=; b=VanjlvZ2p7E0YQJMu4U5XkGpZYAjFCOjKi41ir2IVo27yM4g5fyoGjBYsfbwivbSjp 2WVzhZqkjB7lBnQeKKSIhnAHUPIHy2UFvML8VZoP6ucmKWcrg6uWOJEd1adluJX8Aobs iKbur2Xx9Nh/oJ0bSlP4BODQsGThMvRNiv2pVv+Be7n9p4OUrFZwyDgG1bghlV2SzvqQ Y2eonEdTKOqWIhzgGXaCr2WN2HKYwaz8O6GrPz+5+6ym2YQHZLdtk848iibHcrRbSTpl w3yGOxyqxCYTU8XtduNG2a2JMYOUrytgrE4myyLOY3xUhrzOG3idnSbgBVRXInG8qQQB U70w== X-Gm-Message-State: APt69E2ZgrOKKXwey6zof4VYs703gxlvOKhkugTT7jNacdgNd0pKeuWm 7XIe6ZylFleyizTI+YSbxJING7EBu5I= X-Received: by 2002:a65:494b:: with SMTP id q11-v6mr10610467pgs.105.1528599870031; Sat, 09 Jun 2018 20:04:30 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:29 -1000 Message-Id: <20180610030220.3777-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 057/108] linux-user: Split out modify_ldt, setdomainname, uname X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the same time, merge do_modify_ldt into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 123 +++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 57 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 41facf4b44..4967b84f21 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5755,7 +5755,6 @@ static bitmask_transtbl mmap_flags_tbl[] = { }; #if defined(TARGET_I386) - /* NOTE: there is really one LDT for all the threads */ static uint8_t *ldt_table; @@ -5870,29 +5869,6 @@ install: return 0; } -/* specific and weird i386 syscalls */ -static abi_long do_modify_ldt(CPUX86State *env, int func, abi_ulong ptr, - unsigned long bytecount) -{ - abi_long ret; - - switch (func) { - case 0: - ret = read_ldt(ptr, bytecount); - break; - case 1: - ret = write_ldt(env, ptr, bytecount, 1); - break; - case 0x11: - ret = write_ldt(env, ptr, bytecount, 0); - break; - default: - ret = -TARGET_ENOSYS; - break; - } - return ret; -} - #if defined(TARGET_I386) && defined(TARGET_ABI32) abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr) { @@ -8614,6 +8590,28 @@ IMPL(mmap2) } #endif +#ifdef TARGET_I386 +/* ??? Other TARGET_NR_modify_ldt should be deleted. */ +IMPL(modify_ldt) +{ + CPUX86State *env = cpu_env; + int func = arg1; + abi_ulong ptr = arg2; + abi_ulong bytecount = arg3; + + switch (func) { + case 0: + return read_ldt(ptr, bytecount); + case 1: + return write_ldt(env, ptr, bytecount, 1); + case 0x11: + return write_ldt(env, ptr, bytecount, 0); + default: + return -TARGET_ENOSYS; + } +} +#endif + IMPL(mount) { char *p1 = NULL, *p2, *p3 = NULL; @@ -9498,6 +9496,19 @@ IMPL(sendto) } #endif +IMPL(setdomainname) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(setdomainname(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + IMPL(sethostname) { char *p = lock_user_string(arg1); @@ -10206,6 +10217,31 @@ IMPL(umount2) return ret; } +IMPL(uname) +{ + struct new_utsname *buf; + abi_long ret; + + if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0)) { + return -TARGET_EFAULT; + } + /* No need to transcode because we use the linux syscall. */ + ret = get_errno(sys_uname(buf)); + if (!is_error(ret)) { + /* Overwrite the native machine name with whatever is being + emulated. */ + g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env), + sizeof(buf->machine)); + /* Allow the user to override the reported release. */ + if (qemu_uname_release && *qemu_uname_release) { + g_strlcpy(buf->release, qemu_uname_release, + sizeof(buf->release)); + } + } + unlock_user_struct(buf, arg1, 1); + return ret; +} + #ifdef TARGET_NR_unlink IMPL(unlink) { @@ -10384,41 +10420,9 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_setdomainname: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(setdomainname(p, arg2)); - unlock_user(p, arg1, 0); - return ret; - case TARGET_NR_uname: - /* no need to transcode because we use the linux syscall */ - { - struct new_utsname * buf; - - if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0)) - return -TARGET_EFAULT; - ret = get_errno(sys_uname(buf)); - if (!is_error(ret)) { - /* Overwrite the native machine name with whatever is being - emulated. */ - g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env), - sizeof(buf->machine)); - /* Allow the user to override the reported release. */ - if (qemu_uname_release && *qemu_uname_release) { - g_strlcpy(buf->release, qemu_uname_release, - sizeof(buf->release)); - } - } - unlock_user_struct(buf, arg1, 1); - } - return ret; -#ifdef TARGET_I386 - case TARGET_NR_modify_ldt: - return do_modify_ldt(cpu_env, arg1, arg2, arg3); -#if !defined(TARGET_X86_64) +#if defined(TARGET_I386) && !defined(TARGET_X86_64) case TARGET_NR_vm86: return do_vm86(cpu_env, arg1, arg2); -#endif #endif case TARGET_NR_adjtimex: { @@ -12986,6 +12990,9 @@ static impl_fn *syscall_table(unsigned num) #endif #ifdef TARGET_NR_mmap2 SYSCALL(mmap2); +#endif +#ifdef TARGET_I386 + SYSCALL(modify_ldt); #endif SYSCALL(mount); SYSCALL(mprotect); @@ -13112,6 +13119,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_sendto SYSCALL(sendto); #endif + SYSCALL(setdomainname); SYSCALL(sethostname); SYSCALL(setitimer); SYSCALL(setpgid); @@ -13181,6 +13189,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(umount); #endif SYSCALL(umount2); + SYSCALL(uname); #ifdef TARGET_NR_unlink SYSCALL(unlink); #endif