From patchwork Thu Apr 22 23:02:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1469436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Z8uoVgCB; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRChW2MZkz9sVb for ; Fri, 23 Apr 2021 09:06:03 +1000 (AEST) Received: from localhost ([::1]:34372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiOX-0008UZ-CV for incoming@patchwork.ozlabs.org; Thu, 22 Apr 2021 19:06:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLD-0005AQ-OC for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:35 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:43549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLA-0007p2-UH for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:35 -0400 Received: by mail-pl1-x62e.google.com with SMTP id u15so15754627plf.10 for ; Thu, 22 Apr 2021 16:02:32 -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 :mime-version:content-transfer-encoding; bh=E3bcQGoF5tL2SwrZa81gd5wA84VGUXSBs7q30g13W7s=; b=Z8uoVgCBCKRqwEyyy1CXT+mgEXTiPQK5aDHiBM7TftnnuVidzhBNCWd5KknmnKCQ0G X1DBKTZ06hoX/atHKDcyFQSIpAEu+NcouEWH6xIDMEvLXS/dMZDDrpTLHZsmWaFUHPGY Fnrf6y1hWrIw0ZgWkVk/JCZgsI9ZCCKYynVgAMtgW18rIKYIZN/9j7TdL6jpqiaT9YqX pjr3FhMUpNwMsMa0aKa+eUJeKeNz1mRd1ewn4N8ZPBEZJs/PSwlyuZnlQxGQzdq4ZJWb c7WOO3Iqq+xpF+kGFLDqe7Ds9kG6jyo3Cllxf0nkyLvDrmHfPUa9evFn4fAA9vEtfxEW axDg== 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:mime-version:content-transfer-encoding; bh=E3bcQGoF5tL2SwrZa81gd5wA84VGUXSBs7q30g13W7s=; b=lsCPdh+/LgFQAAvl8Qsqc3/jValaiCtQJV1uQVZnPPxwxyEYSthQ47DOYfFB2n9xiC WHyrl6CD2Vr71/76M+jq75RVbOsf+ZQB8c7rA6kY/pqZHw4bDKRs5tE+YzbmFwehpY1A ZJzdumMfKwTbhMfUfm4TZ2eNHCI+3LV7MvC7ZU3OGkm8zDL1ZfZkrGYNTfTKlkclsV11 3eXpPDArSaLP9U0YyaqewU7wgTMFP2scVf9f3sWIyOmmfNpEJ5zHuXgNXhDr2dJ1e8Cg MK1RoKdDWs7xKPF5SZiBxC8wGcI7a+cU3quZg+IFFIOVi7cImGXqBMhJ901qivE8wjkF KMQg== X-Gm-Message-State: AOAM533xIrY46ig7m6B+sc4s6bld1JuOP4LiVqyVlsSqZyx5WjIH5B5X 0yS6D1Zab3KJPSjHTxXAjF5vybdA1NULxQ== X-Google-Smtp-Source: ABdhPJwxoWceg63ddk3cjhGTbBfZWuYlQwkYIG5b0SORKPxECErp1WFVRpuslUPimmHPjMU3Q+KtCA== X-Received: by 2002:a17:90a:4a8f:: with SMTP id f15mr1136828pjh.19.1619132550891; Thu, 22 Apr 2021 16:02:30 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/7] linux-user/alpha: Rename the sigaction restorer field Date: Thu, 22 Apr 2021 16:02:22 -0700 Message-Id: <20210422230227.314751-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Use ka_restorer, in line with TARGET_ARCH_HAS_KA_RESTORER vs TARGET_ARCH_HAS_SA_RESTORER, since Alpha passes this field as a syscall argument. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- linux-user/syscall_defs.h | 2 +- linux-user/alpha/signal.c | 8 ++++---- linux-user/syscall.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 25be414727..693d4f3788 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -519,7 +519,7 @@ struct target_sigaction { abi_ulong _sa_handler; abi_ulong sa_flags; target_sigset_t sa_mask; - abi_ulong sa_restorer; + abi_ulong ka_restorer; }; #elif defined(TARGET_MIPS) struct target_sigaction { diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 86f5d2276d..3aa4b339a4 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -138,8 +138,8 @@ void setup_frame(int sig, struct target_sigaction *ka, setup_sigcontext(&frame->sc, env, frame_addr, set); - if (ka->sa_restorer) { - r26 = ka->sa_restorer; + if (ka->ka_restorer) { + r26 = ka->ka_restorer; } else { __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, @@ -192,8 +192,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } - if (ka->sa_restorer) { - r26 = ka->sa_restorer; + if (ka->ka_restorer) { + r26 = ka->ka_restorer; } else { __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 95d79ddc43..ee21eb5e6f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8989,7 +8989,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; - act.sa_restorer = 0; + act.ka_restorer = 0; unlock_user_struct(old_act, arg2, 0); pact = &act; } @@ -9085,7 +9085,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags; - act.sa_restorer = arg5; + act.ka_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &act; } From patchwork Thu Apr 22 23:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1469437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=nK+8iNGg; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRChZ4W3dz9sVb for ; Fri, 23 Apr 2021 09:06:06 +1000 (AEST) Received: from localhost ([::1]:34678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiOa-0000CC-Im for incoming@patchwork.ozlabs.org; Thu, 22 Apr 2021 19:06:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLG-0005Ee-0t for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:38 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:37722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLB-0007p6-4f for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:37 -0400 Received: by mail-pl1-x635.google.com with SMTP id h20so24313504plr.4 for ; Thu, 22 Apr 2021 16:02:32 -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 :mime-version:content-transfer-encoding; bh=OcPohUJWUFK5d9fBWTi1civihLvFybtJees054KN698=; b=nK+8iNGgiElRkLPhvH2RntlROcVQ0UaIVOTu5rAW+MEVw6hMb8bKJzhyMD15Tq1Wxy hq08ZcBuEpAfNujI5yFJ11mA5BK3TdO0Gprx6R8hVq6Plb19krvuF+dkTaA2ZqdKICLR sY/4/vsOFg/XilXqx3Ef/ii2VBqg5sqfQ4YQ4nMlQ7SiJePNz5ii/rXof+U9F4swOh8C zcwIIQjvS+xiaBqzaVvR8KfhnssKcBXG5K1Qqu0cBT7dYE64yVaZ+SUP/4TMp6BYWdsN ag7envE1QPNxln8hEJXdZyJyk/Kq9L27iAfiL5tW9W5YcUW6/9YtfexxZgHNYIBTXsQB 6eHA== 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:mime-version:content-transfer-encoding; bh=OcPohUJWUFK5d9fBWTi1civihLvFybtJees054KN698=; b=P1SkwIPeBLTkHu1GuCPmIa48H0FKdL91/s5/7sVY0eeGZynLtwC7j1z3RDnVxmenFj elCc90ms5t64oJq6KmcXg3/APeo4Thcby6D6lqZIzBAeuQEUaEHV5twgnjEGLRy3TKtp 9uH1Gx6eIcDII4iwNdz3d09MpMXdqIknJtf+kBQw8I9mDTgcMkf3XGvvmJ4YHKQmPCX3 RCGERH5iNPJyZKR2HJo5Gk0jOgcvkA0dpI6wO/HwnbVMb/nQA5HZf4Fio+/62vJ9xbwB AR9QFMxqgRZ0yRKslsDVB4UMVyDQ2DbQigDie9ZC36tdTDC95YYwwt6+QxZB7pMK4SGm 8Kdw== X-Gm-Message-State: AOAM532Jsv9XI+dULAcsUtp322t4UeNpsmS4XrF9sZ8YUZyyj6dy7stQ MIzUbqDjjPPSNkxI3TQC9cC5ybELFbj9KQ== X-Google-Smtp-Source: ABdhPJwIiElIq1Cipf1p9U13WPbfbhfOXXqPnNgSSadOTjRWM+VJxZAlm87A1+BPYsZUhPkbt22gZQ== X-Received: by 2002:a17:90a:fb89:: with SMTP id cp9mr1089993pjb.47.1619132551466; Thu, 22 Apr 2021 16:02:31 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 3/7] linux-user: Pass ka_restorer to do_sigaction Date: Thu, 22 Apr 2021 16:02:23 -0700 Message-Id: <20210422230227.314751-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The value of ka_restorer needs to be saved in sigact_table. At the moment, the attempt to save it in do_syscall is improperly clobbering user memory. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- linux-user/syscall_defs.h | 2 +- linux-user/signal.c | 5 ++++- linux-user/syscall.c | 19 ++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 693d4f3788..e4aaf8412f 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -492,7 +492,7 @@ void target_to_host_old_sigset(sigset_t *sigset, const abi_ulong *old_sigset); struct target_sigaction; int do_sigaction(int sig, const struct target_sigaction *act, - struct target_sigaction *oact); + struct target_sigaction *oact, abi_ulong ka_restorer); #include "target_signal.h" diff --git a/linux-user/signal.c b/linux-user/signal.c index 7eecec46c4..44a5012930 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -830,7 +830,7 @@ out: /* do_sigaction() return target values and host errnos */ int do_sigaction(int sig, const struct target_sigaction *act, - struct target_sigaction *oact) + struct target_sigaction *oact, abi_ulong ka_restorer) { struct target_sigaction *k; struct sigaction act1; @@ -863,6 +863,9 @@ int do_sigaction(int sig, const struct target_sigaction *act, __get_user(k->sa_flags, &act->sa_flags); #ifdef TARGET_ARCH_HAS_SA_RESTORER __get_user(k->sa_restorer, &act->sa_restorer); +#endif +#ifdef TARGET_ARCH_HAS_KA_RESTORER + k->ka_restorer = ka_restorer; #endif /* To be swapped in target_to_host_sigset. */ k->sa_mask = act->sa_mask; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ee21eb5e6f..36169a0ded 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8989,11 +8989,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; - act.ka_restorer = 0; unlock_user_struct(old_act, arg2, 0); pact = &act; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) return -TARGET_EFAULT; @@ -9017,7 +9016,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, pact = NULL; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) @@ -9040,15 +9039,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; act.sa_restorer = old_act->sa_restorer; -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act.ka_restorer = 0; -#endif unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) return -TARGET_EFAULT; @@ -9085,11 +9081,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags; - act.ka_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &act; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, arg5)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) return -TARGET_EFAULT; @@ -9104,6 +9099,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_ulong sigsetsize = arg5; #else target_ulong sigsetsize = arg4; + target_ulong restorer = 0; #endif struct target_sigaction *act; struct target_sigaction *oact; @@ -9115,9 +9111,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { return -TARGET_EFAULT; } -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act->ka_restorer = restorer; -#endif } else { act = NULL; } @@ -9128,7 +9121,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } else oact = NULL; - ret = get_errno(do_sigaction(arg1, act, oact)); + ret = get_errno(do_sigaction(arg1, act, oact, restorer)); rt_sigaction_fail: if (act) unlock_user_struct(act, arg2, 0); From patchwork Thu Apr 22 23:02:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1469438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=MXesaNbF; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRCk81fFpz9sVb for ; Fri, 23 Apr 2021 09:07:28 +1000 (AEST) Received: from localhost ([::1]:38842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiPu-0001yy-8A for incoming@patchwork.ozlabs.org; Thu, 22 Apr 2021 19:07:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLE-0005Ak-2A for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:45730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLC-0007p9-5F for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:35 -0400 Received: by mail-pl1-x62f.google.com with SMTP id p16so20353559plf.12 for ; Thu, 22 Apr 2021 16:02:33 -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 :mime-version:content-transfer-encoding; bh=lssDGPyfuni9CuU6IOfi+DPva4cgyenF8vOgPbXMLPk=; b=MXesaNbFzhW2/ZKO+ltPv8YM0ZD4L5WpCZBG94oPSWNzcZvxw2f42Q5xannurG2ZLg xCe27Xo7OWDg5Gkj5h3ylt9uhl7AzzFMal7JE6gq1l+cKzjFNZuHT1MSwe6unFWKDX3a DvlreW+WLHZq9ojN//Xl/GcXHpn5dJ0t/qZRKMns81VWoxp/pcY10lns6yudzU4vhdj5 fOsgzJJCVebeBLGgkUOCuJUpuMng9+eCqT4gINgHL2o3w4jkVgJFQ+I0/ALW3d6+eASQ 03pGgbeLy0mTEWg1ffhMD3CDW+ZKXy0a+Xy3zuJHzrP5HWwJw1ZpkajMzwHjuYhdytPD KSCQ== 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:mime-version:content-transfer-encoding; bh=lssDGPyfuni9CuU6IOfi+DPva4cgyenF8vOgPbXMLPk=; b=Sj6uWqshXRJbuHgsD5h3aVZ8wMvQqeZi+CEvQYDiNuBzi6bVkGfT8Yf2bgDVBNUiOL ty/HL8nxYuLNPXPVHMqsQ7RNxTQUR+N0aXB4xoWWWWnwp2MGamPXCm0BHRZH3Ukkfesw k31nul0EAZkA0OvnfEdK3GyuF9pJ8x6+/Fkk5YCw0mxZIdB5mTQNOfG9DrEHdnj36Lnt nizrgEn6pnMAGKDQ/F3v4I4/C7YP6tTm+DAhcnz6tZMcps5Q3WKIiRVojflQjOwuSQak v/7E0dIu99b7kJ1QcwWln/CTq3bpx0O4zTXl0E5/GcH85OV8FL8V3FIRGTgYiF1LAleP jzDA== X-Gm-Message-State: AOAM531IZGjWa2RIgW0ai0Br4lBVqiPH4cjpyPKgWPMLBnVUeGi7nSP5 qPxIiIqj0N8OIqhGjWEVvD6xH+bq9SyvIg== X-Google-Smtp-Source: ABdhPJw4xowupFCslN6Eo7JLHn4xXwiGp03xy0w35dI1jn1zoUxK6MX0dRHuupGCOiwwIVVUClNSJg== X-Received: by 2002:a17:902:d706:b029:e6:90aa:24e0 with SMTP id w6-20020a170902d706b02900e690aa24e0mr851040ply.42.1619132552090; Thu, 22 Apr 2021 16:02:32 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 4/7] linux-user: Honor TARGET_ARCH_HAS_SA_RESTORER in do_syscall Date: Thu, 22 Apr 2021 16:02:24 -0700 Message-Id: <20210422230227.314751-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Do not access a field that may not be present. This will become an issue when sharing more code in the next patch. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- linux-user/syscall.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 36169a0ded..89d641856c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9038,7 +9038,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER act.sa_restorer = old_act->sa_restorer; +#endif unlock_user_struct(old_act, arg2, 0); pact = &act; } else { @@ -9051,7 +9053,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0]; old_act->sa_flags = oact.sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER old_act->sa_restorer = oact.sa_restorer; +#endif unlock_user_struct(old_act, arg3, 1); } #endif From patchwork Thu Apr 22 23:02:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1469434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=MZVtRtGh; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRCdl0BLvz9sVb for ; Fri, 23 Apr 2021 09:03:39 +1000 (AEST) Received: from localhost ([::1]:54610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiMD-0005Ia-0W for incoming@patchwork.ozlabs.org; Thu, 22 Apr 2021 19:03:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLE-0005C2-Om for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:42777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLC-0007pG-Kz for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: by mail-pj1-x102d.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so225273pjv.1 for ; Thu, 22 Apr 2021 16:02:33 -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 :mime-version:content-transfer-encoding; bh=Pq63tIitSEl/3DIHxaCuKkI+VTWbKxsaVUJWQ8jB2y0=; b=MZVtRtGh6eepo5poAaJrndcIXlcBUIMHSdqOE55GuNbzB+IjnkXv2DN88FoFWIvFWK rX8heO1anc2b4+lNYp3ikXUicBbt6mPb20I3K72A4HRjnb2jdwX8dTxU5TiQAjk3n+aY vUB2uH1rUgGsqHK6J3owYEOrPjGG50fekU8wp52vqNbmi03qSjvtr0rO1gKGPpvpv4A+ mP2PtOJyQqlTqR7uuXztejjNSFnzIFxMMQTN0VbS3GeR7Lz42DeYKnNSD/I7Mz3C4fAP X5dXDm6QxlSAGXvrXdeEAtG7PBMPAoYrzIpeBSMM2MAexjxvxD29FrzzfjxYx9NFnDE6 MhTg== 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:mime-version:content-transfer-encoding; bh=Pq63tIitSEl/3DIHxaCuKkI+VTWbKxsaVUJWQ8jB2y0=; b=GrXFEjB/WqqBD+D1WqKYNRFqS1PA9ETHvVR528DM5XPdrEowF/iyiC8TKbivtoB8Tm bvMB49mmh+/b2d4FVRxbd86dzrXtnn4MSYsHLmV7w768UvP89fz7ZbOm3CpOCFtgWN/5 91X1b1v+RCEWNF9nNNj9nwPqDRzywkrKUCE8UugGE5AcC/oJ78Ze8MzyOPp2J7Rvix/W dwE7mmRAnmdPghoRZx2Y7G8cbgJiBLFuoOxlvacNbI7bD56uzWfj//Qfnw+qObXiPkm/ sp4lvGFBb9xlhF3CCh389zrJju4/fCRB8mOcbXRWdlgKJW5aTIqCC28zTpQYaQa58W48 V4nw== X-Gm-Message-State: AOAM533UHnoh5HoWATfvnssk88WPzvVd2eV/Xkk5twxpiVzPCJFc97Jz FNmt1JcJXe0X489llEsYs0yrKpbaYhL+BQ== X-Google-Smtp-Source: ABdhPJxq2sCBM70ZnV0U+DvZtsUVr9Irzu7MVBse1m5B7jjnJlZIfw+8DGqaTXtqHOo2QuVR6tPyLQ== X-Received: by 2002:a17:902:b210:b029:eb:535f:852 with SMTP id t16-20020a170902b210b02900eb535f0852mr845384plr.80.1619132552721; Thu, 22 Apr 2021 16:02:32 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 5/7] linux-user/alpha: Define TARGET_ARCH_HAS_KA_RESTORER Date: Thu, 22 Apr 2021 16:02:25 -0700 Message-Id: <20210422230227.314751-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This means that we can share the TARGET_NR_rt_sigaction code, and the target_rt_sigaction structure is unused. Untangling the ifdefs so that target_sigaction can be shared will wait until the next patch. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- linux-user/alpha/target_signal.h | 1 + linux-user/syscall_defs.h | 6 ------ linux-user/syscall.c | 37 ++++++-------------------------- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index 0b90d3a897..250642913e 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -92,6 +92,7 @@ typedef struct target_sigaltstack { #define TARGET_GEN_SUBRNG7 -25 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_KA_RESTORER /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index e4aaf8412f..7a1d3b239c 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -507,12 +507,6 @@ struct target_old_sigaction { int32_t sa_flags; }; -struct target_rt_sigaction { - abi_ulong _sa_handler; - abi_ulong sa_flags; - target_sigset_t sa_mask; -}; - /* This is the struct used inside the kernel. The ka_restorer field comes from the 5th argument to sys_rt_sigaction. */ struct target_sigaction { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 89d641856c..216ee4ca47 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9064,41 +9064,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #endif case TARGET_NR_rt_sigaction: { -#if defined(TARGET_ALPHA) - /* For Alpha and SPARC this is a 5 argument syscall, with + /* + * For Alpha and SPARC this is a 5 argument syscall, with * a 'restorer' parameter which must be copied into the * sa_restorer field of the sigaction struct. * For Alpha that 'restorer' is arg5; for SPARC it is arg4, * and arg5 is the sigsetsize. - * Alpha also has a separate rt_sigaction struct that it uses - * here; SPARC uses the usual sigaction struct. */ - struct target_rt_sigaction *rt_act; - struct target_sigaction act, oact, *pact = 0; - - if (arg4 != sizeof(target_sigset_t)) { - return -TARGET_EINVAL; - } - if (arg2) { - if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = rt_act->_sa_handler; - act.sa_mask = rt_act->sa_mask; - act.sa_flags = rt_act->sa_flags; - unlock_user_struct(rt_act, arg2, 0); - pact = &act; - } - ret = get_errno(do_sigaction(arg1, pact, &oact, arg5)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) - return -TARGET_EFAULT; - rt_act->_sa_handler = oact._sa_handler; - rt_act->sa_mask = oact.sa_mask; - rt_act->sa_flags = oact.sa_flags; - unlock_user_struct(rt_act, arg3, 1); - } -#else -#ifdef TARGET_SPARC +#if defined(TARGET_ALPHA) + target_ulong sigsetsize = arg4; + target_ulong restorer = arg5; +#elif defined(TARGET_SPARC) target_ulong restorer = arg4; target_ulong sigsetsize = arg5; #else @@ -9131,7 +9107,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user_struct(act, arg2, 0); if (oact) unlock_user_struct(oact, arg3, 1); -#endif } return ret; #ifdef TARGET_NR_sgetmask /* not on alpha */ From patchwork Thu Apr 22 23:02:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1469433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=avWb8ynR; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRCdj3cvSz9sVb for ; Fri, 23 Apr 2021 09:03:37 +1000 (AEST) Received: from localhost ([::1]:54504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiMB-0005G2-HO for incoming@patchwork.ozlabs.org; Thu, 22 Apr 2021 19:03:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLE-0005CN-W4 for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:37 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:40485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLD-0007pT-2g for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: by mail-pl1-x633.google.com with SMTP id 20so20356068pll.7 for ; Thu, 22 Apr 2021 16:02:34 -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 :mime-version:content-transfer-encoding; bh=9IBgpRlXRDcwQhpg7EYQ7Dn5EzD7vaEg5bq7L4WY5HM=; b=avWb8ynRA7J49Tc/sUJZVMIW1LAdjHBf/5vjzQRzWX7xOKc08cIafzUFQtskoiV3B0 IScMgUuQhJaROSWth3xdwKMPX7O3L4d7sMESOi1j5tx0EtnT7Vk10UOIMmIuanaLMYNl d42DVyqFyj0wd6z8QmteiBpXOTE4olQm6hFYJdT99XkBFlLONCN/dybefuUM4DBhdUrw NwSB9TpgIQLN8aiIEjecvoGDqGW6KBw3VkhXUI6UcWF+i8/xpawayEKW5mC+OUVeG4sk BDBwluwNAiBcESviTIa0AbcXFGSnuWXpZRcnEbxV/4VhGa3dklaW3HIJAWZ9SSSdCRqY VzRg== 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:mime-version:content-transfer-encoding; bh=9IBgpRlXRDcwQhpg7EYQ7Dn5EzD7vaEg5bq7L4WY5HM=; b=FLjGcUIc4AIhSIZMmjTlROJblYshNC8JownBZpZFiFo8YO057LwHUNhpWnic+84WRV livBDsoXBfL8/bWn/rZ1J18kRBQCyUtsKGkxo8CBcT7N9tHk5IovCg8DrVCZ7P78XSr5 Gb2KXRF2tfDQg9I8yrUDzGoAYeRli29XT0D1crHa4jl6f8Z3ziw9B+COYSR1DTUBmXnE 14UOKLBPFGFI86VHuGpyPewKf4RNQ//1gqUfQB3WzGyG4hHy/C1we+VxY+5fDhaRmuZY /fM2LsF5z2wVDEAHeYLosZP1k92rDvo8rvA0PtO9S6R8llNHLKQYF5/1K1FINPQQCkoA fs4Q== X-Gm-Message-State: AOAM533dyc1QBCArvxW8vV5IbHjX1owz5wy3RYvptC4WSQnJ8IaEdalf 7Yux8qgOrhHg2PI/Kwl/RoeGvf/X8ABPPQ== X-Google-Smtp-Source: ABdhPJyKfKQX/W5aXPaw1CrVqCIv4VgYY+mPZMCr/0VfpIVYh+e73MxlJlG4mu7WP6j3X0IOFImGpQ== X-Received: by 2002:a17:902:a38e:b029:eb:3963:5aee with SMTP id x14-20020a170902a38eb02900eb39635aeemr1142615pla.78.1619132553313; Thu, 22 Apr 2021 16:02:33 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 6/7] linux-user/alpha: Share code for TARGET_NR_sigaction Date: Thu, 22 Apr 2021 16:02:26 -0700 Message-Id: <20210422230227.314751-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There's no longer a difference between the alpha code and the generic code. There is a type difference in target_old_sigaction.sa_flags, which can be resolved with a very much smaller ifdef, which allows us to finish sharing the target_sigaction definition. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Reviewed-by: Alex Bennée --- linux-user/syscall_defs.h | 21 ++++++--------------- linux-user/syscall.c | 23 +---------------------- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7a1d3b239c..18b031a2f6 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -501,21 +501,12 @@ int do_sigaction(int sig, const struct target_sigaction *act, #endif #if defined(TARGET_ALPHA) -struct target_old_sigaction { - abi_ulong _sa_handler; - abi_ulong sa_mask; - int32_t sa_flags; -}; +typedef int32_t target_old_sa_flags; +#else +typedef abi_ulong target_old_sa_flags; +#endif -/* This is the struct used inside the kernel. The ka_restorer - field comes from the 5th argument to sys_rt_sigaction. */ -struct target_sigaction { - abi_ulong _sa_handler; - abi_ulong sa_flags; - target_sigset_t sa_mask; - abi_ulong ka_restorer; -}; -#elif defined(TARGET_MIPS) +#if defined(TARGET_MIPS) struct target_sigaction { uint32_t sa_flags; #if defined(TARGET_ABI_MIPSN32) @@ -533,7 +524,7 @@ struct target_sigaction { struct target_old_sigaction { abi_ulong _sa_handler; abi_ulong sa_mask; - abi_ulong sa_flags; + target_old_sa_flags sa_flags; #ifdef TARGET_ARCH_HAS_SA_RESTORER abi_ulong sa_restorer; #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 216ee4ca47..9bcd485423 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8980,28 +8980,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_sigaction case TARGET_NR_sigaction: { -#if defined(TARGET_ALPHA) - struct target_sigaction act, oact, *pact = 0; - struct target_old_sigaction *old_act; - if (arg2) { - if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) - return -TARGET_EFAULT; - act._sa_handler = old_act->_sa_handler; - target_siginitset(&act.sa_mask, old_act->sa_mask); - act.sa_flags = old_act->sa_flags; - unlock_user_struct(old_act, arg2, 0); - pact = &act; - } - ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); - if (!is_error(ret) && arg3) { - if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) - return -TARGET_EFAULT; - old_act->_sa_handler = oact._sa_handler; - old_act->sa_mask = oact.sa_mask.sig[0]; - old_act->sa_flags = oact.sa_flags; - unlock_user_struct(old_act, arg3, 1); - } -#elif defined(TARGET_MIPS) +#if defined(TARGET_MIPS) struct target_sigaction act, oact, *pact, *old_act; if (arg2) { From patchwork Thu Apr 22 23:02:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1469439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=C4QyKbBA; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRClC1wcdz9sVb for ; Fri, 23 Apr 2021 09:08:23 +1000 (AEST) Received: from localhost ([::1]:41774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZiQn-0003AV-89 for incoming@patchwork.ozlabs.org; Thu, 22 Apr 2021 19:08:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZiLF-0005Ck-5l for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:37 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:39913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lZiLD-0007pY-HA for qemu-devel@nongnu.org; Thu, 22 Apr 2021 19:02:36 -0400 Received: by mail-pl1-x633.google.com with SMTP id u7so22494823plr.6 for ; Thu, 22 Apr 2021 16:02:34 -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 :mime-version:content-transfer-encoding; bh=LKfV1I/Csk0qYQwhR0M4lp6iP2nYp4OTkUQuJPZGosY=; b=C4QyKbBANIxwH1YFMbdaY3BSVgMwjkdCbJ8cZPHBoIwx1zIxj9mDEdfin8uRo/p/Pt i1qwlJPHlbRLOOnthiFVWEpdZbkTF5JQnF/8ekARH+LQ6CW/C/MvyZN17xUMrnj9wTdi j/h4AM6dKUSF+j5jiRFxmFOo79z/y9rAjPttt11qKT6WAh0s5nEF715C0LjCCfhz88a6 E25AREdKNsasDGu8rY40qKNo/mvPeiGjCUyPioguruGBzznjancd0T5J7fcW0nbz3f6b bZmCce+Cw8+9bvx7UtVL2HMJbV9XtT8wUlCoEV+ZQuixfli/ELuO+EOxYriZvViR4c8q dtIg== 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:mime-version:content-transfer-encoding; bh=LKfV1I/Csk0qYQwhR0M4lp6iP2nYp4OTkUQuJPZGosY=; b=bmN/8EH9Effo7A1tC4kTCwnQkNYaaRlRxMQgl0s6ZdHpzftNROukyP0dynAEHFnJkr K1twtAZ8+wBpDLzpe9/qr9aKaICMSJpIPc6LtzOtb7ZKQMpcGRenequeBMROIZkUPSwM sWDaOBRH5SXceleqCO3G9S98vXc7PpDqyDEINAu+dL7IOBtl1ujyBYsrO+TzEDsGfNhK 8SWD06Ff8JS1uwJfifvzAswx+B9B6pcW8JxG9hZxZCiClTrdlmHfxiApdIIK0apWW1/X vGZtadv6RpHKfoK26E+wQ9myuYk1bmhMJpM+GAvoI0UTkwlLDCBloZIpK9Jf48WD6NXb kYAQ== X-Gm-Message-State: AOAM5322CtnbpBsBrOkKu4FZfchM+/jesWH4/++nCj3D26XdsjbGgw5b 4bR+DnDxnVCWUcVc5bI6FwXhsffd15jrNg== X-Google-Smtp-Source: ABdhPJx5Td1YDbJzHiZ16Y8821MEwhqcD82ABQhnXZKBElIJvKnYvAAvszeJtWmup0JPCsUXHhf/gg== X-Received: by 2002:a17:903:18e:b029:ec:b394:981f with SMTP id z14-20020a170903018eb02900ecb394981fmr1161614plg.6.1619132553950; Thu, 22 Apr 2021 16:02:33 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id z12sm2930605pfn.195.2021.04.22.16.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 16:02:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 7/7] linux-user: Tidy TARGET_NR_rt_sigaction Date: Thu, 22 Apr 2021 16:02:27 -0700 Message-Id: <20210422230227.314751-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210422230227.314751-1-richard.henderson@linaro.org> References: <20210422230227.314751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Initialize variables instead of elses. Use an else instead of a goto. Add braces. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- linux-user/syscall.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9bcd485423..c7c3257f40 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9060,32 +9060,26 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_ulong sigsetsize = arg4; target_ulong restorer = 0; #endif - struct target_sigaction *act; - struct target_sigaction *oact; + struct target_sigaction *act = NULL; + struct target_sigaction *oact = NULL; if (sigsetsize != sizeof(target_sigset_t)) { return -TARGET_EINVAL; } - if (arg2) { - if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { - return -TARGET_EFAULT; - } - } else { - act = NULL; + if (arg2 && !lock_user_struct(VERIFY_READ, act, arg2, 1)) { + return -TARGET_EFAULT; } - if (arg3) { - if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { - ret = -TARGET_EFAULT; - goto rt_sigaction_fail; + if (arg3 && !lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) { + ret = -TARGET_EFAULT; + } else { + ret = get_errno(do_sigaction(arg1, act, oact, restorer)); + if (oact) { + unlock_user_struct(oact, arg3, 1); } - } else - oact = NULL; - ret = get_errno(do_sigaction(arg1, act, oact, restorer)); - rt_sigaction_fail: - if (act) + } + if (act) { unlock_user_struct(act, arg2, 0); - if (oact) - unlock_user_struct(oact, arg3, 1); + } } return ret; #ifdef TARGET_NR_sgetmask /* not on alpha */