From patchwork Fri Jun 18 19:29: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: 463071 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp170896jao; Fri, 18 Jun 2021 12:31:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMmLTSahgITPXqrT5flKpB7cqjKubdRsZWiAaIqIrNBa61j18lm21jy+dxwdl+F9fUYJ6T X-Received: by 2002:a02:cbd9:: with SMTP id u25mr3721137jaq.49.1624044684772; Fri, 18 Jun 2021 12:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044684; cv=none; d=google.com; s=arc-20160816; b=jX3pbWYIKVA61KJWALBFgv7JhP4veLZeS+V7AppsKwJQEuE3wJEOOkdtuI6eyV1ui2 LeXNd81Dp8JRq3KTvvJEjxT6cg9NBS/l9NKcHy5dZzYwGDBnaKbXdX5LfPyV9yp2hnri glQobm1P3SLokPmTidAKS3CBS2mXFNnE/c+XBoahCRGJe3j7fAz6/Uf7RyRPYnwCZPAN xEaJsQPsC8s5moBzf5P3f/BOETZWosh+yIbWGiBLwwK5U8c22mEMd8iPTAw0U9TGodTt MIjORsRK7Nr+8t+0nOnjIx+VDYWbcBaDLg1CBv/UKB1U3hbk+rwf/wknCfQJeNTY17Da wfjA== 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=HS+I0dvUMHSdSBpKd/9G4tO8nimAsDvjzWITh6jD/wc=; b=oGRf9Tbt7LS0kpfZxk7cZNa+vLlTFka1hsekfPpMFWDsA38tbAGDZjc4V0Bh+PiNiD cd3F395vBw6+EVuCP8RPNrYP6LsuTVZrqVVRvcMRTWVGXjnofC/qPlSy7ozh97b0wHOr ZKQP5lHRKaUDJf0M6+2/+TEZkQdhWgzqwnngf8fMAV0GkwkOh3oTLKyV3SVTwYemIZH5 QMobgoHodpeZEYUgRaFnD1I46TU0lX/0zvpEsiKSypUA1ugXD/8gXBLjco2cPjzG2G3Q Rn0B/5OGRuENXceaHXYgFHiRRwNuvB7ghB5S/FD3kA0ajJ9f+8KeB5H7gawbtmevbiLL jhBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PS5F61YQ; 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 j1si3375232ila.160.2021.06.18.12.31.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:31:24 -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=PS5F61YQ; 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]:55452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKD6-0001NB-7F for patch@linaro.org; Fri, 18 Jun 2021 15:31:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBh-0001ME-3v for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:57 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:36365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBe-0001P9-Fg for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:56 -0400 Received: by mail-pj1-x102a.google.com with SMTP id s17-20020a17090a8811b029016e89654f93so8694477pjn.1 for ; Fri, 18 Jun 2021 12:29: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=HS+I0dvUMHSdSBpKd/9G4tO8nimAsDvjzWITh6jD/wc=; b=PS5F61YQ+NVkboL5qTD/DEB9kwGdQ0/wMJDxhQcoWnq0aWUuMrRpSUwvtZ2OxtVSum ISLMP+VWs0Ibpd1F6iKUsxe2xTDCDhYcPjiUyYlCLN+SonaZjVOfpb+WgWygbEiXjZ1y MDKkucdkgvNWm44fQpd95iL5NX0iLgbXuS1DKX2RFTm3AxT830Z4NIcRN8guYFTILQzF aVJY9/bKWOkZVqOgTCtjXynXKiVh2ny2D+lZzmUftRUwsrG6eFiBZ1Z98E0LA4gZay/4 Ot3/rfmaplvCX5mq3RJWz2TlG1fU4mmOgqoiNxSUA2F5QOpd7yTA9bOcTQnxwVQrs1Hv 7i+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HS+I0dvUMHSdSBpKd/9G4tO8nimAsDvjzWITh6jD/wc=; b=sms1XaNpRXHndXsYt6O1OtKgG6OZlHkkxpjhyth/MWNFgP5T+8++okiC477HfBHEWI 0Uzp1Sxr2tFxDDDS0HlQPvWqzApg956WOay0ThQVL9bc2MX0JVcyVFXnwELBmTUZFdHi 4gMLBUPPrMEzRdGxxAI/rv4yfrLudLx1hSzXwCsVh0OTl/ah58AavRCNmzJ7SOdQwCzD RfS2/PThar4HWbqmPgZ7h9CThxjK2vf1XZPHx9dMVjP7r9888b76NgTenr6/M3iREySp kVcn29wBBB17+BtmNgZ8ALXSYj6int+iSvh5EC1Pe3j135IjTyN+JPyEq3M8GlX0tnp8 cPKA== X-Gm-Message-State: AOAM532jrmOo0Tr98hzLvc5zcd95kXVd+5eKlo9k4zFScOQwJFHyz1RB fe1kJzozA4iGnWyeLipQPqF88htrTxLIGQ== X-Received: by 2002:a17:902:9a8c:b029:113:d891:2eaf with SMTP id w12-20020a1709029a8cb0290113d8912eafmr6155745plp.61.1624044593058; Fri, 18 Jun 2021 12:29:53 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 01/23] linux-user: Add infrastructure for a signal trampoline page Date: Fri, 18 Jun 2021 12:29:29 -0700 Message-Id: <20210618192951.125651-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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: Max Filippov , alex.bennee@linaro.org, laurent@vivier.eu 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 Signed-off-by: Richard Henderson --- linux-user/qemu.h | 7 +++++++ linux-user/elfload.c | 17 +++++++++++++++++ linux-user/signal.c | 3 +++ 3 files changed, 27 insertions(+) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 3b0b6b75fe..9e5e2aa499 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -437,6 +437,13 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset); abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, abi_ulong unew_ctx, abi_long ctx_size); + +/* Fallback addresses into sigtramp page. */ +extern abi_ulong default_sigreturn; +extern abi_ulong default_rt_sigreturn; + +void setup_sigtramp(abi_ulong tramp_page); + /** * block_signals: block all signals while handling this guest syscall * diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 17ab06f612..7bc67ac9cb 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -14,6 +14,7 @@ #include "qemu/units.h" #include "qemu/selfmap.h" #include "qapi/error.h" +#include "target_signal.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -25,6 +26,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 */ @@ -3232,6 +3237,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 9016896dcd..2f19cc0bf6 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -30,6 +30,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 Fri Jun 18 19:29:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463077 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp173997jao; Fri, 18 Jun 2021 12:36:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN3Dcp8zLrC0X21Wm4XIYIPuj8vQpCiqlVm/qcyH+Ju5oDFCHe6DIHbCmoZI4tIGo+vEBJ X-Received: by 2002:a92:1942:: with SMTP id e2mr2556737ilm.4.1624044970273; Fri, 18 Jun 2021 12:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044970; cv=none; d=google.com; s=arc-20160816; b=T/vcQVwEXRHxAkRcAE+BfUoJ3P+LbI60iv2RpUJ4uSnV1gFIPuz2evsQOT20owuS5h NYDZ/iMrqtfJ6zKVKeC2g13KXjLJ2z1QofHbw+DEdxX8NFvYppxxJ9O8noT66KwaRr6F 1a6YMcrfejkiK9ZunUpxkYzqHYyc09tyBuxO+RP0V2poG9kGKEXkqtq6HibmD1kJtSKH HVsn2/dL8fhWwQh5NXjmn+WOWYuvQjOt3S5M/8JzUufOafG+bSH+Kei7qcOeEW7BXO2Q D9jwe6BHTFeoALWMiBYMbaagk6MC0fi6aWAtURoX6cdwU+x1o6kL8UklTT+f+ex5WOl+ CCfA== 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=d9tona3FrkUxASE7ND04pERUPgqb3UguvkZrVQbmfTs=; b=cZitRIWtrGpKLJ2IYDhpXC8cibXal1dF/oPf/7YHjq7soG9/sI+JIuSAus1Qtv1Z6S zslppiE6OcEvq5ZbqqJGEM9MYVL+gF1gnkIeV7/ZOkbJSgfFagfMGPAfpQmlb9tLRSyL stsHnHKup8faQX9Mc4FqWZyhX1I8AUEubb00CR0LcnElJ0L6+Km9s8JN7e/cq97RhE6K zttNq24GxnSf0oad/0NvW2StXStAb77ADTGDvaL1RqkCl1x2oNgbEW7Qz/nMpDF4siuX YYi3daVZ9/1vw9CRPGoX2GeNojUK5Xc45nbxS9ONWa3576gWiD57bUvxx4/eY5G8owgh saRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XGhyRH02; 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 g15si2989163iln.71.2021.06.18.12.36.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:36:10 -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=XGhyRH02; 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]:45538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKHh-0005D2-Ok for patch@linaro.org; Fri, 18 Jun 2021 15:36:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001TQ-AL for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:37756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBf-0001Pl-H7 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 22-20020a17090a0c16b0290164a5354ad0so8692543pjs.2 for ; Fri, 18 Jun 2021 12:29: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=d9tona3FrkUxASE7ND04pERUPgqb3UguvkZrVQbmfTs=; b=XGhyRH02Fyr4/voCKwCAPEr0B4x8vc3L2NbBDdzNQsnHxPxANwVl8h5L50DOc8i55e bk0OmD06VXOypemhj2suNsbaVy7qjQ697b+RC4+YR3B+4K4Xk8M5gUsh4tLJudADHeTv yhOwKr/vAg38gCqGksA03Zj8FcGuKaF3IDZXcCeVjYmn+QaCvpHHtBsedEwAuwcMu3nq fweYBRTpvmim2QmTotKfFPeH5llUAeJjdCh4Z+8j7Y56AqjdUtzkpFG0vLNk7GBmD1VM Y+koyFj40SWI3zJJDdn3yAccCIBTNI+LPGEpmUVQOoq9pNv15eekpIMPUebNTPflj5o7 DGyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d9tona3FrkUxASE7ND04pERUPgqb3UguvkZrVQbmfTs=; b=kAplMkpPY2E9RlD0STrhCsZPk2Kw2bITQZv33QwG9M8D5PC8Gj6Pti/cDIdxQX5Mnq NuKb+uVDALHm7I71Y9oITxcQkAiUgIZfcTgq2/hu/6SCl6Gt4f8QqNyHw1L5Yf589fLS 9Z4sWVD9OP+aaOHz5gbvldt1oVGIrlgf/DncF5eLp/LtAPDmDZBWYmM4uCwhInNZOL90 ZwwSYbUsRFgKZ7S9L2XH+89vD0jB7iLJlrjWQcBa5IeX+qUJKJr5HF/tKMX+0F065vFJ NbCyWcLRiMNRK6RzRRbbJ5xoar5pIKTu0+qAMB3lzLDY/Wqg5mEuUxc2A4145D/rFKbi z0kQ== X-Gm-Message-State: AOAM532CXUvoIKgx/u68ATJWOe5sda2m0e40Fv8gdAkJqG4LPaM9PRkp 2NdSwwfADgLdAzggMs2/GZ3xEaVeq/HISw== X-Received: by 2002:a17:90a:4311:: with SMTP id q17mr22724216pjg.204.1624044593605; Fri, 18 Jun 2021 12:29:53 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/23] linux-user/aarch64: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:30 -0700 Message-Id: <20210618192951.125651-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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: qemu-arm@nongnu.org, alex.bennee@linaro.org, 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. Use it when the guest does not use SA_RESTORER. Cc: qemu-arm@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/aarch64/target_signal.h | 2 ++ linux-user/aarch64/signal.c | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell 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 662bcd1c4e..65b84eb04e 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -108,7 +108,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, @@ -495,15 +494,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; @@ -576,3 +567,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 Fri Jun 18 19:29:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463069 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp170512jao; Fri, 18 Jun 2021 12:30:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws0AbmuM/2v56Ra95eOQAChxtmyrl11cVMWXa4wexjRsfL4804vw0QZ6PQKLKDNfC/FKIX X-Received: by 2002:a9f:2f1a:: with SMTP id x26mr14128357uaj.127.1624044647380; Fri, 18 Jun 2021 12:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044647; cv=none; d=google.com; s=arc-20160816; b=C6iFMdbFUSpAy22blH9teBHvHzwrg/fIPU1beGYzwyDcJT3Aep15QuG3TUH5SuvBNb HBaeLTsNVXzLmjlZc7SSHFeoINr0CU1n/KUSa4WmIHdEioFz7VNuHIv8VSIoEYh3yMQ6 a6TuziElq3KDv5mQ7fJodRVay1X0AJLttFt+79nk3J0CjdO1A8LD/H88rMiF2T2TjO1e V5hmgHqYiekxxZH6R+rj8rlMHhlm51cSFhvUgYtr8VGjSDiMMgQQPJ5VGO6QmGMUZHsM /trZXapxfrLc23XybI/7FuuoATynr1ihj0q+LsI4kTkCgcAbI3AxpPbksPBh7IUjHGbU cFBg== 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=vF/Dv3hdb1vnrzJPeq46hpO+A1VIsu9mSs+eyoe3lIs=; b=XTst54wLHB8+SCTSoxHhlYcXsKff1JAg0to3nrWLnO05K2oh1zCMyzSqnRsU2EHvYs 0XKYoWQ3UsANAWxJ8OWMZbj7ZV9bZ6y9bYGxBVjk86O8OMz+lc6rs+U052ir7LTcKODn xZqzNblyL/xA9/ln2G+VQBXGoNK80bpfaIWhPv96QJyOSltoJX/ts2xicEFVt6JN2A1L iJ54tNxW0NI8PSt2N2yqTH80y2bEbLPrv73DQE4xa18dinML8y5Mt2EoveW7T755Hi97 5WUr+4Gcl5Qbsa9XwTbYZKY4yYIK1Wtkttxs6azMSZWc0InoX4cuaaUQxrMa4vnUeiFe XlFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RbVyyHno; 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 v1si1450023vkb.60.2021.06.18.12.30.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:30:47 -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=RbVyyHno; 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]:55642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKCU-0001VH-ND for patch@linaro.org; Fri, 18 Jun 2021 15:30:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBj-0001QI-Uk for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:59 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:36808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBf-0001Q9-Gj for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:29:59 -0400 Received: by mail-pl1-x636.google.com with SMTP id x10so5207468plg.3 for ; Fri, 18 Jun 2021 12:29: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=vF/Dv3hdb1vnrzJPeq46hpO+A1VIsu9mSs+eyoe3lIs=; b=RbVyyHno/O+Shg0lvjANiqAKI+ptVlioZ0YFEbbi6mV7m4f0Jpo9nY9DVu83OFdkCz 0EFEW2+PQBZDeNYfDlJNQOamB403QuqpSQ3bsIhhd5cBYDhtSES6kl0oiGab/FfhPWKr /xvEJYareZ/5DRQ9N4Y6OlBbTYwKle45983NV0EOpXeK4XBvhMYZeI4UQgfcV1YuSQG3 N7WWr/EXtmpcBsBtsNhySRSqCmkFMnhoMKfdueAZttGeu5IJiUGr9eqQnoMIhNLNA+YC q4TYvUd9rNmtte3A26Y82v6CDhJ15H61p28phbNolHaHIXB2HFJMT7F/e9MNqMX3wHT3 Of4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vF/Dv3hdb1vnrzJPeq46hpO+A1VIsu9mSs+eyoe3lIs=; b=acX/PszOdwuo4ucuNvAy0tgG+NlMR8ZGEe1QwU40CGsXz53pRetQJQzcRUQP+uS3CI EDTALydU7CU968aRjg7s3zNfS8YdkGWHcIEkJxltUp/EACtDP3T0oQvsU5OHtXSkjkkh p+wmTBgYmsoyf4BCSYn4VfXeHIeZis//R0G9tpotg3j2MjU4JWgaG160axg0T3TAQzw6 tJXjgG/Sf0yFmxWhvQEmL2hoLv7kXe/Th7TncIuo/Fk3IcqiFzK8HzWRYCvgoE0fBsSC afvXLU17myaNf6FdTSGavfMicQJXtSLYCcdJOBRjmpjoVa/TjbWRpKKqG5SA0eWJvyHa qyXw== X-Gm-Message-State: AOAM5309OQQ/BOSD47y2mezJP7onq8fHlebPNNUlDnHHqKDdZQtV78W2 rLMlqRpGu2+eWXwYFSx3cb5ivuTDgyhbMA== X-Received: by 2002:a17:902:9a01:b029:11a:d4e:8f4 with SMTP id v1-20020a1709029a01b029011a0d4e08f4mr6140345plp.52.1624044594110; Fri, 18 Jun 2021 12:29:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/23] linux-user/arm: Split out v2_frame Date: Fri, 18 Jun 2021 12:29:31 -0700 Message-Id: <20210618192951.125651-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split out a helper function to test for a v2 signal frame. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index 32b68ee302..cb65623965 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -165,6 +165,11 @@ static inline int valid_user_regs(CPUARMState *regs) return 1; } +static bool v2_frame(void) +{ + return get_osversion() >= 0x020612; +} + static void setup_sigcontext(struct target_sigcontext *sc, /*struct _fpstate *fpstate,*/ CPUARMState *env, abi_ulong mask) @@ -422,7 +427,7 @@ sigsegv: void setup_frame(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { - if (get_osversion() >= 0x020612) { + if (v2_frame()) { setup_frame_v2(usig, ka, set, regs); } else { setup_frame_v1(usig, ka, set, regs); @@ -516,7 +521,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) { + if (v2_frame()) { setup_rt_frame_v2(usig, ka, info, set, env); } else { setup_rt_frame_v1(usig, ka, info, set, env); @@ -734,7 +739,7 @@ badframe: long do_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { + if (v2_frame()) { return do_sigreturn_v2(env); } else { return do_sigreturn_v1(env); @@ -823,7 +828,7 @@ badframe: long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { + if (v2_frame()) { return do_rt_sigreturn_v2(env); } else { return do_rt_sigreturn_v1(env); From patchwork Fri Jun 18 19:29:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463070 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp170529jao; Fri, 18 Jun 2021 12:30:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdLHm9FJnXgLK2wA8z3U59fcrxgFvasFOcAfjdPlTeOFTdjkKRCB+H/r+/OjaZLQLhK//P X-Received: by 2002:ac5:c284:: with SMTP id h4mr7976298vkk.20.1624044648706; Fri, 18 Jun 2021 12:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044648; cv=none; d=google.com; s=arc-20160816; b=uWzfk+2si2Wf2U9LPi10KPiXFhMx4P3/BGOJdjPKtY1eDIfSMhOFYIy/ImP8OP7eJJ e+cY29t96zMvLzOEysW1ZBIjpJ35Grpi5yIfzl1nlAfiKvUo/SdLk+FIP+b58lKNJTth FFl+2u9jXyiGQYCyTyHku1txLUa6ENHJ/hQfC5j2Crih9ThI44B9EAOIoRIMVPfpzJWC 6gnw2AtYq7+BIggl7fbn46K60GOIvUB4dy7OHS5QdKMt870Dw7LrAhsjWzQKJ7h8FCi1 6Tb7AGChcjkLVobh3ChMnH4/YFSe+bbO5TwKQd8OTgOZOG8krVES9+bt3hLKQCmIILw+ ql3w== 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=xc89iOQ6Z9A7jmI+2EVW1gXxkL96LTZi3hKVzfLFP0A=; b=D+noajDllyr8DC8DUv+itns3a+igyL+Jg7d6EBSADRbuB0Fmduha4riGVGT1LGWMJq xiwYyjx+D0bREixruu6DQvAt45HVXs1EOkPxt4tiNpFSbo7ze7BLKEpp2fCjWVspwXcl 8knPFqYub/zjpIgQeJDbX6xSNKO8TQvnxjR/sIOQ7kk46p/0MBPpwnrUFJbi0m5/+b8Z ze8Y7Ju35+Vw3LLXs4UYih91WnRdPG9A2xkLrqstkVGoBq9EugZzg5jB6lHueIf5bq+4 XmyljMee45go0xkTuBB8/ilUtBU1nEK+/jq8ZmDukJDZaHSACCKdY/QsYfxpVge3b9lE O5zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PmixQGL2; 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 50si6171907uag.244.2021.06.18.12.30.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:30:48 -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=PmixQGL2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKCV-0001a0-Tx for patch@linaro.org; Fri, 18 Jun 2021 15:30:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBm-0001WY-Ik for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:43859) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBf-0001Qa-Sc for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: by mail-pl1-x632.google.com with SMTP id v12so5196280plo.10 for ; Fri, 18 Jun 2021 12:29: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=xc89iOQ6Z9A7jmI+2EVW1gXxkL96LTZi3hKVzfLFP0A=; b=PmixQGL27Pxfz3A6w5dAYzho9T5gEWLniESYkDMaxFolfWLUDVGboa5mn0NuCZBSk7 yYhM+Cf08JMP+4SqQdyLIoqERrYSENEZYmpPZDAMcAeFp6Ca2WJPpe6GT+xtlIjXGBx5 bIeAKiQPIiEFSjfLpilGpc7SrBe7lz/Wn9stiQrdVXHaC1J5uXrtlVLzmdWf6fQ3MPov y40gKs2IZovY93iqFEzxLJk4fnY17Fr5AfPK6tVkjeE2Ns7QET4MlZjFjSPnWYGQ4H+T f7Vopma8RPtaFxuuDMJuwWHTQDlW6sczI2UJ0A5jOobZ90r+fMdfF8A/rWC59IQ9y/iB kt7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xc89iOQ6Z9A7jmI+2EVW1gXxkL96LTZi3hKVzfLFP0A=; b=qti8bhiEaTaUOGCBSfMgkHV0VvvGeDc4widOPY1ybo5ss6huSJ7XSO/pbKyYW/CuI/ +6LFXg9ysot/JG+2c00dB6g4yAGyMc98JtRdzUCqDKkyrGveABQey3KsbytQI8vpva/y WHwPBG7uby0Gx6cRCxs2YV3jNDwZuxn287e66BEb5qc7C+yl7POt5OnPYVsch8VHFmZm dkT6W9CDQvuE9dPOg0KFqjQ9n6UCCJnTCqZe14y+o734Tm/r8nGvczeF2bWpko3qjIRX AA5VhLam7y1uDkdbwADQX8TyngLaVga5kPFhlxzNMKFRb/xNvEoLJQ1iQpPB1WJkuuDN qfqg== X-Gm-Message-State: AOAM533deGsPZVGbFmS3Zc9o8n2O78Z1IFroFLcIi2I51A79mhiOElrn bGqrXMOBGVu4JZmHu7L554VkIqXvAhT0Yw== X-Received: by 2002:a17:90b:1bc6:: with SMTP id oa6mr6085300pjb.36.1624044594623; Fri, 18 Jun 2021 12:29:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 04/23] linux-user/arm: Force v2 frames for fdpic Date: Fri, 18 Jun 2021 12:29:32 -0700 Message-Id: <20210618192951.125651-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, T_SPF_TEMPERROR=0.01 autolearn=unavailable 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: qemu-arm@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The value of get_os_release may be controlled by a command line option. Since fdpic was added in v4.14, and v2 frame were added in v2.6.12, this makes no change under normal conditions. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index cb65623965..2d30345fc2 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -167,7 +167,14 @@ static inline int valid_user_regs(CPUARMState *regs) static bool v2_frame(void) { - return get_osversion() >= 0x020612; + /* + * We do not create fdpic trampolines for v1 frames. + * Thus we force v2 frames, regardless of what uname says. + * Support for fdpic dates from Linux 4.14, so this is not + * really a behaviour change. + */ + int is_fdpic = info_is_fdpic(((TaskState *)thread_cpu->opaque)->info); + return is_fdpic || get_osversion() >= 0x020612; } static void From patchwork Fri Jun 18 19:29: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: 463073 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp172750jao; Fri, 18 Jun 2021 12:34:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq6FCvb8FpbNU2pbVxkljLXersNtKPNzEKkpyTyKZ6Qe9+HsreTjl/OD3CPnyv+JRYSLzL X-Received: by 2002:a05:6e02:1a08:: with SMTP id s8mr8463880ild.5.1624044854893; Fri, 18 Jun 2021 12:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044854; cv=none; d=google.com; s=arc-20160816; b=nuS8ntBxIdkj81vYwxK8K6NSFXE0026ckmMrQ83VxHmJQqR2F/AmUoWQlK4pLlKdq2 xuYskyP/rsoRwXqQMY+pphfuwUYQpRWHHObGfCfrlhW52Oj+Cl/QVgcuOGRR96XIRD4L qvKe0wyKmRA1ofpk4gfM0Zp+lw13AR/JOlMzIyiToqiHLpUD+Gvtgj0W7nATNtfUxZk3 FMX0jelhKctAXlSF3GQByL+xeojoKoUde7b4DxvijwXLSuj+RurcxJJjW+mEWb9pdm3a 7ABBzhL7N19qCKDjNUZchMA9u+Bksib+rbOaZtWI+9fcQWpRm4RPCZL7+kr36hK0fJkK +3aQ== 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=BNQDUVyR3ttAl/s4i0xlO2IvPvq1tkDghI/KxgsvylI=; b=g+kZ+NEBOQbQfb1dZGAmWVWe5GXWe63aCRe3m/TZkPuWm1cFuh8m9/jI2bigLaAyuu lg+xxqhfqNyLKVsogqvzP1AAY9QdJ/HH19xuW1dD72T9pqvfhuhsOfc055XoQ4kJKghl 5DJzi0RSQaGIPae8vkZ9wTLCMwjILpQr+n0lG0HxYy5wbu3pB7SeV+HEnnar5HByg6Wk UMCpq2v2dTOwPkMGt4KjC3WNPLYewfFR/2qHZx8pc8TGoMMGyjalrz1qGD3ilvguz2Rx goy9p42JxCulOtAv7DuMHfycuh2OZHzOwzBE4PqJGCz4AHBxCzE03Y/VP19tRKqmVxvx Mo2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AC1CWAdQ; 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 m12si2942724ild.137.2021.06.18.12.34.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:34: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=AC1CWAdQ; 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]:36778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKFq-0007rs-8T for patch@linaro.org; Fri, 18 Jun 2021 15:34:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001Sl-0m for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:41734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBg-0001Qu-Ja for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:00 -0400 Received: by mail-pj1-x102c.google.com with SMTP id m15-20020a17090a5a4fb029016f385ffad0so3651954pji.0 for ; Fri, 18 Jun 2021 12:29: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=BNQDUVyR3ttAl/s4i0xlO2IvPvq1tkDghI/KxgsvylI=; b=AC1CWAdQvfJEvLg1Akyz7PpKMSo5AtgvImyYJq9b8w9PNfynfZJnTqke3HXHaRPrhm HNM9VOzfKu7/ZkIYCb0VQDNnbCuKEtbgxZqbrCDvTOaXNDAmAeyEhasYaGvZaKYPAMYa DXMl+NdhCPqP3pKl4HhzBhIyj3aCfKVeRhQMYKAv+vjKNtO9IfVfoocSAqQTg3PnK6h6 Rom33ECpxZW8e9N9XVxFFzjYMtSvQN/bj8JXfR3fzAxZQS0YNy6e3t8/cBL8ZJdInTkV vOgvmtMsYw3sgB4X0rOxRt81GCtmb7Cxq8HNv2qNBp4XR7txBM45nPRmXPhQ9a/c2AjO sIMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BNQDUVyR3ttAl/s4i0xlO2IvPvq1tkDghI/KxgsvylI=; b=kCq3Q4hEFaYn5k4T4Y05GVETXfca0tS9Vb5CqPPol7OaX7mEqcPWg0lVgixsFV994B kQOABkLAgrIchxXeOX3DP54wQqVGi/K+xD8A62I3ZOsTp1rWRBtQbbVx5waRfLu6bSE9 joh7oSK2aSKKBcXR2KNeVFn2KuvZQDtBv6EewEw26SbzO1QIBqLfhuHlXixfZlQR/pvf YMEV7qFW3F/74RBEGRpdPtbG0usLhXw6S4XHn6CUXpxuvtsTHhyNVI9WdpKqAaE8Ton8 ItOCCMJ+FGsgmV34vbKO01pBOfxVCNas4MoJx64DwLXluay7IgX6JP6tE2J3mFG+0iGE lIgw== X-Gm-Message-State: AOAM530RHR9zQpEzUwQFrs/4eSbOwALBEzaDhv+wqRYbFVYvGIQDFDaK CIXUhIzxM3WYW5wqomsffjVky41Z4vNXgw== X-Received: by 2002:a17:902:788d:b029:11f:6a5d:d5e2 with SMTP id q13-20020a170902788db029011f6a5dd5e2mr6264138pll.16.1624044595256; Fri, 18 Jun 2021 12:29:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/23] linux-user/arm: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:33 -0700 Message-Id: <20210618192951.125651-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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: qemu-arm@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" ARM is more complicated than the others, in that we also have trampolines for using SA_RESTORER with FDPIC, and we need to create trampolines for both ARM and Thumb modes. Cc: qemu-arm@nongnu.org Signed-off-by: Richard Henderson --- linux-user/arm/target_signal.h | 2 + linux-user/arm/signal.c | 170 +++++++++++++++++++-------------- 2 files changed, 100 insertions(+), 72 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 2d30345fc2..63bdd59ab9 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -101,13 +101,12 @@ 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]; + abi_ulong fdpic_ret; }; struct rt_sigframe_v1 @@ -116,49 +115,20 @@ struct rt_sigframe_v1 abi_ulong puc; struct target_siginfo info; struct target_ucontext_v1 uc; - abi_ulong retcode[4]; }; struct rt_sigframe_v2 { struct target_siginfo info; struct target_ucontext_v2 uc; - abi_ulong retcode[4]; + abi_ulong fdpic_ret; }; /* - * For ARM syscalls, we encode the syscall number into the instruction. + * Stubs needed to make sure the FD register (r9) contains the right value. + * There are 4 of them, each consuming 8 bytes. */ -#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 */ -}; +static abi_ulong sigreturn_fdpic_tramp; static inline int valid_user_regs(CPUARMState *regs) { @@ -219,13 +189,12 @@ 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) + abi_ulong frame_addr, int usig) { 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); if (is_fdpic) { @@ -243,6 +212,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); @@ -260,37 +230,24 @@ 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. + /* + * For FDPIC we ensure that the restorer is called with a + * correct r9 value. For that we use a special trampoline + * that reads the function descriptor from the frame, + * 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; + abi_ulong fd_ofs = (retcode_idx & 2 + ? offsetof(struct rt_sigframe_v2, fdpic_ret) + : offsetof(struct sigframe_v2, fdpic_ret)); + put_user_ual(ka->sa_restorer, frame_addr + fd_ofs); + /* Each trampoline variant consumes 8-byte slot. */ + retcode = sigreturn_fdpic_tramp + retcode_idx * 8 + thumb; } else { retcode = ka->sa_restorer; } } else { - unsigned int idx = thumb; - - if (ka->sa_flags & TARGET_SA_SIGINFO) { - idx += 2; - } - - __put_user(retcodes[idx], rc); - - retcode = rc_addr + thumb; + /* Each trampoline variant consumes one 4-byte slot. */ + retcode = default_sigreturn + retcode_idx * 4 + thumb; } env->regs[0] = usig; @@ -394,8 +351,7 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka, __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))) { + if (setup_return(regs, ka, frame_addr, usig)) { goto sigsegv; } @@ -419,8 +375,7 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka, setup_sigframe_v2(&frame->uc, set, regs); - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v2, retcode))) { + if (setup_return(regs, ka, frame_addr, usig)) { goto sigsegv; } @@ -475,8 +430,7 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, __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))) { + if (setup_return(env, ka, frame_addr, usig)) { goto sigsegv; } @@ -509,8 +463,7 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, 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))) { + if (setup_return(env, ka, frame_addr, usig)) { goto sigsegv; } @@ -841,3 +794,76 @@ long do_rt_sigreturn(CPUARMState *env) return do_rt_sigreturn_v1(env); } } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + enum { + /* For ARM, we encode the syscall number into the instruction. */ + SWI_SYS_SIGRETURN = + 0xef000000 | (TARGET_NR_sigreturn + ARM_SYSCALL_BASE), + SWI_SYS_RT_SIGRETURN = + 0xef000000 | (TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE), + + /* + * For Thumb , we pass the syscall number via r7. + * We therefore need two 16-bit instructions. + */ + SWI_THUMB_SIGRETURN = + 0xdf00 << 16 | 0x2700 | TARGET_NR_sigreturn, + SWI_THUMB_RT_SIGRETURN = + 0xdf00 << 16 | 0x2700 | TARGET_NR_rt_sigreturn, + + SIGFRAME_FDPIC_OFS = offsetof(struct sigframe_v2, fdpic_ret), + RT_SIGFRAME_FDPIC_OFS = offsetof(struct rt_sigframe_v2, fdpic_ret), + }; + + uint32_t total_size = 4 * 4 + 2 * 8; + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, total_size, 0); + uint32_t i = 0; + + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(SWI_SYS_SIGRETURN, &tramp[i++]); + __put_user(SWI_THUMB_SIGRETURN, &tramp[i++]); + __put_user(SWI_SYS_RT_SIGRETURN, &tramp[i++]); + __put_user(SWI_THUMB_RT_SIGRETURN, &tramp[i++]); + + /* + * FDPIC require trampolines to call sa_restorer. + * + * ARM versions use: + * ldr r9, [sp, #ofs] + * ldmia r9, {r9, pc} + * + * Thumb versions use: + * ldrd r9, r10, [sp, #ofs] + * bx r10 + * nop + */ + sigreturn_fdpic_tramp = sigtramp_page + i * 4; + + /* ARM sigframe */ + QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS > 0xfff); + __put_user(0xe59d9000 | SIGFRAME_FDPIC_OFS, &tramp[i++]); + __put_user(0xe8998200, &tramp[i++]); + + /* Thumb sigframe */ + QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS > 0xff << 2); + QEMU_BUILD_BUG_ON(SIGFRAME_FDPIC_OFS & 3); + __put_user(0x9a00e9dd | (SIGFRAME_FDPIC_OFS << 14), &tramp[i++]); + __put_user(0x46c04750, &tramp[i++]); + + /* ARM rt_sigframe */ + QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS > 0xfff); + __put_user(0xe59d9000 | RT_SIGFRAME_FDPIC_OFS, &tramp[i++]); + __put_user(0xe8998200, &tramp[i++]); + + /* Thumb rt_sigframe */ + QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS > 0xff << 2); + QEMU_BUILD_BUG_ON(RT_SIGFRAME_FDPIC_OFS & 3); + __put_user(0x9a00e9dd | (RT_SIGFRAME_FDPIC_OFS << 14), &tramp[i++]); + __put_user(0x46c04750, &tramp[i++]); + + unlock_user(tramp, sigtramp_page, total_size); +} From patchwork Fri Jun 18 19:29: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: 463074 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp172863jao; Fri, 18 Jun 2021 12:34:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza4WXIH4ecKwpq47wxX7yNeheg9yJiIXW454W9vFX4apVtkf4A9WBj/5Eqzat7/I2UU5hL X-Received: by 2002:a05:6e02:11b1:: with SMTP id 17mr7813406ilj.225.1624044866791; Fri, 18 Jun 2021 12:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044866; cv=none; d=google.com; s=arc-20160816; b=UKcXPSTPG/PCIqcVm5oC94dp3ZshPjSBE5MFnPB67oNSMSug2n58siv6MxPxmfsCAx Do1IWM8aE88vyv8N1ZAzxBoouEXs06grYC0ertz/AvDfA5OwNrGaEHV+Qsw1mxQ3dwxk OtEMi4ZUotVAfJXVZJJxtgxGo/Gp+HDOtWVZEjrVVz01LL5P0Zrz14cJpJp3Cu2RxoJw P4woK+L3OnVy2XHXuFaj706itT1C1bP2vqN6st/j1w2qakDklChNBlfWb7DvVlIaFdIe RASlDFMJkhoJ/6FcRm06wcuSDIxK/iXhyso0iuhfLAyxeR8x9E4SVJvCq7GxFm6vG5x3 rDXg== 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=Jv0AKUAYCfq8gx2BZJi7SVG0aTCPQkqBNcO1pY7PIho=; b=rHN7uqEa2f6xGYlaLd+GhsaHoLsSKuhbsMCg3/1BwW6mjhIb8Oi/EEg/ak5sOvuWt9 eY4eo2DfOl4JSYgHDcrIG9hbumXkUPrDBcHkza08BvZNZULtdeT+EMZemGo5na+wrkMN G0kd8lsa+P2e4kDe2MYYMzckHAm7ql+95L7RmAJ/mjruOmktRPIlw6u2y38VT5UkwUrT 0TCNgIfc3/Y5XCzFmyzJltgMjLgNQRw38LaaSvwOLgTKek3XH4+A9LEWcgmUc8ooA30U pvOuioY2rlZRMiIX96EnTSUnNEXvaxPE95d5g6Abtms1T4vqZpRCKPMXjaaJ33R5Ok4Y Sh+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DMSP6sPk; 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 h6si3566878ilr.53.2021.06.18.12.34.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:34:26 -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=DMSP6sPk; 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]:38126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKG2-0000Hf-6Q for patch@linaro.org; Fri, 18 Jun 2021 15:34:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBm-0001Va-9z for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:43850) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBh-0001Re-50 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:01 -0400 Received: by mail-pj1-x102d.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso6480166pjp.2 for ; Fri, 18 Jun 2021 12:29: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=Jv0AKUAYCfq8gx2BZJi7SVG0aTCPQkqBNcO1pY7PIho=; b=DMSP6sPk2LlhG7ZPOxmaRMZ8QYXDW4fuDe9mT5oDb3nNFC71lkvdhnXGwgoTMZAVy/ 7VgDBU1mEO07RXb/XmtO+0bFlda2rdVgErZFFrFy3EP773mjyeX7fNh5YYdEQsoULa4I r/pNv5jMNeof16H8V4OTRd4YpheGjV3CoMUhWhZGlwsqgqWzaIjQj9QWSlKez2tgipCi UywmUgE3KTgIz3dAuX4iW3TVppfwWKM6r410kmJraOoFRRnBPM6MsG1XEG7j0dbLWS3Z iOYJ9aAQiGZmKhu3PZe8OegHICj7mKnTZ6YSe0oOXBMZH/uB9r6LD1LS2/wzTVo/dhKp CGHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jv0AKUAYCfq8gx2BZJi7SVG0aTCPQkqBNcO1pY7PIho=; b=ovPrmJIxG7gDcfwWrZkivmDeHh1fgfT9x7stfz0+kUFWvs0yySvfqmDJ7tExC1bBK1 MXEs+yStGn7jbE1ArB0UWLOerePDeGlX97nTDrnID5K9tJGu7dXaYNJ216//1cJ157j6 jy1h/hA/fOyzvdo93iXEtzcXVeXHNfsRvGE8k3u2iCEY26bNqg0HTql+YtIVShwpjpGW Ml5SOkNRH8Kn+2TrvlrBON01CCYY0VJQCNQX9imOeJ9Tp69VYIJzL6uvKwuNHeBPrA81 +n/Z7FcJbvrqSSQPhRIVs/e48TkrwEpCDzPZp7xgJFuSvzlqzhfakTW6mXfEgqbK2s9Q 6WWw== X-Gm-Message-State: AOAM532BTNCPyfBYMQ6Jkg9RV47Q2vlHTALyQ1J98XadyEcN13me5GND b6XTS7rALzXJJ1qSHygawK9pK38/xYrj7g== X-Received: by 2002:a17:902:da84:b029:10e:fafc:b29b with SMTP id j4-20020a170902da84b029010efafcb29bmr6169516plx.35.1624044595845; Fri, 18 Jun 2021 12:29:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 06/23] linux-user/alpha: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:34 -0700 Message-Id: <20210618192951.125651-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. 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 1129ffeea1..e15f5438c3 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -54,13 +54,11 @@ struct target_ucontext { struct target_sigframe { struct target_sigcontext sc; - unsigned int retcode[3]; }; struct target_rt_sigframe { target_siginfo_t info; struct target_ucontext uc; - unsigned int retcode[3]; }; #define INSN_MOV_R30_R16 0x47fe0410 @@ -141,12 +139,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb() */ - r26 = frame_addr + offsetof(struct target_sigframe, retcode); + r26 = default_sigreturn; } unlock_user_struct(frame, frame_addr, 1); @@ -195,12 +188,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb(); */ - r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode); + r26 = default_rt_sigreturn; } if (err) { @@ -268,3 +256,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6 * 4, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(INSN_MOV_R30_R16, &tramp[0]); + __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, &tramp[1]); + __put_user(INSN_CALLSYS, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 3 * 4; + __put_user(INSN_MOV_R30_R16, &tramp[3]); + __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, &tramp[4]); + __put_user(INSN_CALLSYS, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 6 * 4); +} From patchwork Fri Jun 18 19:29: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: 463079 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp174735jao; Fri, 18 Jun 2021 12:37:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvM817mLXvgzqBkpNSlvTx+Zm6fKIuDh3G3ucgpuQbgRawQLCcKaQzVBvmA7xSi8W7fPoi X-Received: by 2002:a67:d819:: with SMTP id e25mr8791905vsj.18.1624045043224; Fri, 18 Jun 2021 12:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045043; cv=none; d=google.com; s=arc-20160816; b=Bicl+O5yJrTeEMz8Trls7jvWjL/p0H9tCkUhTVuJNWEY/TAAO2Pcngai4AugEGsUYM W0AXNprAfVJ09AbUW+2gSOGI33hcpNm4Z6YgG82WrYztluAGhcpY+t0NhZQfaDMJl7o/ tk5lwJtp4ZQAqL6uOqfjMujye9CL1HOusfJkLIACk/oH3MuVA3joJ/v7pC6m6ZipCpY5 1yDaSULIyLKFWlzzzUL5x1SUD3DgE/3QoxWlmJuaUotdvT7lEfIIZM7TUMZ6YJs5FLYl TR3NFIxAJz7Xr5JjYel/KrlWNgORfKe8t1NQU6Hu1AwP6JBkx89j2mkG0DPazZn30f4o ugLg== 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=8EdJTWq8OgKipxSBNkme0TC2fL2bX66wTjLIFL0IsAQ=; b=0LRr2phEIRdk+i0yN++zzssraZkMBHCqydFVpRlZnbf8/tWW0UC0n9LCa9rupjPgOB TvFEZSUP6Whfd54gDlrhO8x7aqhsxYhokpjgrw9sKHY8rEmwsioeBu9wca6BMeIQ2TCT XNaY1+S43c8AYqzY5PIapbO5ZsNXh6uQruqtvIrvvJ3PD5p73jaeA80ii+LTu3w2hR5k jPxLNmW7TOoSBvpE2ZYQ8qCY+US3XAdth+EBU7oW4TAKlIXlPi6jxaE5D+j2cvKsUYSC p/ZiMIt+yFw9SkUyl6IFjFr37kaC02/e4tDXdZCM+gtM/IrafIASz0K817/Jv0oK9INg JxIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eN2E6Xp0; 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 y15si7011431vsm.179.2021.06.18.12.37.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:37:23 -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=eN2E6Xp0; 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]:49002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKIs-0007Yq-3F for patch@linaro.org; Fri, 18 Jun 2021 15:37:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001aL-Hc for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:40769) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBh-0001SJ-GI for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: by mail-pj1-x102c.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so8302007pjb.5 for ; Fri, 18 Jun 2021 12:29: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=8EdJTWq8OgKipxSBNkme0TC2fL2bX66wTjLIFL0IsAQ=; b=eN2E6Xp0HrS7LanIyGtL4QBnH66ramgehpLPHNNXPJvR4ofQ+pgRPK5MNSIvTnaZCu SNPzy7ld8WpsrsepnHEkrbr/UWZpq2l0BD9bjw+SgpC9jhWz2BRn5P0FgTIS6N94f8w2 MRENw/Z5X0zfjPwRVxO0XE9TMHcDwNa4tvrPUcPNimlx+ZSBMFwQ3WN8HYvzyQ2UCpb2 YoOz0jjLI7jWcAkP9tQNmUckWeqdam8ncj0NQrCcD5hf/eEPSdz/E5L3JhGPvVeRdEkH uuyD2WS4V2ljMJy6FxxtLNXdJ5mIrpyQOKx5OIAOc6DHJxaGMFd0N6yakD2C5cqx8Qy3 cv8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8EdJTWq8OgKipxSBNkme0TC2fL2bX66wTjLIFL0IsAQ=; b=XWGq6FRHTghASgyWRRYDbPm6pAnNxDsOLS/goLG2tkA3e5RTscCv+AHAkGexjihT4W vVLOWzOoL0g5y/iseTfGQ35ga5tQRxzR47oBT6XODL2nUKQege6rJLEONb0xJC78MCRX XOay4sZJbEYk+2d10qD3ymXJOltIeYLV+2+uL49rll7mYA5unyZH8ECbQOLg55qd5yoW 4JUTJtpZNbvmA0uNYx5a2c8r0O+9EpJa0fxG2N+8CVLzsmpfkpiFclXXptm/rEYX/JTI fqBUc8l8tSZJF2vgbMtyfpQKDBkY5Q4g9/v3sgj8boliGBhvz14chrhC3sfXGupOMF7A bFgA== X-Gm-Message-State: AOAM5334XqwssAZIq2+wLTZ6FlmNQFHpGXKw89bt8hIg7A8qHOIiLVvh PICvKPaU0ugDecpDMCe47fjOXZIJixwvSA== X-Received: by 2002:a17:902:7442:b029:11e:4b18:daf5 with SMTP id e2-20020a1709027442b029011e4b18daf5mr6113783plt.47.1624044596341; Fri, 18 Jun 2021 12:29:56 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 07/23] linux-user/cris: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:35 -0700 Message-Id: <20210618192951.125651-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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: "Edgar E . Iglesias" , alex.bennee@linaro.org, laurent@vivier.eu 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 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 Reviewed-by: Philippe Mathieu-Daudé 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 1e02194377..9dad50f31f 100644 --- a/linux-user/cris/signal.c +++ b/linux-user/cris/signal.c @@ -96,6 +96,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) { @@ -111,14 +119,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); @@ -134,7 +136,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; @@ -186,3 +188,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 Fri Jun 18 19:29: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: 463081 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp176014jao; Fri, 18 Jun 2021 12:39:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz7hoJcBxxAWAWCsy5JTGeBC4F5BcJvGUBzYx7v4ANrFuWjDv02WIBcCNo4G1vFYJj9+ys X-Received: by 2002:a05:6e02:ee6:: with SMTP id j6mr3163649ilk.143.1624045154166; Fri, 18 Jun 2021 12:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045154; cv=none; d=google.com; s=arc-20160816; b=LMSPIb4LjzM2FiVKgewyyWWfGkrt5SaR67oZU3jzd9aS5lXgqaISKIkl5M2NvKcRTV R9z1OQ0t5PT5w2P/HcRi0DxLTSQ6U1JkrmP2GC9gVlHvCm97c8dt2lBzRIhoibsvbLTc be+boK91c0DZqPWQdUEYeWcduMcfuJUpfreMmoVQmxjLkCYkznh/E4TPdHytaSzE9D02 Ulq3Yg+QLNlXtGukmzan5JOr5V7z3XFb577d7JmpUQCsbM2M3GBvuC5E0HXZvHckCWGj GF488kyCXxVkvaZzTCJq0uyXFlTq6NXfdi9ebGuAFjcFF8xnQeuF9zrfzafT8UCHMTAK QPyg== 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=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=X1MXtNuI0ap9g3DI/XU2MMOOYuyS2/dlS1wvMfasuGYI7P0Hb4bmuukjo/30TFP8Jg zXLbam6xTjwj9zA1s/7FSeZ7xc/ub7GsDf143i6UJyG+djMVhslhXSMCCvoue5EgBjzP x8jan0+Apvuxt4bHr6So2g9rpfSRfZAgrp/l74WPRLzqEOp9AoLenSgqJw6VttZtFbiD IoEpFPzX+Yyd+a1+7ZyBVoP9PpjJxtv1UUirKzNmZt5Y/fr5TkclAnamVeiJvogu32z2 qG8mUop9V1e0aY6QXt2vbk5qTToq8UwGU7xygAattiPkpizL0PRtnn0qzTbKF+860cAM lD6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=J7PPF48+; 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 g4si3296180ilj.40.2021.06.18.12.39.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:39: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=J7PPF48+; 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]:54086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKKf-0002WC-IG for patch@linaro.org; Fri, 18 Jun 2021 15:39:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBn-0001Xs-6S for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:03 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:34341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBi-0001SV-3Q for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:02 -0400 Received: by mail-pg1-x52f.google.com with SMTP id g22so8603786pgk.1 for ; Fri, 18 Jun 2021 12:29: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=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=J7PPF48+lDRnKZZfvhzHBxl8eM9yzfps7HPpimKJUmOs5s/jkVZQeJTPOn1paYNf0O WMeyAMQOO/GETptn5sIEqono3A/KvqGpNh6NE+2KgbsA724adlTwZ2gkC3VOv7yRUyWn eL/bNC3bdTYvESGmCviG/XY/xeGjlFEh6gZ3Fh7rcdVIvppxp+8C9wEuaIkeaQzWvE+x Aju0CD/7UC5ig5DociR+z8fzLm/jFm6od9N8uxS7hdWZWJ7Qbci/a6iz2/72qfE7j5wL EUGz98dBStqc57DZeUvrtMF96nwTaiTVJ/1KLwT2bh3OFIzOO8rBRrvAj4F+axdIdkqB h3Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ReU8vIByGr9momebDN5YoYgZw0eebV80Kt72eW04Sn8=; b=Cit3wuwRo5N16s3hIayCSKaB8fy4DX0X2SfoLrf7tHtK6a/KK/DL+7PGepwjrAQ8YJ 4cTXUODJeEBokQ0UHhH2tBf7DzM55gqQtdn7sJc8XxVHEVpLwp1nsvrfR4WLXCgu4KFK 8lFdE7ibuEwlP+o961HfzyVzZ302bEBVCmG1wRXw6ZkXkPMlWLujpHAQ4Z3dT2jiGKt6 Q1xrVSHSiLXeTK5xJc64J5s/E67SuktAU8loqaZWWuLW/BhoCd08CFhPWTK7kO+1H6eq tepAvLnEdpx4k56IR6SJ2zVIezq4mahzoptfvlmJqQxoMELXf/YoUM//K2GI+ZQuSd9w 3xtw== X-Gm-Message-State: AOAM5301TQKFtNlTgkgUtJIbwPCLEEhy+f4Zk9wL+PIDlPpQhmR/tnqZ N8H/xVjh6Hg0iYaKr2VYFghoje89tYT0Bg== X-Received: by 2002:a05:6a00:844:b029:2f8:5436:dc39 with SMTP id q4-20020a056a000844b02902f85436dc39mr6709786pfk.10.1624044596872; Fri, 18 Jun 2021 12:29:56 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/23] linux-user/hexagon: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:36 -0700 Message-Id: <20210618192951.125651-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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: Taylor Simpson , alex.bennee@linaro.org, laurent@vivier.eu 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. Cc: Taylor Simpson 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 Reviewed-by: Philippe Mathieu-Daudé 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 85eab5e943..bd0f9b1c85 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -161,6 +161,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; @@ -170,8 +175,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; @@ -270,3 +274,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 Fri Jun 18 19:29: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: 463075 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp173487jao; Fri, 18 Jun 2021 12:35:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdMGLyKdTvchrNYHlIKwzxEwqKgVH/Noey7GPmjygG/t2UOZ4fUKwGZGqJ5fxOY4/GVbMC X-Received: by 2002:ac5:cbc5:: with SMTP id h5mr7870890vkn.7.1624044923140; Fri, 18 Jun 2021 12:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044923; cv=none; d=google.com; s=arc-20160816; b=XatjwNofoJe8RYrjkSJqHO8phcIapvDvRWiULKj4apfxUQw2vuTIlXoCYX5b6HcGXz dKRhWr1lXhu98hMmoAHCPICdxGxffFwlzm5OTxgHUsSflLEfvUqjt12ZotDplyUGnKr7 hi3U1y5FkIXvhfUsJib1BDfcN1d/ZsGGm4nQy6Tqvh4J8GLUR2oZ2T2J+GdRJovYVk90 8kzthYySR7VkikeN3w2nznEX4mvN7pa+meqTJy9kzydmOxsr3HH2odjESG/zK6rejtss r3UlmceqNbE29t///WHJ3yz4ASUuYMcdlP8/8XTUAQbfe3258A4VO5PD/SDUxyzqieJs lZOA== 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=nsNLBGu3hFSLFMwY5DTS6N+/D4NETVEH1W8ylGJdh8FOsB9S3bjI5HWBvb7iozTjle ZLQFj1Q1V+vyATcZQg1NRrMCo2Bb2XyKWAGtlq7FnRn+8CRnu7PbNiLNa0+gqMC6eXdn AMTh06uex/vj4UknJzluEAjteIh8nAecUB83LAbIKA9mvVh9ZPnXBdcJWZUMBzaVaSJR p5OwUIwDw9Es7oahcxkN1aRzP91ezcFDLDL9Nc9hTgMYtKYJ49ujHIZrmlEtqHPw5fMP cPPfSFzLBiXh3QDzXFMef4e18dna5RvU3P/avsWBew6btxHNP5+QHNuoyMua7MSleCFs eRig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ulS4pyoB; 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 v12si8389024vso.129.2021.06.18.12.35.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:35:23 -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=ulS4pyoB; 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]:40392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKGw-0001oB-IG for patch@linaro.org; Fri, 18 Jun 2021 15:35:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBn-0001ZN-Tr for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:38639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBi-0001Sj-MV for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:03 -0400 Received: by mail-pf1-x42a.google.com with SMTP id z26so8438737pfj.5 for ; Fri, 18 Jun 2021 12:29: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=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=ulS4pyoB01ZaWpSAAqvb0/v1/U+/UDZcRnwG2IUgbYQ1Eio4F3ASbQIWDQxCNN1bAG T15drD+tdC5b9aUjLpyHwPLvxuvhq4wWb+CkRbYn0J6eirmNDkXHnxGOJvwPdYHao1wT kz+L1qMSdJN4EAYlwP4iHUvMsUWKKnoDUGvpSb4Coj1pEL8LsOEuIGgIp+rFPbpa3Mh+ NzGaiNAvbouQ4qnA53fWdQXq7ypBewhgc2Zcbvrin1pdWmhv5PlRg5qpQGsnofsjpL9e jAU9GuLbNcoqhsanq1KFLkli8lVDbJf3GlEZmrDh1df7FyXsGBL2IKaem4qGDFeKRv5f 8GYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=RgNqvpDfMdbI2E5fedY1LdmV6QMI0FeSYyvzRf75AbKxX+cr1YbMecdnMO45XqO7N2 EubrtylsquodzvmU40n2x4JE0eKAzbUsXNj73cdMcKs22iP99ksgRjd8CXFN7hvSAa6W Nlyt5Z/tOFFs5LV/3dDlSZxG4aD1IGT/xxCyaq6Djklznemtvyiy4sTorG13nURXqy7B qM/rXxsg87q0GuSXDpVKzWpNXidCTS7oKdZC34Ph5igbsHIX24Pd9rU29wsN57Vw4o3W b4wQoHN7lKIsxFWqYyY32EQrhCZJ1j6VVEMQwrc5Bo7t9xAYBneOdlm/VXldASS7p7YQ 76hw== X-Gm-Message-State: AOAM533k6fY7NBNlKkariZc4uyPUs+P5rtm1SBtk1ib+p9KG9jUG8weU eypVsdBJPnLfGnodkjkR9CB0mH9k89rW6w== X-Received: by 2002:a65:6a12:: with SMTP id m18mr11450996pgu.229.1624044597375; Fri, 18 Jun 2021 12:29:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 09/23] linux-user/hppa: Document non-use of setup_sigtramp Date: Fri, 18 Jun 2021 12:29:37 -0700 Message-Id: <20210618192951.125651-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 Fri Jun 18 19:29:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463078 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp174264jao; Fri, 18 Jun 2021 12:36:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtqfzSMqQcvL0mkE5FSJ71WcsCUCnJZyq7zv4xNgxOX0kCrm9HfXCevCCxLzGKVTPGfAws X-Received: by 2002:a6b:f618:: with SMTP id n24mr9366671ioh.174.1624044995515; Fri, 18 Jun 2021 12:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044995; cv=none; d=google.com; s=arc-20160816; b=EdyEARmXE+Za/Sq3Bi4UK21UrhqP3Srwrd0iQGcDRUc4xfTl7yGx1XIag+ZJfQwi3+ 0Cy7TpBpfUv/Hsfxs02ic56Sl6QRz2CGfX1k+4T3Uqo2sDKKfB14pmpAzMiH66NcShke PaNM8S2CtTHmRne6bjqJSEgzIgr5iathcPteijhnjbwL4YGAyGgfIzLGOKe+wBwkfIzY rDUm725BuzXWLoEpsV+O7zu47WURaAs5+1k950zlhd3le5yVyvb2IAfQiO6o1ZuuhUCi wnzWI1d39ovFxS6bVBic3JLmHWIbhavxEQG5AIoKJLunn0r0uCuVAswk7tIOJvBUdQdv 34bw== 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=Kmu7xnRVWsU3eWGJbPPKgl5+mSDH//+NJHn4m15m2Pw=; b=yJcUawyaVEmUhbYipHYZ1JiYHa/P1ruQWUM23oSH0vBjEnT3Z2v9zFLrCDsGUaOimw cEJCWylTaBYc3Co40iPIxJrJ3dzFzuf2zLZOctBvujoVdK64OuemiN/74MNtdpq3HfIW LiBAxlaID567ATYLZFKurKBR0MzLxC3mgIGtBy2Ef9/OItLsCB2YqePy+JGLrdOdnmSx UNL4yKZK+8qW81S1/NmHxiNDROVfY1m7rmFjhbDhThm8GV2TtAOXKBgUf1WppGERcedI m6hThRYb2+hhqZPuN85DYfE8EH3edtjRmsjDdc+QYSZYQxdlUoj4XmxMfnZDY8a5Lu8V VkIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dxDQX56m; 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 z69si9780136iof.91.2021.06.18.12.36.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:36:35 -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=dxDQX56m; 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]:46802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKI6-00068V-PR for patch@linaro.org; Fri, 18 Jun 2021 15:36:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001bU-Ua for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:05 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:37471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBj-0001So-1j for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: by mail-pf1-x42e.google.com with SMTP id y15so2618818pfl.4 for ; Fri, 18 Jun 2021 12:29: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=Kmu7xnRVWsU3eWGJbPPKgl5+mSDH//+NJHn4m15m2Pw=; b=dxDQX56mM5aVhbrjiqVUUXkb6eNqKNlJBK+/HRkmsWFO8tLP4HuGULYH65nB79Z2De /0C7UlRBE6OeFS4XflOiOdklQKzTrH2l9AJslJU2MBN3g9qJ1gaZx3u9Lha4HoBKZ4f5 Qnm5mTXnSsZ3xNymQgkc7JtP5ZwZ7zhOl2cVaB34MkAjPfyJKTVtnvbrSi+aOWtcOzLx UjP4mejf9JeLreo+8DE/LgpKBjhYNiZUWa+wvpRy8Bo/gHrXjEUT+JumcGJ458n24SN+ IWFab3XYB+4ODWTXqYqPV/soF7SUAUEa/8cmO3YVugfrEk7P90oUDUk2duZel92j9910 vWqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kmu7xnRVWsU3eWGJbPPKgl5+mSDH//+NJHn4m15m2Pw=; b=elE4tsTopswm4euNgv30P73eESAfyHu8vTgLOBIm1/ZSUbunf38RDuLs+3Iltx+YhR 5drFneqdxjEGf9MWDg8TRTOPB3BZhBBxA6KTc9Yg3bRVstuCx9tR985AD7sAJSEkojpj CH8tkWjAIPwdfQfEmFquPLHfFf1NnUTIUQ+xP+1fbx0VYXEE0I2fa/wkxa+etSAZeGGQ 3ImTqIixiOkJ8q2MNmX9cv/sWDafBfyIi4HypRaLWcluMRA8qEMLFV7uXe74PthlJ0bq tXjmSR6JxNjB3BCtlE99R4SB5ll96zIsSnkWhGlgx+Bj6ACJgAEdxGwANKCYhtcjKKpb Tuiw== X-Gm-Message-State: AOAM5305+w2vAWVVe7yOwuEHEzAbagK7AU6yL15sJqehA0dMsL2ZLns/ PgDX4uSeBBwsenf2Zn8dz7UH6cxclh/gzA== X-Received: by 2002:a65:610c:: with SMTP id z12mr11670328pgu.453.1624044597869; Fri, 18 Jun 2021 12:29:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/23] linux-user/i386: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:38 -0700 Message-Id: <20210618192951.125651-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use 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 | 42 ++++++++++++++++++------------- 3 files changed, 29 insertions(+), 18 deletions(-) -- 2.25.1 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 8701774e37..a83ecba54f 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -337,16 +337,7 @@ 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)); + __put_user(default_sigreturn, &frame->pretcode); } /* Set up registers for signal handler */ @@ -415,14 +406,7 @@ 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)); + __put_user(default_rt_sigreturn, &frame->pretcode); } #else /* XXX: Would be slightly better to return -EFAULT here if test fails @@ -591,3 +575,25 @@ 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; + /* This is popl %eax ; movl $,%eax ; int $0x80 */ + __put_user(0xb858, (uint16_t *)(tramp + 0)); + __put_user(TARGET_NR_sigreturn, (int *)(tramp + 2)); + __put_user(0x80cd, (uint16_t *)(tramp + 6)); + + default_rt_sigreturn = sigtramp_page + 8; + /* This is movl $,%eax ; int $0x80 */ + __put_user(0xb8, (char *)(tramp + 8)); + __put_user(TARGET_NR_rt_sigreturn, (int *)(tramp + 9)); + __put_user(0x80cd, (uint16_t *)(tramp + 13)); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif From patchwork Fri Jun 18 19:29: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: 463083 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp176274jao; Fri, 18 Jun 2021 12:39:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb0qgAnK6HoqEHFfX9ByQV4Sa8RjJ6wL0Bl2EtZdpP0Zz+GtS0M2114qB5nCimy+/R5PDU X-Received: by 2002:a67:eec3:: with SMTP id o3mr9346804vsp.33.1624045178092; Fri, 18 Jun 2021 12:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045178; cv=none; d=google.com; s=arc-20160816; b=NEdcdL0qoj4+c2e702JUYH6mupFqQvuZpnr/ErHV9EZSkv3aRmjYze+ONEoPa3jQML UephKjJoYGm2egbrwb5cbMrI2rVbOGnu/Y5Ulhjj/THBf+fM8TlyJa9zEkldftuCrJH1 Gfbjz9t6X1x5To+Ly6jds0/H7zfq+xWZFHE5hcSuNc5RgCaegQcyrmr+3C2YijqnZ/EI S3AEJ56ypN7NclC8nYHezMt+tQnV1R8hAPE8BF3TmyZ6siah1ncRd3+ZWheoBQNvNsKd Fi6mKY+HGwMg4CWs72GtRQiIU4ds8Pqdy9PtXPMNyBAWX+4IicKjYaBcUML4rOfFNcHF 4i0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=GuN632MgGCiP7XyBZ4nE/pBo2Og0+mXniZixUyvdJwnIdu86LJvX4Ba4DuplFVqm9z UOneK874jd6eKJ+WBd5fstCTDmI6lW0mQNNAdkisQZ2TJQUJ6giq1DeaJ9mJRuLmntSE 3MUvvx2lNJscc6HgdvmpitmXDhhCMPOvMlVUj503epXIYwduqnnNMKM440/MGt35iu11 TzW2N0tqZ7K1qAE1PRtP+KCPY6zUtnJPATvhNPW4wpd0BmkU5nWqjfxKJLGMNpXFPvPx Lx3X9dSF7yyTz/oAZQWnkHiiaaNkBXi8ccK8qZKsSXiDvUK22/pM33r87hHwvArgM4zY 0MsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="w/8jmxyB"; 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 x9si6764125uau.193.2021.06.18.12.39.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:39:38 -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="w/8jmxyB"; 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]:55474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKL3-0003Rp-FW for patch@linaro.org; Fri, 18 Jun 2021 15:39:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001gx-Jh for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:08 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:45738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBj-0001T6-Nq for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: by mail-pf1-x434.google.com with SMTP id k6so8420080pfk.12 for ; Fri, 18 Jun 2021 12:29: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=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=w/8jmxyBSKlvXRwDrwQgpovS6jdC54Ol5itVKLEOrJ3pdVj9Xyzqo9NjU1wkuiQlKq 0gxhhGClhOl950E/flYjrAnYb3zkYcEiLqcGyBTSVyJiOgz3ga/9maTlGwurmDmnVrVl 0hxoOb2j7Sff9T4vhZ76gRRB/lGELv2E93CXBCU0zXCrvhw/W0kJEqDliFA/6fRByb31 8+m5kjaBayrCXjr5f8RQYIfvx9PMbB71UlxLil9EzaxIMXcM3fZL6BaunP6SKsHuZaoe rMv00ojo/EOHMZhZEvFIY+5j5e4GOZJfkQ5gA9VyMlWo/YsTjpiPk9DWViVzVzgU3vJJ Lwsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xpu2YK19uuJHVJ3NNjszM1h9FJEm/LgeiKDUdqCp49o=; b=CVWnzKyB46jUCSm4fyMs5odknbkUJ2B/+E6CUkpIshZGstGbpqRCXO8B+IMAAYPotI BHha2JVtTPZJoI0WDilCdMQ/49oh8Yw3blM9J5GMkD2Nmmr5RPCBlJM5Wk7AI5cH+IDA GBeWe7RQowWCpBT0EhRZXcQFUIIfaqVgZLuZ18hFh5JnmlenCVdNzabdi1PxIFT8qvBl vkHbAhLrsBQXYKbCAcjD0bh+xFw1LyR76edRry6mah1e/N5ZOH2shXXyU8r9ptvcgNh8 Oc2PBcbmU+GyBujxpbs8ZMzN87TIADxe3pJZtt413zShQh4NxwF2LEKq2ovFFgP8h024 ZyrQ== X-Gm-Message-State: AOAM5305Najp5LU5a/NYVDgigVTfdG4H3rh3vJ5eFcTDQihNrVxcmz48 QmEPz1WqXpGPoLQiOJiw9DoUbR5Myxp6KQ== X-Received: by 2002:a05:6a00:1344:b029:2f6:5ce3:218e with SMTP id k4-20020a056a001344b02902f65ce3218emr6600467pfu.80.1624044598536; Fri, 18 Jun 2021 12:29:58 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 11/23] linux-user/m68k: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:39 -0700 Message-Id: <20210618192951.125651-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/m68k/target_signal.h | 2 ++ linux-user/m68k/signal.c | 47 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) -- 2.25.1 diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signal.h index d096544ef8..94157bf1f4 100644 --- a/linux-user/m68k/target_signal.h +++ b/linux-user/m68k/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* M68K_TARGET_SIGNAL_H */ diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index d06230655e..b4fade1ed6 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -38,7 +38,6 @@ struct target_sigframe int sig; int code; abi_ulong psc; - char retcode[8]; abi_ulong extramask[TARGET_NSIG_WORDS-1]; struct target_sigcontext sc; }; @@ -75,7 +74,6 @@ struct target_rt_sigframe int sig; abi_ulong pinfo; abi_ulong puc; - char retcode[8]; struct target_siginfo info; struct target_ucontext uc; }; @@ -129,7 +127,6 @@ void setup_frame(int sig, struct target_sigaction *ka, { struct target_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong sc_addr; int i; @@ -151,16 +148,7 @@ void setup_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; trap #0 */ - - __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), - (uint32_t *)(frame->retcode)); - - /* Set up to return from userspace */ + __put_user(default_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -287,7 +275,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { struct target_rt_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong info_addr; abi_ulong uc_addr; int err = 0; @@ -324,17 +311,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; notb d0; trap #0 */ - - __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), - (uint32_t *)(frame->retcode + 0)); - __put_user(0x4e40, (uint16_t *)(frame->retcode + 4)); - - /* Set up to return from userspace */ + __put_user(default_rt_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -410,3 +387,23 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + void *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + + /* moveq #,d0; trap #0 */ + __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp); + + default_rt_sigreturn = sigtramp_page + 4; + + /* moveq #,d0; notb d0; trap #0 */ + __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), + (uint32_t *)(tramp + 4)); + __put_user(0x4e40, (uint16_t *)(tramp + 8)); + + unlock_user(tramp, sigtramp_page, 4 + 6); +} From patchwork Fri Jun 18 19:29:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463084 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp177358jao; Fri, 18 Jun 2021 12:41:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhGBv0K9easqQIgKVvKO1fEiNita6p+44+gAlhXTdU1pe11t2Pd8rBvX/4Agn2uQBeYX5D X-Received: by 2002:a05:6e02:1284:: with SMTP id y4mr8752596ilq.240.1624045275532; Fri, 18 Jun 2021 12:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045275; cv=none; d=google.com; s=arc-20160816; b=G36uLihk9v7goZPbPzK3p8mU/qRTHKYpK/FlBZ1mnSQMHpcYmbjYHPMCQaSHqQsr7t UJCqY3YGQSWgNa0aIZWC/6tusqoSRnFa0GzznMTEFMqvUfxT2ch4obLFgk7DGaOaZEau IG4kwXqafUbhI/f6Tkux96GRcCa4zEea+fimdB5fsp2fsYguzWf0gATdMvi3JxFYhIJu YS8L6kmCaNqjMUnqTvQmGRQ1faWK28Rec7U3HrkWR5AiSSQ49aFTVPt/zzsA5mAV/UfB 2tVfda4JGgbv3rXv7D2n9ywjqGBY72pQMOYBdij2As2NhBakFNlCB9ZojPKEjGgtzX/6 QAzA== 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=TA71KdY0ADT8/xQwWyVtukyaxSrQMBNG8W0Sl0VZeBM=; b=W39IXg0TUwbkDOOmQ/6dhnMJGJX1XJJVXCf31uLJzsb4BAuV5Be43UAwqY4spek12Y Z34JI1Ru6Ngh4yVXjNIWx7tKLTSnOHd2XuudqWFNfJuioiRUOARDiJv6+H2/DpgEW8wE LZtfh759T4ZlUHYcMX9C64D0ZUG3zn6wp5oWRhjIsLIK0CrpX9FX2SN3IvouncqSuYCv HU9L82neB/HRk/tlFr1rzQOGrI/wCR3QEkXioh8TkWTk9WKmK7OD2wMMj2J30SrLSYtK QIMogbzRteiC2+Wf2R5EW9+cPvPlvIgbFfljDkmbNjc1NobJmE4ozpsjExd0+L2eJ4Z1 CKeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WCgmp3xt; 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 p24si8553927jal.79.2021.06.18.12.41.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:41:15 -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=WCgmp3xt; 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]:34514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKMd-00006d-0Y for patch@linaro.org; Fri, 18 Jun 2021 15:41:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001bV-Ud for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:05 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:38642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBk-0001Tx-C6 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:04 -0400 Received: by mail-pg1-x52f.google.com with SMTP id t17so8594240pga.5 for ; Fri, 18 Jun 2021 12:29: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=TA71KdY0ADT8/xQwWyVtukyaxSrQMBNG8W0Sl0VZeBM=; b=WCgmp3xtNOWyJCeVKGGBOhtZ2erCff7jAAGZlHCJ8unArE1RjHmrV69RNVbIBNSeHR vHLbrlKE9lfBqsghv9OZqXccqaglsmJPDChnldYDYELnzNafPLG1wyZByH/p1hnGUe2A Gkqp0eUc1zhqusZMyIqgeaA+0+NwdVoYYisYhKP+PrySF6i0UEb8z8tCw8sgdvv9geA9 WB43tRLRE4uTURIcGHaJktz4/Im5UGtpvlYnbB7yHaoRy9VmKTMQ7O5RV4noFDSpl38j kgTMFBXTFxM/66TrGuYkiSYF0HUIDmLKr2Hhkd7t8D9IgVPvmFipIGo0fFakxnPy7cF2 2bDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TA71KdY0ADT8/xQwWyVtukyaxSrQMBNG8W0Sl0VZeBM=; b=gGdt3C3znC+/C4E3jauB0QSe+uqF4FfSilk4oo79VxduiktUoteh7ZDeEL9l+G4LHJ AOtwxP+IqL3cDaqS+BoOzz9dBE/9kYKUWxplBJS4wPF8ScjA5k6gJInU0tenzl+3+UlT gS4PdtG0GTLHP/HztHCBbHpzVosAJo+MXxhL8EZ0NPVgVW54WqjpQpMe7b99Z+C5hXru tvPRdME/UMr4aNif/j9+rhHc8fkQCRypJOQZSHwe2lAuWKYFJAljAyDV9xdwdf3gv+RT VoVm1N5XfArWpVsg8NAc5awjnG/QhOaUa/ISKSomL+kjpa6sLSks5zTeflTndS3eeVkB LVNw== X-Gm-Message-State: AOAM533ij5yZDalQl6TbLIHvbjKKHBikF9+h6kAkWYRb/W4kSvEjIwyr auwR8hNSugmfnrJzLq2gKTHSu2tFHLA7bw== X-Received: by 2002:aa7:9912:0:b029:2e9:c61d:2f27 with SMTP id z18-20020aa799120000b02902e9c61d2f27mr6651823pff.60.1624044599173; Fri, 18 Jun 2021 12:29:59 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 12/23] linux-user/microblaze: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:40 -0700 Message-Id: <20210618192951.125651-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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: "Edgar E . Iglesias" , alex.bennee@linaro.org, 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. 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 4c483bd8c6..aa27454931 100644 --- a/linux-user/microblaze/signal.c +++ b/linux-user/microblaze/signal.c @@ -160,17 +160,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; @@ -219,3 +213,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 Fri Jun 18 19:29:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463088 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp180136jao; Fri, 18 Jun 2021 12:45:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkYxB5oy9UxvXcvaANli8MLLZAM2WMMe7RFcfPrzMpJDO7aj66DjDcJjsWfp1r+G0rdd7u X-Received: by 2002:a67:c513:: with SMTP id e19mr5730974vsk.18.1624045549700; Fri, 18 Jun 2021 12:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045549; cv=none; d=google.com; s=arc-20160816; b=wtj9dqfQtKHmGiGHm465K6lXP4dufdEVpiDy6L8RL34MaDG4sTcfB7KKTcsufUZgQp 6t32+HhAOrTt2xHjci64hzH/NbKZzwO5/WPMS3pcfMD00Z2e45jokpMI35dpSVlB9e6W Di3T8HtPVAKRLtoQr06+okuAxg4wN8mLCvTqJuOavMZ6DuVETbtXkWe33A1tuEfhKVNK jB+sqzA5bgSthK8Z6l8qFkQfXZIOwcDmUts63EE6sQsHZ4tt1PgWV5USpl/5Sfao8ms4 k9PzrxaaeONn0SzuW1RbLkeAs4kPePT0E6an2Lizoojf38XUXFFa/mx8RqSJc25O1oVF 24ZQ== 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=aQk6J+grHW9DaaqkgSJkr7zW933EyDuzJBNH6gtlGcs=; b=qC16GxmNWOzOVUf8su4ayZYR1ArkAjyzRjbKi5JHvQAxCjtpvmvp6PjV9TfTd1fVWK GQ5FZC6GrcYjbZfAZ5k4tf8a3/qSEjP8bB5BOH18KXB9epmfHCP5DScu3qNi1IWXRvsF Xcs9zcxMV23/TPX5vYwEYvAUcdOuaOxirZYbKU1ejgfUhKZx4NwjNeI6XVp4OSmpBlPI Hp0fLdsAPinnSToKmkj2qrfLSd8Sm1hzw3S/K4ULCTZa0imYwoO0QqMIc6M1KRM6yprU pWdG7oLClMLzXtl1CM+p5XBhBYO2q47bjVGVaAlG1VnYD/0WrxgCBmVu/NSeUINZACVS +vmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=suSbYMs7; 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 v3si6479923vsq.437.2021.06.18.12.45.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:45:49 -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=suSbYMs7; 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]:46020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKR3-00082B-41 for patch@linaro.org; Fri, 18 Jun 2021 15:45:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001gS-9r for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:37773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001UP-2w for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: by mail-pg1-x533.google.com with SMTP id t9so8580996pgn.4 for ; Fri, 18 Jun 2021 12:30: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=aQk6J+grHW9DaaqkgSJkr7zW933EyDuzJBNH6gtlGcs=; b=suSbYMs7yIp+guc3RNSDsMT3zXQeM5yYei1ZLqLw8UlSgGOvym49StfFS12quacRut 53edUfRYfgc2wGVUVnMx/rMefXGHtS/tbF07ugPWG/REw/CzwCvpIxK0wZqZWQ7zDVoW qvGurPO+mfoBvqVe3KXjUyrA38s15fOrBLd51DkdkRHJbA1kS9TNtWCFex13wcl+mc+S BXe0YjDZuK2vf0+/giapqtgHuKDRUgbzCdOJio54UWHWADR0nmLuunHIXMfoaF3Tp/aM xs/37Zc+qG0MlvDRyEzkr/09iZVLdP9v16nLvOK1MTCw8Yir9cNrlRpoetFrQbQLwkeZ c3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aQk6J+grHW9DaaqkgSJkr7zW933EyDuzJBNH6gtlGcs=; b=Oxxw2pkut+rmbHinXyWnWuinSDNjHbkKdp3axcb5do/Ru5KNZ26hDfa8bodkgWNXSU ZO6csdCQ4mB9eOQD5WjFZ4mYqXV6eACd9d3/H8rDtgNt10y+95bfnlzX/rcpuK9Xusv6 9CvMlvMvyltkvHLIiMhOwiaDeKznBQ0Ay6RCosJ5CxgIYVz2CnOiWa6lIRrBVvdCjo7u JWP/bXFuwjjLiPGq08gp2oTs3y2gAL1ecEraFn2aQaZXVKZ9KABV14ASp+R1cogAOt6m nfFYYwOLg1q5I75ThiA1FbIYaLLZi8RgqGhn74v6sGuog9dDR3fPkP7dLu9Lf1b/7otN j93A== X-Gm-Message-State: AOAM530y00x+RjYLc4zFe0LVsXIPaYOInE+DudzGc0sO5TxZHYATezRb HyfraTWW8GXPoLYUsKx6bE9YcBIeL0ljdg== X-Received: by 2002:a63:6642:: with SMTP id a63mr11399854pgc.241.1624044599822; Fri, 18 Jun 2021 12:29:59 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:29:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 13/23] linux-user/mips: Tidy install_sigtramp Date: Fri, 18 Jun 2021 12:29:41 -0700 Message-Id: <20210618192951.125651-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The return value is constant 0, and unused as well -- change to void. Drop inline marker. Change tramp type to uint32_t* for clarity. Signed-off-by: Richard Henderson --- linux-user/mips/signal.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index e6be807a81..7cad7526ea 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -86,10 +86,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 ... * @@ -99,7 +97,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 Fri Jun 18 19:29:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463076 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp173830jao; Fri, 18 Jun 2021 12:35:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAbQH+h30Fg2sz8KsQcTGuWqcKHYLMreOfJw1j2rIYYGvxZ6niisGB+EfEIsAK+ISJD3l+ X-Received: by 2002:ab0:1e04:: with SMTP id m4mr14632119uak.15.1624044952946; Fri, 18 Jun 2021 12:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044952; cv=none; d=google.com; s=arc-20160816; b=fHJntyOSiRToY8ioxZR8qnDNNM3vGolXM8s6hLIayi5RfgUOpR458jGyR726Y3P4FF 5cJ89Cooh21iZeiy2HPFmCN2azi81V2R+E2OTeQjPvJpV4kG6mvpLQr+xkKGBhADCKiB maQPazXZmZRl7AD8QOSBWtdRjLF39881zWcPFIUGRCDUjCF6dCjKsVyzugYd98hzVwpw x3nEpgASfZqR8qfB+qmw2EUVje9kj9T1mYTaBjPLizpKHdoz6j89Ia6kUEHnEEu9nbeZ RiEydOXmI8EFTv68LpxvfSIZcswETRYKYYixSvo8v4P5Ac9tubbT6tAk9blUAagxDuRz PBJg== 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=fJ2heq9/ybEPRov+oRcE6gMbBb+FglnKkmzlhd1SVGQ=; b=VPJAD2cXCabdkR4Ic6xpvnirr8GBcqri8kXuO3V0cnNrcNPS4zAv/tR5wD+mZwEqPF mGEp3NeCMA9QoGwmBc3HNMtrw4VR/rAK2o6dOyABsTs2T/tZZ5kK/vyq6RpDMUQPEaOh RntEEZlWIJZDdla2cRfFmKWsJxBccpuaUqiRN45DsV4bwaR9L25soemhBRzMdqN+InKa f1G9TfoF/N5MIPtluf+lcPUl9AxsMX4aTtzT8I3E3v7WNFm3DnTsOpnZVDPth/SAXYjt FNboikAuwWXOVvyOCmZGf8GD8sHbl8RaxC0DZb0JevhtFzvMF2JuDuO45W9hbKuM3Gdi U4Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LnRmyAUR; 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 j13si7545448vsq.188.2021.06.18.12.35.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:35:52 -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=LnRmyAUR; 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]:44690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKHQ-0004eH-90 for patch@linaro.org; Fri, 18 Jun 2021 15:35:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBq-0001ft-S9 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:36375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBl-0001Uj-Ta for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: by mail-pg1-x532.google.com with SMTP id e33so8601786pgm.3 for ; Fri, 18 Jun 2021 12:30: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=fJ2heq9/ybEPRov+oRcE6gMbBb+FglnKkmzlhd1SVGQ=; b=LnRmyAURUgstMs0u6vFLf8pOF4ImJsOJVCdptoR6PQTaDAmTGV7ncGfPRKn3qZdiRy 4aZXJyULOaQGJF27u06N2zasbJeolcS+U5PaanD8twwLI4BQkAM6242NeF/91awL3Wli 15wL7FYBGMc2nPbsX8Yx8mWc11JSmbvAH5XUdtDMgK+Zz1I3Qaj0OMxOMZVx33MObR1N H7cveWFE4tvzo/twU6nVgp2Dq+voquJXiuJ5eTeXn1AO9nIY7eXvi8Jjp9S9kV8rNNCw uCgRRvwhzmD6Gwk+il1wZ3dHNomezY/xjU4RnREHf5MMyzp0Mh9wdAe8I5n34iBz+47/ uBqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fJ2heq9/ybEPRov+oRcE6gMbBb+FglnKkmzlhd1SVGQ=; b=SxhGiH0sXxFLFuFJ2AZQYEKsM7iTYeY2MXn0MhFvI0alXq3GZs7wezqhrvDbHl3Cug g2cocxVy8xEtmgP9bGl4OZh55ytdZV+k0jusLL2f/y97b9w9RE+sJ6HN2+TBlBgEljRf eTiQJLZ2kJn1ruH8AtbnfAEoCYjeALT7tSXwFG7uaxMaKANevAoTFnG93QSRM70KnB6Z 5CyLqg4XpAyEBnYFVeBnLhxQLyGY2MWhFi1W8V79144E6Xa1mG/dlvm+bkPSHCMuOvPT XOV9kGawWeVFy/VIdI7COl43biGaRTszyx2uveZGeq4/64b5JVxWL2jew/ZrLjBLcexS PhnQ== X-Gm-Message-State: AOAM531k8O+sTxqWxLVrIRTLHLWVk3ZtKhs4Ed/S7Y1ng+54ORcHggdq Uj3DvVam3V3ycqxHofxPad7tQ0FHtSZoKw== X-Received: by 2002:aa7:808b:0:b029:2ef:cdd4:8297 with SMTP id v11-20020aa7808b0000b02902efcdd48297mr6748058pff.27.1624044600621; Fri, 18 Jun 2021 12:30:00 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/23] linux-user/mips: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:42 -0700 Message-Id: <20210618192951.125651-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/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 7cad7526ea..a3db08bfec 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -208,8 +208,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++) { @@ -230,7 +228,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 */ @@ -304,8 +302,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); @@ -334,11 +330,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); @@ -378,3 +376,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 Fri Jun 18 19:29:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463072 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp172558jao; Fri, 18 Jun 2021 12:33:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfPQi8f/FwobPS7TVELleoKgT7D8R3ef+J7mRziEVAo3FsEeV3DfSeu0x0mYgakHj14T2z X-Received: by 2002:a67:cd18:: with SMTP id u24mr9042474vsl.23.1624044836881; Fri, 18 Jun 2021 12:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624044836; cv=none; d=google.com; s=arc-20160816; b=qilMhM8QeawTvOYLFiJSzFhtsxRuePsfyIbVCd2/R9DSm9Mio2NGf5KuFtGF5IjBPP wdU48RfmoiDAXjcv4Gmft0P1RxzmAgjZfrMXW+zMg3aeaxheKPRzIK2SP9M6Ty+1K89V jMx5vg11U8i5UVbKXjlm+OAVX1hUIqqvNgECWw0w0BAPbDKWqriet+cZ4nChBN6IDY3H hhLUePXB/rsEwR4rVuIoNhwxNTejJblFw1449CyRyq5grFrhTfNGh9Yx2jK/2rgRn+yv ApgfsaP2qTRLoGtq/tH+3oRAPRw3bfawMPowFUPMw0wsWIGay31ZQCgVArHkAmKYoW01 nkwQ== 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=ZrJxA2097dXMmX/dlQGDy3yrhTNOTODlU+a5YheuYl4=; b=mT3vVMAxM5Ri9RarsScqXwKVikOgbsC2jRLnd6LPHpfN0rU7NB+IF30X2oF4SfGZuY 0TxVmyHlBMDMAOfcUVzbRmHzkJgLDGkpTlvcUczbpdMonxTMYv/olIbT9PcwcCOAwClZ 1dwIWrHp/rrlejoBpHPN8mbwy3DljZWKNifx4h+ZXf5yKVvrw9JeTT3tbsXefBAE6Y3f 3+Vx8BuAZY8ZG18vQqDt/qZNVkKLfB/08QcH607JYmB2/7rH0r9dIVJ5OIsq5WnkIyb1 cuoORras1yNFOWVo+mAcNgD4lhiDCRErnAsRIEWoPcFcottqVISvtBRKbgs76rU7BrGc S1Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=r4F0vv0K; 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 k23si6875099vso.272.2021.06.18.12.33.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:33: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=r4F0vv0K; 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]:36234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKFY-0007Up-8c for patch@linaro.org; Fri, 18 Jun 2021 15:33:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBq-0001dw-62 for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:35345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBm-0001Uz-Is for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:05 -0400 Received: by mail-pf1-x431.google.com with SMTP id h12so8466039pfe.2 for ; Fri, 18 Jun 2021 12:30: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=ZrJxA2097dXMmX/dlQGDy3yrhTNOTODlU+a5YheuYl4=; b=r4F0vv0K7h++rrjBcH4YVyP/irWyfQUiSAelLjujini/dwT8FILiWlr5gCB+Pt3W/7 KyloRbt2sf7Dy34s95pn3jNrN/iF0Y6rozt9incqTi/CU1Y0bL5FMTpEsxxaYTMgpxrg SF6iYpwgJSW5XbJpJPcqU8T6LlqHuCj6cvJX+gU0CimfC0PdbKZBz6cmmo6l5b9EEC9Q 24iOGk0hp1SYvyG5bK6dU6C1Vh2S+Sh8m1Ry5hJYvdPOt3foaZMSWWxXJQ47tJnmkY2G ePz2MvGa6rgm1xnYw+v66kKRTyM7OadrHRvQKimEku2hFgMcGA/V5WpJLMVhFHxJ4LTg 4hUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZrJxA2097dXMmX/dlQGDy3yrhTNOTODlU+a5YheuYl4=; b=aTd6UnFL1bf8osBl+PIh2H+Jj3Ca/kxiokmseoNvoUcUmNEp7iljkUvol8sFRBh+FY Z6lV+FwiM9S2zP+lyc8hmqPY28khHff6tLUMw/KPo8iw0tr8wAjeyJ9mUfbOjixbBLoD J9UJq7FF0PMdE9EYbbfXsfDl3OuFc1ss+CCuuxfbpGJmdx7tPaoFiO8l1p/o1BnKrlrm wjzbuPgGEVn8rNG8XzlAojM0bvRo8rqOVYFkdipK6x17jTC6WQamP7dUVGeY2G6mgtcV +bk8vSozMOYBUoDuB9HzPr45oR95bcqnL+3DZ5kHMX8Wk3KdoeeLKqEO0RWjx+SbEPBf +hTg== X-Gm-Message-State: AOAM533cfzXmTgSZH/ZcRehxi9hF/TtiJuXuIALEeh6O7CFGAdBDJ8Pa zzWUlPefeVxxK1XnCKbRFbfcn/1+k2dKag== X-Received: by 2002:a63:586:: with SMTP id 128mr3674093pgf.366.1624044601203; Fri, 18 Jun 2021 12:30:01 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/23] linux-user/nios2: Document non-use of setup_sigtramp Date: Fri, 18 Jun 2021 12:29:43 -0700 Message-Id: <20210618192951.125651-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: Marek Vasut , Chris Wulff , alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Chris Wulff Cc: Marek Vasut Signed-off-by: Richard Henderson --- linux-user/nios2/target_signal.h | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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 Fri Jun 18 19:29:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463087 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp179339jao; Fri, 18 Jun 2021 12:44:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI/aDaW7vz9EhxzSt0KX8FzMDt+CoBxDBJSYSIiPOCxJzlgvrd/ozVQbvcVpZSkRycOeHr X-Received: by 2002:a67:cb9d:: with SMTP id h29mr9471608vsl.2.1624045470461; Fri, 18 Jun 2021 12:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045470; cv=none; d=google.com; s=arc-20160816; b=F6+zDFj65jySW0s8g0IyI9qCs+6swdeMz+/AOOLSPpHBApOttcEAXVYJsDdehLr73v zHEBEXJDcGKAo+s0uODL77S3p2IhmUkkxOjcP/Y/3miw8AF0JkPpe2Xzy9Zymn5uD1wg ed0kJzG1k7oHrQOm0oz/9F06Ekr9y6XnGU3EvlTASGYffwTcK5/cXufqjId0Vlje9OOT Hxzg71SE6Ii9XC8EtLCapFVrgiiHmamM1Liwsig0uoxGGajI+k7q/YbrEkSSWdSzPl3P 33VpAjdr5Qql5uxxnM9Lh90KuIATXHqczrnj3fIHSfUgAgBn/MLv3unM9Pm+6pvPO3Aq Xnxg== 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=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=ttFqTevhbJjXzO562RgW/GY2v4BfcvJNKq8cb/MNG1gqTaGU7z2bLNZWGpudr98leU KKugd84LJLUczF6B2UeeT1TAlLu3EFlgIYpYE6hDHOddmGpWZDM4MXCAjZiUhEpYMjkB kJYbOITJ+xmVKKRfgm5DG8j2LfRxKiGL5LCTTuNVwylRYNXc8ij4QbEA50AQ7gFFL7jL cDnfg3J4nlOmO215iESxzYnEPJ2t+89laTFB96FctVf2HJzpnASVp8bvXag167l/crUI 4W0Xp6PRqZBmbW8D2f6hrGURbtqfJvsV3/WOeww8Q2XZ9uwgbiaeWpRBdM/bg1KqfOaK /evQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MXBJO8Wr; 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 x14si5348869vsk.173.2021.06.18.12.44.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:44:30 -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=MXBJO8Wr; 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]:41056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKPl-0004eK-SV for patch@linaro.org; Fri, 18 Jun 2021 15:44:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001g3-3s for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:41740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBn-0001Wh-6l for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:06 -0400 Received: by mail-pj1-x1032.google.com with SMTP id m15-20020a17090a5a4fb029016f385ffad0so3652236pji.0 for ; Fri, 18 Jun 2021 12:30: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=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=MXBJO8WrC0oYtShlpSZiimCAk3xfBhYK4sfAhbkPuU9rCjqhNCRpcaaBNgPaIksRpP 4dpAFHlwGl8nDk8JKf/oWoKIeCioB2aebw0p2NHEu4iZK4csDLFUXv/IOa9YJ8B4OIf1 5WN0Wr3qdM0CXDTeioptOnjP0QlA3Of/ai1f8CN79zvRMVXx30ZKnKXqgpA7/R6yUJAY FgX5AZ1WqOn3DIgEwcIO11CGuBU70wC0rGam19cKZxyUmKibK2GfFGR+2bDuMmHt6Wct NUyfi+4qyVcNlNQQb9R3F8IgjYWpaonmBotCPeGtAMPDL/DT3soTmIenpGmlu//lCUZN nl3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Vq41DCrZsY8w8sVZQ5+/3oe8dorwqbm8lEFaa2QNhk=; b=k3YQt1kb2ylsC6CidRGsC8iH5riF7/5vEyL8G9l80fRY+opdaMIoUS898bPeTCUt+A U2FaNHeeBhbqW8airPmCVaIEEbcbQUz8rJZIyeZR+9KgXxk/gX3gdqnw5dc9VL9Vs6en Y42NQcQIF4qPS8iAqVjKTG0c4htlS5spF9LQvKakrSHMYfueVRJD1RrYGWZ6+1GBJbYu rgjRJ0h9YcY+rC6FcIP+9AVKZYDpsSUl2cfi2ynKiJUieK6+3052pSsuAawln8s5fw8k 0YDGALQOVx9X63N7mCvdFLirjRD2xxtxosrKHYAi19dgbDi5jYThwLwwscxKD0o/FBH+ 4u0w== X-Gm-Message-State: AOAM532cz14FRluBBuXT2mnTu2IddOPcMu/CzDPMASz6Q9fUWG9cGCpl 0+rKPoyPYkYOGU83bt9oNLLkRP2ujO4ZAw== X-Received: by 2002:a17:902:7d8a:b029:115:77ae:e1dd with SMTP id a10-20020a1709027d8ab029011577aee1ddmr6170543plm.50.1624044601823; Fri, 18 Jun 2021 12:30:01 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/23] linux-user/openrisc: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:44 -0700 Message-Id: <20210618192951.125651-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: Stafford Horne , alex.bennee@linaro.org, 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 | 24 ++++++++++++++++-------- 2 files changed, 18 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 5c5640a284..b411b01864 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -37,7 +37,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) @@ -115,14 +114,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)); @@ -168,3 +161,18 @@ 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, 4 * 4, 0); + assert(tramp != NULL); + + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0); + __put_user(0x20000001, tramp + 1); + __put_user(0x15000000, tramp + 2); + __put_user(0x15000000, tramp + 3); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 4 * 4); +} From patchwork Fri Jun 18 19:29:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463089 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp181073jao; Fri, 18 Jun 2021 12:47:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9MNCE4Zh1DpmwT7kn1jHhje0OF02jZvfT8hXa648gubHxOCAqB3GPFu1lLK6vUMFWykzL X-Received: by 2002:a67:2c56:: with SMTP id s83mr8959582vss.53.1624045640385; Fri, 18 Jun 2021 12:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045640; cv=none; d=google.com; s=arc-20160816; b=obxNuWU/3g3tGs3gn54XmyzkM5V5ispCZnZVADWFY9C5tgkK2trR/dI2fkO9+HMrDG W/kyBWzoM/MUpjs7CJkwZv/pS3oePTrPXfBnZx+BNptQq52uK8uihjxo5tlWJXxvJi4D BurBan52wg0GWDYrHDopDMUDZMs6BRn26VXMewnpIM0fje0BAedDXb50QgHF6v9xYuwO gDLpcue/H25mRRD9AWGyYyvG5yxmnzRqCTa2muyDnPL8fO5MM8ww70pL3G2G3j4Ho1/x hg+oOAV1FbVA0DfzsRpD8q+BcsUlaRRmXGMCvS1kQ6+SipP21xxgH0mlFDuCKo+nEI+k SI9w== 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=Zh9h+PmWbwWPB35P4oSzNT2+LT+dobQgpXEUdOMWBj8=; b=BqWpBPRJa8jkmM8Mq22lZHt6Tk9VJyieprBvHn8JCufQP5tf1yqN7oOkbJduptTFID /hY8YufEOM8iZDjumhrdnAVola5ALfGGJtdtIkHSwIWndwXrfSZbXBY0dX16ctrXHGIu /KeTAgS996MMcrSd3Lyw5fwJu7NhJjymNhpE4Dlx73A4jSVCjuEu8Wka0q3RxzEgFZTz cRT0tJNtptviXbiIT1pxPaozG8M2hGrW6q8wrLYYZIHp4bOesDN0fsFrcSX8gjq41zSp Fi8acjmxWENxToHlDbIop41DNPlTIZV1gJn5lK00a9SDUPyNnDfGot0fOa8vs1f++KTE n/yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dvxTx89l; 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 m2si8014323vsn.369.2021.06.18.12.47.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:47:20 -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=dvxTx89l; 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]:48386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKSV-0001I9-RS for patch@linaro.org; Fri, 18 Jun 2021 15:47:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBs-0001h6-6v for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:09 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:39767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001Xx-7g for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:07 -0400 Received: by mail-pl1-x631.google.com with SMTP id o21so5193480pll.6 for ; Fri, 18 Jun 2021 12:30: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=Zh9h+PmWbwWPB35P4oSzNT2+LT+dobQgpXEUdOMWBj8=; b=dvxTx89lOsQh5ke2jZafIY2SdwMOM0OI16qYjtPzNYj1tZF6lCtpuTfVeaLSR/w45f YQO6Nx5rvN1C7r+UjdLXJMKdi13Jw6AhPKxBKVWsZ2hR9B9xd06mYB73b9EGdLmRkgbp 0fu8WQSc5kwpKZVcQTcMK5kwh1P76gJ+Xt76mYtmRWYjz8ho5pKTi/YB5mVC34uvqJ6B MMnyLvVTOrgwJg63AnkhhDanazygsbNQj58uQTUw5XjwxJ/lkDI+/TURTU7n7HgJnn8f Toe4h1klP3HU4ErMiWCYTH3GcYbRtH1u0GcxOxsyNGcpAm9OX0iXWushAp5Ps2LJs+uT vtOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zh9h+PmWbwWPB35P4oSzNT2+LT+dobQgpXEUdOMWBj8=; b=E8az78/QIR1ojn15hz4tbfUFmZ/5zFb1rPIquIA0WCDvakuUiHgh23HxaXuUriIu4v Qdrmu28z+XipfBwqKw6Zo8jixkI/aJ0Y1/XD9p5AJ4qXvihd6+IaPvCRf/z3Zl+NXold EJkeD+d168St53PF+mtctBq+vD++BHwRhE95wgdBSQGGlojrDr+NBlo9uRX511McHL08 GV0n3o7bKsbdWwXxPI2E1cQmrBwhGDn+j1kQ9Kwixy1L59g/uMR0vMbzzP9tTt5UadZV 1G9KWmOhowsKxFqHbseZXYkCr5icYsRz5Y5FpSNQTh/N2u4GgosgurfJlqfMSzNRUHLe u7DA== X-Gm-Message-State: AOAM531Gii3yC5fNw8HbY0MiN4DSJniuaEEwArW4ilQ3UYd+gUG2P/NX VkkLPVGiF6Y7ntCosW0KCOokttl61JTP+g== X-Received: by 2002:a17:90a:390d:: with SMTP id y13mr12789089pjb.52.1624044602466; Fri, 18 Jun 2021 12:30:02 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 17/23] linux-user/ppc: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:45 -0700 Message-Id: <20210618192951.125651-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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=unavailable 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: qemu-ppc@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Cc: qemu-ppc@nongnu.org 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 Reviewed-by: Peter Maydell 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 edfad28a37..4ae35aaf6d 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -202,9 +202,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, @@ -437,12 +434,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; @@ -478,7 +470,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; @@ -508,22 +499,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; @@ -721,3 +707,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 Fri Jun 18 19:29:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463090 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp182076jao; Fri, 18 Jun 2021 12:48:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgSyaG4WIHykZhpSFXZ1Qt4T1/ghrtb+UZfXgO1nG5G9hOXRqJ2uEqWrp++tUSnnpjDvLP X-Received: by 2002:a92:d9c1:: with SMTP id n1mr8213321ilq.70.1624045737017; Fri, 18 Jun 2021 12:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045737; cv=none; d=google.com; s=arc-20160816; b=YXoojUHjf2inV6+ZV2SBLzPRTlqu+wEOPiosR59+hOw/GU6hVj1IL3aO0iIi7pUeRw mM71jvTndjT7CyZCTIBVORSBb14AwT6dM8n+B+IqJkuxcB09oaAmCFLWZ09QUu7RJbAR cM7oye0GnIRlLPbEI42sA2bqGSgdF92gdI5CLk8mJmfGIveR1d+qDrplS1VbUWxiHsFD yeFo1JPzPq/7qFuHZ/88tuEgaoGh7Xcxim1lp2OLJDzfPi2sCwyMb0BchlgczHPXLoiK 6FKxLTdNn1vsvBh6MbjNQM4vPnPenI802wJjU5XrIALLP5xX2kSbCQuTEZ1y5cOjViXB GIKw== 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=MOtcx8UXoEPFGOBT2e/rKGCkRm/dpzMLp9SnX27LvpM=; b=f9MWq969mTdGsULy1tk4WTthDKjETBJ9C8uCPIVHnKdgV6Pbx2T3jNCaE0BSeUh018 cJtnUqYLz11Md4UQy4+PmcEHKgv2rro4s4MlUYd2sxwJIJQLGAWVrE73BJbh1Tm3QeP2 4AYVJsboiwyecf+PnqNisCVHp3Q9VjiS/QBN6ujMcnzA1Hk85Z5rDefJtLulpzLioQwq ME9DJz8pU2ySU+5ezunFEhIcTwWSWbH/Zk/I/ln1ZlMi2dLq6ZPpK62M6osWNR+migPC 9sZZFD+8U/cd/wVk8tYZWSupSmfjlfLlrFQFysgw03NcttFPD9BI9LHTaSGY6W2ivkdD v2Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mcv4VK8f; 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 v6si9581598iom.67.2021.06.18.12.48.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:48:57 -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=mcv4VK8f; 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]:50682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKU4-0002qz-Es for patch@linaro.org; Fri, 18 Jun 2021 15:48:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKC1-0001jb-Cz for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:19 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:33679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001Z0-9s for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:16 -0400 Received: by mail-pl1-x636.google.com with SMTP id f10so3071784plg.0 for ; Fri, 18 Jun 2021 12:30: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=MOtcx8UXoEPFGOBT2e/rKGCkRm/dpzMLp9SnX27LvpM=; b=mcv4VK8fN8UZJ7lFtjj5B8HbT/akpiVAya9R9vyr5G1Xw0Md17FvMBF8mFcUox2lwc jPgun0nlsWZ7FUWhjrvPYrfxkNJ9pUG+1QJUawjHBA9PaGKdV3jfuFgQ1OD2w3w+rDD7 kSWxi2NgzF+K+ruUv8sItoBBE6KtA8FahQe9uEGEifLNnn9WVf5wRb/u61F8gCy5/gbq QhCyGEvXOflGGQ9rvPrcqinhEyrSLtE0+wrkm5AKLeYZNLhUE3EBMuli2ywiVrggZ+xv yJrxrl8UqgW5o3yQh+co+DezTeVacWQhwxPRgwE/pk1qxyvYApGrMeRvS0Rd9jbOQ/uK s46g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MOtcx8UXoEPFGOBT2e/rKGCkRm/dpzMLp9SnX27LvpM=; b=TgQPXiQfWHZuUpr84HoBqpJ76P2qRkIDm/W/R/YsptTBB4NPIqLRe3F9m6MVLQp2gY oOm7vJghbEIEbhLwpTdu368JvCFEpBSG7IayyAvPWjG/p9WVmlsSK0HTcTT2C7nRj3wH a+FBhqlHoHMdDS8YegQHHdGs6btaPTv1HmjMGfeVE37CqaJRMwk46yOeTmifbbB7be+B Xogh+lAH3V2xvc8bOAvkvamJLu7BOPVFQrHELaBuPCmkXnpXehCv080jMTOrBluSSFye BARjieQ29jp1gCmjWBnjw7MmruAKCW5DVRooiDn8zKh3R10iPhmggEcBEkFn3EZmBiao F+Kg== X-Gm-Message-State: AOAM5317N6kzAU3GTCTScj++lNwluVmrq/4SnrhpUngz2nsxO1/5chj2 nVxbfylAkE+6QVs2QLs/OQSjVd3g/aBQQQ== X-Received: by 2002:a17:902:d4c8:b029:102:715b:e3a5 with SMTP id o8-20020a170902d4c8b0290102715be3a5mr6103064plg.83.1624044603042; Fri, 18 Jun 2021 12:30:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 18/23] linux-user/riscv: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:46 -0700 Message-Id: <20210618192951.125651-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , alex.bennee@linaro.org, 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 9405c7fd9a..4086dfa5d5 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -46,7 +46,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; }; @@ -104,12 +103,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) @@ -126,14 +119,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; @@ -202,3 +194,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 Fri Jun 18 19:29:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463082 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp176152jao; Fri, 18 Jun 2021 12:39:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJWKzbDJfyvmn91vo+w/nCdevWlSPqVaRHYtrAb9ENDj7Fv0g9cufTHXKmzvXlMiwxHAcA X-Received: by 2002:a05:6102:3123:: with SMTP id f3mr8628064vsh.50.1624045168690; Fri, 18 Jun 2021 12:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045168; cv=none; d=google.com; s=arc-20160816; b=quYswGrKEoQyzR6sPo5JU/qlS+wmnptkTKhmF6QiouMDxwZq8ckbM6m/Y013Pd+CDI L2AyMhawGCXrPvTL2E4BFV9Q3dk6zEEB9uIZ5N5mocEEN5xD6hql3B2EFMoVGamTeVPi NV+3dIuVBwHKrnqWzzvuw3KqOsbNOI4Pvw/WXbUJgCy4JkogMLesl4Hh2Wm6qCwnnMPB xadLP+VpzzjXLVisieM8nBGo5egOkI+bfQXUsy7+VrLdHEVY92FJK5nAlUwxOpw7ygrI +7pLP6TjxnQ3WAwOEJtIqhpow1su2dnAnVWbLM5aD9wvzqgBYkB8ebdtHCRFufoB2zu/ SkaA== 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=NC4wjKEI8ei8zXE+8oh5v+0BndNCvCJb6FftDxcNOnE=; b=zgbGnhqAP9Ac2qXn5Yr9Mn9qC7/lsQhBbGW5vDk3VyKbQjek0wH29PwfuRaSzY7ds6 YlZvSELlM5GwMqFsFhCvv7pMs05tj5nVJoDMDpIF5RcchXm3BI2nPl+8L8GI8QIdhmMc UNeSFpo33B6SNOoV1ENhZHZ4CojXOTlebRvaGn2soZqK0fWWf/IscnTNhG1U0DA8SXro ogqwVf/eaPeGpeto06+Ak9RRQgS6dSmAxzfxrcRUfJpdg6KkzR/xvveFQTZcHkdiS6GX EQVtvPEQWs7Tg8E155XeNK9XSCXw3KSZdHBx6iwKlhfH8WD8uyNssjhzeQwGikaIsVF4 406A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=T4b3zjm0; 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 w187si7686659vkh.28.2021.06.18.12.39.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:39:28 -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=T4b3zjm0; 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]:57458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKKu-0004o6-1K for patch@linaro.org; Fri, 18 Jun 2021 15:39:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBu-0001iz-4x for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:14 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:39768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBo-0001ZW-PG for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:09 -0400 Received: by mail-pl1-x632.google.com with SMTP id o21so5193506pll.6 for ; Fri, 18 Jun 2021 12:30: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=NC4wjKEI8ei8zXE+8oh5v+0BndNCvCJb6FftDxcNOnE=; b=T4b3zjm0jvUgmrtHPiEx74l1HZZC6n7bYilccyY3ECmRzfdVL+oGYlndRJCa5P5jeB uJS/6R519bzMeuU+ALMMGUecghY8xsopn83C8EEOUJBHYHucbWgT2RXZIQT8sbW5Az+u FECcffJnwW+3f89wJRjujB/UKIceweW7xxTO8KA6vGNMb2zUIybWGI4kBTUb2qLvCF8w H1BcBO/mj/r1MXvI/Ktovo0A3482XGm0/GMZAo4YlFYvNnnY1lUI0qUPWYUiRHsuNgNj FAlUHU3HXZLAeVaeIA4qn15ipn55Oc/YviLnDXEcfgfYYBoL5ymwvVknd5ejxMhQUqYB y6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NC4wjKEI8ei8zXE+8oh5v+0BndNCvCJb6FftDxcNOnE=; b=ayuFdT0KIyU+1QoRCyDvSNqGIkZsIhLjLZt0nbNjbAZjFx7AZtVHNd0F0BsGFn7eHa 72oT7wPFTcqHYiIYvQb9Nyzs06DPsYvAG1F5hprq0nejB2Q3RIw2D3M+nF5baMv4Z1zp mYiJwRecFgefv78vh4YIrdpIxfEO9SLCGqP8HEwYQl8Y4Xn5MH7ydeUXaj4PD5AUkxKv HspJpEdbb9ZMNbcI1coi/uCTmOX1nHE1Pvatlu6ek/HIxSScyufGX99tdAqbzpXXloSi RUDFX5XGbNmIG5QNmonOjI5Eu7NWdskQdiu/ki0LbsGStemQaSjj1soh3AM/r8KyDHzO ijyg== X-Gm-Message-State: AOAM532VqKUOC7MxLw+aDY1Tf2LaHqvuPNvC8B9TPQ/dpyXtOauOtAC5 uaQUmkWebz1JjrdTkJcJzUJFBKbqfTpjQA== X-Received: by 2002:a17:90a:ce8b:: with SMTP id g11mr11728706pju.170.1624044603556; Fri, 18 Jun 2021 12:30:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/23] linux-user/s390x: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:47 -0700 Message-Id: <20210618192951.125651-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: qemu-s390x@nongnu.org, alex.bennee@linaro.org, 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 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 ef136dae33..372861d6d8 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -67,7 +67,6 @@ typedef struct { target_sigregs sregs; int signo; target_sigregs_ext sregs_ext; - uint16_t retcode; } sigframe; #define TARGET_UC_VXRS 2 @@ -84,7 +83,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; @@ -200,9 +198,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 */ @@ -253,9 +249,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. */ @@ -377,3 +371,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 Fri Jun 18 19:29:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463091 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp183093jao; Fri, 18 Jun 2021 12:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEiEAx68QH346NR0oC/z60ZI72UyA3LceyQV8N/q+xB0L7gZNgkWdznDUaWkXiwmbBYiPH X-Received: by 2002:a1f:1846:: with SMTP id 67mr7969864vky.24.1624045823219; Fri, 18 Jun 2021 12:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045823; cv=none; d=google.com; s=arc-20160816; b=fNxBWPzPRbuTS2pcAiH9B+ttzX/zVsnsL2ocMak/hubKYPt6ZWGnidWiqzPBLdRGCA YGQPSdFaTzBuRpsTpPB7BYzPLcPdq/zieEdPSywzXAO7oHzX/f0Oj3mlLnD+oAhgse96 RqfVgyreu970YyuuXxd+ZrH3+un3iMc5oNXt46lQxpvfbfnBt9sam6HbhrFtk7CSBrT4 xCKLSpl17TV5rwV0Bwn0wS73nxT82LtOyrWOdA09OSYIljhnq27UeaXJvb3MyBAyernv 2r/v9QZFqrtOtx2ErEgN+YHqczHAZ5cQMogthgw9w0XDJXz+hbxW5NeSITlR3kFVh1Ws bSog== 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=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=GHFKmL+vCSJ0PBkvbC0SvfF9k/lFLpJC4QoEBBMe7/kNBD151xYMKq+XBNySyai+WH YG3DEkAojfSHHHNxwtlBuXWCARfa/s4GvS9u5MsvDC8YoMnB7aQajbcXGfz0EEBWYh6/ TJMGKoEYPs4Wb25EmPCNrIXrlokrKdjHOWAz0xCBggyLlR8dn0Va020AOhDr1TVDFR05 cNJmODXmMQHeYSSO0uJpjCR5P+zYRyCvcwV3svL/OVIobhcZj3tk06QNhT6o44cbX8YD iuVqUtcBFvca5algfYP/fLTZADgZkQImyNH76ZjLayG6L6m74CgKkxA/K/t9Av1oChuq UfeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VWn+KDWH; 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 v18si4531181uak.48.2021.06.18.12.50.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:50:23 -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=VWn+KDWH; 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]:55004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKVS-0005hK-Ag for patch@linaro.org; Fri, 18 Jun 2021 15:50:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBz-0001jP-SW for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:17 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:35368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBp-0001Zl-Bb for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:15 -0400 Received: by mail-pj1-x102a.google.com with SMTP id pf4-20020a17090b1d84b029016f6699c3f2so1351219pjb.0 for ; Fri, 18 Jun 2021 12:30: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=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=VWn+KDWHp8gxLLDPUeSGh+anMq5EevRP427IpnAXrbv6BYCLLO70cts+v1rRdpYRrw oyBrHD8Ao1FrAOx2aJ8ESpq8noVlCFh9bdvIRmdLLuXbrYZUxpwbbhtGxrB3dZy5woes t1fux8l7fx+N2aVqVJLtUPDx9/KAsyi4rogmqqxB6Un6zHf9iTG/q0p9ZyLTxUfLCWcP H7/6/Ek/nqGRi6uuKMz+oT1Z5IBJbxuI/Zlry9Yp13TrQTeGT+bsr0nynDVkYU8CUTn4 QYZfUNEoAmt7g6oXc7CeoSPkT6MOx1oNx3BgQ2ro8qfq76cQ9v/piXPzauEtieNdzMgv MfAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7UwSZzPtNanlmWoP6K+UEdnWrT6YCBYNNgPR1NCdYPw=; b=QZqhhsIaZwuosw2QCawNJB1Cz1Tp7KWEzeSdpvIU9ukqAcrI6xj2CkQS7WBgwJxGXu BODVuXfUhlnkuSrTS+oLv06McqJuipg+YQvClJubH9U8lxYiBmJ2Oo+6MPJW1nGqUoyD V7wlLCuk0rApPX5KeGiHCOlSUmpK95HReBzdxCI0faoVAj4sOCY2ZMWdExZXq/r4SsWS CVNSJ8vxAN7akjftZ0b1afhYtAFR0fjUF3sIC22xhl55zawmIQX1y4asGKRCrQcYYsU4 /JD4qCpL2Vj+dTETf4IfYbC2inOkqe8xjc4scL9FrvibL+uijHF74ZByhWrDgJrn/VLO XFQA== X-Gm-Message-State: AOAM531yiwj9PJECbod2iX61m4JQkR9/GYYdH2maOdKGYXYz57Az3MGh x60PrvBO+ucaYmpic/PvYbwPIv7uQwC57A== X-Received: by 2002:a17:90b:1e09:: with SMTP id pg9mr23720337pjb.208.1624044604071; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/23] linux-user/sh4: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:48 -0700 Message-Id: <20210618192951.125651-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, Yoshinori Sato , =?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 0451e65806..5a5ae69785 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -51,7 +51,6 @@ struct target_sigframe { struct target_sigcontext sc; target_ulong extramask[TARGET_NSIG_WORDS-1]; - uint16_t retcode[3]; }; @@ -67,7 +66,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; @@ -189,15 +187,9 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_sigreturn; } /* Set up registers for signal handler */ @@ -247,15 +239,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_rt_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_rt_sigreturn; } /* Set up registers for signal handler */ @@ -333,3 +319,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(MOVW(2), &tramp[0]); + __put_user(TRAP_NOARG, &tramp[1]); + __put_user(TARGET_NR_sigreturn, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 6; + __put_user(MOVW(2), &tramp[3]); + __put_user(TRAP_NOARG, &tramp[4]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 2 * 6); +} From patchwork Fri Jun 18 19:29:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463086 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp178162jao; Fri, 18 Jun 2021 12:42:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuWnQ+vDBRKfAMGeXjcUoPdYnyIF+LYb0dqVRy/eiAYBeepE04jfHuQds5ncjDOT8Xng41 X-Received: by 2002:ab0:6a8:: with SMTP id g37mr14234982uag.96.1624045352771; Fri, 18 Jun 2021 12:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045352; cv=none; d=google.com; s=arc-20160816; b=FJz6yoWcxUrss+QFZCzcUKx+4FQTN9KnAJM/gDziYPo6GV0g1QVufei8HrStXncBfO hE/vHzHCG3yxK9KuxRtDyBAlh0MXqiwSxOY8W0hEFm7EJdm4XBrupY6P7wDd+GqoM83n birb2qxNGNUyWp0r++oyNzC88BCXh2Fi03HJj/nogLI0uWCEivlSei8dfSwPjnUgfpTi ixS/X3nKuiAS6szPEx7YlDtqtSS6QUP/2+Zq5+SXMXGRLS2bQpefiPQYuh5IpJpDN4SH 4QD4mJ7pfSg9aWP4S8t4OTe7ahsvnj+aa7wMEBtIQcPAhqHzuX3UmBPR9PYUEQPKOpft /vvA== 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=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=yRoypJusIRpHfIJW19XkUvL5EqWPP6vlJ4bVs3LsL7Tgj/IFbpMQ9Q60Re04tnWEJJ 1vWS4kQSjaieE2PzTYY3ioWm86D6//Y1TeA2gLgXnqtju+uFLS2rPPYaEkiWFxSL+VK1 HRSldovv8B3X2R/VQ0gcVeycabQEXMHTavHrzffEuD8e4gW4y0ZrT190Gala/qv8OMM0 4SmwxRjqVk/YPknulEARI3X60yRHDKTFMr/GeZ8tgobbwM3GQTMb702RKXb1SNVdrCBC kQPZIo8yL7ntcYh1VoyGaAXpW+XMYbtHMhrwYUwFqc3Nbh7a4g+9Fi1S16Fsn5z6piTG RJeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XiP20hLY; 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 f7si8490217uap.78.2021.06.18.12.42.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:42: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=XiP20hLY; 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]:35530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKNs-0000ou-6c for patch@linaro.org; Fri, 18 Jun 2021 15:42:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBt-0001iv-Mz for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:14 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:43849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBp-0001a0-Tf for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:09 -0400 Received: by mail-pj1-x102b.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso6480535pjp.2 for ; Fri, 18 Jun 2021 12:30:05 -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=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=XiP20hLYh78l9XbpOtPsEORO3CXi/DD39o8DfjPNLzM6uUdIRI6MB+yV/zkXVCo5tb GkVRz9yfyiV5tIZIqIxCIE4v9Rxnc9QKpOYqE0X8n+aTAddqrwAX+4gbV4ThW3Wt2TMn IPwXKhOdfDhEuY/geiZB27n25VlLKuKA0w2s8J2WZ6dmeUoxdQpX5OHFK/m2keCZFC9i k89R1OU10QlV6VJ1julayM8o5Dfoyiqc2WLaIwSz7COj/FziujZg+ELGWsb+nrqhLMfW BL/9TlSPRGZoWqiPa/LM/v3h+MAjDB5T7uUudYxy3So4N3UoJ956J4ylDUXAoGrYOf/A Dk0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6YW5guTHBvWRMH5moaLCydApEzADr3l/GtZeuUgDhrc=; b=G0JwMCqkYJFRJPD8vusAaEzNQNiBp3W0kGpqhP2mY/zAuPJFF93u8kYk4t1E/OMJl3 kb96Iwfjtv+TEv6CWO2j9DzarTM5gjRbcVAg7QcMk1mqzli/PbjslwmgWm2k9i8orBMa 1W0rmXDNA2VXWF/2jsjm0DGLcwu+qHE9x/LKZjf0QxvdH35k5/LOuMc9F5HjZRFgJv/P egg+EYv3HL9/wAs/bVQXO3DyfdOU7dPOek03b3XS61k3ED96hroU3Y3mcTRZQXEZR92y pgHxfh6trhQTzZiaGpps7gaB3cfpjTTI4KM7rM7mCXt0X4dgJ9jXlOayaIwP7hIsxjrR 9n2g== X-Gm-Message-State: AOAM532t7ZL4ij8s3r6JdbACRYpBFS/o9SdN7wyPezptFVPweewaIsH3 Qf/2scepTLLOD3GHNAdIWnKfmaod6PH+jQ== X-Received: by 2002:a17:902:694b:b029:118:b8b1:1e23 with SMTP id k11-20020a170902694bb0290118b8b11e23mr6084076plt.31.1624044604671; Fri, 18 Jun 2021 12:30:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 21/23] linux-user/sparc: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:49 -0700 Message-Id: <20210618192951.125651-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: Mark Cave-Ayland , alex.bennee@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Mark Cave-Ayland Signed-off-by: Richard Henderson --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé 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 0cc3db5570..65e9b7f8b4 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -290,13 +290,7 @@ 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]); + env->regwptr[WREG_O7] = default_sigreturn; } unlock_user(sf, sf_addr, sf_size); } @@ -357,13 +351,7 @@ 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]); + env->regwptr[WREG_O7] = default_rt_sigreturn; } #else env->regwptr[WREG_O7] = ka->ka_restorer; @@ -774,4 +762,20 @@ 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; + __put_user(0x821020d8u, &tramp[0]); /* mov __NR_sigreturn, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ + + default_rt_sigreturn = sigtramp_page + 8; + __put_user(0x82102065u, &tramp[2]); /* mov __NR_rt_sigreturn, %g1 */ + __put_user(0x91d02010u, &tramp[3]); /* t 0x10 */ + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif From patchwork Fri Jun 18 19:29:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463080 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp175601jao; Fri, 18 Jun 2021 12:38:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZw4KIQBQFqbJ9Yb93WHXgF78VB5W0dWFt+qvm1xjDWoYRlYbrJLd57fWSVORyoDgRzomN X-Received: by 2002:a92:c68c:: with SMTP id o12mr8679855ilg.6.1624045116656; Fri, 18 Jun 2021 12:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045116; cv=none; d=google.com; s=arc-20160816; b=GTPchGf6Bb2McbFY3uTm19jtHzsWBy/4a2ykgGb6Fq3OOkm1aWobDGvUAq28nAxTga wBoHG7fjzLvbcdAdHtKf1btr+dl23MhyQdZ1c+dNbXItR+seYb/UOvXhUHgSNCJltAPj 2mu4nLJj/XqmCumIJLizT74yVLhAyYi2adPlrBPzPDkDB3qx6DYObDlGD75SNIVodI2N I4nlQjCYUYEMEITABXqEbwWVF3T6IMBvT1YVbA9vU78VdfFIJ/BqhDOR4dhlwf7yAW6a An9FYfVt4baw4mhPJmFMXgzkt3DGc0/jYMZ+V1mALGSmHgvcfxZWGpKXLMrKuDEezJlY LArw== 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=r1aOR56lJG8Y7fzXfcIBZhWpAZ7tMlA6NQMa73cEU+c=; b=ujCvE+lNoJNMfuqavD92e+k/AH5VoLuy54EhME0so7gexEvcen6sYnuiFFFfSNwOMP WbQXzCxN3SF6Q+nkT6IijMlRCzRirL/i9TPUI2r7pKJW84WjdNa5CpTyuHKbRZLzYj3c gaq1E5FjD1R2V7wQ6dyShOS3HHnXU6JyC06twoo1FGUiARemt+QhxOpk+mrPtmH5yDMh qstx7NHPHY7a8duhRrCu6UtA0mbT/vatnEFIXZmx2vUHC3Srw5Dq5N3c7HyVkud3Wc2s BrGfsI+egZ/CxIV388QFjMI0LvdccwwVcbR/DWtRIgKcswsSyB58tS6X9cbnjjYXva2x 0RhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KyNN2hn0; 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 b11si4153514ilv.25.2021.06.18.12.38.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:38:36 -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=KyNN2hn0; 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]:54176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKK4-0002ZY-2O for patch@linaro.org; Fri, 18 Jun 2021 15:38:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBw-0001j4-KF for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:16 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:34446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBq-0001aR-Hm for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:12 -0400 Received: by mail-pj1-x1034.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso7650131pjx.1 for ; Fri, 18 Jun 2021 12:30:06 -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=r1aOR56lJG8Y7fzXfcIBZhWpAZ7tMlA6NQMa73cEU+c=; b=KyNN2hn0k/oADtZ0Dg6venc869M7WJ253Wrdjs4oCRqYIkOfTAAn+imn4oQcpcKicq FvHVSWdj2ZXwFk0UxoCiq3+/X3axylJdBf7+Lq6lmAAilI1a2jl2aWPZHv6LgIX1oojx xuGiFsHt2LnsfJj/2XAowfNoVc3LDoz7786sSbviedJsEFv5Wf6SJKXdjUuFHRNH1j39 gZZfY22OnrftUN91wjuj1IZSZKkVywxSx4EtJuwZbLm6ElHKrgtfNHMgNAtzrPblTq2t XLltc/tgXPnuz6PuDbVI6R6Tyfhd8Ybf1dMFq0t/s1nckyYx4uQHJUKPuAFz8u+wMq5X tARw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r1aOR56lJG8Y7fzXfcIBZhWpAZ7tMlA6NQMa73cEU+c=; b=rJ1t3pRtAtyUcPC9ROZg1z3vY8gEwLjkOH42C7O7NQrrhpf7LCLttRZtGHSg/D49Bt 5lArllWGjmi/VRsISzIHoWrdAoC8nuWCBnSJyF9d4OzCAgf7eyUGKFc7uh/q4zJ5Eje1 nKA8BfgGz/pbEUsFdAVmRDuVOrH/00qZeYNYzFJT+QdORGiA1IbZdzkfLytK8aeSopp7 jkjVDzgsury9AmDz+cgN6JA9k2VtHRfZWq21rJtr7jPCazOM6GYwF+q0crOt7VDyvG3Y xzSIkoFY8k6902wPpUyPdUoN5fNLY58u1svD2M4R2A5+MeSf9rOlIoV20CLRDglnQBMP Yt9A== X-Gm-Message-State: AOAM532BlGze669zOe8+UKy+X3/1KlJFaj/lmvvnPtslfceAipK2zN7D ba28zclJrjoIDczlSbRAVRpUV9l7Bx2WcA== X-Received: by 2002:a17:90b:3253:: with SMTP id jy19mr21824466pjb.196.1624044605273; Fri, 18 Jun 2021 12:30:05 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 22/23] linux-user/xtensa: Implement setup_sigtramp Date: Fri, 18 Jun 2021 12:29:50 -0700 Message-Id: <20210618192951.125651-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: Max Filippov , alex.bennee@linaro.org, laurent@vivier.eu 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 Signed-off-by: Richard Henderson --- linux-user/xtensa/target_signal.h | 2 ++ linux-user/xtensa/signal.c | 50 ++++++++++++++++++------------- 2 files changed, 32 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 72771e1294..fd57481bf5 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -163,26 +163,7 @@ 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 + ra = default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc = ka->_sa_handler; @@ -263,3 +244,32 @@ 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); + +#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 + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 6); +} From patchwork Fri Jun 18 19:29:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 463085 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp178070jao; Fri, 18 Jun 2021 12:42:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjRkxUQWl2+HdApxcph2sHTSmbxQmkrKcHMRy6W8mWltrouRX+E6R6CU+xyQahQ4m4LO/1 X-Received: by 2002:a67:f4cb:: with SMTP id s11mr9182992vsn.20.1624045343264; Fri, 18 Jun 2021 12:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045343; cv=none; d=google.com; s=arc-20160816; b=mxnpgh+irWGSK39ztf2e52a3VH2Th7HB6NOhkrGCA2ru33rSJUbP8IFQamQq9Z4e3a PSloNm0JXc6az51pv9P39mj8pf1VdbQjm8yAw7W93g2wmgXeDWTPIm5PgWi2U3k3+OTI MDtqZG5iadtRJxR9EPyxFgW89hNt9Xf0ea3k97iDiqis7eWkdXVHIFx0XBfWT7OVbXW6 JZaUBmiO/EKNy0QNDH1dFiiZSNpMlQXjFsGt9e/776Pn0Sa6Au0s/X8fxG6TNDMdKsJj Sea25XIs676PwiX4badJslzQQ+ENN+S/8X2S1QiIEgVgpSMa3020KUQ47ivEYtMCKmhi zb+Q== 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=i6vIvt0pneZSp74FyENOB1Pe/9xAPO7tymkBwoPywig=; b=Yi9s9XwAdoCbf30uNJ4mSfRbJmSzrRJVdj3agFl8YWUUssV4kf4rfo6XlpLWJdBqyq S6oNvbCuyGTr8tCpmNwtvcQBDTSaddMD9WY4eIRquprlIEEHuxkRcls/KSxcJi1OHtuf dY7FaCVzEYYgp6Imbopumn2PopRlj4o2PyhJXJ0zXinpdNwXqZOiy78Pm47Oh0XI0WZA pU1h0zpREawyyykkWlY2sKCbY2jJLp1zS9OOVX3G4i/IO+AGdtOClt2UA2mywvNW5vmA pXgBV3CEAaff5wRd/7XCHDOCw2z2Ib64l9BJqF3DmQOQItN0cKr9Ib8TW+i+TffQVWkG PVaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fAU6NcIm; 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 u3si5511183vsn.0.2021.06.18.12.42.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 12:42:23 -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=fAU6NcIm; 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]:37056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luKNi-0001tB-M6 for patch@linaro.org; Fri, 18 Jun 2021 15:42:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luKBw-0001j5-Vt for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:17 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:45981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luKBr-0001b9-4I for qemu-devel@nongnu.org; Fri, 18 Jun 2021 15:30:12 -0400 Received: by mail-pj1-x102b.google.com with SMTP id z3-20020a17090a3983b029016bc232e40bso6470950pjb.4 for ; Fri, 18 Jun 2021 12:30:06 -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=i6vIvt0pneZSp74FyENOB1Pe/9xAPO7tymkBwoPywig=; b=fAU6NcImZsmPlk0eKq/ocCWdcsrk+Jdv6eaN5UgT/fMvaeCHA6vXmn69zfsaLlFax/ vuiu/PAqzK1HgifYpQd82T03KW5PpxRmi8bBXzzdAGz8yDnXYq2JbVK4kDsXILjUacxP 5SFw0BXomsF3tpTb1O7eDQ11lAOms+UAlreFyQkxaH9NfuVSqXQPtpSBKgw7Uc4joDlK oXD7JWpZDD0TRvDbq1l+uYUtgr6bB3OzFCyLALC9NC19WM9a2YqkK3YDiximxUFa9Fzz IyyI4oXSS4p+mWlEhDCy+sDf3UtGeXPzzyMZXQx4Qap7wrMKOn2pYXrBOQFEAw4WP40j 0nyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i6vIvt0pneZSp74FyENOB1Pe/9xAPO7tymkBwoPywig=; b=e6Ywlqw/4Zms5nH7lVmUpWhA44x0QVDUioxn8RtrNXyK9da2aTsr2/1Mc2LhfPV00d MyTZL6qtyD/YTKSatlI4nVCr5EbU+hNllIn5Qf1vxVJ3EHDTAuQ4PeJjGEFDJfMtQ4ew fpteJHxnc/TPTWdNgeI3ud9xSDm9LBnGQoLh+Qde5HFny/pIUJAC4sj9QBrKRcNe//cr 4g7Vfr07mxBGyHtuskaOaTAV7duXAQIFcCIOuNLa6IMKoQLbZ4bBHnAV4FaKlMOXa66X 40rWbJmYTy3ImgNzCqDp1SJmNhKLMeVf0xuqaXzS7jYNe+baP2Cz46mAm6P/dfbpVtnO Syog== X-Gm-Message-State: AOAM531jxa9vZ00X3Iyhi8N+A5v4gb9mlIYda5s8y6wVnMCGsIPQEo/K ipq72Lw9/grD3tPWq9SXhtSeD0hEdNgk1A== X-Received: by 2002:a17:90a:6304:: with SMTP id e4mr12749821pjj.222.1624044605899; Fri, 18 Jun 2021 12:30:05 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id 92sm11938234pjv.29.2021.06.18.12.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:30:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 23/23] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Date: Fri, 18 Jun 2021 12:29:51 -0700 Message-Id: <20210618192951.125651-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618192951.125651-1-richard.henderson@linaro.org> References: <20210618192951.125651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-?= =?utf-8?b?RGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 7bc67ac9cb..c0236a0b09 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -26,10 +26,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 */