From patchwork Tue May 18 05:30:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 441119 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1776189jac; Mon, 17 May 2021 22:37:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNZjnyzsoWczs9sD1x5NOBZSUFpHg0M1rBUQ1dm/x2pGdY3dXuehYScN+2nXjL0i2Chiw+ X-Received: by 2002:a1f:160c:: with SMTP id 12mr4238474vkw.25.1621316260864; Mon, 17 May 2021 22:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621316260; cv=none; d=google.com; s=arc-20160816; b=m0yO5uH9FNgN1aRv7ldGA1SdAIlnnK9pOlum9S6h/9ezXtFqMyLyjWv3y236xn+SwU Kjpl/PyYwvQiJDAr7NvvXQ5pG8GFsEiT+wjVUBZ1xFq0l90zxb+wDfOoHsMfV/Fv2htp hBkVrKHKTMWNoEr0xkOzFlYWL46equgNfTAyKrNlaewpcsMHk1MdhUS/2EIg3oXPinzO ohWt2djSDc8B+zw91v2KUkASUbHcNl04DV20tp+2RqdO+E9rXZ10KguR13WLWtaQka7C iZ3/0HvpGve6mcpbePzYknY3Aq9RVqzCJXUdi/cMlw5YpZA+aj/waAl/1mtdaHxxw8tJ TzBw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=FsBmKb5yhr2M5OsIL5COxS7Do7okkyTuDNGVTS8LN8E=; b=d+m09ajVT6JLWp59p89g6PUlSttisqwxYNLSlB9cDYwvNNmSWtzc3DV4J6yXy5s66Y fQY0f4/wheCNbYIq7bvrIech187lBCgoE1DZrhYxCkghXI4JW7rYRqHSFdT6AF/LwClu eJzllDQnQWFbuaxm2SWRhTo7wDtEdLFJsvni9X5AAEnYlFMzv2mEzNkapokzvr6wGOpF l9swMdmGMwWxf5IMTO9JDRXAf1a6hND8xoEE6vAAChcFOSCbLvK7e0WsQAjn0JdensQt Mr4utIYUbWCo33SikXBXowmZiBuWhQewFMUuQFHrUSW4Mq2Mgv6uqjUjaEoGxvbRWLcf ws/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i35si1489566uad.205.2021.05.17.22.37.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 May 2021 22:37:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:36774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lisQG-00076D-7E for patch@linaro.org; Tue, 18 May 2021 01:37:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lisKT-0006jq-Fg for qemu-devel@nongnu.org; Tue, 18 May 2021 01:31:41 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:44839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lisKR-0006uG-Dl for qemu-devel@nongnu.org; Tue, 18 May 2021 01:31:41 -0400 Received: from quad ([82.142.31.78]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MYvHa-1lw1U11kBM-00UtMf; Tue, 18 May 2021 07:31:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/59] linux-user: Pass CPUArchState to do_sigaltstack Date: Tue, 18 May 2021 07:30:42 +0200 Message-Id: <20210518053131.87212-11-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210518053131.87212-1-laurent@vivier.eu> References: <20210518053131.87212-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Jw/oUiKDbNugkvf4iJbUazGAX2NzpEhAkTWc54ZKkoceoDH+qg4 olZj7g53VYt6JD8eLQWsGDREJ9PA7YChgadWBavteBUWjLaCbcmzWGKGWgwix/yrJbQ+kR8 NsuyFhJvmwVTlZEWOu5Clir61SrukYU1RaRH2Gzec8f2kWCrWfuDToTvq2eutWLIYAsQqpi 3e07wrvVHkxD+N9oOZfvQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:If9dX0RJ5mc=:Xdz3KYrHF7kP5L+IOxcMLC Pb0/zp+EzYp4t6rzHsJazEiFXf8nLDzvW6gtAeOB1i4N7GVz85cpqDIZmUzI6V5OywtE/kCuq 6E3HtFYFjo32tKJhwHtWO2S0IUUZ0SGVCnJLez4AZkVcZBwAUn/xdi0r2PM6XAHgd0ZvGjxRg 5Tsj0TIRu8L0EIVwAhyOQVWQB8HIDJiIw95wVW6J4DukmHzIAMnuqbdZR7XY7FiZVR5bpRqXr TdQ5X+mND6RJo/89mzGrx9hHToUZMrwj7eMkzf5K7/4TPk/7pdjQOJuhGmrMogD0Q7wgUusdD MC8ghIU7JfBzoBy3rPwG11or7X99kjjwpylNg+2dw0c/YFrha048/oB1lNZazL+rzyq/Q2Ruk T3POjNNbNlNZySr40UH6+FFOe4ha/mCFvuYf5tBZ6Cqi086sdkeL9pcpkScPyftW4mWqlzczq ++2wmgefj9ROf0KtJW7r/vebaASc+DfK37dAozTXMuE+Yq+Y7VN6CmwMmCQkj1JB2q6q0i7Md 112FxYEHsYKBmxKP/OeVjo= Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Now that we have exactly one call, it's easy to pass in env instead of passing in the sp value. Use target_save_altstack, which required env. Signed-off-by: Richard Henderson Message-Id: <20210426025334.1168495-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/qemu.h | 3 ++- linux-user/signal.c | 11 ++++------- linux-user/syscall.c | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) -- 2.31.1 diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 74e06e7121c5..3b0b6b75fe8f 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -432,7 +432,8 @@ int target_to_host_signal(int sig); int host_to_target_signal(int sig); long do_sigreturn(CPUArchState *env); long do_rt_sigreturn(CPUArchState *env); -abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp); +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, + CPUArchState *env); int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset); abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, abi_ulong unew_ctx, abi_long ctx_size); diff --git a/linux-user/signal.c b/linux-user/signal.c index 9daa89eac5db..2e1095055b7c 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -800,21 +800,18 @@ static void host_signal_handler(int host_signum, siginfo_t *info, /* do_sigaltstack() returns target values and errnos. */ /* compare linux/kernel/signal.c:do_sigaltstack() */ -abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp) +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, + CPUArchState *env) { target_stack_t oss, *uoss = NULL; abi_long ret = -TARGET_EFAULT; if (uoss_addr) { - TaskState *ts = (TaskState *)thread_cpu->opaque; - /* Verify writability now, but do not alter user memory yet. */ if (!lock_user_struct(VERIFY_WRITE, uoss, uoss_addr, 0)) { goto out; } - __put_user(ts->sigaltstack_used.ss_sp, &oss.ss_sp); - __put_user(ts->sigaltstack_used.ss_size, &oss.ss_size); - __put_user(sas_ss_flags(sp), &oss.ss_flags); + target_save_altstack(&oss, env); } if (uss_addr) { @@ -823,7 +820,7 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp) if (!lock_user_struct(VERIFY_READ, uss, uss_addr, 1)) { goto out; } - ret = target_restore_altstack(uss, sp); + ret = target_restore_altstack(uss, get_sp_from_cpustate(env)); if (ret) { goto out; } diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 95d79ddc437a..4d52b2cfe36d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11195,8 +11195,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } case TARGET_NR_sigaltstack: - return do_sigaltstack(arg1, arg2, - get_sp_from_cpustate((CPUArchState *)cpu_env)); + return do_sigaltstack(arg1, arg2, cpu_env); #ifdef CONFIG_SENDFILE #ifdef TARGET_NR_sendfile