From patchwork Tue Sep 28 02:00:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514747 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4699270jao; Mon, 27 Sep 2021 19:12:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhbd+ZEqH4ofh1MRyWpi9L9VIq8oBp1HUcTAm6cThWYrrSvyzhkfAw3YlKs9zlJgRHhY3+ X-Received: by 2002:a0c:f0c2:: with SMTP id d2mr2946101qvl.47.1632795162422; Mon, 27 Sep 2021 19:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795162; cv=none; d=google.com; s=arc-20160816; b=eMoYEDs/OB7yXVxWmqPBtwZoDNB9Rt1HrfELrxLf/GxQENeT3AtfBXqvzrWkdPCjhz It62Hyclw+mQ4pYTdYTts+HVPrh5xILyF8ucgahU0Sdb0KX0ftT5L7Cl0Uka5Ep6La5f YC/PEOuXke9Lx/O2Bs2TrPzgFHRc/I4q/gMSQPSO6lZMPQ+nxOyTBSxbPHVOsFZGmrBp 6rSj9Dh2fa3IPYNsjyWhLJN0H/Pz9R3UUFVhRhsLW9Zq+vKhZ8sy6sG2q6xqoMTejZjz MnoKt7FDMy4gtRtr+XShSy4MwaAHV/v+Vj2gceYvqjrZDI41JlUKtB3BIL9ZbY+mmXgW pviA== 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=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=F1H43ckOd7teE0SR+npFOgkIuMaajuznx0N5Bqcv2HcXslJJyT0vwHPLcwhww4+8Yv r27aeR2MI2rzizpZQPU/ywmksYnld+vXXkqjVsLgjtfgOCSbHXrEV+lqJmID+ldSxWfA 00Vwy7AFxX91BF41ECRYi/0lUegJthjUYHM/B/SSjUTZZt7/r3o9NnwripAVrSc/8r3x hGPa0XbYMhEU5nDHL8CJ3hrFrNwq2guyzXtRlJXzo72/5PbM6upLQPVxMpCyM8fTLMFJ vgaZpiPbmEQbLhAnLamf5MWUHibMZdNX7BxHz/5gXVd0uTvbFqpnsyPOvugItPqqoKEP 5IPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nV7wlcqb; 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 u5si11146061qtw.171.2021.09.27.19.12.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:12:42 -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=nV7wlcqb; 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]:36556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2bp-0001ic-RY for patch@linaro.org; Mon, 27 Sep 2021 22:12:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QQ-0004a9-Ma for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:55 -0400 Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]:39639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QF-0005d8-Hz for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:53 -0400 Received: by mail-qv1-xf2b.google.com with SMTP id a14so12479608qvb.6 for ; Mon, 27 Sep 2021 19:00:43 -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=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=nV7wlcqb5AJFq2ES+S9KhcKm6ut6yZJBkQL3faOofSs79WBIxDY77TnVlM0HlD7jtj RjWPWqGrufS5atKJF4hB64T0SeKA2qYHRF4rtYQwYzI5bWgN+dSqINZobtHDi/zNIOuq g5Kpln3bKwGgj5jeXNwIzjiSMIgM5VzJ7cbfZceXzMzZ8O35XIT3XKNhZi6YG2v55304 OesCUuSrf4MTtvG1qvULy34s3leAdMMWWFXmnMRctQltiJz7fuMcarfAPh3QFwdQrxuk vyd6UCuk2KRWhe64N4wxzl76XOJ/MhK/DA8O4nL4ud/gHhLD3VXoyqVDWdYVcsEubJmY COXg== 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=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=4jAdR4qr3tLw7HL4U3S8Dd9zifMDlXDOW/HIfWkCGIJbzYnqP64Yk0tcprQL4QBD1B Yvx3xXtubRYc0PE4NUEEYcX/4CKnTItWyi4skZsBsGCwHOB3byJlV960XBh+LpsbWMjc hCb74sEi528m+p1JR/ZayWV9TZW2G84XP/Nh9OJ9AfyrKZf5RU6XDY/wDWUbQbZ4c4Xo RZP6UOOC63rXCgKe+tjANQlFXv+BGBNKDaj/268CHlmXb6p9Bjd0dBJLcFr64kUSNMw/ A2Ia8JBX7r8b8y8fXJvPXtCJEzpIsLe7uv6MvK0WzgUTCHEbVJdAO3JcluM3kq0tvmKC AITg== X-Gm-Message-State: AOAM5323vxzMu7kZ6B3Fme+C7q4k90c+HTH2unRSKLFWbpZsisWbm6Hc 5viRYQ8FamYP/yM89sUjn6vV+wouN2lA4g== X-Received: by 2002:a0c:90c8:: with SMTP id p66mr3022573qvp.55.1632794442563; Mon, 27 Sep 2021 19:00:42 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 01/25] linux-user: Add infrastructure for a signal trampoline page Date: Mon, 27 Sep 2021 22:00:15 -0400 Message-Id: <20210928020039.184412-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2b.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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , laurent@vivier.eu, Max Filippov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allocate a page to hold the signal trampoline(s). Invoke a guest-specific hook to fill in the contents of the page before marking it read-execute again. Reviewed-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/signal-common.h | 6 ++++++ linux-user/elfload.c | 18 ++++++++++++++++++ linux-user/signal.c | 3 +++ 3 files changed, 27 insertions(+) -- 2.25.1 diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 79511becb4..7457f8025c 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -20,6 +20,12 @@ #ifndef SIGNAL_COMMON_H #define SIGNAL_COMMON_H +/* Fallback addresses into sigtramp page. */ +extern abi_ulong default_sigreturn; +extern abi_ulong default_rt_sigreturn; + +void setup_sigtramp(abi_ulong tramp_page); + int on_sig_stack(unsigned long sp); int sas_ss_flags(unsigned long sp); abi_ulong target_sigsp(abi_ulong sp, struct target_sigaction *ka); diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 5f9e2141ad..459a26ef1d 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -7,6 +7,7 @@ #include "qemu.h" #include "user-internals.h" +#include "signal-common.h" #include "loader.h" #include "user-mmap.h" #include "disas/disas.h" @@ -17,6 +18,7 @@ #include "qemu/units.h" #include "qemu/selfmap.h" #include "qapi/error.h" +#include "target_signal.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -28,6 +30,10 @@ #undef ELF_ARCH #endif +#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 +#endif + #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */ @@ -3249,6 +3255,18 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) #endif } + /* + * TODO: load a vdso, which would also contain the signal trampolines. + * Otherwise, allocate a private page to hold them. + */ + if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) { + abi_ulong tramp_page = target_mmap(0, TARGET_PAGE_SIZE, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + setup_sigtramp(tramp_page); + target_mprotect(tramp_page, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC); + } + bprm->p = create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, info, (elf_interpreter ? &interp_info : NULL)); info->start_stack = bprm->p; diff --git a/linux-user/signal.c b/linux-user/signal.c index 2038216455..14d8fdfde1 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -35,6 +35,9 @@ static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_signum, siginfo_t *info, void *puc); +/* Fallback addresses into sigtramp page. */ +abi_ulong default_sigreturn; +abi_ulong default_rt_sigreturn; /* * System includes define _NSIG as SIGRTMAX + 1, From patchwork Tue Sep 28 02:00:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514744 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4696861jao; Mon, 27 Sep 2021 19:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnEE88GpAULZP2KWBFUjYuRW9A8Z5kd7FtgFG8MlpK963Hzs3CSo8AAGvHaH/9IgwIheGU X-Received: by 2002:ab0:3d11:: with SMTP id f17mr3324947uax.65.1632794933050; Mon, 27 Sep 2021 19:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632794933; cv=none; d=google.com; s=arc-20160816; b=aStK7ysmP6rQXn5QPPtVH1Urd9VFlE2OcCO/yfE6ooS3E8OnJBTVsAuCDJjRT10rql Q/W9nrjbkqa8aF/EnwpESONgdHt34/DAtLnkDoSyrYNFVvo6re1RVcx8crw/8QOXhIcZ zErNm+LKL4l/jph28Lrfbcfnugqsw/mnFwiBE0iMY/07QNhqJ46ITWtblnJ3vX3sW1AU ATtPHHK8tXpryU55J080mFeE6F88Jl6AefVMH/y/FRMk/cbnVP5OOyIg2Bqvg825HmoW THfneeeFdaBSYRx6PcE9DAGgagwLOYJDmoKh9W/bVoxaC0CdKTDdWi9LMlQYf7kOhm14 M/Ug== 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=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=ZtJwAGuGOKKdG1zsupuL9Tu+FU3t3wQzwzPLFTZhoYaCsp8PVDNVYdaAY05PcRB22F SMtRwDGxM1KUPU6fU6nL1iLjWRjRcOMwe+w5Bta+XeU7sUh9IFOWm7eNYxgzV/ykER1O wpk45EYfQCixfGY0yzsAP8kEAcel6VTMD/J8fSZInKsoQLaXBkuoP9A4L2R+W5M5IhEt G/TXI2T/Z5wdBYvY5+/CxNLIjfaVnfknwYvvOQRKU39aKmVc8bYOm85nDbCQO7a2hJ6P H++9YuBdJoAD2j4S/ioLWNPBYc3m5sh6TEPjabWypk4c0smijvpHcji4Ni7EpXVYqJ0R rH4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="s42fSLn/"; 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 y26si11588918vsg.352.2021.09.27.19.08.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:08:53 -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="s42fSLn/"; 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]:56380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2Y8-0004PX-Eg for patch@linaro.org; Mon, 27 Sep 2021 22:08:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QK-0004ZS-33 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:52 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:34718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QG-0005dR-6T for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:46 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id w8so12509501qvu.1 for ; Mon, 27 Sep 2021 19:00:43 -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=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=s42fSLn/tSzuE/ONf/W78emoJzyqpfhN5oLYeI+G60gEvTK/Ta709171e+rJWxDmws nwkftCOd11EEXhGEnavkfYG4qj10zy+Kv1svzt8j0iXq++1LW47yVT+AcqNZHSdu1+qU GtePGnLwdxwL8sCi++J68o8q5lms1Bk2e4F9JHOE38kjGsGhKVNjEgyTVUsCj2M5TBD4 BfJ1fJhj+4kayeloqwDHS10SELAqr4Mzw7BX1/VOrj+qdobB6rMc+LXpZgwYGxCw67OG FpnNJfCeLXlcvonJ6KJodCL66jMQMyj+BJlpcf86/ifsvxQh5wDGtBh7HhZEBPWalKnh JHEg== 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=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=1Y/E7eMJAaFRh8KhoC26PxBXmrc358sUKd3mRJOp8/jHuJDnAybXsG+1lvnvUBlHlX 8O2GSLmV8+IedRxKyyqQIm7Il6poPczJip6KlPLJnaXmzhLxv2R7SMFhNmvwwxkcQdnU E6l+qybipRekhcImOtVEQw3GX0B4WmAM5iAlqxpEXj6+d09xy2PoaE+meutuTM7GJyuu PERkHEISJLLaT+qbA1JCpj7rAVKzk/F6KBYV7Xu8jGt2yq5f30mvnb04sfyIba8lMdgy 00JUan+iNsaVF8LfXH2/Y6+j68eJuRWnFiGkfwYIgJ9OBTLEj1HGjHqIeGbXrrAyaTYv NV3A== X-Gm-Message-State: AOAM5326eefVHlcv2TxGUoaJHApl7otSWscQVNv0lWNev6N3QrdcKqKc Piu3BY70iqehH8wnXcVA2nhobw3KWuSHfA== X-Received: by 2002:a0c:8045:: with SMTP id 63mr2861536qva.63.1632794443340; Mon, 27 Sep 2021 19:00:43 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 02/25] linux-user/aarch64: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:16 -0400 Message-Id: <20210928020039.184412-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2f.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/aarch64/target_signal.h | 2 ++ linux-user/aarch64/signal.c | 34 ++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) -- 2.25.1 diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target_signal.h index 18013e1b23..7580d99403 100644 --- a/linux-user/aarch64/target_signal.h +++ b/linux-user/aarch64/target_signal.h @@ -25,4 +25,6 @@ typedef struct target_sigaltstack { #define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* AARCH64_TARGET_SIGNAL_H */ diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 49025648cb..29c52db3f1 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -109,7 +109,6 @@ struct target_rt_sigframe { struct target_rt_frame_record { uint64_t fp; uint64_t lr; - uint32_t tramp[2]; }; static void target_setup_general_frame(struct target_rt_sigframe *sf, @@ -461,9 +460,9 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, layout.total_size = MAX(layout.total_size, sizeof(struct target_rt_sigframe)); - /* Reserve space for the return code. On a real system this would - * be within the VDSO. So, despite the name this is not a "real" - * record within the frame. + /* + * Reserve space for the standard frame unwind pair: fp, lr. + * Despite the name this is not a "real" record within the frame. */ fr_ofs = layout.total_size; layout.total_size += sizeof(struct target_rt_frame_record); @@ -496,15 +495,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { return_addr = ka->sa_restorer; } else { - /* - * mov x8,#__NR_rt_sigreturn; svc #0 - * Since these are instructions they need to be put as little-endian - * regardless of target default or current CPU endianness. - */ - __put_user_e(0xd2801168, &fr->tramp[0], le); - __put_user_e(0xd4000001, &fr->tramp[1], le); - return_addr = frame_addr + fr_ofs - + offsetof(struct target_rt_frame_record, tramp); + return_addr = default_rt_sigreturn; } env->xregs[0] = usig; env->xregs[29] = frame_addr + fr_ofs; @@ -577,3 +568,20 @@ long do_sigreturn(CPUARMState *env) { return do_rt_sigreturn(env); } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * mov x8,#__NR_rt_sigreturn; svc #0 + * Since these are instructions they need to be put as little-endian + * regardless of target default or current CPU endianness. + */ + __put_user_e(0xd2801168, &tramp[0], le); + __put_user_e(0xd4000001, &tramp[1], le); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Tue Sep 28 02:00:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514737 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4692327jao; Mon, 27 Sep 2021 19:03:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj/clUtQI8dGyuz2bzOUbY6DTMcIEBG9wbilobnpXhpSoAWoNZJmgG84cDbnC65l7RCiQH X-Received: by 2002:a05:6102:3547:: with SMTP id e7mr3246107vss.41.1632794583815; Mon, 27 Sep 2021 19:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632794583; cv=none; d=google.com; s=arc-20160816; b=n7gyMmqioAW9LaeLnj19pKJJ0ueHRrl2GB7Zm0PoQcJrCwNkVH6OXcaNCYXUijqN33 c9a0N908iUn2xN2cOIjCjhktzHiV6sCGEvzIaMgXfSrooDQIiwMTLqQtU8h2266/ydYL cfFzazINXQv5w9SLN2+CwA3ajlTD58mVf4eMt8LEP3Z+uAO5BDTYVSqPtUNyCMI3R2gm vTdi2E0r6t2oVUVlpDWaQvx0Fw5xz6yb2WHbqLMBeGk1sDZZkGuGe1fDacwh+pQNOKxu 7U1+dDPQhcfw5obp1ssaixHwwkDFokwQr3RfnICmFkJrviABObv9I0iKFlt8BQAxoG7n D6fA== 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=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=QfJ0kJykk3zsOlB/HDukrPGaWsNF0YRvS/0o+Gzj01gRNrgUh7gWgkOFRF/Ejc79/A oW6uRoUTUBIwgGJlZ26HfrbF8BPcuH1WnavLZsDpTwbunYqjaxfArzeTS/5RN3OXSGSG t9RlahEoA9h7S4dew7wn4gqbf0XkORIvJj0osrZ3QO1sA6NRQqzIpM6GbBVsLd3ec2f5 fuZKtuvAK59HW4v9cDU60Zp4V5B7qZr7MGEtKnngPRHbhlglt/tkTaIenRbz94AHskLN eg6umv2jfCLl97J3F04rM8jCquUsTu5CPzJzB7DHH/5/fAP29JWosxFjs3fntT7cWX8o qBeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jL9PWFzg; 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 b6si12175907vsf.425.2021.09.27.19.03.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:03: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=jL9PWFzg; 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]:44506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2SV-0004aZ-4F for patch@linaro.org; Mon, 27 Sep 2021 22:03:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QK-0004ZT-3A for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:52 -0400 Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]:42935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QG-0005eP-WD for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:47 -0400 Received: by mail-qv1-xf2b.google.com with SMTP id a13so12487023qvo.9 for ; Mon, 27 Sep 2021 19:00:44 -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=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=jL9PWFzgO7IBswIjAcRT6DliXGAN81TZl7GbHROFMgv9rHtDnOSgJiDskc+DI94pZL J8inhCZLqMtgUaZ57oENEGYQIei22Sj+m1TxEoNmWxKzciEPRJiQ885ioRRERJptCpnA Wo+Plav0xtFYukOsyukS6uBqvOK7rAOZfK7NhW1V/d1SrPE09iV+EBROzeOwNLAA/sxs xlqg2DghiOk7/bOBBXPkfZ2XDqcJh+uMU83b0rkbPvKkwhykDKtHcdZpBp9EzZEpo5ah ZXlvqujHgXNfCr5WInJ2321khVwHiEksoem3MRthNiq9DNWEt5bBtYGj3aa7D4wpGzuE H5oQ== 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=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=5/r45hojZUZDByzNR8PMcsou6yePtrbA5FMKQLsK4gTeiVNy09I5bWPxOAPwDbZbj2 93DbPx8TusLCot5GSjJPq/pVsc8f3xcwOTY9jTPT18YFAlupqvelyE87WaY2jvPKUXeJ /s0/QpkEe/3JdIfg7mMBXPWE7MIH/Wo5msTg23mZGi8F+YjHp19aqO3ixP1bRUPssqm/ UPzwvHA97S0ozvg8yuJ7C6h/j2hXa+YuS/3K6iEuVpcSBnmAJI916cX+TJXLGDr/7I3d iFel10UfWPNc4s7JrpeGvLCjRL2RhiSPWgUUFaMRH+bh51264Ake9xZHRJUgEvi1GYaQ LX8Q== X-Gm-Message-State: AOAM531r8e3SBwXCe8fmcgtR3l1iGffDFfpW0evQ/VFooXFnz60Dqo+k ahzRHhwHqLFnFrIZmDhLQkfP9FJB2pLadA== X-Received: by 2002:ad4:49a6:: with SMTP id u6mr2987052qvx.14.1632794444090; Mon, 27 Sep 2021 19:00:44 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 03/25] linux-user/arm: Drop v1 signal frames Date: Mon, 27 Sep 2021 22:00:17 -0400 Message-Id: <20210928020039.184412-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2b.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Version 2 signal frames are used from 2.6.12 and since cbc14e6f286, we have set UNAME_MINIMUM_RELEASE to 2.6.32. Suggested-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 220 +--------------------------------------- 1 file changed, 4 insertions(+), 216 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed144f9455..d0940bab47 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,14 +46,6 @@ struct target_sigcontext { abi_ulong fault_address; }; -struct target_ucontext_v1 { - abi_ulong tuc_flags; - abi_ulong tuc_link; - target_stack_t tuc_stack; - struct target_sigcontext tuc_mcontext; - target_sigset_t tuc_sigmask; /* mask last for extensibility */ -}; - struct target_ucontext_v2 { abi_ulong tuc_flags; abi_ulong tuc_link; @@ -98,28 +90,12 @@ struct target_iwmmxt_sigframe { #define TARGET_VFP_MAGIC 0x56465001 #define TARGET_IWMMXT_MAGIC 0x12ef842a -struct sigframe_v1 -{ - struct target_sigcontext sc; - abi_ulong extramask[TARGET_NSIG_WORDS-1]; - abi_ulong retcode[4]; -}; - struct sigframe_v2 { struct target_ucontext_v2 uc; abi_ulong retcode[4]; }; -struct rt_sigframe_v1 -{ - abi_ulong pinfo; - abi_ulong puc; - struct target_siginfo info; - struct target_ucontext_v1 uc; - abi_ulong retcode[4]; -}; - struct rt_sigframe_v2 { struct target_siginfo info; @@ -363,37 +339,6 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, } } -/* compare linux/arch/arm/kernel/signal.c:setup_frame() */ -static void setup_frame_v1(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) -{ - struct sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); - int i; - - trace_user_setup_frame(regs, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - setup_sigcontext(&frame->sc, regs, set->sig[0]); - - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->extramask[i - 1]); - } - - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v1, retcode))) { - goto sigsegv; - } - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); -} - static void setup_frame_v2(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { @@ -422,60 +367,7 @@ sigsegv: void setup_frame(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { - if (get_osversion() >= 0x020612) { - setup_frame_v2(usig, ka, set, regs); - } else { - setup_frame_v1(usig, ka, set, regs); - } -} - -/* compare linux/arch/arm/kernel/signal.c:setup_rt_frame() */ -static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) -{ - struct rt_sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); - struct target_sigaltstack stack; - int i; - abi_ulong info_addr, uc_addr; - - trace_user_setup_rt_frame(env, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - info_addr = frame_addr + offsetof(struct rt_sigframe_v1, info); - __put_user(info_addr, &frame->pinfo); - uc_addr = frame_addr + offsetof(struct rt_sigframe_v1, uc); - __put_user(uc_addr, &frame->puc); - tswap_siginfo(&frame->info, info); - - /* Clear all the bits of the ucontext we don't use. */ - memset(&frame->uc, 0, offsetof(struct target_ucontext_v1, tuc_mcontext)); - - memset(&stack, 0, sizeof(stack)); - target_save_altstack(&stack, env); - memcpy(&frame->uc.tuc_stack, &stack, sizeof(stack)); - - setup_sigcontext(&frame->uc.tuc_mcontext, env, set->sig[0]); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); - } - - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v1, retcode))) { - goto sigsegv; - } - - env->regs[1] = info_addr; - env->regs[2] = uc_addr; - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); + setup_frame_v2(usig, ka, set, regs); } static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, @@ -516,11 +408,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { - if (get_osversion() >= 0x020612) { - setup_rt_frame_v2(usig, ka, info, set, env); - } else { - setup_rt_frame_v1(usig, ka, info, set, env); - } + setup_rt_frame_v2(usig, ka, info, set, env); } static int @@ -553,54 +441,6 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) return err; } -static long do_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct sigframe_v1 *frame = NULL; - target_sigset_t set; - sigset_t host_set; - int i; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - __get_user(set.sig[0], &frame->sc.oldmask); - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __get_user(set.sig[i], &frame->extramask[i - 1]); - } - - target_to_host_sigset_internal(&host_set, &set); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->sc)) { - goto badframe; - } - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; -} - static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) { int i; @@ -733,55 +573,7 @@ badframe: long do_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_sigreturn_v2(env); - } else { - return do_sigreturn_v1(env); - } -} - -static long do_rt_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct rt_sigframe_v1 *frame = NULL; - sigset_t host_set; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_rt_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) { - goto badframe; - } - - target_restore_altstack(&frame->uc.tuc_stack, env); - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - unlock_user_struct(frame, frame_addr, 0); - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; + return do_sigreturn_v2(env); } static long do_rt_sigreturn_v2(CPUARMState *env) @@ -822,9 +614,5 @@ badframe: long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_rt_sigreturn_v2(env); - } else { - return do_rt_sigreturn_v1(env); - } + return do_rt_sigreturn_v2(env); } From patchwork Tue Sep 28 02:00:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514740 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4695041jao; Mon, 27 Sep 2021 19:06:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeHlzomm/Ze9aLSH5fl6JSTJXlC5jK78xO/Q7gGgcQTjbrRppMOTkT6382bXeDCOrM7SMx X-Received: by 2002:ac8:610b:: with SMTP id a11mr3181682qtm.182.1632794779854; Mon, 27 Sep 2021 19:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632794779; cv=none; d=google.com; s=arc-20160816; b=YJAiYbqHHYwcH/de3orFQ2ROZoif9P1rWjDy/lrOB3eWiRh5Oi6f+Ft8SXmQdgjJOJ //FAuoDuGenXz5drNGz42FAf4C8F/XlV9YtJxRJ3Zj2RhxiTEfH0kiBaFq+kNLentQ0M qGbJ8nkTvenNMaWEqZMmh4twPShaPBfHRZJrl0HL/Ou4U6G1+rZo+YKh7utOipOPlNYr j7RNFd+aKx7PiEHwWEsSZQz1RE677tCZJI2ygSCtke39oWkgPXbU4EjH4tZtuuu0Vad+ bGZALiohYvekPUpbArLpT7WCK3tfcKTttMoMlUZPjVP7q0MhwII2LqcYfjVfefTaYook x7jw== 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=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=xEC0A1uZY0bGOh5smkMfcmsgcGVZvYG0Bb1ntu6zGduG5L+aTW8Z5mG/vZZMRgN+6X BaRnCe9nRKq0ajubK2i0KoL18k8deRL0WD/vqdRGG+DogEyDMHIgdp6iPaK8f41Ks4qD e7o6uD/9EWGe5ITOzfhzFt+dHNMTsRLtqGaKByWtzvG6xfzGfJuffLjIK5GhHz/9Fn6s q9/D3oeBYh7j72rgnyNXo+UN9Ba3TYMYr25N3b4c66GTvMQWk+IoC4/aw6TtL5iTsxMT bE3ZrnEfYM0ggYZ4lp3bd2igbfpUt+M11269MMPiFLjBoZ8BkUDs+zU5HoBkiPAH2jVE thAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HzD7kXyP; 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 hu15si2454456qvb.100.2021.09.27.19.06.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:06:19 -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=HzD7kXyP; 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]:47692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2Vf-0006t3-7v for patch@linaro.org; Mon, 27 Sep 2021 22:06:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QO-0004ZV-GN for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:53 -0400 Received: from mail-qv1-xf35.google.com ([2607:f8b0:4864:20::f35]:37670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QI-0005f3-22 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:49 -0400 Received: by mail-qv1-xf35.google.com with SMTP id o15so44986qvq.4 for ; Mon, 27 Sep 2021 19:00:45 -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=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=HzD7kXyPgCHFTQ5C0P+/QIS0JXQeQcKUciDfW9h7xwoS0iuk9mYr/lKKl4RSqfqVsf t/7ORjxXk9U6Guaoch9ai6LHO36ysheWCxEomVytw60FyGGQUEHBTNUhYeaE99d9VXG4 TsUnDwYOpP1E3gzQ3uWg1Tx0OJ/RyG1IeAksQSuMr8ohKeYamain5MexhD9i2wPTFvau wUsxKl1BIho0L8+WFHNPIfQna9A6CDhX3uZmtjVQEVA5Z1Q5So8IGyfvR/x2oCsz8X2O R8t48OgvzLxuRKvwmnU2Y0YuNsFwVRLFQN41L/LkiC56KPDP1kZJ3Q4+Wap/JKjEwkfn xbjw== 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=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=EJXEDDujwRrGXPbP3hq8aaYjH55kJG8Bh66SLSGhZ0j93HewP5lQnsoXFXxoNGzEjP IDx4cXzOeaFVHEqURvUsXgdD330Hi6C9luJXBgjm7YpgPZKdZ/kllicFo9kimDVsSxSN IQprHauIa6tEZWlJ9Y6wRP9g3mOqQl5rAUkPzjWQng7UUFqDv1HFEVgFpRXY4RNZN82T 1xVJJMiOtPJkrr23hpm+T3fYd1OIB9L9rN4M9iWCzTSzU7KNjLnsy4hkQkHgf9zDw4yf EE3z9hRYfj8cwHHGwuL90B82WwmX/wLiNt5gYfs4Z9sljKQEgSZvTblO2gP9A2bRoZa0 R3XQ== X-Gm-Message-State: AOAM530SB9BusxL8i5E4WBgy17dNEY0nJeerK/JvsjyotVvsTF8LJEvt VlvZh0RMCdH+bbztBHvxkNKW2yKxRgfa8g== X-Received: by 2002:a0c:d44b:: with SMTP id r11mr3063163qvh.27.1632794445014; Mon, 27 Sep 2021 19:00:45 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 04/25] linux-user/arm: Drop "_v2" from symbols in signal.c Date: Mon, 27 Sep 2021 22:00:18 -0400 Message-Id: <20210928020039.184412-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f35; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf35.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since we no longer support "v1", there's no need to distinguish "v2". Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 155 +++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 90 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index d0940bab47..ed7d1d80bb 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,7 +46,7 @@ struct target_sigcontext { abi_ulong fault_address; }; -struct target_ucontext_v2 { +struct target_ucontext { abi_ulong tuc_flags; abi_ulong tuc_link; target_stack_t tuc_stack; @@ -90,16 +90,16 @@ struct target_iwmmxt_sigframe { #define TARGET_VFP_MAGIC 0x56465001 #define TARGET_IWMMXT_MAGIC 0x12ef842a -struct sigframe_v2 +struct sigframe { - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; -struct rt_sigframe_v2 +struct rt_sigframe { struct target_siginfo info; - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; @@ -270,7 +270,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, return 0; } -static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) +static abi_ulong *setup_sigframe_vfp(abi_ulong *regspace, CPUARMState *env) { int i; struct target_vfp_sigframe *vfpframe; @@ -287,8 +287,7 @@ static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) return (abi_ulong*)(vfpframe+1); } -static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, - CPUARMState *env) +static abi_ulong *setup_sigframe_iwmmxt(abi_ulong *regspace, CPUARMState *env) { int i; struct target_iwmmxt_sigframe *iwmmxtframe; @@ -307,15 +306,15 @@ static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, return (abi_ulong*)(iwmmxtframe+1); } -static void setup_sigframe_v2(struct target_ucontext_v2 *uc, - target_sigset_t *set, CPUARMState *env) +static void setup_sigframe(struct target_ucontext *uc, + target_sigset_t *set, CPUARMState *env) { struct target_sigaltstack stack; int i; abi_ulong *regspace; /* Clear all the bits of the ucontext we don't use. */ - memset(uc, 0, offsetof(struct target_ucontext_v2, tuc_mcontext)); + memset(uc, 0, offsetof(struct target_ucontext, tuc_mcontext)); memset(&stack, 0, sizeof(stack)); target_save_altstack(&stack, env); @@ -325,10 +324,10 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, /* Save coprocessor signal frame. */ regspace = uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace = setup_sigframe_v2_vfp(regspace, env); + regspace = setup_sigframe_vfp(regspace, env); } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace = setup_sigframe_v2_iwmmxt(regspace, env); + regspace = setup_sigframe_iwmmxt(regspace, env); } /* Write terminating magic word */ @@ -339,10 +338,10 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, } } -static void setup_frame_v2(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) +void setup_frame(int usig, struct target_sigaction *ka, + target_sigset_t *set, CPUARMState *regs) { - struct sigframe_v2 *frame; + struct sigframe *frame; abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); trace_user_setup_frame(regs, frame_addr); @@ -350,10 +349,10 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka, goto sigsegv; } - setup_sigframe_v2(&frame->uc, set, regs); + setup_sigframe(&frame->uc, set, regs); if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v2, retcode))) { + frame_addr + offsetof(struct sigframe, retcode))) { goto sigsegv; } @@ -364,51 +363,38 @@ sigsegv: force_sigsegv(usig); } -void setup_frame(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) -{ - setup_frame_v2(usig, ka, set, regs); -} - -static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) -{ - struct rt_sigframe_v2 *frame; - abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); - abi_ulong info_addr, uc_addr; - - trace_user_setup_rt_frame(env, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - info_addr = frame_addr + offsetof(struct rt_sigframe_v2, info); - uc_addr = frame_addr + offsetof(struct rt_sigframe_v2, uc); - tswap_siginfo(&frame->info, info); - - setup_sigframe_v2(&frame->uc, set, env); - - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v2, retcode))) { - goto sigsegv; - } - - env->regs[1] = info_addr; - env->regs[2] = uc_addr; - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); -} - void setup_rt_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { - setup_rt_frame_v2(usig, ka, info, set, env); + struct rt_sigframe *frame; + abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); + abi_ulong info_addr, uc_addr; + + trace_user_setup_rt_frame(env, frame_addr); + if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { + goto sigsegv; + } + + info_addr = frame_addr + offsetof(struct rt_sigframe, info); + uc_addr = frame_addr + offsetof(struct rt_sigframe, uc); + tswap_siginfo(&frame->info, info); + + setup_sigframe(&frame->uc, set, env); + + if (setup_return(env, ka, frame->retcode, frame_addr, usig, + frame_addr + offsetof(struct rt_sigframe, retcode))) { + goto sigsegv; + } + + env->regs[1] = info_addr; + env->regs[2] = uc_addr; + + unlock_user_struct(frame, frame_addr, 1); + return; +sigsegv: + unlock_user_struct(frame, frame_addr, 1); + force_sigsegv(usig); } static int @@ -441,7 +427,7 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) return err; } -static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) +static abi_ulong *restore_sigframe_vfp(CPUARMState *env, abi_ulong *regspace) { int i; abi_ulong magic, sz; @@ -471,8 +457,8 @@ static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) return (abi_ulong*)(vfpframe + 1); } -static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env, - abi_ulong *regspace) +static abi_ulong *restore_sigframe_iwmmxt(CPUARMState *env, + abi_ulong *regspace) { int i; abi_ulong magic, sz; @@ -496,9 +482,9 @@ static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env, return (abi_ulong*)(iwmmxtframe + 1); } -static int do_sigframe_return_v2(CPUARMState *env, - target_ulong context_addr, - struct target_ucontext_v2 *uc) +static int do_sigframe_return(CPUARMState *env, + target_ulong context_addr, + struct target_ucontext *uc) { sigset_t host_set; abi_ulong *regspace; @@ -506,19 +492,20 @@ static int do_sigframe_return_v2(CPUARMState *env, target_to_host_sigset(&host_set, &uc->tuc_sigmask); set_sigmask(&host_set); - if (restore_sigcontext(env, &uc->tuc_mcontext)) + if (restore_sigcontext(env, &uc->tuc_mcontext)) { return 1; + } /* Restore coprocessor signal frame */ regspace = uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace = restore_sigframe_v2_vfp(env, regspace); + regspace = restore_sigframe_vfp(env, regspace); if (!regspace) { return 1; } } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace = restore_sigframe_v2_iwmmxt(env, regspace); + regspace = restore_sigframe_iwmmxt(env, regspace); if (!regspace) { return 1; } @@ -535,10 +522,10 @@ static int do_sigframe_return_v2(CPUARMState *env, return 0; } -static long do_sigreturn_v2(CPUARMState *env) +long do_sigreturn(CPUARMState *env) { abi_ulong frame_addr; - struct sigframe_v2 *frame = NULL; + struct sigframe *frame = NULL; /* * Since we stacked the signal on a 64-bit boundary, @@ -555,10 +542,9 @@ static long do_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, - frame_addr - + offsetof(struct sigframe_v2, uc), - &frame->uc)) { + if (do_sigframe_return(env, + frame_addr + offsetof(struct sigframe, uc), + &frame->uc)) { goto badframe; } @@ -571,15 +557,10 @@ badframe: return -TARGET_QEMU_ESIGRETURN; } -long do_sigreturn(CPUARMState *env) -{ - return do_sigreturn_v2(env); -} - -static long do_rt_sigreturn_v2(CPUARMState *env) +long do_rt_sigreturn(CPUARMState *env) { abi_ulong frame_addr; - struct rt_sigframe_v2 *frame = NULL; + struct rt_sigframe *frame = NULL; /* * Since we stacked the signal on a 64-bit boundary, @@ -596,10 +577,9 @@ static long do_rt_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, - frame_addr - + offsetof(struct rt_sigframe_v2, uc), - &frame->uc)) { + if (do_sigframe_return(env, + frame_addr + offsetof(struct rt_sigframe, uc), + &frame->uc)) { goto badframe; } @@ -611,8 +591,3 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } - -long do_rt_sigreturn(CPUARMState *env) -{ - return do_rt_sigreturn_v2(env); -} From patchwork Tue Sep 28 02:00:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514739 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4692473jao; Mon, 27 Sep 2021 19:03:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxATsQqTEgYKlGJqKVpRwJ+yB4LbSYecewZGJ6W591GCC5Uia3uXSa9jrYRxPyNTGDF2VIG X-Received: by 2002:a67:eacf:: with SMTP id s15mr3188012vso.44.1632794594636; Mon, 27 Sep 2021 19:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632794594; cv=none; d=google.com; s=arc-20160816; b=rETG8GWAhCSgEM/PVpHwzDfClQKfGnL8GLL5APREWYFaeKHXDUuVwFyeaaSBtMZj6G eC/X3qADMOJ312jJWvqoHHWEAO4x3UgqavYtI2AuWhrKbXb9z8VntiBRPimrEgTSpH3Z 5hbIET6fLDX6r6Q56wVnQy8CkTGGuoCaYGSYbrdxRuof9STZ3rYyPoefFNZYNLWKkhCG zc87rh5X0yAVeEqRyrrM6G30RmELs0yhSGit4PjkVZOBfB9qx0FXxBxex8HoSex1Kux4 xeknzZL+e7zhtJPW9ijijs9fgW+YfJgyEY5Asn22iKydEYTSwWGSPS6Ak6QIUZ/SjlJd mRvA== 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=Ktw9tUrJhzUu8kusMPVwZ3Oa3vGWKHqQeWg6eFN1MAk=; b=LVt/0PMo5/t8CfZpNZ+pHbWjfbihxvH0/FiJm2Q8ULpqHl6NL8nldbPRyZb/TWILmd W6fs10XmMC53oIUikkc1mH0RBd7PULUDNUxpaCK6JQO5WOjfcv0gWgAV3cgVWwUZ9Ic3 l7AN/LqeJ4uwoYXRyPSR7xOO4KtbHDAWXMcYivOYC3NRY414n38lLw3KdxaF8lszAqf/ oBI2Bqq83urotCmU4z7dmqvtDEuUsGzBB22MkTFK3ot1kEQRlH4JZmTWDspIsNftQycR FPHBKaaLFuYO5FaGHDDQHp1hoGelATWa7nuhRGVQvRYK0WmG7xGsQAy4B1luCrc1wPDx stnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VaclZ4KD; 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 g15si10076026vsb.377.2021.09.27.19.03.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:03:14 -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=VaclZ4KD; 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]:44732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2Sf-0004je-UE for patch@linaro.org; Mon, 27 Sep 2021 22:03:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QO-0004ZW-QG for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:53 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:44972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QI-0005fD-QY for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:52 -0400 Received: by mail-qt1-x82a.google.com with SMTP id r16so18528861qtw.11 for ; Mon, 27 Sep 2021 19:00:46 -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=Ktw9tUrJhzUu8kusMPVwZ3Oa3vGWKHqQeWg6eFN1MAk=; b=VaclZ4KDhSG1909iBUzwa8fim5P+cX+eiwQW1Eowr7kth07TOdUavTst22t8Dk+dgI bbNK2ASKW2kHV+aindTQPxKy5vmzl2sWKCZ6mUX3w9efn0pKoKYx+AbV6ZWzn1KWWTqN K6wOqRarORitbHnVgYAcmTT6brj2dESKqcIStXQl9sNQorw382XK3g+kMTYwJoD5JT6E cX8UeTSbpFGNhh8PkMoEirKW+ywtesxDuOSvVvd/y9XPjfYKxOpJ5ryAV8l8J6F9NtzI Cou/a/dxQhVNEzvwKt79n8UnvwqWA/pnqNvIZFK+h1rfMT4XVGaemzEC5+YDGhi2Ht+a xPSA== 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=Ktw9tUrJhzUu8kusMPVwZ3Oa3vGWKHqQeWg6eFN1MAk=; b=2OHhEXg/apuSKZrUskNndyDrhde1VYMFqnjo4PrMEqaNa+S5CpQWCMMv24XRmi+p5y L4Py0Jaz00w5+uZx/5eVy8wfH3FPXQ3lJRyF9FeyXeq7GIfPpZVrkz1+tnJJ0CdBOvw2 WfvK5Km72P4ksct9BrzbmHwEhlikEdyvXTRIh7lKFrNWLtkYiTXtOhI4y1pFtjkR4W2d JL4KxT4uUIVo60PCWiek6iMtge36IsWMUoOqA7I8k3ygSsiFFsZ9gsPvLGRblwqzkBwO WWOJbdC6FBluRtoXku3l2c1wv1x4gPzH/2sG0Az8S0AJbOp0wdUb1VMeKFHWaqg0gAEr SGnw== X-Gm-Message-State: AOAM531ytUV0X36qucDCF4ttTrRLOcF9InSVFnX6b6w/kmq9850as8/x cFbnta+Bmi0ThZ2uE8qOpPq25xxu4yIwAg== X-Received: by 2002:ac8:611c:: with SMTP id a28mr3096612qtm.276.1632794445814; Mon, 27 Sep 2021 19:00:45 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 05/25] linux-user/arm: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:19 -0400 Message-Id: <20210928020039.184412-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82a.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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Mirror what the kernel does in arch/arm/kernel/signal.h, using the old sigframe struct in the rt sigframe struct. Update the trampoline code to match the kernel: this uses sp-relative accesses rather than pc-relative. Copy the code into frame->retcode from the trampoline page. This minimises the different cases wrt arm vs thumb vs fdpic. Signed-off-by: Richard Henderson --- linux-user/arm/target_signal.h | 2 + linux-user/arm/signal.c | 184 ++++++++++++++++++++------------- 2 files changed, 115 insertions(+), 71 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/arm/target_signal.h b/linux-user/arm/target_signal.h index 0998dd6dfa..1e7fb0cecb 100644 --- a/linux-user/arm/target_signal.h +++ b/linux-user/arm/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 /* ARM_TARGET_SIGNAL_H */ diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed7d1d80bb..67a3d1428b 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -99,43 +99,21 @@ struct sigframe struct rt_sigframe { struct target_siginfo info; - struct target_ucontext uc; - abi_ulong retcode[4]; + struct sigframe sig; }; +static abi_ptr sigreturn_fdpic_tramp; + /* - * For ARM syscalls, we encode the syscall number into the instruction. + * Up to 3 words of 'retcode' in the sigframe are code, + * with retcode[3] being used by fdpic for the function descriptor. + * This code is not actually executed, but is retained for ABI compat. + * + * We will create a table of 8 retcode variants in the sigtramp page. + * Let each table entry use 3 words. */ -#define SWI_SYS_SIGRETURN (0xef000000|(TARGET_NR_sigreturn + ARM_SYSCALL_BASE)) -#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE)) - -/* - * For Thumb syscalls, we pass the syscall number via r7. We therefore - * need two 16-bit instructions. - */ -#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_sigreturn)) -#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sigreturn)) - -static const abi_ulong retcodes[4] = { - SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, - SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN -}; - -/* - * Stub needed to make sure the FD register (r9) contains the right - * value. - */ -static const unsigned long sigreturn_fdpic_codes[3] = { - 0xe59fc004, /* ldr r12, [pc, #4] to read function descriptor */ - 0xe59c9004, /* ldr r9, [r12, #4] to setup GOT */ - 0xe59cf000 /* ldr pc, [r12] to jump into restorer */ -}; - -static const unsigned long sigreturn_fdpic_thumb_codes[3] = { - 0xc008f8df, /* ldr r12, [pc, #8] to read function descriptor */ - 0x9004f8dc, /* ldr r9, [r12, #4] to setup GOT */ - 0xf000f8dc /* ldr pc, [r12] to jump into restorer */ -}; +#define RETCODE_WORDS 3 +#define RETCODE_BYTES (RETCODE_WORDS * 4) static inline int valid_user_regs(CPUARMState *regs) { @@ -183,15 +161,15 @@ get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize) } static int -setup_return(CPUARMState *env, struct target_sigaction *ka, - abi_ulong *rc, abi_ulong frame_addr, int usig, abi_ulong rc_addr) +setup_return(CPUARMState *env, struct target_sigaction *ka, int usig, + struct sigframe *frame, abi_ulong sp_addr) { abi_ulong handler = 0; abi_ulong handler_fdpic_GOT = 0; abi_ulong retcode; - - int thumb; + int thumb, retcode_idx; int is_fdpic = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info); + bool copy_retcode; if (is_fdpic) { /* In FDPIC mode, ka->_sa_handler points to a function @@ -208,6 +186,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, } thumb = handler & 1; + retcode_idx = thumb + (ka->sa_flags & TARGET_SA_SIGINFO ? 2 : 0); uint32_t cpsr = cpsr_read(env); @@ -225,44 +204,34 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { if (is_fdpic) { - /* For FDPIC we ensure that the restorer is called with a - * correct r9 value. For that we need to write code on - * the stack that sets r9 and jumps back to restorer - * value. - */ - if (thumb) { - __put_user(sigreturn_fdpic_thumb_codes[0], rc); - __put_user(sigreturn_fdpic_thumb_codes[1], rc + 1); - __put_user(sigreturn_fdpic_thumb_codes[2], rc + 2); - __put_user((abi_ulong)ka->sa_restorer, rc + 3); - } else { - __put_user(sigreturn_fdpic_codes[0], rc); - __put_user(sigreturn_fdpic_codes[1], rc + 1); - __put_user(sigreturn_fdpic_codes[2], rc + 2); - __put_user((abi_ulong)ka->sa_restorer, rc + 3); - } - - retcode = rc_addr + thumb; + __put_user((abi_ulong)ka->sa_restorer, &frame->retcode[3]); + retcode = (sigreturn_fdpic_tramp + + retcode_idx * RETCODE_BYTES + thumb); + copy_retcode = true; } else { retcode = ka->sa_restorer; + copy_retcode = false; } } else { - unsigned int idx = thumb; + retcode = default_sigreturn + retcode_idx * RETCODE_BYTES + thumb; + copy_retcode = true; + } - if (ka->sa_flags & TARGET_SA_SIGINFO) { - idx += 2; + /* Copy the code to the stack slot for ABI compatibility. */ + if (copy_retcode) { + uint32_t *host_rc = g2h_untagged(retcode); + int i; + + for (i = 0; i < RETCODE_WORDS; ++i) { + __put_user(host_rc[i], &frame->retcode[i]); } - - __put_user(retcodes[idx], rc); - - retcode = rc_addr + thumb; } env->regs[0] = usig; if (is_fdpic) { env->regs[9] = handler_fdpic_GOT; } - env->regs[13] = frame_addr; + env->regs[13] = sp_addr; env->regs[14] = retcode; env->regs[15] = handler & (thumb ? ~1 : ~3); cpsr_write(env, cpsr, CPSR_IT | CPSR_T | CPSR_E, CPSRWriteByInstr); @@ -351,8 +320,7 @@ void setup_frame(int usig, struct target_sigaction *ka, setup_sigframe(&frame->uc, set, regs); - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe, retcode))) { + if (setup_return(regs, ka, usig, frame, frame_addr)) { goto sigsegv; } @@ -377,13 +345,12 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, } info_addr = frame_addr + offsetof(struct rt_sigframe, info); - uc_addr = frame_addr + offsetof(struct rt_sigframe, uc); + uc_addr = frame_addr + offsetof(struct rt_sigframe, sig.uc); tswap_siginfo(&frame->info, info); - setup_sigframe(&frame->uc, set, env); + setup_sigframe(&frame->sig.uc, set, env); - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe, retcode))) { + if (setup_return(env, ka, usig, &frame->sig, frame_addr)) { goto sigsegv; } @@ -578,8 +545,8 @@ long do_rt_sigreturn(CPUARMState *env) } if (do_sigframe_return(env, - frame_addr + offsetof(struct rt_sigframe, uc), - &frame->uc)) { + frame_addr + offsetof(struct rt_sigframe, sig.uc), + &frame->sig.uc)) { goto badframe; } @@ -591,3 +558,78 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +/* + * EABI syscalls pass the number via r7. + * Note that the kernel still adds the OABI syscall number to the trap, + * presumably for backward ABI compatibility with unwinders. + */ +#define ARM_MOV_R7_IMM(X) (0xe3a07000 | (X)) +#define ARM_SWI_SYS(X) (0xef000000 | (X) | ARM_SYSCALL_BASE) + +#define THUMB_MOVS_R7_IMM(X) (0x2700 | (X)) +#define THUMB_SWI_SYS 0xdf00 + +static void write_arm_sigreturn(uint32_t *rc, int syscall) +{ + __put_user(ARM_MOV_R7_IMM(syscall), rc); + __put_user(ARM_SWI_SYS(syscall), rc + 1); + /* Wrote 8 of 12 bytes */ +} + +static void write_thm_sigreturn(uint32_t *rc, int syscall) +{ + __put_user(THUMB_SWI_SYS << 16 | THUMB_MOVS_R7_IMM(syscall), rc); + /* Wrote 4 of 12 bytes */ +} + +/* + * Stub needed to make sure the FD register (r9) contains the right value. + * Use the same instruction sequence as the kernel. + */ +static void write_arm_fdpic_sigreturn(uint32_t *rc, int ofs) +{ + assert(ofs <= 0xfff); + __put_user(0xe59d3000 | ofs, rc + 0); /* ldr r3, [sp, #ofs] */ + __put_user(0xe8930908, rc + 1); /* ldm r3, { r3, r9 } */ + __put_user(0xe12fff13, rc + 2); /* bx r3 */ + /* Wrote 12 of 12 bytes */ +} + +static void write_thm_fdpic_sigreturn(void *vrc, int ofs) +{ + uint16_t *rc = vrc; + + assert((ofs & ~0x3fc) == 0); + __put_user(0x9b00 | (ofs >> 2), rc + 0); /* ldr r3, [sp, #ofs] */ + __put_user(0xcb0c, rc + 1); /* ldm r3, { r2, r3 } */ + __put_user(0x4699, rc + 2); /* mov r9, r3 */ + __put_user(0x4710, rc + 3); /* bx r2 */ + /* Wrote 8 of 12 bytes */ +} + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t total_size = 8 * RETCODE_BYTES; + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, total_size, 0); + + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + write_arm_sigreturn(&tramp[0 * RETCODE_WORDS], TARGET_NR_sigreturn); + write_thm_sigreturn(&tramp[1 * RETCODE_WORDS], TARGET_NR_sigreturn); + write_arm_sigreturn(&tramp[2 * RETCODE_WORDS], TARGET_NR_rt_sigreturn); + write_thm_sigreturn(&tramp[3 * RETCODE_WORDS], TARGET_NR_rt_sigreturn); + + sigreturn_fdpic_tramp = sigtramp_page + 4 * RETCODE_BYTES; + write_arm_fdpic_sigreturn(tramp + 4 * RETCODE_WORDS, + offsetof(struct sigframe, retcode[3])); + write_thm_fdpic_sigreturn(tramp + 5 * RETCODE_WORDS, + offsetof(struct sigframe, retcode[3])); + write_arm_fdpic_sigreturn(tramp + 6 * RETCODE_WORDS, + offsetof(struct rt_sigframe, sig.retcode[3])); + write_thm_fdpic_sigreturn(tramp + 7 * RETCODE_WORDS, + offsetof(struct rt_sigframe, sig.retcode[3])); + + unlock_user(tramp, sigtramp_page, total_size); +} From patchwork Tue Sep 28 02:00: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: 514738 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4692434jao; Mon, 27 Sep 2021 19:03:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx90v/eRANYtZqXvaQmLvBD+PmZ8qrqaBNLgaS5yszuYV2djMcTpz8TTYa0DNMPocuKC5p+ X-Received: by 2002:a1f:2603:: with SMTP id m3mr3154683vkm.2.1632794591809; Mon, 27 Sep 2021 19:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632794591; cv=none; d=google.com; s=arc-20160816; b=qcOCGnuqwDTLf9pg788DidXzg09jYGcQkQIE+dGrG44V2jhwRmBrfLuSoeX6MWH8Yd rEZBCgSLq1PDgIWZo817yY6+Yz5mGb7juzPcbLmdzxXzRwFLw3zfQ4+CbIpDab39Sj6m nw+LOBakhjtN09c9d9T9v+MFmH81r/7cGosiC6tzHG9vZe1GG6kiwUlxbdj9WlhiRqbY TZmNltejFezuYSAx4kEPLE5pYx0u9Xnvwfvmq2U3rfIJQbCVWIX5NeuMC6p0ajp7lGWL 6JD71/a18Nxr+4olD2G7gjNoIXaGZ3DwvHBaNI9UbzHkeUVk7v7pyprOxSFCZKX8TXxI IGOQ== 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=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=nnr6nwHvsh4xLB8mSik71wvGg7E6/zmppvvg9WJSimRV323ZGaTD8GdygM8cY5zBYb A6peL4URuSd1NANtYZdUh+5dJNWSurx19M23BnFz7O1poTHHV5I4i1hSY4XhB84bDnVq gPyHtyTlq5g9q1CndgptcO9LZS6ksM8SdzzushoYIUZ81TJ588/BH9Gbw2cYDft2JX8o x2jYa6QyxToeIMCxZUD99d5X9RMOvGGCSw1dPzAqfzLsZdryYax7dyv5hA0cUWK/y7Kn o0TTEi4eomzRd44kGCfjSVup2SJeRQHoVckLTseItmuKtvswgiJD0oSfLAqNGT1tpLJl P1uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YdgvNBNu; 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 x3si885403vsf.0.2021.09.27.19.03.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:03:11 -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=YdgvNBNu; 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]:44522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2Sd-0004b1-7K for patch@linaro.org; Mon, 27 Sep 2021 22:03:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QO-0004ZX-QL for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:53 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:45017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QJ-0005g9-T1 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:52 -0400 Received: by mail-qk1-x735.google.com with SMTP id 194so38849951qkj.11 for ; Mon, 27 Sep 2021 19:00: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=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=YdgvNBNu672kC5PXsTdZnjKq4LjdfOfNlUKhZrWTKFqlt6jWoIhrJoVhTaOFeeVFfV GylxgOkLkf6tLTzjOTP/E5fHfeV6kU7EfF9u1UjSAA5+5SQtEd76f2lHFF0qC79w+aet 4FymObMB6Rg9OmCulswa9sYftgvYhtOqUL1XJE7pynl3aV8jPMaZobEFz5uxutm2zYaH iAFAangVvqL6O0jfGT4C1kknG6NND6lDYpPYeQ38jZzpVvxnPAj249YQqVGiAzv+XfId gNGuYa3nHFJUyAvu2XyBKwEdOlqjTTBmTHHZcWSq74XYExrbWZ5t04plV/GUpZ66nZ3F Hbig== 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=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=rTowxhtx/1Y2nwyz76LH6XCySVpTKqE2iv5Yt2Cnd87yC55rCW+nuiOHBR65TRbYq4 3vIYnW/ABkcpe31NyIA6Tp6LuRt0fhsJmOzb8LFrxjb09QiJhd7idUwaBjVS9c17Hhxx 5VbbzBN3Mq7/I4SDccWE24q/oDcTg7eFtyRZLMEBPPFbNAjMnlJSts5tRY6lG9q99nro VZDlq58mokhSxrn0iERXla9vKOEFcHUEDYt+CxR5B5T4iOJLilJOR+Fy7+PBcO+8XGaf hogGoo/DI2ZUzclFg8at84AE3he8gdkTCVWXgUavyOCf/1ukMRpC2SZ2rljoX9YqzN76 h9TQ== X-Gm-Message-State: AOAM531If69HVASLunNRw9FIWl4JWRyelzdJ/o8wKzPXKBzuULrwF3Ew oGc+iUY+qscADfTOv4oFRGVASU+JPgUwgw== X-Received: by 2002:ae9:eb4e:: with SMTP id b75mr3167481qkg.266.1632794446721; Mon, 27 Sep 2021 19:00:46 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 06/25] linux-user/alpha: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:20 -0400 Message-Id: <20210928020039.184412-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-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 ka_restorer. Reviewed-by: Philippe Mathieu-Daudé 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 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 3a820f616b..bbe3dd175a 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -55,13 +55,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 @@ -142,12 +140,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); @@ -196,12 +189,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) { @@ -269,3 +257,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); +} From patchwork Tue Sep 28 02:00:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514750 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4701077jao; Mon, 27 Sep 2021 19:15:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCm3wOTv4iq2jmAKn+d4FvNRjoa2QKstboVZQsZf51dYSAuI2txDpdHLiB43MaMQhCSq2l X-Received: by 2002:a05:6e02:12e8:: with SMTP id l8mr2231971iln.43.1632795342523; Mon, 27 Sep 2021 19:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795342; cv=none; d=google.com; s=arc-20160816; b=BzBmW/MW//FKkJpvQbSXoPnfC/GsvBHF5O8FkjeZnpWTrmZlOIvHJLSGRQUylOG5Rx zD/LMGBiWqJAVT3d9HvYn1gm0UGfAbysrSldeExzlgjwBLEgIkI/O+TWF0W09a/kK3ds fiOJSz7M4CJSmkCWicbJfE7VkVti4AX4/hFvvNjwXBu96oxpp8LMReTCcUlHzqGXXC+l Ru3KtsEI4n55R2If5xU1x3cMxhXgHVmHzuIe3tbxA+RwnnCjpNUrHXz+yNJo0/77gXYQ r6HXBXDDRXO414T7Gbta1ypPF2tHB2vufp/JzUFYs+qO82odrVQxB1LZKA/XR2ZW7C/X Kw6Q== 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=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=bq0X6xLj1l7FCVPFGU6s74eR4eyL9toDbNfsG0MIBEAJac8uKUfAF6gkkVRyYCsUU8 EdKhXjym037VQFffs/4Mfl4eIcZGB63ySxp9jYY+Gyq+8FeakOyYZbFBPDPnS67Y5ef0 0h12vGuuQlz0AaqplqC4X5wlrpVSzGe9fKElhGCp80FX31kzZlYOhHwjY3W3Ozvx+Y+N gBiNePJdtw+Ziz/LvOovI1mt/ecjfymzVupyjKdIVDkm8tXLMJIvHhm8yQ4/P8rEHGQu OWabWiPutQGFvDH0AinlqtyrgLN6isgQVlYxgISfS4T2DNFV9moMcHX5V4FoiFYymsra 1t6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lpyrraay; 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 t19si21261965jac.62.2021.09.27.19.15.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:15:42 -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=Lpyrraay; 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]:43552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2ek-0006MY-18 for patch@linaro.org; Mon, 27 Sep 2021 22:15:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QQ-0004aA-OH for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:55 -0400 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]:34720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QL-0005gi-Es for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:54 -0400 Received: by mail-qv1-xf31.google.com with SMTP id w8so12509590qvu.1 for ; Mon, 27 Sep 2021 19:00:48 -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=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=LpyrraaySanQF2GUjk/5s5JnULXcI73CZNwInuCI8pFvazTD9QjXOJ9/Isjne6xb8K BlY+Mkq5eOjyvPn19B/xSm2VKvWDm1kQKM5sVFLAREvdIYz/teFQ0IrmHFfpt/AFrqhn Cc0BKI/mHFYfJU9MRsPvt9lBa1udVnSN6rLoxHiHwoGcgNr+YEE4SF7gN11FkZj3Rj06 Y9oM6kq3QhHMANKv2CmBZgcNZidQK6GMO8FusKW1fTVDAtkp9XLcdWGGsoT0v686H33N 6lxqxzlI2dScJWr5LRt93c6DzuiHIrwmocjQnDY34NkpaDFlyhBiM2Cispr8UsFe53xb pncg== 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=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=jVikLN7nma3Hsm+/IKC4w+gSF6qNtGtZzA1fmuJ+KokPh4OPHYYxS8flfBL4IFeFjB G3/FxLSlhWMHSzo5b8H2mMfSaPAecffk7cjgbCZik08svzSwTdZLUEla3eHcmqlN6aEM PgdfYU7pMD2EDvjoka0WRN/bBa+SDstncr0D7wbsn0903zq5zL35X9KfOAKjxF5sAiUK wQyuTuFoI4kZ33zld/h2GvH3bE6xNk3WUiuw007YneDkQw/+GkvyxO6UmmrB/NmrmpOl BOZ6HQsp0Zge/mb40XCti/j0rjXbNJ5BeYqTd5gylhHmMbKRH/v+4hB9JOsnQ5selK0l jpvA== X-Gm-Message-State: AOAM531gMXcjVg6c6M/cbg237j4tJuMudG7YF2MsoA8nZGc2Hj/2x+Zz dOONW8jfnjsXD6u8m6S4Ei5hKTCbfrTu/g== X-Received: by 2002:a0c:a915:: with SMTP id y21mr2943216qva.55.1632794447680; Mon, 27 Sep 2021 19:00:47 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 07/25] linux-user/cris: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:21 -0400 Message-Id: <20210928020039.184412-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f31; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf31.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , laurent@vivier.eu, "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split out setup_sigreturn so that we can continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/cris/target_signal.h | 2 ++ linux-user/cris/signal.c | 29 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/cris/target_signal.h b/linux-user/cris/target_signal.h index 495a142896..83a5155507 100644 --- a/linux-user/cris/target_signal.h +++ b/linux-user/cris/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 /* CRIS_TARGET_SIGNAL_H */ diff --git a/linux-user/cris/signal.c b/linux-user/cris/signal.c index 2c39bdf727..7f6aca934e 100644 --- a/linux-user/cris/signal.c +++ b/linux-user/cris/signal.c @@ -97,6 +97,14 @@ static abi_ulong get_sigframe(CPUCRISState *env, int framesize) return sp - framesize; } +static void setup_sigreturn(uint16_t *retcode) +{ + /* This is movu.w __NR_sigreturn, r9; break 13; */ + __put_user(0x9c5f, retcode + 0); + __put_user(TARGET_NR_sigreturn, retcode + 1); + __put_user(0xe93d, retcode + 2); +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUCRISState *env) { @@ -112,14 +120,8 @@ void setup_frame(int sig, struct target_sigaction *ka, /* * The CRIS signal return trampoline. A real linux/CRIS kernel doesn't * use this trampoline anymore but it sets it up for GDB. - * In QEMU, using the trampoline simplifies things a bit so we use it. - * - * This is movu.w __NR_sigreturn, r9; break 13; */ - __put_user(0x9c5f, frame->retcode+0); - __put_user(TARGET_NR_sigreturn, - frame->retcode + 1); - __put_user(0xe93d, frame->retcode + 2); + setup_sigreturn(frame->retcode); /* Save the mask. */ __put_user(set->sig[0], &frame->sc.oldmask); @@ -135,7 +137,7 @@ void setup_frame(int sig, struct target_sigaction *ka, env->regs[10] = sig; env->pc = (unsigned long) ka->_sa_handler; /* Link SRP so the guest returns through the trampoline. */ - env->pregs[PR_SRP] = frame_addr + offsetof(typeof(*frame), retcode); + env->pregs[PR_SRP] = default_sigreturn; unlock_user_struct(frame, frame_addr, 1); return; @@ -187,3 +189,14 @@ long do_rt_sigreturn(CPUCRISState *env) qemu_log_mask(LOG_UNIMP, "do_rt_sigreturn: not implemented\n"); return -TARGET_ENOSYS; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + setup_sigreturn(tramp); + + unlock_user(tramp, sigtramp_page, 6); +} From patchwork Tue Sep 28 02:00:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514743 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4696226jao; Mon, 27 Sep 2021 19:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzysgrgdGK2B4lEh6To5R/J+4PO47ddqyVlBnDigmIwno7CIsTrGvDMeas8UKfDMIfxRxRA X-Received: by 2002:ad4:4629:: with SMTP id x9mr3055038qvv.58.1632794879767; Mon, 27 Sep 2021 19:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632794879; cv=none; d=google.com; s=arc-20160816; b=wER+jKAmmPaph6QP7vn3evNUqJHfU8nxFPXo5A+k+lSM22+B862S11edF4YOvd99GV viGRXi0hZuXsJciBezp+jBntMaRTfQ6o63DD84LVxWc6jW/JyRgiBQbO4+DJADDax9a/ b8Ym9hWLpghqPc9czXb+mTnli/zxNktXxrHO/XyGmAarP7kwAVLtrFsqIESNwUet2n/b iBqqIs/BpKg5UR14N7YPQnLCttmvIlWnOWL8gOEI1dsUZmw4cNj/V9GDpIgrRlbAruex njaUFEJFYrfbfdypD7F8Y804weu4YXWst77qPmcgiOYOH2zjTLLfYu2/63IiSnl8zpis Pz3Q== 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=1f4aYpKsB+ja4QJ7hAEtER7A5IlRmh/mgnhLrHPEyy0=; b=Wi+BOEIS3ArxaK9RJW+8xukVSagrMrO0qUE5QXQUdsAe76iN+fB5QWjlZmM0MeU7CX V8NWXObWTs/vq0MNWMRjcs2etTKNnn12bBR3jIVvUQWWZkDayKUJsrBLfnfXtcZMw0R2 RNPggNWfoRPN3fMt7k15fQD3M5suCoUA5yedWI8wH2QNIwvx/yxEYi8QsxRxBoRj21Y6 8xGCCR/GDnnWqjH7agXwyoQPtmLLNDUC7ofBu4CrVn/u9i1xMCVbYRyPjqBtsfgzRuuQ Neu+Y2AKxJnzo3LMzezyBQrJfPDGR1CeVy7g1mWZ4o2VVhlMR9xRPldRXmPLABgRfksd kagA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="JmwpBSC/"; 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 o5si11405710qtw.76.2021.09.27.19.07.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:07: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="JmwpBSC/"; 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]:53474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2XH-0002SE-4u for patch@linaro.org; Mon, 27 Sep 2021 22:07:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QT-0004cg-Cg for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:01 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:39525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QL-0005hf-FF for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:56 -0400 Received: by mail-qk1-x72c.google.com with SMTP id f130so39079076qke.6 for ; Mon, 27 Sep 2021 19:00: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=1f4aYpKsB+ja4QJ7hAEtER7A5IlRmh/mgnhLrHPEyy0=; b=JmwpBSC/6IDY0zjOmFDq0MFGYtgVaeUZpBt1O0spFK9O2OjmPAJ7Piy6cpK31Saaw4 o6IPPE4AQj/mMj2TWXZnQTHjjtr+1tnldK249suwbYuP+BwRNDq919jGS3N2Q2NOhChF p2I9jfuvGXCHUKfINBRligjgIMSlDmkhhtc7THtDA75uZENGt3z/qMmOp7wlmEEzDIYn ZKGBIn/WI9aX1BOJp8bqxhW3bN8nAo5c92CocWgWh8Aj9WXsXmOeILYLx2oXrZ+Iv5TW IvcbS001hOBeI0CMg2PZ6nYouf7d3X2yZbl57QR+duBFfo/BaR7rwVcEN+KohW77LYSU myGQ== 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=1f4aYpKsB+ja4QJ7hAEtER7A5IlRmh/mgnhLrHPEyy0=; b=STsCppXauKvosIELkSyy1ZPDR5gNNvWTfziDymb76lrMuVaFY0S98Qf/mFL6njp7Uq S8y9z2fDW7cQ/4XzgSQ7/TtNyWw4+BlbCIAfJOyTY9ZLViaR3yMOFcAL5NDreyXsr6k8 ehbL36pHswh6/hOeSHlWSt0j2BSIfBLlazsw924HDlRGLm72bVYCHoLITg0WLwj/n4vy r3GtPUBwfjeBjCGTEFgyQBAQMkk1GDsOkw5GljrZ7EYWx0NO3XozqY3pnHTOQE3KQCdY 1SKE3mDPFDTV92AZ1wHQD7aUaVJp9LgWck+/eNkEegKsnyhkGhOI5BKBj9zEYEk2kdjj aITQ== X-Gm-Message-State: AOAM533NFZHDrQEbJewQFikNds5CCDqHD6tTqAT9Gx1UzaEg936PLfa3 2gozPxV7Z8kLBe/68s94XmyuA4mn3brzmw== X-Received: by 2002:a37:bc85:: with SMTP id m127mr3147429qkf.119.1632794448566; Mon, 27 Sep 2021 19:00:48 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 08/25] linux-user/hexagon: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:22 -0400 Message-Id: <20210928020039.184412-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72c.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, Taylor Simpson , laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Reviewed-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/hexagon/target_signal.h | 2 ++ linux-user/hexagon/signal.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/linux-user/hexagon/target_signal.h b/linux-user/hexagon/target_signal.h index 345cf1cbb8..9e0223d322 100644 --- a/linux-user/hexagon/target_signal.h +++ b/linux-user/hexagon/target_signal.h @@ -31,4 +31,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* TARGET_SIGNAL_H */ diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c index c7f0bf6b92..74e61739a0 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -162,6 +162,11 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); + /* + * The on-stack signal trampoline is no longer executed; + * however, the libgcc signal frame unwinding code checks + * for the presence of these two numeric magic values. + */ install_sigtramp(frame->tramp); env->gpr[HEX_REG_PC] = ka->_sa_handler; @@ -171,8 +176,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[HEX_REG_R02] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[HEX_REG_LR] = - frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[HEX_REG_LR] = default_rt_sigreturn; return; @@ -271,3 +275,14 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 * 2, 0); + assert(tramp != NULL); + + default_rt_sigreturn = sigtramp_page; + install_sigtramp(tramp); + + unlock_user(tramp, sigtramp_page, 4 * 2); +} From patchwork Tue Sep 28 02:00: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: 514748 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4700133jao; Mon, 27 Sep 2021 19:14:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDIGHeMV9s9QNmiRHNvoddbvHsgYhUXEPr3t0VJ+kqXyvTENkDyZCwu5XJW50xSBI3++NB X-Received: by 2002:a9d:1708:: with SMTP id i8mr2865856ota.233.1632795257218; Mon, 27 Sep 2021 19:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795257; cv=none; d=google.com; s=arc-20160816; b=wKurNL0grWFg++29q7n0TbrMkKEeDoccL8GqiizlH/hUVl9joKbgcV8wBnw6jzQdsm eymGTykeI6brZwC/mCEpqakQLm+xsTlmtI0cq8cMHATStnQlXsyIrAgHpO4N7BupbCeB y8IMNbrNbDuQYeamggy10vqrNVtjwg4WX/SrWS6WsE299x1E0U5I64J//mEDy2qYW+4Y 9g8PwIP0YZkuB1nKaYdeCDIDDRaQy0T21+XbGaAw26l0MKamoWGgymNHq/rm/4l6aY3l ceKP04+BmDcZVdBvM3MJgnIWwTyDmVCFtlNBHYpfCWMxylAcK2u2ugfTLXhC8UzYzJe+ 0A6Q== 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=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=dI77e9CehbzaZH1UwWeCExDNKM7AMNmu6dq6FHp9vmjAVGuIhnW7dRNio34Ff6yUWy OGQGVyl90W0M8EOomZhsdS07nO6C2mw6XtvTtbh0PsbcCFzWS2izKkaX+m2z+/JOa60v iio3bHqhfSQuULwad3fQ/Ey92t8CpfhrCXu0Ct20vrlCpLnSKb9Mcqi0f4T4CAukI7I4 fh/AceNYS4ofy+zW/cLrZAvWItsSGVHiu5om3/bvuVp4J5eiDU88q2VJHYsMD2cZjr2A 3JpujHovlArkcDTqjTam/33Rgn6VYGRdv5jm9FpXS2vMOYX77oI/xFXg4GkMlU7Td+oH eqjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Y7MyHPqd; 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 l11si23268365otv.101.2021.09.27.19.14.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:14:17 -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=Y7MyHPqd; 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]:41136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2dM-0004kI-Jc for patch@linaro.org; Mon, 27 Sep 2021 22:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QR-0004aL-Bn for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:55 -0400 Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]:37661) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QO-0005i3-9a for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:55 -0400 Received: by mail-qv1-xf2b.google.com with SMTP id o15so45064qvq.4 for ; Mon, 27 Sep 2021 19:00: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=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=Y7MyHPqd0zxKUoYZH3onKJDxhHXNCeQs+ORL1n7MWgm43lZLlattGstOihEANNIMop JGy7mSI+34LQrNaI30Uec9NCuwrMC1rCzpuZiZcg5AuaEx9xrZ88+FVCrZ6WT5oybavI xbT7oSKCzuJ37okPSaQFu8Rgj402L+AKokg4bSSOBRFCDeOx0saXs30+3ZloHdZdow70 fM3LVqypVNZkmIFvdS0rRqbGTYQ+CiCO9cOq7+bX2i8oGFcwDINYbp63gBNusD/1z9KA uZ3XUW6fhB3CuHTdJNauOBYT1zCdmY27b/y7Ets3Hth1Jps2sw/i/aVIjbvFSpOrtvLZ m87w== 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=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=35b5h/p5wQyYbXS/Iqr5cn6/cvbTXrPdAhCuYhuygtetQr5sWW93x+McLQ9LXdIhra 50gFKvnSdXJsjEZZByp/hiB6jC9sAXIUy1NAQyq64/FvkMpTrg67mJnWEesAjDjKzAYS 2gGffBYQ7D5oWrNl5TOj+Zk6pYIJAkuhYMKbkukpNpsbVmiU4ckzfihYrRObqJDtSx+Y SAGzhULo8e8P0ZoArKzTG5sv8k2usVFZh+jXB2/OJ7Ea9RI2s6YhPozlGfY4yyiMdWNg ZGx+R1ZsBt/ixLXA25NNynvOmdgykQS3WDakIhZ5sPwrTGnP1C50P9XKcgd9oUyB9P7+ fDow== X-Gm-Message-State: AOAM532uicwX91EgJSKnZzZSlh1VrJCj73dLk/RPiSXNbcvkK7kndCOs qc8aLKwMro0ryb3SHwM6+MIoS8oARwnVeg== X-Received: by 2002:ad4:4a93:: with SMTP id h19mr3358510qvx.41.1632794449535; Mon, 27 Sep 2021 19:00:49 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 09/25] linux-user/hppa: Document non-use of setup_sigtramp Date: Mon, 27 Sep 2021 22:00:23 -0400 Message-Id: <20210928020039.184412-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2b.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, =?utf-8?q?Alex_Benn=C3=A9e?= , laurent@vivier.eu, =?utf-8?q?Philippe_Mathi?= =?utf-8?b?ZXUtRGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We cannot use a raw sigtramp page for hppa, but must wait for full vdso support. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/hppa/target_signal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.25.1 diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signal.h index 7f525362e9..d558119ee7 100644 --- a/linux-user/hppa/target_signal.h +++ b/linux-user/hppa/target_signal.h @@ -71,4 +71,18 @@ typedef struct target_sigaltstack { /* mask for all SS_xxx flags */ #define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM +/* + * We cannot use a bare sigtramp page for hppa-linux. + * + * Unlike other guests where we use the instructions at PC to validate + * an offset from SP, the hppa libgcc signal frame fallback unwinding uses + * the PC address itself to find the frame. This is due to the fact that + * the hppa grows the stack upward, and the frame is of unknown size. + * + * TODO: We should be able to use a VDSO to address this, by providing + * proper unwind info for the sigtramp code, at which point the fallback + * unwinder will not be used. + */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* HPPA_TARGET_SIGNAL_H */ From patchwork Tue Sep 28 02:00:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514742 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4696194jao; Mon, 27 Sep 2021 19:07:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykRgs07iCbcIlJoaMgOSULkrFGi+POzdh4KG68bWMP1h8t4E9c7fx6KbroaLB3ybqGfD+B X-Received: by 2002:ac8:4a16:: with SMTP id x22mr3215942qtq.253.1632794876947; Mon, 27 Sep 2021 19:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632794876; cv=none; d=google.com; s=arc-20160816; b=veEIx8ZuKvSr62+Od3mepDmAX3TMT9jhsSqTKMkK6zmCpEXBjo9qgrtcjgEm7H3P/j NFE9937ztCcm/wMejcEu+4ffFLnj+6xKOgcp6AZo3rDhX3PW+DrdbYenTFgN+3NDeZgL IRkciQ46sBroGV48KfQ91hVrEsUemmQsh4CVre3Gjyo/wmqzLvUKVH5NS4l8DELEgiOe tLE+gXTSLP+0T94+tueB5fqrTbs3750Vtg87xbmoAFB+PE2Y7On8NRvmULB9WwvRCtgt 1PURkWSGRF76eDdw5S/zhuMQk+vgvjqnhj5CXqCU97IytS6Y47TLNViAkD4Mo4MWxooK Vuuw== 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=5QYt+lT4ScAusNQ+/GzAnI366ZRjwM4LWiOtotKhJfU=; b=KjhOCfPMcSqX8lTfpPJE0aEc4dCt3BnWAj5+zD7Oti2knriFn7OhkmnsNalIG9jNc4 36i9a3+3LAMeEof8jqTJ2nC30BrSSQDahfcFWSk5jvPa6ncGVgsg3eHd3suXsDUCI/9p pTU5roNKrEWvXfsXB/85vqSv3IvO2AVPgg3ml0agm3p02WH9xVnTpsUfx9Gxy0KOYsey XwP1w4aIkLOZlfAurR6adRXOT7BFHxjfPVh7rvk52TMVlc/JZNm+8r7BGPw6aaloVQi7 Too/I1UswNxGlK06J4H4KpSW+8zUNzkzLxs0892sQlvmBpi0gU1gsz98BGP1xGRfcxVN uuIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GL5eZQAA; 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 d9si14761514qvh.2.2021.09.27.19.07.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:07:56 -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=GL5eZQAA; 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]:53212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2XE-0002HB-A2 for patch@linaro.org; Mon, 27 Sep 2021 22:07:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QR-0004aS-Fr for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:55 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:41710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QO-0005iP-AR for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:55 -0400 Received: by mail-qk1-x733.google.com with SMTP id m7so22267769qke.8 for ; Mon, 27 Sep 2021 19:00:50 -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=5QYt+lT4ScAusNQ+/GzAnI366ZRjwM4LWiOtotKhJfU=; b=GL5eZQAAWaZi+I6wrFeJQHOGB5ztU3S7aXox6h1YDsqKvxvhUH4i+VzNQY7LA8GVw6 /JcNKHPjeG8sD3BuvxnuhjVfYmFlA3CI0JFRIVxixDTYQZ5Ui3GJ2FzY55oTz6kmPEgJ 4XvPkDz/N7y1A3fqPJTpnxdKxCC5yKoiDfeA0ZFO2Ym/TE1vtUF6wUf2efe5qiOk2NZi XWs69iO0m2zFqD6Cf6UOsB7WnrBRTWYluMtlL4hQm1A+Q9yaeqsnA/PnPkQvv+TFf0tQ 5v+ctDeALfkovHccNxvh3CECbWKXDzqyyqgJxoq6TCnN9zBdLYxgi5/8C5EpvoP5gjpP Fi0w== 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=5QYt+lT4ScAusNQ+/GzAnI366ZRjwM4LWiOtotKhJfU=; b=J0m8b5tAO3EoHd2VV71RyRzNKIdwPrwKxB+MG9NqSEoEGa+sGPaGXD1FWBYxuzLt/n LxIIlJq4F0zgnTzkQHxt9Qc9DsQZGqsHfb+k8C0R+y3tdXJ8qPg2WMmoOLbiVdyXotiF 8SnL3S+NiowNvSUouBvRjJVmKpyqMac/Ik2yDxuiP5ebdGqKdQAP38UsIixZe6Hr995m 8qlgLtXcvIbWAQudrqK9NWhfZbJGCVYGWwgnQQsIoJnFRzK3rl7Uh2dS2MkkvNKru/GM gc+js/UY8NDDcumjvuAUQMiwMO7fyQ789S4+ZG3ZYePKdZzCslFZpl3LcfZeJ53fsgjR qn/w== X-Gm-Message-State: AOAM533OlI09nX8/DLXLc5n/DUEtoWOTrI37BfJ0Ye28Gk0s2yZBGJd4 EgADTTqarJL6Wg30iyfNmXGxB8WuULRy3A== X-Received: by 2002:ae9:d61c:: with SMTP id r28mr3162909qkk.122.1632794450327; Mon, 27 Sep 2021 19:00:50 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 10/25] linux-user/i386: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:24 -0400 Message-Id: <20210928020039.184412-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.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 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. Note that x86_64 does not use this code. Signed-off-by: Richard Henderson --- linux-user/i386/target_signal.h | 2 ++ linux-user/x86_64/target_signal.h | 3 ++ linux-user/i386/signal.c | 56 +++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 18 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/i386/target_signal.h b/linux-user/i386/target_signal.h index 50361af874..64d09f2e75 100644 --- a/linux-user/i386/target_signal.h +++ b/linux-user/i386/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 /* I386_TARGET_SIGNAL_H */ diff --git a/linux-user/x86_64/target_signal.h b/linux-user/x86_64/target_signal.h index 4ea74f20dd..4673c5a886 100644 --- a/linux-user/x86_64/target_signal.h +++ b/linux-user/x86_64/target_signal.h @@ -21,4 +21,7 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +/* For x86_64, use of SA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* X86_64_TARGET_SIGNAL_H */ diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 3b4b55fc0a..b38b5f108e 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -310,6 +310,22 @@ get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t frame_size) } #ifndef TARGET_X86_64 +static void install_sigtramp(void *tramp) +{ + /* This is popl %eax ; movl $syscall,%eax ; int $0x80 */ + __put_user(0xb858, (uint16_t *)(tramp + 0)); + __put_user(TARGET_NR_sigreturn, (int32_t *)(tramp + 2)); + __put_user(0x80cd, (uint16_t *)(tramp + 6)); +} + +static void install_rt_sigtramp(void *tramp) +{ + /* This is movl $syscall,%eax ; int $0x80 */ + __put_user(0xb8, (uint8_t *)(tramp + 0)); + __put_user(TARGET_NR_rt_sigreturn, (int32_t *)(tramp + 1)); + __put_user(0x80cd, (uint16_t *)(tramp + 5)); +} + /* compare linux/arch/i386/kernel/signal.c:setup_frame() */ void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUX86State *env) @@ -338,16 +354,9 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { - uint16_t val16; - abi_ulong retcode_addr; - retcode_addr = frame_addr + offsetof(struct sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - /* This is popl %eax ; movl $,%eax ; int $0x80 */ - val16 = 0xb858; - __put_user(val16, (uint16_t *)(frame->retcode+0)); - __put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+6)); + /* This is no longer used, but is retained for ABI compatibility. */ + install_sigtramp(frame->retcode); + __put_user(default_sigreturn, &frame->pretcode); } /* Set up registers for signal handler */ @@ -416,14 +425,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { - uint16_t val16; - addr = frame_addr + offsetof(struct rt_sigframe, retcode); - __put_user(addr, &frame->pretcode); - /* This is movl $,%eax ; int $0x80 */ - __put_user(0xb8, (char *)(frame->retcode+0)); - __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+5)); + /* This is no longer used, but is retained for ABI compatibility. */ + install_rt_sigtramp(frame->retcode); + __put_user(default_rt_sigreturn, &frame->pretcode); } #else /* XXX: Would be slightly better to return -EFAULT here if test fails @@ -592,3 +596,19 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +#ifndef TARGET_X86_64 +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp); + + default_rt_sigreturn = sigtramp_page + 8; + install_rt_sigtramp(tramp + 8); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif From patchwork Tue Sep 28 02:00:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514745 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4698502jao; Mon, 27 Sep 2021 19:11:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkwmMCwT0O+PXrdk6cv/xIaJdy9Klf3lsrmjUFng5gyvS0Zxch2/mUVU6L2yIXYA8eKSYZ X-Received: by 2002:a5d:87d7:: with SMTP id q23mr2105833ios.168.1632795092701; Mon, 27 Sep 2021 19:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795092; cv=none; d=google.com; s=arc-20160816; b=PBVi0sKhVx5Im05XLCBX3Iijc0s1FznCCtTUFhCJL8JE7QTvRJb1KppBRQavY2Ap6L pJj2ubYmvIBN90hStj0FTqUfHWSLbUusztQMQxOsuOfaU4s0qciVtRusurzDLZkFM25y vaEln2Z28JmuldTQYC4O34Z2zK+GSUPoXAsS7RAw1FuRBUrLf73a3+eXgfFbuucmKy8L Kn3TPxVP9/UYdrKfoZu/h/ODF99w4QbruPVAQ/yzjcWUsdYKXna/8Z0GSU/WLO3it47p 1WZLFbloZ4vcs8YNS0grmPXEGv9Op/xUAHZKBKKunm2rp4cTJv2tR9dYIumlCPLLQLHq LF9w== 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=vFT/6UTjn+SRrtv7SJvOboDTfiqpHPjXAVLEeQqZ7rU=; b=Bzx7r4TbnXI+UdyxEbX6ZuTjG6ZggXUFN/9zubG68Z5Kow1eG/Ia4pC8OCjTldkTDB 5vVz7qxCk+Bsmxpq6GUaF60c1n8QKeuEspvU2Qt3h31U/tPy0biFwAhIRF3K2XGWm+nX VAKzATwgV5/T9FYoCzAv3/g5iy9molHoEvE24s0IuYacv4rMG+rmV5xgxD7LW/vp3tz1 er68iEGikCOOgxsce4y7SRQUImCQfJTS9jH3s8+z+TWsnBz23fWbq4/2di9SMskW3Ga3 3U0iNYSROVQ+zpEEIxFtzDIyUU31+RePk6y35Uiv++3UDACbk+Jf13M5AxeqncwfO8G0 azpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vhBW82v7; 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 q5si14805781ioq.60.2021.09.27.19.11.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:11:32 -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=vhBW82v7; 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]:33322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2ah-0007u1-UT for patch@linaro.org; Mon, 27 Sep 2021 22:11:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QR-0004aB-2y for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:55 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:33355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QO-0005j6-BC for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:54 -0400 Received: by mail-qt1-x82a.google.com with SMTP id x9so18662277qtv.0 for ; Mon, 27 Sep 2021 19:00:51 -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=vFT/6UTjn+SRrtv7SJvOboDTfiqpHPjXAVLEeQqZ7rU=; b=vhBW82v745U/Fkr6KnOspKtirs5wywdpyArZYCgmuWjkE/vyQn4TfBvT5MUXM00da5 4Qge4nBoiNK6Di1eigSBPFpvLNRILThMFGz+EGk+4Y38TyIAYQdxqwCaar/S3mYtSsP3 uvI2wjIJuTUqLGxGradwajna4xlioeiiCcVY5O5zU6MpZRlF3QnTRHb6nIWhHlw+Qyz2 OLRNtjIYf9ARLIAFz3B4WAcfQwsdvSkEj8joQiEaL78Bk4mb97Zw2AX7o4YuEmkvIy87 jFNSOS2+hMGe+UDGBcwEV38SCxhmDkE9Mkj+2jYjWrER92/z0ccRsUXZ2CmWJIDzTniT Ebkw== 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=vFT/6UTjn+SRrtv7SJvOboDTfiqpHPjXAVLEeQqZ7rU=; b=1N+nmgq8sY0gFsz9NAPBRfyaHPl0TYWLZmmQ5JyRz2UzqD2uwqTox/2ICeYhEmMZBO O93t3FJ1tNgGGazwBA1uT5xpn3yy9ijQ4VQqobFwLEhagqnzbAODx6Bhaq1Jox1m3XDf bVivU8Cv8ChZ4x8iYN8IS4qdHcUyxdRWORex+E23reDaIinpFOdxDXNTwiRyGJ6/ZWvJ 7B9BNY6EdjRiWW0P/yGrhGOwl2aU0TvHo7RhejHhgzAiBrb/1Yc7co4ObMfBPqNpresG cRFNQNHEqBqIW7uAg3oUpeaYDIilPn65Es/EEkWuJI7vpo52fVlDLA6Mk5BbIUEyRxp8 OJmw== X-Gm-Message-State: AOAM530ICxTxMSh1OK7Ntsv/ziUeY2sBJ6Je4tHrF70AAL3JrV59TKTj qm/o1HaG9QyIYt2NJMquUdzf3u9Akp/jlw== X-Received: by 2002:ac8:4d87:: with SMTP id a7mr3130933qtw.260.1632794451232; Mon, 27 Sep 2021 19:00:51 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 11/25] linux-user/x86_64: Raise SIGSEGV if SA_RESTORER not set Date: Mon, 27 Sep 2021 22:00:25 -0400 Message-Id: <20210928020039.184412-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82a.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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This has been a fixme for some time. The effect of returning -EFAULT from the kernel code is to raise SIGSEGV. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/i386/signal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index b38b5f108e..433efa3d69 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -421,19 +421,18 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ -#ifndef TARGET_X86_64 if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { +#ifdef TARGET_X86_64 + /* For x86_64, SA_RESTORER is required ABI. */ + goto give_sigsegv; +#else /* This is no longer used, but is retained for ABI compatibility. */ install_rt_sigtramp(frame->retcode); __put_user(default_rt_sigreturn, &frame->pretcode); - } -#else - /* XXX: Would be slightly better to return -EFAULT here if test fails - assert(ka->sa_flags & TARGET_SA_RESTORER); */ - __put_user(ka->sa_restorer, &frame->pretcode); #endif + } /* Set up registers for signal handler */ env->regs[R_ESP] = frame_addr; From patchwork Tue Sep 28 02:00:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514746 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4698626jao; Mon, 27 Sep 2021 19:11:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzKkerYj+r7cUt6ZAYEAdEOdgZsgtndK4EGbP9YAOfYJ0Ql79UNnpxW3tTPbJ+jovppDmf X-Received: by 2002:a02:ac01:: with SMTP id a1mr2385188jao.93.1632795101316; Mon, 27 Sep 2021 19:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795101; cv=none; d=google.com; s=arc-20160816; b=CzRto3ayHHaSbwuuWwaPJtOA+PMgPIjmKBFrVR8IEQbKelb1k2Sp7NG+ar1exr1sxo k0HKujY5lo/OrGQHPeF4u8CGoEhmcXtnSWdClsy+yojwOxkwjF93myGNiX0zlFvz5awn F8//WmtM3mGNXN+oPhzVXmrXke+P6tYSm/O8jYAwQoe1NhUCBxlfsjBl6lFoRnOQiU+N bTsgcgHDTYeq8qHeSL68JsKl9wH/VcVqSRhZC85tviOVndHrn42HReut6Gxb/1VIGSeF BEo8S8xWY08msO93iyKw158uSA+gHRDf4NENxK8KJ1yrUVjSjIoEOY6c6n5L02YcnFi/ 6z3g== 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=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=W8/h16c2b9k+Hs6ih3XR/fxZ+GV0uXnuIcPB2GfvtLpzmslPMGIWUe67+gSmhv3VXk oBX9ph7A74rpwoOvFsucW0K5DY8A8pt+B0LrhUsUnRMfOtpVhpjv/mfBYHZ5WS27I6v5 DJXFNu22s9YPAvyyE65SsKEoVnexuhRSc+ahWILP+7Z7n0U7uH4ywFpK64X8rrAj57qL mtzAnMHLwVeXQUwrG/6APFDBKT2fWEw3RAWj2g8DpXv18PjsX5vksajakr4QFKKnFo/7 qlOrs6FJo3H8skWEpKUh94g1EsXh+9rkaUZo1Ul21yVyYjL8SdxFsrM8kgaqJ7dzhgsw MoYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EjnPaKsg; 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 i45si17562348jac.83.2021.09.27.19.11.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:11:41 -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=EjnPaKsg; 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]:33892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2aq-0008H8-ML for patch@linaro.org; Mon, 27 Sep 2021 22:11:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QT-0004cd-CC for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:01 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:34659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QP-0005jP-19 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:56 -0400 Received: by mail-qt1-x829.google.com with SMTP id m26so7049190qtn.1 for ; Mon, 27 Sep 2021 19:00: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=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=EjnPaKsg+5LlVxNjdtE6ApwD1L80lVjhlqMYXUDq+/hcjeYUxAFWKsHjpeN7EVevnx lriOaxi5FZ7bm1nsbpAuqPYFX4FJL+wT48f3lOBgvllr05OWjcLsMU0HLqLQrZq/XpFu XSBkyGAsmVVuAGWDhJJKkP2p0NC3Pb/5CnboSW6n8jE291gM46GoDmnfTWBz5RyGQjli hyQrKcNCx8u0hM1OKZiHSEqx7eqgSevdYI+pHosGKJ4rT84Mfd0DJhlZquBFaEsRYIB2 0Sh59b0xWR1YM3Ju8+tqvt67nW2a11cRG7kNPcXuh1KVT2EGGINacjHhy0gwBWHwphoQ TrGg== 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=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=a9XBQFJXbRF4HFcYM1zc2ofGUKjZ2cSiz2Q+R6l+AV6IsnlF7PgkTM9HDV3A55M4r4 Fo4arlWDcm2JkNVWxNS7tVZ9w5FuL9RAN6tixtI5nF6bWFQ9zpD7zEAKaWpFddGhTaSo BN/zIXh8XeyJvlKzUvigG3HuERorJQXa6qH+L9DWouB0yBj26QZ+DUkOYqACSI975d/g FSCawCLNEgnYt1N8AG75OmZHOJrbyf4O4vZOKoXZ7Xb8TkOhlhM4Au/gRsgDF4/OxiHd y3FpgQo5RZWOor+LFCAackhcJzCu9cO2JKHnwswEBHZnYILuZ47Sw1TuvhHsUhe4J60b 6VWw== X-Gm-Message-State: AOAM532jIFo1sGSkJrOJ0SeYFhUo7lhrKZvr+nZcoCX6aRR7BKtOUmUI ScPcQsgTxJKLQNP68CzDJvRvC0oMyCF/FA== X-Received: by 2002:ac8:119:: with SMTP id e25mr3129005qtg.232.1632794452205; Mon, 27 Sep 2021 19:00:52 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 12/25] linux-user/m68k: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:26 -0400 Message-Id: <20210928020039.184412-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x829.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= 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 4f8eb6f727..ec33482e14 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -39,7 +39,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; }; @@ -76,7 +75,6 @@ struct target_rt_sigframe int sig; abi_ulong pinfo; abi_ulong puc; - char retcode[8]; struct target_siginfo info; struct target_ucontext uc; }; @@ -130,7 +128,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; @@ -152,16 +149,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; @@ -288,7 +276,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; @@ -325,17 +312,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; @@ -411,3 +388,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); +} From patchwork Tue Sep 28 02:00:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514752 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4702230jao; Mon, 27 Sep 2021 19:18:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvqojOhYwlDzV7UKxUC18+mu8YEnuX/FNeaAEg1OW/BviVq9A9QH30rrgmhFLO8jsSXgSh X-Received: by 2002:a0c:aa5c:: with SMTP id e28mr3073000qvb.2.1632795480873; Mon, 27 Sep 2021 19:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795480; cv=none; d=google.com; s=arc-20160816; b=LB9apBjDsotvk6pTLq/8lCR41h2hXxVEmNNmXAINFKqvFezzw7778jinT4m+6f4NOF jD1gINi2KMmu0X7M1a2QaG20HwrV3pTaGvYvjbWaIonqq/jwdlWBgfzUvxgEkouUJT0M uzl4Iam+lRcxW2eziPtW5iR91SRgY+WxomrpvuHz3LQYGaTFauxNds5MxrbOr6ZO3Y8h UAgOwUBCl6Gj39mmqIvQB8oRpiWZ7drL7LO3GgJy6eGUSnc4Z2uy76zq57z+rx/8eWIG gwsCANxtjm/JgOJK3wswWDYJ7+cCc+iUT3opVZ6DCLrdaSkPwul4MU7EfyDzQkN6PNMK GNCA== 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=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=b+9ddB/jy0z9C8FFlwHYlTsv8/Zw5Q0B10AOxLHnQFCpnMsarO+7SzMZVaLIdPIM98 s0Y/K2lfMz82doU7W9eSDkQRtXLXuzH9p1BrCyDp4ciU0QeD4csAiCBY14epM7Vcof9d BTF693AywgnR8275fKpcap6cG/Ho1EACjeCVcunhlw/iJjnDnHbpnfdqS4KzyPTNqmDZ POoj3F38YsWhH/1DqXYvjFicEV37wSbUVB5KPfXQsQkfXy3AYQAGSfvTkUpzB+TUp+AB s/A2x0Xjtpx78SFBCJhLBWvikSL5uVtQF7aot5bLwXJ4cjXVEiRPkMutta1fbca8qqoI q3SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xRRYgDrY; 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 u65si13554347qkd.50.2021.09.27.19.18.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:18:00 -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=xRRYgDrY; 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]:49472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2gy-0001y8-5B for patch@linaro.org; Mon, 27 Sep 2021 22:18:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QT-0004ci-E0 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:01 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:35632) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QQ-0005k2-GL for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:57 -0400 Received: by mail-qk1-x732.google.com with SMTP id c7so39335636qka.2 for ; Mon, 27 Sep 2021 19:00:53 -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=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=xRRYgDrYy+28W5H/JqYLpHcRbgPZe422Xzv10xG1UAcBRpkjVCiMZBdin3xjz3J0Xr 8U/iP94NwAbPZvfbMqbQFaZKMGwkS/MCULq+qS5oLSAoDLrwHfk5YAPxYHiwr011i5kw V/PgW3HjbPjF5TtxpVWlorxmYZEcZv3TPByvTf0SlXm1MnaPUJGRm+IUQ/mCNcHzqFhc DKdryauXHcbK7e3xVX9dsixX7KX+yvCGYfSgCLWJhM1H3O27kgyOF7sHKA1bPxPLm7nl hDsAxk0aZDCYWy4EKyrbyLzkn+LHZf1IqWB8Oua6aGXszfA2G+n2BEkjwuSApbFELaRd lpsQ== 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=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=QWPMh7ASEKtuibkU0m0GjAtNigIkrtSrx7+BVW53FhUiteg2IqOLnAfAVn07rNNDZw dHm4aBYjckeUHhrh/WBeiF86inAocBIT3HxB0CHe4J56Xz4eIe4vxBauzwB1beM1v0t3 YeKe46FQ+AmYY0nWvCFO1iV4wASM8tMYqE29ike5Fpp8bG+61DvxsKK7jPpe943xmbkk PzheL0KzBGlIIesoer3DE1HuW9FY/P64E1LKGYr0UjtSHzTgwlCXyLaakchXaHeny+Ot 3Aqi4qrtG3ll4QssZeENrWPntbjeb25x/A0wOwm0vjzQ/hdlfUJQ4SYWXdTmMoBM9kr9 +0tQ== X-Gm-Message-State: AOAM531dIs1aPq8HRsDZCkaPZKKQkSkat3Ae1hLApXRj4QUaDiuCDK1W jRB+clawKRCwY69ymfwpImjnPDYPD3S0gA== X-Received: by 2002:a05:620a:e12:: with SMTP id y18mr3176578qkm.464.1632794453015; Mon, 27 Sep 2021 19:00:53 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 13/25] linux-user/microblaze: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:27 -0400 Message-Id: <20210928020039.184412-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , laurent@vivier.eu, "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/microblaze/target_signal.h | 2 ++ linux-user/microblaze/signal.c | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/linux-user/microblaze/target_signal.h b/linux-user/microblaze/target_signal.h index 1c326296de..e8b510f6b1 100644 --- a/linux-user/microblaze/target_signal.h +++ b/linux-user/microblaze/target_signal.h @@ -21,4 +21,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* MICROBLAZE_TARGET_SIGNAL_H */ diff --git a/linux-user/microblaze/signal.c b/linux-user/microblaze/signal.c index b822679d18..8ebb6a1b7d 100644 --- a/linux-user/microblaze/signal.c +++ b/linux-user/microblaze/signal.c @@ -161,17 +161,11 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Kernel does not use SA_RESTORER. */ - /* addi r12, r0, __NR_sigreturn */ - __put_user(0x31800000U | TARGET_NR_rt_sigreturn, frame->tramp + 0); - /* brki r14, 0x8 */ - __put_user(0xb9cc0008U, frame->tramp + 1); - /* * Return from sighandler will jump to the tramp. * Negative 8 offset because return is rtsd r15, 8 */ - env->regs[15] = - frame_addr + offsetof(struct target_rt_sigframe, tramp) - 8; + env->regs[15] = default_rt_sigreturn - 8; /* Set up registers for signal handler */ env->regs[1] = frame_addr; @@ -220,3 +214,19 @@ long do_rt_sigreturn(CPUMBState *env) force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * addi r12, r0, __NR_rt_sigreturn + * brki r14, 0x8 + */ + __put_user(0x31800000U | TARGET_NR_rt_sigreturn, tramp); + __put_user(0xb9cc0008U, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Tue Sep 28 02:00:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514751 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4701769jao; Mon, 27 Sep 2021 19:17:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvhLnS8a4GMni5E4CMaDzqejYLHCmxjdvwFiX8IARxixay+0mgr2BNjS9dVSXhfbIJb9Y7 X-Received: by 2002:a0c:ab12:: with SMTP id h18mr3342263qvb.55.1632795427750; Mon, 27 Sep 2021 19:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795427; cv=none; d=google.com; s=arc-20160816; b=RGCR/NwOHNQ/MNAQK/c9Fr9xZLgpXjQDg5Q5qGQkR/BxKOepJyVooogwTk28zPZX2I 6LCgyndaWRZtrKZIZR7uzSUlZbNavXxwKYAI1eAht4lZ7QlJbyQ9l3+vj0bsSDbz2uko pjLo5ZvRsXXhiPwwTu/jXf2UBd+fLmoi2inHIIbkVtWjtzQX5EBS/gS9GFDCMN1JTr4O 15y9L1RSXB9rz6WuTW01OXRJUwzMxUBGJ6J+WvLfqyeCg276jNisZKvuefrHQL3QM72n TjbB6vzN9fDYhcGr+kp26aOEcfvMo8d/kcVhZMvtRsUVu/CN+EBQror61TqjOWPDGy1R +kzQ== 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=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=ELZ/WYMjbTYhVEADUwzvQ1JAbpBgD/+meVk96AqxEPxv9J+0+2PjwQuuJBG9WbJBcB yKQlcf4h7y3qGjtp2hpXaL3IFC4UtQGlEfDBtaVQhRWDnFIzBHJPRKgOMEExG9JvAxMB bVxVuRywrOIy/9Rrt0sRN8UmOmKgh996S10SXO94INqgQJNO9NC43arccTpYWdAuV5tA iJIWNAloYDuuEyYrZTv6zEJnZTLWYUzMtMA15nfLw1cS97BPYuVSXhcah9huUHYNEslt Pxltg7kP2AEXut7+iRGfyhiqj+p4YbEnAK1q8UqWUs0pB7uTiLPa8/LUwizqvPa22cl1 sT4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YGa3VXgn; 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 jk5si16609826qvb.26.2021.09.27.19.17.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:17:07 -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=YGa3VXgn; 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]:47490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2g7-0000dt-7I for patch@linaro.org; Mon, 27 Sep 2021 22:17:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QX-0004dh-LB for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:01 -0400 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:38469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QQ-0005lQ-N9 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:00:57 -0400 Received: by mail-qk1-x736.google.com with SMTP id q81so35435937qke.5 for ; Mon, 27 Sep 2021 19:00:54 -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=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=YGa3VXgnsv1ZhAKLGxpTNhGV1j0LVxdubi9hdKKWCT44kE/8Ux7nh0+yT/abpmYAbW A4LsWdffxyBAQ/k6E2Fhwyol/HakzYOgihe58NxsbC2Ns9VMp8A21w7adHe8X5OQWetb Czab4BcHcpKTChCtpOE7qstALQf1e4MjWAvcIZP37P912TN2zMP1EOsDJUkurEUQOxG+ XWBwDQKMiuAWsroT56hHQRne5qSiM77Y3noFwgGNdkJw1SnRTp8EFdhCCUUTKVrECwjf wTJFKslRc/8sJUWJhsp46+Y13fxfUWaC1JwC/srK+QXn2UDceSOYKxbtFYJzle2K7VBi oHUw== 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=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=lbo3XJiW2xdq8RItqd/o8zm11bU9d5bO1zCcV+w0nsBOJF1bLY6MUvvCqy7rll/5S9 4HsbVNUeg/EZEV59wSbs87GmCo08kxLbvCsqhcmIIB4MbqhIkiW9jFmWAFsHUYmQ05RT TUqNQp3xcBdqLljlt+FgsenOntdDkRIpegJ6xTvcDRFGAK7QqFYIBCvddTz8qfIXTm1X jARxSxWspENC7vXB4dkEu4qR8bQnN9A8+HVjBz3HeFJgd1LfuaPNmDBZzjAbBr9k/lgd wLkV8EQO03DvfXa11KqoyudpxW6S371ps4blagUsJ09ADCstpwzXb9HEQh5lzxojU/IS JolA== X-Gm-Message-State: AOAM530hJi3oCzmE2VqH4oGah43RzGXKdQyXdsU8t1Yh+9JjYzLcnSGs 3ZFJMYPEDeBLKhIa0gG/FT2kuViZL5uiUw== X-Received: by 2002:a05:620a:41a:: with SMTP id 26mr3165208qkp.380.1632794453848; Mon, 27 Sep 2021 19:00:53 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 14/25] linux-user/mips: Tidy install_sigtramp Date: Mon, 27 Sep 2021 22:00:28 -0400 Message-Id: <20210928020039.184412-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x736.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The return value is constant 0, and unused as well -- change to void. Drop inline marker. Change tramp type to uint32_t* for clarity. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/mips/signal.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.25.1 diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index d174b3453c..64072779b9 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -87,10 +87,8 @@ struct target_rt_sigframe { }; /* Install trampoline to jump back from signal handler */ -static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) +static void install_sigtramp(uint32_t *tramp, unsigned int syscall) { - int err = 0; - /* * Set up the return code ... * @@ -100,7 +98,6 @@ static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) __put_user(0x24020000 + syscall, tramp + 0); __put_user(0x0000000c , tramp + 1); - return err; } static inline void setup_sigcontext(CPUMIPSState *regs, From patchwork Tue Sep 28 02:00:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514760 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4704514jao; Mon, 27 Sep 2021 19:22:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9ONw+L+bYue8o8zoezyHCFotoDYf1b8nmlQpwrP58PGJOhrqGjovJr/C4ySI7+02tHcUg X-Received: by 2002:a92:c546:: with SMTP id a6mr2451564ilj.173.1632795736820; Mon, 27 Sep 2021 19:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795736; cv=none; d=google.com; s=arc-20160816; b=k2WWKqu9dAaFKxOgVoiyPin7oBlAwM8cjPJuj+mzGuAHQY/tTzfLMBibOng0lSi1k3 CJllyYqgC+ozKIE3M/oUBR/V2C5fFd5/t6A2fPGfKIUCxtLmZGHA44lSE41dSUEMLqPD fZ9ujoK8BqS1LCHE2zufoUQGQlvDf1z9vOioQ4ZKnbvg7lBaslVHPCUo0/vfvVKGlHOY YIpqH4eZyIx5rBypQxHaVay3QFSiMxth3JM4V2NsC2tMCgt9j32+Mz5A0XcUKAwhHk8s ZIYSIxTxvUs6h+pIdVFxl/m/vUsX0z2IxRmytgKgc2odj0MtQ1BZ/XuYT65KNwA5uw06 np5w== 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=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=M4Xi9aiNIdHgTr0mxbXhdAtuEISkDB0HTivcm4P1mpwfhK0GaOCq+P5wNcvHujDS8m q4lM95mbFSMM5XfHEX6msHBRZ3Zy7xG4mWLDA4iYtZW96hwDUGR0ppFdWsml3MV7Ql2h ZfB2JyJHI7LhB9nZFno1ri/dkZKRp2r8rgUtN8ma6oJrbM2vC9AKGsIExrAaooJSGsMl kW4zoE/AuL/yxbiZvui9tFxd8ehFMKgdxhCXKUCA+Qclmocv0YrYAgd3e0qAuIYutsJP OUKcTlE60DuguayGzFHYdnjaoJoyPMR4fGz1R0d5r2Jw9iHNbJps1EEUMuXzPqnzh8qF oNRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WPRIRYLC; 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 p14si25208951ils.103.2021.09.27.19.22.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:22:16 -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=WPRIRYLC; 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]:58218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2l6-0007v4-Ag for patch@linaro.org; Mon, 27 Sep 2021 22:22:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2Qa-0004ks-Dk for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:04 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:46840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QS-0005nW-76 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:03 -0400 Received: by mail-qk1-x72e.google.com with SMTP id b65so38728231qkc.13 for ; Mon, 27 Sep 2021 19:00:55 -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=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=WPRIRYLCfCaQzirp5hA3CiEoBL+RiU917qfH8jMeY8Rikdcc8wDvL+m5wUL3ZSckQr /I+fDdlXkLeo4uW0z/Xw8t6vdJ8TlHvPm4zWHfpPWpcT3AsTZmqAa5g0JqaMf/wJjZHS NVHMZxuQwKqfCsEmupqhJs33A19dxU7u9VDhziPPZAM++kEucBXoJpESqVdDWFXUx4ft +DLF7fqlCdodjO4YYtKBnLrHdqilP5ygw09lAbQnRVrAc78QrohN/7VQIjKllw9aMogW A3Kzh49cLJsW5XtzPQWXGPHULELKj8+OXlmkxO3FOEMqzajZrY0L0iov+0J7Hmzstj9e scdA== 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=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=2Y1w0lfJq1OUL3VylhFiL449ZXha48IMBJRvG4cxagborRZr4r4WzPTTk4rLhh0sD8 1hHrDViDNWry5IYKcVaX6XaBczxWBXJWi8FKCqLbwQyKwu43ZTfQt5j/A3pooUXTzECa tNliHCk5q8wMkjdnU6PYySQixiNilCfktXNTFSvxLnbdXP5VBuMNybwFUsGeOPYINYbP BP1k97fVvqYNsd8L8C3gEyAU1VcD/m+LMNu9sciZI5rSieu1GdwNu3B7YMYBSGejP4HT VY+KE3IMQ0yOsvWPE1rr+PvBS6vnsy3XHQgj5NpQEujvONeRQQ2mkKWXL0bd42uRfNPZ mkag== X-Gm-Message-State: AOAM533O2G4o0EgjOfdEmAauuNiGfZ2NnJ02ANuNbSxzOr4YwxF3tQ5J kvi3TAKIlBMVwaphZu18mvCzWhrtZmrPoA== X-Received: by 2002:a37:b143:: with SMTP id a64mr3185284qkf.413.1632794454697; Mon, 27 Sep 2021 19:00:54 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 15/25] linux-user/mips: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:29 -0400 Message-Id: <20210928020039.184412-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= 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/mips/target_signal.h | 1 + linux-user/mips64/target_signal.h | 2 ++ linux-user/mips/signal.c | 34 ++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) -- 2.25.1 diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signal.h index d521765f6b..780a4ddf29 100644 --- a/linux-user/mips/target_signal.h +++ b/linux-user/mips/target_signal.h @@ -73,6 +73,7 @@ typedef struct target_sigaltstack { /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/mips64/target_signal.h b/linux-user/mips64/target_signal.h index d857c55e4c..275e9b7f9a 100644 --- a/linux-user/mips64/target_signal.h +++ b/linux-user/mips64/target_signal.h @@ -76,4 +76,6 @@ typedef struct target_sigaltstack { /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* MIPS64_TARGET_SIGNAL_H */ diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index 64072779b9..8f79e405ec 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -209,8 +209,6 @@ void setup_frame(int sig, struct target_sigaction * ka, goto give_sigsegv; } - install_sigtramp(frame->sf_code, TARGET_NR_sigreturn); - setup_sigcontext(regs, &frame->sf_sc); for(i = 0; i < TARGET_NSIG_WORDS; i++) { @@ -231,7 +229,7 @@ void setup_frame(int sig, struct target_sigaction * ka, regs->active_tc.gpr[ 5] = 0; regs->active_tc.gpr[ 6] = frame_addr + offsetof(struct sigframe, sf_sc); regs->active_tc.gpr[29] = frame_addr; - regs->active_tc.gpr[31] = frame_addr + offsetof(struct sigframe, sf_code); + regs->active_tc.gpr[31] = default_sigreturn; /* The original kernel code sets CP0_EPC to the handler * since it returns to userland using eret * we cannot do this here, and we must set PC directly */ @@ -305,8 +303,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - install_sigtramp(frame->rs_code, TARGET_NR_rt_sigreturn); - tswap_siginfo(&frame->rs_info, info); __put_user(0, &frame->rs_uc.tuc_flags); @@ -335,11 +331,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->active_tc.gpr[ 6] = frame_addr + offsetof(struct target_rt_sigframe, rs_uc); env->active_tc.gpr[29] = frame_addr; - env->active_tc.gpr[31] = frame_addr - + offsetof(struct target_rt_sigframe, rs_code); - /* The original kernel code sets CP0_EPC to the handler - * since it returns to userland using eret - * we cannot do this here, and we must set PC directly */ + env->active_tc.gpr[31] = default_rt_sigreturn; + + /* + * The original kernel code sets CP0_EPC to the handler + * since it returns to userland using eret + * we cannot do this here, and we must set PC directly + */ env->active_tc.PC = env->active_tc.gpr[25] = ka->_sa_handler; mips_set_hflags_isa_mode_from_pc(env); unlock_user_struct(frame, frame_addr, 1); @@ -379,3 +377,19 @@ 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, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} From patchwork Tue Sep 28 02:00:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514749 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4700310jao; Mon, 27 Sep 2021 19:14:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0WUYH9gZ6hjTGcPbI3CNw9adLfBgQPoFil0XtnqN4on2gagI/6WHsoFnCKtWbFKsa0MQC X-Received: by 2002:aca:5c3:: with SMTP id 186mr1715098oif.155.1632795271728; Mon, 27 Sep 2021 19:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795271; cv=none; d=google.com; s=arc-20160816; b=nFE0cUOS1nF5tbhQVahmkSXJevEjt6VA72W/Ok5ASbyU7bgOC+bykTbK3TJq8eKh1o V8GZ/wxWbnknD/Q0WFFvbEpSKyPnsnzgi32C5VViMiMWAtkX6rb4ZeZzDpr6BHSYwm8t Cc1U5XeezslGz6wrOsQRmXJ1nqOsa+wPsbKTRIhhZRzUDxsVbnDDrHm6R1BBP0YrQdA2 c/0OoxDODaS01cChElgmbS1QmyXXm4Mz4FMrdm7ziGUVC6fknQO7a5iwRSVhQ6ivz66k KqEet4qbtzapN7pNOCRKUFCd7hxAoxgBnaAoGRCd2IfJyzfdM5oB4NsJQNipsHl/AEga uIDw== 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=Axf/AlajWgYqNQeZh+H3y8dgIcJPGnXr8g5Xd1PG7h4=; b=qBBPytOOXHRIANhkzQioEvZKb4RIo59Cf+4Ap2qSuJ/2XPg+ioimNNHXvCWmndACjH ODSB50cKalfqf1y8lgqEBkDT6PpaQ8ts+vU4zdTBBSAU7TGVVwgjYprlKJxagZJB4KzA sKeLBWi3JRkDIbPLWpGarTfMk0PkVIiriVwbGy/D/Bp222CPLwO9tdmpTF0vT2JsszSl mLZWGzGxu1sCYntmBB1yHWYbSP3dcyVphIv+HQ8mtTPwGmat2qyG005Gwx58W+CuhAlT DJed974GZpwhfmjtY5mE2e5Oj3GEOxBCDiv2yT0IBvmKbhnMlkB0XRZkOq2C4Vcaqji/ DgqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zLwMOOmw; 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 184si19448977oor.70.2021.09.27.19.14.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:14:31 -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=zLwMOOmw; 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]:41696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2db-00058H-5P for patch@linaro.org; Mon, 27 Sep 2021 22:14:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QX-0004dx-Nc for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:01 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:36360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QT-0005or-31 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:01 -0400 Received: by mail-qk1-x72a.google.com with SMTP id p4so39281914qki.3 for ; Mon, 27 Sep 2021 19:00:55 -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=Axf/AlajWgYqNQeZh+H3y8dgIcJPGnXr8g5Xd1PG7h4=; b=zLwMOOmwfaByqnPGiFd98CpmvVqazxbNVR4bnNw1AYTdy2bslcHsLWM75va2RRGCt4 XdAgJSXa4ar3ILRYHWSyJysserAqwYeyRJea0qN/6Nb1pXKub8TVWxFSdB54VIphTC7s +klYq9WpbpzewramYCjz+NxzpulwSirzMJ/aYti9mmH9AYuZzR5l0J3kev64zBdrhh61 aleDzCGXo5aOGbDV9ACbxiNLDLfxybG2CdcCJdDCZtavr6x6vAdzP559l56wOeLbOL63 Cb6+UCT+W8Us7QiYqi8qdGyWOKz8Ev4WQqW80Q0kiY57tFrfMCoRIZplusoAG5+aqrCk QxMA== 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=Axf/AlajWgYqNQeZh+H3y8dgIcJPGnXr8g5Xd1PG7h4=; b=CeeqW4ZoKxnyjaUtbJQCxHqjWWxiKGuW9iniAHObUpWjJFg9vaZN0sqbyb8RKwJQN4 Jp5iY9fyyUz9m6P27s+zQC3s11GmJR1YzDfJDSv2nhIRhfmm8vN2Xi2bZIzJpUyRaj2d 1wSm+z7Vc3Kh0rAme8TjhzniWw7nDBk8IIn1H6xEGSufvCfeKgiDqW9kzOtp7WkjYnrV FPZkrFDbtcOM7CNTEY875a+fYIhvjoFu59uUhTXcyx0qnW4WtOHrik3eMws+l7twH61p EANr2/qdwn5s371ULrlBrXuKVGnYROSsYy9thZROQHNhRjN8yLxqX6YAlTx02DPzGdeA OtoA== X-Gm-Message-State: AOAM532BrgB2pxtSNPfzUlqWBFsGeLgUXvACXiIVievpOaoms549O6j8 m6s+UQ97+vcAYaKKYq9b+Y+6uuj4haICMg== X-Received: by 2002:a37:44c8:: with SMTP id r191mr64612qka.507.1632794455434; Mon, 27 Sep 2021 19:00:55 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 16/25] linux-user/nios2: Document non-use of setup_sigtramp Date: Mon, 27 Sep 2021 22:00:30 -0400 Message-Id: <20210928020039.184412-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/nios2/target_signal.h | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/nios2/target_signal.h b/linux-user/nios2/target_signal.h index aebf749f12..fe266c4c51 100644 --- a/linux-user/nios2/target_signal.h +++ b/linux-user/nios2/target_signal.h @@ -19,4 +19,7 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +/* Nios2 uses a fixed address on the kuser page for sigreturn. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* NIOS2_TARGET_SIGNAL_H */ From patchwork Tue Sep 28 02:00:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514753 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4702963jao; Mon, 27 Sep 2021 19:19:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSEWjKk415T7AWnbOZPNvhfOoFiUzDNRwA5J+SGCLPoQGPnNaciYARYXtWsWzkJFRtwGCk X-Received: by 2002:ac8:724b:: with SMTP id l11mr3249891qtp.109.1632795557229; Mon, 27 Sep 2021 19:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795557; cv=none; d=google.com; s=arc-20160816; b=E7JkKFnwFHpwe13TxE5UGYsZMNDbF3yg/X5mXsVvlg7NRkOpwVnmD/hO89OX/fGYMM 4kt1Kefqv2iaulx468HdfVfq88KQTZ5CVL4jpwGRp0VOh+VW8qZKR7lrOyTw+yO4yAq3 PnyU34AfVrWoJTbJqUgt3a6OzkQ0uQj3tyWNP3Hw30pmJjcmj0ymViDEm/j3G+3pvKuZ 5yBz5ZS0g+SZ15MmQiIxUPv4iY+erpeR2PrRD0FDO0ljxYrd7ttIrPgsRaw+8cvODyv1 4tAKeRqIDsvu0WlAYScw04ze+M+IWxgPMp6DFLYcBV7HR5CUdmluHx66LsRTp3dOCUiu jy3w== 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=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=pyGyVCe+Cpact716D4I12+z+ePgw591TzSU17qYUrbd+VsFowAsonIVzxEe+PqKU5c ukcpOiGAZ7c4LBT/eOT5ww4f794QlZPISqnQXlx+kEdAQEZlvYK90EWar3IrBupsHBPR PqDQBRS6aVtbMWAcnzDObTD85PgAbU2IDonqhRdvH3FocJZD7nMPgxS5VaFqwsxNhfaF Yp4RUA89YJcdy3xetgFyHKcPd36oLAnDr8SF9x8aWUGnzEUyhpX4eMVQK7N1PlR7m8SS 2LirhNFmN6K+Kv+WzguMiRNVOJ5oI3mVs0X/N4i70mCmWXDKZd9Pg2ShCniPoGkoezwN oWng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Uo7Pa737; 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 b4si11108447qvf.103.2021.09.27.19.19.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:19:17 -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=Uo7Pa737; 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]:52018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2iC-0003fO-Lo for patch@linaro.org; Mon, 27 Sep 2021 22:19:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QY-0004gM-IK for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:02 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:36363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QT-0005pB-E4 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:02 -0400 Received: by mail-qk1-x72d.google.com with SMTP id p4so39281954qki.3 for ; Mon, 27 Sep 2021 19:00:56 -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=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=Uo7Pa7379w9kxNJdhXZMHwr475yY6pDoJSIDMh93P/pFctZZpm9TRvpAcNghFJ2KWG JxDGcWyw0trOJ4hHuqSjsqH8986r+nCCbtjW0eXXaMiheDiyWDuvCOloB85dDECKrLeY wIQZdM9XS1/XSo02Hw1Zof4u8p2oKtj27NdEBywK2OLZ+SM1qCnHX6lsgSIjVmkWcc+/ xpkK1FfOwXVCo/W6AsmcKzz+BgJZ2ASxfmSQ7qlHTSN59VQi8Kq3Ss4aWJGb8hvIoJMQ /poP5twSDrm43nnIf9x21GnQqiJhcW4L4MeqCfPVFkcnphmxwA6XIHb+H1rm+P3+g+Cy rmEA== 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=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=h2XUFJmnBwEMHKBENEnC7rA0SbyHPflqZJESDNJSeqp2QkJAGswGHMQeo2+jw/YKjX Y+0fPv1FyJVZSxEaX+vrsMolbNQjOB4rUzkNikq5cYyBc7SlQ2tAm4tLscmCBhzXF9nj nYewR5iWG9B+si4SnlPYd6Wse3DDVM43GSQ477GA0jKzVdzqhI6mUeB7QTJpzVegtT7L 6Dtl5hojAi/z6oV+tIgnJ2X8rw/efX52TiCJFjDCBbt+Ynb6DLivAOdaUJbT4dVSm8p4 52cUEzwX790CO/J97yJK3KCX+cMEZHfnijdvZJjjGrOoYv57cXIOnzR5vpDMiVGbD29b 9Jew== X-Gm-Message-State: AOAM530Dc0sdagJcW3hTAPnqQ+8gaPhJ4vlXoy6YIkXYbyDXjM2GBG+1 8UHTsrlbXNvoyoC5POp5XPARS3bGdfzJCA== X-Received: by 2002:a37:e14:: with SMTP id 20mr3244194qko.250.1632794456364; Mon, 27 Sep 2021 19:00:56 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 17/25] linux-user/openrisc: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:31 -0400 Message-Id: <20210928020039.184412-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.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, Stafford Horne , 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 | 22 ++++++++++++++-------- 2 files changed, 16 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 ca2532bf50..be8b68784a 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -38,7 +38,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) @@ -116,14 +115,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)); @@ -169,3 +162,16 @@ 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, 8, 0); + assert(tramp != NULL); + + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1 */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0); + __put_user(0x20000001, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Tue Sep 28 02:00:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514754 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4703338jao; Mon, 27 Sep 2021 19:20:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6+NS2faGcD41NN0KXpwey6sasSFHYVfNlUGMDEtvrUygqC2zbQC6UpTnTEMJBVz9cg8ki X-Received: by 2002:ac8:151:: with SMTP id f17mr3079977qtg.313.1632795603311; Mon, 27 Sep 2021 19:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795603; cv=none; d=google.com; s=arc-20160816; b=jsCweBFu7zDGn9ajZMmUk0TxtS6qnN2J/k4gfPttES1ldxwx4xey9fAcgJ7geDJyYa C94lO8P1R4UGnAJIXUlu4e4cQ3AVE9hB+27fOM0vqYUn86t6hzU/jNHhSgO9P7fUrLGa xTllTq41EMIZiv9/sF6dO+NVKxmMu2rwTQEktuRax0Q7WbW0JyCR2h0dUAAfZVOLQtrW H1Cukb/11hIC3Xvgy5J/Ju1+FXWnFODCMj1Xrf/L+lsIzAC34ciZyovgYjvhomKw+pmE RNASfGowNFoOWX2S68dSqNVbjkaI1aiAzu0iVvycXnP5EIJTmYePqDHvoOv8tielKPeP ZidQ== 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=7zszFeWHoddqJiQjxDacbGdC0FlOhNlodUAD1GXKctw=; b=uoTwehGfPQJTEwQVDNChcpW834rIz7IBvymAWXG+TXJhMziZ4IFi1g5o9302ranNhI 1C5UDs10StYezqIfMTCG/vDYELf8kDZSJRRmXXbtYlLXaWi7yaKeRFP9bNOSuaQaCbDb I7B34x1jpKmcQ9dsqnnUhiKv+46ZTiDcoP2U1+w1f35Z1V8X3UI4SJLjGKaG2Lz8LnT2 GkBzlTbz+ECNm4NOtWDl8Esbn4E52Ci9L7RYi32r0VWccepeP+dIQqIfA+l54n10rjpS BMXlFVCN5FmL1R36Nn6VwRSTFA8KCZsOcj5X86aPUwcDraRDj7SaZag8mPmjPio9g7nT 2nsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tGw20w8l; 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 u27si1657114qke.228.2021.09.27.19.20.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:20: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=tGw20w8l; 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]:53756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2iw-0004pX-On for patch@linaro.org; Mon, 27 Sep 2021 22:20:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QZ-0004ha-3X for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:03 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:46845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QX-0005pg-5k for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:02 -0400 Received: by mail-qk1-x733.google.com with SMTP id b65so38728301qkc.13 for ; Mon, 27 Sep 2021 19:00:57 -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=7zszFeWHoddqJiQjxDacbGdC0FlOhNlodUAD1GXKctw=; b=tGw20w8l0lMbc2LveH9rZnYYzJbTd1hYpchi9+FBZImzseHjrnl9uTJiTDPmnUnvM9 4Ogntz4l5MYJXrykvFI71hnUlmBnhuT2i0Cdf6c3JVeW5Yt2qwk60JvlfHQGcYyyB1NX ub44W2m1lJ4+WutckZJ2+4wFnDjDdTY3zb2RyhIie2XMqSfl/GD0NnNwI/u6TpHuOU82 12JwJ368mAN6bNABWN7a6vTHzjj4/K8cG8ZEqUMvn/vg1ksm1ktmkVBJPz6YlsWo0skt zN43ph0ltBQ+d7sdZ7NYby4YPeG13vdvuwfgQLVGj+6NBohp3jALEgHRgNtwfJK4LD/H FC6w== 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=7zszFeWHoddqJiQjxDacbGdC0FlOhNlodUAD1GXKctw=; b=0u2G/sbZI0n8wqaEgxeMmOP1jiG0VlZytHoQ7+GzySRyzjqXaM4xyuvnrLM/vx0ywq cUM6b3fbeaB24rUfod6YOAspkNDnTBgMzwZCYGBIp6ycxcZEineCZY+oKC0fjC/DbI8E fRXMZcFFiI+nTnWw0x7RWzKZhUZtPIabrsW2OylL5uDZV1qJwfzjwOJW9MKpV5zVSB1A 0MZxKuI8aWQPeGW6KvQ0tA+aDUgmR4X/ZDJfQjoNQWAptFqMzlJWfF9wtBxDXIX6ceD6 1GrtO1RgEbXiuvfWOKuh1n+iExlRvUimQC99REKQISuUtST/ISvT8Tce0h/r4qaWxvoa EfcA== X-Gm-Message-State: AOAM533JiivkJaPM/S9r6B/xs5ZHZTkY44/YNbudSeB75qTvyN4OWqRV dgYtx+rWUwC5LDdClkHM5XM3x5SLHkVTKw== X-Received: by 2002:a37:bb41:: with SMTP id l62mr3030567qkf.486.1632794457219; Mon, 27 Sep 2021 19:00:57 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 18/25] linux-user/ppc: Simplify encode_trampoline Date: Mon, 27 Sep 2021 22:00:32 -0400 Message-Id: <20210928020039.184412-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The sigret parameter is never 0, and even if it was the encoding of the LI instruction would still work. Reported-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/ppc/signal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index e4d0dfa3bf..77f37b9f01 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -309,10 +309,8 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame) static void encode_trampoline(int sigret, uint32_t *tramp) { /* Set up the sigreturn trampoline: li r0,sigret; sc. */ - if (sigret) { - __put_user(0x38000000 | sigret, &tramp[0]); - __put_user(0x44000002, &tramp[1]); - } + __put_user(0x38000000 | sigret, &tramp[0]); + __put_user(0x44000002, &tramp[1]); } static void restore_user_regs(CPUPPCState *env, From patchwork Tue Sep 28 02:00:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514763 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4705855jao; Mon, 27 Sep 2021 19:24:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpesdKQVZpXo78atudI0H/LY3lvoG89gFRId811XCGc0nHCAVfLxi9D3ZJcX5VPZzSaVk7 X-Received: by 2002:a37:6553:: with SMTP id z80mr3147325qkb.42.1632795883405; Mon, 27 Sep 2021 19:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795883; cv=none; d=google.com; s=arc-20160816; b=hNl1qke5/FZJjljzabHTGT7u84xQKAaVwzfmCF5YQCkMStwIo6ULw2iOqswe7nkAA4 PZ1ectMfB9fEhpdF0UvaStMjds2vr4QxFWQ4Ko3ujTr9pIZKRvQOPBJCDdWhh6tGTWz2 eOA237ghgaWs8lLbFFL71+9AkXi7f7O/CooBN+XYaWJJnqHK22IFuOOS5HtnOZvyZU1r TyKg7NleZYlQz3I/YTSwP+cDInzbhLmq+Vf1qaKP2f+S7bwFTZmDmMN575vY4nJ2aoFg xlHeMACxA54WBPnS/Nt/sxVplOIjJb8MIH/NXxtadO0WztYzVDDyAx8nPQaWxzS+yHqi 9lMw== 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=MmSCGYIFzfMZzarwBYHnm0N3s8Oxz8OvMDOHLBQ9iBw=; b=iMJKejRHbJBP0nQ0zEc22A7JwiNbKtnGAbKynsYD4plTxZc087HSG/zWz9D2vRfPaN 3VGgmSNLV3Q7mKqhKU4FNYu54ygRuODR5ZOQ32jWhpVcPUuuemSUsEpODJ/9FrWuApgj NvIanIVQUNlA/uqzMyxAB2b5kNb598/WCq0z250ExpkAdDyOYHIeSFNcgWmFhHg9qmH7 nFNOpQp3STKS1N05mblh9YzfAlXEf1gmqRX4QZhg4aRIo6h8nLSmzNXqcMw6WkgC/+sX bs+vyZAvagFrVh4ZrTEyBZO55tc+GdfjXoVjezB8aOR+cuxkq3oFcGw3GYxEC24Wcvxa d15A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GPOgNSWj; 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 u65si13567268qkd.50.2021.09.27.19.24.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:24:43 -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=GPOgNSWj; 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]:36524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2nS-0003oB-S9 for patch@linaro.org; Mon, 27 Sep 2021 22:24:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2Qa-0004mB-QB for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:04 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:36368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QX-0005rK-8g for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:04 -0400 Received: by mail-qk1-x732.google.com with SMTP id p4so39282011qki.3 for ; Mon, 27 Sep 2021 19:00:58 -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=MmSCGYIFzfMZzarwBYHnm0N3s8Oxz8OvMDOHLBQ9iBw=; b=GPOgNSWjjNNRF0VqZN898vKjB2eCzkY5cfWSrvJ8IpE66kZnjB3//CR/p+Q51Da8gk qEqcYkzrW7078W9jg1yrjqiWZpptfp7ZqOMuKwtkdIlFjVOqy1wNVZcTsJqLCTg9SnUt 4bOhKD27p0n6MwUt/1aAc05uE8vUjW2s4i3Q0TXrsjswkM7PtOzmJ/zfsPGilH63GJ82 MwhMFNcPREgeodH6CmNyUTnNxLCxzMZjldWd4QYxCcod+qzTvQJIXWENiY4OPIeK0xtG UUTmRy0p8TQpr/4JXFnt11dNanFCTYsVGfURvYJV34LEe4GvcW3sR3Fo7qj/4uKBSjEc 8qlA== 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=MmSCGYIFzfMZzarwBYHnm0N3s8Oxz8OvMDOHLBQ9iBw=; b=y/hKwZlOY5mGzc5vK8N7AQ9+EvY4aWZgJ+iDS5ZFU7OAhU6VwABi3uQ+T4dGxWJW9X 7qR+EtV/F+yXYXs7ozRyaa2YoR2Ej+HJONtQ7X03H5qTSTOCtXskPSOHwC6gl5Ldwd9P y6gDzL+o3VaWA9787PflGPdzOadms4jy+atYTPTNESsPib3tYjj4hwobXOGVr/+CXXfq KRaCEFxmWMl/Q4yYO1DPwhVIcxaqkKb9vvF/ng2TrqMzs/bOQ0TA7LMxRLOFe9XJpY9n 1ZsQ9W7yk5lbtVp4k4OPMnnhgQ/w8CJwz3P/EBMW0sSQEbbJzpkG0BtvtxOhX7nU3diY IyQQ== X-Gm-Message-State: AOAM53302mO20sAOaBg6cOmJXWzr0IkFel3uyZgk7yHneggyreXDgaZi UOCN2RZfG3cDN3JCSJP6E7mJ67qC4twS2A== X-Received: by 2002:a37:41c1:: with SMTP id o184mr3127881qka.95.1632794458027; Mon, 27 Sep 2021 19:00:58 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 19/25] linux-user/ppc: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:33 -0400 Message-Id: <20210928020039.184412-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.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, qemu-ppc@nongnu.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Cc: qemu-ppc@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/ppc/target_signal.h | 2 ++ linux-user/ppc/signal.c | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) -- 2.25.1 diff --git a/linux-user/ppc/target_signal.h b/linux-user/ppc/target_signal.h index 72fcdd9bfa..82184ab8f2 100644 --- a/linux-user/ppc/target_signal.h +++ b/linux-user/ppc/target_signal.h @@ -24,4 +24,6 @@ typedef struct target_sigaltstack { #if !defined(TARGET_PPC64) #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* PPC_TARGET_SIGNAL_H */ diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index 77f37b9f01..c37744c8fc 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -203,9 +203,6 @@ struct target_func_ptr { #endif -/* We use the mc_pad field for the signal return trampoline. */ -#define tramp mc_pad - /* See arch/powerpc/kernel/signal.c. */ static target_ulong get_sigframe(struct target_sigaction *ka, CPUPPCState *env, @@ -436,12 +433,7 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Save user regs. */ save_user_regs(env, &frame->mctx); - /* Construct the trampoline code on the stack. */ - encode_trampoline(TARGET_NR_sigreturn, (uint32_t *)&frame->mctx.tramp); - - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(frame->mctx.tramp); + env->lr = default_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -477,7 +469,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUPPCState *env) { struct target_rt_sigframe *rt_sf; - uint32_t *trampptr = 0; struct target_mcontext *mctx = 0; target_ulong rt_sf_addr, newsp = 0; int i, err = 0; @@ -507,22 +498,17 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, #if defined(TARGET_PPC64) mctx = &rt_sf->uc.tuc_sigcontext.mcontext; - trampptr = &rt_sf->trampoline[0]; sc = &rt_sf->uc.tuc_sigcontext; __put_user(h2g(mctx), &sc->regs); __put_user(sig, &sc->signal); #else mctx = &rt_sf->uc.tuc_mcontext; - trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp; #endif save_user_regs(env, mctx); - encode_trampoline(TARGET_NR_rt_sigreturn, trampptr); - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(trampptr); + env->lr = default_rt_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -720,3 +706,19 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + encode_trampoline(TARGET_NR_sigreturn, tramp + 0); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + encode_trampoline(TARGET_NR_rt_sigreturn, tramp + 2); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} From patchwork Tue Sep 28 02:00:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514761 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4705079jao; Mon, 27 Sep 2021 19:23:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd7XkhHTFgca4HXo4UAuntIikN5OvXdwpBgb6L3cQo5EfJkwVl+wdtRmVeOiruoDIoV5vx X-Received: by 2002:a92:cdab:: with SMTP id g11mr2429133ild.306.1632795792211; Mon, 27 Sep 2021 19:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795792; cv=none; d=google.com; s=arc-20160816; b=v9eS9DZidmcHNU528nDftNPiXTGlZqDixY3Yn4cl1E2mg0YiloDkkSYJ0Ol4G7JYsK hCXKcLG9SFuUEQ7NPP6O1LpPLArPESJr6ulO+PsM9xRnXTJws0Q3Dh5ZWndBVbCCDgiB XHemwXAHbojEimYVft7xubmW/wBnRvErnIOTHujwifkvNFWv/FOVwyAQb+u7hNUu5mad gSffwnq1+cp4fxsgWq7PSkdUwN95ihsXlUwiISicShxFcWoyJqgAMziCMuUztW+MPNcS AY0K3pwF85zPd3ch9oTOmHnxWNAHuYjt4plSI2AGFNft41TvO1BwiFGd0SAqVZnTvlw8 Pe9w== 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=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=nm9BTsdv/3jw5FYWL5Z8eUyH9Aj5M4fIbCP+SAuSZgQHDmbXiiMMq4GgU3w/4hQW6Q g75jY9nOagE6Us5bhjSVtMeNPFTUtV5LMH5Jz/LsY5iOV3C1sTwx97GNFxHMuc5pTWvX UWIpt8aqbCGC4q0gvi9b4WhqikOnL5mb3EXQqCgfWk4qx2ML3pQfKKAo2vHFd8nVVMBH 063Z+SdZnaNnpFwl8f9hcON4asDYehOhGNxx70EAKXklPaulsB6joWiOlezoPnwTDZAb /0rZVmTBiMzWMtyJMz3bPcHTJbOeSVhuDtDiezH9kzSQOTyDzORlawLRDGyiRg9NpjWE IaQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fVzrN5sc; 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 h17si21512406ilq.30.2021.09.27.19.23.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:23:12 -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=fVzrN5sc; 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]:60474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2lz-0000zp-Nd for patch@linaro.org; Mon, 27 Sep 2021 22:23:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2Qa-0004lN-HD for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:04 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:36370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QX-0005s8-Bf for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:04 -0400 Received: by mail-qk1-x734.google.com with SMTP id p4so39282051qki.3 for ; Mon, 27 Sep 2021 19:00:59 -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=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=fVzrN5sc8Wx4Bzrx4XYYcPgRy2DMNcJeADA7BafK7q1Y9sHQZmCTVoAUzP7ass+CBW FL2ALGJbPCli3c6wb8w+BDGV3o4p3ezsuf6R2K2rQyV0W5FaOKI47ImvK0urTzuSFKTD bNTMrql7mgneDMFKdshFMu4tCWPWKsfShTZjJcvsm9FR8m3ry3H/Bn5U1TZPbkLJZyj3 YNcoI0r+jGX4aHzqfbXGVL1r8LbCa8o2ZqJ1xItGEIFJjHZ3QiL2QUjdLCgbOESsKTij R6/n7FqYEfTBzfpWsc3bvFy2saP1Guc/10WP1rNJ3sKPqCl5Elsiuly4XX1OTOcjyaFt 7Yzg== 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=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=q1HrOtLjWmuF/i/4/X8QPGTYK9vZYBAjsNPrMmhtVl4pfDNI1TuGVCkChK0abD4OYx tNUmYm3v3LnYroLPd+8D/joAVqyw++Fa2bDrISHjVADsBD4LlR/ndpf/kRf42QxqMwH1 Ov4rcekzFoQ2MAITxA83qBzzNmUbgvbhecX4AyjOS1OVHaF4RNMeWDPgd4ooUimTnmrT sys+5oIkSWVOFoCS90/cYpThzdRsFr7a/Osrrv2rM/IAc9QBQJQan1IoYAFbm3uzu5VS Mfn7Pc2mRNfkEj64F5P9E/Uor+QsR0meMTV+sPQ4ayKDM+D4k+Ym5YyX/cUqJ7hm5ufP +bsA== X-Gm-Message-State: AOAM530UWBKX1LyLqhdcKAbWOmbkHA19x/eG8JIxXNSsk9M9qs4GNu99 BODKvzH+8jxL6swBDNbSsa72HJq+mEDvxw== X-Received: by 2002:a37:2e81:: with SMTP id u123mr3200346qkh.156.1632794458932; Mon, 27 Sep 2021 19:00:58 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 20/25] linux-user/riscv: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:34 -0400 Message-Id: <20210928020039.184412-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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, Alistair Francis , 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. This fixes a bug wrt libgcc fallback unwinding. It expects the stack pointer to point to the siginfo_t, whereas we had inexplicably placed our private signal trampoline at the start of the signal frame instead of the end. Now moot because we have removed it from the stack frame entirely. Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/riscv/target_signal.h | 2 ++ linux-user/riscv/signal.c | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) -- 2.25.1 diff --git a/linux-user/riscv/target_signal.h b/linux-user/riscv/target_signal.h index f113ba9a55..3e36fddc9d 100644 --- a/linux-user/riscv/target_signal.h +++ b/linux-user/riscv/target_signal.h @@ -15,4 +15,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* RISCV_TARGET_SIGNAL_H */ diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index f7f33bc90a..a0f9542ce3 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -47,7 +47,6 @@ struct target_ucontext { }; struct target_rt_sigframe { - uint32_t tramp[2]; /* not in kernel, which uses VDSO instead */ struct target_siginfo info; struct target_ucontext uc; }; @@ -105,12 +104,6 @@ static void setup_ucontext(struct target_ucontext *uc, setup_sigcontext(&uc->uc_mcontext, env); } -static inline void install_sigtramp(uint32_t *tramp) -{ - __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ - __put_user(0x00000073, tramp + 1); /* ecall */ -} - void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPURISCVState *env) @@ -127,14 +120,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); - install_sigtramp(frame->tramp); env->pc = ka->_sa_handler; env->gpr[xSP] = frame_addr; env->gpr[xA0] = sig; env->gpr[xA1] = frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[xA2] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[xRA] = frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[xRA] = default_rt_sigreturn; return; @@ -203,3 +195,15 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ + __put_user(0x00000073, tramp + 1); /* ecall */ + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Tue Sep 28 02:00:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514759 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4704182jao; Mon, 27 Sep 2021 19:21:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcHZ5WoMEt/XJGiWfAxMfPLNV85eIeeexjwMFnABKfr/DWCW6M6U2yH2mRhiyP809fYp2M X-Received: by 2002:a05:6e02:1a4d:: with SMTP id u13mr2493573ilv.4.1632795701654; Mon, 27 Sep 2021 19:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795701; cv=none; d=google.com; s=arc-20160816; b=i2SxTuElROelRlFbH8vPAIXdGhWNgZQ2h3v7Ba2sshIGY6Dk1kZrmF9Xz18i+nNni5 B00TTAkOv6ysp0nOfhfKnbgmRfuxlwardunCxXD17GqruoDhz+zm0KNAXAIllehtbJZ8 ptSHnlzbzWqYyC0171G5y1wLRdkIrBipD4nJZYS4KRl8a8gCmmbrcdBdGDcBOabs6zkg jaBc4i33I1KV1yxabWZT66Pe8j9o0y/WIT3HdUDHxm6gWyhBpEyDCREklhTyC1N2vmZi FKxHh//LzX0s4q6ExNS4eKIBLf+vgw8FLxS35Y61XMazLOWevMxItJ1hw6oOsJG8p+46 X7bQ== 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=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=vme6boOPvm/hds1gfWdQAiWgNrL5JUTuRpe2TeD7BvqNEbDLfvzBKvc4hCcJl7y3xh +0aMXQpGYg6kCGYgQiKmhGUulFs0ohsGqBP+KWZvpqSYhEbSc5JXg3qC+I2qrrDIvjz+ nImDhWp3oHWA5DDqF7W5Cqmhcxnkqdm9uRAa/BP8nO/9w9ogbHHe5wugTIuT0y/S/EjS 48RLYL3o9ZXs3KSuUyZbLJLEAH5RsJhQAorWop+cQpsJtQtcic6G1u3rpesjHz4k9sD6 F39iKp8UO+VBhedR4iPgxnGEQV04B8lJEJa4rOpgZHM3h+elpzNV5EqKLSJU8fsRL6bE +WDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iRfTaPUX; 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 s19si21508314ilt.14.2021.09.27.19.21.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:21:41 -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=iRfTaPUX; 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]:56272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2kX-0006VY-16 for patch@linaro.org; Mon, 27 Sep 2021 22:21:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2QZ-0004hr-5n for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:03 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:43899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QX-0005sH-8w for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:02 -0400 Received: by mail-qk1-x735.google.com with SMTP id 138so38755832qko.10 for ; Mon, 27 Sep 2021 19:01:00 -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=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=iRfTaPUXsCrbUfTIL6jd+LT+MsWfqUnEA1M+hQY34NV7I10Ev0zpAMofjm4WHvtfld MpZgbnfuOgspvcWFjQEfH4P2/ryqsG5VthcNy147Nzp0YCtZ6pMDIWv29gSIGf0DXiIB 12Fp1dta7oaY26tfMYuOJ0Ju2SsjckLCq76fqWYx4hnIkHoTdPiXXGIOnMeAzxoSc2/g fGh2qUHvCIjs/hQJ1TaeiWz0YYIN+z8C1r6849e1+2WXTqJada55jwWwFpWmt3qotiEB esKzmhGJLcVG/X7zCRoTv0Z810kdsHnJYtK8fiyA7CQl1S4Gi9MpRq7mBTwl1cncfUno HvRg== 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=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=MoxCthE6SOdDKAy6vUAbmUJAJnC+6ZyreVn5wT4sctDcBJfpXmWMswpcCf0vhb8xcy barwNMaJU36V70KDYOnjnXE2DdBnTSXmqJA2J7H4uukGca0Kb0vPwbkYCscL9q+8JQKT RyzEZ7fGy8xvY/DYz8J0Ajvatotb12GPfpGVeUUfMauQ/pVBnUSShY4ZSI1lxT0r+Dcn spgibD+2cO9Qxfod68Jo0W1T/E+wskuyvzUOx/Xcp0O1YZdtvsHqSV48VQ0HR/wYhUJ/ r0cHt22QZPzhbDfS8d42M88bHoGi8hAUURAgafNzywRlPpdkP6vfEfKmav5e7ndensX+ njVQ== X-Gm-Message-State: AOAM533TaeJFPihaKKmgowXup+MuELkbm2Onx7TbK/hPe8yaZwIeiZOM OO8s9RyPNYrXsBc9qxsGuvQt1bS9gI1uMA== X-Received: by 2002:a37:9cce:: with SMTP id f197mr3179320qke.1.1632794459853; Mon, 27 Sep 2021 19:00:59 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:00:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 21/25] linux-user/s390x: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:35 -0400 Message-Id: <20210928020039.184412-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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, qemu-s390x@nongnu.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-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: qemu-s390x@nongnu.org Tested-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/s390x/target_signal.h | 2 ++ linux-user/s390x/signal.c | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_signal.h index bbfc464d44..64f5f42201 100644 --- a/linux-user/s390x/target_signal.h +++ b/linux-user/s390x/target_signal.h @@ -19,4 +19,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* S390X_TARGET_SIGNAL_H */ diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 80f34086d7..676b948147 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -68,7 +68,6 @@ typedef struct { target_sigregs sregs; int signo; target_sigregs_ext sregs_ext; - uint16_t retcode; } sigframe; #define TARGET_UC_VXRS 2 @@ -85,7 +84,6 @@ struct target_ucontext { typedef struct { uint8_t callee_used_stack[__SIGNAL_FRAMESIZE]; - uint16_t retcode; struct target_siginfo info; struct target_ucontext uc; } rt_sigframe; @@ -209,9 +207,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(sigframe, retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, - &frame->retcode); + restorer = default_sigreturn; } /* Set up registers for signal handler */ @@ -262,9 +258,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(typeof(*frame), retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, - &frame->retcode); + restorer = default_rt_sigreturn; } /* Create siginfo on the signal stack. */ @@ -405,3 +399,17 @@ long do_rt_sigreturn(CPUS390XState *env) unlock_user_struct(frame, frame_addr, 0); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 + 2, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &tramp[0]); + + default_rt_sigreturn = sigtramp_page + 2; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &tramp[1]); + + unlock_user(tramp, sigtramp_page, 2 + 2); +} From patchwork Tue Sep 28 02:00:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514765 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4707721jao; Mon, 27 Sep 2021 19:28:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR68grW4qJCxpHvd5VdexQVs1lU7DLhHX4NCnCDw62PLXKiDZ02Gupkf+7GKfW+Oyehrvs X-Received: by 2002:a05:6e02:1588:: with SMTP id m8mr2531700ilu.188.1632796114117; Mon, 27 Sep 2021 19:28:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632796114; cv=none; d=google.com; s=arc-20160816; b=N4gCQWBS6FVqXh77LTYDRS5PaZIuAEjvC43ncDqvt7QLCmfGECDPSVIMqBW1sOv5WG 3lOq2geQen4YO6W8YknynC2tMpmltHwyn5LyAo4H0ue9R65gPazZptzh0KGZRJDtchLl YqXL1zXjKVo1zq9pvn3FIVJQa9EoE0/hfdTI8dWYP/c8fmneT5psYJKJXMdPusTrMZqh D8bd7m9cNIXtPUeyE4YW5W6bkBxR7YFOx3dTBJ2nORjC7iW5d/yuVAZGv8una5NzUn5g BridfXeSTHEOukj740S3CIPEyotQgH6zxrGCIBxpFw6uvRVtnvGUaf4/+QGmFGRXsVWJ uteQ== 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=XYLSjR6CJEUN0Bx3YlhEBap/4S30t5e+7cuYrp3JIET10yopgGQtkFd0HzZdVWi7Tk QXOsVAgib329bS5OEzzw79t1gdYx8ptO5lLS7l3GcUn82L6FdKi9hSWtlX+OucmRjooN +aZWXJB+Edk5IpZUV49ZCb3YvNqQk4Dm6YpHSCYRRup6/c6q98vKX4NBvVVy2pCuTv7T AAt+jeIc1J0rCGp8UjnS4WrXdyacmlwnyZX64XPND1d1BqX+1DxchOKEYc3l8pf/izYm pPaBtH2nSSnyvOEj8lYiMDH31zus/oN0iDmp3zJwt0GNjpWiWJnI5oKI0zOxCgM2fgcS b4Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ns4Fqc9a; 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 s2si17659352jam.25.2021.09.27.19.28.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:28:34 -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=ns4Fqc9a; 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]:42330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2rB-0007pI-K2 for patch@linaro.org; Mon, 27 Sep 2021 22:28:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2Qd-0004te-1q for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:08 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:37561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QX-0005sR-Tc for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:06 -0400 Received: by mail-qk1-x72c.google.com with SMTP id 73so39195710qki.4 for ; Mon, 27 Sep 2021 19:01:01 -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=ns4Fqc9aDpxuGBNXAn4B9qg3MzubPW6uoW+fyCXT7yh/QaYuLQMfJdvVcg4qDIi81q +5Ebdv6kB324kUG0CcJc7nJiACdnHWwVm3Tt7uAfV/xDK72TzvaVb4N3V92wm5y4ZJrB pJLlD17GSfcqPTGvFGTJaQycdca0EIH66zkXhGjLW2dakDV2+OxpBvl/1fFrpY8kc/6G orsn6ioSJnZ8QTbxeSsGig4IITclAPXHuj+Cj8RjqdnBMIiuQV8F4bD/Ngs/4FsviyXV i2mMMKlijIYUT9mOelBpfDztqXzCDsgbEgS25MbDDi3I29+tSkguLjgYIrMqflJ6K0+h oB8g== 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=4TteA6Exu+gxn8bchpc654xRYRxgCNUGJprcUoWpJji3GNOL1636lm7SqZ+b3MPBdy ipldPmImIzzMbuV8aDWo1OcmzerBig+pR5Jtl3owTMl/hGlbSO1khj+h9v+Dfk6FaWvO PoFpo+whLlf3oux9pCUp/SEHVGLnaZsmi53fw0pglstDmVBZEhl10oY4fwhfB7g5wKRK KcC4VXXcdIa51SvqqlvnYWkV3Dko6Fyv8ZWVqk7at/51cV4fqDPOuwAnVd1D1SDNFnk8 1Yx/PoOgzV9tCCKqJ2DLrNdyMxy/OI2m7UuiuL702j5+fvyVSHqd7tjVtCH8ftfTa/w7 CR1A== X-Gm-Message-State: AOAM533/bcZka0m2hb1a1PxVRGF6RezQNGIJsQdmHsqp6MkvtFMUyufF WQ/D29qzsathaFggC1ljZ7owIlDkB1YVew== X-Received: by 2002:a37:bc85:: with SMTP id m127mr3148276qkf.119.1632794460797; Mon, 27 Sep 2021 19:01:00 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:01:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 22/25] linux-user/sh4: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:36 -0400 Message-Id: <20210928020039.184412-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72c.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); +} From patchwork Tue Sep 28 02:00:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514766 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4708731jao; Mon, 27 Sep 2021 19:30:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdxZT4pHhk1PTNle0wC3UrNAWK4Wp36mC1wiZeww+lqpjYC2Xh8XhfHNG5KUgdo+lVKaLN X-Received: by 2002:a02:c7d0:: with SMTP id s16mr2420872jao.135.1632796225377; Mon, 27 Sep 2021 19:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632796225; cv=none; d=google.com; s=arc-20160816; b=ZYvQ294zIQPYovmfpxpAK/hbQQhy5Atz4fchQzHLpT7m7cWfGAniH9VqQmCYwrhB5d q5L2N79a0wUED6xQQHplmdQ6Cgoylm3wcb+odS9hqxZz2vcFIpfbIl/DGtouCOLs7q33 g2WorJbhDIt0krap8lxtSB3P9TRtqm0gnl4+uykx+YaerpEbSMzcb7ux8kpqDTiRTHtQ FlrAgD99d+XvuQAlSY37+rghPtPEciqSY7R9JiutmT8idCwC5MwdJiQfzZPcrIFOcl7r LnZTa3xvau/8aiq4KqDXn9sNSkqAPcI4NY4SEqOClyE4ZbM4oiQmLUIUex1brzYoMUaT 1phg== 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=Dk5wEWFCvQRhrhbVHtFmHpph+eQ4gpvIz8pVx649H1E=; b=WjtSaBhukOGd8kLHlwpAjCdRZ0znmaPIDvOGMBG1hvwPUnq3SZXliW+w/t50XFUpqY Pbu/N6Imq6JmDgZ+9G70Hd24O9EjTLB7B72mStCEu/udYJNP73xxEDq05B99CZ3yXu1T lkw8WWkM8sqFDg0+grmn6vgK4F9/xEy+B9tbx1U+tRegjd7Nj3Ns5HofCqn85g1IIUzu jecoGUbFruBn0B16lL4rQ3896NFtAvtb0Vyc1H2Je1uD7BtnAtpn5Pl9Ng+CF0r/EDTa gu9dcqoS0+dYRIa3EuvqIyTJfzw/OG6ttmd7/QIHv3Y+Cv/s5NfRt/biu0fS6Y+CK7lx itBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kJwfZHQJ; 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 j8si457935ilq.113.2021.09.27.19.30.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:30:25 -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=kJwfZHQJ; 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]:44474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2sy-0000pO-QD for patch@linaro.org; Mon, 27 Sep 2021 22:30:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2Qe-0004u0-2W for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:08 -0400 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]:36809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QY-0005t6-Iv for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:07 -0400 Received: by mail-qv1-xf31.google.com with SMTP id jo30so12485261qvb.3 for ; Mon, 27 Sep 2021 19:01:02 -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=Dk5wEWFCvQRhrhbVHtFmHpph+eQ4gpvIz8pVx649H1E=; b=kJwfZHQJk+cUeQ0XEZe813u8r+jSsXY31RGyzXIgLLHE6KcSdLCWLjfTcDNsZ0qL7H 5P62zMPEVKpy2eQxfjRMYI8LDFDQQXWXjb7FWyd54wKqISd+ivSbJXhfGD6GnejUEObJ s+z/NGs1vd0Vzd5giBUnH6FFncq5D4GFLPN7GRMShB+1c0DKIfSg23RSvxwdVPgRSJEX mhmyvLMyJS8Bn0lff9y8vPEqrzFItp676SpLehORG4JPSWoctWyowWJNIvDDyg8lqhYp 3jmOZ8aFepWW1kpnG3LKQudoRL5EpcCLuGlQCBNHyguXM18OTeCfPxkxgeIqdDec7kG5 jb+Q== 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=Dk5wEWFCvQRhrhbVHtFmHpph+eQ4gpvIz8pVx649H1E=; b=DDt5j1O6VPrbk6iIn188LSKaJYSNarz+elUZLOiBwgBriTYoGEG6B/XhHpnHtGGYNu fZ9YScExA04hUSaOtMGgRVPrCBTxyaWluQ3cVbWXIUxmVxQBrn2PS0Acql3Mk6/i2srZ BquGh4L39qKzqJO1q8ChGkRXANHiS6hTsN+xCy+74PhID6btohzXzS6as5zv2zJ0tR++ xU52VhFuPL7Q2pf8VSTVkzULWY3KbeV35JEgxMfaQMLR5ArBSS1MXokC8K3e0ZboVr4j O8HORWdowZ7wOpeJ5Bf3sfPavdH/y8y2+1AIfARi3bQZiEj4k5Prlhmr+Fv27OPI87eq TqUA== X-Gm-Message-State: AOAM531kqHFkbHQZUDmCt+Lf40VgQsExBjtsegZCK/3h6hBUH5T1+ZAK deJfHj4pNg/cJDQZWWwTDZmMZobyQfdtDQ== X-Received: by 2002:ad4:44f3:: with SMTP id p19mr3052061qvt.33.1632794461619; Mon, 27 Sep 2021 19:01:01 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:01:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 23/25] linux-user/sparc: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:37 -0400 Message-Id: <20210928020039.184412-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f31; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf31.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, Mark Cave-Ayland , 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 SA_RESTORER. Cc: Mark Cave-Ayland Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 40 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Acked-by: Mark Cave-Ayland diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.h index 34f9a12519..e661ddd6ab 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -69,6 +69,10 @@ typedef struct target_sigaltstack { #ifdef TARGET_ABI32 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 +#else +/* For sparc64, use of KA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 #endif /* bit-flags */ diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 3bc023d281..23e1e761de 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -242,6 +242,12 @@ static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env) } #ifdef TARGET_ARCH_HAS_SETUP_FRAME +static void install_sigtramp(uint32_t *tramp, int syscall) +{ + __put_user(0x82102000u + syscall, &tramp[0]); /* mov syscall, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUSPARCState *env) { @@ -291,13 +297,9 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = sf_addr + - offsetof(struct target_signal_frame, insns) - 2 * 4; - - /* mov __NR_sigreturn, %g1 */ - __put_user(0x821020d8u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_sigreturn); + env->regwptr[WREG_O7] = default_sigreturn; } unlock_user(sf, sf_addr, sf_size); } @@ -358,13 +360,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = - sf_addr + offsetof(struct target_rt_signal_frame, insns) - 2 * 4; - - /* mov __NR_rt_sigreturn, %g1 */ - __put_user(0x82102065u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_rt_sigreturn); + env->regwptr[WREG_O7] = default_rt_sigreturn; } #else env->regwptr[WREG_O7] = ka->ka_restorer; @@ -775,4 +773,18 @@ do_sigsegv: unlock_user_struct(ucp, ucp_addr, 1); force_sig(TARGET_SIGSEGV); } +#else +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif From patchwork Tue Sep 28 02:00:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514764 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4706982jao; Mon, 27 Sep 2021 19:27:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKYUnxwwpXu9YS7/Q6Rx9TDQytlcdrpzavZZSOw5dfEAYmfEnwetBf4De3jzRSrtwUQCDo X-Received: by 2002:a05:6602:55:: with SMTP id z21mr2113030ioz.205.1632796023374; Mon, 27 Sep 2021 19:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632796023; cv=none; d=google.com; s=arc-20160816; b=TUPN2tLE9D60kaLvOWNQTp7gQjz2Psl7sPCHxM0D2AGZ0MiLnF5AkaZ1b/PxheW9TP 5H+F2zxOsnp3tm48dJaX0ofh+v+ZxrnLIIpio8SDQ0l59bAz/FPROeUbmSz8TwghicvL 0XiGPAAGZNH0BRzIT6XYeeszCHgFbLzmPyeeXoDjd81XB+WB4VFtAeXGe/01VWLpLmMh ++wpW1dhTOhonMGxgdm7PUHUPwwZgYkJhvKc+gE23xmHh2myAE/zwNX/npxOuqqUPB+h qfdbgkbS9W7dV3nlCgdXPJLFPYxr+mm/QArtsGwnYU8lZxGAtIeVAmmKCffWtZ0D7aCr B93g== 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=/YCijfVDlMthAy6Aqm4CcfWtzvTL1hpUSrm3kzthwro=; b=N6sErvIDDQEyw9OeG9n78SmF4aybLLlNyFOyGAZTFTxCpC1aSXEpxM9D5vsIcvhdyX cHYB89yg7KTLTpFUgWK/TyCqEV6g7SloTbUAF9iXUTRepwRx0jMlqvE6slz9lPbDXhzu Er5Zm+b0BC2KZetoH7gy0LLRTMfTgYRoV9JkR598PU5wyqdTY9US/gG8q81lvA3fm9RX 3LBr+ZPyK0mUBglK3+ebuUC02Es4zgQ0LuufORmbJHe4xzteGWyarUEVdP9BRp2ch3yj xDnYLcoc1LTxhMSyJo2SDdtyHgpnb0qZqo3Q4xh3J93bmVBvhu0rMHayyjjRivCRVAoM wAnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tjRJbzum; 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 y12si26846334ilv.168.2021.09.27.19.27.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:27: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=tjRJbzum; 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]:40216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2pi-0006Mx-Rr for patch@linaro.org; Mon, 27 Sep 2021 22:27:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2Qc-0004qZ-4Q for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:06 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:34719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2QZ-0005uW-MD for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:05 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id w8so12509897qvu.1 for ; Mon, 27 Sep 2021 19:01:03 -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=/YCijfVDlMthAy6Aqm4CcfWtzvTL1hpUSrm3kzthwro=; b=tjRJbzumwq6we86x8zoBLnRHi/79cunacioo1ubW2gDe8OolNEkrrYeVAR6c8SPOL2 okTtvC3n8cPerX3owhC0kSCRJz1OSafgG4EztxXA+K4YPIuOSDnG+aF7BcF2HEkpdYFy ZXX+OpukfJhMynFG82vn74B2vCcB/kX1awrGMow1mhzKsEXMd99/XfYlk4HTzWtA57dw uqDvLPb4rnu/ESr1TYvTi42GhR99+YnwHE5bRbQVEWV07SwZ4U3Mf9Op2bmJ+/njUJal 8xhBQMCsmk6+JgZCtMaXiAS5vFRJPm8X5EZJvzvRVtMiwiMSuOiv4ufq9MJJP0vn4p/P /AcA== 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=/YCijfVDlMthAy6Aqm4CcfWtzvTL1hpUSrm3kzthwro=; b=KdqLVr0VMYv+dO+cUDqR/jKjipPIV3+2gl880yagMe6K2/hYe5fAUMvxAd3oLhMcex RZ+fjWbjeBn+ZupYXShWjocpxjXI0AHDDaRgDP5kDsXni0z495HwPZn3efN0d3S+pWLe iv5aER8V/Kq5iNDJYTI6oGrsCsg5sW/yBgvS8lwcsXxVpUZCSCXl7I8bXIdFJM7VmRzX piU08SSKBZ+trm725faVgVPm+atv/wKBbjpmZhdDvvdqJa1snfIXzYtN/Ux60wpqEhVx d2+shSj9l7cq/wpXHkwJa0HxT2qCANMi7LG3stve1IYIZBqpyqYvv9P89P4uodLHzjyt 8vdw== X-Gm-Message-State: AOAM53199CBJUKMldztjigBSKn+jQFotdHAQuj4Hx8LraRSYvXYi7TyC FRc2Jz0zSH11P8jCdJur+F833qvTiVkQHg== X-Received: by 2002:a0c:e2c4:: with SMTP id t4mr3229449qvl.48.1632794462679; Mon, 27 Sep 2021 19:01:02 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.01.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:01:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 24/25] linux-user/xtensa: Implement setup_sigtramp Date: Mon, 27 Sep 2021 22:00:38 -0400 Message-Id: <20210928020039.184412-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2f.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , laurent@vivier.eu, Max Filippov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Reviewed-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/xtensa/target_signal.h | 2 ++ linux-user/xtensa/signal.c | 56 ++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 20 deletions(-) -- 2.25.1 diff --git a/linux-user/xtensa/target_signal.h b/linux-user/xtensa/target_signal.h index c60bf656f6..1c7ee73154 100644 --- a/linux-user/xtensa/target_signal.h +++ b/linux-user/xtensa/target_signal.h @@ -20,4 +20,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 7a3bfb92ca..81572a5fc7 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -128,6 +128,29 @@ static int setup_sigcontext(struct target_rt_sigframe *frame, return 1; } +static void install_sigtramp(uint8_t *tramp) +{ +#ifdef TARGET_WORDS_BIGENDIAN + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0x0a, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x05, &tramp[4]); + __put_user(0x00, &tramp[5]); +#else + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0xa0, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x50, &tramp[4]); + __put_user(0x00, &tramp[5]); +#endif +} + void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUXtensaState *env) @@ -164,26 +187,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { ra = ka->sa_restorer; } else { - ra = frame_addr + offsetof(struct target_rt_sigframe, retcode); -#ifdef TARGET_WORDS_BIGENDIAN - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0x0a, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x05, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#else - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0xa0, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x50, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#endif + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(frame->retcode); + ra = default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc = ka->_sa_handler; @@ -264,3 +270,13 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint8_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + + default_rt_sigreturn = sigtramp_page; + install_sigtramp(tramp); + unlock_user(tramp, sigtramp_page, 6); +} From patchwork Tue Sep 28 02:00:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514762 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4705385jao; Mon, 27 Sep 2021 19:23:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDq5sPmnEHpPiRadjZWU5bRQWd6lwlymiWs/MWHoHTJaJEeQLKjn27Nkasq4QEB+06wZlk X-Received: by 2002:a0c:a889:: with SMTP id x9mr3190270qva.11.1632795826394; Mon, 27 Sep 2021 19:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632795826; cv=none; d=google.com; s=arc-20160816; b=ZgzZ01rbijClm2iQpXGeNCsQgLWWKBqMGqMjxFl3WWCpdTPZUrF556YjtKFwbgAl3k 19JhnZRVAPUDUqPKl8nKwJaEMwiFdC2AAxDq6pxqT3CBAPCHGNZLR/Kp2mMtlUDXHwZ1 hAtXjmc9GqQpmU9w6U+9jkxOetJl9NYf2W5J7qPRApv6Izw0JOWOUO97z45pT7sZVXhW suH56N9IcGwv6oghFWhofsi3MJswDMewrNjQlJYKzo32S/6Fk/INJdpH43u35pC3YpvY fWegUOrXWWafDnY60QPTK4g14id/GtECw7Kgv9gFdbnkGcY7E0f/oglbLfZxov7FNQWz i6vQ== 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=m3BaOtd2sKvGGMkwsWvzzoYXWYcfmOr52yRDlczbFYY=; b=HcAWltoXF4eS/Yw3xqp20APzM5rGdxFL3f+aJtnX1rzS/E3bsKWsH2FhW9kWsrZaHu 8YpueuzPIofnyI1w4DaBET/6PVjT0+0sgNixSz/755w7Wrh3jry3mga5jR9LanoglORw sUbU0HoGptepjcOk9bpIsVd95ri4HoC82aPG/8j+9abpzbvXZqYBlqMgGi8OaO+Db5o7 o/dKVZtgiuVkUJ25HQA2O8SIElZLWVq8VFuThodn9ZUfRwWCyZ9TXpsapy1oBmLUrrT0 sx0d3tBi8Zc0wFrSwxp/oDgpjWMO8pkuWARib6X5bKedptCSV8RnvMKM4GsQ8rNYEO80 cK1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oui9UMA6; 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 r25si14906870qtf.306.2021.09.27.19.23.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Sep 2021 19:23:46 -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=oui9UMA6; 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]:34240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mV2mX-0002Ig-SS for patch@linaro.org; Mon, 27 Sep 2021 22:23:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mV2Qc-0004rr-E0 for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:06 -0400 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]:39642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mV2Qa-0005v4-Ob for qemu-devel@nongnu.org; Mon, 27 Sep 2021 22:01:06 -0400 Received: by mail-qv1-xf2d.google.com with SMTP id a14so12480070qvb.6 for ; Mon, 27 Sep 2021 19:01:04 -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=m3BaOtd2sKvGGMkwsWvzzoYXWYcfmOr52yRDlczbFYY=; b=oui9UMA6AgesmqmpfYq9aeAXTEwmmEGPD6QFeCJUsO2eHQb92viveCPew8SBg0s6Dl QWuP7Pthpe1w4fEzgS5OkEel60kCXKzryi3dok4GZ0+8FNKuc+Ma+2aByOQhODT9o7Qb xLejw/Um8zJ4PGC2bgeCE5KqCuV27yDLaok7itj2SgSTSdeSu8/EW/KfbNW6gXr2gj/c spXRd9eYa7mGHwXgOWPLECpmPoetPvYjFhY3lNvCCIsaDT6bkr3S9BYDjUy83034/cIX /wSPMpgAlfkb6R5IX/A34bGOteu3str3mmBk/kQ07FWTKkSRm/NO4fWdH4oqhvbA3Fio 5OuQ== 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=m3BaOtd2sKvGGMkwsWvzzoYXWYcfmOr52yRDlczbFYY=; b=3ZKvEL4C5K8c3xpXgxH7MnPUKPrBY+hh/Y7FaZ0HGFnXNcs/ORxXdUxtJ70kCybwx7 VWGuwteqABI1wjZdJmAbrJguuiYMHCcGWvU4YVHP3nQ1O5R1OnBOFN9LSLaNAaORf18r zXEgjFulXU8PYCssl0jOnqoxBGqdR2y82dWnYsMGaKuyUHouS5NVf5AFwg6qIQaWb4i4 KV5QRRMVIcdt5lHdaBIQ5T5wFRSLwDe2BsMMO0lXiOICuzoyyR3FtEwtqD/sshZVwGq8 JgGUSatBsdDI2dMPgBUGu9Wf94oQD4J5rQEH24rYC1rTKQebY+bLahPwWs1Y8JjRqR0N PvzQ== X-Gm-Message-State: AOAM531TAWXixXSwybaj/7oAud0NQZMWr/lrgVDhr5ka9/NakJtioU51 aW0NhJirTLDu8np6c2fcFx6ATn2l/u6yqA== X-Received: by 2002:ad4:47af:: with SMTP id a15mr3046768qvz.36.1632794463471; Mon, 27 Sep 2021 19:01:03 -0700 (PDT) Received: from localhost.localdomain (cpe-24-31-215-130.sc.res.rr.com. [24.31.215.130]) by smtp.gmail.com with ESMTPSA id g12sm12530370qtm.59.2021.09.27.19.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 19:01:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 25/25] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Date: Mon, 27 Sep 2021 22:00:39 -0400 Message-Id: <20210928020039.184412-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210928020039.184412-1-richard.henderson@linaro.org> References: <20210928020039.184412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2d; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2d.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, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All targets now define TARGET_ARCH_HAS_SIGTRAMP_PAGE. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/elfload.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.25.1 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 459a26ef1d..2404d482ba 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -30,10 +30,6 @@ #undef ELF_ARCH #endif -#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE -#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 -#endif - #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */