From patchwork Tue Feb 8 07:12:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 540751 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp319874imo; Tue, 8 Feb 2022 00:47:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZWSaUW9mMxTLAtTeIdvfp8ECo7VpXM9l8vyjeEv3opPvpmTE7wlX8TChw5WMT5TqWi7N0 X-Received: by 2002:a05:6214:5195:: with SMTP id kl21mr2264957qvb.69.1644310033237; Tue, 08 Feb 2022 00:47:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644310033; cv=none; d=google.com; s=arc-20160816; b=Izy5rz+hUVSCm/FEHwtmsjfRXqpHgJLsvkhjBufHGkgQJgAYbDTCQzk2CC6FVc02IF 3sjm11ZDgLTBSMt1qKz1F3R4wmwgsRrVCJ6ZE3TDmwtpud5DWhATXupHiQs+3aO5FaW6 HGvcq4JzM6Y295Qd/Shx2/zEPSDC2eY0clRU3MG3Xckiapz4L8iRpBnG7TfoMoqsQNGK VTKV7VSq47t48XYIhvOcdjxV1MKA7uADb+eAEM5h1uA2q47dSEHWOPXMBnzlk4xT4ZlN iLfmg3yK+y582R/GZyvxMEjOYt2dWLmU8Vf4H9TTayULFvwznP+gyeJwbU7vN/LBf0Hx +DvQ== 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=Uh058XUts6HPkXe97baHsy8/Ac7JrSk6cgbCWbIo3VY=; b=GhP0KiTq2x6rydir9rhn0zCfOIkbUBrhiKqND19X590djG5BGtcrS5+lfPk2BLcj08 HYvzKolF80C7mVqtxFv1pcoKjMlCvkis6BtLAO1CEYykqId9TD75FG8WgDqZRyuDAWs+ kXXpqiGfeyo3aLEeR7KONu5jZByCHahWRFDVYjXRERUQfqw5ucGtVsK6JMMDfZTJNgRY FXW9fWUS8lBSSGRpFfXv81oy3PggcfuAbT8AmLCbOAuvXn+HwSYEce2l+WFlbsqdm6IN +ADzvqSOqpu+jiHat1hV6nC8lHmM2YAHV7H9Xa2PLiOQ5yHuBqNejsrvgEIC8dIZR/+Y HA9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znbDpHVW; 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=pass (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 b23si2702081qkg.95.2022.02.08.00.47.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 00:47:13 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=znbDpHVW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHM9Y-0003Zz-IB for patch@linaro.org; Tue, 08 Feb 2022 03:47:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKgD-00079d-6J for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:49 -0500 Received: from [2607:f8b0:4864:20::102b] (port=42522 helo=mail-pj1-x102b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKg9-0000RK-Rz for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:47 -0500 Received: by mail-pj1-x102b.google.com with SMTP id my12-20020a17090b4c8c00b001b528ba1cd7so1784104pjb.1 for ; Mon, 07 Feb 2022 23:12:45 -0800 (PST) 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=Uh058XUts6HPkXe97baHsy8/Ac7JrSk6cgbCWbIo3VY=; b=znbDpHVWPdPeOFwQq63atb1VJMFLiq6Njizswlg8axXVYQLQiNuF2D6I33hRhZm0u4 AgWLKR0vHpq+HS3oqcakBvnl8ig4aThIjkhUetzqKKeKR7JWejK27LE3Oj8BR8B6woAD B77OfgJuYEG8Xkh9DEW80tQvxsYpajsdbLqKALNXXFBuqyl3WJMxxVaI5XqnlJh9acap EcjNKDrhUZr7OaSGCxwKPsi2Vg0Ug+a6Jeow10tCJZH6GWl9ySF2bTCaGru6WNtOvYSH 91TA5EM7IMA22WEcufSNsT/bd5yR+rv1r4DW68S5MjUvSPEU7qlCRic7TXPrUuHFINed Gowg== 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=Uh058XUts6HPkXe97baHsy8/Ac7JrSk6cgbCWbIo3VY=; b=6qihhCiUBVNBuC0Q314KPZJGqSRRb5Q5UWGMSMzCkz0ryGzinXRT+dVh8N0p9BC+3K dIIHpGoriCkCb5BnnGXHBH0Mw3Yv4cRLvRFK1bGVqzW5kv8nIz10jING/QfcHqv8aMOq GSZy0wsdCA8JGbeP5CNYFWnN89iKR2F7V7UsRF3OEn/vkfABulCWzpOkWvOHE4oDMNOn q+PE8qRmGaItjCZBMckOngSiWiknGMIBommnJuUUAk+AebHsQE4EpVk1ofTD1ZegKlqE BRhcOVcxxCLBaocaLlwGrDEpvQYL3YvySBKO9R4F+A8yDMHOHlOKWXA4f4DeqAHj+jBq TWew== X-Gm-Message-State: AOAM530e8A108vffGHnzkKVYDG3GOpvERHXJnTSnG+BR6JHxyyy1bPEw TvVR5vuWht2Ejs0LmHqbOKF6axLLwz4gEA== X-Received: by 2002:a17:90a:d343:: with SMTP id i3mr2961862pjx.104.1644304364242; Mon, 07 Feb 2022 23:12:44 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id b12sm13908088pfm.154.2022.02.07.23.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:12:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/5] common-user/host/sparc64: Fix safe_syscall_base Date: Tue, 8 Feb 2022 18:12:33 +1100 Message-Id: <20220208071237.319844-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071237.319844-1-richard.henderson@linaro.org> References: <20220208071237.319844-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the "retl" instead of "ret" instruction alias, since we do not allocate a register window in this function. Fix the offset to the first stacked parameter, which lies beyond the register window save area. Fixes: 95c021dac835 ("linux-user/host/sparc64: Add safe-syscall.inc.S") Signed-off-by: Richard Henderson --- common-user/host/sparc64/safe-syscall.inc.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common-user/host/sparc64/safe-syscall.inc.S b/common-user/host/sparc64/safe-syscall.inc.S index a2f2b9c967..c7be8f2d25 100644 --- a/common-user/host/sparc64/safe-syscall.inc.S +++ b/common-user/host/sparc64/safe-syscall.inc.S @@ -24,7 +24,8 @@ .type safe_syscall_end, @function #define STACK_BIAS 2047 -#define PARAM(N) STACK_BIAS + N*8 +#define WINDOW_SIZE 16 * 8 +#define PARAM(N) STACK_BIAS + WINDOW_SIZE + N * 8 /* * This is the entry point for making a system call. The calling @@ -74,7 +75,7 @@ safe_syscall_end: /* code path for having successfully executed the syscall */ bcs,pn %xcc, 1f nop - ret + retl nop /* code path when we didn't execute the syscall */ From patchwork Tue Feb 8 07:12:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 540744 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp294826imo; Mon, 7 Feb 2022 23:58:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwp7BDqAfnF7+IELqUn5bR7AbGh+3YnaXCusrCaQGDUmfI15Ld6hT1D9YuEZKqMyjmsXBxO X-Received: by 2002:ad4:5744:: with SMTP id q4mr2337439qvx.70.1644307122260; Mon, 07 Feb 2022 23:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644307122; cv=none; d=google.com; s=arc-20160816; b=geINWyBYifGCAffeHmaZzBDCt1+PVYNu5rVXQavnG54ZzhH3/rwaVDLIJfgNyl/XLg tV0AWKIraA9AngCIyqnjrniogBtJuo1NGcChWKAx2pJMfCkWGn4arK45edy0kqwhnxOK 2pchP/VMmvvWw97DBZ0AWXAv6wgvx+rIkO9UmY/ME0zBwMKWztZM59TLtSF6x3q4iJJQ OjKFkQlMWD4wSox08Vak4mMikbEfam4qqJ9tj2dlHmDv9bPk2+V92wQu/82vSNvPmGI+ I62HMmuDkgEab8as/nPdjXpr5TsSFTbYHP86vfg/3jA/ogTUB3u6JUqVOn6HoMbtpTG/ tALA== 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=3v2O+lFaW0GAttdgH6e1He7KUEe11OJUzhNwIeGxPJg=; b=duXzdwL86sbTZHM4veS4+Vi1MH9BKfXBOruLmcCcrPcXE+y6UGzWK3JKMwFhdbIct7 0wQaYGPAAmj3Gn+d8ccoDXxFwjYxT8Avs2H9f5Hso73Jv5SeK5DIDlc+CtMKnnmcArH5 0fC2gXJRD3YaTeiKgGQiRiOSB1RKlfukDFldTQ5a+CZsSAvVldwAY9sIn2+4UhBGeToE RWuCYSdGsP9YoM1uWh+bBlHsHHcFXnQP5usk26MpkiI5epXq9emuIEAo2X42vtXtBhLk ApY+3tXW/fIt1nUGmJdtQw/A2/DBADtK1DYXvkF+YHn72Inr+v+M0Qwu+DX1PRqafuR/ Dpiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rbmLE1De; 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=pass (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 bp38si2995258qkb.293.2022.02.07.23.58.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Feb 2022 23:58:42 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=rbmLE1De; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLOb-0007WO-N1 for patch@linaro.org; Tue, 08 Feb 2022 02:58:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKgE-0007AV-40 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:50 -0500 Received: from [2607:f8b0:4864:20::429] (port=35406 helo=mail-pf1-x429.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKgB-0000Rh-KY for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:49 -0500 Received: by mail-pf1-x429.google.com with SMTP id z35so295757pfw.2 for ; Mon, 07 Feb 2022 23:12:47 -0800 (PST) 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=3v2O+lFaW0GAttdgH6e1He7KUEe11OJUzhNwIeGxPJg=; b=rbmLE1DeEt4/VhnOv4yh0k9zCl4sPHTTJoWYS4++PPtQSiG5rBH18I/ofn++ZR7Buc 7IpnU30g6mM74vaOwBh8KV4I8ES9peH0d4d08SCFL206SGhcdzsjNWOfaqfuOhsjHj0q SgQ0G/Iu+TQeZj3VNv5IsCSZrKxgsoNfkXKZu/tFKCZqkT+MbvKvAWRApuLWXJPF8hsW NHwWloXLNZ8BOoFv3K3iGwDqm2dV/Xo5rM8gwrnomFcRg8K8EQW1QOa+ZuFqFCAgyt+P drYqQ0FceJeoj+sAPHyc/cGyTUHZnpDBYUksQdaEosr2TQRFVlwYS0LFPhIVmP2aOOWg 3RBg== 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=3v2O+lFaW0GAttdgH6e1He7KUEe11OJUzhNwIeGxPJg=; b=l3fyCqIiiVNZvTAKXs39WeLmzRPKjgacvm/tME/kDNJrerxk5SxtypH6rQqlNBTb02 RCeQ7kfmOqL+lNS90ed14yeB9uTPQhW1tCnWGkiDZcu2ZFEHxme41Fm8WlSSgJaA252y YQlNXI5pDOiWwIWdc6UgrYSSW+N3TmFWaPDR6/lUBOKkR9xRKVoxCuqTb5bPnVaPMdeA FSQ/jMQpUnhlfykVpcd29DvEzsNrujHIZPPdzzNmF7IP742xVD5ZQtIwzzkLO4F2lRPT 1X4ZJVf7DQCViRriai9IsmbH92W9KMjg3eJMboM2qE3hhfDGYMalHFCY4OTSkNrIFUFF 10UA== X-Gm-Message-State: AOAM533iSVRfSdysyWRcGqW6aYEKK6AQDkZ/8RkEQY+zU90qLCeKCwIM 7HKdIuN66hxIt6yRoVVCzfxtwdGHRPynkA== X-Received: by 2002:a63:dd0f:: with SMTP id t15mr2474894pgg.12.1644304366206; Mon, 07 Feb 2022 23:12:46 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id b12sm13908088pfm.154.2022.02.07.23.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:12:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/5] linux-user: Introduce host_signal_mask Date: Tue, 8 Feb 2022 18:12:34 +1100 Message-Id: <20220208071237.319844-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071237.319844-1-richard.henderson@linaro.org> References: <20220208071237.319844-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::429 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not directly access the uc_sigmask member. This is preparation for a sparc64 fix. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- linux-user/include/host/aarch64/host-signal.h | 5 +++++ linux-user/include/host/alpha/host-signal.h | 5 +++++ linux-user/include/host/arm/host-signal.h | 5 +++++ linux-user/include/host/i386/host-signal.h | 5 +++++ .../include/host/loongarch64/host-signal.h | 5 +++++ linux-user/include/host/mips/host-signal.h | 5 +++++ linux-user/include/host/ppc/host-signal.h | 5 +++++ linux-user/include/host/riscv/host-signal.h | 5 +++++ linux-user/include/host/s390/host-signal.h | 5 +++++ linux-user/include/host/sparc/host-signal.h | 5 +++++ linux-user/include/host/x86_64/host-signal.h | 5 +++++ linux-user/signal.c | 18 ++++++++---------- 12 files changed, 63 insertions(+), 10 deletions(-) diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h index 9770b36dc1..76ab078069 100644 --- a/linux-user/include/host/aarch64/host-signal.h +++ b/linux-user/include/host/aarch64/host-signal.h @@ -40,6 +40,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.pc = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { struct _aarch64_ctx *hdr; diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/include/host/alpha/host-signal.h index f4c942948a..a44d670f2b 100644 --- a/linux-user/include/host/alpha/host-signal.h +++ b/linux-user/include/host/alpha/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.sc_pc = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t *pc = (uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include/host/arm/host-signal.h index 6c095773c0..bbeb4ffefb 100644 --- a/linux-user/include/host/arm/host-signal.h +++ b/linux-user/include/host/arm/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.arm_pc = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { /* diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/include/host/i386/host-signal.h index abe1ece5c9..fd36f06bda 100644 --- a/linux-user/include/host/i386/host-signal.h +++ b/linux-user/include/host/i386/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.gregs[REG_EIP] = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h index 7effa24251..a9dfe0c688 100644 --- a/linux-user/include/host/loongarch64/host-signal.h +++ b/linux-user/include/host/loongarch64/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.__pc = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/include/host/mips/host-signal.h index c666ed8c3f..ff840dd491 100644 --- a/linux-user/include/host/mips/host-signal.h +++ b/linux-user/include/host/mips/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.pc = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + #if defined(__misp16) || defined(__mips_micromips) #error "Unsupported encoding" #endif diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h index 1d8e658ff7..730a321d98 100644 --- a/linux-user/include/host/ppc/host-signal.h +++ b/linux-user/include/host/ppc/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.regs->nip = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.regs->trap != 0x400 diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/include/host/riscv/host-signal.h index a4f170efb0..aceae544f2 100644 --- a/linux-user/include/host/riscv/host-signal.h +++ b/linux-user/include/host/riscv/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.__gregs[REG_PC] = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { /* diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/include/host/s390/host-signal.h index a524f2ab00..e454cea54a 100644 --- a/linux-user/include/host/s390/host-signal.h +++ b/linux-user/include/host/s390/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.psw.addr = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint16_t *pinsn = (uint16_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h index 7342936071..158918f2ec 100644 --- a/linux-user/include/host/sparc/host-signal.h +++ b/linux-user/include/host/sparc/host-signal.h @@ -29,6 +29,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) #endif } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t insn = *(uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/include/host/x86_64/host-signal.h index c71d597eb2..d64d076625 100644 --- a/linux-user/include/host/x86_64/host-signal.h +++ b/linux-user/include/host/x86_64/host-signal.h @@ -20,6 +20,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) uc->uc_mcontext.gregs[REG_RIP] = pc; } +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe diff --git a/linux-user/signal.c b/linux-user/signal.c index 32854bb375..0c61459d4a 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -820,6 +820,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) int guest_sig; uintptr_t pc = 0; bool sync_sig = false; + void *sigmask = host_signal_mask(uc); /* * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special @@ -849,8 +850,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) if (info->si_code == SEGV_ACCERR && h2g_valid(host_addr)) { /* If this was a write to a TB protected page, restart. */ if (is_write && - handle_sigsegv_accerr_write(cpu, &uc->uc_sigmask, - pc, guest_addr)) { + handle_sigsegv_accerr_write(cpu, sigmask, pc, guest_addr)) { return; } @@ -865,10 +865,10 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) } } - sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + sigprocmask(SIG_SETMASK, sigmask, NULL); cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc); } else { - sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + sigprocmask(SIG_SETMASK, sigmask, NULL); if (info->si_code == BUS_ADRALN) { cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc); } @@ -909,17 +909,15 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) * now and it getting out to the main loop. Signals will be * unblocked again in process_pending_signals(). * - * WARNING: we cannot use sigfillset() here because the uc_sigmask + * WARNING: we cannot use sigfillset() here because the sigmask * field is a kernel sigset_t, which is much smaller than the * libc sigset_t which sigfillset() operates on. Using sigfillset() * would write 0xff bytes off the end of the structure and trash * data on the struct. - * We can't use sizeof(uc->uc_sigmask) either, because the libc - * headers define the struct field with the wrong (too large) type. */ - memset(&uc->uc_sigmask, 0xff, SIGSET_T_SIZE); - sigdelset(&uc->uc_sigmask, SIGSEGV); - sigdelset(&uc->uc_sigmask, SIGBUS); + memset(sigmask, 0xff, SIGSET_T_SIZE); + sigdelset(sigmask, SIGSEGV); + sigdelset(sigmask, SIGBUS); /* interrupt the virtual CPU as soon as possible */ cpu_exit(thread_cpu); From patchwork Tue Feb 8 07:12:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 540752 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp323772imo; Tue, 8 Feb 2022 00:55:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFPf6G3xKRnHqk0jCdiwAPva9Yt9kxMIBhaf6DaTE6Pc/xvZVhEK2s3n4rhYXYhE8E4i3k X-Received: by 2002:a05:622a:1a0b:: with SMTP id f11mr2279165qtb.329.1644310520776; Tue, 08 Feb 2022 00:55:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644310520; cv=none; d=google.com; s=arc-20160816; b=klxaAGyl15lPs+txftxJE/22Vii8jsIXYGzc9DXBbsPhiF/ig2aFzzE/lWbTb8wVox l5Ncy+Y0fS9w9zO0/L/yyTI31/ZvR8KF+r2XKJLTur++BD6nrKsuZpv5vKzvDDTKFm9v rZyaQVoX3QgGhcOiNjJl87DUbDWQC0M5sH5AlgFo17JAc6IkmpUnpaPSpdHZFZ4gDC4w zzi0etHCITml2AAGzWH5QV/zJHuj1fAcdoEi7QbbDjGnLJyZKwmYbO4vKRm75oPwD0G5 Ng4y3IqKHp6Hif3BBen9wKdVXUihUarLEw+jSnFoIXAKR7twHyMXL98SdjDtx4izkOhu oBaQ== 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=oHQ1OXiOIcQWGDrerT0s2CKiSSZ/T9A2Et8ZkjaMCfg=; b=wwRq9ixq61EVVVZk4rnu9c9M7ddqKM5QNooCcNZEABmrYpbOW0AZHJaygqJIH0IFle uc7K0VJ1khmCzvcPGLHcPEhPKZR5IgDtO/frrdKbAKffrjcVNHoA4SE5jcvToaCHD4Cj LP3uJHB5Ih0TSJvwOR4BXLnjuJ7wU2jRMhpA1qfIWFxL6W/CdNSOG7jxlF0A6YqZdaFO o4dloGgyIkXDmGNOzWyTqsolMZRWzZxrAhgUln1BZfOa9W0+0Fl6jFD8/+5GTwTUgfmR GYqFrwjEYyShEVU9paHppzu5/fzUwYFuBbFxIi0CYcOLx5H5ISjedl1pNs8OihGaSqMP SYRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JBRzzfce; 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=pass (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 y9si3053189qtw.560.2022.02.08.00.55.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 00:55:20 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=JBRzzfce; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHMHQ-0001YQ-8L for patch@linaro.org; Tue, 08 Feb 2022 03:55:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKgG-0007C0-EV for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:53 -0500 Received: from [2607:f8b0:4864:20::42a] (port=44837 helo=mail-pf1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKgD-0000S4-RG for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:52 -0500 Received: by mail-pf1-x42a.google.com with SMTP id n32so17342247pfv.11 for ; Mon, 07 Feb 2022 23:12:49 -0800 (PST) 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=oHQ1OXiOIcQWGDrerT0s2CKiSSZ/T9A2Et8ZkjaMCfg=; b=JBRzzfceKggQRZZCvfVQQ8rPbFK6LtMzL5voC6MBWOxdkTerigxmPYQ0Vk4y07YH53 BeKYSrPbcgj32ni+Ulgdf9tMbm1XBFFOCgFYqiF62iKVg8JjjMNxL+mRwPqRH53DGKsu MThlVWC6Oon/eHsXkU0fMbdIV3m0F2/h3k8F99FxA6caid0OVOooREteHCxbR8JPoiKT W5gZ8ZZD3jen4w9HreAmvcZqbJsyQdOT9kK4NIgZ+G1MA92hOb9XS3rFi/bhkuLUq8c6 E6xbcI/h3rK8ga0elbXzt3fIpOaoB92qa7QqlwVtVlNZZl7Wwx/hJcsGKDg4/bNevS+D xvxg== 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=oHQ1OXiOIcQWGDrerT0s2CKiSSZ/T9A2Et8ZkjaMCfg=; b=G8gSF8hy+GPuJGt4Lny258igYNaAS+/30Ryhf7hSBhGllXBt9o7jl3Mz3mt3jDUPVu IRnDnZLM/ORXETDFCmSVyqLAd4B9FcUUP0xYsXmChDk1q6tW3lzqSN5lz/NhfNjsNzO6 hQBiu1jynKJHMk0nK76UC+Y0QX786mhu6gj91k2lVwosz9z3M0frj0MCONrJI0usBBf7 vIg0EkzFJkze5AfXSr9Rl6YukMkfbBYKRIcUV18TMSq0w6deS8ILAcVC8wuu14WB/NiC Q/M3xThhJMRhSwCg83njcfOW9NQUHmkN30Odzr3ly6wNXaZ5qe1TA4gY+S2mtU3Wx4li fxBw== X-Gm-Message-State: AOAM532RK/OVOtWdwVqWsKvy8/CwjAePpCtNhNTTGKzaIT66OX7PW0un UZuOa22DkqMI8phvJTKKHMkqLM9lB77I+Q== X-Received: by 2002:a63:4408:: with SMTP id r8mr1166970pga.101.1644304368460; Mon, 07 Feb 2022 23:12:48 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id b12sm13908088pfm.154.2022.02.07.23.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:12:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/5] linux-user: Introduce host_sigcontext Date: Tue, 8 Feb 2022 18:12:35 +1100 Message-Id: <20220208071237.319844-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071237.319844-1-richard.henderson@linaro.org> References: <20220208071237.319844-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not directly access ucontext_t as the third signal parameter. This is preparation for a sparc64 fix. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- linux-user/include/host/aarch64/host-signal.h | 13 ++++++++----- linux-user/include/host/alpha/host-signal.h | 11 +++++++---- linux-user/include/host/arm/host-signal.h | 11 +++++++---- linux-user/include/host/i386/host-signal.h | 11 +++++++---- linux-user/include/host/loongarch64/host-signal.h | 11 +++++++---- linux-user/include/host/mips/host-signal.h | 11 +++++++---- linux-user/include/host/ppc/host-signal.h | 11 +++++++---- linux-user/include/host/riscv/host-signal.h | 11 +++++++---- linux-user/include/host/s390/host-signal.h | 11 +++++++---- linux-user/include/host/sparc/host-signal.h | 11 +++++++---- linux-user/include/host/x86_64/host-signal.h | 11 +++++++---- linux-user/signal.c | 4 ++-- 12 files changed, 80 insertions(+), 47 deletions(-) diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h index 76ab078069..be079684a2 100644 --- a/linux-user/include/host/aarch64/host-signal.h +++ b/linux-user/include/host/aarch64/host-signal.h @@ -11,6 +11,9 @@ #ifndef AARCH64_HOST_SIGNAL_H #define AARCH64_HOST_SIGNAL_H +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + /* Pre-3.16 kernel headers don't have these, so provide fallback definitions */ #ifndef ESR_MAGIC #define ESR_MAGIC 0x45535201 @@ -20,7 +23,7 @@ struct esr_context { }; #endif -static inline struct _aarch64_ctx *first_ctx(ucontext_t *uc) +static inline struct _aarch64_ctx *first_ctx(host_sigcontext *uc) { return (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved; } @@ -30,22 +33,22 @@ static inline struct _aarch64_ctx *next_ctx(struct _aarch64_ctx *hdr) return (struct _aarch64_ctx *)((char *)hdr + hdr->size); } -static inline uintptr_t host_signal_pc(ucontext_t *uc) +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.pc; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.pc = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { struct _aarch64_ctx *hdr; uint32_t insn; diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/include/host/alpha/host-signal.h index a44d670f2b..4f9e2abc4b 100644 --- a/linux-user/include/host/alpha/host-signal.h +++ b/linux-user/include/host/alpha/host-signal.h @@ -11,22 +11,25 @@ #ifndef ALPHA_HOST_SIGNAL_H #define ALPHA_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.sc_pc; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.sc_pc = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint32_t *pc = (uint32_t *)host_signal_pc(uc); uint32_t insn = *pc; diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include/host/arm/host-signal.h index bbeb4ffefb..faba496d24 100644 --- a/linux-user/include/host/arm/host-signal.h +++ b/linux-user/include/host/arm/host-signal.h @@ -11,22 +11,25 @@ #ifndef ARM_HOST_SIGNAL_H #define ARM_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.arm_pc; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.arm_pc = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { /* * In the FSR, bit 11 is WnR, assuming a v6 or diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/include/host/i386/host-signal.h index fd36f06bda..e2b64f077f 100644 --- a/linux-user/include/host/i386/host-signal.h +++ b/linux-user/include/host/i386/host-signal.h @@ -11,22 +11,25 @@ #ifndef I386_HOST_SIGNAL_H #define I386_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_EIP]; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.gregs[REG_EIP] = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h index a9dfe0c688..d33c3fc03e 100644 --- a/linux-user/include/host/loongarch64/host-signal.h +++ b/linux-user/include/host/loongarch64/host-signal.h @@ -11,22 +11,25 @@ #ifndef LOONGARCH64_HOST_SIGNAL_H #define LOONGARCH64_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.__pc; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.__pc = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc); uint32_t insn = pinsn[0]; diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/include/host/mips/host-signal.h index ff840dd491..0dbc5cecfd 100644 --- a/linux-user/include/host/mips/host-signal.h +++ b/linux-user/include/host/mips/host-signal.h @@ -11,17 +11,20 @@ #ifndef MIPS_HOST_SIGNAL_H #define MIPS_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.pc; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.pc = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } @@ -30,7 +33,7 @@ static inline void *host_signal_mask(ucontext_t *uc) #error "Unsupported encoding" #endif -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint32_t insn = *(uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h index 730a321d98..b80384d135 100644 --- a/linux-user/include/host/ppc/host-signal.h +++ b/linux-user/include/host/ppc/host-signal.h @@ -11,22 +11,25 @@ #ifndef PPC_HOST_SIGNAL_H #define PPC_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.regs->nip; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.regs->nip = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { return uc->uc_mcontext.regs->trap != 0x400 && (uc->uc_mcontext.regs->dsisr & 0x02000000); diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/include/host/riscv/host-signal.h index aceae544f2..decacb2325 100644 --- a/linux-user/include/host/riscv/host-signal.h +++ b/linux-user/include/host/riscv/host-signal.h @@ -11,22 +11,25 @@ #ifndef RISCV_HOST_SIGNAL_H #define RISCV_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.__gregs[REG_PC]; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.__gregs[REG_PC] = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { /* * Detect store by reading the instruction at the program counter. diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/include/host/s390/host-signal.h index e454cea54a..6f191e64d7 100644 --- a/linux-user/include/host/s390/host-signal.h +++ b/linux-user/include/host/s390/host-signal.h @@ -11,22 +11,25 @@ #ifndef S390_HOST_SIGNAL_H #define S390_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.psw.addr; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.psw.addr = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint16_t *pinsn = (uint16_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h index 158918f2ec..871b6bb269 100644 --- a/linux-user/include/host/sparc/host-signal.h +++ b/linux-user/include/host/sparc/host-signal.h @@ -11,7 +11,10 @@ #ifndef SPARC_HOST_SIGNAL_H #define SPARC_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { #ifdef __arch64__ return uc->uc_mcontext.mc_gregs[MC_PC]; @@ -20,7 +23,7 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) #endif } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { #ifdef __arch64__ uc->uc_mcontext.mc_gregs[MC_PC] = pc; @@ -29,12 +32,12 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) #endif } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint32_t insn = *(uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/include/host/x86_64/host-signal.h index d64d076625..5a7627fedc 100644 --- a/linux-user/include/host/x86_64/host-signal.h +++ b/linux-user/include/host/x86_64/host-signal.h @@ -10,22 +10,25 @@ #ifndef X86_64_HOST_SIGNAL_H #define X86_64_HOST_SIGNAL_H -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_RIP]; } -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.gregs[REG_RIP] = pc; } -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); diff --git a/linux-user/signal.c b/linux-user/signal.c index 0c61459d4a..27a0ff30e9 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -800,7 +800,7 @@ void queue_signal(CPUArchState *env, int sig, int si_type, /* Adjust the signal context to rewind out of safe-syscall if we're in it */ static inline void rewind_if_in_safe_syscall(void *puc) { - ucontext_t *uc = (ucontext_t *)puc; + host_sigcontext *uc = (host_sigcontext *)puc; uintptr_t pcreg = host_signal_pc(uc); if (pcreg > (uintptr_t)safe_syscall_start @@ -815,7 +815,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) CPUState *cpu = env_cpu(env); TaskState *ts = cpu->opaque; target_siginfo_t tinfo; - ucontext_t *uc = puc; + host_sigcontext *uc = puc; struct emulated_sigtable *k; int guest_sig; uintptr_t pc = 0; From patchwork Tue Feb 8 07:12:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 540747 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp303475imo; Tue, 8 Feb 2022 00:13:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJymjsKnzflJUAkLdBSBsjUh1+SZAnHBBE91QDsd4hl6kyexht7o5ojs/aJ+rrP+z+9NzISi X-Received: by 2002:a05:620a:210b:: with SMTP id l11mr1968922qkl.201.1644308025210; Tue, 08 Feb 2022 00:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644308025; cv=none; d=google.com; s=arc-20160816; b=vJYBySVwTN79yzbOENPaDk6JRyyvRcwmEK/fwvZuOGQpQq6/8BPa9wQyCCgMAXwgsz pKZ0SWdFtuuI51YDiQTkjTm3dxAYh2u7R3TZaQlKXeEzC4c8mxHAxLbgd+vdKY5crcX7 AQcBwhcEKHqWMN0V4XXRPhFYH6VQm+WTyQ79MOEVksc1RZJklqmoKlbPF0TrSf/hFcaQ q4TsyCIRvYJHIvXiaUiPolRPtl0xX1dNgIK6EffM1CUvVtCyu3fp/3mo6a8N3cMVSQ87 sily+CELXBy9YPt+tvQ/OmTzto55SviAWalt2s0t14K6TwlX0FpyQ7pwDxLSfM7rV5wn gGvQ== 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=FJuLwgpIKS69h636IRXxH6OktXJuo/SfsuMoxMe201g=; b=ZBqMVTGmlgGfl5eSNHPAry93VOJjGgcdCNlIu4xbel47SRTCd/ixgTbB3DefYUb2cs h8if12K+DVXGKnsxuA/gk2THFmQgC0QDkpOqC1iD/cBTft8ca0NoJcX3+njxStPVjFXd wTOhewHdlQJe5s9PixjUy0NjDId2tjvBirJgQf36BNT6i5RgYYZn/WXN2x6rY2EiizSn YVtYl5XUOfPKs7gzr9Xu88mhvvsmSPMCOT6Qyq/0gRhNeR8PAEz3kk6aQ2ghoSwELe2D QdJqquRkkwPVdpluM/Se5ayUlbkduppXNf0LYgSm2n+3QpmXgifidm1UqipV7/wOGkmu cxnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o/HokwXX"; 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=pass (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 bm36si3211799qkb.605.2022.02.08.00.13.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 00:13:45 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b="o/HokwXX"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLdA-0005Y5-Fv for patch@linaro.org; Tue, 08 Feb 2022 03:13:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKgI-0007Cp-3e for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:54 -0500 Received: from [2607:f8b0:4864:20::435] (port=41713 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKgG-0000SR-0Q for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:53 -0500 Received: by mail-pf1-x435.google.com with SMTP id i30so17339953pfk.8 for ; Mon, 07 Feb 2022 23:12:51 -0800 (PST) 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=FJuLwgpIKS69h636IRXxH6OktXJuo/SfsuMoxMe201g=; b=o/HokwXXisnt0GaK7ZBW1ZOX/tBQtAq9JGlorXjLjJUYTHNmT00tsgH2Y0jhfZtNHR 6henEikK3JHnsbkwGCNUNJxqVSiqj1SEvLYRld0peYz3YliUcDy3vxOKiuyZus7i5gqS zU4tI04Jb75YsHmDbe8CI++hlIyDcWSlp3S9ZEi5oAVH6To4nmF93hXd3ElfenZmjA+/ KC6tHt1ZhW51TSBBoYE79pwm/DW4Oai8zpRbYDS/IfU7n7JrBuW6aH8WJdEHeFLX40DN ct+P14c2wBTYqaOFu8M4fjwt/CGRxdSCnpl7/DuEkx6NIjarpyWVz1B05Qjto6EpvGTW 0+Ig== 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=FJuLwgpIKS69h636IRXxH6OktXJuo/SfsuMoxMe201g=; b=bHb/t6YU395DfThckp0W8hTbTs8offmzfd7aE2/XoVB347tLG0Sr9nh+bYDy/sDrM4 eoeDBxX4t5ulww2LJQXBy7wNd/DDvYprfWlHyBnNfpIrBx3r2P+LjhqTOGSwqpz7qsJD KIxrEEHrBGVEr1SrI9UC/dCcjO70DcFDt4V/2QyPzwF82CCzQgXC8+/6IRGZF2GLk8TS 0jgZb0kndIGR1qJ6J4nGLifO+p554SvSbizdr+/F1UYozbz4DF9qiCP2dWvmbhcWl6sY dbRZoT5b2cxawxvbE56zhK6ZZRRTFlm0bbXvTgq2sTslkiz/3jmbh8IjJo2tKgqF8W/B gGJg== X-Gm-Message-State: AOAM532TuDqTFyG3ApoPfKTO8YlW1TSZbXaFCwXBuvw9PqRC0O3wWGZb SOe1gbzPvhhJ0rk1GcEZG+URXGOSiKHB/A== X-Received: by 2002:a63:8ac8:: with SMTP id y191mr1506425pgd.29.1644304370676; Mon, 07 Feb 2022 23:12:50 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id b12sm13908088pfm.154.2022.02.07.23.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:12:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h Date: Tue, 8 Feb 2022 18:12:36 +1100 Message-Id: <20220208071237.319844-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071237.319844-1-richard.henderson@linaro.org> References: <20220208071237.319844-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::435 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We do not support sparc32 as a host, so there's no point in sparc64 redirecting to sparc. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/include/host/sparc/host-signal.h | 71 ------------------- linux-user/include/host/sparc64/host-signal.h | 64 ++++++++++++++++- 2 files changed, 63 insertions(+), 72 deletions(-) delete mode 100644 linux-user/include/host/sparc/host-signal.h diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h deleted file mode 100644 index 871b6bb269..0000000000 --- a/linux-user/include/host/sparc/host-signal.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * host-signal.h: signal info dependent on the host architecture - * - * Copyright (c) 2003-2005 Fabrice Bellard - * Copyright (c) 2021 Linaro Limited - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef SPARC_HOST_SIGNAL_H -#define SPARC_HOST_SIGNAL_H - -/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ -typedef ucontext_t host_sigcontext; - -static inline uintptr_t host_signal_pc(host_sigcontext *uc) -{ -#ifdef __arch64__ - return uc->uc_mcontext.mc_gregs[MC_PC]; -#else - return uc->uc_mcontext.gregs[REG_PC]; -#endif -} - -static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) -{ -#ifdef __arch64__ - uc->uc_mcontext.mc_gregs[MC_PC] = pc; -#else - uc->uc_mcontext.gregs[REG_PC] = pc; -#endif -} - -static inline void *host_signal_mask(host_sigcontext *uc) -{ - return &uc->uc_sigmask; -} - -static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) -{ - uint32_t insn = *(uint32_t *)host_signal_pc(uc); - - if ((insn >> 30) == 3) { - switch ((insn >> 19) & 0x3f) { - case 0x05: /* stb */ - case 0x15: /* stba */ - case 0x06: /* sth */ - case 0x16: /* stha */ - case 0x04: /* st */ - case 0x14: /* sta */ - case 0x07: /* std */ - case 0x17: /* stda */ - case 0x0e: /* stx */ - case 0x1e: /* stxa */ - case 0x24: /* stf */ - case 0x34: /* stfa */ - case 0x27: /* stdf */ - case 0x37: /* stdfa */ - case 0x26: /* stqf */ - case 0x36: /* stqfa */ - case 0x25: /* stfsr */ - case 0x3c: /* casa */ - case 0x3e: /* casxa */ - return true; - } - } - return false; -} - -#endif diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/include/host/sparc64/host-signal.h index 1191fe2d40..f8a8a4908d 100644 --- a/linux-user/include/host/sparc64/host-signal.h +++ b/linux-user/include/host/sparc64/host-signal.h @@ -1 +1,63 @@ -#include "../sparc/host-signal.h" +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef SPARC64_HOST_SIGNAL_H +#define SPARC64_HOST_SIGNAL_H + +/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) +{ + return uc->uc_mcontext.mc_gregs[MC_PC]; +} + +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) +{ + uc->uc_mcontext.mc_gregs[MC_PC] = pc; +} + +static inline void *host_signal_mask(host_sigcontext *uc) +{ + return &uc->uc_sigmask; +} + +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) +{ + uint32_t insn = *(uint32_t *)host_signal_pc(uc); + + if ((insn >> 30) == 3) { + switch ((insn >> 19) & 0x3f) { + case 0x05: /* stb */ + case 0x15: /* stba */ + case 0x06: /* sth */ + case 0x16: /* stha */ + case 0x04: /* st */ + case 0x14: /* sta */ + case 0x07: /* std */ + case 0x17: /* stda */ + case 0x0e: /* stx */ + case 0x1e: /* stxa */ + case 0x24: /* stf */ + case 0x34: /* stfa */ + case 0x27: /* stdf */ + case 0x37: /* stdfa */ + case 0x26: /* stqf */ + case 0x36: /* stqfa */ + case 0x25: /* stfsr */ + case 0x3c: /* casa */ + case 0x3e: /* casxa */ + return true; + } + } + return false; +} + +#endif From patchwork Tue Feb 8 07:12:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 540742 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp285959imo; Mon, 7 Feb 2022 23:38:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoNxnGoj88ZF2Tq8yW6tUhJSiLi8kqS1FtIZDILbj7tojoKV7YiE+Q7NuQOnX3TIjgGVs+ X-Received: by 2002:a05:622a:192:: with SMTP id s18mr2102285qtw.47.1644305922777; Mon, 07 Feb 2022 23:38:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644305922; cv=none; d=google.com; s=arc-20160816; b=YUk/6gRdqx7rgIdz5BIg1Xhan3SMuinR1Z8uFBbYaaroQ5VOMInE+OaPdFxskDEXEY zUhZ891Ns5q5VS+GZRbKoDL3KQ8Pp8fMStZocfJVqM+CObyWw9lgg0p8DZKuyTht+2T5 VM2huPDgN8khjGLLz8jL0iKEvNMZKGRBRxON2A8gkjYmdOmvl78xJ37zDfSkHBX7js9d mWwLCSgORmdtDrH4vPnq1NTFWRW0B8DDn3MgSJxZ5VuzylCDBK2wUHxMZED6+IRrG3DR 0Celj2KNGjZ9LduA3paXz+SoVArcaEh3QUxrGRNejZ8UOrrA+27+Zu/JmASG9myk9VhP z7YA== 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=xkQSSfw7Pzh/MwPufzIC/bP8BbJT214j9m8GQ4wb+68=; b=Ay0QpYbqMCTPZPBHXRn/HL/5dX9ZdofutWNS6NntECkMioEPpYJFPf0Jb1Uyk/C4Pu YmoV79vDcKgTQTZa19ZWWkiLTP5QSzQXGJwsbNWJM2R7wEfxnAdP8w1FY+qgYjpT5aMH BJkhjNYfvDhtLQtd821N7hwjxe6PNHF5vFW1dlv5z8+SqY02A/M4hX8mIj11xCAxnZIA d6uTXUBaTrg5eFdsUD/aAeAi/APe7Z3sD9W4eukm3mUUxBfHnL2Kqcw017TjcBWUw77S ZzJqJyEXoGaleMqIPQPHfxnVP6CGr69Bugtxn6p5lor6S4MXDPubsAlwMkUd/9+YPlt3 IeeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a7VmFXtf; 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=pass (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 w19si2942700qtk.551.2022.02.07.23.38.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Feb 2022 23:38:42 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=a7VmFXtf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHL5G-0003e5-9j for patch@linaro.org; Tue, 08 Feb 2022 02:38:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKgK-0007Dg-05 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:13:00 -0500 Received: from [2607:f8b0:4864:20::636] (port=45812 helo=mail-pl1-x636.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHKgI-0000Sn-55 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:12:55 -0500 Received: by mail-pl1-x636.google.com with SMTP id w20so3859779plq.12 for ; Mon, 07 Feb 2022 23:12:53 -0800 (PST) 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=xkQSSfw7Pzh/MwPufzIC/bP8BbJT214j9m8GQ4wb+68=; b=a7VmFXtfLaVD2u83SHaHUP5olYh09h1HNgHMuQ8rcR+CnzgGbwevYKk0RTL/ulOf50 F5pj54fGV9ZCHBA5R6RT2sM6qteK4A7Vpl2i9/RqYyPWC3AWIzm3fo4Deqt4y38RM1SJ MXz9Hk/+RWz7JYM3bu60yP38Pfsc1cZrPyvly3Cr4ngAhVYRvTs2nIkuLv8n0H8DKfNc d4B4FsDN+KjEFPsEkr/uZLG6aZ2oYAmsKqtcI+yIcurk6u55cxp+nw1GTsjjk/4DA99g UzM6gj/Tp3fQncONjwedntKdVBPbSvDLV/8m+E77KoGxbzdHZ2M7KDsTpPkfeHorYwpu Bjow== 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=xkQSSfw7Pzh/MwPufzIC/bP8BbJT214j9m8GQ4wb+68=; b=DzySnvi9Q985P0CQecw3Pk/C/pf6OPNhSL+zFUYh0CA909tYnhJ37VPu0lBHyy8KUS aQKsjofKziU98cYPCU5QUUJFGF/FubgHoi4fqWbAZoqTt0WaAQS1EE1X7C8upgOuuHXX QylVrRfys6UqhkQD+RUBf7LdmQM+8SlWcyqJLZsIkXdjYnc/DaAAvk0wmyBgAaYJoMGZ uOFF9HRDfJWj/WuDxUFDjIiDA6Px3NoYOwP137x+2Me4KnOI8lJyTgM87mHaRm4+2HKj MbbIsRvv0+A4XcEA4uK5PAd8IrjnW8YYyMLdopc9ZJPuWzs3QOVv7dRQLVjos5bkbrZ1 AV3A== X-Gm-Message-State: AOAM531clnVgvv0f3Cy0vekqxU3CVzUbDzdfNgShQnv9zVc1VzE0VDxP 4/leNI3ExcTwo820zq0UOTHruov4uD/Ueg== X-Received: by 2002:a17:902:6903:: with SMTP id j3mr3202041plk.23.1644304372837; Mon, 07 Feb 2022 23:12:52 -0800 (PST) Received: from localhost.localdomain (121-45-127-8.tpgi.com.au. [121.45.127.8]) by smtp.gmail.com with ESMTPSA id b12sm13908088pfm.154.2022.02.07.23.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:12:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 5/5] linux-user/include/host/sparc64: Fix host_sigcontext Date: Tue, 8 Feb 2022 18:12:37 +1100 Message-Id: <20220208071237.319844-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208071237.319844-1-richard.henderson@linaro.org> References: <20220208071237.319844-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::636 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Sparc64 is unique on linux in *not* passing ucontext_t as the third argument to a SA_SIGINFO handler. It passes the old struct sigcontext instead.t log Fixes: 8b5bd461935b ("linux-user/host/sparc: Populate host_signal.h") Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/include/host/sparc64/host-signal.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/include/host/sparc64/host-signal.h index f8a8a4908d..64957c2bca 100644 --- a/linux-user/include/host/sparc64/host-signal.h +++ b/linux-user/include/host/sparc64/host-signal.h @@ -11,22 +11,23 @@ #ifndef SPARC64_HOST_SIGNAL_H #define SPARC64_HOST_SIGNAL_H -/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */ -typedef ucontext_t host_sigcontext; +/* The third argument to a SA_SIGINFO handler is struct sigcontext. */ +typedef struct sigcontext host_sigcontext; -static inline uintptr_t host_signal_pc(host_sigcontext *uc) +static inline uintptr_t host_signal_pc(host_sigcontext *sc) { - return uc->uc_mcontext.mc_gregs[MC_PC]; + return sc->sigc_regs.tpc; } -static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *sc, uintptr_t pc) { - uc->uc_mcontext.mc_gregs[MC_PC] = pc; + sc->sigc_regs.tpc = pc; + sc->sigc_regs.tnpc = pc + 4; } -static inline void *host_signal_mask(host_sigcontext *uc) +static inline void *host_signal_mask(host_sigcontext *sc) { - return &uc->uc_sigmask; + return &sc->sigc_mask; } static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)