From patchwork Fri Sep 24 16:59:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514605 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1691443jao; Fri, 24 Sep 2021 10:18:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxclKmAPheLydkvu6+NuBQcixpagluCuWGdfeEhbXcTCpriTKANI54YQYvhgou70Ls7VgjZ X-Received: by 2002:a05:622a:188d:: with SMTP id v13mr5395345qtc.294.1632503925388; Fri, 24 Sep 2021 10:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503925; cv=none; d=google.com; s=arc-20160816; b=swJW8WmD5rpIX3fWakgfzPXT+IbhuHWehfwTL8DS/+UzePF6U3KhiBZJr8WKmlwrNs kurDi9woq7MmW4Ylr2jkEa7jMfo4B6HK40AulCPnz03RWOA6xzqWUPbaOE79+F7uVhm9 guhjx+yxdheMU/15sXJ0uARiUHeh9pAYrHaWtKwBUEir0YKrs9aDNl29o5c5/ZeLShaB stv/YhI8vosDLiIgGWTTa5VtRGtFDGZJ0SqD+GMthED2yeDpKLtg058oV6y2msJbSCYg bZlA5gyaPgKDaD00UaG8Me0mXd9DJZLztUKFbXQpt1KWQVI1iOrdH3820ynh/KlMb3Je 2zkg== 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=vfrTFNcnbBzzKOHxWPIdq3+rOcfAx3GsGPWWiMrLDXBeKNUbaL5TASbGhQfLIPL6e7 ZLFXVD8MkR2mXXVbH5YIL7BcHx+6u/Z7AW6gpkyjxnzVm5pIG/ujVGpSH1/OZJoaunoY tg5pk9ayCPs4vPlXJr4VMysG0YyziL9RGqF+p7WnL1LUEsRSk3Y781QCWCpL4uOlUb3x DSi0Li2QTM73bS9u3o4LeAue7gAt3LIW+tPXRvN3XnQ46qHsJyWuyymwrVleCfbrmCzP ecxzh8fihj8NVSSW3WHxOlecSodKRFqH4hT4ZPJfsb/+uCEhcgXvmNB5BZ1U6B4P50rX VuFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TiEHkqLh; 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 fi16si6875617qvb.7.2021.09.24.10.18.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:18:45 -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=TiEHkqLh; 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]:48870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToqS-0003E6-O4 for patch@linaro.org; Fri, 24 Sep 2021 13:18:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY7-0002p9-IW for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:40664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY3-00072D-IJ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: by mail-qk1-x734.google.com with SMTP id 72so28625264qkk.7 for ; Fri, 24 Sep 2021 09:59:42 -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=TiEHkqLhCxqVrpRpuynLDSiG61R6O8JsvscC0KYwWWQmsnqu3bR4A4c2xfB1jIz8PO 90jU/0nfyp2AlupK8D8pU7k8QvcSKFks8sed1hFwiKniQOQLZPGd2bRqknXQ8cBHY1lT jODWivjgjAZSNobY0iEEvs5XUHlsuubmvzyTshdtduJekVQRwGokoO2V0rW0wx6CnafV YWWiq651InGZxuKXaPMh1zJH1NPcRAZuYOyHLKJ5N6wtQjcWBQxkXvx50cOdGqSdhKTZ +uKTnUS0HpRS2mWhhPbSilrFFw32n6Gap+jjxo0WoKkflhDd6rIfpcJH4hQmLFWuxcc7 +sVg== 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=YEiZpevQ+aDfAz8KwSgLc4EWKUo/KU8vECz1iSe3GE1xNfTwAZKhdYEYEyHgJeX6ky obkU7xBgw8PiDAw+c2oYQIHMZfs3FCZ4T1BTjLNjhAGvrARA1kz/ED5gpHhSE+/EMB+r Rf7N+tojeJTl+CkjexTtWwqqJUHFk1ZgyzDYvQzL6blcvoBoMghdxbkBZPGuvPnb5Ggk h1M+kcIXcUpeVeZFcJmeIkSiSkPq6aWdaEu7vbbnbgT5Usj6tPn0FBZeWyVj55OmHBOJ FEIWJE2xLUauHa7VUz39G3dSuLc+dJG9VG+GJb7JdefAkX7t/7sS9mBRIItwqXmTNshP m7GA== X-Gm-Message-State: AOAM5330btFeo0kweTbmHSECnPMOmb+QrBWWrmOAbpsnJao4wzxhKoog emLpZhV9e1hC49Nxaf9UdULxOExRL7AkuA== X-Received: by 2002:a37:ae83:: with SMTP id x125mr11855501qke.37.1632502782447; Fri, 24 Sep 2021 09:59:42 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/27] linux-user/openrisc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:18 -0400 Message-Id: <20210924165926.752809-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.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: peter.maydell@linaro.org, Stafford Horne , 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); +}