From patchwork Tue Jul 6 23:49: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: 470635 Delivered-To: patch@linaro.org Received: by 2002:a17:906:971a:0:0:0:0 with SMTP id k26csp5553578ejx; Tue, 6 Jul 2021 17:05:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM0Dfk+D8Wo+rsCAW4vy1vILIA6VNVe1K8UWLq26INsa9Nfzyf/bLV+nq6WhpV/Rg/F5Va X-Received: by 2002:a67:3c2:: with SMTP id 185mr17850861vsd.42.1625616324550; Tue, 06 Jul 2021 17:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625616324; cv=none; d=google.com; s=arc-20160816; b=Bw2uHm/V09mv/CmUoZM6k3t+bFIer18m7GDMbbKbbgEcG1idgUcm8RdNWJ1A1y0sYM CvqnyYOPIS3/nmECGZtxCW+VhYHbBBKgOmYTbDFm2/S2KWQCLpkFZ5rggNLk8dj5WMqG UYZTv4vTXrIYzenaAKj0YKFtT6f0a9CBRFcUx25ELG4C6Qxz9Vp/33G195U1lP/ezaFh Wjubz9/RhBhbGi/mzqwH6SyBkivsKAAJFHjuFaIFT+VV7NkjhXPYQLE50XycSY1fTQOq aZPPlB1L5Tl1rWDa6/y+DCD24R8tOR+iOxEDcKUVsAUTHolETl/7QTXrGVgWOtxAg3gH lQXA== 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=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=N2RznWWsmMvYCL994Bbg+cBJTvUIInWCe9wgdfu6ioXZvX4dlWNE+EvwYz5cWGUhyv g2WRZ+KjmzBt+qDssLt35yj29KtOtOpFFmpwKYKn9hKNjyMGmsto9IkYl6ZcgWIf1B90 nrMSXbThmgEdsvkV/9zX+3MBbBXRvWmPRzftKCR/ltIzO+s+YzW6pyflL5ebKvvR1Qfp pst1N+UE6FsQFf0JnagcXEFtERRux8NMVXcQB5VDGOHklxSVWdH16TH5tW9NE8MnkC7m NqUO4RKjZZt2MSrK/PjWrWXOA9B5lTvsibEWIO3qpi2fxvvyXGlm1pjou5/ce45UPMrX 6bfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TFNBtg86; 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 az4si12328779uab.19.2021.07.06.17.05.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jul 2021 17:05:24 -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=TFNBtg86; 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]:60692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0v47-0002Q5-Qc for patch@linaro.org; Tue, 06 Jul 2021 20:05:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0upG-0001mI-Tl for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:50:02 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:40452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0up7-0006gP-7T for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:50:02 -0400 Received: by mail-pg1-x533.google.com with SMTP id g22so399135pgl.7 for ; Tue, 06 Jul 2021 16:49:52 -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=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=TFNBtg86qS1CVcMbXGlRXDk0HHqQt2YFPq6a0dc9Yc/kfhPnKBoEaBTy4YoiNxcsbD +sSgGerxVuMEAQXacAgwp3kjtdT83XorCB89ogiykghFrjlvIG9u+4sGKIVRNBg1KB7n 4QocVDldj6vR9Fc7JUd+TUxliPq5OgKqaf6yg3DaTOkbYZGAqhjVk59Y2b1E3cJcCbro 3fGv8qRRQYmkNbnlTuKiVrPQejDNYHQ/eqrVlM/TqOZ6edxTvsFFwo8Unp1fTK/mKbWQ J9HM3MbdQGTYgzSGq0lzcIosSUwmEOAr2aQwFzI9CwV3vby4W+sM4hj8xS9MsTmp5c81 3wsw== 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=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=CI2kJHaw1OjTelvbjDNnqaw+tQoWPsB1N4IkzyypWWSUi5jsq0jdZrCcMzclT/Hpcx 7k7bw9AsBCyQUexbJcdDNz18TFstzl6sHcRXZpWsnlROw/1ycibYH6CV4V0JAMflxwcK EPu63QQ7HF4WHRTxwvdpak+DU+H0ojHnxpYTI1rSOLW6tnXCACH7/PJYo0R6exx1cULm su//53ULH3lZttf719PfApl/2obnIhXfgiw60saxz5IxUlT1oU35dziByJ71USSUF2+8 3p/QVzJbXGbekMC9EY7jpk5yAxRnEwADfBbl9eIQg33Ubj1NoWIPaSjPzp4do3ahzmAr KrbQ== X-Gm-Message-State: AOAM531Nqt6L2aFlMQ+0Tw4end65gVrj4B0jkiuLFWyo4+7wYCWIvLdG lKdPxSeVyVhdkHwvAPPNJu5tzXb0XBDW4Q== X-Received: by 2002:aa7:8d86:0:b029:2ec:82d2:5805 with SMTP id i6-20020aa78d860000b02902ec82d25805mr22659605pfr.11.1625615391986; Tue, 06 Jul 2021 16:49:51 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id b3sm18058114pfi.179.2021.07.06.16.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 16:49:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 29/36] linux-user/openrisc: Implement setup_sigtramp Date: Tue, 6 Jul 2021 16:49:25 -0700 Message-Id: <20210706234932.356913-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210706234932.356913-1-richard.henderson@linaro.org> References: <20210706234932.356913-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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: 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 | 24 ++++++++++++++++-------- 2 files changed, 18 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 5c5640a284..b411b01864 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -37,7 +37,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) @@ -115,14 +114,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)); @@ -168,3 +161,18 @@ 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, 4 * 4, 0); + assert(tramp != NULL); + + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0); + __put_user(0x20000001, tramp + 1); + __put_user(0x15000000, tramp + 2); + __put_user(0x15000000, tramp + 3); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 4 * 4); +}