From patchwork Wed Jun 16 01:12:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461327 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp105804jae; Tue, 15 Jun 2021 18:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeMiPO65lHleKgM5Oqoj1AiwqcuFmn/D/ddIu+USjga8AhmUSX+9FN2Il0qkbb8toae6PC X-Received: by 2002:a37:b6c4:: with SMTP id g187mr2642842qkf.491.1623807059646; Tue, 15 Jun 2021 18:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623807059; cv=none; d=google.com; s=arc-20160816; b=Cp23roKbgPp3QWik0yONCD0tLPLR5WmDW1eXvWwbkCVq5co7Mfk5wM7McrVmh6v7nV PA5f4ZZzqUDwzGfATbZOHW6HOGm3CE2sk9nJF6b1jTaR58qXjBXd52Gv+8KjPamJCCi5 i7FLqYYb1BcFXqxNHK4l7Gh9/Dj9EhMwf0pM/ev8FPRPTLBJ5k4gLMSbsB1HEoCmG/f2 sq5Ou6PUh0TvcEpG85mSShH3MyFzUbR3x2BshQ9LKdawo55gfgx5NONHAJDeP8BQYYM4 fNoOIsQ0CX/tCAc2xtnDKPzVBLWQ0+wYn/ItrYGp225y3M8oyu7xDFf+oxbDMdAKEEOw qDYQ== 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=gmXhcVzm0Mn9qra3UUrV4KJ0gXBFFg35s1ELoxfM9Zo=; b=VmY3hSlDqGIWvulOqHd/vaYmRamutrElh0ANecpMNvvBU9yLYK+a9+qHzfeuMpWpK5 //82YClT6YoYL9QIxgzxeNKnJdzdpgf2zZLvG+YuDnkZ5ecnBh0ydD9+THy/tx8H+Eb7 sNVej18ZoakH5HVQ31D8lafxJxldIYaRwAGTm4TP1N/Ffte5hGaa/0R6WyekpBAWIe8Y qToECMjWTsfOq0xSYJjom0qCuZsDWI+EISB8N57lSd9/iSwQ9v/eMcjGQj8kxGDT1OPo F+vY+AA9vg6iSuLbUQtP4D931txbtH2M4uu2J/Ye9EEyWQVz/0A9KiGJlbCd43nnGTtW Df6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bg5J7xyu; 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 w23si555597qto.128.2021.06.15.18.30.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:30:59 -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=Bg5J7xyu; 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]:33574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKOQ-0001ro-Vx for patch@linaro.org; Tue, 15 Jun 2021 21:30:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6e-0005fu-4c for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:36 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:40949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6R-0008UD-Hu for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:33 -0400 Received: by mail-pl1-x636.google.com with SMTP id e7so259813plj.7 for ; Tue, 15 Jun 2021 18:12:23 -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=gmXhcVzm0Mn9qra3UUrV4KJ0gXBFFg35s1ELoxfM9Zo=; b=Bg5J7xyu7UhebMUdPbm+bab9HhIKGCcokiHNF4HgWZpVmus1tvnWxma6kUaIHATmlx k3cRyTUG+ATTxla+uP7yT/ljqcuvjXArtEyq6ngwxboe1LH8wum7jrguUzmgMseBrqvb 8wW4jGcLivVUOXTD5cLT9KYIDo5Uus/I1c9+wGWK5hKYgAvd/NGlQw7KJWHPLY2XAwWQ oWXwGxoim91l16XAVoZcKUn1+LP0/b9S1rHiIQ3bo8pktFm4+k5M6+pVKYxiHomMtW9L If8sqVPz/y0hHET11CeNVwQVjSeGuoY6LTYhnuwycqVlaDjAAoHBcwXso5h/a4gRzzkq yjIg== 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=gmXhcVzm0Mn9qra3UUrV4KJ0gXBFFg35s1ELoxfM9Zo=; b=qMPy02IR+RbZI8vwq681g4quGqNEZPMlK8EQtpogCejJMMrbmtYsDbsemh3njAB3Gt A4kO7FsQCoFTn3zSCBGBY3B8+eh8jhay0uhDxKmnjBlSNfT68OO31u3/1Po9+um56pNw QNSloBqqtZ2+u1m7HRoA7/W5ByyY9/jbnshlz6yalQ5lgNS6yfQQVLVQxmH+AaqAI6jT iKMpB/Yg9GvD7pqDu2U/S6vaCsGtPdNMKHmycSssFzpR+qU2AYWeLOqgxkGvhqI9kbfY 9LXzanGUVNpwAXKTxFv2AuQdzAEbu6LEjq1g+GctlToE+tRVL0RrecxcMhWiOhaRjR1L waYg== X-Gm-Message-State: AOAM531MCtv10/Bi9ScjzyufYq6s+b89V+F1AmVLhd+AuVole4fWUkfV j8DSoV2bOVK+9tfqUFogzchQbpRT9VnC6A== X-Received: by 2002:a17:902:8bca:b029:11d:b5c0:5677 with SMTP id r10-20020a1709028bcab029011db5c05677mr4826490plo.11.1623805942138; Tue, 15 Jun 2021 18:12:22 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id y18sm305297pgk.53.2021.06.15.18.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 18/21] linux-user/sh4: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:12:06 -0700 Message-Id: <20210616011209.1446045-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210616011209.1446045-1-richard.henderson@linaro.org> References: <20210616011209.1446045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: alex.bennee@linaro.org, laurent@vivier.eu, Yoshinori Sato 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 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 Reviewed-by: Philippe Mathieu-Daudé 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 0451e65806..5a5ae69785 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -51,7 +51,6 @@ struct target_sigframe { struct target_sigcontext sc; target_ulong extramask[TARGET_NSIG_WORDS-1]; - uint16_t retcode[3]; }; @@ -67,7 +66,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; @@ -189,15 +187,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 */ @@ -247,15 +239,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 */ @@ -333,3 +319,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); +}