From patchwork Fri Aug 13 13:18:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 496560 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp558185jar; Fri, 13 Aug 2021 06:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzz3JpGQxHtiTSGCAvad1nhm3lxdqET0Jc6A4ID/ALtlnMhZyOavx4VFFCroH4mrfyglkBF X-Received: by 2002:a5d:49cd:: with SMTP id t13mr3109989wrs.217.1628860994409; Fri, 13 Aug 2021 06:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628860994; cv=none; d=google.com; s=arc-20160816; b=pTN+GSzbC1dMFbLCy0jUWbpkiK/VsdwRRVx9QtWzf54mRgEkQo9pM/eOSZKJkNbViZ ujRjgIncjiIkkslIv2IXtqagHZr1oQ7A0CFD6Nqv08TCCuOJt8JhaQTXl0Q9WrdS0MQp zk4HJdFs++d0OuCktWVdiaTUUY8rcur2Ox3G0TcscO9Q5Yz5GkPSKCgYL1yo1hBK80LL rh61cisUkVoMkH4QvnlvFU97dfE5xo58Ib45E3BochW7G1YvQVbxIaBDWVimBl0Cj8DK 7Q5F8jnM0uDtyc9uQhuPHl38Rm/BzG4huo67BNkrCLqYBI2FMmug9JA89q/+0oLuXetG GCrw== 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=5MB/CWOu8y75nxH9S62qSbJCleKrqKA9mDnlY1X/YB4=; b=S8iZwKWor9L7kmtw4/Qjwu4Tn0JZsjrTV9rBDHX8PxYYeNt90rgFYXR6HQeWIxK9W3 uRtu7D1tG+x6dHVFYui863FObTcqNKpmTItHXHLOccnLWjpmIuaLfaoGTPKKnGmYuj5c VUbbIY9aF/5uUtcrqpXlyqHbwX72GF7f3qEXA4hLRjHjsiP6eqC5HGcD2Cgs+qejvcGf 1gKF15V5GH6jQtfMDkLe4iNgXcJtn9SPIyNQYAkrpaBxU1B/yYoKbQLO+ae9pcP5jSp8 P2hjWDycdH79QxeTYAGh4+pl/4nGgZYxPREgk1PwwtoCgCEgQBCH66CUfLhYpgljgVzj EQdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BeCjYGp5; 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 v12si1747348edc.154.2021.08.13.06.23.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Aug 2021 06:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BeCjYGp5; 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]:38874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX9V-0005S4-Ec for patch@linaro.org; Fri, 13 Aug 2021 09:23:13 -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) 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-Received: by 2002:a5d:574d:: with SMTP id q13mr3169796wrw.425.1628860692396; Fri, 13 Aug 2021 06:18:12 -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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/aarch64/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 Reviewed-by: Richard Henderson 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 = TARGET_SIGTRAP; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr = env->pc; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_SEMIHOST: From patchwork Fri Aug 13 13:18:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 496555 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp554616jar; Fri, 13 Aug 2021 06:19:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRn3KICWAYdiOcIOHsPF/BU5gVSWf0elgrHEx7KSfJQsdZjgEU8QcJaEsF1y46DTPTqKIa X-Received: by 2002:aa7:cb86:: with SMTP id r6mr3090811edt.181.1628860749838; Fri, 13 Aug 2021 06:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628860749; cv=none; d=google.com; s=arc-20160816; b=y6uTFxvSWn/AGm8aXbpx1cmrEvCWEZHG60xZ304FIY7acEqV/cDFWrV4lFJKIWJ+4l 2Pp0plcOc3b7SiBcfmu0kUhgt0crZPvKjU+djrmZzMPF2JBCWet0hzJQWKHA9u+zDrXo fzDIeHyVImGilCxh/xFjGbwapr4dLHbF/p8Ymbdbjt2yHn9i77A315Co36H0CZ6i0mcs wMVr9RHhfaj1j/jePnZ2l2kt7UFFct4GIvmtcVPBHyFHMMPxHoDqqzQqQgmfpKstxgkd IeNvvLQytTzZPMPB/FAlPEgWjrfWCE+lBNILc9PV7XtyaS48NIJr6qJuGGtJJvtUUHmT Fmdg== 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=OwsRmN+On96JlTIEqDrfPOxNFjdnyRq58apo5gMpvTk=; b=n4uFy5Xi9Bk/RgHWw/EHHwDw7AoZ63ZUL8eh1tgOlq9QY/vIGnfhxp+E8eO3Lf0NOu KOo/cDAoSS9EYwWFyt8O60p4yPBE8fn5KuTIZyDogdNjlVjePJxCstxQMHa97CMdQAns n0F04Eq3Hs4M/lrbE4Wthjkv/2cTrWHVWXtnhLfkKdExVtcz+bdKvZ/mDIHDESmC1ZYn qMLa4alZFi0Tq3bIv7vj6MTxOYWIzHjx9jsaop0amHQQSFwgxWMZb0IVgJo33CQZ/KlG RS5LCfQWVG/aWdIPeZX6mvdvAYwdN5yUgVB8/H7mAOZ3rzbdsCtI3vkJQJp4BU0wyPLB pwLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p9le70mF; 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 e4si1600508ejs.733.2021.08.13.06.19.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Aug 2021 06:19:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p9le70mF; 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]:55724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX5Y-00063X-NU for patch@linaro.org; Fri, 13 Aug 2021 09:19:08 -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) 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-Received: by 2002:a05:600c:5114:: with SMTP id o20mr2665051wms.176.1628860693052; 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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/arm/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 Reviewed-by: Richard Henderson 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 = TARGET_SIGTRAP; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr = env->regs[15]; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_KERNEL_TRAP: From patchwork Fri Aug 13 13:18:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 496558 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp555845jar; Fri, 13 Aug 2021 06:20:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY6Qv5DNbOKjqFOUJ+Pp7k17GzcxyoxcZXv4y9SQyUuNG4GZ8jPyi6xtPVjbby2AToMifv X-Received: by 2002:a05:6402:1299:: with SMTP id w25mr3230359edv.30.1628860836798; Fri, 13 Aug 2021 06:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628860836; cv=none; d=google.com; s=arc-20160816; b=ZRZxGySFoGy4e56CAOGbm4AaEhd91H0TE7hpvhn/HMtBaUtEZ/tcCvIC1QUPhuunSO 0QIeN/jdx/99kgdFtY1rU4ikFz2ilVRsTsAXYbh241oH4W7bbMWcsvY9+xWAbtK7miTE L7KDous6VCTuXEp7f/oGpKZ+wGf8T1ESgthCj1P4aBYttZacNv6nkutCnvgW0stou9dX pA+wfaifJ2uySJw5MklxiBZK2p50LJJHUGGs7YwtqSmA9DoF9EYhR1hjuvAMObJ3Lpco F+SdlVfsUoyuODAHZ5vH1akiDlezUKOE8t9IP3klXCF3P0H5KQikfE9Zz/JrNeSCVE9f tQGQ== 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=z1jD/SaL+e0IFj9uD3ovecMKRiP3oqP49v8hJs55uWQ=; b=E7c6pqOhL73YbQEsxx5DE9lyvjP6Md0524Jlrzr8Vmzwv95iWjqm6LAKzYM2/X8MgU U9oivkKcFsuXJYqDkajNwUUZVHT6WjRPMC/1MoEw9Td2VA78YQaLaI88GJP/FYn4BcE2 CKqNCyLNfgQNd1/vX/aVrXC96TOihm29TUnZ7AOMbjGPOfP+6a9KyK6HPsse5KH1mhX4 tzvPxD+A8G5wW+xEW+VM2o8+vjIhO3dNnUeSdK3P2pegZa7yueeTrnOedUcQqHxxOXKH RhCifMv2UGt2kpotPvfWsS9iKinMAfwAyHrqoKBv3MXiy/DILm7SUYFbxEEfkbPv7ybE ZKyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KNNFrDzH; 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 yd3si1705598ejb.632.2021.08.13.06.20.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Aug 2021 06:20:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KNNFrDzH; 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]:58424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX6x-0007so-QN for patch@linaro.org; Fri, 13 Aug 2021 09:20:35 -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) 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-Received: by 2002:a7b:c114:: with SMTP id w20mr2685272wmi.85.1628860693904; 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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/arm/cpu_loop.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson 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, uint32_t opcode) ts->fpa.fpsr |= raise & ~enabled; if (raise & enabled) { - target_siginfo_t info = { }; - /* * 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 = TARGET_SIGFPE; - info.si_code = TARGET_SI_KERNEL; - - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig(TARGET_SIGFPE); } else { env->regs[15] += 4; } From patchwork Fri Aug 13 13:18:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 496559 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp558139jar; Fri, 13 Aug 2021 06:23:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQQWYyDb815StF6TUowaiFGuln2vcKf2Fcba1S+7Fb4OP50v/3LHMZ3CnPRSE+L/uJVW+6 X-Received: by 2002:a17:906:2691:: with SMTP id t17mr2456433ejc.158.1628860990791; Fri, 13 Aug 2021 06:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628860990; cv=none; d=google.com; s=arc-20160816; b=V5yAFULjQx6qdIW6pZdEth89AvG77MkJFnXLN+tAq1KtQOXzowpiDSMkL8/uBikDho AvjczYP8CoQKAuUIBzJ2rN1YxQp+3Yews2Q7CV1cESfSmITESfcQc0rAlUXdpBmLopCm l1bXZ0D4y0tl8/i0XWc2mWOQN76r1cR3Jj5lelvxRMaWnZtNEZ+OQVUEcfEe3Rf8Yak1 BiMCCmjHoeqp7fP3w9zJeNeKxA2lIwnp9lKLtGZdX61mhSvUg6G6f6uDoRTXKNaWOFdO lVC7dQXQ5OVcnnPnWfy55DB21xzCEAPaZyuwfy5LvYpPgb+/CPUlYMyaQB/Au+zrWxfa vP7A== 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=d3Hr9Wc4dvCtUGT2UQ15hAVNCLMUJmbjebAXeIh4mmY=; b=hbsia1p8v14znSAZlftaukcs3Z3TDqDwpcwBCAnnctkSCYMLEBsyEvySTcNGUu9w6x PeOBgk906W9raI2s0KKZwCdykbDMMHqLFtdSlZseZVpdspqVC1TZT1b0GXf12tvcIeg2 fuwxsmSF7OPpBnwCpnXhKuhWVZudWCdagm6g8kv7VR1fQ7HKb4L4IKGlwdhozbUb+xPY V67Eq1UF9Wy+g9JYQMiUJYLBCOOVsQxsprjOO6zNyhtphCyItb/hZ7ISprNvxXC/GCg5 M7LJUEdxj2E96Vz9/9s4QAUMVwJ1UTnMPBcAZD/PSMd7Uyvgo/2r39iDJXao5t3j/Nul ZYKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ClGrxmKM; 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 s14si1701359edw.68.2021.08.13.06.23.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Aug 2021 06:23:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ClGrxmKM; 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]:38400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX9R-00056B-Qf for patch@linaro.org; Fri, 13 Aug 2021 09:23:09 -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) 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-Received: by 2002:a7b:ca45:: with SMTP id m5mr2624732wml.158.1628860694702; 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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson 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 = thread_cpu; CPUArchState *env = cpu->env_ptr; - target_siginfo_t info; + target_siginfo_t info = {}; info.si_signo = sig; info.si_errno = 0; From patchwork Fri Aug 13 13:18:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 496561 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp559645jar; Fri, 13 Aug 2021 06:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW9Y4kjacRtn+sCcXdXvKvsD6aAYivT1jUHz3p9WBd1dor2eI1Iokiyszdj8Tg24MQaDSZ X-Received: by 2002:a17:906:14c8:: with SMTP id y8mr2400792ejc.475.1628861088913; Fri, 13 Aug 2021 06:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628861088; cv=none; d=google.com; s=arc-20160816; b=EF04hg4reY8ZngQFcuBlbWXxu3+CTa7QTuSS8H78yQi3HW5jXjhfOhYkJ4UgovhGVj EWVoctnMjU0BAT0SOWlNwtHVi5twItoMDIDPg3lMpjU5hqk/KkU2FOyNDD+7uccYHD23 1yu1WWlEFrvnFOxx8qiJ3QVhmSKDIvaBEVIJny4fVrVSy5g53RVYz7QRUMUGwbp7D1MX CP0VrViyHHJVAKpkC0HQRJAP8+w8sbTLwZkDGjIbXHXYfsgN98DgLw+WCiDz716hmVgo TQ8+qd9Xtj6yrq8NpcCDj7qEo8GPfQX0poCgzDsz2LFUx6mPseUI5pWusVoc37bUIUPj HpVQ== 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=Mpfyk7/1xkPWCm67v6Q4b34MWfBO1kqI/kzOqeHhh68=; b=0BuZH0fEaVcQM+YeggzkYGueBhnR7EMlI2b3RAY565lgEVcBsRHRq9Oj08E3vZ6jCn d+5nXgXYbI+jmWis0hTvbu35Wm2Yb6ScBRT9yCvECirGRpBEuG/R7fXlOdmK+pUjg/EW UGqgNzTVmeMFy6rdWLyuSYL7kr1usQjqRfnCMbjSidKscT8aIG52Bl2hQ4iEwwaUPtYh MlTbBhtdfAbHih0KTJhAiR8eGUg5iTeaZsZtRyTlE1U9pnana1tohtvyH0YMGJjWvy6w N/EaOQc9/+Ewgs8pAeB5KyT3MiEpbHaL+rmmnIiw0TRj+ktAbMMZqLuTK2aVYHOjDIwr Sw8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mpUHRByN; 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 9si1716702ejy.65.2021.08.13.06.24.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Aug 2021 06:24:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mpUHRByN; 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]:45212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEXB1-0001Jj-UN for patch@linaro.org; Fri, 13 Aug 2021 09:24:47 -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) 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-Received: by 2002:a1c:7711:: with SMTP id t17mr2646248wmi.77.1628860695706; 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: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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- linux-user/signal-common.h | 1 + linux-user/signal.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) -- 2.20.1 Reviewed-by: Richard Henderson 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); } +/* + * 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 = thread_cpu; + CPUArchState *env = cpu->env_ptr; + target_siginfo_t info = {}; + + info.si_signo = sig; + info.si_errno = 0; + info.si_code = code; + info._sifields._sigfault._addr = 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. From patchwork Fri Aug 13 13:18:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 496556 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp554634jar; Fri, 13 Aug 2021 06:19:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnidCFLeOf5l8ArtdhG6Z4Sux4joU4mbilmjPCzlLjtbRIT2ZUm7U/mKQPdZPLCM79Am1V X-Received: by 2002:a50:fc10:: with SMTP id i16mr2039489edr.88.1628860750954; Fri, 13 Aug 2021 06:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628860750; cv=none; d=google.com; s=arc-20160816; b=PrrV4yGuEF43PxdYdaFrl7IeTLXmsdMtgTcKjBkbE9EmVN+luRSxe3uiReayHbqlcv E5CaJXrx0zPuc7tsX6sLtFQXM+Dh7uRE36Vp6DSbl+gE6LoFMa5BRLOePlHQGySeZ8j1 2VV3SOpPuq+IJxiKgrrBY+FS/3W8iqt0HRssekCZ5xehjRoRgAMSXjjQ2+QsZEslrGRv lNJtJmGt1xEmUUnliJB2S2NYk7FQ0e+wGC7lbUvEDzSJwGRl6qlxwBMk/2ji7jtX/RIA epBCUB5gdGpVoiswa6Akpx3YHTQ/d3N7FbT064DDiGl7FApETQMK4jJzMFt277K7YlJo kBjw== 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=fJIpsv1H5kq5YSGMr5mAwnnyIFFq6TrksBVoWM/ILDs=; b=SCiaX02Orz4C9UdrEfCL3hgR1S4siF8sTa+O6BMtEOypj6yRUX149UfAnHCz/nTUFA PfniVyPjL3/6UY4BlpHOThZvPRRKTcMUCcmqnc8qUqbmaxkEOKpvHgzFGaFtHn4utgZi 7OhMjR6OAH7ndGUbnuL68U8e417Sp0jRWpPVOc3ARuR7BhMrcfNWsGuf3ncUSYEPzGuE ZYWIlznmGnLaBnkhXm56dxdhdOmoaJ9C3iwhBBOrdbsd8uamyBuuvagXqVe7qujWLNS5 kC/10JuqH8v+EOv0XVq1hvkYTuLRqihFw/t6rSAZd7bR8D8uTJUwxdM9aUlowwP1uIqM xq9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eCR11VKx; 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 r16si1767780edq.576.2021.08.13.06.19.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Aug 2021 06:19:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eCR11VKx; 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]:55772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEX5Z-000667-Sr for patch@linaro.org; Fri, 13 Aug 2021 09:19:09 -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) 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-Received: by 2002:a1c:6a07:: with SMTP id f7mr2575581wmc.15.1628860696444; 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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell --- 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(-) -- 2.20.1 Reviewed-by: Richard Henderson 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" #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; /* Based on the 32 bit code in do_kernel_trap */ @@ -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 = TARGET_SIGSEGV; - info.si_errno = 0; /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->exception.vaddress; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); } /* Handle a jump to the kernel code page. */ @@ -284,8 +281,6 @@ void cpu_loop(CPUARMState *env) CPUState *cs = env_cpu(env); int trapnr; unsigned int n, insn; - target_siginfo_t info; - uint32_t addr; abi_ulong ret; for(;;) { @@ -320,11 +315,8 @@ void cpu_loop(CPUARMState *env) break; } - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr = 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 = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLTRP; - info._sifields._sigfault._addr = env->regs[15]; - if (env->thumb) { - info._sifields._sigfault._addr -= 2; - } else { - info._sifields._sigfault._addr -= 4; - } - queue_signal(env, info.si_signo, - QEMU_SI_FAULT, &info); + abi_ulong faultaddr = env->regs[15]; + faultaddr -= env->thumb ? 2 : 4; + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, + faultaddr); } break; } @@ -434,24 +422,14 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - addr = env->exception.vaddress; - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = 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 = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr = env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[15]); break; case EXCP_KERNEL_TRAP: if (do_kernel_trap(env)) From patchwork Fri Aug 13 13:18:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 496562 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp560828jar; Fri, 13 Aug 2021 06:26:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv6G/B7TAGhzGA25meF9zDRZBfegHW9PSX7sfkF7eMcrdjnKQRhIdPPNez/HbkWdzIMG33 X-Received: by 2002:a17:906:491a:: with SMTP id b26mr2458416ejq.25.1628861173671; Fri, 13 Aug 2021 06:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628861173; cv=none; d=google.com; s=arc-20160816; b=n3jS//QLyfooIKp3TUhftHpO7jXKzfgRmCWt39Yu6dNzlM0P3OKiEQoDSUImhfsE05 NMkU+b45Qr7b5m+jTsA9+atxqbnFCsJQX7dpYUHZQzxvrebXHE/Jg7msgaN3absgpObG 257u8MUi15q9v1JcEuf5CHbwGKT90ZuTerUYjMPex643qKx+ZIybg45gXmeJLlurNkzu gCaseT4Xh0lMJGzTjI25c9A11//R++lx1oO9AN8NmsifgJ7SPMhpsOZpDtGbvcbwDDjZ 2eUzjUaDTtUSQpNddNeeO8cey5mxMRTN4gQhDPYsV4ka4ZP/jHHETWdCXOBsmOnFOt4l ShbA== 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=FaVpNm4zi8LBLF74GF2v06M6jAfCJGSvBMAfoKeKoug=; b=svRTUjcU7rsPNd8ung/jQJaW3SeVL5A06k1vlV+CpFO6SYYyW+yDswkoe9r3n1ggto H+3mdR1UvnenfKZCpI6DoZJjsi+A2b7Y6ddWO81mmu/AK6ZtRYzkmZJtfmV+njb6XkkP Ixl0eXWyizrgg+b2PXE/ACHLiyjumikKQUiSKM5uft3Zs36jR9pBNWOauTYbuQpfAKmr F6s536EcfnyDNb0FTo5wyPb2pXbobjeNaEn/kmB5I0kYgcJoQ4Uld0o+pc4VBEYLj32i jtDp/dwTgj7CmqYgytFl1aAJi6TqGfXkexfY9TYi5jU92EJkjhKPbXlN+X3jXc8be6Zy SQcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VOaLi687; 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 nc22si1357571ejc.484.2021.08.13.06.26.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Aug 2021 06:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VOaLi687; 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]:48254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEXCO-0003Po-Kt for patch@linaro.org; Fri, 13 Aug 2021 09:26:12 -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) 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-Received: by 2002:adf:fb8f:: with SMTP id a15mr3151012wrr.92.1628860697168; 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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell --- linux-user/aarch64/cpu_loop.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson 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 = env_cpu(env); - int trapnr, ec, fsc; + int trapnr, ec, fsc, si_code; abi_long ret; - target_siginfo_t info; 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 = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr = 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 = TARGET_SIGSEGV; - info.si_errno = 0; - info._sifields._sigfault._addr = env->exception.vaddress; - /* We should only arrive here with EC in {DATAABORT, INSNABORT}. */ ec = syn_get_ec(env->exception.syndrome); assert(ec == EC_DATAABORT || ec == EC_INSNABORT); @@ -128,28 +120,24 @@ void cpu_loop(CPUARMState *env) fsc = extract32(env->exception.syndrome, 0, 6); switch (fsc) { case 0x04 ... 0x07: /* Translation fault, level {0-3} */ - info.si_code = TARGET_SEGV_MAPERR; + si_code = TARGET_SEGV_MAPERR; break; case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ - info.si_code = TARGET_SEGV_ACCERR; + si_code = TARGET_SEGV_ACCERR; break; case 0x11: /* Synchronous Tag Check Fault */ - info.si_code = TARGET_SEGV_MTESERR; + si_code = TARGET_SEGV_MTESERR; break; default: g_assert_not_reached(); } - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, si_code, env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr = 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] = 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] = 0; - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info._sifields._sigfault._addr = 0; - info.si_code = TARGET_SEGV_MTEAERR; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MTEAERR, 0); } process_pending_signals(env);