From patchwork Fri Sep 24 16:59:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514582 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1673625jao; Fri, 24 Sep 2021 10:01:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwX0Ih3rR+72w/n2cmkN6ZAfhHzWwipEoJkXzEySUcdZOktGVCaTnw6R+FEPubkyxMkgwJW X-Received: by 2002:ac8:538a:: with SMTP id x10mr5317982qtp.251.1632502886235; Fri, 24 Sep 2021 10:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632502886; cv=none; d=google.com; s=arc-20160816; b=mtS6V1spfKgeMeKQJJGyFefU4sRVJxNki1Njm08Ds5iYnOd0gOaWyUrQDsN1bMXql6 kcWrbmHAqxd8p42mUsaSHqlNP1jUyL0FWiBIkLtS8+FxZhvpoo84Go3yht9Vk0O5A820 c7MLLEdeXlqKG9rGDxg8J1sLXdggNObAQ9Uxi7EMFi2SqWdczm7thz4xH49X5csvzDDP yG1i6iWQntp7nA0Ax5i28QMO7wc0pk+dVd/x7Sla9VmRIcA2Sp4DW8JZhy4LSz7qBHBg cb9V4iB+nr1FcJP0n5VDa0NYPoumRIgcdfaebNc/cwZgeF6jsVBJUGPVUMdEtw3CoxgW dJMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=CGOosasLuWVrQkAKo2YVUubUIw5+FrCZZpw5zdCIfU2ZDrLyuycHwu4HlI8j+GWMbq K7pdtk8aUGfMAgpOTIZJcXTtl+wg4GhTGLUIyvqcLj5luUIlAOwWhHV6/wxslqePzrS2 LUJMrokSNWbccDY+IsfTlKS2VUiEYd5tesbpHzK86yvkTIOWr3ZoN5aTDAzQeotGvdP3 7esn8dfGTvSj+CUcgBNke39lJmMrLYrC+c82EgIrOb7xq0etYC8ChsPUoCInmdegkfSV b7lRs4XiwlG6aqfzGdL9Fi0Y1rCnBQub+mtRU1gASsu4JveZzicF3xbp+ZzyYfSPLLOD ldcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xfAv5iPt; 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 a8si6058263qkh.106.2021.09.24.10.01.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:01: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=xfAv5iPt; 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]:55074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToZh-0002ff-OT for patch@linaro.org; Fri, 24 Sep 2021 13:01:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXx-0002dx-2H for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:39550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXq-0006rS-0d for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:36 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id a14so6648490qvb.6 for ; Fri, 24 Sep 2021 09:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=xfAv5iPtHAieHsIzSI/p1Ty23DbheWyX3t4bsn4MClUY6i59zpx8PcKP4794BPIgoV pfWQKnJe5+OqccwWiI1pTfvv3jNj8bAGrBOB7rJLJuoGm9ILv5AdTHvhX3A/YfYZt4dR xfSNNqbxjwciypCFwQ6G19aWGXywb+X0dt+EvojjpE2e1I5d0bDrPE1gAyyF3dQZ4K7N BXRrGViO7p7t/jV667+NetbZOExWc8z/i7eGFoTo25rUWP+uVgqBa4hEWv3WPUh0Gp4T GEE7QASXo9PFTZtiCrCMKdC+Zoy/rtqV0JVvemmamev45an08Ze+lPlJweoaGZCJvffH XaZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tmL+joXfoW+8Wn51iJgMBifiuqpS0R+kHN3F+bMNUq0=; b=Z1e/PnHMrFNY/JqFfE0bPseuGlwPvyGUvx3KldKahEm9zI0pRhh7dWCAw4yA6CmAKi FSOzfItu8Hj+osN52PqZmmFHpE5lKwQXK5DOhd0Tx/TrzjjjO6wZm3QGXoMq4etVTEwx YxhBscb3/DFURUuDngPULxYrMnbo+AaOyEfnSufgd7HxY92h+UuZDtmWrM/C80yOiUsS 7UD+3t9d7WJXeHY8qtc2fVn2iy6Ja1MU/hjqIsAiBcBH+c7c4xiWoAW5UNcsB9TRgXwy ioQfLgQkdkCf1Xr0e1YF74CnvLiOc1iY1kehYjuBCl/7IiDUdU6Gn2pJtf/AK6Oqp5xL +Tdw== X-Gm-Message-State: AOAM531UIorv4kbEjhuL3XiLEvpK/bY92V3OIhIOFRPE6Xe0orqAu18B dASwLaGE8hnzVI2MfU6Ax4W4Es7srohUwA== X-Received: by 2002:ad4:4629:: with SMTP id x9mr1451260qvv.58.1632502769084; Fri, 24 Sep 2021 09:59:29 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/27] linux-user: Add infrastructure for a signal trampoline page Date: Fri, 24 Sep 2021 12:59:00 -0400 Message-Id: <20210924165926.752809-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , laurent@vivier.eu, Max Filippov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allocate a page to hold the signal trampoline(s). Invoke a guest-specific hook to fill in the contents of the page before marking it read-execute again. Reviewed-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/signal-common.h | 6 ++++++ linux-user/elfload.c | 18 ++++++++++++++++++ linux-user/signal.c | 3 +++ 3 files changed, 27 insertions(+) -- 2.25.1 diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 79511becb4..7457f8025c 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -20,6 +20,12 @@ #ifndef SIGNAL_COMMON_H #define SIGNAL_COMMON_H +/* Fallback addresses into sigtramp page. */ +extern abi_ulong default_sigreturn; +extern abi_ulong default_rt_sigreturn; + +void setup_sigtramp(abi_ulong tramp_page); + int on_sig_stack(unsigned long sp); int sas_ss_flags(unsigned long sp); abi_ulong target_sigsp(abi_ulong sp, struct target_sigaction *ka); diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 5f9e2141ad..459a26ef1d 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -7,6 +7,7 @@ #include "qemu.h" #include "user-internals.h" +#include "signal-common.h" #include "loader.h" #include "user-mmap.h" #include "disas/disas.h" @@ -17,6 +18,7 @@ #include "qemu/units.h" #include "qemu/selfmap.h" #include "qapi/error.h" +#include "target_signal.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -28,6 +30,10 @@ #undef ELF_ARCH #endif +#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 +#endif + #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */ @@ -3249,6 +3255,18 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) #endif } + /* + * TODO: load a vdso, which would also contain the signal trampolines. + * Otherwise, allocate a private page to hold them. + */ + if (TARGET_ARCH_HAS_SIGTRAMP_PAGE) { + abi_ulong tramp_page = target_mmap(0, TARGET_PAGE_SIZE, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + setup_sigtramp(tramp_page); + target_mprotect(tramp_page, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC); + } + bprm->p = create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, info, (elf_interpreter ? &interp_info : NULL)); info->start_stack = bprm->p; diff --git a/linux-user/signal.c b/linux-user/signal.c index 2038216455..14d8fdfde1 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -35,6 +35,9 @@ static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_signum, siginfo_t *info, void *puc); +/* Fallback addresses into sigtramp page. */ +abi_ulong default_sigreturn; +abi_ulong default_rt_sigreturn; /* * System includes define _NSIG as SIGRTMAX + 1, From patchwork Fri Sep 24 16:59:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514598 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1686689jao; Fri, 24 Sep 2021 10:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysuLMy7TvtfxoYTWNqeCSxkbt00rY4UwD5GwccVgSq/TKba6dv8rZzxOX0BFbhvPfUOxGz X-Received: by 2002:a05:622a:452:: with SMTP id o18mr5491850qtx.266.1632503614949; Fri, 24 Sep 2021 10:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503614; cv=none; d=google.com; s=arc-20160816; b=MYN9Y4J2ILXbtzO+MpkZRnwrbHTDTx1CedKdWNNBjVY0LPGdhIb+I/5aVx8Nn2xSis dUbRltHRAKIyWArlFPuYk9FXcFpRBegn8y27o8m0fIMq5R8qgcc0xuci/AiQmdYbHeMG 4Y9//6RrlBEtN1rODyjqsoPL4OQI34zd20md+FO215Zl4/Zo0ekc/beA2sBA92hDVtZD yT4o16YFXa6l6L8faLq23E8IOraXYzbzdH1247uOCFTM9wD/RFS5PffP/w4O0WxEvl0y mTf2cxDfQ5kKdww3ZTPltX6iQUWdRBFul5beMfcxzebG2OvUTJaiTsB9GOiJuzGdFiHF kJXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=BJTTm+eYhJX7ygJYiTi9crS8CKfGOdRZZ2jH9hilExDvhpbCJt45mgKqqtcnFbJi/e 15gIBNR2pybG4JOpVxlZhApi/dFXJZz9lajQw2ESJpXw66Dhzg6LNlCmZKE4/4uPuTcS 8JgcP89DKsN9/tKOfEb9fHcR0wCWwaLobS9aBzaHrEULRyXQ3kT1lzPD1Whh2feaeMwg SkvwgBMF/ytKEBF61RqMasb4ZyvnGJ4OPwAEsmQyu1VihF0agZOoAAbygGbmocTsM6J7 0QmzUz9B2LeOpazsUXNnwX74D96OTo7Qk8vT94T5wUL9I9AMvfWl0QTsFUcbygT4Crss JBFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lwQTK+KU; 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 b17si6232085qtb.12.2021.09.24.10.13.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lwQTK+KU; 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]:32996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTolS-00012B-Cm for patch@linaro.org; Fri, 24 Sep 2021 13:13:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002gb-UW for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:38828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXq-0006rd-KE for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: by mail-qk1-x732.google.com with SMTP id q81so25089127qke.5 for ; Fri, 24 Sep 2021 09:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=lwQTK+KUnDVPNS0vgUasmJy86QCOKIYv09hfvX7kHxzm545272dsnNDdHZictKJWN2 BboCrhg6Ofgyk/5BTxUzn1aefIXYszVm0poe4bNhFpflphP5K0YuQFcu1+Lgv0ba0JCH dTSkVJ+KwTz4CYkcbihofXKH1biTw3Qmdd6Tf/eKZlV1oaO15ibkYykwlLG2jzPdM2WA B+whWbj0cmkPHHkn8O8JnC2drkPkf/oOn/agkLufOIi06k6JBwjUMOoOK+eXbUk/XKG2 OWLBYAN9LRadrJwYYvBNyeY81MT07S8tnw6RnpJNIPgV0t1XgK0C5utnYT/DD2fV1qsy vhyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VOAvx3TChGYyGqXcRBxcpjzeCX+UxKswiiX03Eo6C3g=; b=0eJT1jVc7g6fWhTBDfoiOoWbCkbQP4C/23ZMHe4u29K49nLObXKux88/cwFbY9ITwg jsmvl8EK30Vqghz6d97B35G+boKl5DWd1MdOQ4P4lhJ2pZ0WKa0QNzj0ycgjGmGdILjH r1L2wTzHTXtiXUbr640epsoLGNOlvlPJkDyjRg67L8XFu+3ZexwscnKPKxFDZ3OEDCML rhxZh0ou0Z6hhkB/hqB6HmV2YAxJ1UwiU7TD9NIu3J0t5sugf1sdU/FiteBCS4eiIk1c 2bVv5KkOkgrI+jkXBs24IDlw97e0IMSJ/pc+HdUwqL8cpZZhKzp6k6m437MoH9/8qZcr xv1w== X-Gm-Message-State: AOAM533+IwnklvyBs4Z7GdV7RliYxNgyJTECwsWeViTZSVRNySGKL/5M OxujtKsZqZXpGQHUhrpWndHLT/CxjZNeqA== X-Received: by 2002:a37:a904:: with SMTP id s4mr1620281qke.60.1632502769750; Fri, 24 Sep 2021 09:59:29 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/27] linux-user/aarch64: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:01 -0400 Message-Id: <20210924165926.752809-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/aarch64/target_signal.h | 2 ++ linux-user/aarch64/signal.c | 34 ++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) -- 2.25.1 diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target_signal.h index 18013e1b23..7580d99403 100644 --- a/linux-user/aarch64/target_signal.h +++ b/linux-user/aarch64/target_signal.h @@ -25,4 +25,6 @@ typedef struct target_sigaltstack { #define TARGET_SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* AARCH64_TARGET_SIGNAL_H */ diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 49025648cb..29c52db3f1 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -109,7 +109,6 @@ struct target_rt_sigframe { struct target_rt_frame_record { uint64_t fp; uint64_t lr; - uint32_t tramp[2]; }; static void target_setup_general_frame(struct target_rt_sigframe *sf, @@ -461,9 +460,9 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, layout.total_size = MAX(layout.total_size, sizeof(struct target_rt_sigframe)); - /* Reserve space for the return code. On a real system this would - * be within the VDSO. So, despite the name this is not a "real" - * record within the frame. + /* + * Reserve space for the standard frame unwind pair: fp, lr. + * Despite the name this is not a "real" record within the frame. */ fr_ofs = layout.total_size; layout.total_size += sizeof(struct target_rt_frame_record); @@ -496,15 +495,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { return_addr = ka->sa_restorer; } else { - /* - * mov x8,#__NR_rt_sigreturn; svc #0 - * Since these are instructions they need to be put as little-endian - * regardless of target default or current CPU endianness. - */ - __put_user_e(0xd2801168, &fr->tramp[0], le); - __put_user_e(0xd4000001, &fr->tramp[1], le); - return_addr = frame_addr + fr_ofs - + offsetof(struct target_rt_frame_record, tramp); + return_addr = default_rt_sigreturn; } env->xregs[0] = usig; env->xregs[29] = frame_addr + fr_ofs; @@ -577,3 +568,20 @@ long do_sigreturn(CPUARMState *env) { return do_rt_sigreturn(env); } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * mov x8,#__NR_rt_sigreturn; svc #0 + * Since these are instructions they need to be put as little-endian + * regardless of target default or current CPU endianness. + */ + __put_user_e(0xd2801168, &tramp[0], le); + __put_user_e(0xd4000001, &tramp[1], le); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Fri Sep 24 16:59:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514587 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1676968jao; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0OebAnBz8jnVcUW1ZXdfxFmsq6pVfRP0g9PLEp1oeDtGvmvS6hvNKnme9YwdEWwQNvCGn X-Received: by 2002:a37:754:: with SMTP id 81mr11469569qkh.260.1632503076744; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503076; cv=none; d=google.com; s=arc-20160816; b=r3jxVGj8czgqla7CLXcdSifsG8xhE9DidGdrCuPKaAnzB7dTf+4GMciRsm9H9H2Tp+ +ZZjv2s1UqIicKd6+JumSRNNG5lEgPdhXOQ3WokDDz4SKcI49w15uTM6rf2CC8BQ0EI0 XQG0vX5Uy50hmvhUHWMWHgANQd/z4lR30UWVQt4sOwctgVhh9DQzH27oE0oSKnsDmeuC 2uK9C7TM8JVbPt4FU4pqsjFr+ccBFLwTg6fvo8MOi4BHXIf/cWGKXSTSNrFUrIX1XYOJ Fs7AtOvycoaNWYoggvDiEKVqJ/SzaIxj1Ncp6M8sqJY7QuzR8ELLaApZ9Q1EHYMKWxUw NYHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=S7N5bWD4i9g9/hMJ0RVt/aGbfhySW2xet6EXvUiOvmawbmvUARwQnF62OVkZ5ld71x F/iAbmK/aNSqTJ1VSti6H/cX/SLZjIvztkQS7eO+X5yGx15bDytLviLf05qaA0oQ/2ze 1ptc7BIzQefT8qUbR5Evaw056pFUu9PegKYu0GrCXobdC2JbNsD1q11D9oJ5g4Ff9yn6 s6vWlu8Vz5JIo0e6bxPcg6lUxsWACCCBtxcOBEU407IM/Qnkn0mBOX6YM60D9xz8xjts kGY5NQtgWGCAJ1bCGGGeaGLmNdHNeEldT3qaSIrEznznCREnnMR7YHbok/ueBUn90xzb ojwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UBgNzb4w; 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 d7si1935781qkn.80.2021.09.24.10.04.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:04: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=UBgNzb4w; 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]:35412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTocm-0000TO-6o for patch@linaro.org; Fri, 24 Sep 2021 13:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXv-0002dc-C6 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:39553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXs-0006sq-UE for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: by mail-qv1-xf32.google.com with SMTP id a14so6648536qvb.6 for ; Fri, 24 Sep 2021 09:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=UBgNzb4w1rN/7zgVQMVmhj2RZkMfo45LY8uLiZPciaA7Dvtjy6dDPslJkzDYpDahOg /wLd0GkJx3tmT0wwhmMEgKfceNKnXAHroaeZqOduySHxK9y3C2/llHCwMN9Gux85B7L7 1yph/8ZXm20ZsdE3RRxT6Ev7PyKyKZEQh7JMhpBp8jRCpQKdW4mdQc59mlFdbc2takNe B8q1ihXqjgME6Wu0RaO8luPT3ofxvwW0hIGiacfqT9RP+julZt9hD4InNQ8eZ47fJLj9 lo4kIKOf+j+UhEl0PkQuBkDsyHn6M4/LzBXQ9SP/gWQ1g3LbYU6bGzfXDGY2kjTNPpdj T9AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qw4dD1OgISmN9k1dJ+QkWah6FxPb8XtaJuuTt7cvGa4=; b=MK5oh8uhgiqIQpneXQFt3Lrtry7rVC8GC5dVA03k7vFQQqkugrHDvMGEQOUatc2lRj it8cX12U/sRfQ1iTtWuXQPitRfGBsVLsaBxpEsHFCGWGRV1EDBeh17oOFJdy8rZ/AoCW nQ/1i8sER6hu0FChSWpDALWEbQdthmPbNg1qg9m4f+nIxrvYe4I5WY+Rdbgy5oX5BuUw J0Hi4o9p3z0H0eIUn3plhapYU37bbzVbmsniOazdrQhv3QRxvLPGDkHgQcx9CzSXfRMn lyrrTjg3krK8LogQjatA58vdtaQmGxWFIvDGHe7mOtJDLD6cgA52Aa7FEgRUVc5AGuHu 2T2w== X-Gm-Message-State: AOAM5306gOeqHriYxmI638JajwzB3YWYEwF4xeFycoe80xT8dYUCMpRf zj9Hk7+9Dimz3iScBNJdu+Ni9Q9zm9vCDg== X-Received: by 2002:a0c:cc84:: with SMTP id f4mr2268295qvl.14.1632502770503; Fri, 24 Sep 2021 09:59:30 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/27] linux-user/arm: Drop v1 signal frames Date: Fri, 24 Sep 2021 12:59:02 -0400 Message-Id: <20210924165926.752809-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf32.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Version 2 signal frames are used from 2.6.12 and since cbc14e6f286, we have set UNAME_MINIMUM_RELEASE to 2.6.32. Suggested-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 220 +--------------------------------------- 1 file changed, 4 insertions(+), 216 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed144f9455..d0940bab47 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,14 +46,6 @@ struct target_sigcontext { abi_ulong fault_address; }; -struct target_ucontext_v1 { - abi_ulong tuc_flags; - abi_ulong tuc_link; - target_stack_t tuc_stack; - struct target_sigcontext tuc_mcontext; - target_sigset_t tuc_sigmask; /* mask last for extensibility */ -}; - struct target_ucontext_v2 { abi_ulong tuc_flags; abi_ulong tuc_link; @@ -98,28 +90,12 @@ struct target_iwmmxt_sigframe { #define TARGET_VFP_MAGIC 0x56465001 #define TARGET_IWMMXT_MAGIC 0x12ef842a -struct sigframe_v1 -{ - struct target_sigcontext sc; - abi_ulong extramask[TARGET_NSIG_WORDS-1]; - abi_ulong retcode[4]; -}; - struct sigframe_v2 { struct target_ucontext_v2 uc; abi_ulong retcode[4]; }; -struct rt_sigframe_v1 -{ - abi_ulong pinfo; - abi_ulong puc; - struct target_siginfo info; - struct target_ucontext_v1 uc; - abi_ulong retcode[4]; -}; - struct rt_sigframe_v2 { struct target_siginfo info; @@ -363,37 +339,6 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, } } -/* compare linux/arch/arm/kernel/signal.c:setup_frame() */ -static void setup_frame_v1(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) -{ - struct sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); - int i; - - trace_user_setup_frame(regs, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - setup_sigcontext(&frame->sc, regs, set->sig[0]); - - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->extramask[i - 1]); - } - - if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v1, retcode))) { - goto sigsegv; - } - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); -} - static void setup_frame_v2(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { @@ -422,60 +367,7 @@ sigsegv: void setup_frame(int usig, struct target_sigaction *ka, target_sigset_t *set, CPUARMState *regs) { - if (get_osversion() >= 0x020612) { - setup_frame_v2(usig, ka, set, regs); - } else { - setup_frame_v1(usig, ka, set, regs); - } -} - -/* compare linux/arch/arm/kernel/signal.c:setup_rt_frame() */ -static void setup_rt_frame_v1(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) -{ - struct rt_sigframe_v1 *frame; - abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); - struct target_sigaltstack stack; - int i; - abi_ulong info_addr, uc_addr; - - trace_user_setup_rt_frame(env, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - info_addr = frame_addr + offsetof(struct rt_sigframe_v1, info); - __put_user(info_addr, &frame->pinfo); - uc_addr = frame_addr + offsetof(struct rt_sigframe_v1, uc); - __put_user(uc_addr, &frame->puc); - tswap_siginfo(&frame->info, info); - - /* Clear all the bits of the ucontext we don't use. */ - memset(&frame->uc, 0, offsetof(struct target_ucontext_v1, tuc_mcontext)); - - memset(&stack, 0, sizeof(stack)); - target_save_altstack(&stack, env); - memcpy(&frame->uc.tuc_stack, &stack, sizeof(stack)); - - setup_sigcontext(&frame->uc.tuc_mcontext, env, set->sig[0]); - for(i = 0; i < TARGET_NSIG_WORDS; i++) { - __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); - } - - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v1, retcode))) { - goto sigsegv; - } - - env->regs[1] = info_addr; - env->regs[2] = uc_addr; - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); + setup_frame_v2(usig, ka, set, regs); } static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, @@ -516,11 +408,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { - if (get_osversion() >= 0x020612) { - setup_rt_frame_v2(usig, ka, info, set, env); - } else { - setup_rt_frame_v1(usig, ka, info, set, env); - } + setup_rt_frame_v2(usig, ka, info, set, env); } static int @@ -553,54 +441,6 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) return err; } -static long do_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct sigframe_v1 *frame = NULL; - target_sigset_t set; - sigset_t host_set; - int i; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - __get_user(set.sig[0], &frame->sc.oldmask); - for(i = 1; i < TARGET_NSIG_WORDS; i++) { - __get_user(set.sig[i], &frame->extramask[i - 1]); - } - - target_to_host_sigset_internal(&host_set, &set); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->sc)) { - goto badframe; - } - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; -} - static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) { int i; @@ -733,55 +573,7 @@ badframe: long do_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_sigreturn_v2(env); - } else { - return do_sigreturn_v1(env); - } -} - -static long do_rt_sigreturn_v1(CPUARMState *env) -{ - abi_ulong frame_addr; - struct rt_sigframe_v1 *frame = NULL; - sigset_t host_set; - - /* - * Since we stacked the signal on a 64-bit boundary, - * then 'sp' should be word aligned here. If it's - * not, then the user is trying to mess with us. - */ - frame_addr = env->regs[13]; - trace_user_do_rt_sigreturn(env, frame_addr); - if (frame_addr & 7) { - goto badframe; - } - - if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { - goto badframe; - } - - target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask); - set_sigmask(&host_set); - - if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) { - goto badframe; - } - - target_restore_altstack(&frame->uc.tuc_stack, env); - -#if 0 - /* Send SIGTRAP if we're single-stepping */ - if (ptrace_cancel_bpt(current)) - send_sig(SIGTRAP, current, 1); -#endif - unlock_user_struct(frame, frame_addr, 0); - return -TARGET_QEMU_ESIGRETURN; - -badframe: - unlock_user_struct(frame, frame_addr, 0); - force_sig(TARGET_SIGSEGV); - return -TARGET_QEMU_ESIGRETURN; + return do_sigreturn_v2(env); } static long do_rt_sigreturn_v2(CPUARMState *env) @@ -822,9 +614,5 @@ badframe: long do_rt_sigreturn(CPUARMState *env) { - if (get_osversion() >= 0x020612) { - return do_rt_sigreturn_v2(env); - } else { - return do_rt_sigreturn_v1(env); - } + return do_rt_sigreturn_v2(env); } From patchwork Fri Sep 24 16:59:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514586 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1676967jao; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5TFczNyTxliDchX2RH+t1zEVYGqHqo406M6vJsAOVK65Wusep0EbYZcKzw/Vgb1iDUvsH X-Received: by 2002:ac8:60d2:: with SMTP id i18mr27920qtm.390.1632503076747; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503076; cv=none; d=google.com; s=arc-20160816; b=hiQ+gPwBgBitPizvkPQyMBSWcgb56o/yDAN6MJPvFNt/iFoSXooOVGGpst4AVumKPF EaHtOegCQ3u+J8XmF3rN744DF2tYvS306/x17v+92MmWadYizy4k6Ijx6cYpjUwh4meU 8RCyrOcZb7aD2SGPejdlVLt5Rg+bVh5jDf4RIbEiVY4VIPyoCAJsUV0DJdLk5+n8IwfE 3b88OlgXrEGYyh6hV4Qocdesvz8/+B6+b8yCKGLoh0mIIqYkErKOzwYS7W3R4JZjon24 ro2KqLiMvkDJmIxc9/kTHJ/yvTKOl8acMICbIuOdHH33OIw0/O69/hXsKzXZDHoLchJ3 n43Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=UmRHRs9txsIGq5mUkkbtYYKOscJsWE4rORq3s/SwlAlWjuCqmxTlKPdfSLuM3Om2O5 TmdXM7xfUVK8/+Xcwu6SYC87f6JmO+jD7BO89qTSe7AV2ooGHkKFGThrgD+Bizf2yeZt 5mNHbjyrOCpSlSHUx6gqUs9AC8Nwr64P8TLZ0lkpEsVsOKyhRYD9DR822LDe1kG6nFZG VPrv5ldO/BPlnwUR3xSwyZd/8RRv/fJGKc1eI4SmcXq9ZLQgHctjjWgMYUPqlh/ViMIl sofSyP2qx53gQbR6B7zOCkOj5SZiLNblUw1HhouJ2JlSZ/zcdTjpn3jxqmlORL7npa+D LE3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="CNvJ3/Ms"; 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 k6si5730286qvm.154.2021.09.24.10.04.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:04: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="CNvJ3/Ms"; 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]:35368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTocm-0000SF-9B for patch@linaro.org; Fri, 24 Sep 2021 13:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXx-0002dw-2T for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:47096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXt-0006tc-Fz for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:36 -0400 Received: by mail-qv1-xf30.google.com with SMTP id gs10so6621211qvb.13 for ; Fri, 24 Sep 2021 09:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=CNvJ3/MsUGCgoyu/DfdaXe5WtCXORRd+leVdiKK8yh9MRBeX2Kplbflijtd4dlTjuU +TYc7Et+MVtZT8flopOOyyNfnwZqDNQZ6kVHCpWpchsKDm0uBA8nzmKH804t8xhW7ICD XU6anPWeYSgVzTv491HK+N/q76I8ApcDU+d9SPKcVlh1q0cTyBy3/9m9TPR7eZiECkoK 9CG6VEKsYHF6TOvRwB18jFzcNU5eJjd5SLLdzk4YPSL2RejOKTFHlJewBzoAo2Q7mmhd f6Z46t8WVHDy1xgF4ZkMJBhpyXjmdEOE9RWhdAXG6XLu2wRPXvCgRkskpODNnMGYh44I Q4ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ix3gXlqnervNFIKDwCYoxZx+7RHohDod9PWp4e0JtEc=; b=6zUK6Jp6M+7uUvYsaiT1FOOlPi5THu2IPK2qmymnkIbNeT6hZcuRA01VbEEJrLAaF/ /pQuQzSY7QJf5iJyuvLSurE7BD1XPV/8bTua1tpUT1w4FAfdx687LMRO5XFWo7D8Ni3Y IYZz9z8b/FBe0NIX5SnkWeeKrSSeau4vW7fYTPqP/VXOHHWVLDtUT9cQ5fVaPV1G/H34 sVahIkCe+s1HWCjQEQnMs5HUa5BLAl0J2u50iMV6lXuadKSOMqRGbtuvaLKpVCK1vpzV tDHwHNvnWHEYJqYx5wAc+FCqB0jemQ4tGvSOu315gsLUkJqBMCCxz3MPpwg+TIz2xXt2 HJDw== X-Gm-Message-State: AOAM5335emqMvbJ1Krteik7VvIFiPkpk3gPVUkP3ojExFux3oWPw3iHM AKMUpTQlOyCklKXVTBwDxr2GGrm3XbJrYg== X-Received: by 2002:a0c:c293:: with SMTP id b19mr2799216qvi.22.1632502771245; Fri, 24 Sep 2021 09:59:31 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/27] linux-user/arm: Drop "_v2" from symbols in signal.c Date: Fri, 24 Sep 2021 12:59:03 -0400 Message-Id: <20210924165926.752809-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf30.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since we no longer support "v1", there's no need to distinguish "v2". Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/arm/signal.c | 155 +++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 90 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index d0940bab47..ed7d1d80bb 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -46,7 +46,7 @@ struct target_sigcontext { abi_ulong fault_address; }; -struct target_ucontext_v2 { +struct target_ucontext { abi_ulong tuc_flags; abi_ulong tuc_link; target_stack_t tuc_stack; @@ -90,16 +90,16 @@ struct target_iwmmxt_sigframe { #define TARGET_VFP_MAGIC 0x56465001 #define TARGET_IWMMXT_MAGIC 0x12ef842a -struct sigframe_v2 +struct sigframe { - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; -struct rt_sigframe_v2 +struct rt_sigframe { struct target_siginfo info; - struct target_ucontext_v2 uc; + struct target_ucontext uc; abi_ulong retcode[4]; }; @@ -270,7 +270,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, return 0; } -static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) +static abi_ulong *setup_sigframe_vfp(abi_ulong *regspace, CPUARMState *env) { int i; struct target_vfp_sigframe *vfpframe; @@ -287,8 +287,7 @@ static abi_ulong *setup_sigframe_v2_vfp(abi_ulong *regspace, CPUARMState *env) return (abi_ulong*)(vfpframe+1); } -static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, - CPUARMState *env) +static abi_ulong *setup_sigframe_iwmmxt(abi_ulong *regspace, CPUARMState *env) { int i; struct target_iwmmxt_sigframe *iwmmxtframe; @@ -307,15 +306,15 @@ static abi_ulong *setup_sigframe_v2_iwmmxt(abi_ulong *regspace, return (abi_ulong*)(iwmmxtframe+1); } -static void setup_sigframe_v2(struct target_ucontext_v2 *uc, - target_sigset_t *set, CPUARMState *env) +static void setup_sigframe(struct target_ucontext *uc, + target_sigset_t *set, CPUARMState *env) { struct target_sigaltstack stack; int i; abi_ulong *regspace; /* Clear all the bits of the ucontext we don't use. */ - memset(uc, 0, offsetof(struct target_ucontext_v2, tuc_mcontext)); + memset(uc, 0, offsetof(struct target_ucontext, tuc_mcontext)); memset(&stack, 0, sizeof(stack)); target_save_altstack(&stack, env); @@ -325,10 +324,10 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, /* Save coprocessor signal frame. */ regspace = uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace = setup_sigframe_v2_vfp(regspace, env); + regspace = setup_sigframe_vfp(regspace, env); } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace = setup_sigframe_v2_iwmmxt(regspace, env); + regspace = setup_sigframe_iwmmxt(regspace, env); } /* Write terminating magic word */ @@ -339,10 +338,10 @@ static void setup_sigframe_v2(struct target_ucontext_v2 *uc, } } -static void setup_frame_v2(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) +void setup_frame(int usig, struct target_sigaction *ka, + target_sigset_t *set, CPUARMState *regs) { - struct sigframe_v2 *frame; + struct sigframe *frame; abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame)); trace_user_setup_frame(regs, frame_addr); @@ -350,10 +349,10 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka, goto sigsegv; } - setup_sigframe_v2(&frame->uc, set, regs); + setup_sigframe(&frame->uc, set, regs); if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe_v2, retcode))) { + frame_addr + offsetof(struct sigframe, retcode))) { goto sigsegv; } @@ -364,51 +363,38 @@ sigsegv: force_sigsegv(usig); } -void setup_frame(int usig, struct target_sigaction *ka, - target_sigset_t *set, CPUARMState *regs) -{ - setup_frame_v2(usig, ka, set, regs); -} - -static void setup_rt_frame_v2(int usig, struct target_sigaction *ka, - target_siginfo_t *info, - target_sigset_t *set, CPUARMState *env) -{ - struct rt_sigframe_v2 *frame; - abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); - abi_ulong info_addr, uc_addr; - - trace_user_setup_rt_frame(env, frame_addr); - if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { - goto sigsegv; - } - - info_addr = frame_addr + offsetof(struct rt_sigframe_v2, info); - uc_addr = frame_addr + offsetof(struct rt_sigframe_v2, uc); - tswap_siginfo(&frame->info, info); - - setup_sigframe_v2(&frame->uc, set, env); - - if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe_v2, retcode))) { - goto sigsegv; - } - - env->regs[1] = info_addr; - env->regs[2] = uc_addr; - - unlock_user_struct(frame, frame_addr, 1); - return; -sigsegv: - unlock_user_struct(frame, frame_addr, 1); - force_sigsegv(usig); -} - void setup_rt_frame(int usig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUARMState *env) { - setup_rt_frame_v2(usig, ka, info, set, env); + struct rt_sigframe *frame; + abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame)); + abi_ulong info_addr, uc_addr; + + trace_user_setup_rt_frame(env, frame_addr); + if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { + goto sigsegv; + } + + info_addr = frame_addr + offsetof(struct rt_sigframe, info); + uc_addr = frame_addr + offsetof(struct rt_sigframe, uc); + tswap_siginfo(&frame->info, info); + + setup_sigframe(&frame->uc, set, env); + + if (setup_return(env, ka, frame->retcode, frame_addr, usig, + frame_addr + offsetof(struct rt_sigframe, retcode))) { + goto sigsegv; + } + + env->regs[1] = info_addr; + env->regs[2] = uc_addr; + + unlock_user_struct(frame, frame_addr, 1); + return; +sigsegv: + unlock_user_struct(frame, frame_addr, 1); + force_sigsegv(usig); } static int @@ -441,7 +427,7 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc) return err; } -static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) +static abi_ulong *restore_sigframe_vfp(CPUARMState *env, abi_ulong *regspace) { int i; abi_ulong magic, sz; @@ -471,8 +457,8 @@ static abi_ulong *restore_sigframe_v2_vfp(CPUARMState *env, abi_ulong *regspace) return (abi_ulong*)(vfpframe + 1); } -static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env, - abi_ulong *regspace) +static abi_ulong *restore_sigframe_iwmmxt(CPUARMState *env, + abi_ulong *regspace) { int i; abi_ulong magic, sz; @@ -496,9 +482,9 @@ static abi_ulong *restore_sigframe_v2_iwmmxt(CPUARMState *env, return (abi_ulong*)(iwmmxtframe + 1); } -static int do_sigframe_return_v2(CPUARMState *env, - target_ulong context_addr, - struct target_ucontext_v2 *uc) +static int do_sigframe_return(CPUARMState *env, + target_ulong context_addr, + struct target_ucontext *uc) { sigset_t host_set; abi_ulong *regspace; @@ -506,19 +492,20 @@ static int do_sigframe_return_v2(CPUARMState *env, target_to_host_sigset(&host_set, &uc->tuc_sigmask); set_sigmask(&host_set); - if (restore_sigcontext(env, &uc->tuc_mcontext)) + if (restore_sigcontext(env, &uc->tuc_mcontext)) { return 1; + } /* Restore coprocessor signal frame */ regspace = uc->tuc_regspace; if (cpu_isar_feature(aa32_vfp_simd, env_archcpu(env))) { - regspace = restore_sigframe_v2_vfp(env, regspace); + regspace = restore_sigframe_vfp(env, regspace); if (!regspace) { return 1; } } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { - regspace = restore_sigframe_v2_iwmmxt(env, regspace); + regspace = restore_sigframe_iwmmxt(env, regspace); if (!regspace) { return 1; } @@ -535,10 +522,10 @@ static int do_sigframe_return_v2(CPUARMState *env, return 0; } -static long do_sigreturn_v2(CPUARMState *env) +long do_sigreturn(CPUARMState *env) { abi_ulong frame_addr; - struct sigframe_v2 *frame = NULL; + struct sigframe *frame = NULL; /* * Since we stacked the signal on a 64-bit boundary, @@ -555,10 +542,9 @@ static long do_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, - frame_addr - + offsetof(struct sigframe_v2, uc), - &frame->uc)) { + if (do_sigframe_return(env, + frame_addr + offsetof(struct sigframe, uc), + &frame->uc)) { goto badframe; } @@ -571,15 +557,10 @@ badframe: return -TARGET_QEMU_ESIGRETURN; } -long do_sigreturn(CPUARMState *env) -{ - return do_sigreturn_v2(env); -} - -static long do_rt_sigreturn_v2(CPUARMState *env) +long do_rt_sigreturn(CPUARMState *env) { abi_ulong frame_addr; - struct rt_sigframe_v2 *frame = NULL; + struct rt_sigframe *frame = NULL; /* * Since we stacked the signal on a 64-bit boundary, @@ -596,10 +577,9 @@ static long do_rt_sigreturn_v2(CPUARMState *env) goto badframe; } - if (do_sigframe_return_v2(env, - frame_addr - + offsetof(struct rt_sigframe_v2, uc), - &frame->uc)) { + if (do_sigframe_return(env, + frame_addr + offsetof(struct rt_sigframe, uc), + &frame->uc)) { goto badframe; } @@ -611,8 +591,3 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } - -long do_rt_sigreturn(CPUARMState *env) -{ - return do_rt_sigreturn_v2(env); -} From patchwork Fri Sep 24 16:59:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514583 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1673631jao; Fri, 24 Sep 2021 10:01:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRfnWRMNfDzoQdu3XCpKI0WGlWQALcBylsdFKZCX9gL+WY1/33bfW7fQ0OYL/VAW6FQRcS X-Received: by 2002:a37:a557:: with SMTP id o84mr11597889qke.330.1632502886432; Fri, 24 Sep 2021 10:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632502886; cv=none; d=google.com; s=arc-20160816; b=M48nRtdjMPn24HtAjlDwOQDulzw4NxLwYeIKmNejVJo906VXo4/kwrKVnEXN5y36Wz oqTR2NZ3Z/GePyT8OmBhuXPZ1kuSrVRcZimBsy+pivIdx2dLTm1PQV7SXJXzLY8qBn/A XkBY17kQOTMnHr5iSmwQ6aENZ5wJAxHc7ZWJILy3aTrliy7D2befQLohnMNfZzFZYylV oUPUQBpA1oiu/SKSPfwPHNIR58+6JmCg02VFABirjQrMGFa0x05SavfOwVGK64UMwviu gNvpM8yLDs9JY6ActrBbA8vQcNCf3caEvmNeG+i3oPFmMfKe/+kZzcTJl46/SrpDORLs HzSQ== 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=tTWEHxzXUUId2fX/NSdCUm8jXTQGtuUSFGG/XZYirZo=; b=X7N6A/Y4RRhOxFLrmWJE03Mw7cTGri1EzcYkfbdnoXz6V/r0lzZiBoNVQSjrETsgi5 cSs/eISZsBgl16RyAYEUNLAkCtbRBThf6qMTu4Cts5NeIKA46YC16m4CR6cksHsKsgnj Y5U3sAIVf7xbJHJ1Kse6mhYAWX3CNJeYXOoLUJSW8xaUei4KHHs1Bkov0FaBLRXQHbmb vTy+1bdmY3rNfHVIsycW3YyhAbrq4PmMVL+9kdBj4lH48EOg9VJ5gxXhQtRRYG/5vK7E h8flpBi6859Bo/zJcTUw9mofbn0ha/jZwAw8g9ojXbRXSkZeRUP1znz6mtDjtq5IWFSk /Vog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VOCM2nTb; 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 e28si5401745qvb.216.2021.09.24.10.01.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:01: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=VOCM2nTb; 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]:55052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToZh-0002f2-Qr for patch@linaro.org; Fri, 24 Sep 2021 13:01:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXv-0002dd-Pp for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:36 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:45806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXt-0006tj-Fm for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:35 -0400 Received: by mail-qv1-xf32.google.com with SMTP id x9so486539qvn.12 for ; Fri, 24 Sep 2021 09:59:32 -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=tTWEHxzXUUId2fX/NSdCUm8jXTQGtuUSFGG/XZYirZo=; b=VOCM2nTbaAf0Fx3vPobozgYQV63bh0P3PtyWu4qqmoSMcmJDiCVZmQcdtgg5nc/Kpn 2FdpIOSranUcVQX7PZCMVo2xZyTWODIgK3CS2CbLQNxlroGJ4Tvw52AohfQW4ULU1bYQ RFHoPGhDbDyYOkNAj/mFwnFt2bNm1auMX+F9R86VzUgSC+06kyLvfnoqum+36K/HuUJe TtFBmeOKxvHftD8Zk52XhHGmwWYMxVreGZt2OmSUOGbxCMDut6ELpMh0KgK1vQKX3+RZ LijT7/r0sTqdf8UoOomqZIKxhB8X4QYezz7vcVROFtM/MaRkYS35zHv/+ln/Lf5fdzhe AxJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tTWEHxzXUUId2fX/NSdCUm8jXTQGtuUSFGG/XZYirZo=; b=K3X4lp1FfD9YWKghNa6af0p8NYSADgAKlzeLLoYztnWKq61yD1a9WnW0IiZNmUglKe Yfo8ymv2i6uCXK91+3YB05l0jS1WfUQXsJYbKHQXBk6fSJuaIyo82ynqLEIsfZx1CIzK ayJxfvWAo/nZI4fFLkYXM0xTHMvF4ap6m+X6ZsVlBQfnB5E8uDMfnzY3efgpVq2m5QcA FOOLIoFyYFBlmFmZZQvyai9ICT8lpjWI8NC/rnpBSX8R5ILE2ny2PpeJTTqFTkcIx1Bl CWcIe6pMwBZJl0Je60O72Et89q/x9a+A1svOIWlH8fy4KFYtO/MI7YXwS2dVvfvypY1q ceWQ== X-Gm-Message-State: AOAM531emB7bsQhkXU4TnaR8ftslC9F355zRE/DemRdLmL8Xt5BV4IqQ f4gQ+Sb/Pk3ch9tgeC8BHRvV2wkCPcae0A== X-Received: by 2002:ad4:446f:: with SMTP id s15mr11239397qvt.3.1632502771872; Fri, 24 Sep 2021 09:59:31 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/27] linux-user/arm: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:04 -0400 Message-Id: <20210924165926.752809-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf32.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Update the trampoline code to match the kernel: this uses sp-relative accesses rather than pc-relative. Signed-off-by: Richard Henderson --- linux-user/arm/target_signal.h | 2 + linux-user/arm/signal.c | 177 ++++++++++++++++++++++++--------- 2 files changed, 130 insertions(+), 49 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/target_signal.h b/linux-user/arm/target_signal.h index 0998dd6dfa..1e7fb0cecb 100644 --- a/linux-user/arm/target_signal.h +++ b/linux-user/arm/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* ARM_TARGET_SIGNAL_H */ diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c index ed7d1d80bb..ccfae43028 100644 --- a/linux-user/arm/signal.c +++ b/linux-user/arm/signal.c @@ -103,39 +103,52 @@ struct rt_sigframe abi_ulong retcode[4]; }; -/* - * For ARM syscalls, we encode the syscall number into the instruction. - */ -#define SWI_SYS_SIGRETURN (0xef000000|(TARGET_NR_sigreturn + ARM_SYSCALL_BASE)) -#define SWI_SYS_RT_SIGRETURN (0xef000000|(TARGET_NR_rt_sigreturn + ARM_SYSCALL_BASE)) +static abi_ptr sigreturn_fdpic_tramp; /* - * For Thumb syscalls, we pass the syscall number via r7. We therefore - * need two 16-bit instructions. + * EABI syscalls pass the number via r7. + * Note that the kernel still adds the OABI syscall number to the trap, + * presumably for backward ABI compatibility with unwinders. */ -#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_sigreturn)) -#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (TARGET_NR_rt_sigreturn)) +#define ARM_MOV_R7_IMM(X) (0xe3a07000 | (X)) +#define ARM_SWI_SYS(X) (0xef000000 | (X) | ARM_SYSCALL_BASE) -static const abi_ulong retcodes[4] = { - SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN, - SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN -}; +#define THUMB_MOVS_R7_IMM(X) (0x2700 | (X)) +#define THUMB_SWI_SYS 0xdf00 + +static void write_arm_sigreturn(uint32_t *rc, int syscall) +{ + __put_user(ARM_MOV_R7_IMM(syscall), rc); + __put_user(ARM_SWI_SYS(syscall), rc + 1); +} + +static void write_thumb_sigreturn(uint32_t *rc, int syscall) +{ + __put_user(THUMB_SWI_SYS << 16 | THUMB_MOVS_R7_IMM(syscall), rc); +} /* - * Stub needed to make sure the FD register (r9) contains the right - * value. + * Stub needed to make sure the FD register (r9) contains the right value. + * Use the same instruction sequence as the kernel. */ -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 void write_arm_fdpic_sigreturn(uint32_t *rc, int ofs) +{ + assert(ofs <= 0xfff); + __put_user(0xe59d3000 | ofs, rc + 0); /* ldr r3, [sp, #ofs] */ + __put_user(0xe8930908, rc + 1); /* ldm r3, { r3, r9 } */ + __put_user(0xe12fff13, rc + 2); /* bx r3 */ +} -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 void write_thumb_fdpic_sigreturn(void *vrc, int ofs) +{ + uint16_t *rc = vrc; + + assert((ofs & ~0x3fc) == 0); + __put_user(0x9b00 | (ofs >> 2), rc + 0); /* ldr r3, [sp, #ofs] */ + __put_user(0xcb0c, rc + 1); /* ldm r3, { r2, r3 } */ + __put_user(0x4699, rc + 2); /* mov r9, r3 */ + __put_user(0x4710, rc + 3); /* bx r2 */ +} static inline int valid_user_regs(CPUARMState *regs) { @@ -184,13 +197,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 *rc, abi_ulong frame_addr, int usig, abi_ulong rc_ofs) { 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) { @@ -208,6 +220,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, } thumb = handler & 1; + retcode_idx = thumb + (ka->sa_flags & TARGET_SA_SIGINFO ? 2 : 0); uint32_t cpsr = cpsr_read(env); @@ -225,37 +238,39 @@ 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 need a special trampoline + * the reads the function descriptor from the frame, + * sets r9 and jumps back to restorer value. + * + * This on-stack code is unused but retained for ABI compliance. */ 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); + write_thumb_fdpic_sigreturn(rc, rc_ofs + 12); } 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); + write_arm_fdpic_sigreturn(rc, rc_ofs + 12); } + __put_user((abi_ulong)ka->sa_restorer, &rc[3]); - retcode = rc_addr + thumb; + /* Each trampoline variant consumes a 12-byte slot. */ + retcode = sigreturn_fdpic_tramp + retcode_idx * 12 + thumb; } else { retcode = ka->sa_restorer; } } else { - unsigned int idx = thumb; + int syscall = (ka->sa_flags & TARGET_SA_SIGINFO + ? TARGET_NR_rt_sigreturn : TARGET_NR_sigreturn); - if (ka->sa_flags & TARGET_SA_SIGINFO) { - idx += 2; + /* This on-stack code is unused but retained for ABI compliance. */ + if (thumb) { + write_thumb_sigreturn(rc, syscall); + } else { + write_arm_sigreturn(rc, syscall); } - __put_user(retcodes[idx], rc); - - retcode = rc_addr + thumb; + /* Each trampoline variant consumes 8-byte slot. */ + retcode = default_sigreturn + retcode_idx * 8 + thumb; } env->regs[0] = usig; @@ -352,7 +367,7 @@ void setup_frame(int usig, struct target_sigaction *ka, setup_sigframe(&frame->uc, set, regs); if (setup_return(regs, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct sigframe, retcode))) { + offsetof(struct sigframe, retcode))) { goto sigsegv; } @@ -383,7 +398,7 @@ void setup_rt_frame(int usig, struct target_sigaction *ka, setup_sigframe(&frame->uc, set, env); if (setup_return(env, ka, frame->retcode, frame_addr, usig, - frame_addr + offsetof(struct rt_sigframe, retcode))) { + offsetof(struct rt_sigframe, retcode))) { goto sigsegv; } @@ -591,3 +606,67 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + enum { + SIGFRAME_FDPIC_OFS = offsetof(struct sigframe, retcode[3]), + RT_SIGFRAME_FDPIC_OFS = offsetof(struct rt_sigframe, retcode[3]), + }; + + uint32_t total_size = 4 * 8 + 4 * 12; + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, total_size, 0); + uint32_t i = 0; + + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + write_arm_sigreturn(&tramp[i], TARGET_NR_sigreturn); + i += 2; + write_thumb_sigreturn(&tramp[i], TARGET_NR_sigreturn); + i += 2; + write_arm_sigreturn(&tramp[i], TARGET_NR_rt_sigreturn); + i += 2; + write_thumb_sigreturn(&tramp[i], TARGET_NR_rt_sigreturn); + i += 2; + + /* + * FDPIC require trampolines to call sa_restorer, and different + * from the pc-relative versions we write to the stack. + * + * ARM versions use: + * ldr r3, [sp, #ofs] + * ldr r9, [r3, #4] + * ldr pc, [r3, #0] + * + * Thumb versions use: + * ldr r3, [sp, #ofs] + * ldmia r3, {r2, r3} + * mov r9, r3 + * bx r2 + */ + sigreturn_fdpic_tramp = sigtramp_page + i * 4; + + /* ARM sigframe */ + write_arm_fdpic_sigreturn(tramp + i, + offsetof(struct sigframe, retcode[3])); + i += 3; + + /* Thumb sigframe */ + write_thumb_fdpic_sigreturn(tramp + i, + offsetof(struct sigframe, retcode[3])); + i += 3; + + /* ARM rt_sigframe */ + write_arm_fdpic_sigreturn(tramp + i, + offsetof(struct rt_sigframe, retcode[3])); + i += 3; + + /* Thumb rt_sigframe */ + write_thumb_fdpic_sigreturn(tramp + i, + offsetof(struct rt_sigframe, retcode[3])); + i += 3; + + assert(i * 4 == total_size); + unlock_user(tramp, sigtramp_page, total_size); +} From patchwork Fri Sep 24 16:59:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514585 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1676961jao; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd+FrTgbFV7gdQmm/Xq7tEW2Ld/zbsBWaL2Veky8na3cJ6daqADhGJXhgsNYUrObkNmHL+ X-Received: by 2002:ac8:5e0d:: with SMTP id h13mr5363525qtx.403.1632503076532; Fri, 24 Sep 2021 10:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503076; cv=none; d=google.com; s=arc-20160816; b=SXVvtbus0A/ZFOfVZD6SkyXVaIaDO/DnkDL4wIQq/sffBZLpJBmfOeiXrN8LFSM2uz lF/PdR/1eadbbRdWmEmxVgKTh/IAMctQoS1RAFhq9pZnEIYz1KOnM1ihghZaudXTbYPU 968YAnc2gmBiytKHrAEK4vPdRjOJ4YpeHuD221uOjrbocdskwf7ggOASaVkmwqd/N1Ol Nw8YeGp/BgvRo+8F8zEpjrfQg7X9MvPeyCOdiF++qKndqiWqFIGmpXKpip4DjKorREff kFtYoNZEQ2bwLKv2kL88lK0X+Y+Yo6+BheSnec3X8TDGoummWYFkXi1jjJh8W4a3sdyC nHKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=CbHXPrAD32ELq5r5ihCevy9di5uJmn8/HLdyBS8r2g1pdnRmwj+IG9HPhmJvdPgvjs 5gi3HOCVfAokn+vt8pf+YQI5QebZPSiArcLkNQJlMe4MKhWB9pypiUteMx60sEbqQge6 Cwe3+j6JUJQDhKmQEd2FJr+4NXr3qQmqsq9Urlvjf/DRyaHznWyAUKIXD7nXW/jeE9Hv 5kMIXlOL9iDIkCpTmZthkP/FqBGNRaJby+pWZ5NJYDEimYsf8vB4oZaj7ssM+TPA5FfJ Cm1ZPbqzkEi+uBXF0ErWhhY92Ph9MFQg1oShTylAT3jjdjwlxB+TVuEgxgp10Q6thgIk XkXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ud9lf2mY; 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 v9si6851195qkp.410.2021.09.24.10.04.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:04: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=ud9lf2mY; 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]:35436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTocm-0000UA-1Q for patch@linaro.org; Fri, 24 Sep 2021 13:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXy-0002eH-Dp for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:39697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXt-0006uP-GB for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: by mail-qt1-x82b.google.com with SMTP id j13so10052488qtq.6 for ; Fri, 24 Sep 2021 09:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=ud9lf2mY1kqgyV1OUwTUDcnBBvctQRisFqCtOvkpLfvkZuAFZyOT0ocd6QCPyB/d5z BqEyBG7l7VGVeIwexC5E7oP5JLMrEez13+7nhB9ciddNS0dwTh/P9JatLwaCuV9I6pLS 1+1FftaAZDdeqRlKXGMhnIUCygfUYW65vcj/pDIHLU0KHwfX67Qn7oEzhbF3I8EdUeuB EEKBhtm2yMGIZmRChWlr31hccJ0yIneMaNI9A82OGGJl8wuJE6yTznl4PAui1REJTace BGHThyj9pX3eCm0S93+8u+zJOZxjXrWswnG4uBUe80BXLJO778aC2pLb02BQ4iAEIMmz u8Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E9r1xAdALpfQj8Y2p7MHsD/Kt2/NgPJhspyOQqw2vSE=; b=Xs8Wg49WJHE5FM9c/oXmYZrZLIsg0q/mBFCjBudvxJInV55VYMkBOuT7ADT7Nbv3HJ 5CEhJllcde8ovl+zVGgEysDTWivnLmtI3HQmhBKlGdoNLZnk4YmvV8GEPuaDySnI7lTa yN51hLSt1CvIjUQoezEUXr2REPlr6HiTIfUviZG9qnWD6Mou404f/e2ce8ftXrHA5cr9 I62p45NeyA/q41uWm5NAShNpC0e6SdkDfv9yubzjK42Jh0yYbrYI+rXBQYUVg1ftW3t2 ynXyEKN2Chz4gB6a532I8PeRGOTxm6xeb4fWYqO3WPPbUZ0Re6mteX7R1WgbjNkpHrsX QxYg== X-Gm-Message-State: AOAM530D6W7rrk9cCtyWiI19MJhc8w1JVFNNf6+gw7U8WsLe+yubSNAe /55wVAbUXqAw9UHzuCDbmhngixsElM8Xeg== X-Received: by 2002:ac8:7741:: with SMTP id g1mr5283788qtu.366.1632502772511; Fri, 24 Sep 2021 09:59:32 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/27] linux-user/alpha: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:05 -0400 Message-Id: <20210924165926.752809-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use ka_restorer. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/alpha/target_signal.h | 1 + linux-user/alpha/signal.c | 34 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index 250642913e..0b6a39de65 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -93,6 +93,7 @@ typedef struct target_sigaltstack { #define TARGET_ARCH_HAS_SETUP_FRAME #define TARGET_ARCH_HAS_KA_RESTORER +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/alpha/signal.c b/linux-user/alpha/signal.c index 3a820f616b..bbe3dd175a 100644 --- a/linux-user/alpha/signal.c +++ b/linux-user/alpha/signal.c @@ -55,13 +55,11 @@ struct target_ucontext { struct target_sigframe { struct target_sigcontext sc; - unsigned int retcode[3]; }; struct target_rt_sigframe { target_siginfo_t info; struct target_ucontext uc; - unsigned int retcode[3]; }; #define INSN_MOV_R30_R16 0x47fe0410 @@ -142,12 +140,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb() */ - r26 = frame_addr + offsetof(struct target_sigframe, retcode); + r26 = default_sigreturn; } unlock_user_struct(frame, frame_addr, 1); @@ -196,12 +189,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { r26 = ka->ka_restorer; } else { - __put_user(INSN_MOV_R30_R16, &frame->retcode[0]); - __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, - &frame->retcode[1]); - __put_user(INSN_CALLSYS, &frame->retcode[2]); - /* imb(); */ - r26 = frame_addr + offsetof(struct target_rt_sigframe, retcode); + r26 = default_rt_sigreturn; } if (err) { @@ -269,3 +257,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6 * 4, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(INSN_MOV_R30_R16, &tramp[0]); + __put_user(INSN_LDI_R0 + TARGET_NR_sigreturn, &tramp[1]); + __put_user(INSN_CALLSYS, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 3 * 4; + __put_user(INSN_MOV_R30_R16, &tramp[3]); + __put_user(INSN_LDI_R0 + TARGET_NR_rt_sigreturn, &tramp[4]); + __put_user(INSN_CALLSYS, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 6 * 4); +} From patchwork Fri Sep 24 16:59:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514590 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1680932jao; Fri, 24 Sep 2021 10:08:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuZIHseIQtBFvvxOqzP+XOdCwVksb2wdgPz91G3AcufCS85q5kIY3uPH7VCHtTyAUEDTKN X-Received: by 2002:a0c:e1ce:: with SMTP id v14mr11264453qvl.28.1632503280360; Fri, 24 Sep 2021 10:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503280; cv=none; d=google.com; s=arc-20160816; b=okXMFK9yE7n8BXgBJZKA5HDQPsKu7BSUyX20zT8GCVcmDPGW9OS75PXv/6vtwWrOSW iRwVNd87g0AEKydtKIsBHQGh2yAr5TZhTZlotebxSENrEUAyZwTM0t+rcEZGueG3GQXJ F+MGjQNpNE9NBv42USPOvByB5peO4t+eQMOZEM8DP9e/A4kv1Nlku4HK5JAtNmlkALEL QFY4XRRwiD4qroL/XSxFneLznJxEnaqyYbjL96RbzkOhjR9gnIH38uGx6csQ7R5o/KMy 4Rjo5WPOsgPR2/hIHXaK+X81Crj/MTG5SwiuXbb2G1RBNZIad1jBy34avmKL52rsJh1X esjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=dkKnOCMic/lDNFTR6IGu2auHWcA0OnDcSFrmO8z3CNLaPew28sd1n0r3UOovsS6bv9 dsrCcodedLIipa0oM3xXdgIIiQrXq+uwCC41ZzfSlBz5tiBtiL9Vuw61s6LnrlLBkdbs KlOBIEcue/brl2VAqppVqu/zBcYCZid/r6S6Zdy+VaMcmDLHSh6ea4fBuFE/51g1il29 la4aQRtC5rCUEmXwEx+UXZ7VtlzstCQsQR7pH7kCyQDwqpYFqcJfIrqK+oQXE7nSOV6F +1jYZwPmpgLWayHlUi5BFlofelyS8eMy/Ix+dgzoOfXaU94jSXQpe5QMt5VVDWaH2xS3 CxbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eXml2nXa; 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 w4si6528648qko.336.2021.09.24.10.08.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:08:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eXml2nXa; 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]:43894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTog3-0006E5-U1 for patch@linaro.org; Fri, 24 Sep 2021 13:07:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY0-0002ep-3v for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:41 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:42613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXu-0006vL-2F for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:39 -0400 Received: by mail-qk1-x734.google.com with SMTP id t4so28576879qkb.9 for ; Fri, 24 Sep 2021 09:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=eXml2nXat9+Vihtlw6ZwnOLHOSI6g2gFXnIN6qzzVvp+XuCFeRcQUm7FYmiHLZx+T3 nyP/C4ulaqfdsDm6PiQH/NjtqlLqtHDDRPFdUB34RoOogjKONQ/Yo1RhfM0hfoTD0wsH PmC+7evT+7/GZb8mtMrv9gLBb29GtrqU9sGdD8jVIC1vUtPMQ4ojJHzrr906UmgZTNSi kG0ZBPRl/XBwvKdCl3Z19YJ6zthA+jwi33xOgOMx6PNH4PYjkCPTb6EoyQi58Shm0Pjn 1bipsOKuCgA2DBw408s4EYxkFuhIEkCXD/Hq7D9490UxnGHuuyKrLSt2QJnxxB8Ok2OR F6TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gwFLRVkTdcJ6AaaaGFzbcnne0zgO30rR8Nm1DoFMwjE=; b=2Wkq+O5UvgpPfddzliuJ9NTVOmKgwbgTXreua2rSmstmo6+/9KwTyQxsyDAj6jo7nw ERbqFzK19mnlqeLRkTM349RZ2XZqOOqNm2DlDQs5F3C7L3pks3lM2GYuDpTTYpPW81AK YbzmY9AmLKcDdEk3zYyXPKxv7iVQxpkgUn8dk7kwTstwaX0EyzPvuAsHQlZhPhtUtmJr +vqCXlOmv1gB7Nsa53g8kswh+aOwAmMJ8rnBvIz5pJL6jy7/oYZpo1xJU5pUzSmkCUV1 rZckTxyYn3JFgrwy01AGEU+zKGf626zuc1OLgPCVyksioEdbk9Z25qmUsPN8HoHujvEW xvaw== X-Gm-Message-State: AOAM532oz/073c9U7Dg8BQp1njK6qdqt4whQxCZtw1dh71YAmDjY9Zpy VJkRna9WPofvpGHLP8M4Nk2Lq5zQIRRIuw== X-Received: by 2002:a37:c42:: with SMTP id 63mr11738951qkm.104.1632502773217; Fri, 24 Sep 2021 09:59:33 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/27] linux-user/cris: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:06 -0400 Message-Id: <20210924165926.752809-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , laurent@vivier.eu, "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split out setup_sigreturn so that we can continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/cris/target_signal.h | 2 ++ linux-user/cris/signal.c | 29 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/cris/target_signal.h b/linux-user/cris/target_signal.h index 495a142896..83a5155507 100644 --- a/linux-user/cris/target_signal.h +++ b/linux-user/cris/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* CRIS_TARGET_SIGNAL_H */ diff --git a/linux-user/cris/signal.c b/linux-user/cris/signal.c index 2c39bdf727..7f6aca934e 100644 --- a/linux-user/cris/signal.c +++ b/linux-user/cris/signal.c @@ -97,6 +97,14 @@ static abi_ulong get_sigframe(CPUCRISState *env, int framesize) return sp - framesize; } +static void setup_sigreturn(uint16_t *retcode) +{ + /* This is movu.w __NR_sigreturn, r9; break 13; */ + __put_user(0x9c5f, retcode + 0); + __put_user(TARGET_NR_sigreturn, retcode + 1); + __put_user(0xe93d, retcode + 2); +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUCRISState *env) { @@ -112,14 +120,8 @@ void setup_frame(int sig, struct target_sigaction *ka, /* * The CRIS signal return trampoline. A real linux/CRIS kernel doesn't * use this trampoline anymore but it sets it up for GDB. - * In QEMU, using the trampoline simplifies things a bit so we use it. - * - * This is movu.w __NR_sigreturn, r9; break 13; */ - __put_user(0x9c5f, frame->retcode+0); - __put_user(TARGET_NR_sigreturn, - frame->retcode + 1); - __put_user(0xe93d, frame->retcode + 2); + setup_sigreturn(frame->retcode); /* Save the mask. */ __put_user(set->sig[0], &frame->sc.oldmask); @@ -135,7 +137,7 @@ void setup_frame(int sig, struct target_sigaction *ka, env->regs[10] = sig; env->pc = (unsigned long) ka->_sa_handler; /* Link SRP so the guest returns through the trampoline. */ - env->pregs[PR_SRP] = frame_addr + offsetof(typeof(*frame), retcode); + env->pregs[PR_SRP] = default_sigreturn; unlock_user_struct(frame, frame_addr, 1); return; @@ -187,3 +189,14 @@ long do_rt_sigreturn(CPUCRISState *env) qemu_log_mask(LOG_UNIMP, "do_rt_sigreturn: not implemented\n"); return -TARGET_ENOSYS; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + setup_sigreturn(tramp); + + unlock_user(tramp, sigtramp_page, 6); +} From patchwork Fri Sep 24 16:59:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514592 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1681216jao; Fri, 24 Sep 2021 10:08:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9eN6Yx5e/OR+wPveaRXEN9eQ623sP0sjxZ9Eg/dX17dPLW6opjDeASfVpRC4PaMfa3lva X-Received: by 2002:a37:9d96:: with SMTP id g144mr11216134qke.23.1632503296797; Fri, 24 Sep 2021 10:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503296; cv=none; d=google.com; s=arc-20160816; b=ZE7EaJpq+9vOhrwM4RQZI9HpxU9rn1+RjSMvRtI84cxRRppd7/lc9XAwYMgirrR+9y AS6OO9WgjnJ8eqSNtJmlg9ssdo+wm8ZL9IKenNyAdrGKCQEWvq1fJg3GbokOsxxJsKxg pifiFR7TU/DXXxSKTaqj2i27WqIIq5Kld/nZbQDe3TbbgiI5S4RGtquwa1clhXgnYDFF L+ODZE7zoRs8PLTEjQjt0m0uUpIaHPlDO7W/PFnfDMZK0icS3+jWPUA7PRiLMNZndfFu xpbVr1wtwlmklcOpDNP5IV7lVsaVj4AOpakO4kJgGDCnQelhxROUBSWvCoN519Gfho0T pUvQ== 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=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=gf2UJ4Mb06RWnh/cILyYg1tjCadCg87PlzSDvxrUKwYM9hv8jM/pNLm+BsRSerASQf xFhHP9lqpqwQ5W8M9BV3oMmoLd7IGfjuU7QE0BXkws5PCVeRhDNTvGmiCVMAPq0wkib1 o/YG39mcdOM7+ZqCD5EoFlX+iz1ytFSxDzZV12zNyeSqYqx4RylOohMst1GXu1YQDd4R kDZ3Rsi/FCie9oUKNIuWD6GshHiOE5aZ8NQt0ou5zIEtkEjufW+sw+hwh6nZ3vkjBQds Fo6f/KxBM37r3VNkeQ+b1va6dTZI+2LBN6m5iffJpPLKogxs/+aGsyCuo7SMU2KhSuOe DHBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jbqpXiP2; 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 u5si7022936qvc.72.2021.09.24.10.08.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:08:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jbqpXiP2; 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]:44214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTogK-0006Qp-98 for patch@linaro.org; Fri, 24 Sep 2021 13:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToXz-0002ej-4N for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:39 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:35522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXu-0006wI-Ur for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:38 -0400 Received: by mail-qk1-x72a.google.com with SMTP id c7so29003543qka.2 for ; Fri, 24 Sep 2021 09:59:34 -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=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=jbqpXiP227iB56KT34GI22QoNKWUmiAL5m0c+fZrYQg9FlTNcu4p5uznvNQNmGexYW aqn7/0JXtTqFHPjdthtVhhyHZ3CWwEPE+cKlfOCaOhh2jyjMKG55xq+uc8YiU/derCI6 U1uhgkf/r1E4r7ZlJdDavHUGL8JwAs6jKdBYxAzSH0x/QtXKLtrIuuc3NdBDw0hnPGBM hEg/I+492spSjz6JKJ7SdW4cd1+U5KOl18jhnaAgE09qnjjXpG4FhGoErpDk4rmIWT2B nFvs1kesh+8vNiN8thn0+hHTcHfDKVyTAfdOk0Z8YigkMtwS5R5zlAZ9S6H7lAfBhLEs esxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FWLQL0pLDN+l5fhiAE6r0vZZJCHIq9CC1u+lOHbDMRg=; b=t21JrUq9u7Uofb1gNE//cBbBeS7bfiwxQdBps/suAKsniVz/DIeEzoozMHclFOkcMG zdIsRKAtAm15tZ98f9NG+2eHmEN5rTTZ0SAZdlCPUz61n9DgM1p/PyKTWpqeS7eAmuUa RWVdtfl7tkSmCSfQBU3xO4bxFfdosDK/qds/dqDbD4xN3Yg6pdJK4r6pF51OsA89dr02 bRYuG1HX3rYRlM33DcqiTIWgxNJBG7Qs+p+pwamwiz7rdlhPGcPXsdV7xShyq8JPuHvP FwH34+796NoqXx4L1yGOXFQRyUkn2niP08Bt8FOLdVchVB0v6FBAD5S/DeV+6sCIILq+ OO+Q== X-Gm-Message-State: AOAM532etQCQzCJ8DIaNJHR4fn/Bk9YkZzliEHzu00YvtFpMLFFQnVPj wzN0wBREjBaTL9uWOPguREQ0FKVBaIkfVg== X-Received: by 2002:a37:9606:: with SMTP id y6mr11326294qkd.13.1632502774021; Fri, 24 Sep 2021 09:59:34 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/27] linux-user/hexagon: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:07 -0400 Message-Id: <20210924165926.752809-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Taylor Simpson , laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Continue to initialize the words on the stack, as documented. However, use the off-stack trampoline. Cc: Taylor Simpson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/hexagon/target_signal.h | 2 ++ linux-user/hexagon/signal.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.25.1 Reviewed-by: Taylor Simpson diff --git a/linux-user/hexagon/target_signal.h b/linux-user/hexagon/target_signal.h index 345cf1cbb8..9e0223d322 100644 --- a/linux-user/hexagon/target_signal.h +++ b/linux-user/hexagon/target_signal.h @@ -31,4 +31,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* TARGET_SIGNAL_H */ diff --git a/linux-user/hexagon/signal.c b/linux-user/hexagon/signal.c index c7f0bf6b92..74e61739a0 100644 --- a/linux-user/hexagon/signal.c +++ b/linux-user/hexagon/signal.c @@ -162,6 +162,11 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); + /* + * The on-stack signal trampoline is no longer executed; + * however, the libgcc signal frame unwinding code checks + * for the presence of these two numeric magic values. + */ install_sigtramp(frame->tramp); env->gpr[HEX_REG_PC] = ka->_sa_handler; @@ -171,8 +176,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[HEX_REG_R02] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[HEX_REG_LR] = - frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[HEX_REG_LR] = default_rt_sigreturn; return; @@ -271,3 +275,14 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 * 2, 0); + assert(tramp != NULL); + + default_rt_sigreturn = sigtramp_page; + install_sigtramp(tramp); + + unlock_user(tramp, sigtramp_page, 4 * 2); +} From patchwork Fri Sep 24 16:59:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514595 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1683952jao; Fri, 24 Sep 2021 10:10:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLPbNMezjO9uR+BjAcdRUOIIO52mdikZ/ohnyqGteRUHFldMfA7INf6cU6L6n/YGtVcSpT X-Received: by 2002:a7b:ca45:: with SMTP id m5mr2953619wml.104.1632503448990; Fri, 24 Sep 2021 10:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503448; cv=none; d=google.com; s=arc-20160816; b=KAcijkjy6VAUJzNl6tvpoN3n90wfyrB1s1DvUpE5nygAHLcfVpVHD8o9jDpJFLFHjG gofpWgs0ydbdH6RjR2NqBD63zM86HuKm37N4B49JpEEt1O60AfBSXyThkfq8Gct7XOLF RrXhLP7ZSX1c1/yjhb5Mp7nPQxNj66o7W4Jdp1uvKc+Hp0OwCzS7cNyvG8gHVZvc4ui9 WnDdWLaA95msFdz+O2OlUaB0bq4CldF7HwigWyTtqC3ZnkbdjvxBE4wXi5+47ikZrBxD RQNg1JGDTxnHcXZ+E6QFMnzJQ/wTs6yb81waOQXw1nZmIr2kQOulDVsoaubFlGUkYxUr 5QIw== 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=p8EKc5nnXKWumUwfTClt1gPynIpSAfeMJXHjXBsocVGTdGEhbsovRQAEuczEKqKNsu iJVwguXtdZyMlVmlXlCMadY7haRVmdtybc/QaNb/zzSZq+m9hwwu3mtHWGiC7KpcY/kv LmY92Bf3Moh+RJKP4n8xQwfv94e9IAthA8TG4v+gcv6A78ENdCrUOEOng2swPD27W4/X 6CwCQ6kgXnKAIpihuEsWcyieSNgH1Pc6EI8eY4FO7k7gcXkh+jcBM5x0Pwt2S8RfkYb4 hTrhpgfuvf8pWgChhFqp89/bN8T0lVT3Va12ICKU7kioLfLoy004t8ujvkc5ZyOKu+SC /Z4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=y1R55l3y; 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 k17si11053215wmj.196.2021.09.24.10.10.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:10: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=y1R55l3y; 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]:52794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToim-0003lZ-1R for patch@linaro.org; Fri, 24 Sep 2021 13:10:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY2-0002fZ-3D for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:41541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXw-0006x0-Mw for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:41 -0400 Received: by mail-qk1-x72e.google.com with SMTP id m7so11925475qke.8 for ; Fri, 24 Sep 2021 09:59:35 -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=y1R55l3yDenfrNbpwSVjFg0dDYxN3NAVRc4/S5F6XCa3I1mbBizZCnYiqMdkoIiP5J 6M6ipzFF+AG2LVcdEVBcSRVKqMYrjNZYLhY5xIvFNqNghP+cYi6pjc1/fonXga4F/q3U OfzGz8CMN/oJ8UxLCraq2npbYiNwUCCHuMbkPWPxtvLu7VsIychWmtoKnfJw2MVNoUQY TeF4odtEcCqz3m/awjef3Q+k03djVl5WWA6vz3CSdv81jm7N/gehtIMQidr7L0Xxdx5F IsbcJcGGYe+3LZFzVr2Cow1NXfaTbfjULbvoMjwDwy0H+BO6Ism/oGJhft0FqNwtfFzI R+Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9uDmWChPs4lp5UI8b6weWaZXX8zbdz4czXb1drnckGg=; b=30jGSA9WAC2MBZmKLhTQ5/ISOuT9z7asZcLVOY8+LGCpIOe4XGp8C8p0VhCLZLcMso wIZYYsUqMOpB+Zr7+vvlMHRdseM+pNaCb/P23NzrDD50KlgpccYJj0KjQ38d5YafdJFv mH+FfFY/2AI6C9XHQbYCu0MvombvUHtP7ajWEVmDHDjPtvRdmMBUSOKwJAIOUVUiFeIn dSkxaxmAHFH1NsBvsK/6SB9bO776aRxbfu2QKv8ltkk8LXGp5nom58XpXivWj5j/9j9H D4ednnFACOSkY6dG/pB2c9pHCsbTCMq7+Lc7r3sQCY5MrdZsPb1UeLp3o6MJXt0toARI F1SQ== X-Gm-Message-State: AOAM532NBtOzZLOuT/gOFGUFphihIV1sHYbEGBdMYdfFak14Yi8pGJgh mJB4iG1rNmkoy5335/ZoM5KX41/7azLiug== X-Received: by 2002:a37:64cc:: with SMTP id y195mr11350785qkb.97.1632502774804; Fri, 24 Sep 2021 09:59:34 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/27] linux-user/hppa: Document non-use of setup_sigtramp Date: Fri, 24 Sep 2021 12:59:08 -0400 Message-Id: <20210924165926.752809-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , laurent@vivier.eu, =?utf-8?q?Philippe_Mathi?= =?utf-8?b?ZXUtRGF1ZMOp?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We cannot use a raw sigtramp page for hppa, but must wait for full vdso support. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/hppa/target_signal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.25.1 diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signal.h index 7f525362e9..d558119ee7 100644 --- a/linux-user/hppa/target_signal.h +++ b/linux-user/hppa/target_signal.h @@ -71,4 +71,18 @@ typedef struct target_sigaltstack { /* mask for all SS_xxx flags */ #define TARGET_SS_FLAG_BITS TARGET_SS_AUTODISARM +/* + * We cannot use a bare sigtramp page for hppa-linux. + * + * Unlike other guests where we use the instructions at PC to validate + * an offset from SP, the hppa libgcc signal frame fallback unwinding uses + * the PC address itself to find the frame. This is due to the fact that + * the hppa grows the stack upward, and the frame is of unknown size. + * + * TODO: We should be able to use a VDSO to address this, by providing + * proper unwind info for the sigtramp code, at which point the fallback + * unwinder will not be used. + */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* HPPA_TARGET_SIGNAL_H */ From patchwork Fri Sep 24 16:59:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514599 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1686719jao; Fri, 24 Sep 2021 10:13:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzACWPA7Sm9OZBcoPsoIpjwRmeaJ55uWs/zV5VxbmVeDdGeY/R4PGGIBk/Hqi74xBg8HdaC X-Received: by 2002:ac8:4308:: with SMTP id z8mr5374762qtm.121.1632503616588; Fri, 24 Sep 2021 10:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503616; cv=none; d=google.com; s=arc-20160816; b=ClK01GyorBQ2QdupEUjNmhkCloUTwhNe1Vui4Q4ThaUhaD9KCEDNmSztzKa2B4jlrf FV8Fe55WHJyILARoubZyplDFSwDX9SYHSWHpAzbqntY+uOtMEZkFev+wOqVJI/oh5+DC Gc719HBHyQcRiKbKcqKSe+pvZAZtNhMYjRnX6CwsDi8rBe7JMx7RDK87/M8bHTF14vqZ +cuoHeY/MsxFZtGH1zOxH20Z/jyZ6cvnLMf4odRWYYM5Tpv52HOWuqAfQQbCiT1uw2Iu ue9kHfnaq/UghmPDRCgy3G8lhHSzRQvrpMtLHr1dsfhi8++p6WzvITq81Zjv5zBwg9QR lXww== 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=uNdU6ybIJfer/a+2lnb556GEnq4khU62qRteMioxBnA=; b=Ho0Iq2TVB+KPdWTKPS89gy1dfzkPlWr/VRTcynM33qZxNUIUzLkr7kCVkpI8t0KLoe LO9dv5eFGH2Rtwd314CQ8RNGBprptQG5Qs0t8tRouQg9BvVzjl0YvG6jj8m/CnYYE4ri IK2JkdWmzTbGb6beHItoqkwaysgVihZVX5myqShnStnia3U5dPT47KfnTHYpYfsAgVUp rDZ225GEv1Tzjhp/aueEn326fV4tPfwwVBXOmWAYQb42voied68exCokv2Vq6dIOcIbf GB1B/LZ9R+VC2YkzQkLy+jS6y0ULGOVrP6Upjb522TkR2Q5gJo2xzLbhITbAJuvBAtgU Mqlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c6rBbSE9; 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 v22si467965qtk.42.2021.09.24.10.13.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:13: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=c6rBbSE9; 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]:33098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTolU-00015y-3d for patch@linaro.org; Fri, 24 Sep 2021 13:13:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002gK-2K for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:44749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXw-0006xG-OF for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: by mail-qt1-x834.google.com with SMTP id r16so10014205qtw.11 for ; Fri, 24 Sep 2021 09:59:36 -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=uNdU6ybIJfer/a+2lnb556GEnq4khU62qRteMioxBnA=; b=c6rBbSE92Bl275CCX6hCTkSHXu871oEY/WrE2Ftsa1Xk9LuMFvOtrO6hao3B7CyKMQ vEzbOrOvLBRAoSldiepRD7SWr6DYA/7a1H+93hAmw1pgQUdeIb+oyZT1B+OVWc/IIycE bfUyGaSD5BvRErSXfB4Nj5ksEm+BF9ESKHWhdJV4ZJPHJ9/0OKYUt2biIU/q+SkOEuDE 2522sgkbpORXaF2KZcgzJ0GR/xE+gtWBucbC2i8eIabCM07rLB4DyYSJzKKHAyG7tGCP JI/WSBydWGveNmjAhPkjJk2hPGwFpi5/PWEp83pjpzdqJ8FbH6bXLkFbX4J9C6sZqeIa 6nTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uNdU6ybIJfer/a+2lnb556GEnq4khU62qRteMioxBnA=; b=xwNvtkJnYVT0DaKfooqlpxs+Setg58x2K4NSJDM27YGgkMrtYYo+Sy8aoqHzcoPkGF wmqNib1XOJBjYML8lJDimW7jiuAVEfD72ILD/KuNVHI2mRJAWlmDVjT4z8LeWWYV0CEG pjmgwOCME3go91cGGgbNtFrjlmKFdcK12qpdbrb1xuinzTNVFeafYTa1xNGrjYPRivpf GiOrxcGn53N8prVlgxxn0KPnXEJWmJmwTugmQxENj83x3QEHzeqJfXYBXG8YQHezbX48 PveHMadMwZwlGdp9TJNSyTKi7e90VM+T/T5/TlIu7NmL/MnsYXJiQ8gBGFS2JoxUdAVX 3WIg== X-Gm-Message-State: AOAM533S8u32330FGRKuvqZTT4EwJEUMQTgPK+qHlcwFMgQhv0IKnnUc JzGHbwMAmSNns9/OXnKhfSx+SneYn4LGZQ== X-Received: by 2002:a05:622a:11ce:: with SMTP id n14mr5291983qtk.374.1632502775487; Fri, 24 Sep 2021 09:59:35 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/27] linux-user/i386: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:09 -0400 Message-Id: <20210924165926.752809-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x834.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Note that x86_64 does not use this code. Signed-off-by: Richard Henderson --- linux-user/i386/target_signal.h | 2 ++ linux-user/x86_64/target_signal.h | 3 ++ linux-user/i386/signal.c | 56 +++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 18 deletions(-) -- 2.25.1 diff --git a/linux-user/i386/target_signal.h b/linux-user/i386/target_signal.h index 50361af874..64d09f2e75 100644 --- a/linux-user/i386/target_signal.h +++ b/linux-user/i386/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* I386_TARGET_SIGNAL_H */ diff --git a/linux-user/x86_64/target_signal.h b/linux-user/x86_64/target_signal.h index 4ea74f20dd..4673c5a886 100644 --- a/linux-user/x86_64/target_signal.h +++ b/linux-user/x86_64/target_signal.h @@ -21,4 +21,7 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +/* For x86_64, use of SA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 + #endif /* X86_64_TARGET_SIGNAL_H */ diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 3b4b55fc0a..94ab6396a0 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -310,6 +310,22 @@ get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t frame_size) } #ifndef TARGET_X86_64 +static void install_sigtramp(void *tramp) +{ + /* This is popl %eax ; movl $syscall,%eax ; int $0x80 */ + __put_user(0xb858, (uint16_t *)(tramp + 0)); + __put_user(TARGET_NR_sigreturn, (int *)(tramp + 2)); + __put_user(0x80cd, (uint16_t *)(tramp + 6)); +} + +static void install_rt_sigtramp(void *tramp) +{ + /* This is movl $syscall,%eax ; int $0x80 */ + __put_user(0xb8, (char *)(tramp + 0)); + __put_user(TARGET_NR_rt_sigreturn, (int *)(tramp + 1)); + __put_user(0x80cd, (uint16_t *)(tramp + 5)); +} + /* compare linux/arch/i386/kernel/signal.c:setup_frame() */ void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUX86State *env) @@ -338,16 +354,9 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { - uint16_t val16; - abi_ulong retcode_addr; - retcode_addr = frame_addr + offsetof(struct sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - /* This is popl %eax ; movl $,%eax ; int $0x80 */ - val16 = 0xb858; - __put_user(val16, (uint16_t *)(frame->retcode+0)); - __put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+6)); + /* This is no longer used, but is retained for ABI compatibility. */ + install_sigtramp(frame->retcode); + __put_user(default_sigreturn, &frame->pretcode); } /* Set up registers for signal handler */ @@ -416,14 +425,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { - uint16_t val16; - addr = frame_addr + offsetof(struct rt_sigframe, retcode); - __put_user(addr, &frame->pretcode); - /* This is movl $,%eax ; int $0x80 */ - __put_user(0xb8, (char *)(frame->retcode+0)); - __put_user(TARGET_NR_rt_sigreturn, (int *)(frame->retcode+1)); - val16 = 0x80cd; - __put_user(val16, (uint16_t *)(frame->retcode+5)); + /* This is no longer used, but is retained for ABI compatibility. */ + install_rt_sigtramp(frame->retcode); + __put_user(default_rt_sigreturn, &frame->pretcode); } #else /* XXX: Would be slightly better to return -EFAULT here if test fails @@ -592,3 +596,19 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +#ifndef TARGET_X86_64 +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp); + + default_rt_sigreturn = sigtramp_page + 8; + install_rt_sigtramp(tramp + 8); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} +#endif From patchwork Fri Sep 24 16:59:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514594 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1683938jao; Fri, 24 Sep 2021 10:10:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpqZfT/5LxdweP7fVZydtBtXqTszShHD5OqZCQ9vZVLcVvYg39GLM41gDDmmvvwGOEUl9Y X-Received: by 2002:ab0:73d7:: with SMTP id m23mr10690977uaq.118.1632503448119; Fri, 24 Sep 2021 10:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503448; cv=none; d=google.com; s=arc-20160816; b=rXIVFry8Vx0gtNm+d+JljqkFQ5ew5FpC+OG2ZVZl6996/pL7hMjDv+78sykLJ7StDb o+UmBQt3CfPETUYu1oBwZ80pFzVJ0Rm1K6aIGaWX5gN1MoM78oy1PvmSq4x4IggnfygK LOFZnVJ4xFWhDmm+aKLCdtnuPC8f5vuOFBlit9jb4awxIhaK44HBlwWUxnFTwro0A4TU VzyrQifd08S//ynjZn2322u5C+c1wWo2XBMbpuO+U8VoS6HO2aFWgSr7/XbQj7A64XSe 2Tr88m89X80K96bk8w+gNmaj+IusmomTw7vEh841rN2KLjXMMvfe7Y7WrAsosFrO1HEs gr3w== 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=ULwFc4fsoMDCKBA2xVTYfXV3nCZVlLyz/guJ8iaI5Rw=; b=Wdjnu1+I43Tf5QThCQ+F0vRp4e3MuRyLc5Wci4KdDs3Lvfwt3spvqQ8JYJ9bAuMWUt LH8w6/HVeUMSDcuI38PGSNDYFCVUqpl3W5BRvc/PVKgAXnNDD1sobWdOoCrYjZPUnTKW ux9GqG4tzd2t2oGMi2gZuuw7x9Tq7Uf7W8Nbx0INLB04oa8NeEsiLaCJOD2lJxoBpqtJ yVItHgWVTAUtgLTWOkl+Vkf29UaxlywiyX3PF/cLgQz5SwF8aRzpb2C8cEtBYH+vEsvb fbWzYwNlurDc12lrbQU+BnQIxaMDgcWquZgyotW4IkQBJsWavA+rJvEl3R1QnDUcGLwH Q4/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KNu6QFb8; 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 j21si6210885vsf.266.2021.09.24.10.10.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:10: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=KNu6QFb8; 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]:52818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToil-0003mS-J6 for patch@linaro.org; Fri, 24 Sep 2021 13:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY2-0002fO-1f for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:46693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXx-0006yT-1b for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:40 -0400 Received: by mail-qk1-x735.google.com with SMTP id b65so28387706qkc.13 for ; Fri, 24 Sep 2021 09:59:36 -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=ULwFc4fsoMDCKBA2xVTYfXV3nCZVlLyz/guJ8iaI5Rw=; b=KNu6QFb8ex3Ct5FPynmI5DxsbDncOGuIO75EcbmuBF3jbNt79pVcljFkepUYRi89rO T5UMNy6uW5nTrHuYDBMgZwrmoISGPZe6kiQp0xy5LF+HWtCCMT7DOJ4sguKFJWpljxhM 2KXBSdTH8kL/7VW3XeldCmoAwG29i1N8Vbrho6GOYbxHe2olKfoaMEDUBza1wZp2ucAS 8XGJIWh8Ii1Ku5gYSPjPDFJ0m/nodFfUTk1yDhJmgXanietodh1iFKYYpN2TCA9QklAl GlStyjvcnxJ/rbHv3+WQM7R56QBOsiWnfZ5w0wcMfpNgyApkeK4AmsKV23ZjsC1BmMS5 YOOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ULwFc4fsoMDCKBA2xVTYfXV3nCZVlLyz/guJ8iaI5Rw=; b=GEFIOWiOK8W+UIZSB1YY2J+FSiDoyCNqho+HYaisMdfddBSbzgm4/URA8bT82C5zUc cF5+qvgu00iwoSGQRHYwNrOg6YTjjgMCnWzs24OxM9w8MicRoXkQPYyVj1hPjceRiIUa c4thMS8e8Oc0bmheDvm7khU5Iw5U+2Zeu2XmyJQIDpusY2G6Zrr4d6ZER8e7bc+UnwRs HlQOQFbByCpxt7cLN5aw2Ro98NCFZqidUI+67ZLdTOX+03uhe0S+e95DSGh7JMV517LP K/T9RALuWxudBZ+x7wMrRGcBfiWA3NBfYiMEMsJ7W0pGqCWe3EI8ORiltoY+KPP924cU ybuA== X-Gm-Message-State: AOAM532jTHIdIcEiHcLOPmpXiAmJmhjYSRA6FPaLIp08kcKBu6py2r2x vyrI+U4ANPoFYf1K00JDayNCERhgq5UCMg== X-Received: by 2002:a37:b703:: with SMTP id h3mr11870358qkf.240.1632502776173; Fri, 24 Sep 2021 09:59:36 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/27] linux-user/x86_64: Raise SIGSEGV if SA_RESTORER not set Date: Fri, 24 Sep 2021 12:59:10 -0400 Message-Id: <20210924165926.752809-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This has been a fixme for some time. The effect of returning -EFAULT from the kernel code is to raise SIGSEGV. Signed-off-by: Richard Henderson --- linux-user/i386/signal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 94ab6396a0..55a36476d1 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -421,19 +421,18 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ -#ifndef TARGET_X86_64 if (ka->sa_flags & TARGET_SA_RESTORER) { __put_user(ka->sa_restorer, &frame->pretcode); } else { +#ifdef TARGET_X86_64 + /* For x86_64, SA_RESTORER is required ABI. */ + goto give_sigsegv; +#else /* This is no longer used, but is retained for ABI compatibility. */ install_rt_sigtramp(frame->retcode); __put_user(default_rt_sigreturn, &frame->pretcode); - } -#else - /* XXX: Would be slightly better to return -EFAULT here if test fails - assert(ka->sa_flags & TARGET_SA_RESTORER); */ - __put_user(ka->sa_restorer, &frame->pretcode); #endif + } /* Set up registers for signal handler */ env->regs[R_ESP] = frame_addr; From patchwork Fri Sep 24 16:59:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514588 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1677040jao; Fri, 24 Sep 2021 10:04:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3yCmOVdiPkDTz97qvBx07QEHFWF+2F2iQznIhmpwYHwWWy1qJIWW3HhHV40d7QS+LHSJZ X-Received: by 2002:ac8:151:: with SMTP id f17mr1477808qtg.313.1632503079271; Fri, 24 Sep 2021 10:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503079; cv=none; d=google.com; s=arc-20160816; b=rRf7XcxgqMfYRHQwWoXn9JXTZkkiniF+Qrmz4zpMd2SGRw1tvDXxLkoeTOsRTjh7f6 T+PlLHoxQckmhXLBB3dB5qOenhIXwkzFGfERfDFk4a5YmknV8yJShTaRDR90baSO0e8L EfXZ3a7Jqx9CQsfrE+tTtnMUda03btFpz3xglMnJRfKRmwbzvsgZeedz2iVq22thFQzF KmWn0EQ+aMv+WOBlZqZhNnqUjP5zDoPGBVsmBV3jQsM5C4l4ho8Uc0jukezg78CQGQPf /92SC+sB3AhNoNttuanx78ViXCDhagenyxjeCLgYhHqwsGTrll1to6FHSnsibKB73Z5H ZEkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=xAfd1jv3RRYDF8kxagPLTl8H2e9QYgMY3h1n7is5LtGLc68BTPgPXI0Kshf9pY39rQ AGN8cXAjO4qnwNN9ecXjSNH5lmbjBvRul6h98oMisTOf5DcGoHHbnoAHlhbEkkFFO7HJ ZRhcb0QiqaF+xHTUXcIqI521iZst35gHAQL0K6Iz9NBClOIjaNIbgsOpREr/Xag9n5Mo V/LlPs1aDCo1wFnRI6xAswAMF818DhY5cGKjKOdsY5Koja3UepQ5YTka9vvYhuFzGLdb lrZwhwY07nVZA+0sMVxIBGaFTPG13lcytdaQ6KTSxSzqanaJmWwZel39vjxKVSnxjkzD 7V2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dISEU4PH; 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 q3si5705185qvd.48.2021.09.24.10.04.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:04:39 -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=dISEU4PH; 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]:35788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToco-0000iJ-LF for patch@linaro.org; Fri, 24 Sep 2021 13:04:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002g7-Uu for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:33763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXy-0006yk-5O for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: by mail-qk1-x72d.google.com with SMTP id d207so29102448qkg.0 for ; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=dISEU4PH/27FdDhhEsf1d0QKp+BVBsRGrWbc3P7OWRVlryT8cR5Omcl6DCRfebKmVj NL1UJin65msHDdhmyGVFQRqHVcLqvydNF/pR9BYZaC/P7VdyhfViWPdnnfR+BBBs8VbQ yb6/3bKx2Frk/f+b7jd4yFDhdI1+7vECVls1ChFvfPvHY01+QlhHvFOBLvbW6NbE4bT0 7cZxHP6p8ThR1+knIxiDx5yL3XG4GlZYcproKjGSzqk9gQAzLuYKD+z5cVEZqIzJlRYe N2uTocIJPjP+kBkX759yS6K7bl8qzkj+rGS4/0QMSoTCB/Cgr4PKBoDVaZIOSt3pEQtg i4aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UICQteUsiyVZ78cpdv1J4mwbKpxziCK3H4LazUFdv1A=; b=pFiSt0Fbfbp6yvehJMot6YE/FzgSk8P1uebQr2HPJ6W3jZcg4iD33ylOQJS5FCaBIq EcXH7UoAWKrYxIzUehVGSViQ+br8VqDy+iunxEoykbtEroIAzAVihDC89AYcO2wgnnDo thEpaqhl/yNcjcmP/u2G6MtcFOswmDwSyCXVb6hbMpDFlb3LiJ8CQnWRdcmAWZCjXce9 yAy+FW+/egkWZ1OPoP6nyMwnC+05yqxGiOD1aPOjiOcCdFKkJGc+nARHRUjyEJzqqu73 4umLPhRtLGfH54ifYHSiYGqxa1M77czJmU5Qn5yHTmONI7jlBiBvbX4tU1ZpqS6JinFU SlBA== X-Gm-Message-State: AOAM530bIIv7QVfSeJ5gm1ct6AJCkrfezreq7tjAy43jTrlPAJ+AitxM nTfuU377l9DWFnInVltcc7Us8yBdr76W6Q== X-Received: by 2002:a37:a495:: with SMTP id n143mr11406693qke.339.1632502777017; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/27] linux-user/m68k: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:11 -0400 Message-Id: <20210924165926.752809-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/m68k/target_signal.h | 2 ++ linux-user/m68k/signal.c | 47 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) -- 2.25.1 diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signal.h index d096544ef8..94157bf1f4 100644 --- a/linux-user/m68k/target_signal.h +++ b/linux-user/m68k/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* M68K_TARGET_SIGNAL_H */ diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c index 4f8eb6f727..ec33482e14 100644 --- a/linux-user/m68k/signal.c +++ b/linux-user/m68k/signal.c @@ -39,7 +39,6 @@ struct target_sigframe int sig; int code; abi_ulong psc; - char retcode[8]; abi_ulong extramask[TARGET_NSIG_WORDS-1]; struct target_sigcontext sc; }; @@ -76,7 +75,6 @@ struct target_rt_sigframe int sig; abi_ulong pinfo; abi_ulong puc; - char retcode[8]; struct target_siginfo info; struct target_ucontext uc; }; @@ -130,7 +128,6 @@ void setup_frame(int sig, struct target_sigaction *ka, { struct target_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong sc_addr; int i; @@ -152,16 +149,7 @@ void setup_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; trap #0 */ - - __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), - (uint32_t *)(frame->retcode)); - - /* Set up to return from userspace */ + __put_user(default_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -288,7 +276,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { struct target_rt_sigframe *frame; abi_ulong frame_addr; - abi_ulong retcode_addr; abi_ulong info_addr; abi_ulong uc_addr; int err = 0; @@ -325,17 +312,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, } /* Set up to return from userspace. */ - - retcode_addr = frame_addr + offsetof(struct target_sigframe, retcode); - __put_user(retcode_addr, &frame->pretcode); - - /* moveq #,d0; notb d0; trap #0 */ - - __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), - (uint32_t *)(frame->retcode + 0)); - __put_user(0x4e40, (uint16_t *)(frame->retcode + 4)); - - /* Set up to return from userspace */ + __put_user(default_rt_sigreturn, &frame->pretcode); env->aregs[7] = frame_addr; env->pc = ka->_sa_handler; @@ -411,3 +388,23 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + void *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 4 + 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + + /* moveq #,d0; trap #0 */ + __put_user(0x70004e40 + (TARGET_NR_sigreturn << 16), (uint32_t *)tramp); + + default_rt_sigreturn = sigtramp_page + 4; + + /* moveq #,d0; notb d0; trap #0 */ + __put_user(0x70004600 + ((TARGET_NR_rt_sigreturn ^ 0xff) << 16), + (uint32_t *)(tramp + 4)); + __put_user(0x4e40, (uint16_t *)(tramp + 8)); + + unlock_user(tramp, sigtramp_page, 4 + 6); +} From patchwork Fri Sep 24 16:59:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514591 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1681207jao; Fri, 24 Sep 2021 10:08:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzES6UR6qlmXubOyVDv/OjevONQ8FVE1QMQ+zfTfiaqpvbEr3Ivw8BU2RT0XaTmeT/Ee1qX X-Received: by 2002:a05:620a:68c:: with SMTP id f12mr12028653qkh.363.1632503296471; Fri, 24 Sep 2021 10:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503296; cv=none; d=google.com; s=arc-20160816; b=bqLRif0+YGL43Sbmgyzr6qZ9sHC6en/zRC5nMQ4N+msfNzIjhG5jDaAKfI6at6Lpfr BEoCgEFqBs2XJkGB+1/UGmtvsZ/TFYj7zkdnb4lDvnkfzXX1DlsVKAVP5xZCMRC8miDw 0v8GhkKekc9gp5XqF9/0WcNnFtwgcFKEtaur9feB4w2dbGyBYQ19+CCRoxsM/Tnc74jb bcObPPEkx78daWiIEmKPMREC/qI+Dg8oMreTwSi4EVYGF4xhg4LV5YfjgirG4+JdB+XF kxD8aNx+dPb/GpTroVbNELAp7cdrewYpX+R07G2uPVd6AdagvTBA/ElnMFm7UXM9mGcs L1vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=YUB9L1J9fdRlIlKuQEyY6Dupo5OaFNLFaZ3/fowPn4Pb+2JYEfDwrNlBewYUbd0eq2 F7WfhO+nDbMr+DW/1vHcrRq8yCj/2PP+QdCxspJwIufwzqntjxEOkK0+uKdTsnt19eMC e2TaqllRzivCnZ6ARiOQhMx9Cjh//TMfx0w6DsNO4n/RR6I1PpAHd8o2SXJGKJ4wRDnH VUndzGoBIgt6FNb/Q4HwKMRvmh+DwR0hSmPlg3lw0CKwZm1cfjIQP3q+nGCMN8lWRmlN Xe8tfZC2g9bpYwGakRleqrdUobgc8iiIQmmeDYTBnu9+ZZE20jdMBCsAwX6dewXEqGtx X8XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zVH3lMoe; 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 p20si6205301qvl.42.2021.09.24.10.08.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:08:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zVH3lMoe; 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]:44258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTogJ-0006SL-Vb for patch@linaro.org; Fri, 24 Sep 2021 13:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY2-0002fi-J1 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:43 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:37455) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXy-0006zQ-LN for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:42 -0400 Received: by mail-qk1-x730.google.com with SMTP id 73so28870149qki.4 for ; Fri, 24 Sep 2021 09:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=zVH3lMoenLl4YiqnnqqgeZ7ttEm0hnZOlGueNBSeUaAjjJXy21eC9UAhtAf87totyx x0Bbn7cBm+VJzCDMbmOaW9IgG9AwV0Z8jTCZoGZS3ue0kl66al9NtKIbrAhVuBr+WRCP KHmSlRgeO3K7KYaWzUsiMEl3EtHECSG8cDd7Pgi0ubUhkEWheb+9Figdzi4qNMEA750o 7oa1scl0OEEBMdyX8IClI75CE8onpSJfS/P7xi5d8pmPyoKyWtgUi70w26vdJpQOyz/I ITvF0BZhPLRiMXAqQxu2QcW4guD02UtS4GVKIP4Fn5QOxyD8Rjjn2wvlHqNUOM8/Em1t UjLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OeHNvhPeuZfmulgUe9ozzImEdGk/YkGYzR1u2KyMGGs=; b=4XYRImmUTxNHlg2oS/H66cCntdHzOD6PjMj/LzKgUYpyY4Wwg5VeXFZzIWXXiu2dyF kAvdstQ7S7aTEozjRPjVd1CZHxBFp+M0DsBuST7ahOLRnTL/VnZHrpe3aroIdx2RmM0d L06Oji5FFWSiMomSgZG2y3tHteN9Ozh/EMitSfY7HyGknWco7cN3Y1C534jXR9+nh/UR grp8qhFE9+PyfhfY+p2vZzCiN9GiS7vAOLMpxz4t6D9USTZc7DtduSy3lElx7az1ndtJ GG6um7I7uQApDquwfUa6yl3O1HYccSt1+6/50XerqOcOP6E9konmviV5eAFliMQEtsF1 ck2A== X-Gm-Message-State: AOAM530NspMks1JBb4bIMdYr+Me3iXnEcyc4bIp1BpMH0iEw60A0xZsf YsIF64VCxDb2NQ8AkhldbEQvtHh8sG4Prw== X-Received: by 2002:a37:c83:: with SMTP id 125mr12073152qkm.229.1632502777804; Fri, 24 Sep 2021 09:59:37 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/27] linux-user/microblaze: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:12 -0400 Message-Id: <20210924165926.752809-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , laurent@vivier.eu, "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Cc: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/microblaze/target_signal.h | 2 ++ linux-user/microblaze/signal.c | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/linux-user/microblaze/target_signal.h b/linux-user/microblaze/target_signal.h index 1c326296de..e8b510f6b1 100644 --- a/linux-user/microblaze/target_signal.h +++ b/linux-user/microblaze/target_signal.h @@ -21,4 +21,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* MICROBLAZE_TARGET_SIGNAL_H */ diff --git a/linux-user/microblaze/signal.c b/linux-user/microblaze/signal.c index b822679d18..8ebb6a1b7d 100644 --- a/linux-user/microblaze/signal.c +++ b/linux-user/microblaze/signal.c @@ -161,17 +161,11 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Kernel does not use SA_RESTORER. */ - /* addi r12, r0, __NR_sigreturn */ - __put_user(0x31800000U | TARGET_NR_rt_sigreturn, frame->tramp + 0); - /* brki r14, 0x8 */ - __put_user(0xb9cc0008U, frame->tramp + 1); - /* * Return from sighandler will jump to the tramp. * Negative 8 offset because return is rtsd r15, 8 */ - env->regs[15] = - frame_addr + offsetof(struct target_rt_sigframe, tramp) - 8; + env->regs[15] = default_rt_sigreturn - 8; /* Set up registers for signal handler */ env->regs[1] = frame_addr; @@ -220,3 +214,19 @@ long do_rt_sigreturn(CPUMBState *env) force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* + * addi r12, r0, __NR_rt_sigreturn + * brki r14, 0x8 + */ + __put_user(0x31800000U | TARGET_NR_rt_sigreturn, tramp); + __put_user(0xb9cc0008U, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Fri Sep 24 16:59:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514602 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1689428jao; Fri, 24 Sep 2021 10:16:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3qtAWRLDRnEi8gWIo8TvM0Xgk7nkKVrcfoeS5jvxtOqJikxbg9rtkquvE+3v7P1uJ+A4m X-Received: by 2002:a37:ae81:: with SMTP id x123mr11889934qke.498.1632503787373; Fri, 24 Sep 2021 10:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503787; cv=none; d=google.com; s=arc-20160816; b=rsSP/DGHjbE7ZvHVUskbEcNq9x4vaGL/2pD73Tmvk+AUycEPEGfC730xkPMK/lVYVl fi3zy7rkKX+UwIiZS8QrYV/Wy/LYinfvuVblonBE4Ecl5UnqZteraXTciiFjqQPtrmz/ 5BQy8H3mxvb9ToA1cAOtqs+zLxK67PhgcuOtkrBCvb7HKE2wizyJxtWQuh+8WwnW7ZYM 3mbB3Bx/fY6N29hS7xHoDdyc2HS6B3xMHP41LuufrmW+1WbbViVia8+1m2StlssnZaCK xnmysk8k65izobYeMC23GD2aoMQneM+caSUdU2yNhun6u5VNeLH2t77x7JViR6FFKPeh yhhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=i1VCtQGj2ibIqLBzX6CvQVQK76RnqzFYmrDV96jVWdyqCoZP7Ntt+0vqvm4m6g6bnZ iwvs2rlH2E7lqvTQ+vMmx1q9FJGzUU/bFFLsUrOP2nndYK0ARvP/UcEQ4IlnF8RDUFvY 2oFsOipQJ/WdOKbF+bP3PDOmj1mnCCdJssoqc+XTRDgZ0hDssoakEG6uJxQSc5TXQD58 csF1lD6nrCwXNDrnc1QL8g63k2YO/2npfi5J4CAuz35vAVdd9iD5Qu5Yj+0tz2FlPaqv fz44b5olNNJuQELrahxDL0X36iKxTJ3GM/3LvfD5luos9MJUGJcPFywPwx9UyWwtfotf ickQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vM90U61z; 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 h7si5854230qvh.166.2021.09.24.10.16.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:16:27 -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=vM90U61z; 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]:41534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTooE-0006ee-Q1 for patch@linaro.org; Fri, 24 Sep 2021 13:16:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002lP-CB for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:46683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToXz-0006zu-Pv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:45 -0400 Received: by mail-qk1-x72a.google.com with SMTP id b65so28387831qkc.13 for ; Fri, 24 Sep 2021 09:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=vM90U61z9hv+oDAyRUPgTyDwsHvXpznhYBmtvW5yH+XsViEzxYZsj536RuJyNbWYl/ ods1E4qeFHIJtFTo/G16OA7A7SZBdhpAzbpKbd3VdexDhrNhTHYObaiGcifYJBfdj0NP Om0Zo2Nk5iUUoyfYEoDRO/Po6G1Qsp3i6QdPZyE8FeER6o3RGu+AyTP/0R6t8JhKGGtF EExfsOVAPx+OInb8rCUPpNwyo8qOou6nX0grkkFzREXBjlMeVPSDHwuyqq25CFay96b1 63+GtoTTz1jqRZg9fg/iZIQEavbLQwRFDBIr3vmNiLYDf3s4UCxSSEqVRII6Gg7dF8H0 dKWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kxfPZ7H57dcm7rNQ+f9pWEPpiqUmhBqRaotBBFRVjb0=; b=kKvR0dQQaU7Efrd4B/S7BIFbeq7zInj0aIZDRhQPGbKgPrOYs0B9BTDLe9nRZ/PgGL KvHxH+sXLCakFarWwcYGxC3J8ZdvQgFM22Lv2k1IbARlvNIrGz4qtWMfYuacPoX80pF3 elcwPieM2cuZeDVOHL9UcVnY0EXKKvajgLgyOOfDN1DfFMBVC9Xh+OXoXY26KG30Y9cN n6XaEpPqt+0jPKkSF5XG0/Z+LabpvLlMTNRq/6qhZhk8oTJi8PJBGgEiOnvha20sMqUv Wec2+t/EVytIPdqo+ioUxBioiTsR9rQWa+T14nDBBJ1vGUBmOaISbnbbYr0cDVSdy6u8 K0Uw== X-Gm-Message-State: AOAM533VDkIRAFwwEHUGHBqlVNVrNnH4+0vmapjr6jYu/XUr9Jw/B5So DIzDTvhPpPmG4isQWzjRzchyzA7daIMTqw== X-Received: by 2002:a37:a904:: with SMTP id s4mr1620915qke.60.1632502778459; Fri, 24 Sep 2021 09:59:38 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/27] linux-user/mips: Tidy install_sigtramp Date: Fri, 24 Sep 2021 12:59:13 -0400 Message-Id: <20210924165926.752809-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The return value is constant 0, and unused as well -- change to void. Drop inline marker. Change tramp type to uint32_t* for clarity. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/mips/signal.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.25.1 diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index d174b3453c..64072779b9 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -87,10 +87,8 @@ struct target_rt_sigframe { }; /* Install trampoline to jump back from signal handler */ -static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) +static void install_sigtramp(uint32_t *tramp, unsigned int syscall) { - int err = 0; - /* * Set up the return code ... * @@ -100,7 +98,6 @@ static inline int install_sigtramp(unsigned int *tramp, unsigned int syscall) __put_user(0x24020000 + syscall, tramp + 0); __put_user(0x0000000c , tramp + 1); - return err; } static inline void setup_sigcontext(CPUMIPSState *regs, From patchwork Fri Sep 24 16:59:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514603 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1689432jao; Fri, 24 Sep 2021 10:16:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu3AORuIBJM2dD9jGgn3k2HMFF9emj4eqsKibjSLesCVTU3ot3JIq0kVp+Vg1TUZOeTny1 X-Received: by 2002:a37:634c:: with SMTP id x73mr11250061qkb.120.1632503787830; Fri, 24 Sep 2021 10:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503787; cv=none; d=google.com; s=arc-20160816; b=CLe6oO2VTiXWysfr+Yu0xQU1TZm4qYDX61cRtdd++8DyViAKlW/1/3kIx0IN3LZlfJ 8TZgPem00EgnOHFNrpyWQHVXv0YaDMOIIYjjtkPHSHMo+5C2LrmE3oR/oPDOjgwtDHD8 jufg/VMDvgK3eMF5Euz1f8B2z+BMGpyMqBa5TUct5T4qAXUIJv5+xU1r68Mf738fJk+m fAkpiKHala8O0og25SADcgTVVb77v+dlptnVcbibFobI4WxZzJbH278XmiOzU+yHzJY6 f+czmW7J5tJlz1v6JaA4GqiAcBrz506z90gxl0vH0jpTXCa2eH6ilFk5a2G9Gt0Lmlng hwBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=ihuxDtylU32BeOUjAG7RfsCXJ+dC28GSVN8ABYNzu6Y2dpGQi3Z2c3sUikJ+U4dSFI 8ncbJYNKc3ytnh1HObu8Nl4lemMBUo8xjGPPaWC1UA6exbWviEKvKEcz1yGPVsu3w/T1 IlyyCqyjJPFizk6owrYC60AjsMtOE78HRkn06UrF8aYk1qN5VFW4TbUqxTBl2ZqPBVuU FGvFv8ElHwLGfJLWnFC56qWLDND+ehIOKShLa7wWbMpOACDLoP7CM1GakXt4hWc+nHFr sywFUIwz4ktLvSHi9D9B+EvLhOScpWOPWoBEtNIHgXrfE58GvORUGHrwRRwX1EiityZ3 r2ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZSoWJQ6i; 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 bi19si159914qkb.358.2021.09.24.10.16.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:16:27 -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=ZSoWJQ6i; 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]:41688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTooF-0006mi-Bi for patch@linaro.org; Fri, 24 Sep 2021 13:16:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002hT-8K for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:34376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY1-00071A-RZ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: by mail-qt1-x829.google.com with SMTP id 2so10095821qtw.1 for ; Fri, 24 Sep 2021 09:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=ZSoWJQ6iTMEkoSktMtaIQuTX41EcJ9GIq6ilGSxW5bucuCGbYejCOmEdCdxb/VzQSy pGO+OAMkFhZPTa5/S3EC/zjsLVi4+QWp7dFhkGXfa4CdTcfn5wRKcgviKQcpfFr/JBcx weOisHw04m1KU4GjgrpNN9dYnSgYtuZHUqtHLsYfXJgPQkPenEwve/Jfek3CL/qtJ1uB hJAt3Fq+O9mZufP6M/egdTdUGWtjyUd98tfayzeMGG7gdXFX82mOzAByd/7xjqgY4ROp SXs48lilT+YcG3L734Lkjd3cf5vBqyumPsZ9Z1vk+TCJRthsLB3GKe1jSHZFkf62ocNm Xs0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+2oTGkDFDH981BJQF84oTMrfB4/Msl13jtU0KS59bkI=; b=nEIYUDTxzMtmy9WHJNGDoBGDlQ3evlWff3GGIqP1yahBDVakMrB2KrM+dkPTYKFWAB HTLTHURiH7IWda+sbjzn5WBcWoSoRyNVwF4bishmo6Pl2R0yOE+1lyI9m3+yBy8LyUu+ V6YiKpJ4YUdFNU1MVo5VYQF8TTSOOwhBtleyWmBD0/RjG55USMnBVkCHnfE0EkdN7xh6 pE67+J3if9IgIGJ32SqrQ72+TNV5cbGdkkVnwRb6rPrfd9vb6+CQtO4CZKE9A2HlP/4f SPe3Wlylc971gw8kaLP/R7iarMKPuK51j1uP7pZmHw5szBOMuNq3nsjJ2jiUYWENwo6j xICg== X-Gm-Message-State: AOAM533fR3lzqzlIR44NCIFOq3y5Gc7WFsqaJNYx47m8FrK7YdEd0Uv/ cGK67Zo9Am2Rs1ckxBfCskSW3t5ilQaAlA== X-Received: by 2002:ac8:71d1:: with SMTP id i17mr5231103qtp.210.1632502779205; Fri, 24 Sep 2021 09:59:39 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/27] linux-user/mips: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:14 -0400 Message-Id: <20210924165926.752809-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x829.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/mips/target_signal.h | 1 + linux-user/mips64/target_signal.h | 2 ++ linux-user/mips/signal.c | 34 ++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) -- 2.25.1 diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signal.h index d521765f6b..780a4ddf29 100644 --- a/linux-user/mips/target_signal.h +++ b/linux-user/mips/target_signal.h @@ -73,6 +73,7 @@ typedef struct target_sigaltstack { /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/mips64/target_signal.h b/linux-user/mips64/target_signal.h index d857c55e4c..275e9b7f9a 100644 --- a/linux-user/mips64/target_signal.h +++ b/linux-user/mips64/target_signal.h @@ -76,4 +76,6 @@ typedef struct target_sigaltstack { /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ #define TARGET_ARCH_HAS_SETUP_FRAME #endif +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* MIPS64_TARGET_SIGNAL_H */ diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index 64072779b9..8f79e405ec 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -209,8 +209,6 @@ void setup_frame(int sig, struct target_sigaction * ka, goto give_sigsegv; } - install_sigtramp(frame->sf_code, TARGET_NR_sigreturn); - setup_sigcontext(regs, &frame->sf_sc); for(i = 0; i < TARGET_NSIG_WORDS; i++) { @@ -231,7 +229,7 @@ void setup_frame(int sig, struct target_sigaction * ka, regs->active_tc.gpr[ 5] = 0; regs->active_tc.gpr[ 6] = frame_addr + offsetof(struct sigframe, sf_sc); regs->active_tc.gpr[29] = frame_addr; - regs->active_tc.gpr[31] = frame_addr + offsetof(struct sigframe, sf_code); + regs->active_tc.gpr[31] = default_sigreturn; /* The original kernel code sets CP0_EPC to the handler * since it returns to userland using eret * we cannot do this here, and we must set PC directly */ @@ -305,8 +303,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - install_sigtramp(frame->rs_code, TARGET_NR_rt_sigreturn); - tswap_siginfo(&frame->rs_info, info); __put_user(0, &frame->rs_uc.tuc_flags); @@ -335,11 +331,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->active_tc.gpr[ 6] = frame_addr + offsetof(struct target_rt_sigframe, rs_uc); env->active_tc.gpr[29] = frame_addr; - env->active_tc.gpr[31] = frame_addr - + offsetof(struct target_rt_sigframe, rs_code); - /* The original kernel code sets CP0_EPC to the handler - * since it returns to userland using eret - * we cannot do this here, and we must set PC directly */ + env->active_tc.gpr[31] = default_rt_sigreturn; + + /* + * The original kernel code sets CP0_EPC to the handler + * since it returns to userland using eret + * we cannot do this here, and we must set PC directly + */ env->active_tc.PC = env->active_tc.gpr[25] = ka->_sa_handler; mips_set_hflags_isa_mode_from_pc(env); unlock_user_struct(frame, frame_addr, 1); @@ -379,3 +377,19 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} From patchwork Fri Sep 24 16:59:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514584 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1673700jao; Fri, 24 Sep 2021 10:01:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQI87N/5BI6p9znEWmdyVV85vl6bu2nJhyuyuWAdqpzAcMTYT5YukRb/p90HaYGOiSjx47 X-Received: by 2002:a37:ab15:: with SMTP id u21mr11605543qke.394.1632502889299; Fri, 24 Sep 2021 10:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632502889; cv=none; d=google.com; s=arc-20160816; b=OkoFaexxGjl+yYBBNLp8vrMIoB18Ln09Szgd7gvpgZJsBFIXQtaH2JQh1gmHyvE7PF YuWcNHaCwH/vAebll1abRSdca4hNJhxiLfY+fdLWaPbgqTEbmqzZ1aELgK65trQWtG/M XQQasdbr131n4N9VviaKK3bmxhhVNCiQvsRJH2CIlvMUEjTO/LWEx55MLmQ932Ty+3wG ZYEd0QcXsJcoG5q4k+yXyQVWNT5kgz5GkjXO0FSpVWMPA1G1HA+9R55OOmh6OnFGFg9W dh7FbckoIlG6NrakfT1UhfjT81wjlrZtgrcRUBkzwbeDF0N/onEJZaxwNwyqhErnbELH Di9w== 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=QyWQEo+8inM5iDruY826QX36+Q2J0PKidDJBY0ejKxk=; b=RDqRkARK+F8EDRRLB+7Ipip/Avh0svBn8l+Rg/xND17jD+CsbOR1cVBuxxaOLeNMVY uDl4nZ/BSZyVzFh8Vt91Jt3aWXqFtSIrBZmZ3+7HoRnvKsmA50sHuF8WbTBiCDPjD6vu SdkL8t4gwQEv9l+2of/YzYAwd56MfEkLkmFqpHzoQopASWXpd5Twc5S1YmttozggBOaH uR2gt6fXSfHkeEq4rjd3kbED0e3bG3KPk7CgYhIUPy42/+RC8yOJozTO90Lqo1dJPPaz WEVFCtwp2Opyam89+qtsVvAyBfCnyGCcvF4UaNmtE1ff8O8SNVcqy61DWELnreZduR+z vPJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ObdanfZr; 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 m19si5831996qkh.230.2021.09.24.10.01.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:01:29 -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=ObdanfZr; 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]:55344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToZk-0002qd-OR for patch@linaro.org; Fri, 24 Sep 2021 13:01:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY4-0002gU-TI for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:33406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY1-00071g-RY for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:44 -0400 Received: by mail-qv1-xf34.google.com with SMTP id a9so6724748qvf.0 for ; Fri, 24 Sep 2021 09:59:40 -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=QyWQEo+8inM5iDruY826QX36+Q2J0PKidDJBY0ejKxk=; b=ObdanfZr1BcgLUvvWkMdYOEO77IQ8AWjbRSBuQ9axysAmhzOLHSO/AC2bBSdrUU1Gl lExrkwmAVuiGcYDZWzXUr+qVPxytPecQhQ80w0hC+99tJ29W2XKzr/5hR6sRvxoF/8BD dvSMl467KFLfOcqUnHSeQquGxfVa4yKf0Di74reozUbBN/JvxmAb2vcfRILFYxBaiAHl r721b8jKTY6cz2hkuxlnKuEHESv/k/KCiOKHuEW5xHDpjUOLjLiBRQNktAnFA81RaJPO DqILIryYDKSIw+DmpryQyv++eZb+lVhjC3mUtMVw3XSfhuVvGBNhv9tP4vPUyrfAa90V y3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QyWQEo+8inM5iDruY826QX36+Q2J0PKidDJBY0ejKxk=; b=zp4QWqmNpJyVNgKP/pkPXnRQrSYwMjjXSmHsDieJfbmpY7ww9xy0gcFNSjZfPfe0GX 0BixiEJCclogyRPcuabJ30xY9HagyTqc+OU+xjgFQgVy4CP3HUn9OaHz2OvVxUvHaVNJ 4lCvtZ1rNWeZdoAhffm3JjqBuwArVpBnhEODsiaPRqcxny2qdcpK1wsZlbGjNX+P57EI SQLKCKkmvdEEMUhS2EDrSrFtQIgXE1IIo5HMzQUukogsYH68aX8iYgnrUDUKZfma827R O6E547TOI0whLk6J5CcT7e8nSdiKqlek2sKwuB2zJmzdhwzafZOFHVfWQSzWXXpO24G8 tssQ== X-Gm-Message-State: AOAM531CdfDbh5zSWPextFFhX+mUrhimSvZ5/8VwBwAuyEgbWzbynqoq FqfklZ+5HpR3trcKXm27erZ8gwZmnAILEg== X-Received: by 2002:a05:6214:4b4:: with SMTP id w20mr11195739qvz.20.1632502779865; Fri, 24 Sep 2021 09:59:39 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/27] linux-user/nios2: Properly emulate EXCP_TRAP Date: Fri, 24 Sep 2021 12:59:15 -0400 Message-Id: <20210924165926.752809-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The real kernel has to load the instruction and extract the imm5 field; for qemu, modify the translator to do this. The use of R_AT for this in cpu_loop was a bug. Handle the other trap numbers as per the kernel's trap_table. Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 5 +++-- linux-user/nios2/cpu_loop.c | 35 ++++++++++++++++++----------------- target/nios2/translate.c | 17 ++++++++++++++++- 3 files changed, 37 insertions(+), 20 deletions(-) -- 2.25.1 diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 2ab82fdc71..395e4d3281 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -158,9 +158,10 @@ struct Nios2CPUClass { struct CPUNios2State { uint32_t regs[NUM_CORE_REGS]; -#if !defined(CONFIG_USER_ONLY) +#ifdef CONFIG_USER_ONLY + int trap_code; +#else Nios2MMU mmu; - uint32_t irq_pending; #endif }; diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 34290fb3b5..246293a501 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -39,9 +39,10 @@ void cpu_loop(CPUNios2State *env) case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; + case EXCP_TRAP: - if (env->regs[R_AT] == 0) { - abi_long ret; + switch (env->trap_code) { + case 0: qemu_log_mask(CPU_LOG_INT, "\nSyscall\n"); ret = do_syscall(env, env->regs[2], @@ -55,26 +56,26 @@ void cpu_loop(CPUNios2State *env) env->regs[2] = abs(ret); /* Return value is 0..4096 */ - env->regs[7] = (ret > 0xfffffffffffff000ULL); - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[CR_STATUS] &= ~0x3; - env->regs[R_EA] = env->regs[R_PC] + 4; + env->regs[7] = ret > 0xfffff000u; env->regs[R_PC] += 4; break; - } else { - qemu_log_mask(CPU_LOG_INT, "\nTrap\n"); - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[CR_STATUS] &= ~0x3; - env->regs[R_EA] = env->regs[R_PC] + 4; - env->regs[R_PC] = cpu->exception_addr; - - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + case 1: + qemu_log_mask(CPU_LOG_INT, "\nTrap 1\n"); + force_sig_fault(TARGET_SIGUSR1, 0, env->regs[R_PC]); + break; + case 2: + qemu_log_mask(CPU_LOG_INT, "\nTrap 2\n"); + force_sig_fault(TARGET_SIGUSR2, 0, env->regs[R_PC]); + break; + default: + qemu_log_mask(CPU_LOG_INT, "\nTrap %d\n", env->trap_code); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, + env->regs[R_PC]); break; } + break; + case EXCP_DEBUG: info.si_signo = TARGET_SIGTRAP; info.si_errno = 0; diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 08d7ac5398..485b487665 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -636,6 +636,21 @@ static void divu(DisasContext *dc, uint32_t code, uint32_t flags) tcg_temp_free(t0); } +static void trap(DisasContext *dc, uint32_t code, uint32_t flags) +{ +#ifdef CONFIG_USER_ONLY + /* + * The imm5 field is not stored anywhere on real hw; the kernel + * has to load the insn and extract the field. But we can make + * things easier for cpu_loop if we pop this into env->trap_code. + */ + R_TYPE(instr, code); + tcg_gen_st_i32(tcg_constant_i32(instr.imm5), cpu_env, + offsetof(CPUNios2State, trap_code)); +#endif + t_gen_helper_raise_exception(dc, EXCP_TRAP); +} + static const Nios2Instruction r_type_instructions[] = { INSTRUCTION_ILLEGAL(), INSTRUCTION(eret), /* eret */ @@ -682,7 +697,7 @@ static const Nios2Instruction r_type_instructions[] = { INSTRUCTION_ILLEGAL(), INSTRUCTION_ILLEGAL(), INSTRUCTION_ILLEGAL(), - INSTRUCTION_FLG(gen_excp, EXCP_TRAP), /* trap */ + INSTRUCTION(trap), /* trap */ INSTRUCTION(wrctl), /* wrctl */ INSTRUCTION_ILLEGAL(), INSTRUCTION_FLG(gen_cmpxx, TCG_COND_LTU), /* cmpltu */ From patchwork Fri Sep 24 16:59:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514604 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1691432jao; Fri, 24 Sep 2021 10:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDBWtM7O6YGjl5DvjbeD02spW7HCgHfX13bR0o/qBxMFDEQ88SHoSdjCf3pqhs7/ym5gQD X-Received: by 2002:a05:620a:142:: with SMTP id e2mr11976494qkn.249.1632503923812; Fri, 24 Sep 2021 10:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503923; cv=none; d=google.com; s=arc-20160816; b=qeWxZwbqWkofz/StZydy5eQcrfuj8lqE9VGRVCR5T14vMGB3O4vIc8b17AL6DakcOl dIM+hqJrAaMB81KWf923iDuyT1yswXjfoje2UnL1GI8syQR/KHQ5WxakA/ctgh2u+MMn pE+FG+byZ8IIQPki6P/JkeIuHXl8/+ggGoS1cUbqbaQivsrsqghPvZn+QlxTq1c80F4H JmzjoxqtuQRajSS22RjgxqYaRzIWobkMLZAvT4tM0E7z+vU1gAjOc7HztcmVAUNi3/Ec Ap1tXKd7Gwgicjiy6qmAOsiQbytBhaT/SF/pn9iM2Yn8niWkbzAxek/gD5ZTae7dwQXa YiQg== 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=Rtqr3C3eoq1EPLIGYi3WdYYbWrj10vk/pNHEu4YGvvs=; b=rzUxCAuSJ0OH5OdgF8V2geX3eP8sEZ/ee3fRXrrUnvkTfjXsK5vNJLsr+f+EWppvwl tRRW77WZg2DOPnYEVRkMt0d+XJnvwXj6KEl1knrur46eITNfiDsz6FEfCuYNYSkDGLYW Cu0tjC1NbDf723lhhaBFDgBIO+eH90BF5pfUKcu1dZplAb1JM+HUhKCtviX1D0rc2gXD 5xHTfF7qOkA/Q8YC8bMUQTdj2+dyRnA+oJlJ/u1wjgEKHNFXQLv69lT+jdQL1G1oKrQ5 mvjvahx+d3I36BI09NLMe41OA6vK9fTrwoOOalWNQvxuD5/aXwsStBwkQ1Gg0fZAtDBW Mlvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="O3fes/8Q"; 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 o15si6762253qta.103.2021.09.24.10.18.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="O3fes/8Q"; 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]:48574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToqR-00032T-1O for patch@linaro.org; Fri, 24 Sep 2021 13:18:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYF-0003Dl-Ms for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:55 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:46692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY1-00071o-SJ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:55 -0400 Received: by mail-qk1-x733.google.com with SMTP id b65so28387972qkc.13 for ; Fri, 24 Sep 2021 09:59:41 -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=Rtqr3C3eoq1EPLIGYi3WdYYbWrj10vk/pNHEu4YGvvs=; b=O3fes/8Q7RRsJoVUb03lXxWyPddHN3I9YTFoax+0QZ9uukwbsRVhrrL1p6VYrzBt3o 4NH2DgYJKb5PskLkwoSwFBs3xe85sz4+WTUTzrNgNKHUG0PI81Vu+7I25lzmIVBSkgYX wBr+4sKr3L4KmfZwCri8CTkTkOAzYac73pEOGyvGURgMHIjqR1IrZJZMLruSA5+PTNoq dwNTONQ88++CMDb8DYNhfplT6iiQqTthogSA+bCwIe3X0Ivz1Dt12HZl/+IHNEy0245Y nR5Jh93G3s6c+mpmsynq18bXXRkmCHsvW1j+Kl8Rk+AtC1FtV3AaohRrBkJ8EGQj+7wy ozFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rtqr3C3eoq1EPLIGYi3WdYYbWrj10vk/pNHEu4YGvvs=; b=ardQLA0RBASy8Cqol1VI9Y1DFwL/A/qetc+cLIY5kR9JlQudRwwjWKtAnjG9e50+db K+b2TKcxmHK3gCyNl8su2QFEd+lS1I6IkdnQ8Q1ByZ9RBsFc3xLwYCv39E8ZXy1+Tekn sMD5rF4d6ifjd8xSguQ1Ty3paRMkgXKQn5DUopMaySeu5vCK9uS8XwEmXSN9rzV6/E94 +WcFsRtrQug+ZIhVu0MQiRne7eferNQi0fZlreE/QJmzlRhGlcsS8TlNu+XMZmFM9M+F fYodmOaxrM6ypaT2yLxIGkH6193vggjCz1pQQ9CcN6EyQ4gr3tnkrdjJd7Jmo0TOUDd5 tsNA== X-Gm-Message-State: AOAM532Kd4cGDBg2582YUaEveGfx4V2aIjZ7EGTlpwP2GI96p2jsfuEh jGSGU8h0a8u1oJsA8Mq+9sJy0N9AVPkY1Q== X-Received: by 2002:a37:a548:: with SMTP id o69mr11577288qke.9.1632502780911; Fri, 24 Sep 2021 09:59:40 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 17/27] linux-user/nios2: Map a real kuser page Date: Fri, 24 Sep 2021 12:59:16 -0400 Message-Id: <20210924165926.752809-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The first word of page1 is data, so the whole thing can't be implemented with emulation of addresses. Hijack trap number 31 to implement cmpxchg. Set default_rt_sigreturn based on the kuser page. Signed-off-by: Richard Henderson --- linux-user/nios2/target_signal.h | 3 ++ linux-user/elfload.c | 35 ++++++++++++++++++++++ linux-user/nios2/cpu_loop.c | 51 +++++++++++++++++--------------- linux-user/nios2/signal.c | 2 +- target/nios2/translate.c | 9 ------ 5 files changed, 66 insertions(+), 34 deletions(-) -- 2.25.1 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 */ diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 459a26ef1d..7b3a91b3ed 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1100,6 +1100,41 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUMBState *env static void init_thread(struct target_pt_regs *regs, struct image_info *infop) { + static const uint8_t kuser_page[4 + 2 * 64] = { + /* __kuser_helper_version */ + [0x00] = 0x02, 0x00, 0x00, 0x00, + + /* __kuser_cmpxchg */ + [0x04] = 0xfa, 0x6f, 0x3b, 0x00, /* trap 31 */ + 0x3a, 0x28, 0x00, 0xf8, /* ret */ + + /* __kuser_sigtramp */ + [0x44] = 0xc4, 0x22, 0x80, 0x00, /* movi r2, __NR_rt_sigreturn */ + 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ + }; + + abi_ulong pg; + uint8_t *ph; + + pg = target_mmap(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); + + /* + * If the mmap doesn't give us exactly page 1, there's nothing + * we can do, and it's unlikely that the program will be able + * to continue. FIXME: Error out now? + */ + assert(pg == TARGET_PAGE_SIZE); + + ph = lock_user(VERIFY_WRITE, pg, sizeof(kuser_page), 0); + memcpy(ph, kuser_page, sizeof(kuser_page)); + unlock_user(ph, pg, sizeof(kuser_page)); + target_mprotect(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC); + + /* Install __kuser_sigtramp */ + default_rt_sigreturn = TARGET_PAGE_SIZE + 0x44; + regs->ea = infop->entry; regs->sp = infop->start_stack; regs->estatus = 0x3; diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 246293a501..12070c8a3c 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -26,7 +26,6 @@ void cpu_loop(CPUNios2State *env) { CPUState *cs = env_cpu(env); - Nios2CPU *cpu = NIOS2_CPU(cs); target_siginfo_t info; int trapnr, ret; @@ -73,6 +72,32 @@ void cpu_loop(CPUNios2State *env) force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, env->regs[R_PC]); break; + + case 31: /* QEMU specific, for __kuser_cmpxchg */ + { + abi_ptr g = env->regs[4]; + uint32_t *h, n, o; + + if (g & 0x3) { + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, g); + break; + } + ret = page_get_flags(g); + if (!(ret & PAGE_VALID)) { + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, g); + break; + } + if (!(ret & PAGE_READ) || !(ret & PAGE_WRITE)) { + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_ACCERR, g); + break; + } + h = g2h(cs, g); + o = env->regs[5]; + n = env->regs[6]; + env->regs[2] = qatomic_cmpxchg(h, o, n) - o; + env->regs[R_PC] += 4; + } + break; } break; @@ -83,29 +108,7 @@ void cpu_loop(CPUNios2State *env) queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case 0xaa: - switch (env->regs[R_PC]) { - /*case 0x1000:*/ /* TODO:__kuser_helper_version */ - case 0x1004: /* __kuser_cmpxchg */ - start_exclusive(); - if (env->regs[4] & 0x3) { - goto kuser_fail; - } - ret = get_user_u32(env->regs[2], env->regs[4]); - if (ret) { - end_exclusive(); - goto kuser_fail; - } - env->regs[2] -= env->regs[5]; - if (env->regs[2] == 0) { - put_user_u32(env->regs[6], env->regs[4]); - } - end_exclusive(); - env->regs[R_PC] = env->regs[R_RA]; - break; - /*case 0x1040:*/ /* TODO:__kuser_sigtramp */ - default: - ; -kuser_fail: + { info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; /* TODO: check env->error_code */ diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index a77e8a40f4..c9a235ded5 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -177,7 +177,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace; jump to fixed address sigreturn trampoline on kuser page. */ - env->regs[R_RA] = (unsigned long) (0x1044); + env->regs[R_RA] = default_rt_sigreturn; /* Set up registers for signal handler */ env->regs[R_SP] = (unsigned long) frame; diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 485b487665..77706dd805 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -795,15 +795,6 @@ static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) dc->base.pc_next = pc + 4; /* Decode an instruction */ - -#if defined(CONFIG_USER_ONLY) - /* FIXME: Is this needed ? */ - if (pc >= 0x1000 && pc < 0x2000) { - t_gen_helper_raise_exception(dc, 0xaa); - return; - } -#endif - code = cpu_ldl_code(env, pc); op = get_opcode(code); From patchwork Fri Sep 24 16:59:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514593 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1683870jao; Fri, 24 Sep 2021 10:10:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwslgX4IOF9jpw38RMNNtlGS/pUV1OdZ+DrW25iPLxU4lB6xI6aQ1b7HDwamJEO4YCSIDzD X-Received: by 2002:ac8:7b48:: with SMTP id m8mr5382710qtu.133.1632503443965; Fri, 24 Sep 2021 10:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503443; cv=none; d=google.com; s=arc-20160816; b=aRLXIOT4H+MIZrvCN0l4KYR/4QZESKgno8BvlzjFRlT6PdktqK3+yzt4bzMYTN7og/ NGW12Ep9gye8Nw6BJN2JF7Tq6VjKdMlPT2oifNi3nJuGQ9XhPCmw7XzWwwZJmf76Yd9d 124T60eCv/DfB5Qr2w2HuvtJc1tTTmOxYT2up3DJ8YZa0Xt+uyHDS5zZQcyqk49jIjox lJ4GYJKSLQdXjraanpyDuDXoCnhcWyzoKGbCC3b/HBDFqYFNi+ijkpKTd6l2FrYMtCTU S/oCGyCqPZ6YIpMLkiXS36xCneGg9FVsMH7zDbSRN1Tp3dd+DOYmAzNFTO+BW1wRIF5w EZnA== 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=PTxH4FIm8UZKfO6Q1wb4hu+tVJghYRydXpLjkNTr2zo=; b=YvIxRGJ20OGARzZK3qMdEBNQzoN7hFseT7dRXBUnnxldgnSw3ngTHVrJS4JM6YG6AD NgVQ3/sdvm1oB21XZz+5+Lls67MZ39nQpDackAQLXjZr1AyFQ4ESy6GtUMRYAjj1OqXw KY2xbiAFxJvWJwhQNdoiIJA/KWf/MSlZADRGN4sJ8jdjyWWcbdSxNP1p3iKTXwEONp7/ CkzwcmModSg7rS2Vt46mjn1aC/M0TaxCKpNAEaea9AQUntobZWDLFI/Y4pJa0/RPinRF ZjHe1EJwYgyknsIDlOzlZRFwonnEBc3rit074hB0Uike+ISPBvfvKvO3AeizyWsHqYfp Pp1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VJTfst6M; 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 s4si6381825vsu.406.2021.09.24.10.10.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:10:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VJTfst6M; 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]:52492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToih-0003Zl-6j for patch@linaro.org; Fri, 24 Sep 2021 13:10:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002mZ-N9 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:36783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY3-00071w-I0 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: by mail-qk1-x72e.google.com with SMTP id p4so28962528qki.3 for ; Fri, 24 Sep 2021 09:59:42 -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=PTxH4FIm8UZKfO6Q1wb4hu+tVJghYRydXpLjkNTr2zo=; b=VJTfst6MefBeUJw+1PD7rTKn4E+MszmdumrP3jlb+MS5MzK0+FBft8HrFzZqaIAiZi 55VfyDP1VOkGOJ6Zxg1berkvS+gqm+IDZbCiOdSnmgm2TPcqnL2cHcQDYQh5pL0LL1tu QxqB2DhcY9PP6HXHFrtYKLy3rlIZ7YE2YoIDznueAq2zJUlddxw/2fjV4DQNYArYius1 aN3KIWeWP42pMLOKfHPQScOA3yEV8NlxmtlZ64uYLlttF+HpT9rjfHGvlQ3rNRpU6KNm tnbprB7mOdzZdUT02BLFLlJDcG6j5WtwLEGLsZ6B+Xhkqfw4tJc4cW1VQiGPTk0u30UT Okcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PTxH4FIm8UZKfO6Q1wb4hu+tVJghYRydXpLjkNTr2zo=; b=JeSSex8AvJcJog5SIR/d91tDmBKrxyx0XavS6D2/Kpw+snm4NyHWOECCZ2u7HjGAhD FSNOPMRJuwZmwpLcj2COCYqKX/FLkVTmCg8mbYCAZVhLpE2vasFHOxyHxSbexIraaE6a 6y63lSKbSLOxWaWe2R7tYbaBMN5uSg/ffNCP938hLiQMLvuSmDa6E+P4311b8lg1VkoE TPreo6veFHr537E0cOfDd7m4ecCrJyAWfBww5Y45wfbnoLMfye1oGZXkt83MXa0okXCQ U8Uz1S4KkCLzOTSx/hH2HkDnONRyzX1hbwj4Sn6LU1HeL5B7Z6kSHs1XHf5FkhZhqyoQ x5qg== X-Gm-Message-State: AOAM5333j1nlgMDJzdtAYZUELwbsARpezPj49DIB4qATKpLd5xtQp1Kw a1q57Ohvat52t0eYWwYoVFOseY5guhokDg== X-Received: by 2002:a37:a88e:: with SMTP id r136mr11551861qke.490.1632502781593; Fri, 24 Sep 2021 09:59:41 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/27] linux-user/nios2: Fixes for signal frame setup Date: Fri, 24 Sep 2021 12:59:17 -0400 Message-Id: <20210924165926.752809-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not confuse host and guest addresses. Lock and unlock the target_rt_sigframe structure in setup_rt_sigframe. Since rt_setup_ucontext always returns 0, drop the return value entirely. This eliminates the only write to the err variable in setup_rt_sigframe. Always copy the siginfo structure. Signed-off-by: Richard Henderson --- linux-user/nios2/signal.c | 49 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 29 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index c9a235ded5..95f6d737e1 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -42,7 +42,7 @@ struct target_rt_sigframe { struct target_ucontext uc; }; -static int rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) +static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) { unsigned long *gregs = uc->tuc_mcontext.gregs; @@ -75,8 +75,6 @@ static int rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_GP], &gregs[25]); __put_user(env->regs[R_EA], &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); - - return 0; } static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, @@ -135,8 +133,8 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, return 0; } -static void *get_sigframe(struct target_sigaction *ka, CPUNios2State *env, - size_t frame_size) +static abi_ptr get_sigframe(struct target_sigaction *ka, CPUNios2State *env, + size_t frame_size) { unsigned long usp; @@ -144,7 +142,7 @@ static void *get_sigframe(struct target_sigaction *ka, CPUNios2State *env, usp = target_sigsp(get_sp_from_cpustate(env), ka); /* Verify, is it 32 or 64 bit aligned */ - return (void *)((usp - frame_size) & -8UL); + return (usp - frame_size) & -8; } void setup_rt_frame(int sig, struct target_sigaction *ka, @@ -153,26 +151,25 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, CPUNios2State *env) { struct target_rt_sigframe *frame; - int i, err = 0; + abi_ptr frame_addr; + int i; - frame = get_sigframe(ka, env, sizeof(*frame)); - - if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame_addr = get_sigframe(ka, env, sizeof(*frame)); + if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { + force_sigsegv(sig); + return; } + tswap_siginfo(&frame->info, info); + /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); target_save_altstack(&frame->uc.tuc_stack, env); - err |= rt_setup_ucontext(&frame->uc, env); + rt_setup_ucontext(&frame->uc, env); for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user((abi_ulong)set->sig[i], - (abi_ulong *)&frame->uc.tuc_sigmask.sig[i]); - } - - if (err) { - goto give_sigsegv; + (abi_ulong *)&frame->uc.tuc_sigmask.sig[i]); } /* Set up to return from userspace; jump to fixed address sigreturn @@ -180,19 +177,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[R_RA] = default_rt_sigreturn; /* Set up registers for signal handler */ - env->regs[R_SP] = (unsigned long) frame; - env->regs[4] = (unsigned long) sig; - env->regs[5] = (unsigned long) &frame->info; - env->regs[6] = (unsigned long) &frame->uc; - env->regs[R_EA] = (unsigned long) ka->_sa_handler; - return; + env->regs[R_SP] = frame_addr; + env->regs[4] = sig; + env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); + env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); + env->regs[R_EA] = ka->_sa_handler; -give_sigsegv: - if (sig == TARGET_SIGSEGV) { - ka->_sa_handler = TARGET_SIG_DFL; - } - force_sigsegv(sig); - return; + unlock_user_struct(frame, frame_addr, 1); } long do_sigreturn(CPUNios2State *env) From patchwork Fri Sep 24 16:59:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514605 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1691443jao; Fri, 24 Sep 2021 10:18:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxclKmAPheLydkvu6+NuBQcixpagluCuWGdfeEhbXcTCpriTKANI54YQYvhgou70Ls7VgjZ X-Received: by 2002:a05:622a:188d:: with SMTP id v13mr5395345qtc.294.1632503925388; Fri, 24 Sep 2021 10:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503925; cv=none; d=google.com; s=arc-20160816; b=swJW8WmD5rpIX3fWakgfzPXT+IbhuHWehfwTL8DS/+UzePF6U3KhiBZJr8WKmlwrNs kurDi9woq7MmW4Ylr2jkEa7jMfo4B6HK40AulCPnz03RWOA6xzqWUPbaOE79+F7uVhm9 guhjx+yxdheMU/15sXJ0uARiUHeh9pAYrHaWtKwBUEir0YKrs9aDNl29o5c5/ZeLShaB stv/YhI8vosDLiIgGWTTa5VtRGtFDGZJ0SqD+GMthED2yeDpKLtg058oV6y2msJbSCYg bZlA5gyaPgKDaD00UaG8Me0mXd9DJZLztUKFbXQpt1KWQVI1iOrdH3820ynh/KlMb3Je 2zkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=vfrTFNcnbBzzKOHxWPIdq3+rOcfAx3GsGPWWiMrLDXBeKNUbaL5TASbGhQfLIPL6e7 ZLFXVD8MkR2mXXVbH5YIL7BcHx+6u/Z7AW6gpkyjxnzVm5pIG/ujVGpSH1/OZJoaunoY tg5pk9ayCPs4vPlXJr4VMysG0YyziL9RGqF+p7WnL1LUEsRSk3Y781QCWCpL4uOlUb3x DSi0Li2QTM73bS9u3o4LeAue7gAt3LIW+tPXRvN3XnQ46qHsJyWuyymwrVleCfbrmCzP ecxzh8fihj8NVSSW3WHxOlecSodKRFqH4hT4ZPJfsb/+uCEhcgXvmNB5BZ1U6B4P50rX VuFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TiEHkqLh; 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 fi16si6875617qvb.7.2021.09.24.10.18.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:18:45 -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=TiEHkqLh; 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]:48870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToqS-0003E6-O4 for patch@linaro.org; Fri, 24 Sep 2021 13:18:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY7-0002p9-IW for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:40664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY3-00072D-IJ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: by mail-qk1-x734.google.com with SMTP id 72so28625264qkk.7 for ; Fri, 24 Sep 2021 09:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=TiEHkqLhCxqVrpRpuynLDSiG61R6O8JsvscC0KYwWWQmsnqu3bR4A4c2xfB1jIz8PO 90jU/0nfyp2AlupK8D8pU7k8QvcSKFks8sed1hFwiKniQOQLZPGd2bRqknXQ8cBHY1lT jODWivjgjAZSNobY0iEEvs5XUHlsuubmvzyTshdtduJekVQRwGokoO2V0rW0wx6CnafV YWWiq651InGZxuKXaPMh1zJH1NPcRAZuYOyHLKJ5N6wtQjcWBQxkXvx50cOdGqSdhKTZ +uKTnUS0HpRS2mWhhPbSilrFFw32n6Gap+jjxo0WoKkflhDd6rIfpcJH4hQmLFWuxcc7 +sVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lOx3X1NullOBxWQQkPTVyDx8zRAFH/X5J8rlFdQM6Qw=; b=YEiZpevQ+aDfAz8KwSgLc4EWKUo/KU8vECz1iSe3GE1xNfTwAZKhdYEYEyHgJeX6ky obkU7xBgw8PiDAw+c2oYQIHMZfs3FCZ4T1BTjLNjhAGvrARA1kz/ED5gpHhSE+/EMB+r Rf7N+tojeJTl+CkjexTtWwqqJUHFk1ZgyzDYvQzL6blcvoBoMghdxbkBZPGuvPnb5Ggk h1M+kcIXcUpeVeZFcJmeIkSiSkPq6aWdaEu7vbbnbgT5Usj6tPn0FBZeWyVj55OmHBOJ FEIWJE2xLUauHa7VUz39G3dSuLc+dJG9VG+GJb7JdefAkX7t/7sS9mBRIItwqXmTNshP m7GA== X-Gm-Message-State: AOAM5330btFeo0kweTbmHSECnPMOmb+QrBWWrmOAbpsnJao4wzxhKoog emLpZhV9e1hC49Nxaf9UdULxOExRL7AkuA== X-Received: by 2002:a37:ae83:: with SMTP id x125mr11855501qke.37.1632502782447; Fri, 24 Sep 2021 09:59:42 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/27] linux-user/openrisc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:18 -0400 Message-Id: <20210924165926.752809-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Stafford Horne , laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/openrisc/target_signal.h | 2 ++ linux-user/openrisc/signal.c | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/target_signal.h index 8283eaf544..077ec3d5e8 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -26,4 +26,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* OPENRISC_TARGET_SIGNAL_H */ diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index ca2532bf50..be8b68784a 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -38,7 +38,6 @@ typedef struct target_ucontext { typedef struct target_rt_sigframe { struct target_siginfo info; target_ucontext uc; - uint32_t retcode[4]; /* trampoline code */ } target_rt_sigframe; static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *sc) @@ -116,14 +115,8 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } - /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */ - __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, frame->retcode + 0); - __put_user(0x20000001, frame->retcode + 1); - __put_user(0x15000000, frame->retcode + 2); - __put_user(0x15000000, frame->retcode + 3); - /* Set up registers for signal handler */ - cpu_set_gpr(env, 9, frame_addr + offsetof(target_rt_sigframe, retcode)); + cpu_set_gpr(env, 9, default_rt_sigreturn); cpu_set_gpr(env, 3, sig); cpu_set_gpr(env, 4, frame_addr + offsetof(target_rt_sigframe, info)); cpu_set_gpr(env, 5, frame_addr + offsetof(target_rt_sigframe, uc)); @@ -169,3 +162,16 @@ long do_rt_sigreturn(CPUOpenRISCState *env) force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1 */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, tramp + 0); + __put_user(0x20000001, tramp + 1); + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Fri Sep 24 16:59:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514589 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1680835jao; Fri, 24 Sep 2021 10:07:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk49kfafngGbqXuKhnYJ4AU3eruEXTGSDft+Vm8dT4V15UvSFHs4ZduZIAoKKDYj8fZO/h X-Received: by 2002:a37:a413:: with SMTP id n19mr11533694qke.461.1632503274816; Fri, 24 Sep 2021 10:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503274; cv=none; d=google.com; s=arc-20160816; b=ejXyG0nqHhxjR95dCHXhatlvKEV7Ofddq4YzpqkYVoft/qOeL7IyAKTixTiSTlxYat Xx4aTCeJqAXJ0oV8zyWI+PVcH9/oxmdC4v7fV9O6ep/w9swlEyYzO/CqestE5CMFUv0X PX4iLtbnLQYcW8vRHNYyrBg728ZYNcmrAoK7pMl/vlbVdjQ1D0/X2dVMO3luA/UB/coM aYpAxoamze887LXBHaHKc9rPCJl+2BZeCGeTjuDkMffe+uznxX6P5xxryowfCEzozd8O EzU8DJoPFXxX5BqUiAB0GP9IAgaEdnRT0TlvrhYRYblBg3+nz+wRH9laXVIP55M9RfJq I/FA== 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=rvAlqQQaMJOEemK1f4c76TW1TW8p9KSzHxLmC3ERHiU=; b=oHihGzIw9AnNQmZEPn3B8Dmdqz7RbkOo3Wf+DQEHHpu2buFtAgQb17whUyFpP6aeMp 5nyMOFy9v6DoKyX9jzwurnxlCnMkIWtVbQ+IjzhjTq3OLm5/qP4jUJQZPSuJ4wzeZ7RK Ex4QhinnKRvOYVpCKXKW+tKcmZ8lSvOrCsZ7ut4BIJnWVMq5dpNLA5DkABFJ9DvjYa2s GvsLV5gDVLS9jPdMHRV1LIvWZnJAsUvlemH6NBzCQRkeCBHG+aevdEtqtWCo9J+vDG/M v6W1ynjAH199NgkH118vRqVL8GERIQfOQtUSLc8Wo3NQ9Isx2vQ8sxDWF1Vwx54ZQIxX 0oQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fU77HVUZ; 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 f6si6311719qte.318.2021.09.24.10.07.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:07:54 -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=fU77HVUZ; 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]:43860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTofy-0006D9-Bg for patch@linaro.org; Fri, 24 Sep 2021 13:07:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY6-0002mt-Pl for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:44741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY4-00072J-Jw for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:46 -0400 Received: by mail-qt1-x82a.google.com with SMTP id r16so10014639qtw.11 for ; Fri, 24 Sep 2021 09:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rvAlqQQaMJOEemK1f4c76TW1TW8p9KSzHxLmC3ERHiU=; b=fU77HVUZPzfIQjoQJUr0pIf9YHhi/E5OVVhAfXGjRwlE3gdqRrrn3ZOmnQeMffvmQA GNKV7kuuPMLbNbiGBZIGGkRuDsZ+mnRYndT4PDJ54zR4KppaXidApaBEsheLjJiRYwW0 ZYXPiJsx/VkkFfNnkBoPMsbGo2b8MZHEDIamL8WstPH2bEro0GF7d/MyK1e23hQP8XHs fkMqDJJFbX0De/UAzI0ieSDWz2eG3c/LWiopYyl8/fPH3ifJLZS0WlfP3kAluJm23CIU eXBibC2Th8hhyv1iE+/6KTuI9v/ZIt0z1ZQPq9ZNn/iV14pbSePG9omWspN0V80P0aPt 8VYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rvAlqQQaMJOEemK1f4c76TW1TW8p9KSzHxLmC3ERHiU=; b=3thep9HwZLL0+mwDx0zq2y7NFNTr8Ks9issXG5JAonPsn6AXcdCdEnrxnB/yXg70K8 mPH6yMwr0v5iCJqq3AhDlSMTHq1LSGpafICKczZnofhBJfpmQrarYJCK2aZAvKs1AQaq 3kfZvIZEzWpsR2imqX9x9c6sC+8u5+0SoG/o4Cog8ntzCwVYsl6lWlRpVoi4qfGfo0xC bTEwvHm/8LP3XoIyLLNh2hTpOguY2sT3ai0St/V9trheZJCBgX7MUfwuLbA9GUTyfg8A G5reEkLb+b5YZaIFtZ3BSKOr58tdOdCM5FBwFifrdk/4unzR3tXu+y1qd30zzsA0rVaf JhhQ== X-Gm-Message-State: AOAM53349ZIuwMC2TeZBzIMf4LsM7cTq89QbEh3r3iXKNWSZEpZe/qQd AcnPzbKtsCzCxWOqxmfJpRtc13hs0poV2A== X-Received: by 2002:ac8:7143:: with SMTP id h3mr5378609qtp.242.1632502783131; Fri, 24 Sep 2021 09:59:43 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/27] linux-user/ppc: Simplify encode_trampoline Date: Fri, 24 Sep 2021 12:59:19 -0400 Message-Id: <20210924165926.752809-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The sigret parameter is never 0, and even if it was the encoding of the LI instruction would still work. Reported-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/ppc/signal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index e4d0dfa3bf..77f37b9f01 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -309,10 +309,8 @@ static void save_user_regs(CPUPPCState *env, struct target_mcontext *frame) static void encode_trampoline(int sigret, uint32_t *tramp) { /* Set up the sigreturn trampoline: li r0,sigret; sc. */ - if (sigret) { - __put_user(0x38000000 | sigret, &tramp[0]); - __put_user(0x44000002, &tramp[1]); - } + __put_user(0x38000000 | sigret, &tramp[0]); + __put_user(0x44000002, &tramp[1]); } static void restore_user_regs(CPUPPCState *env, From patchwork Fri Sep 24 16:59:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514607 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1695199jao; Fri, 24 Sep 2021 10:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC7KXZPbY5ClzqNizJ5I4UIosncdjAhKC72r2OW+r2psUnIsuFpYwpoPxOTH2rtGUn15fo X-Received: by 2002:a05:622a:45:: with SMTP id y5mr5239311qtw.145.1632504162052; Fri, 24 Sep 2021 10:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632504162; cv=none; d=google.com; s=arc-20160816; b=FHq1EcADOVlQ8iWdjeKVtkELmvdLjccwJSuD6WfRl18j2WwkWP2Knk/OnqX07AQ/0/ iB2A2pir0Cxw0GoZmSKThxNIZsffnp0JhO8mhjrNfZO/htGDehJDC8AkxMPpzJ13pueu bn7ncRb0XiElyP1dGW6mIXU2NnPEU+p62RATXVIJomRlPoMKZyZ2+oVyGLuxBGpbw90K QffTpruoPZFlA+KddSWEN6onu3XEgHuIJNS85Yt+gIf67q4i5VAikjbd7qYl1aKqWEo+ riCvoe2F40c4WPdXRoLXyZfU1M8DjUCP5VfyyYDqsW7/jsfgmrIJe8G4RBtdSDy22qvq mn5w== 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=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=hzP1HFUKfYafkNLk9PeO10xWn7NJXp1sEFmhtfwoMxcnBaqOxmLXeND6zRUn4TUcY3 SAgfB1gkdeaAVaJhl5qR7s9HzoF3wPwmwSAetoHuakFASkBFjGNRtLRTgsqRN3c9118l Qmty6HUcWS5CQHYPlBhZjuey4kMEFr5/u0Lyt3Noz0X6DxpvcA1RVvd7yRlH/04+Z7rB yvxN3382iLc8Qje8Aw/+yIah4LtjI88k2cFg3G/WqZD/hHHDmS4QPBf8zpw14IbucY8n yoCRdY3VBoTYCjvcZ/g5sccb/evd8Cq1mWjw0o6c9aAaZ4bppmPFPKiotJsV93PYoM4q zsoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nvb6X7Ig; 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 d2si5682282qvx.151.2021.09.24.10.22.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:22:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nvb6X7Ig; 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]:55356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTouH-0007Y7-Ic for patch@linaro.org; Fri, 24 Sep 2021 13:22:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY8-0002qi-1r for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:48 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:41546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY4-00072x-Oy for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:47 -0400 Received: by mail-qk1-x732.google.com with SMTP id m7so11926007qke.8 for ; Fri, 24 Sep 2021 09:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=nvb6X7IgiG4QCH5gBpebZZBVwD0cHgiVSvGUIt3D1q2xOX9C4n11QpThSMrdAjDkPS p8zJdtsIM6H0OnRTenjURypWvqDEAs1Qam7HnngzsT5EPG2b/Nhl6Sv6s+l58SQLMUiJ vgHxcJYQ1rg5ZEeWDLxU6npoh/y+E31kueAmAJpfqnMef8EM8I2/SErBwFNIfNTeasiZ HBQUgw4IILUkzflpG7lQk8rhvCTQOGXzHuciOnJaoA5HeAi310tW0VsNkPMH/SB+2gNn tG6xGpUDFct/reIyhz7YEuL/FAmqwSAhFq87l9RNscJr4rWYOdPOqJJlE1vPw9FTm1hE icjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SZvv6mwim/aN6A6ZYNe3jpT629cJgaIoaOTFut4hzug=; b=Robhj/2FEjwhBdpYkpeRqdGhbXZJBpGyV6V65avN8mn9YubWnmBoU9T5l7JpyF25Jk HZ5k5oXu1ewYMVSUNOBpYoZfcyIM5Mn9k4m6cINYZZcUJvAXjnoxocSj5t6l4aNSaPPz w7TEUCz+U9Hxs5D/ZerlEjeA29WWgXFBipKIxyjvR8KweLzu8b7gMiY4JQ08r/IFW3V3 1FW+hDr5nPAOdT7q79qeYeaQbLsETsdM0xAQWvuyQvnjAopyDhB/1v1HolxouLTtVFSk OWSAVlxRuC8XbfB/B6sQ9WlkJyasIlrJ2HGQWYe+5pw1nGRLevkoBGQVSMKlO/G63cIL JKSg== X-Gm-Message-State: AOAM532qr8y4Qzoyi79/nTsygW22+56mZY9tsuOtrsj+1t7Jlv6Jugi4 MHEYZYAy9tqk3eBicOqpshDQhiqfsBTxQw== X-Received: by 2002:a37:64cc:: with SMTP id y195mr11351439qkb.97.1632502783932; Fri, 24 Sep 2021 09:59:43 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/27] linux-user/ppc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:20 -0400 Message-Id: <20210924165926.752809-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-ppc@nongnu.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Cc: qemu-ppc@nongnu.org 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 77f37b9f01..c37744c8fc 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -203,9 +203,6 @@ struct target_func_ptr { #endif -/* We use the mc_pad field for the signal return trampoline. */ -#define tramp mc_pad - /* See arch/powerpc/kernel/signal.c. */ static target_ulong get_sigframe(struct target_sigaction *ka, CPUPPCState *env, @@ -436,12 +433,7 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Save user regs. */ save_user_regs(env, &frame->mctx); - /* Construct the trampoline code on the stack. */ - encode_trampoline(TARGET_NR_sigreturn, (uint32_t *)&frame->mctx.tramp); - - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(frame->mctx.tramp); + env->lr = default_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -477,7 +469,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUPPCState *env) { struct target_rt_sigframe *rt_sf; - uint32_t *trampptr = 0; struct target_mcontext *mctx = 0; target_ulong rt_sf_addr, newsp = 0; int i, err = 0; @@ -507,22 +498,17 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, #if defined(TARGET_PPC64) mctx = &rt_sf->uc.tuc_sigcontext.mcontext; - trampptr = &rt_sf->trampoline[0]; sc = &rt_sf->uc.tuc_sigcontext; __put_user(h2g(mctx), &sc->regs); __put_user(sig, &sc->signal); #else mctx = &rt_sf->uc.tuc_mcontext; - trampptr = (uint32_t *)&rt_sf->uc.tuc_mcontext.tramp; #endif save_user_regs(env, mctx); - encode_trampoline(TARGET_NR_rt_sigreturn, trampptr); - /* The kernel checks for the presence of a VDSO here. We don't - emulate a vdso, so use a sigreturn system call. */ - env->lr = (target_ulong) h2g(trampptr); + env->lr = default_rt_sigreturn; /* Turn off all fp exceptions. */ env->fpscr = 0; @@ -720,3 +706,19 @@ abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx, return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + +#ifdef TARGET_ARCH_HAS_SETUP_FRAME + default_sigreturn = sigtramp_page; + encode_trampoline(TARGET_NR_sigreturn, tramp + 0); +#endif + + default_rt_sigreturn = sigtramp_page + 8; + encode_trampoline(TARGET_NR_rt_sigreturn, tramp + 2); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} From patchwork Fri Sep 24 16:59:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514596 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1684835jao; Fri, 24 Sep 2021 10:11:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx92jQq4yUR4KySjcHpzU26MDAZS77Ac+v+640npXWQYJC/GgXdy0EiOntOIYgDDYeSTF6Z X-Received: by 2002:a05:6214:1351:: with SMTP id b17mr11148356qvw.11.1632503500463; Fri, 24 Sep 2021 10:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503500; cv=none; d=google.com; s=arc-20160816; b=XMLArX4nn4tBPaf2qyX4NuhmTQAnuoSgB2lB8x7ZLtzJpdPpVoozbK2ShZmPX1PSZC IfzErd48NJT6S8QPPcHJ4aaI0mwRhAxzZ8CKUHS29d6HD6dO2+HdFwE9H1wacQv2lu2z VkKrVoh64l86fswVKnQiQCJTxsEFLWnTaC6GvzWcDm1TzkE1TfUeYzjSfmHvnRWtVORl 6o6dUf62RhXKwG0DjhIbIw+VXH3GY5DFyhDZAQvNFKQ6ISPyKZezOSpuV335VTJZvojj h5ThUXz2N/2jJocfsM81RHKACi66qRo1BXaTzFkc6DHbdBPQIoJIj4V5dFnSBqFDe467 qXkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=IPxK6UI6kQJFuDvvHcsjU5WX3W2EQhGZlZM5qX6O2Q0lFwM2BPAS7gFZLLGPec+qUD U81CQoLXF1vRrOCewMdH9do2EJd4Yk0QWpv8KN00dmL/0rDA884HNk9AwnfEFPpORvtt i+GzCECmCFHlgTSDzcTdwHxXpKu7T28OZSQXj28Xdy0F0d9GsAhDhLQ5FrEVfq9OshiH IS7CaDjK+2zqmzqRbPaPLBToO1tQvGOjniBB9MwNi3NmYQxqMZ4UgnXzKuKSSYGj/S+A rcZjy7sih9GjAXPojiGHnrdfMQV1bTLMsucfn1eHzKiVVcT7h/Mc1NqRyyvoM/Nf1gyx IoNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ofmns6Nb; 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 i25si3204838qkg.70.2021.09.24.10.11.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:11:40 -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=Ofmns6Nb; 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]:55374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTojb-0005S3-Ta for patch@linaro.org; Fri, 24 Sep 2021 13:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY9-0002xf-Jv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:36789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY6-000745-LZ for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: by mail-qk1-x734.google.com with SMTP id p4so28962711qki.3 for ; Fri, 24 Sep 2021 09:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=Ofmns6Nb9e8eLHBnOUOL6cJTd3Jelb2Ec+/aJPWv9iev7XxrAnLv7F1oDLJkUj4jdM KpWde5gdWj2Zo7rPrmCLkl5i9EHwBUrg7/KXC/CyXLnMPV95rg7oN9jexpr1mWVgRbcI 7nVnQqy2YB0VJrLW4a7V9iR9WoV2omDtwn4FZqO9WuXWXsPXxFjges9TBL+L6jZrVYsq EkTfUmrndcM/HyQ9q/6fwYIIuUeKbs+1NAolQ39H1E1oGh5x845alwC7E/PVHkUda7zp 5EzXV5gzrUOSw2VMhZj1C0T2zIuajgQZRDpbaif9/QaCy77eabFRVxhYgmYMuh0YFkqS lYfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2KLcqQYFIaqI/6GBRBsTweGpPd52GQDyv8etIxbrli4=; b=CCahY8wS+eTQ0MvGmersg2vPuEF45dyWoLiAJmROT66oYI+do7GxT5bUnvxThSuPZx yh+I86oDgv6RHWzScDVCXB2Pe5mF4gn2z6YmIiXYKZXcCcYR2GEpmkPzjv0XVt62iy6W FYigLJEHjrcqC2Cwh7Af2NA+yB44VufhH9U6HpcDuUiDibKwKVmC/UoIjs2+9PNE2al8 FySu+tgv3U0/Rz4Ljn+k5bOe+FHkGQvLGWL6IIU01UWuM/58a4LDoxM3U+qYNPj3J3AB GvL8h1kR3fUBrdBuWoDDjYqea5WTv7w99aePiB9I5kLdhlW0k+p2PsV9qGb7KNrzCCcN HZRA== X-Gm-Message-State: AOAM5310myAJmTMHMEA93vLYWzEgmgUrpP55Flp1Zpkt+uiN4lrZdxOQ T0fGJeirC7HLy1O5P+6uUqQoywUXCxHg7A== X-Received: by 2002:a37:a54c:: with SMTP id o73mr11744712qke.334.1632502784749; Fri, 24 Sep 2021 09:59:44 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 22/27] linux-user/riscv: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:21 -0400 Message-Id: <20210924165926.752809-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Alistair Francis , laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. This fixes a bug wrt libgcc fallback unwinding. It expects the stack pointer to point to the siginfo_t, whereas we had inexplicably placed our private signal trampoline at the start of the signal frame instead of the end. Now moot because we have removed it from the stack frame entirely. Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/riscv/target_signal.h | 2 ++ linux-user/riscv/signal.c | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) -- 2.25.1 diff --git a/linux-user/riscv/target_signal.h b/linux-user/riscv/target_signal.h index f113ba9a55..3e36fddc9d 100644 --- a/linux-user/riscv/target_signal.h +++ b/linux-user/riscv/target_signal.h @@ -15,4 +15,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* RISCV_TARGET_SIGNAL_H */ diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index f7f33bc90a..a0f9542ce3 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -47,7 +47,6 @@ struct target_ucontext { }; struct target_rt_sigframe { - uint32_t tramp[2]; /* not in kernel, which uses VDSO instead */ struct target_siginfo info; struct target_ucontext uc; }; @@ -105,12 +104,6 @@ static void setup_ucontext(struct target_ucontext *uc, setup_sigcontext(&uc->uc_mcontext, env); } -static inline void install_sigtramp(uint32_t *tramp) -{ - __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ - __put_user(0x00000073, tramp + 1); /* ecall */ -} - void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPURISCVState *env) @@ -127,14 +120,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, setup_ucontext(&frame->uc, env, set); tswap_siginfo(&frame->info, info); - install_sigtramp(frame->tramp); env->pc = ka->_sa_handler; env->gpr[xSP] = frame_addr; env->gpr[xA0] = sig; env->gpr[xA1] = frame_addr + offsetof(struct target_rt_sigframe, info); env->gpr[xA2] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->gpr[xRA] = frame_addr + offsetof(struct target_rt_sigframe, tramp); + env->gpr[xRA] = default_rt_sigreturn; return; @@ -203,3 +195,15 @@ badframe: force_sig(TARGET_SIGSEGV); return 0; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp != NULL); + + __put_user(0x08b00893, tramp + 0); /* li a7, 139 = __NR_rt_sigreturn */ + __put_user(0x00000073, tramp + 1); /* ecall */ + + default_rt_sigreturn = sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} From patchwork Fri Sep 24 16:59:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514606 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1691469jao; Fri, 24 Sep 2021 10:18:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHMDYc+xBqzSahLi0q+u9G6kEc4kOwdH90RD+/7jhZgxlEzmWnKfNl2emXKU0OflmZxuZI X-Received: by 2002:a05:6214:605:: with SMTP id z5mr11475787qvw.34.1632503927171; Fri, 24 Sep 2021 10:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503927; cv=none; d=google.com; s=arc-20160816; b=Ah9qSbb9a7dqM9OuE18jutk1Os8h5B3Ad5jTCX5Ylwe7YsYXZleOiW75lp7t1yG4kt X9Py9BTPaBVrnqegbrX/gy3o6xhyl7th2gfL+BWZ25lx4QrvfwU/d2vBj2QYNZNsSaIO yrS5fWL8kXJ9+BZWtmPoBx+ccLP/yEPktcsa3jY47NFLvJl9j8YxckqmRvdkmxm6v+P0 mUjmVRW47L/RqlLjfRjf1zR1vFf0t0Zpx4nfwDlaIyPKJgNQMi9sP/HKpW4uKUQWF5aY rc6mkMSIkxnJP6EXUwtNxpev+0jFJGfB4poozD3MdPGsv1Rgv2RU/Nbqprz2F9YNmZxi 7erw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=Q8YndjwK63dDySgWd9selW2PAYvGvyHdYYdQoM12sGMnlccmEt5VW6bHZS72VM5io8 Gl+VEPdpG3NoUokQFrtEsftJe2Gb3zI5wT7RXy08a7Vo5N3hzXJ9LP1LRYVH7ft4H/NC bvar9v1krK0pRa1Q8pnWPxfVwQI5N++S8SCV2zQbyOH49qQMMkO3BQz1gzGOUYws9z9L PeFHVeJkiY/NGVWUhunxsPwy1GZ9NgVOFR+vRPHByTNsYnUtwi0TE4NU9rhZ0QRtW+WS cKMBtz5vfISF1t9XkoapvCTKyfZHwRShNS08PM8XvRz+Mdr8rjYI/dZ4vbHVPyHk5QcM HUOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=izwHaXTW; 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 s2si6471958qki.335.2021.09.24.10.18.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:18: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=izwHaXTW; 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 1mToqU-0003Ju-N7 for patch@linaro.org; Fri, 24 Sep 2021 13:18:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToY9-0002wV-BM for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:39700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY6-00074K-JH for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: by mail-qt1-x82d.google.com with SMTP id j13so10053148qtq.6 for ; Fri, 24 Sep 2021 09:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=izwHaXTWBfwELcDM9unPhyjA1hL02WdAguVFjIjDGbOEcwEngy+DLf/BHM+mdesGbo i5NFVM9DfQoDRdv27arefaurzgH4FtCmCnNkcMit63gUMCZu+Z263VvvgMK5bw2flMQm KgZ6OK7+tAar4WIOveArojcEdLDDT/TYZRGUAS8vuwbOQ9CrCfEwCjgTKuwaipNFkMzZ IdHqTfJjJwsdmi5quk61HqKZ8vSKlY6O1cisjzVilSNtMHLtwApssFqvLW2Yzm8ZN6h2 7t6QEV3AFJV1poFEtk3r8wau0o8B6t9N8vWXHpYdhWqyKmswG9Oh6EDAORR6FMtgGQsx 6QYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z6sdM0HHcKJX3xm0cdq26GIq2QyBnBfucTBir90HJQ8=; b=kfxTWTnPH8Xt6fw5YVMCF64YqbhGpQHEtwaffnDyajgPgstWq8UY4i1WD38DoYfPiH kLJpnrvYh0AIqaLDSiKk8Buz3FuwD7nJEWSq/VYmXpLhXhM2/DkY7xRMgDQTmFs1JFI3 NBzK5CHGATFKZmLGL7d7xYcW9UuFnpFA5AJ1s+MKoihj1aYIdf53lcu6dLYN7w7BxhUO QmArskiy8BcSgwfkS+/OLVe4uOn0106H73vfTCqPGaM4eRyXF5mJ1gCBhmvuR/qgCio1 KrNVdSD2f9f/mvx2XktwGSSa7wzmc7pvjY6SwIARAsoXoh0Cb6EKtTUk60uShOkrYWj/ LyvQ== X-Gm-Message-State: AOAM530hGcUJjqHXhQYJJrpSxIHaGc17gOdbFS91O1fQXZRlQWC8EAd2 SClH7Xu2afX3NW+JKNReXguOBcK/E3ASfg== X-Received: by 2002:ac8:74a:: with SMTP id k10mr1304225qth.17.1632502785658; Fri, 24 Sep 2021 09:59:45 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/27] linux-user/s390x: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:22 -0400 Message-Id: <20210924165926.752809-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.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: peter.maydell@linaro.org, qemu-s390x@nongnu.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: qemu-s390x@nongnu.org Tested-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/s390x/target_signal.h | 2 ++ linux-user/s390x/signal.c | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_signal.h index bbfc464d44..64f5f42201 100644 --- a/linux-user/s390x/target_signal.h +++ b/linux-user/s390x/target_signal.h @@ -19,4 +19,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* S390X_TARGET_SIGNAL_H */ diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 80f34086d7..676b948147 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -68,7 +68,6 @@ typedef struct { target_sigregs sregs; int signo; target_sigregs_ext sregs_ext; - uint16_t retcode; } sigframe; #define TARGET_UC_VXRS 2 @@ -85,7 +84,6 @@ struct target_ucontext { typedef struct { uint8_t callee_used_stack[__SIGNAL_FRAMESIZE]; - uint16_t retcode; struct target_siginfo info; struct target_ucontext uc; } rt_sigframe; @@ -209,9 +207,7 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(sigframe, retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, - &frame->retcode); + restorer = default_sigreturn; } /* Set up registers for signal handler */ @@ -262,9 +258,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { restorer = ka->sa_restorer; } else { - restorer = frame_addr + offsetof(typeof(*frame), retcode); - __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, - &frame->retcode); + restorer = default_rt_sigreturn; } /* Create siginfo on the signal stack. */ @@ -405,3 +399,17 @@ long do_rt_sigreturn(CPUS390XState *env) unlock_user_struct(frame, frame_addr, 0); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 + 2, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_sigreturn, &tramp[0]); + + default_rt_sigreturn = sigtramp_page + 2; + __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, &tramp[1]); + + unlock_user(tramp, sigtramp_page, 2 + 2); +} From patchwork Fri Sep 24 16:59:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514608 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1698732jao; Fri, 24 Sep 2021 10:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9NlAttKf/3+P2uPvptbqQhU7OjYWCSDHLRKP91o8WmEasASUXTDBm/UZ3kYY6uJbbvnCt X-Received: by 2002:a37:8e07:: with SMTP id q7mr2578023qkd.287.1632504393656; Fri, 24 Sep 2021 10:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632504393; cv=none; d=google.com; s=arc-20160816; b=WumPPbnZkGQRgLxlebktIIG33I9eZICAN0RTyH/jeewRclQoD4BmJ4kMOVNNh7JgRa wzRZ5MBRc6ntW4eRQT2ZlM0t5cSxrUkdIhxhw5fXGmfwK5ks0XAko4X4vDyG5R40qNWg gtBlLefmnLycsaH/8zJ66Hq2uqf4JzTKNP5VGc2caesTfjQ7yu448PoRKeB3E623dKup N6ho4goEaEpPWDcfhGDIrAgyBRGKyEeA14Wdd9j11LYKg299rPwMJ9X8nox35cDawvf9 KLy5aNblkcRN0zzt4Ey2w1fTn9ftTOQ0/6y1XknqxuEXdOaH0Krhf2MhKX/R4zm7uXcb sszw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=i0RLYll53/bPmDu1xgc+S8CnnnxSf1nKzpzdcHlqpVSrI09RKHWNVOTs08l9e+znAO Rvyt8JklPp3pHMqQcKXLngH8vYJOgypo6Bg5fqrRoBva21Ow7FdpVvSayD4PjYz9qr9Z 1ASt2FRqy9aIo13ABVl8CrVNOb0Etm2Y36lxKxBvDT5PyXDcwW+qoOwboCf+7uer6Qir rB8m4mPJRWOK+ynaplDy1stfDUPYsd+O3u/0cBjnDbbyo19jkvWtjkbHjD/TwU1X4F2p dizAPoIoTvkKzaHVcEJ2e7TXGepqMEA/ZGy+sVMawaYYpSfxGDPXLSKiajVqwUQ9ZT2D ZhEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JTHRst3l; 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 v4si5571730qvk.149.2021.09.24.10.26.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:26:33 -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=JTHRst3l; 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]:34246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mToy1-00042W-2o for patch@linaro.org; Fri, 24 Sep 2021 13:26:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-0002zM-4h for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:38829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY7-00075I-C6 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:49 -0400 Received: by mail-qk1-x730.google.com with SMTP id q81so25090075qke.5 for ; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=JTHRst3ll0y8WPA4QcJr76vLZXA6cp1hCJovcLAHi1ezcjj2KEIYIGz7r2q2CXZfEm JX4HYvhh0QkLZ1RL7G1GLkK0lSAjmQk4GJOpZCdRmYq4mnW/VBxys9jqTesgm0WghZ1l Hrh9XpfMD++3SbDLSno2qAR4jS2RhQvCrATQnGaLYTMH3HM0kDnJZLO5p9zU95OYgsVv VSmikbFljlQHPbpomEeimENVENfYhnOZL+gHawOKjKEDj+IpiPZxsw2b036FoSm1+icd BnADbM0hfKjrlOuG7lNRhJqt0wL4mbcop1tWod3EOC/AHaGZR6koShb6WIjL8Yg6O7Kg 1Www== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N1pQeWtC9n4Sw0tRD9grdf+GtJJknjzU5E/8NqeYIIg=; b=QnZAHEowDfvItSDERIZFABDQeuoYUBqOvsGVpJnYaNvqEmC6RCoQtS8SNJXjshEEvG XkuY+/qjoyRxRIjNPdl2hD24gq7r6rD5RKj/iTOKJpub7VBvpSv0qu3TvXesIeuVNYTa F2mqRZJqtRvIee9tFqgrQNpu6jH3xK7MPR53DtBMiOThZDMDHLjzQUzzdvhQxAcFJ+9O ar3lbPGlAkpQ6PV9ZMRRdJ4QRkjgxjjJ2xL1f69Y2WvslX2fFid1Kq9zD2uzon2GjEcM X0dq4ACqh89j3uPyWS08yfUbgCoZrKxZrg+P90h059Np5WIdqNQjSBMCzPoJkQ7dvrsn F2Dw== X-Gm-Message-State: AOAM533Ppe1QOPW6n+GNWXzGiXBuRnUwWBw/nd3YcFP/vTA/r2taYFsS e/4jT8RUGvBr9Kz7f90KTzjf3mQ9HQdwDQ== X-Received: by 2002:a37:b703:: with SMTP id h3mr11871098qkf.240.1632502786453; Fri, 24 Sep 2021 09:59:46 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 24/27] linux-user/sh4: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:23 -0400 Message-Id: <20210924165926.752809-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, Yoshinori Sato , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Yoshinori Sato Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/sh4/target_signal.h | 2 ++ linux-user/sh4/signal.c | 40 +++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) -- 2.25.1 diff --git a/linux-user/sh4/target_signal.h b/linux-user/sh4/target_signal.h index d7309b7136..04069cba66 100644 --- a/linux-user/sh4/target_signal.h +++ b/linux-user/sh4/target_signal.h @@ -22,4 +22,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif /* SH4_TARGET_SIGNAL_H */ diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index d70d744bef..faa869fb19 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -52,7 +52,6 @@ struct target_sigframe { struct target_sigcontext sc; target_ulong extramask[TARGET_NSIG_WORDS-1]; - uint16_t retcode[3]; }; @@ -68,7 +67,6 @@ struct target_rt_sigframe { struct target_siginfo info; struct target_ucontext uc; - uint16_t retcode[3]; }; @@ -190,15 +188,9 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_sigreturn; } /* Set up registers for signal handler */ @@ -248,15 +240,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - regs->pr = (unsigned long) ka->sa_restorer; + regs->pr = ka->sa_restorer; } else { - /* Generate return code (system call to sigreturn) */ - abi_ulong retcode_addr = frame_addr + - offsetof(struct target_rt_sigframe, retcode); - __put_user(MOVW(2), &frame->retcode[0]); - __put_user(TRAP_NOARG, &frame->retcode[1]); - __put_user((TARGET_NR_rt_sigreturn), &frame->retcode[2]); - regs->pr = (unsigned long) retcode_addr; + regs->pr = default_rt_sigreturn; } /* Set up registers for signal handler */ @@ -334,3 +320,21 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint16_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 6, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + __put_user(MOVW(2), &tramp[0]); + __put_user(TRAP_NOARG, &tramp[1]); + __put_user(TARGET_NR_sigreturn, &tramp[2]); + + default_rt_sigreturn = sigtramp_page + 6; + __put_user(MOVW(2), &tramp[3]); + __put_user(TRAP_NOARG, &tramp[4]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[5]); + + unlock_user(tramp, sigtramp_page, 2 * 6); +} From patchwork Fri Sep 24 16:59:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514597 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1686636jao; Fri, 24 Sep 2021 10:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh/az1XggzlNAauv4jB8zIWgRczy+SlB2ib7OTI5Kg+uCOW3f4YARV/JsQVXqk/9BWDQhH X-Received: by 2002:ac8:42c5:: with SMTP id g5mr5194389qtm.224.1632503611206; Fri, 24 Sep 2021 10:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503611; cv=none; d=google.com; s=arc-20160816; b=DNWvfIWZRUeva5A5/pGAHjzLCsqVewzrvEoUp71eob7mS2x4NEinyJn9Gxg8soQxqa laX6fswk3VBvGsk9tnbtQDma6gfmue8vjHSGj6IB129KMxZkqY6ydomRFOmhRDmdtYT3 DZBjX0RNX358uHFVKPdCoiyUuTIGgKeAu7gr0zhC3LBOzoqvhu6Yj3NqQFYdsisFyQK2 gJrQWsBXvxdhJDlvlbNpC0hBGGl2LQctupwxu9jMJVafg82HIvYAqrk/Un6HkhxsMXT/ dNTufv+EqGeqEwBrQne9rltUpVn4mpnNcpNL3ehjZd2XR+NRIKqycXzjxzgqgCC6goJx rr+w== 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=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=kj8cImUFZagJOgCQTzJQVzzLhe4FMMwfLurfRTrg5kXkw3XNhthelLIJEzs3dWakjg GAoVhNpFWxb5X4b+cKb24pEV+PYHq8Ltmjtth09so/CmYaqgbjep5moKEwQOr2vXOOZL 8Jp4RSWONsPV2g5euFm6W4KQqM996rLI4xsyU20FCX6uTIzcrA9mNkmY9aCFXGVnkHt8 nLJgKeQ1I9n24Uwhtw09/qaumMXtHUAxZmK/82c9xsCDor5DZRNcOqqTDNvaNdNTOeg+ pdr7YQckffkP6eyO0E/wKnqNbmVOPn77J+WqQjllM0qiyR587TM50To/bnLEtGLMnEkD aCIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=daLEaNGm; 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 l10si2654010qkp.104.2021.09.24.10.13.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:13:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=daLEaNGm; 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]:60980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTolO-0000sR-Iy for patch@linaro.org; Fri, 24 Sep 2021 13:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-00030P-Gw for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:39702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY8-000763-2M for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: by mail-qt1-x82f.google.com with SMTP id j13so10053206qtq.6 for ; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=daLEaNGm2JcBkU6qTxW3+UqnC899+eVTOSVIn7EyU8Dk7RAlC4wGj2VFQlN80RsthD Rh2nmyERAt9nxhAQZ3n4IuQx35c9YR+7/WqRDfIHLSfhzVrZzc3EGOg8ozQSk3IArTQv peUJS/lV92BSFaP39eKF/xeJkKpLf12PmQTshsPzRu+RyDLJkk39rJdSSW9pXfscX+0J ExbMQoTLMQ7HjM9fDGnabNmmvrYjXy2bByeyTxkUN2pe0skvRCfFKG/8RhsyUWX1Uw86 G8OG/dVvk/eKJsVdO48WF5ZJpNwD3os3+wvOpPugzbb0y4mLK5GMiAok472xRwzCTjOm pDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JReOUZ1JauLUBHSvydaez4tEecQ2s9UVamV6Wd7OsXg=; b=50GanN+GF0i3mj5z8DjyLfDD9Soc0QUHLxcAJ3TSB11YanC2wrMBwSK+nzhe8vOPIh VxelASetu9oEhR1aaxVLEvLifGwNOcVHhu4GspjJdBNOvLSsTNcO3saFJM8oMh5aebmc QcOd5tN0RU7LteT+msUflJBLHI4GGs2dDyIQGCmHV6cEh1oyLoLrKi59tW8EGvLFJ2Ja MKRujY7IeOYbjinJMGRNztWLoV24zMROxSpsA04p55k6GODKNKqzjR95DR/C73DwXbQs 3DPq7Q3lvSNVfkIJVIu2E6g6yKJiZqg4WL4NVzEoKnQaK6XDPXlpzm/FVWvljTl5sIBF leEg== X-Gm-Message-State: AOAM531fvwpNFlpRzInYn0M0U6n/mK5FMAklkWmcIUmqaWMyvcqZkMo0 ZQ8RIb79mS/+WK3RXbCOOvYRU5E/agzJog== X-Received: by 2002:ac8:5290:: with SMTP id s16mr5162195qtn.412.1632502787172; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 25/27] linux-user/sparc: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:24 -0400 Message-Id: <20210924165926.752809-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Mark Cave-Ayland , laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the two signal trampolines. Use them when the guest does not use SA_RESTORER. Cc: Mark Cave-Ayland Signed-off-by: Richard Henderson --- linux-user/sparc/target_signal.h | 4 ++++ linux-user/sparc/signal.c | 40 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.h index 34f9a12519..e661ddd6ab 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -69,6 +69,10 @@ typedef struct target_sigaltstack { #ifdef TARGET_ABI32 #define TARGET_ARCH_HAS_SETUP_FRAME +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 +#else +/* For sparc64, use of KA_RESTORER is mandatory. */ +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 #endif /* bit-flags */ diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 3bc023d281..23e1e761de 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -242,6 +242,12 @@ static void restore_fpu(struct target_siginfo_fpu *fpu, CPUSPARCState *env) } #ifdef TARGET_ARCH_HAS_SETUP_FRAME +static void install_sigtramp(uint32_t *tramp, int syscall) +{ + __put_user(0x82102000u + syscall, &tramp[0]); /* mov syscall, %g1 */ + __put_user(0x91d02010u, &tramp[1]); /* t 0x10 */ +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUSPARCState *env) { @@ -291,13 +297,9 @@ void setup_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = sf_addr + - offsetof(struct target_signal_frame, insns) - 2 * 4; - - /* mov __NR_sigreturn, %g1 */ - __put_user(0x821020d8u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_sigreturn); + env->regwptr[WREG_O7] = default_sigreturn; } unlock_user(sf, sf_addr, sf_size); } @@ -358,13 +360,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->ka_restorer) { env->regwptr[WREG_O7] = ka->ka_restorer; } else { - env->regwptr[WREG_O7] = - sf_addr + offsetof(struct target_rt_signal_frame, insns) - 2 * 4; - - /* mov __NR_rt_sigreturn, %g1 */ - __put_user(0x82102065u, &sf->insns[0]); - /* t 0x10 */ - __put_user(0x91d02010u, &sf->insns[1]); + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(sf->insns, TARGET_NR_rt_sigreturn); + env->regwptr[WREG_O7] = default_rt_sigreturn; } #else env->regwptr[WREG_O7] = ka->ka_restorer; @@ -775,4 +773,18 @@ do_sigsegv: unlock_user_struct(ucp, ucp_addr, 1); force_sig(TARGET_SIGSEGV); } +#else +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 2 * 8, 0); + assert(tramp != NULL); + + default_sigreturn = sigtramp_page; + install_sigtramp(tramp, TARGET_NR_sigreturn); + + default_rt_sigreturn = sigtramp_page + 8; + install_sigtramp(tramp + 2, TARGET_NR_rt_sigreturn); + + unlock_user(tramp, sigtramp_page, 2 * 8); +} #endif From patchwork Fri Sep 24 16:59:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514601 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1689390jao; Fri, 24 Sep 2021 10:16:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj3UfcdQ3/adcvrPoTGqBO2nj5ydxrlcRvjgv/7VBXx1JmZX4/xQou7b8TamgcmLKR2Eg6 X-Received: by 2002:a37:62ca:: with SMTP id w193mr11817987qkb.137.1632503784870; Fri, 24 Sep 2021 10:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503784; cv=none; d=google.com; s=arc-20160816; b=ae8QjSJvTNj3AQh3fzugJFsThcahCEOzuXqoggH4Icy5VzDuh6XeMUotigEBAMqD3s OV3q514Vy/XWMfpXbmOh0XFdxxBjvwiI9WOe8EuZHgKF0FA4EgF/nHTzPVwV2OkqqA+u H76h3hhPilCwrDWB+eDYvhfwnN37pJssvy+NHTpfo/+l3Hmhgpm6F/6ZCQ0SYu8XCf7p /HyY0JWomWzTwZlFeSZKO31zm2absfPd2m/lARKla/ZC3cIlKJN+C7BXaDImDgV6+ECW fLNzy8ZANyGBvL+BxLqFpuV9lKkYmOzaubdqkb2PhuTH8t30oWOWKHFuAapNqgY++zv3 AfDw== 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=TpDW54Nw8YhHP+9jPj0cxZwWHyAWvFzhUjsYMPCYrAg=; b=KReTgZfyto8C8BueJtBbW7h2/ts3/0IRigJek3QAjAhSK3tMOQX0mAOIjwcQ49YdUT JC6gordItkMLAbtZXlCHurNUHk1VgEmmLbsYzonN3Ygm8mMZIf553ve7TTeZkPOZfv6o HMAvnaQb476mh6HLg/cxwmPXTe9U15jhidb5VFvG/ChccgGs6H1ege8GxfgvbbRw/PLa qDSMp3JVj/glFzALNeLCzF7RJEqtAioIVaqPbee2X8fZv+6cyFEcDqEOfiDXo5asi79z TKoEVwEIwFNySbAjZ9Od5lmQIln1f5ilscb3PxUePAyaTQhgFuJiAr78FkdkkcFBm+v6 cfzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xIMJ5M1D; 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 f15si958743qtg.186.2021.09.24.10.16.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:16: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=xIMJ5M1D; 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]:41160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTooC-0006Pt-3I for patch@linaro.org; Fri, 24 Sep 2021 13:16:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYA-00031g-S3 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:34472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY8-00076p-Q1 for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: by mail-qk1-x733.google.com with SMTP id i132so29018409qke.1 for ; Fri, 24 Sep 2021 09:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TpDW54Nw8YhHP+9jPj0cxZwWHyAWvFzhUjsYMPCYrAg=; b=xIMJ5M1DSDv0410bZB+xxE1p8qx9lod20d293kf53rxCA5EjFT3njJJ95x8bvOHK2A xN3BbstZM5SxiHB11evg/HZoLjt1Kpvi0zjEdVFrW7D2qyVzfc7atyWLpvbefPq5g13K 4HAdMCEZyKGwVhzsFZtowPkzJ11cgviLwdHGvkOa9A3YsWVHRbg5JOhNBQk7UP71+cfh C9yLZ+Mio/Iy9Q+t74rf9LkTNxE7cAeiCdcxtm1TJn5cGeB44VeRLzKNvswjHP2oyjp8 V81I//bgL0v96XaDVV8VrsdjvIAkv4Okwyro/IdIRhrEvgLiyGb3p9h1Q+J9oH6palB2 d4eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TpDW54Nw8YhHP+9jPj0cxZwWHyAWvFzhUjsYMPCYrAg=; b=MfuP75aw2rSNhLPWB4K1umNJw9vle2b2REmh11WwNL1dyOwsfXzD8igd34TY9Bl+7u SoT2GgPmjo01WUACW1o+42+uVNHxzcKKe7SeQBBk1VmyAU5TBW4nKn2OrTs8OAPaWuH5 VWw66wqUFSRbDB0glJcxhr6LoSjGhT1EQvbd0aYViVdCrTobQSAQH0dWfwxMI+tVGy28 8YDlrBbavgqfl2nNjdpa9GjV2euMSwt5B/zaJw4FtELoh0jBz4OrHJRi9ETqUdvkQtON ov9fhNiRX5IJAgt92AmXdienghuYlLHDPcAASSwsFsTKOSFs6BTd3sgKLaVTuGND2T/c v/Lw== X-Gm-Message-State: AOAM530IRy5OLygDolUywo2ohZLHQarPsdrdqkw/JdPhnMYj8m1OV9dJ MfOoJW4FFzzZT/qZVBuqqQoIEIywqDw2HA== X-Received: by 2002:a37:f613:: with SMTP id y19mr11365789qkj.524.1632502787902; Fri, 24 Sep 2021 09:59:47 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 26/27] linux-user/xtensa: Implement setup_sigtramp Date: Fri, 24 Sep 2021 12:59:25 -0400 Message-Id: <20210924165926.752809-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, Max Filippov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create and record the rt signal trampoline. Use it when the guest does not use SA_RESTORER. Reviewed-by: Max Filippov Signed-off-by: Richard Henderson --- linux-user/xtensa/target_signal.h | 2 ++ linux-user/xtensa/signal.c | 56 ++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 20 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/linux-user/xtensa/target_signal.h b/linux-user/xtensa/target_signal.h index c60bf656f6..1c7ee73154 100644 --- a/linux-user/xtensa/target_signal.h +++ b/linux-user/xtensa/target_signal.h @@ -20,4 +20,6 @@ typedef struct target_sigaltstack { #include "../generic/signal.h" +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + #endif diff --git a/linux-user/xtensa/signal.c b/linux-user/xtensa/signal.c index 7a3bfb92ca..81572a5fc7 100644 --- a/linux-user/xtensa/signal.c +++ b/linux-user/xtensa/signal.c @@ -128,6 +128,29 @@ static int setup_sigcontext(struct target_rt_sigframe *frame, return 1; } +static void install_sigtramp(uint8_t *tramp) +{ +#ifdef TARGET_WORDS_BIGENDIAN + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0x0a, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x05, &tramp[4]); + __put_user(0x00, &tramp[5]); +#else + /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ + __put_user(0x22, &tramp[0]); + __put_user(0xa0, &tramp[1]); + __put_user(TARGET_NR_rt_sigreturn, &tramp[2]); + /* Generate instruction: SYSCALL */ + __put_user(0x00, &tramp[3]); + __put_user(0x50, &tramp[4]); + __put_user(0x00, &tramp[5]); +#endif +} + void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUXtensaState *env) @@ -164,26 +187,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, if (ka->sa_flags & TARGET_SA_RESTORER) { ra = ka->sa_restorer; } else { - ra = frame_addr + offsetof(struct target_rt_sigframe, retcode); -#ifdef TARGET_WORDS_BIGENDIAN - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0x0a, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x05, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#else - /* Generate instruction: MOVI a2, __NR_rt_sigreturn */ - __put_user(0x22, &frame->retcode[0]); - __put_user(0xa0, &frame->retcode[1]); - __put_user(TARGET_NR_rt_sigreturn, &frame->retcode[2]); - /* Generate instruction: SYSCALL */ - __put_user(0x00, &frame->retcode[3]); - __put_user(0x50, &frame->retcode[4]); - __put_user(0x00, &frame->retcode[5]); -#endif + /* Not used, but retain for ABI compatibility. */ + install_sigtramp(frame->retcode); + ra = default_rt_sigreturn; } memset(env->regs, 0, sizeof(env->regs)); env->pc = ka->_sa_handler; @@ -264,3 +270,13 @@ badframe: force_sig(TARGET_SIGSEGV); return -TARGET_QEMU_ESIGRETURN; } + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint8_t *tramp = lock_user(VERIFY_WRITE, sigtramp_page, 6, 0); + assert(tramp != NULL); + + default_rt_sigreturn = sigtramp_page; + install_sigtramp(tramp); + unlock_user(tramp, sigtramp_page, 6); +} From patchwork Fri Sep 24 16:59:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514600 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1687420jao; Fri, 24 Sep 2021 10:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVV7Ikna+SsOQ3KO8BnluseiXjSmW1HBklBtSKmBaB8KocncwmxcNoAAAPx5flxSJ8btnC X-Received: by 2002:ac8:1e0e:: with SMTP id n14mr5463126qtl.59.1632503658304; Fri, 24 Sep 2021 10:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632503658; cv=none; d=google.com; s=arc-20160816; b=WwDZzKJ3pNcwhS+j3WuS8p0kdI0k5RKv4DlWpWkGPScqb5tZ3Jtq24czmao0zMRRL8 /X/mSO7L0gb5W88d02ULIrzkIRaTE2Y91kMp+3Tg3Kd0xh98I2q28EQtNQWDiZcdtsZQ VxJCqsedUznPW9tjcdfrNLdP6/NkH91m14izIg5YrABrPhH+jhx3w8Hh//u6xSWaiU6y U2t+wwYyfROjaFmr2zZqUg/2t76vF8TaUSui9WsYj+Lht8Q+uTgF52mEs8xxUXOYcrqW ZKdB7+wToD1EeBoSlVuodqNODU1hkOxa3OQaTZhOPoYh7pqKpumGW0gVi1RCI4OzVsFZ UCTw== 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=6YUMG9BLv2uEtpi53x6iY+Kj4bYcd7Wn5Zd273lBD+w=; b=YSfBGsId/9g3afdHDr7pfu/8XHKpL30xaF9tmHGeLHq5eWLEf3zVqU5ktSnm9+4JP/ M0R8UfEkRQAbjSIrCcLdCTOikWPqITifWTO+10sO5qTOx1so3nyfdJdMLTMZ+UXYSwVk PeFHgBFnbC9PFWz1bLBP2ss0FX5m9PoTtqtolg7gvljut6iSeI4GGIwpB3fBqyCr2tbX RbY8eQuN4PqYYk6jdrNDcbIcO8gECNjEo6uuDreMkhglGUZ7QjvwRqlEGobpu2F7Vi4O fHRd9UOkdnb439uOGNowkHDTj+vMsck2mViCshPONylc8rcbqg5JKX+JN3ou+b8OwhY6 mwJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nUkAvkf4; 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 o69si6634658qvo.170.2021.09.24.10.14.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 10:14:18 -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=nUkAvkf4; 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]:35722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTom9-0002q7-RB for patch@linaro.org; Fri, 24 Sep 2021 13:14:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mToYB-00033C-Dv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:51 -0400 Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:33402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mToY9-00077M-Hv for qemu-devel@nongnu.org; Fri, 24 Sep 2021 12:59:50 -0400 Received: by mail-qv1-xf2f.google.com with SMTP id a9so6724948qvf.0 for ; Fri, 24 Sep 2021 09:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6YUMG9BLv2uEtpi53x6iY+Kj4bYcd7Wn5Zd273lBD+w=; b=nUkAvkf43ZVpU71HQ49DEBhet9R30v4JNPpMuXHZjlitnrmgEgjbmbNLWt3gtIFMm0 MMFemC5bEeVaP/4v+iOr7hIw+J5C71ggsaZzc3F8TToMdWa/Vf2MN9+0Kej1xdUhFNBg ZfWdgECkhnFRymiw9sT0EZdKh7dvI5VwCSXpQstJW+EJmE1twPPVq3QGPXRI8MUTGDxG p8uXJr6rvbZePRvaNgo4FjyxgpcLPce2VmTMkbZOZsRHkCNPByEoqebO3mXWYyBFibu+ u+gS1tWWkoItVV5CbDk0HnQJkwCV05qTVr7KNUmfy9XiN7c0XDasJSsPC3Fa6AzD6pKG 7NUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6YUMG9BLv2uEtpi53x6iY+Kj4bYcd7Wn5Zd273lBD+w=; b=FSCsVpXU6SkQS43HS9kUMs/FHDHavEV+7nHwgQE1NqU0MKgPoTn9W4CCTZ7XecX8KE Oz5xGiV+9UxvB2WUzqIHUyzZTUPFUvVjzZDQWI+dKqpSFTRmJGHCtYqx1Cj6xO1qLovK aWbDm+DDSfccSYr0lJN2lSzeaG/d/tYmgJ0fs43tZK49uQuBEkzX87Xbudr5aF2CZSvf gB8Ikw+7meoO6x7ibqGhD39D0fMHtlfUm6dmqDFnyLWVByBwsgIQZ0CA9l8/GfOIlUvj KiXu73VOe0yqH3LjIWJm02jGAlhDumiIX4STvxVCFkIVK9pGMvQmoV5l/3qQGdPtkWBr DOoQ== X-Gm-Message-State: AOAM532KQYwR53Kt759PXKEvvh4QtRCnTejNJZA0b9IaOWltAmgWsi2u 2Qx8X4sC3bzbe4LP0T739Z+0G1ExFgtLfA== X-Received: by 2002:a05:6214:13e3:: with SMTP id ch3mr10927371qvb.35.1632502788632; Fri, 24 Sep 2021 09:59:48 -0700 (PDT) Received: from localhost.localdomain (cpe-24-74-129-96.carolina.res.rr.com. [24.74.129.96]) by smtp.gmail.com with ESMTPSA id r13sm7141104qkk.73.2021.09.24.09.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:59:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 27/27] linux-user: Remove default for TARGET_ARCH_HAS_SIGTRAMP_PAGE Date: Fri, 24 Sep 2021 12:59:26 -0400 Message-Id: <20210924165926.752809-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210924165926.752809-1-richard.henderson@linaro.org> References: <20210924165926.752809-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 7b3a91b3ed..f6a4f8f489 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -30,10 +30,6 @@ #undef ELF_ARCH #endif -#ifndef TARGET_ARCH_HAS_SIGTRAMP_PAGE -#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 0 -#endif - #define ELF_OSABI ELFOSABI_SYSV /* from personality.h */