From nobody Wed Feb 11 01:09:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528602831921689.364900475332; Sat, 9 Jun 2018 20:53:51 -0700 (PDT) Received: from localhost ([::1]:42451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrQN-00067e-2m for importer@patchew.org; Sat, 09 Jun 2018 23:53:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfL-0003xn-3f for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfH-0004Lm-St for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:15 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:37284) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfH-0004La-JN for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:11 -0400 Received: by mail-pl0-x243.google.com with SMTP id 31-v6so10386558plc.4 for ; Sat, 09 Jun 2018 20:05:11 -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.05.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:09 -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=8+14MLF8Fqk1uqq8p44jusU/RdOQfrK1yUjLT+Lb4M8=; b=Gms9mzTVBnWDd8eJsk7Wx70Rmqm5LSpojq+aMz/lJMRM+aKMEYmdxPQJmtYipPVFil VA4PmzLtf2GyDWpcQe38kBPm3xM27WGhkEVbsrhZIrwur36W1AELMBggM5D9BFfmCY9w loJN+XjFnbUoaMBPiyHICvGkFiJEOV4iTIS8o= 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=8+14MLF8Fqk1uqq8p44jusU/RdOQfrK1yUjLT+Lb4M8=; b=Wd2JcwAYs2Ycf5xbvHAz/u4cUg3sR4rQE0tCd6xhPSDg+EBHFEO7GIHg7XAdtloRtY lH+7/z2rq8InVcMRwUDgumA/63lpbafFy3qLJZjX0GDUsMqNuWjdCM3jqU5SPxtlXJq4 XEdhHQJz7YO7eSVLQnZ0DSppglmdLUdSu0CIuP4d89RPiIhJSsAnA6XO3QZ0HPtnk6fu jys9mxxkm4qfGlZpB8t6SczCgskkG1LmZ4XYbjDzwN+wiUSaQFPL2Ogqg8Bcdc3oNudN KXTauWu1ETwhCAUEQNqjkNVkiaA7f2xK7syE2VCjM/8yFli99P2JAHMvL2EdKId/avFs Tg4w== X-Gm-Message-State: APt69E3/7LyKsX5ZYK2imrHUqZ1dyIrrjUiZ+REL4i/JR1YuG3MzmU9N MrW4TTp7N+Pl6itJRzQcCqJcM4b07mU= X-Google-Smtp-Source: ADUXVKJcU9OChlyrC4APjD14OOHnxf6HjhU9zuDWDPoDh7XNNz7pEt4BJro9KhywVvm1ru2muZ3AJg== X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr12602775ple.285.1528599910398; Sat, 09 Jun 2018 20:05:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:50 -1000 Message-Id: <20180610030220.3777-79-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:c01::243 Subject: [Qemu-devel] [PATCH v2 078/108] linux-user: Split out osf_getsysinfo, osf_setsysinfo, osf_sigprocmask 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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 323 ++++++++++++++++++++++--------------------- 1 file changed, 162 insertions(+), 161 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 17560ebd41..ae591a6523 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9444,6 +9444,159 @@ IMPL(open_by_handle_at) } #endif =20 +#if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) +IMPL(osf_getsysinfo) +{ + uint64_t swcr, fpcr; + + switch (arg1) { + case TARGET_GSI_IEEE_FP_CONTROL: + fpcr =3D cpu_alpha_load_fpcr(cpu_env); + + /* Copied from linux ieee_fpcr_to_swcr. */ + swcr =3D (fpcr >> 35) & SWCR_STATUS_MASK; + swcr |=3D (fpcr >> 36) & SWCR_MAP_DMZ; + swcr |=3D (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV + | SWCR_TRAP_ENABLE_DZE + | SWCR_TRAP_ENABLE_OVF); + swcr |=3D (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF + | SWCR_TRAP_ENABLE_INE); + swcr |=3D (fpcr >> 47) & SWCR_MAP_UMZ; + swcr |=3D (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; + + if (put_user_u64(swcr, arg2)) { + return -TARGET_EFAULT; + } + return 0; + + default: + /* case GSI_IEEE_STATE_AT_SIGNAL: + * -- Not implemented in linux kernel. + * case GSI_UACPROC: + * -- Retrieves current unaligned access state; not much used. + * case GSI_PROC_TYPE: + * -- Retrieves implver information; surely not used. + * case GSI_GET_HWRPB: + * -- Grabs a copy of the HWRPB; surely not used. + */ + return -TARGET_EOPNOTSUPP; + } +} +#endif + +#if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) +IMPL(osf_setsysinfo) +{ + uint64_t swcr, fpcr, exc, orig_fpcr; + int si_code; + + switch (arg1) { + case TARGET_SSI_IEEE_FP_CONTROL: + if (get_user_u64(swcr, arg2)) { + return -TARGET_EFAULT; + } + orig_fpcr =3D cpu_alpha_load_fpcr(cpu_env); + fpcr =3D orig_fpcr & FPCR_DYN_MASK; + + /* Copied from linux ieee_swcr_to_fpcr. */ + fpcr |=3D (swcr & SWCR_STATUS_MASK) << 35; + fpcr |=3D (swcr & SWCR_MAP_DMZ) << 36; + fpcr |=3D (~swcr & (SWCR_TRAP_ENABLE_INV + | SWCR_TRAP_ENABLE_DZE + | SWCR_TRAP_ENABLE_OVF)) << 48; + fpcr |=3D (~swcr & (SWCR_TRAP_ENABLE_UNF + | SWCR_TRAP_ENABLE_INE)) << 57; + fpcr |=3D (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); + fpcr |=3D (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; + + cpu_alpha_store_fpcr(cpu_env, fpcr); + return 0; + + case TARGET_SSI_IEEE_RAISE_EXCEPTION: + if (get_user_u64(exc, arg2)) { + return -TARGET_EFAULT; + } + orig_fpcr =3D cpu_alpha_load_fpcr(cpu_env); + + /* We only add to the exception status here. */ + fpcr =3D orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); + cpu_alpha_store_fpcr(cpu_env, fpcr); + + /* Old exceptions are not signaled. */ + fpcr &=3D ~(orig_fpcr & FPCR_STATUS_MASK); + + /* If any exceptions set by this call, + and are unmasked, send a signal. */ + si_code =3D 0; + if ((fpcr & (FPCR_INE | FPCR_INED)) =3D=3D FPCR_INE) { + si_code =3D TARGET_FPE_FLTRES; + } + if ((fpcr & (FPCR_UNF | FPCR_UNFD)) =3D=3D FPCR_UNF) { + si_code =3D TARGET_FPE_FLTUND; + } + if ((fpcr & (FPCR_OVF | FPCR_OVFD)) =3D=3D FPCR_OVF) { + si_code =3D TARGET_FPE_FLTOVF; + } + if ((fpcr & (FPCR_DZE | FPCR_DZED)) =3D=3D FPCR_DZE) { + si_code =3D TARGET_FPE_FLTDIV; + } + if ((fpcr & (FPCR_INV | FPCR_INVD)) =3D=3D FPCR_INV) { + si_code =3D TARGET_FPE_FLTINV; + } + if (si_code !=3D 0) { + CPUAlphaState *env =3D cpu_env; + target_siginfo_t info; + + info.si_signo =3D SIGFPE; + info.si_errno =3D 0; + info.si_code =3D si_code; + info._sifields._sigfault._addr =3D env->pc; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + } + return 0; + + default: + /* case SSI_NVPAIRS: + * -- Used with SSIN_UACPROC to enable unaligned accesses. + * case SSI_IEEE_STATE_AT_SIGNAL: + * case SSI_IEEE_IGNORE_STATE_AT_SIGNAL: + * -- Not implemented in linux kernel + */ + return -TARGET_EOPNOTSUPP; + } +} +#endif + +#if defined(TARGET_NR_osf_sigprocmask) && defined(TARGET_ALPHA) +IMPL(osf_sigprocmask) +{ + abi_ulong mask =3D arg2; + int how; + sigset_t set, oldset; + + switch (arg1) { + case TARGET_SIG_BLOCK: + how =3D SIG_BLOCK; + break; + case TARGET_SIG_UNBLOCK: + how =3D SIG_UNBLOCK; + break; + case TARGET_SIG_SETMASK: + how =3D SIG_SETMASK; + break; + default: + return -TARGET_EINVAL; + } + target_to_host_old_sigset(&set, &mask); + ret =3D do_sigprocmask(how, &set, &oldset); + if (!ret) { + host_to_target_old_sigset(&mask, &oldset); + ret =3D mask; + } + return ret; +} +#endif + #ifdef TARGET_NR_pause IMPL(pause) { @@ -11652,167 +11805,6 @@ static abi_long do_syscall1(void *cpu_env, unsign= ed num, abi_long arg1, void *p; =20 switch(num) { -#if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) - /* Alpha specific */ - case TARGET_NR_osf_getsysinfo: - ret =3D -TARGET_EOPNOTSUPP; - switch (arg1) { - case TARGET_GSI_IEEE_FP_CONTROL: - { - uint64_t swcr, fpcr =3D cpu_alpha_load_fpcr (cpu_env); - - /* Copied from linux ieee_fpcr_to_swcr. */ - swcr =3D (fpcr >> 35) & SWCR_STATUS_MASK; - swcr |=3D (fpcr >> 36) & SWCR_MAP_DMZ; - swcr |=3D (~fpcr >> 48) & (SWCR_TRAP_ENABLE_INV - | SWCR_TRAP_ENABLE_DZE - | SWCR_TRAP_ENABLE_OVF); - swcr |=3D (~fpcr >> 57) & (SWCR_TRAP_ENABLE_UNF - | SWCR_TRAP_ENABLE_INE); - swcr |=3D (fpcr >> 47) & SWCR_MAP_UMZ; - swcr |=3D (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO; - - if (put_user_u64 (swcr, arg2)) - return -TARGET_EFAULT; - ret =3D 0; - } - break; - - /* case GSI_IEEE_STATE_AT_SIGNAL: - -- Not implemented in linux kernel. - case GSI_UACPROC: - -- Retrieves current unaligned access state; not much used. - case GSI_PROC_TYPE: - -- Retrieves implver information; surely not used. - case GSI_GET_HWRPB: - -- Grabs a copy of the HWRPB; surely not used. - */ - } - return ret; -#endif -#if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) - /* Alpha specific */ - case TARGET_NR_osf_setsysinfo: - ret =3D -TARGET_EOPNOTSUPP; - switch (arg1) { - case TARGET_SSI_IEEE_FP_CONTROL: - { - uint64_t swcr, fpcr, orig_fpcr; - - if (get_user_u64 (swcr, arg2)) { - return -TARGET_EFAULT; - } - orig_fpcr =3D cpu_alpha_load_fpcr(cpu_env); - fpcr =3D orig_fpcr & FPCR_DYN_MASK; - - /* Copied from linux ieee_swcr_to_fpcr. */ - fpcr |=3D (swcr & SWCR_STATUS_MASK) << 35; - fpcr |=3D (swcr & SWCR_MAP_DMZ) << 36; - fpcr |=3D (~swcr & (SWCR_TRAP_ENABLE_INV - | SWCR_TRAP_ENABLE_DZE - | SWCR_TRAP_ENABLE_OVF)) << 48; - fpcr |=3D (~swcr & (SWCR_TRAP_ENABLE_UNF - | SWCR_TRAP_ENABLE_INE)) << 57; - fpcr |=3D (swcr & SWCR_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0= ); - fpcr |=3D (~swcr & SWCR_TRAP_ENABLE_DNO) << 41; - - cpu_alpha_store_fpcr(cpu_env, fpcr); - ret =3D 0; - } - break; - - case TARGET_SSI_IEEE_RAISE_EXCEPTION: - { - uint64_t exc, fpcr, orig_fpcr; - int si_code; - - if (get_user_u64(exc, arg2)) { - return -TARGET_EFAULT; - } - - orig_fpcr =3D cpu_alpha_load_fpcr(cpu_env); - - /* We only add to the exception status here. */ - fpcr =3D orig_fpcr | ((exc & SWCR_STATUS_MASK) << 35); - - cpu_alpha_store_fpcr(cpu_env, fpcr); - ret =3D 0; - - /* Old exceptions are not signaled. */ - fpcr &=3D ~(orig_fpcr & FPCR_STATUS_MASK); - - /* If any exceptions set by this call, - and are unmasked, send a signal. */ - si_code =3D 0; - if ((fpcr & (FPCR_INE | FPCR_INED)) =3D=3D FPCR_INE) { - si_code =3D TARGET_FPE_FLTRES; - } - if ((fpcr & (FPCR_UNF | FPCR_UNFD)) =3D=3D FPCR_UNF) { - si_code =3D TARGET_FPE_FLTUND; - } - if ((fpcr & (FPCR_OVF | FPCR_OVFD)) =3D=3D FPCR_OVF) { - si_code =3D TARGET_FPE_FLTOVF; - } - if ((fpcr & (FPCR_DZE | FPCR_DZED)) =3D=3D FPCR_DZE) { - si_code =3D TARGET_FPE_FLTDIV; - } - if ((fpcr & (FPCR_INV | FPCR_INVD)) =3D=3D FPCR_INV) { - si_code =3D TARGET_FPE_FLTINV; - } - if (si_code !=3D 0) { - target_siginfo_t info; - info.si_signo =3D SIGFPE; - info.si_errno =3D 0; - info.si_code =3D si_code; - info._sifields._sigfault._addr - =3D ((CPUArchState *)cpu_env)->pc; - queue_signal((CPUArchState *)cpu_env, info.si_signo, - QEMU_SI_FAULT, &info); - } - } - break; - - /* case SSI_NVPAIRS: - -- Used with SSIN_UACPROC to enable unaligned accesses. - case SSI_IEEE_STATE_AT_SIGNAL: - case SSI_IEEE_IGNORE_STATE_AT_SIGNAL: - -- Not implemented in linux kernel - */ - } - return ret; -#endif -#ifdef TARGET_NR_osf_sigprocmask - /* Alpha specific. */ - case TARGET_NR_osf_sigprocmask: - { - abi_ulong mask; - int how; - sigset_t set, oldset; - - switch(arg1) { - case TARGET_SIG_BLOCK: - how =3D SIG_BLOCK; - break; - case TARGET_SIG_UNBLOCK: - how =3D SIG_UNBLOCK; - break; - case TARGET_SIG_SETMASK: - how =3D SIG_SETMASK; - break; - default: - return -TARGET_EINVAL; - } - mask =3D arg2; - target_to_host_old_sigset(&set, &mask); - ret =3D do_sigprocmask(how, &set, &oldset); - if (!ret) { - host_to_target_old_sigset(&mask, &oldset); - ret =3D mask; - } - } - return ret; -#endif - #ifdef TARGET_NR_getgid32 case TARGET_NR_getgid32: return get_errno(getgid()); @@ -13316,6 +13308,15 @@ static impl_fn *syscall_table(unsigned num) #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(open_by_handle_at); #endif +#if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA) + SYSCALL(osf_getsysinfo); +#endif +#if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA) + SYSCALL(osf_setsysinfo); +#endif +#if defined(TARGET_NR_osf_sigprocmask) && defined(TARGET_ALPHA) + SYSCALL(osf_sigprocmask); +#endif #ifdef TARGET_NR_pause SYSCALL(pause); #endif --=20 2.17.1