From patchwork Fri Sep 24 16:59: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: 514608 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1698732jao; Fri, 24 Sep 2021 10:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9NlAttKf/3+P2uPvptbqQhU7OjYWCSDHLRKP91o8WmEasASUXTDBm/UZ3kYY6uJbbvnCt X-Received: by 2002:a37:8e07:: with SMTP id q7mr2578023qkd.287.1632504393656; Fri, 24 Sep 2021 10:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632504393; cv=none; d=google.com; s=arc-20160816; b=WumPPbnZkGQRgLxlebktIIG33I9eZICAN0RTyH/jeewRclQoD4BmJ4kMOVNNh7JgRa wzRZ5MBRc6ntW4eRQT2ZlM0t5cSxrUkdIhxhw5fXGmfwK5ks0XAko4X4vDyG5R40qNWg gtBlLefmnLycsaH/8zJ66Hq2uqf4JzTKNP5VGc2caesTfjQ7yu448PoRKeB3E623dKup N6ho4goEaEpPWDcfhGDIrAgyBRGKyEeA14Wdd9j11LYKg299rPwMJ9X8nox35cDawvf9 KLy5aNblkcRN0zzt4Ey2w1fTn9ftTOQ0/6y1XknqxuEXdOaH0Krhf2MhKX/R4zm7uXcb sszw== 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=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=i0RLYll53/bPmDu1xgc+S8CnnnxSf1nKzpzdcHlqpVSrI09RKHWNVOTs08l9e+znAO Rvyt8JklPp3pHMqQcKXLngH8vYJOgypo6Bg5fqrRoBva21Ow7FdpVvSayD4PjYz9qr9Z 1ASt2FRqy9aIo13ABVl8CrVNOb0Etm2Y36lxKxBvDT5PyXDcwW+qoOwboCf+7uer6Qir rB8m4mPJRWOK+ynaplDy1stfDUPYsd+O3u/0cBjnDbbyo19jkvWtjkbHjD/TwU1X4F2p dizAPoIoTvkKzaHVcEJ2e7TXGepqMEA/ZGy+sVMawaYYpSfxGDPXLSKiajVqwUQ9ZT2D ZhEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JTHRst3l; 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 v4si5571730qvk.149.2021.09.24.10.26.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:26:33 -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=JTHRst3l; 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]:34246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToy1-00042W-2o for patch@linaro.org; Fri, 24 Sep 2021 13:26:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-0002zM-4h for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:38829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY7-00075I-C6 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: by mail-qk1-x730.google.com with SMTP id q81so25090075qke.5 for ; Fri, 24 Sep 2021 09:59:47 -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=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=JTHRst3ll0y8WPA4QcJr76vLZXA6cp1hCJovcLAHi1ezcjj2KEIYIGz7r2q2CXZfEm JX4HYvhh0QkLZ1RL7G1GLkK0lSAjmQk4GJOpZCdRmYq4mnW/VBxys9jqTesgm0WghZ1l Hrh9XpfMD++3SbDLSno2qAR4jS2RhQvCrATQnGaLYTMH3HM0kDnJZLO5p9zU95OYgsVv VSmikbFljlQHPbpomEeimENVENfYhnOZL+gHawOKjKEDj+IpiPZxsw2b036FoSm1+icd BnADbM0hfKjrlOuG7lNRhJqt0wL4mbcop1tWod3EOC/AHaGZR6koShb6WIjL8Yg6O7Kg 1Www== 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=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=QnZAHEowDfvItSDERIZFABDQeuoYUBqOvsGVpJnYaNvqEmC6RCoQtS8SNJXjshEEvG XkuY+/qjoyRxRIjNPdl2hD24gq7r6rD5RKj/iTOKJpub7VBvpSv0qu3TvXesIeuVNYTa F2mqRZJqtRvIee9tFqgrQNpu6jH3xK7MPR53DtBMiOThZDMDHLjzQUzzdvhQxAcFJ+9O ar3lbPGlAkpQ6PV9ZMRRdJ4QRkjgxjjJ2xL1f69Y2WvslX2fFid1Kq9zD2uzon2GjEcM X0dq4ACqh89j3uPyWS08yfUbgCoZrKxZrg+P90h059Np5WIdqNQjSBMCzPoJkQ7dvrsn F2Dw== X-Gm-Message-State: AOAM533Ppe1QOPW6n+GNWXzGiXBuRnUwWBw/nd3YcFP/vTA/r2taYFsS e/4jT8RUGvBr9Kz7f90KTzjf3mQ9HQdwDQ== X-Received: by 2002:a37:b703:: with SMTP id h3mr11871098qkf.240.1632502786453; Fri, 24 Sep 2021 09:59:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 24/27] linux-user/sh4: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:23 -0400 Message-Id: <20210924165926.752809-25-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::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.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, laurent@vivier.eu, Yoshinori Sato , =?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 two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Yoshinori Sato Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/sh4/target_signal.h | 2 ++ linux-user/sh4/signal.c | 40 +++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) -- 2.25.1 diff --git a/linux-user/sh4/target_signal.h b/linux-user/sh4/target_signal.h index d7309b7136..04069cba66 100644 --- a/linux-user/sh4/target_signal.h +++ b/linux-user/sh4/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* SH4_TARGET_SIGNAL_H */ diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index d70d744bef..faa869fb19 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -52,7 +52,6 @@ struct target_sigframe { struct target_sigcontext sc; target_ulong extramask[TARGET_NSIG_WORDS-1]; - uint16_t retcode[3]; }; @@ -68,7 +67,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; @@ -190,15 +188,9 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_sigreturn; } /* Set up registers for signal handler */ @@ -248,15 +240,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_rt_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_rt_sigreturn; } /* Set up registers for signal handler */ @@ -334,3 +320,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(MOVW(2), &tramp[0]); + __put_user(TRAP_NOARG, &tramp[1]); + __put_user(TARGET_NR_sigreturn, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 6; + __put_user(MOVW(2), &tramp[3]); + __put_user(TRAP_NOARG, &tramp[4]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 2 * 6); +}