From nobody Sun May 19 12:45:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628861035; cv=none; d=zohomail.com; s=zohoarc; b=V8fOOswyzFKgDDUwTrujTlXtlaGycxJr9FgdEf4J+Zz5TPrRZZINKgxDfVurcpt9WEiKCw1s1lUdUtl6NErhOsVW6jofE4dxT8e1Kp/fMx/ayPv424eQy2Z8h578fz8MekmL2/Jtm/lcL+W/S1yH3DwlDnYpWHs3c62BhUqmwHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628861035; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5MB/CWOu8y75nxH9S62qSbJCleKrqKA9mDnlY1X/YB4=; b=VTjDEPxmfTDL5VUqX1XR2UKqZyWcYgRC7Q66Ds3mRri0dCWZp+POCA7MqfjoZFB5AUmB/liMj2N2HObjUNxVa89KnxtZXafuRYM83PNJEvXS0j48GVLAGf2b13iPXLb4j0j46TuKl4m//AP7SfnGLktW8zkbUGDHtZikngSVTPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628861035129876.4181398216514; Fri, 13 Aug 2021 06:23:55 -0700 (PDT) Received: from localhost ([::1]:41886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEXAA-0007SE-2g for importer@patchew.org; Fri, 13 Aug 2021 09:23:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEX4i-0005zI-Rk for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:18 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:47078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEX4g-000190-N9 for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:16 -0400 Received: by mail-wr1-x42e.google.com with SMTP id f5so13211352wrm.13 for ; Fri, 13 Aug 2021 06:18:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q75sm1585705wme.40.2021.08.13.06.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 06:18:12 -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=5MB/CWOu8y75nxH9S62qSbJCleKrqKA9mDnlY1X/YB4=; b=BeCjYGp55J77YtWl7Rg09vx2yRialAJFAhHOk8THvE1l88imoYWfHWnDLqV3K5Dhom pyMZjh2rWtHuJlUw11+fGCztVWft2UQYph078V//bs5hQHy7CN4eI2C/Y5OduCSZwuwG LJ/SCf0Bp2EXKZO43gVS2leGQ6T0rFuebBfs75x0rk+Wvm72esTVRcfYo/ZKVX3Vqd97 n7XfJqbgzt9E8zvO49jBDsh9qJvFt6UTnDZkSBHuv8lhhA0u+/MRCILHZqVRyo4urYLx jlxeFo4Hi/R4N5Lj2Cvi+DvtMdWb1YoDDkh9T3ZN4jYVqio6bAPMYwMUCU7EM5StjxGg o/Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5MB/CWOu8y75nxH9S62qSbJCleKrqKA9mDnlY1X/YB4=; b=k4Zv1KgXz9bTTsuaegeAaC2EGApXCUk2ePBDYHCutl6KdGx05dkrkqYKG4KX7U5+Vp iaqp6PE4TAL7T//JNUHAqYJCf2G73Hp0vo4zYC94EFZGOCcc/CT3AkOq/BFMzD8j9mfI 0hmL6/w9Mf5xiajpWIgrFwoUZ9lRzPcuz9GglDEF4qtLqQZyu30a+tryqFznFOBkRmlU kJhTNwRhMHbU25cK7u1WLhbAMC20HlpNcFLfYkRCSd5B46Dz6yUhv1gnhWtFNAhAGKhz vaaNZxLA5QVS+fYhqwmle4/aGJjW00sFQnffYoUOi3VTrfY/WuGcEP1JM437EKhWeqlD PGsg== X-Gm-Message-State: AOAM5310kUtNOmD3FDVNd8WBN7LCkKaswSzI5X92Ggo/cnRv8BNTzlad PvDZJf0URzbQe3FKA95dh8BkfsE4s1gCCQ== X-Google-Smtp-Source: ABdhPJzdJtfLMDCsm4xosVNbD543Q26QRHkOPRZgABxq7KFwPcP7jquVFM6W3spyDFwtgIL+phCvSQ== X-Received: by 2002:a5d:574d:: with SMTP id q13mr3169796wrw.425.1628860692396; Fri, 13 Aug 2021 06:18:12 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.2 1/7] linux-user/aarch64: Set siginfo_t addr field for SIGTRAP signals Date: Fri, 13 Aug 2021 14:18:03 +0100 Message-Id: <20210813131809.28655-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813131809.28655-1-peter.maydell@linaro.org> References: <20210813131809.28655-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628861037358100001 Content-Type: text/plain; charset="utf-8" When generating a TRAP_BRKPT SIGTRAP, set the siginfo_t addr field to the PC where the breakpoint/singlestep trap occurred; this is what the kernel does for this signal for this architecture. Fixes: Coverity 1459154 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index ee72a1c20f0..5d8675944d9 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -148,6 +148,7 @@ void cpu_loop(CPUARMState *env) info.si_signo =3D TARGET_SIGTRAP; info.si_errno =3D 0; info.si_code =3D TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr =3D env->pc; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_SEMIHOST: --=20 2.20.1 From nobody Sun May 19 12:45:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628860817; cv=none; d=zohomail.com; s=zohoarc; b=KTjCvTpO9s2CxgW8gz0owclm5ucmstgbzzLSmr6fnfpy0fIbINC8GUw7CeizurICA54FTSZerFTt28NX9UqQ10YdRlhJ+wIEPEV1e1BpKvWsNr7Oas9JJI+TKOAOZS9up1+sqtc+TDmnxP6J208urWe7tETuU9ZlxKBoDI7YvSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628860817; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OwsRmN+On96JlTIEqDrfPOxNFjdnyRq58apo5gMpvTk=; b=U5z7VByMNsZgPYaeHP7HV5LrEZYS8sfhoRnvsHDTOjEFOSSIuJwpPuIxKpbc925ZdBCHxQLyEr9GCKE4ZfB9p+ombPh4oYelpYetvzMWX8YQRrPKUvR03cqvrwfMN28Tpg8MbQuJK/gr8szZHvb/1AyT5PFtj4xqicGdjyAx/TU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628860817662616.2415470996411; Fri, 13 Aug 2021 06:20:17 -0700 (PDT) Received: from localhost ([::1]:59748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX6d-0000Lg-7P for importer@patchew.org; Fri, 13 Aug 2021 09:20:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEX4i-0005yv-AP for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:16 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:33332) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEX4g-00019O-N8 for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:16 -0400 Received: by mail-wm1-x32c.google.com with SMTP id l10-20020a05600c4f0a00b002e6be174c29so2810072wmq.0 for ; Fri, 13 Aug 2021 06:18:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q75sm1585705wme.40.2021.08.13.06.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 06:18:12 -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=OwsRmN+On96JlTIEqDrfPOxNFjdnyRq58apo5gMpvTk=; b=p9le70mF9teyB9QiwtTF3Q7MmormSg/wO6A3fKftC92iY2oxwMG0uV0pqCPAwa7vFJ hG1va1lBAdhCfrHTzPafO3IPPbS9PaNDd9UdoV4CmD9AVo5zCzzRazqlNwNUn8/qlPSA tASBOQMIS7N1xDWeT9ZRWwEClY29Fqz4+FvecWxLdTOSng8FIY1ei0e/1WATZK8U4Suz 7u7QUvYChJ8BT7PXdV/mWq42AAqgH3k0kfzPMEnCXM8+AFBCvCf6O685wOyIZ8vd/Z0A pOqvN11b+BUcsHBI5b9/Qv2BVL76SjBZXui7QwU46tOcIYWNtlSQcbbYXTkG+tEvp1nJ O6fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OwsRmN+On96JlTIEqDrfPOxNFjdnyRq58apo5gMpvTk=; b=HsEhXmLpXxV0HQZGA5y9cMOARV70k2KSN8ApNoQAKevz0C5GMzXR5vceFViuUpPmjd 2jkIsCHji4ZS0VnmKJqDhAWQ9wAMb3fOYKCzP7u3QIJWX1swMdWhZ5LMicPWRDIDsq1e rOKw3D899rrp9Au/F51VFcwfBEFgGZVhlqflH18UmqUZ5/ade8mZ2ergyPwgm1V+kAm/ 9FBznO3g4yZ+hn1FjZfX7VbjAjW4LiBjnZwhVr813vWodY3Iy6uLMt0WhHuT5DCdKrLh Pe8BbsZgODieOxOyt+1wppzKqaUmd/5CpayuKbvn4ItcKHeoLHzxLEOBSVfL/56rq9of KEBA== X-Gm-Message-State: AOAM533hjQETa3eLcIK4lu0es1AprNJYPa6QMl4TxTpn4AxWepyTqbMB 32Bqvei8orWroBjuoOokGK31Lg== X-Google-Smtp-Source: ABdhPJzA/+5ErX6vNYbhRGUvsZL4xI7hoMrwUEt7kwrPtmQVdEDtM+GtEobMxcywZ8dhtNg5gb2C4A== X-Received: by 2002:a05:600c:5114:: with SMTP id o20mr2665051wms.176.1628860693052; Fri, 13 Aug 2021 06:18:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.2 2/7] linux-user/arm: Set siginfo_t addr field for SIGTRAP signals Date: Fri, 13 Aug 2021 14:18:04 +0100 Message-Id: <20210813131809.28655-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813131809.28655-1-peter.maydell@linaro.org> References: <20210813131809.28655-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628860818530100001 Content-Type: text/plain; charset="utf-8" When generating a TRAP_BRKPT SIGTRAP, set the siginfo_t addr field to the PC where the breakpoint/singlestep trap occurred; this is what the kernel does for this signal for this architecture. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/arm/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 69632d15be1..007752f5b74 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -453,6 +453,7 @@ void cpu_loop(CPUARMState *env) info.si_signo =3D TARGET_SIGTRAP; info.si_errno =3D 0; info.si_code =3D TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr =3D env->regs[15]; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_KERNEL_TRAP: --=20 2.20.1 From nobody Sun May 19 12:45:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628860881; cv=none; d=zohomail.com; s=zohoarc; b=Qbk3ifRIRuPlwFWPgk2gqmqKDI9HjU0I36YEwd/Gkw78xRvpeN7rIwF1VTGo63IP1ByJOSk96qo2mZIvedFA/BX9lImqJ3D/g41Wdd9dIOI5uq9ZiDMfyZv2UaTgV+FSt/GcoHzF0OaIXoQRp0e3Q9zvAxUbipd0CeKlOayx9PM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628860881; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z1jD/SaL+e0IFj9uD3ovecMKRiP3oqP49v8hJs55uWQ=; b=VKZg5FgT4ScNuMM4evhGzvvaHfmjF4I3rRKflWLcFwK0UPTZ84L4gwoCgCzKjbAhQL0smiqkaEXB5tAr+atbcq7tlU2BTZtdgGwL8Qt4Asb2MI+9uYDzEiw2xZG+mX5kvre5UrvVeLYTGs/P1D2Eu5a1hHZfFearc1eIoabWtcI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628860881605918.3123895925447; Fri, 13 Aug 2021 06:21:21 -0700 (PDT) Received: from localhost ([::1]:34236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX7g-0002I5-DO for importer@patchew.org; Fri, 13 Aug 2021 09:21:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEX4k-0005zX-0R for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:18 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:43899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEX4h-00019b-Dn for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:17 -0400 Received: by mail-wm1-x330.google.com with SMTP id k5-20020a05600c1c85b02902e699a4d20cso6902151wms.2 for ; Fri, 13 Aug 2021 06:18:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q75sm1585705wme.40.2021.08.13.06.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 06:18:13 -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=z1jD/SaL+e0IFj9uD3ovecMKRiP3oqP49v8hJs55uWQ=; b=KNNFrDzHl8/oQlOxebYW+s06ZqZfncN7TzCvMbW8C9i6AUY85RBqFrRosCj3h+rkYY TnYcWWRkeVYEGr9n5dSic/C8wDfngmeKp8vdQqg4fXksSVpUcIbTyZJY21G9p7qQEUGO QqN6bBmeP6ppHlQQdYJp1F9ZKh2LhbV3yMED4mu72bizV/HkOQGS0EwAdo5JjYHSrCq5 IJ3qBtLW4Kghw2FqFm+z+bq5js3Lgl1M3twoS0+huEh+b7xKpnWssCtxvoyz/KpSX9vZ o40kxWB8AgiGzKTOGzjiXpSn3GCfQw3MGfeM4WWUZl0+z5/6p3iRxfZyAntFmgNb0tSh JMDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z1jD/SaL+e0IFj9uD3ovecMKRiP3oqP49v8hJs55uWQ=; b=W42YzF5TUVxlzqojcinXJCnRn12QyOjDE+KbWLtA/CZRbzrrWr4hAFvZov27HtNpVE r5F1qwZhtcvwbRzAFVovL+AL+1oLcrJCMllRZViziltpuazuM3kkG+pksmzwYO+DaXLq KrraShh/C2YAiHw6SsT9UFosTyONKI4Ztd3seb/B5aXpqKbQu8jpKx0T6nqftBvgVdw/ iv5Wiv+Re+s0VkXtozFId+CJQkFMKEXpGOrOZlmslangCU3V+lQgAV0WM9V8v1De0unW 3apDg8RY8WV/L9TCs/Go6PkEDHWodbWPTC6hPeqp/sh3NvMuWeZhzTXUL/XEKA7+DK3A X6HA== X-Gm-Message-State: AOAM530OMgx1HdMAlGOfn1o6NKBk5y9VuEfbIt/uM31OkvgPOVvfn7MQ wN/pydPaB3y9BHbzQQHl4RVNwnjjlQw0vw== X-Google-Smtp-Source: ABdhPJzo3lSLFc/eppqPQXJyxE9z8l+gsepaENzwYFOQc24hpFXoUcU+qLBHNXCNn/OfhUuKojetGw== X-Received: by 2002:a7b:c114:: with SMTP id w20mr2685272wmi.85.1628860693904; Fri, 13 Aug 2021 06:18:13 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.2 3/7] linux-user/arm: Use force_sig() to deliver fpa11 emulation SIGFPE Date: Fri, 13 Aug 2021 14:18:05 +0100 Message-Id: <20210813131809.28655-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813131809.28655-1-peter.maydell@linaro.org> References: <20210813131809.28655-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628860882674100001 Content-Type: text/plain; charset="utf-8" In the Arm target code, when the fpa11 emulation code tells us we need to send the guest a SIGFPE, we do this with queue_signal(), but we are using the wrong si_type, and we aren't setting the _sifields union members corresponding to either the si_type we are using or the si_type we should be using. As the existing comment notes, the kernel code for this calls the old send_sig() function to deliver the signal. This eventually results in the kernel's signal handling code fabricating a siginfo_t with a SI_KERNEL code and a zero pid and uid. For QEMU this means we need to use QEMU_SI_KILL. We already have a function for that: force_sig() sets up the whole target_siginfo_t the way we need it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/arm/cpu_loop.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 007752f5b74..44324976196 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -266,16 +266,13 @@ static bool emulate_arm_fpa11(CPUARMState *env, uint3= 2_t opcode) ts->fpa.fpsr |=3D raise & ~enabled; =20 if (raise & enabled) { - target_siginfo_t info =3D { }; - /* * The kernel's nwfpe emulator does not pass a real si_code. - * It merely uses send_sig(SIGFPE, current, 1). + * It merely uses send_sig(SIGFPE, current, 1), which results in + * __send_signal() filling out SI_KERNEL with pid and uid 0 (under + * the "SEND_SIG_PRIV" case). That's what our force_sig() does. */ - info.si_signo =3D TARGET_SIGFPE; - info.si_code =3D TARGET_SI_KERNEL; - - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig(TARGET_SIGFPE); } else { env->regs[15] +=3D 4; } --=20 2.20.1 From nobody Sun May 19 12:45:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628861021; cv=none; d=zohomail.com; s=zohoarc; b=LO5SO8A5hk8cOEBiHeIbgD5b5UDYoc58PX6ZqUTn+9UxvGciwCdT0ScfiebqqRmRhwFJ7gMJudzHafi5Uu2wKNDNCZXr7rqa7lLidUfonDgK6ad6UgUs6ww4wSBGY9gKpPA8unhAJJiMD0pYld11s0OXVFz3KnP6OT9IYjnBDfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628861021; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d3Hr9Wc4dvCtUGT2UQ15hAVNCLMUJmbjebAXeIh4mmY=; b=iDE51jy+gs+578Rtd/36Ts7wFbRHWBDAs4rPvZdw8Qc5z09bOIONIc9RYfTop30Bn9UdOU+VlwSMGJ9RRaCHtRh+Ps1yYl41a+zTYduDMPfzrziqc+oyAMFI5LP6l5j1qWhxRa2pcgBxOKC0w+6MBCfJ7eFTNqGDeG73xutkbNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628861021881115.55700036451628; Fri, 13 Aug 2021 06:23:41 -0700 (PDT) Received: from localhost ([::1]:41572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX9w-0007Fi-Qr for importer@patchew.org; Fri, 13 Aug 2021 09:23:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEX4k-00060I-M4 for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:20 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:44665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEX4h-00019r-Ut for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:18 -0400 Received: by mail-wm1-x331.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so3462235wml.3 for ; Fri, 13 Aug 2021 06:18:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q75sm1585705wme.40.2021.08.13.06.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 06:18:14 -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=d3Hr9Wc4dvCtUGT2UQ15hAVNCLMUJmbjebAXeIh4mmY=; b=ClGrxmKMPx+hiwBVmMIfXS7TrxU2IMbo3zfqELLr2OTzFWBrFM1sV5mVlzW1nXLpKN 1QOFdsyzqEEdSfUuelUFKzWInIgEkyKA9vHK9XnewPZ89yrOVftYZKoA17jecTbMCgrh 7nH4hUo3J+y+teJTfiEC64AwKeUT/mGx7DMSDFhWCMsJYGGDbFIaSV4YGAwPmbW14Wns S+3DCvjHOlDQqjiATBI/OfHq1QXdT84F+Jwewzko1DeVWGrsFwXy3FjGrVu3t0+hDdJR Lwp0HVeV0aHix7WyKC2aaYg8tZ8Awx2n9+O1Gy+Lw4lYKTXLwoc0cBBPij2ptLUdQ12T J9DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d3Hr9Wc4dvCtUGT2UQ15hAVNCLMUJmbjebAXeIh4mmY=; b=FNisVOfREZnEUW1iUPMDt/83qPIww9w2PpJcHkuB3MLJbkQOYDM+RPB8byb67uvUZv ifJDYcWS5phYH/APsg2cn7p6RYB7bgmIqfr8Ag3WYEdgosu2YrSRCBf4EZSq83xYRDJD 1u1NUB0oaDLeqoy2txNGJ0zgknJ+jopRzs0ZfaYBXSSHxmheV2r/R7iWregk+qI82LGW +BdF2600OTRdQuJM/G26EyS/LkYBt/9NJqZPkPk6yOiqnolGjTp/yddGDdG9EqUj0KpP hyzOhI4CAzD91E1PQhTiWR/dLu3bHb2HCmwHJ1TCmw2cV/Rj8BGRI5v6HSmUcwm2fT5M 3PVw== X-Gm-Message-State: AOAM5308aFJ1Ri2JqIcUuvPHw4L70wOEB2usu5pSMgApc0kNWiyF9Y20 Y/0rbLrky8YBGiBnXpyyo9JZ1Q== X-Google-Smtp-Source: ABdhPJw7HtFJTNglFbgpjAnEk1eBHEm8U3AXhWfaU+EGX9yDpK6MSWUW5grjb14i3pocfMmqRrZL7w== X-Received: by 2002:a7b:ca45:: with SMTP id m5mr2624732wml.158.1628860694702; Fri, 13 Aug 2021 06:18:14 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.2 4/7] linux-user: Zero out target_siginfo_t in force_sig() Date: Fri, 13 Aug 2021 14:18:06 +0100 Message-Id: <20210813131809.28655-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813131809.28655-1-peter.maydell@linaro.org> References: <20210813131809.28655-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628861023720100001 Content-Type: text/plain; charset="utf-8" The target_siginfo_t we populate in force_sig() will eventually get copied onto the target's stack. Zero it out so that any extra padding in the sifields union is consistently zero when the guest sees it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index a8faea6f090..fd3c6a3e60d 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -636,7 +636,7 @@ void force_sig(int sig) { CPUState *cpu =3D thread_cpu; CPUArchState *env =3D cpu->env_ptr; - target_siginfo_t info; + target_siginfo_t info =3D {}; =20 info.si_signo =3D sig; info.si_errno =3D 0; --=20 2.20.1 From nobody Sun May 19 12:45:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628861104; cv=none; d=zohomail.com; s=zohoarc; b=OdQFlHwu/WoN/6n6jTuvrkz20ei871gA2kBehpiJGtjB3P1paG9MAeOyFGwPePT3z1CkxoaR3aBjkgNVj7lRxdBSd+fWo4+6i8FrV/VWda1H4lc1DGNCmd2r4F3YmVtTiEETGb6ky7+oQo/w7H0J9JMimRwHM/CSGtUk9n3U2kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628861104; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mpfyk7/1xkPWCm67v6Q4b34MWfBO1kqI/kzOqeHhh68=; b=U+BNneXh8e+pq+OFfD5aEwKcwEnq5yKz1nQN1tYSSo7HjfeySOalGzXZCn98E/x4N+DyKgGfJBDUWgcxwezPIggEQW7LoCZp5d3SpXNRNlhG0fzPgpWTD8cf7wquPUpcqxXzyrhu1ZxfRo8cpXUudIZOhR9pSN9x1iPN3ITpOck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628861104408353.6298162151609; Fri, 13 Aug 2021 06:25:04 -0700 (PDT) Received: from localhost ([::1]:46668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEXBH-0002H0-A2 for importer@patchew.org; Fri, 13 Aug 2021 09:25:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEX4k-00060N-VH for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:20 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:35758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEX4i-0001Au-Tf for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:18 -0400 Received: by mail-wm1-x331.google.com with SMTP id q11-20020a7bce8b0000b02902e6880d0accso9690922wmj.0 for ; Fri, 13 Aug 2021 06:18:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q75sm1585705wme.40.2021.08.13.06.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 06:18:15 -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=Mpfyk7/1xkPWCm67v6Q4b34MWfBO1kqI/kzOqeHhh68=; b=mpUHRByNGlwsgFsz6qJ1k9zn6TWNEH5dr9CSJ1aYY7KQwHUK7EC1T1fAf7IHbPJfu/ bdI6SZgL6LGpTcEjPiwpwWc2de2lMy3gTvzLu1ClMXbu8F+MlSeOLb8XNE0Lc7D1JBRJ ddYxixB3vcK7SQQbXKv6Y5guHSbMU1+wR9Vn7G0r8VXcI0DYk+tC0OjLcfMNp8PPhzji YA5fVP2GFPRLV5uNQA5JE3IQH6rZC6G7wDmFelGtJ5pzTu7wK0YUtIiWwWhcs3kzxpXo grhBbJMEzQw2hlXZkkuz5BbOAH5NrjRKJXy0y7KugOxex3qV86iMjiOCW8+x05wcClYe fP0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mpfyk7/1xkPWCm67v6Q4b34MWfBO1kqI/kzOqeHhh68=; b=MkfjSV0Sb4dY6GHReFh4in7Woz9XVbHDdap4uHrZirSyHMVmggluYXQJwYnYTjEpUy YMKEtbeI5tUbo3/yfq8aO+yAPPxgG3hhqCNR7OzuUML4hfW+LIhx/HZV+mU98OCJCphX 9Iv8jOIJHLD57vGjsx28/YWF94SttDulGE+8Bcd0qHpCNDdBogAn+m/aak1XaHzZ3ws/ dqfw6+xOu8LplpoxqDr0CrOwPGF+lX1GQ7q9ajtlf/fNfYg2rX5aLMfED92dxa/WM4b8 6BpuXQE3HolumiPxEJrBESBAqJr0dzuDiUywDLhgfRIoSQ/S93PI6zQX6VPP46BSq5EH p/yg== X-Gm-Message-State: AOAM532Nl5nB+Sx8akiqxUTjCfylwpWmH7cYM7zAU2xvTt8WX28s2b18 FAQXnE/LplwO7D9Zxs4BVqQUag== X-Google-Smtp-Source: ABdhPJxwxUrZvEcVXoGNo6VZytA4oZXyEGrp25polZasVvIdosfCNP0zTWv6b8/auROU4mpo13vDfw== X-Received: by 2002:a1c:7711:: with SMTP id t17mr2646248wmi.77.1628860695706; Fri, 13 Aug 2021 06:18:15 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.2 5/7] linux-user: Provide new force_sig_fault() function Date: Fri, 13 Aug 2021 14:18:07 +0100 Message-Id: <20210813131809.28655-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813131809.28655-1-peter.maydell@linaro.org> References: <20210813131809.28655-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628861105936100001 Content-Type: text/plain; charset="utf-8" In many places in the linux-user code we need to queue a signal for the guest using the QEMU_SI_FAULT si_type. This requires that the caller sets up and passes us a target_siginfo, including setting the appropriate part of the _sifields union for the si_type. In a number of places the code forgets to set the _sifields union field. Provide a new force_sig_fault() function, which does the same thing as the Linux kernel function of that name -- it takes the signal number, the si_code value and the address to use in _sifields._sigfault, and assembles the target_siginfo itself. This makes the callsites simpler and means it's harder to forget to pass in an address value. We follow force_sig() and the kernel's force_sig_fault() in not requiring the caller to pass in the CPU pointer but always acting on the CPU of the current thread. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/signal-common.h | 1 + linux-user/signal.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index ea86328b289..536c7ac2c20 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -40,6 +40,7 @@ void tswap_siginfo(target_siginfo_t *tinfo, void set_sigmask(const sigset_t *set); void force_sig(int sig); void force_sigsegv(int oldsig); +void force_sig_fault(int sig, int code, abi_ulong addr); #if defined(TARGET_ARCH_HAS_SETUP_FRAME) void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUArchState *env); diff --git a/linux-user/signal.c b/linux-user/signal.c index fd3c6a3e60d..5ea8e4584a7 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -646,6 +646,23 @@ void force_sig(int sig) queue_signal(env, info.si_signo, QEMU_SI_KILL, &info); } =20 +/* + * Force a synchronously taken QEMU_SI_FAULT signal. For QEMU the + * 'force' part is handled in process_pending_signals(). + */ +void force_sig_fault(int sig, int code, abi_ulong addr) +{ + CPUState *cpu =3D thread_cpu; + CPUArchState *env =3D cpu->env_ptr; + target_siginfo_t info =3D {}; + + info.si_signo =3D sig; + info.si_errno =3D 0; + info.si_code =3D code; + info._sifields._sigfault._addr =3D addr; + queue_signal(env, sig, QEMU_SI_FAULT, &info); +} + /* Force a SIGSEGV if we couldn't write to memory trying to set * up the signal frame. oldsig is the signal we were trying to handle * at the point of failure. --=20 2.20.1 From nobody Sun May 19 12:45:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628860827; cv=none; d=zohomail.com; s=zohoarc; b=aRmI5O8lA1MJx+Cf0CfoFw3oqEIbICM18+6WiF8MTp+lEflAzwUHehKjKbCGki2lujoEtzlMP4pdt9uqvsUwwyLCwR18Gax8meMzkdkcQLbLgYefpVLjJeqAB66JKFUm/3ygfePCd9hq368LhxypaxdESllyBOWWy45N6zz3ZeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628860827; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fJIpsv1H5kq5YSGMr5mAwnnyIFFq6TrksBVoWM/ILDs=; b=LAoGU+WNhq8R8YE2pDbbu6gsluimtt+xnIMDx6QQSF+kidHTHqoHPpvRNCZ4QcmjAi02qFIz6K0nCvwLLcBCd4OZNy3QIbVnWA4rzVoYY+hGGN/VtNiWBdsnGJQpm9wVeCk2W/11AHnjvbbYnkFDSWj9kHjYdefEgt9H3l4jzC4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628860827625712.2592867297669; Fri, 13 Aug 2021 06:20:27 -0700 (PDT) Received: from localhost ([::1]:59898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX6o-0000TZ-Ki for importer@patchew.org; Fri, 13 Aug 2021 09:20:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEX4m-00061h-6y for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:20 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:56318) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEX4j-0001BH-MV for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:19 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 6so6880892wme.5 for ; Fri, 13 Aug 2021 06:18:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q75sm1585705wme.40.2021.08.13.06.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 06:18:16 -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=fJIpsv1H5kq5YSGMr5mAwnnyIFFq6TrksBVoWM/ILDs=; b=eCR11VKxyvxY/s1Xko6dkF1JxhyzTULV3anFfycSnEX6mGtPr/tFCz2Wv9GRutP4cK FlP1u2jv+Pi+Omogx2TgVfOPA5tDgw/wpzZEgW08Oj5Fy8EWxzLdyrpgh24kNAuI9Nfg 37ue0u5jMNvvTmvQ8dQxyRvWUX84yjn+5KpGFNQMiYLXmQ/5Ou58Bzc1YJYbPVNRnAbI 4HE1Utx8fI/n8fB9LzBOnVwlfyG36RaRga2jb3CLYeYmCrLqSJDqmClJJRXwLjnb44eU 1LLZF9HlrLTN92eTnFGHh84oKpfhSke0vPM1hmnT4XRxj9e3ZuEYsVrNFve9jXdKnU2o WvZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fJIpsv1H5kq5YSGMr5mAwnnyIFFq6TrksBVoWM/ILDs=; b=YRQVFknYsaHPGO8dDH9crxzaKfJIgrSn1vDnpiPw3eqeKMivivvMBSLrcoh7uTtm2C zYDu/dcVwH3FZU9aJWsua/NgMX3eJkshX83cE1ChxLDqXGfobo1aN7YnYSmXz1KRsNiE h6wLS3C0rzCod0wIf/Ii9WVpoOdwcImz6BouZF7tArps4ZnkO+mM6S+mxmOmIM4BmNDS 027DJHM20Yh30eWbpnjmqc+1G+CFf/SY5wEoJfYp3FV6v0t9QTvEsagMu+2a13b9JjEh EBf0PFtH3KQhdpDGHLH9xcWW9cqJHi63pnHUMqdgcCc0PB/Y4o9TN+s/jIMFyJ91+pY+ yGPA== X-Gm-Message-State: AOAM530ftmqCrAbuciXS0qdTrVgBGvuP6VP0q5PiaHMaNQm1dTySbVIx KWVGN4m/HqvHLzfmAbiLtf/yIg== X-Google-Smtp-Source: ABdhPJwrWwVMbShO6Kj9waS5iM74iY/68w0HA6Or7hCFlLExBdBaLeN86Dp2WhMArwxN91XYX9346w== X-Received: by 2002:a1c:6a07:: with SMTP id f7mr2575581wmc.15.1628860696444; Fri, 13 Aug 2021 06:18:16 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.2 6/7] linux-user/arm: Use force_sig_fault() Date: Fri, 13 Aug 2021 14:18:08 +0100 Message-Id: <20210813131809.28655-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813131809.28655-1-peter.maydell@linaro.org> References: <20210813131809.28655-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628860828480100001 Content-Type: text/plain; charset="utf-8" Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- I threw in a comment confirming that the si_addr value for the "bad SWI immediate" SIGILL really is different from the PC value reported in the ucontext_t and resumed from if the handler returns, because it looked like a bug to me when I was reading the code... --- linux-user/arm/cpu_loop.c | 54 ++++++++++++--------------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 44324976196..d4b4f0c71fc 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -22,6 +22,7 @@ #include "qemu.h" #include "elf.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "semihosting/common-semi.h" =20 #define get_user_code_u32(x, gaddr, env) \ @@ -92,7 +93,6 @@ static void arm_kernel_cmpxchg64_helper(CPUARMState *env) { uint64_t oldval, newval, val; uint32_t addr, cpsr; - target_siginfo_t info; =20 /* Based on the 32 bit code in do_kernel_trap */ =20 @@ -141,12 +141,9 @@ segv: end_exclusive(); /* We get the PC of the entry address - which is as good as anything, on a real kernel what you get depends on which mode it uses. */ - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->exception.vaddress; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); } =20 /* Handle a jump to the kernel code page. */ @@ -284,8 +281,6 @@ void cpu_loop(CPUARMState *env) CPUState *cs =3D env_cpu(env); int trapnr; unsigned int n, insn; - target_siginfo_t info; - uint32_t addr; abi_ulong ret; =20 for(;;) { @@ -320,11 +315,8 @@ void cpu_loop(CPUARMState *env) break; } =20 - info.si_signo =3D TARGET_SIGILL; - info.si_errno =3D 0; - info.si_code =3D TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr =3D env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, + env->regs[15]); } break; case EXCP_SWI: @@ -392,18 +384,14 @@ void cpu_loop(CPUARMState *env) * Otherwise SIGILL. This includes any SWI with * immediate not originally 0x9fxxxx, because * of the earlier XOR. + * Like the real kernel, we report the addr of= the + * SWI in the siginfo si_addr but leave the PC + * pointing at the insn after the SWI. */ - info.si_signo =3D TARGET_SIGILL; - info.si_errno =3D 0; - info.si_code =3D TARGET_ILL_ILLTRP; - info._sifields._sigfault._addr =3D env->regs[1= 5]; - if (env->thumb) { - info._sifields._sigfault._addr -=3D 2; - } else { - info._sifields._sigfault._addr -=3D 4; - } - queue_signal(env, info.si_signo, - QEMU_SI_FAULT, &info); + abi_ulong faultaddr =3D env->regs[15]; + faultaddr -=3D env->thumb ? 2 : 4; + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLT= RP, + faultaddr); } break; } @@ -434,24 +422,14 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - addr =3D env->exception.vaddress; - { - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D addr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + /* XXX: check env->error_code */ + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: excp_debug: - info.si_signo =3D TARGET_SIGTRAP; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr =3D env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[1= 5]); break; case EXCP_KERNEL_TRAP: if (do_kernel_trap(env)) --=20 2.20.1 From nobody Sun May 19 12:45:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628861188; cv=none; d=zohomail.com; s=zohoarc; b=ESP1wQ4y9ohaez3B8B7dut3ZoXCclGt6slc13w094rWFjsTMS5130oVBiZRBeGIUCbY7FhegFz8byG8PfuPIn8dtsxcnoT2DDaBI4ZAaPsu990yIVvBsrJehQv/ByQRJV6jMtoevXUyZtS++EQeTaEUxZs88/adPmomcYUtBw74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628861188; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FaVpNm4zi8LBLF74GF2v06M6jAfCJGSvBMAfoKeKoug=; b=bC41YQ8H7SUahtbn6QQBqSATLJLIfQ7STB5zNHagxz18FD7gpxWk2UEL/8Hs0zvWeiFtew3l69Dja/jIBdFdFMO9GUMkNqRLB7/sLgQDJtJHin4YHM8IEXpdxqQlqmXWdIycZfyJwUV22PhF6/yK/mill/QqDbnTiWgGQpzZTi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628861188668919.046471043116; Fri, 13 Aug 2021 06:26:28 -0700 (PDT) Received: from localhost ([::1]:49286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEXCd-00045s-Ar for importer@patchew.org; Fri, 13 Aug 2021 09:26:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEX4m-00063H-JA for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:22 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:39852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEX4k-0001Bg-Ft for qemu-devel@nongnu.org; Fri, 13 Aug 2021 09:18:20 -0400 Received: by mail-wr1-x42f.google.com with SMTP id q6so1750872wrv.6 for ; Fri, 13 Aug 2021 06:18:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q75sm1585705wme.40.2021.08.13.06.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 06:18:16 -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=FaVpNm4zi8LBLF74GF2v06M6jAfCJGSvBMAfoKeKoug=; b=VOaLi687fL6Is7ILAK3PKrUw3xskbJEMqf2kZdrf1Gr08zJIzt4R+rkRJtYjplg26g u2MK7poz6mnWwSRliLVouV2CblX5gFGKwrCYDxpYBfgWYDwu/t101sYG72Tpw3ZSPW0A 6HsXDsXxN/ERbko1IqZ+7LMerfw2jbnMgfBevG7EOhGAp7YkkNK/qYYfYSeiVJFDzRxL u0FcgX7DiA3SwTyfXqKwJvkp2KF6To9jbpUq4EKPUtQTd4bx1LewVIg3S9V2X/Y63OwU exf/hLuKkgDE3DmsWkVfOyQV195mcBJi14D5oZgpPklYj/ysOoNbcbVwYMkiFf0O/yC2 OjNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FaVpNm4zi8LBLF74GF2v06M6jAfCJGSvBMAfoKeKoug=; b=X1fF/lLF3BCzg73eoWcWQSkwtaunvYT9IP/Rb+fTZ3cwF2feJitWEmCRDNHffCtfd5 1SI0Arx/rwocC6+FAHn0AHLqTPCNYu4J5IaxxHiFbaonqKE+caW6jOHfXbu3NNwfj4iM D8m+JZbx2D6MCUMb8p5hlcyt6DnRR03EQb6KSr434izCydFN+BNQJi5cYZtNvgdU6dIf sW1PoIxuZgk7inCMf8WTwP1LnQjxtWMavI8/EOgXnbFzqxDNmjS1leqfdqILgkM0E9Tz uoFbQHCO+7Lstz3Juhn24DurQb4oNEBETRx3txRKjhm+S3YLFUTGfZeWGLCHhHbwRlCC fDqA== X-Gm-Message-State: AOAM530BeH4J2pTW0ugq9HOCfhnU9FtHctL5bRQkrgoBLLsetyrrvwIe Ze6Ax1byygWqLj/Q0XA1yosvvqEtqr2G0g== X-Google-Smtp-Source: ABdhPJzAp/qvARIkWgQRX7un8A2esKETp6DyePAEVActL5hXTEk5d2WScRdDv6OG8xJs85afql+mzg== X-Received: by 2002:adf:fb8f:: with SMTP id a15mr3151012wrr.92.1628860697168; Fri, 13 Aug 2021 06:18:17 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-6.2 7/7] linux-user/aarch64: Use force_sig_fault() Date: Fri, 13 Aug 2021 14:18:09 +0100 Message-Id: <20210813131809.28655-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210813131809.28655-1-peter.maydell@linaro.org> References: <20210813131809.28655-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.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: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628861190646100001 Content-Type: text/plain; charset="utf-8" Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 5d8675944d9..11e34cb1007 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -21,6 +21,7 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "qemu/guest-random.h" #include "semihosting/common-semi.h" #include "target/arm/syndrome.h" @@ -77,9 +78,8 @@ void cpu_loop(CPUARMState *env) { CPUState *cs =3D env_cpu(env); - int trapnr, ec, fsc; + int trapnr, ec, fsc, si_code; abi_long ret; - target_siginfo_t info; =20 for (;;) { cpu_exec_start(cs); @@ -108,18 +108,10 @@ void cpu_loop(CPUARMState *env) /* just indicate that signals should be handled asap */ break; case EXCP_UDEF: - info.si_signo =3D TARGET_SIGILL; - info.si_errno =3D 0; - info.si_code =3D TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr =3D env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->pc); break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info._sifields._sigfault._addr =3D env->exception.vaddress; - /* We should only arrive here with EC in {DATAABORT, INSNABORT= }. */ ec =3D syn_get_ec(env->exception.syndrome); assert(ec =3D=3D EC_DATAABORT || ec =3D=3D EC_INSNABORT); @@ -128,28 +120,24 @@ void cpu_loop(CPUARMState *env) fsc =3D extract32(env->exception.syndrome, 0, 6); switch (fsc) { case 0x04 ... 0x07: /* Translation fault, level {0-3} */ - info.si_code =3D TARGET_SEGV_MAPERR; + si_code =3D TARGET_SEGV_MAPERR; break; case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ - info.si_code =3D TARGET_SEGV_ACCERR; + si_code =3D TARGET_SEGV_ACCERR; break; case 0x11: /* Synchronous Tag Check Fault */ - info.si_code =3D TARGET_SEGV_MTESERR; + si_code =3D TARGET_SEGV_MTESERR; break; default: g_assert_not_reached(); } =20 - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, si_code, env->exception.vaddre= ss); break; case EXCP_DEBUG: case EXCP_BKPT: - info.si_signo =3D TARGET_SIGTRAP; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr =3D env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_SEMIHOST: env->xregs[0] =3D do_common_semihosting(cs); @@ -169,11 +157,7 @@ void cpu_loop(CPUARMState *env) /* Check for MTE asynchronous faults */ if (unlikely(env->cp15.tfsr_el[0])) { env->cp15.tfsr_el[0] =3D 0; - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info._sifields._sigfault._addr =3D 0; - info.si_code =3D TARGET_SEGV_MTEAERR; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MTEAERR, 0); } =20 process_pending_signals(env); --=20 2.20.1