From patchwork Tue Jul 6 23:49:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 470638 Delivered-To: patch@linaro.org Received: by 2002:a17:906:971a:0:0:0:0 with SMTP id k26csp5554018ejx; Tue, 6 Jul 2021 17:06:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwljkdnodj6qQqcP2fT4t8LOAdlYSXy8A+ljMti6Uh/JIj6ShHS1kMulNdt/Ag4DUvdpQlU X-Received: by 2002:a05:6402:28b6:: with SMTP id eg54mr448826edb.216.1625616363122; Tue, 06 Jul 2021 17:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625616363; cv=none; d=google.com; s=arc-20160816; b=TT8wbDSgR3pMIB5qVNE0YRYErFBcuAL7dgOZ2i8zJSzt3iCqzVfIYWkEFhNwsaSaCY gLGZlztRI1CWFgUOwbCc8XGcgA5b7Ow05YEAYbisxEdC82zcoIJilTAWJpnxvz2wsuSo BuxzlXPQZees5JL+R9FN6Qv+drpg+Az/SltTb7pIIYHVn6Ti//g8cQPGfX4Mf6n8eXTp yVeKFBgxXqylfODRVe9mw5dwpOr8oE/qTJ4bBOWpoBntX4C0AB6vzeSdvobdDase2q6i wXEBcYpch30n9eM/5PXfIvlewQcYA58XOu/JXb7+6AqUIDAqBb+neBAO5J5N5+koWicN LGag== 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=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=E3asyaTYwSxtHlSA2LJkTOstUYkJOxLUkUBec0HFQKilo5YyRxz67Dj5AuSkK3NZBu fwmDf+kpyHNc93vpCZW7FZ0Tx3KzND7YC2vjpelKEmj/M+LKj0DeayiapAf5wQbIEFDz PM71N87AC7VzdVLVZgYC3AVwUYkJSq2gVNuE+pCdeG+KUH9KKLd7DOdLElcoW9NJ6NCm X96tMWNIVfJLGIkhm8N99LsQRtpOEsuJkcR+eBXFZ1F7U1d2r0dVL/PzDzWESxT1GrnC p0l0w+TygC5VQ13w/cDaVllLsqeutXz/LQwe9Kz0+PDO3ZwYXGWpCPU9bMR9YcDU/mup xZNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QZHdIJQI; 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 hs36si7271503ejc.198.2021.07.06.17.06.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jul 2021 17:06:03 -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=QZHdIJQI; 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]:34606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0v4j-0003pO-Tm for patch@linaro.org; Tue, 06 Jul 2021 20:06:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0upK-0001py-SQ for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:50:08 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:36632) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0up4-0006fc-8O for qemu-devel@nongnu.org; Tue, 06 Jul 2021 19:50:06 -0400 Received: by mail-pg1-x532.google.com with SMTP id f5so415521pgv.3 for ; Tue, 06 Jul 2021 16:49:49 -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=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=QZHdIJQILNoCgXECf2yblJwbu0a0J8/Rp9LCPm/VoKRj9Jt+Ldwdt0oFJw6JVPVM/O wwekA/tq1OS1vFg12DWROVSZs/8gDyHxDE27NmW5zy+m7iLmHsPVUa8/zgR2AtopsPRb qzGUrNMHuV3fPV+4yx0McXMESn6tJNZgZJ3vjXExMZKC4W0KzXglQdD4AuCI6YRy7DGc 8vkrX2eNiFCpiTynU5+m9HWuKENUm3GfNVIdUQa9AuvFv5Vz5EAAnrbhFJmn0+iy5dSj g8ZSJ1lZFq05yielQmepB1KXHSYnnZyYlgBcFlHyFLrgPnImX1OtwWxRX+Y8nhRqY7jh s5Lg== 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=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=N3rXOeuNlCu2XkqxcGjRUhfTXxkjgpmYYYevR2F2m3I7RSyzcUWrbx3CxdkgHyAnX3 wG6R9rSUcPIAOlE90qWK3C0jJi9h7K5o1mlhgiMgxTgnAiFYjwCnHwlPMbVlVrlNjgv2 Bwd6orbLO+nLB2dUgd86RyqUzyyU0uUpk8m5gG/YZnMf+Xspeyrhw7pDQA+nhUAlBeBx oV0P3dsj/hhRAoaJ/tYWbE8+FBiJVBNV0t+yvFRjnSIw49GwT2yyELDfOKLcPRq3aVG0 fsXiate0PKqnBHba45GS1Y0BjKxzCzOSr5LP00FOfd8OEDepX+IOxUlmGdIzwfoIa/Pu PHng== X-Gm-Message-State: AOAM533dWiJxKh3Qq+0GNzZfoGJdKc2ty8dkEDCCKKolPV4sgh8Fp4l8 vrd1KWYuZVWIHcK7RGrRPNr+7/JvFNiAbw== X-Received: by 2002:a63:e316:: with SMTP id f22mr23117740pgh.100.1625615389016; Tue, 06 Jul 2021 16:49:49 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id b3sm18058114pfi.179.2021.07.06.16.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 16:49:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 24/36] linux-user/m68k: Implement setup_sigtramp Date: Tue, 6 Jul 2021 16:49:20 -0700 Message-Id: <20210706234932.356913-25-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::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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, =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/m68k/target_signal.h | 2 ++ linux-user/m68k/signal.c | 47 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) -- 2.25.1 diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signal.h index d096544ef8..94157bf1f4 100644 --- a/linux-user/m68k/target_signal.h +++ b/linux-user/m68k/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 /* M68K_TARGET_SIGNAL_H */ diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index d06230655e..b4fade1ed6 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -38,7 +38,6 @@ struct target_sigframe int sig; int code; abi_ulong psc; - char retcode[8]; abi_ulong extramask[TARGET_NSIG_WORDS-1]; struct target_sigcontext sc; }; @@ -75,7 +74,6 @@ struct target_rt_sigframe int sig; abi_ulong pinfo; abi_ulong puc; - char retcode[8]; struct target_siginfo info; struct target_ucontext uc; }; @@ -129,7 +127,6 @@ void setup_frame(int sig, struct target_sigaction *ka, { struct target_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong sc_addr; int i; @@ -151,16 +148,7 @@ void setup_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; trap #0 */ - - __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), - (uint32_t *)(frame->retcode)); - - /* Set up to return from userspace */ + __put_user(default_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -287,7 +275,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { struct target_rt_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong info_addr; abi_ulong uc_addr; int err = 0; @@ -324,17 +311,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; notb d0; trap #0 */ - - __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), - (uint32_t *)(frame->retcode + 0)); - __put_user(0x4e40, (uint16_t *)(frame->retcode + 4)); - - /* Set up to return from userspace */ + __put_user(default_rt_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -410,3 +387,23 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + void *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + + /* moveq #,d0; trap #0 */ + __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp); + + default_rt_sigreturn = sigtramp_page + 4; + + /* moveq #,d0; notb d0; trap #0 */ + __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), + (uint32_t *)(tramp + 4)); + __put_user(0x4e40, (uint16_t *)(tramp + 8)); + + unlock_user(tramp, sigtramp_page, 4 + 6); +}