From patchwork Wed Sep 29 13:05:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514845 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:4087:0:0:0:0 with SMTP id m7csp25109jam; Wed, 29 Sep 2021 06:27:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrEsg1QdbglYGrynCC3RGVoHdgLylPy1bJihdvtDXNweKk6W/4pPVGgakoWFRLdXsSu+lH X-Received: by 2002:a05:6102:1d2:: with SMTP id s18mr10513279vsq.42.1632922030105; Wed, 29 Sep 2021 06:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632922030; cv=none; d=google.com; s=arc-20160816; b=gYDABSeKrXkl+ZdZR3K1CDUCNh3D3EPDDrLP3KG24eHX3aLqaOcllvdmun19FYFEHa 6p5lhwHYs3HnJ+ITWPKcBresjRCmLJzw7C2rlKSbPpnRqsXoNBIMBEaZNG9T81q+dcwZ dItYkmOfCNRmxaMAyRXW1waxGtfQoPuVn3QEK/rrBxXJ20nqoRlCaw5TVtlGR+HG28vG nAMaAmgASBMS1neR6Wb5TFR9ToBigGbYwrRvdUI+SxG5zXOPdmB+ev5dI54O2CcKlZG9 DL8ft7P0qgqQyx0jDgYpRqBuNzbJllDvSfx+B3FSSV83F36V/cqBdCtv6f3fGdEw78K4 N74A== 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 :dkim-signature; bh=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=lR9LORGJLMQucJvaD6O2yRiex/Mpk7VKVN4Igim+vXVAXI5tR6SYe1gPcU9prI94yW oB3lMRz72pqpuAujsetqEJPmk+dXY07Day7s4eeTmHS7y5oJ8ONeLSSQM6/Gg2A40o14 DtE0IoL666FNJJ50QppaabfNn2jNDO2/fl358euwVws5mJNZ2Y9zZkhBz8zD1u6/5Z2N y3W1MTGCN6kWrLw9YXgvf8+vbGnoFRm7qIyPqKo0muG39n4o5hBz0E5xX94u/o8Yi+7f rq73LM5DfdhXvKAHUiijvSOt0KRIrz1fKvrtweFWjq3RmFreTK2uQaNSbIvpXaUxJvhO uUiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=s+cOxUgJ; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a10si1980859vsn.228.2021.09.29.06.27.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Sep 2021 06:27:10 -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; dkim=fail header.i=@linaro.org header.s=google header.b=s+cOxUgJ; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVZc5-0003tW-Hu for patch@linaro.org; Wed, 29 Sep 2021 09:27:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVZIG-0007JH-RO for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:40 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]:37626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVZIB-0006Km-RI for qemu-devel@nongnu.org; Wed, 29 Sep 2021 09:06:40 -0400 Received: by mail-oi1-x235.google.com with SMTP id w206so2798524oiw.4 for ; Wed, 29 Sep 2021 06:06:35 -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=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=s+cOxUgJhxJSEd+iF3RaesX37YvNz8xAhey40RQsAsSlLGaHowBZzizB8pHC/9d6YA jrubxV+GiFuYd/4nXt12fkdxZ4HVhUl8chB8uLfXj7y3Bsqt0ChNudEr3xK+E2plr0Mx fjpJv5BdqBwjI/5SaNgmPtal9/i4WSZla54xrep7Qd71yDIV9LVD8HhMfjrkgnoAdwbk ONtmY1MPlxRSdVKolFxE5lVrHTJjhJsDVnJ3bXXeWwvceeCdURYTZhRCVVP3YQ1dq0mV dEVH5jnhHzTIdG04B2hgsjwkWYFeXkeqEld4+IrxQ+2sIt/P61q9d2V7OlPbuGu7GmnF kXgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=TDZM+piDN0qwq735TEKqTbK+anL46PeG+NT7Ua3WLlSwMXuaMLCI40rgc6DhC5f/N+ cNVjql2BKgs4YXs6uDLJ6zFAiN+VsQrghBVV3Hn3mG6u8NNems8R9k1nnC1RK1S6fFmb i62OU6qO+TOW6QC9v7weelAcMMbfx+02En4HIBXUIXhy0Bf8XQcCHNXIEnXWPjlPDgiw Fsj5SzpnnelnuZwbH0eG8i01O6Yyijpu0DSVy1095aU4Q2XZt3xvXcnZy0BhYjZTSlm9 oXW/FWT8ucINB4czsCcl9Rf6awt/XaDAeve1sNk6Gl/BYtpvekjhJsxzVh0+kZSiayja bSxg== X-Gm-Message-State: AOAM530AMgPo1xQbxcJeYrsaHxcmqZpQg/L2SFeCsVC3iNvstvbu55eG WVf83NTqLU6O1e0c82c8OBW70Soa7pVWOA== X-Received: by 2002:aca:de8a:: with SMTP id v132mr8008094oig.61.1632920794631; Wed, 29 Sep 2021 06:06:34 -0700 (PDT) Received: from localhost.localdomain ([172.58.171.248]) by smtp.gmail.com with ESMTPSA id w1sm442823ote.41.2021.09.29.06.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 06:06:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 17/26] linux-user/openrisc: Implement setup_sigtramp Date: Wed, 29 Sep 2021 09:05:44 -0400 Message-Id: <20210929130553.121567-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210929130553.121567-1-richard.henderson@linaro.org> References: <20210929130553.121567-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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: Stafford Horne , alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/openrisc/target_signal.h | 2 ++ linux-user/openrisc/signal.c | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/target_signal.h index 8283eaf544..077ec3d5e8 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -26,4 +26,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* OPENRISC_TARGET_SIGNAL_H */ diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index ca2532bf50..be8b68784a 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -38,7 +38,6 @@ typedef struct target_ucontext { typedef struct target_rt_sigframe { struct target_siginfo info; target_ucontext uc; - uint32_t retcode[4]; /* trampoline code */ } target_rt_sigframe; static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *sc) @@ -116,14 +115,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } - /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */ - __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, frame->retcode + 0); - __put_user(0x20000001, frame->retcode + 1); - __put_user(0x15000000, frame->retcode + 2); - __put_user(0x15000000, frame->retcode + 3); - /* Set up registers for signal handler */ - cpu_set_gpr(env, 9, frame_addr + offsetof(target_rt_sigframe, retcode)); + cpu_set_gpr(env, 9, default_rt_sigreturn); cpu_set_gpr(env, 3, sig); cpu_set_gpr(env, 4, frame_addr + offsetof(target_rt_sigframe, info)); cpu_set_gpr(env, 5, frame_addr + offsetof(target_rt_sigframe, uc)); @@ -169,3 +162,16 @@ long do_rt_sigreturn(CPUOpenRISCState *env) force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1 */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0); + __put_user(0x20000001, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +}