From patchwork Wed Jun 16 01:11:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 461316 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp99911jae; Tue, 15 Jun 2021 18:20:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF+ptob/8gWo9LIYjW5e+oJBc0Bpc5ogUYUFZPjU05QXEScv8fTjyB+i913JqmMOapP5sU X-Received: by 2002:a05:620a:1182:: with SMTP id b2mr2544353qkk.408.1623806437084; Tue, 15 Jun 2021 18:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623806437; cv=none; d=google.com; s=arc-20160816; b=b0rZPNfqYlucDvXydctheJL04kTSur5GUW9xVYqGKbOLwGwvhlMYMzNndj0cXJw1JV bPRkKaXQldO/FgeSW+GZFz5p77R7HcgBHmbmgQAS0oeIaY2gBSkmaBLrZl5kKtugewZN sSqFxQMFteMQk/Bw8pjrr5rNWhyXXzoWZoSLzBUs3+j749nPtzaX0SLXZt7wu07he7jo kWdUttc1ijTk8D8ZqJ8BEOOQFit6yv0e6YeHZh2jlKOdhK3TdGUAFuOnT5oAcK6gfnao 3G2ovIJloM53k8uUYHqyU5l4HemwwDs/xTJKvJu77FrSVY6JWV5+j5Y5BGWKkMPIL+hG nZqQ== 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=KFW3jyEgxroFTOmj54q2vXSb8LZmHdRxtn8eHcREl60=; b=TBe6JominJzdxtt8cv0H9WbmNExa4BHa0RgMxk8rG/YbfdVSnvqj0X+0/aY+GYCFtq hJwk/rnQc0XsHvtxJH+eszOcIZAHMkB6Mn7M5e80x9LZTmYzL9NMZm1DZoef6LVkJxyX uZOQjHINfE1n+D0Aa829ffJyicfYZOWp/76Y0Bk2GjMRPZMamEbl44CDGY/7LBy3S5bT TOonXLgdg6obRQzTNBaJh5y0+QSP+cQxg5qndmdOmGF7d10Hq8t2NBVn7bzH71Tt6DJ1 8dKYmSK3KuQZnSqJGMkZK+gWmNMqI0IUhVUQR+AIL1FwkxP61A0LWDnyZ2rhYTfXKVOC dzsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vxLryv0K; 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 h19si506247qtn.294.2021.06.15.18.20.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jun 2021 18:20:37 -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=vxLryv0K; 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]:55754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltKEO-0003hO-6t for patch@linaro.org; Tue, 15 Jun 2021 21:20:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltK6O-0005KC-V3 for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:20 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:40541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltK6J-0008NE-6l for qemu-devel@nongnu.org; Tue, 15 Jun 2021 21:12:20 -0400 Received: by mail-pg1-x52c.google.com with SMTP id m2so573569pgk.7 for ; Tue, 15 Jun 2021 18:12:14 -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=KFW3jyEgxroFTOmj54q2vXSb8LZmHdRxtn8eHcREl60=; b=vxLryv0Kz9lxKcRRqFSZry7VfZ6qXzuAkq3pZWl4QDFJdeASI8S44E3Ay3bsOD+ezz KpOzVz49ldM9WFfJwo1/PtXdoSNOpndVw6w3ydBB+YYU2iIyBMNbmaIw2jalzJURCTPh 64KlpEDwJlIFSER6M6RhsCcaTZJuSDzc4OFXfNoneGI0yyiGSmw17cv1au/RjZcSYRqe dmafpt2XPhr2u/6083d7zJINMae0g8YZnyqXXK9j6waNZxzaqU4z/zZM0uINffFqDLHn 8xXfonZjMB1dTMlxiaNI8tpndQXyFgu3Rw++NdjjOtNkEnPRaMFhXE9eMwtNZ7Tzq5cR /4DA== 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=KFW3jyEgxroFTOmj54q2vXSb8LZmHdRxtn8eHcREl60=; b=T3IqCnk5YX9unKVVIy2igPuXSmYuy8QOxdhvpTUnYcHnM3tNJYpl3llFB1yLxBv5Wi qBNjr4pZ6f9WBCfqHqjY65bhJ49nO4GR6ChUseLJICEEtnKr4usmxJbZtVGxRSx1jA6X SPNOzRUyf4cJZ6DJo05UmT5mDVccurUwn1zuQX5lhQcnnhMefuIN9KOyQh7oS2yy0gcG Tl7EL5KH0I3UVNfBQfuSFH4E0eabGjQ3pTWB5peGRuS4+f9hQU8vr323CRrGEk95v1Qk EWi78Dkzlo8bU2EGglATThGGNa1auKZDBjiyX3ME4WnGMxliMGvz4RFS42zyo4hQWPwI OoNQ== X-Gm-Message-State: AOAM530bM6AJ8D/zLRP3Ly+C5zFwJoCryg8gm4taPcqUd+e9OmR2eQHY q7UXJQMYHGqLjofe2j9d5xNoc8QSYae4dg== X-Received: by 2002:a63:514f:: with SMTP id r15mr2293061pgl.374.1623805933892; Tue, 15 Jun 2021 18:12:13 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 18:12:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 05/21] linux-user/alpha: Implement setup_sigtramp Date: Tue, 15 Jun 2021 18:11:53 -0700 Message-Id: <20210616011209.1446045-6-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::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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 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 ka_restorer. Signed-off-by: Richard Henderson --- linux-user/alpha/target_signal.h | 1 + linux-user/alpha/signal.c | 34 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index 250642913e..0b6a39de65 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -93,6 +93,7 @@ typedef struct target_sigaltstack { #define TARGET_ARCH_HAS_SETUP_FRAME #define TARGET_ARCH_HAS_KA_RESTORER +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 1129ffeea1..e15f5438c3 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -54,13 +54,11 @@ struct target_ucontext { struct target_sigframe { struct target_sigcontext sc; - unsigned int retcode[3]; }; struct target_rt_sigframe { target_siginfo_t info; struct target_ucontext uc; - unsigned int retcode[3]; }; #define INSN_MOV_R30_R16 0x47fe0410 @@ -141,12 +139,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb() */ - r26 = frame_addr + offsetof(struct target_sigframe, retcode); + r26 = default_sigreturn; } unlock_user_struct(frame, frame_addr, 1); @@ -195,12 +188,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb(); */ - r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode); + r26 = default_rt_sigreturn; } if (err) { @@ -268,3 +256,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6 * 4, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(INSN_MOV_R30_R16, &tramp[0]); + __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, &tramp[1]); + __put_user(INSN_CALLSYS, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 3 * 4; + __put_user(INSN_MOV_R30_R16, &tramp[3]); + __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, &tramp[4]); + __put_user(INSN_CALLSYS, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 6 * 4); +}