From nobody Fri May 3 14:01:13 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1622031789; cv=none; d=zohomail.com; s=zohoarc; b=KMPBtEabmVH/673PggXDx1rorBst09inN0NPL7HEJZn7Noafxj7nxgoSt9Si0W7kVcgTDAx/CGbmUanvK8GHz8tHuzDeA/bvik2niS18vv59PE6MizmJtMjDuwk+9F/67PkN8HSOGSDCcqfUvOiS+zazAMm6brmOcdvgQntWaiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622031789; h=Content-Type: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=KfA8qXEUy9bbVVK/akFipulP2A2BpZIpjv1lSajdBSk=; b=MxJfwsGXEydkuGsQByXRYIqi2MJPZLUcMX1aeEbGcTyoDrAXdlX4e9QnG97YzK3XjSpG0VmrFDo1xk3p4dkOS4SbT/aCeAuHAjfxklYPkPCLZ5ItCLrFJNbfPGhU2O7uZzW7QQBOPNuBx/3wCFWe/gUD0TnIWpIalbSm8STBLb4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16220317899407.912483822062768; Wed, 26 May 2021 05:23:09 -0700 (PDT) Received: from localhost ([::1]:55638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llsZ2-0004Uh-TL for importer2@patchew.org; Wed, 26 May 2021 08:23:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llsV4-0001ZX-1F for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:02 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:52146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llsUx-00032d-WE for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:01 -0400 Received: by mail-wm1-x32e.google.com with SMTP id b191so603102wmd.1 for ; Wed, 26 May 2021 05:18:54 -0700 (PDT) Received: from localhost ([82.44.17.50]) by smtp.gmail.com with ESMTPSA id c7sm19811030wrs.23.2021.05.26.05.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 05:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KfA8qXEUy9bbVVK/akFipulP2A2BpZIpjv1lSajdBSk=; b=MrJtjQcW06ZUIL9QbU926bZ+aJOBv0P8zFwQThgWw1iweY40rFyvXSbKwmEBdYVwut T80BuEKPokFRIXVpZ0DSSbh2o9PKG8KFPcy0q59MIVtsIs5NbdT9wVnv89Mr3V0ok17K 8oCIA4Uv/nmQAvOsIg6wZp/vO3U7tFIpacOXtIyU6GE7LFDy3y5ZeNDc1blMhFdgL0I8 PavNUPsZ/voZg8iRC0eFOoQ1MuGnc9WVieTA9Wkskyq0G+cgAROdAuIGSfM8oa8HKpKL cKow6NhOwDnc2yQ0M69iSd9sHjNU5Tnqc32TrJ/TDxAr71Ec0m3Tywmfg/YgaYRS2tTP Qd0w== 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=KfA8qXEUy9bbVVK/akFipulP2A2BpZIpjv1lSajdBSk=; b=kzALPfQ7CqsHEI1TEf6lez70mfxMtyADGekWCL9buYFdihSxtOXKRjqXOHfpm+RyA7 Ha0yWcERSflhsX3qXnkAbRzHJokXb+qiidvpBsI9YqjUyxeygB6XJq1vGwUoDiDpsVn+ sKDDv2+L4VpItBODKnjCpHVdYAX5YWYKCZvTz0bz02InLwnEouJJYoF5vXrAF/D7mmcs 5hNWL2B+dt2UvwUzcZOFYj9d4HssdIMCJVfgxNURhDV3TtKT62ZK1haGJ5WWyH/OyVHk WVhtxFn50wKlCji15AO2arEzX/P3KUT4gkMynJm+08Jo4xg9UQO2/pI/YseXxPps5dLx ru6A== X-Gm-Message-State: AOAM5322jp1hdkZkFxsPgke6aC3JAB/B4QtIWbYayFrKEwluMsobwWmd S8Tb1BEVADHKamXCxlaQiix9+g== X-Google-Smtp-Source: ABdhPJzI5BdSnyJ47IrOo52SaPJJ1VIoJOcZyon9OngcA8/PPkjgcTjnXwedjH3LBYph0hfgAxIkSg== X-Received: by 2002:a05:600c:219:: with SMTP id 25mr3096259wmi.156.1622031533102; Wed, 26 May 2021 05:18:53 -0700 (PDT) From: Jamie Iles To: qemu-arm@nongnu.org Subject: [PATCHv2 1/4] target/arm: fix missing exception class Date: Wed, 26 May 2021 13:18:44 +0100 Message-Id: <20210526121847.1935454-2-jamie@nuviainc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210526121847.1935454-1-jamie@nuviainc.com> References: <20210526121847.1935454-1-jamie@nuviainc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=jamie@nuviainc.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jamie Iles , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The DAIF and PAC checks used raise_exception_ra to raise an exception and unwind CPU state but raise_exception_ra is currently designed for handling data aborts as the syndrome is partially precomputed and encoded in the TB and then merged in merge_syn_data_abort when handling the data abort. Using raise_exception_ra for DAIF and PAC checks results in an empty syndrome being retrieved from data[2] in restore_state_to_opc and setting ESR to 0. This manifested as: kvm [571]: Unknown exception class: esr: 0x000000 =E2=80=93 Unknown/Uncategorized when launching a KVM guest when the host qemu used a CPU supporting EL2+pointer authentication and enabling pointer authentication in the guest. Rework raise_exception_ra such that the state is restored before raising the exception so that the exception is not clobbered by restore_state_to_opc. Fixes: 0d43e1a2d29a ("target/arm: Add PAuth helpers") Cc: Richard Henderson Cc: Peter Maydell Signed-off-by: Jamie Iles --- target/arm/op_helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index efcb60099277..078ed74ab962 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -63,8 +63,10 @@ void raise_exception(CPUARMState *env, uint32_t excp, void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome, uint32_t target_el, uintptr_t ra) { - CPUState *cs =3D do_raise_exception(env, excp, syndrome, target_el); - cpu_loop_exit_restore(cs, ra); + CPUState *cs =3D env_cpu(env); + + cpu_restore_state(cs, ra, true); + raise_exception(env, excp, syndrome, target_el); } =20 uint64_t HELPER(neon_tbl)(CPUARMState *env, uint32_t desc, --=20 2.30.2 From nobody Fri May 3 14:01:13 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1622031790; cv=none; d=zohomail.com; s=zohoarc; b=E9kk54Sr9L/3Z0LUr1LRqFDSBXwWz980HTbIbqb3QdsDCgi1aKWDS9Q6fXzs0I4H9b1HLlyup2qDocKyEhZFBKQTHoQqm+yqpwT5ASs62cr4XpNz8+x036pQ6Lz244rrbbvgDKbm8hMe1J9bMO8s1h+4ZtzyDx5lVwivp64pl2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622031790; 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=3PQhiScHPkNKcCY+PhXTE0UGJiFJX/FPoJRFcJeb+U0=; b=UFMOBRu3E9huGYhf/9PN9KLMRthMpVVemGfFOaIgXj/GFbTQrAj75rbnh3HPsjSWPVNRCA6A+4inzafVCuJenwre6BB9ZOjoF1w7lPr4yiteV7J5Ixj9WjD9KSAA51rmCpyLoU6WEDfkYq2Hp48FG0eD3GGkv4mXd1tzU68Q38U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622031790284188.2885696235145; Wed, 26 May 2021 05:23:10 -0700 (PDT) Received: from localhost ([::1]:55654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llsZ3-0004VH-4a for importer2@patchew.org; Wed, 26 May 2021 08:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llsV6-0001Zt-2d for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:04 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:56280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llsUy-00033H-0c for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:03 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 16so585634wmj.5 for ; Wed, 26 May 2021 05:18:55 -0700 (PDT) Received: from localhost ([82.44.17.50]) by smtp.gmail.com with ESMTPSA id n13sm21000887wrg.75.2021.05.26.05.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 05:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3PQhiScHPkNKcCY+PhXTE0UGJiFJX/FPoJRFcJeb+U0=; b=OpUxCrrXqnAop+Smfw6gb/h67wmtiVBhoiTxyI9RdJu0GgMBdKVFHdR1dgGqvRBx2L s7BGEwAUZQyxBpuIvHcFGuYyxcvqyu7PHtCJTQhZz5FQNgNqynij5pIP+96/biiSZisW jj/WgPmyAzSVzDQYJQ59PhezGe3ROXAFmhAhpT24o0n3OxLo9BLoXCeSu3HZxINww8lA F7v5JCa1csryj6+JmTK2ZCt1rnwj1cG32qvGQZfW4q+/THrWGWy0ZW9Aao+6LGhZRJ74 PAC9g1dLCRAYbkGQMkIueVyfijS3biBOgRU8Ilo+y1FqG2ZdXBV01/TPzb5p/Yv76+zU 8IxA== 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=3PQhiScHPkNKcCY+PhXTE0UGJiFJX/FPoJRFcJeb+U0=; b=otXWL1g+DXu/JVOvI9vyphVnSp9swCpEInlHJUmie4HatlTXs5NTqOVSq1jAa71T5l Ju2ETjCZTibTn7ZZ8evcvD3XDblhlMGV6MFVdU5OMv7FQBLEZDNhIrSn1qOnIMmTEUwe l5AdHdqyWyNZZDBsNWcMb/h6JdTL82cszm3sQOAKmdKC1tj1JBnAex2pe2tD8nl9QLmF JHb231309GUwM93HedUxMZaU/9HShtYG7zriuse8ziz4r9pet8C9Orp5ECxr1Pk93Tq9 hPADHp8rjNVI61FFU73rA3AVW6wgvHR+tbjuES8DVJbe+hJXjIxWjV4+5kbf4N5Tpq93 ZnZg== X-Gm-Message-State: AOAM530N+JbRqIYYX0KMtcfszafue4mwOvjIbnruhHNhKd1530nR9T5O 6uaSYbdiGRY7KinxDesKjhRXBA== X-Google-Smtp-Source: ABdhPJxxuPZR4qBKDwQ9bix/m6K/wNuvILQZFok1m5NYwWukVXYdSHkYb7c8r1Ow0bIx+UTrZFPhcg== X-Received: by 2002:a1c:c911:: with SMTP id f17mr29180288wmb.45.1622031534171; Wed, 26 May 2021 05:18:54 -0700 (PDT) From: Jamie Iles To: qemu-arm@nongnu.org Subject: [PATCHv2 2/4] target/arm: fold do_raise_exception into raise_exception Date: Wed, 26 May 2021 13:18:45 +0100 Message-Id: <20210526121847.1935454-3-jamie@nuviainc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210526121847.1935454-1-jamie@nuviainc.com> References: <20210526121847.1935454-1-jamie@nuviainc.com> 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=jamie@nuviainc.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jamie Iles , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Now that there are no other users of do_raise_exception, fold it into raise_exception. Cc: Richard Henderson Cc: Peter Maydell Signed-off-by: Jamie Iles --- target/arm/op_helper.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 078ed74ab962..3b3daa955598 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -27,8 +27,8 @@ #define SIGNBIT (uint32_t)0x80000000 #define SIGNBIT64 ((uint64_t)1 << 63) =20 -static CPUState *do_raise_exception(CPUARMState *env, uint32_t excp, - uint32_t syndrome, uint32_t target_el) +void raise_exception(CPUARMState *env, uint32_t excp, + uint32_t syndrome, uint32_t target_el) { CPUState *cs =3D env_cpu(env); =20 @@ -49,14 +49,6 @@ static CPUState *do_raise_exception(CPUARMState *env, ui= nt32_t excp, cs->exception_index =3D excp; env->exception.syndrome =3D syndrome; env->exception.target_el =3D target_el; - - return cs; -} - -void raise_exception(CPUARMState *env, uint32_t excp, - uint32_t syndrome, uint32_t target_el) -{ - CPUState *cs =3D do_raise_exception(env, excp, syndrome, target_el); cpu_loop_exit(cs); } =20 --=20 2.30.2 From nobody Fri May 3 14:01:13 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1622032020; cv=none; d=zohomail.com; s=zohoarc; b=bgqMNoiAS7jgTvsw0XgwYxevbS1MWX21prA+22iP+qc7YUj2NiaWDh4/FxhTLxKiZSbEtYCswJth7D4LR4ayuaGXIgWNpbvc0tmD6xPPF2UWJc0nduTJ7ON7zYLbGix9pMTpVw11CBS4cwtNfPnRzHMzO8s+qO0JjpFXapqoF7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622032020; 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=YzZcKLssN7IMbDyrpIALXOlPU1SgzuV4mOV0Xk2F1ro=; b=MB99MT1Mq5lJt3DQnsSUFwHSh3lSX6ijfOyn/qTR7e/GP/mOWkweWCQdoK+ua/0mbnJ9iY3AtaOz4NdkDGBnQwgtJVe/oq33ZBbt1vSfT9VWFS1TcVzy0WOQXtNyYPaEg3I6mmOk/EvlX5KrFx4OwK9s+Q2WIWosofHU3h8BgBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622032020248818.1577553277639; Wed, 26 May 2021 05:27:00 -0700 (PDT) Received: from localhost ([::1]:34532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llscl-0000z1-7b for importer2@patchew.org; Wed, 26 May 2021 08:26:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llsV6-0001a4-9y for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:04 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:46806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llsUy-00033q-CB for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:04 -0400 Received: by mail-wm1-x329.google.com with SMTP id l18-20020a1c79120000b0290181c444b2d0so382730wme.5 for ; Wed, 26 May 2021 05:18:55 -0700 (PDT) Received: from localhost ([82.44.17.50]) by smtp.gmail.com with ESMTPSA id q11sm14634522wrx.80.2021.05.26.05.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 05:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YzZcKLssN7IMbDyrpIALXOlPU1SgzuV4mOV0Xk2F1ro=; b=EdvBbosOQzKMxr8CF4OHRsrOo+a4DByEwTwhnCH4NvbGm/DN0eTvXW7z47PeIQf7i1 hWD3UjR24N3L0WVWOr5gbbaK2L1QxOReU24L6OpROSYkH/aIE7SAno+yNp+Gs0FhqLrw 4Fvan53o8KG8Higqh+wMRfuczEVdoBx9hN77+IwTzjTOi/PiEi+2jJ+5MIP6MIp/mDKt 0sceW266kQBnSHyyWTQBaVYmQejIDCKq4Ov8G3K96Imol0JZVkLfBsZwEbrDl6K6W/uV 6QPs+E+Xs2/9HSDLfo9A4VKFNk0hBUqdD3CYSGOULrkgc0Qthw5l4L0pGtSGwQMT4hIO chJg== 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=YzZcKLssN7IMbDyrpIALXOlPU1SgzuV4mOV0Xk2F1ro=; b=Egznp0+w5AldQF2d+fTpu3GtRx2NYBPYHs/cgRUl2Eg7wo82xdnnc+mDw/ijGJGPQs FbqP637hyMsDZnIHzLCkwsVn/jtVXZ9jkggPDY8aMEtO5620HeXr/VYVRkkozp1gfnzp AXDpnzY8CCWgp0h2W9Y7p3bsOqSRjtBp9etqJnv43ZMppaBgNMwTZxWb8HPl74PMNS/G L7ZKMmFwvXVl8iLRZTIvTCb0V81g7GYx5CRsuDwywG6Aaz0Nsl3ubJwoQ7S6MQxoDpKz QneMgFd+BhSlnyxuCZAfRrKbgqeXmH2FmlY6I1X7dS0cAei4vO5rHqj69EEWu3jb1fwj KM5w== X-Gm-Message-State: AOAM5335r16S0+0+FkzD4DhYbA+kI/FDUwXHimnZUVXBbNLiG+OddU4x cx1FEx+Z8mWlyZWfRt8Dg3I1EA== X-Google-Smtp-Source: ABdhPJz/YwYJK9TWFzbv6ha0yQNxxvWtkT/WCKqqWxvRgjZhOCw1PkRPDq+3Ja1SN2SnuG2fcCjGdg== X-Received: by 2002:a05:600c:4f15:: with SMTP id l21mr28463396wmq.37.1622031535083; Wed, 26 May 2021 05:18:55 -0700 (PDT) From: Jamie Iles To: qemu-arm@nongnu.org Subject: [PATCHv2 3/4] target/arm: use raise_exception_ra for MTE check failure Date: Wed, 26 May 2021 13:18:46 +0100 Message-Id: <20210526121847.1935454-4-jamie@nuviainc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210526121847.1935454-1-jamie@nuviainc.com> References: <20210526121847.1935454-1-jamie@nuviainc.com> 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=jamie@nuviainc.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jamie Iles , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Now that raise_exception_ra restores the state before raising the exception we can use restore_exception_ra to perform the state restore + exception raising without clobbering the syndrome. Cc: Richard Henderson Cc: Peter Maydell Signed-off-by: Jamie Iles --- target/arm/mte_helper.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c index a6fccc6e69e2..d48419583747 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -563,20 +563,13 @@ static void mte_check_fail(CPUARMState *env, uint32_t= desc, =20 switch (tcf) { case 1: - /* - * Tag check fail causes a synchronous exception. - * - * In restore_state_to_opc, we set the exception syndrome - * for the load or store operation. Unwind first so we - * may overwrite that with the syndrome for the tag check. - */ - cpu_restore_state(env_cpu(env), ra, true); env->exception.vaddress =3D dirty_ptr; =20 is_write =3D FIELD_EX32(desc, MTEDESC, WRITE); syn =3D syn_data_abort_no_iss(arm_current_el(env) !=3D 0, 0, 0, 0,= 0, is_write, 0x11); - raise_exception(env, EXCP_DATA_ABORT, syn, exception_target_el(env= )); + raise_exception_ra(env, EXCP_DATA_ABORT, syn, + exception_target_el(env), ra); /* noreturn, but fall through to the assert anyway */ =20 case 0: --=20 2.30.2 From nobody Fri May 3 14:01:13 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1622032239; cv=none; d=zohomail.com; s=zohoarc; b=h6wl9J0y8gasz621HSY7IbtWELVPlbB4GVjQbdzEOF79jiYbkrRLYgtvdSyreKpWKLhrgL5wXdTCB53NiyUED98FvWxyKtpyg8bSyitRmmH17q8kNwV0f79pAr2t1OmCVdbrce4j7MTGOWPlHYv2xZtoVkzQEZiapwq/nEDXX8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622032239; 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=5qHVT2mA2TWjPyo6mee0Tv5AQZrQhpH5e6Tzk+OdaYw=; b=SIa+BzG0ZmvMdX+kYal7lI9Qhi+4PzFIi/pu7ql8Vdo49Ew4SOk/9NR25PQYirruiecggZDSCZNRn6XBFbTC+lw3g167XCpA+Dp5G15ytC3vHZx2Y19rS9moQGZ/o+95v2xWU24KL3009bvl8/Z2Vikkdkwgna9VeIW2U0o7Q7o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622032239100422.1705010308291; Wed, 26 May 2021 05:30:39 -0700 (PDT) Received: from localhost ([::1]:38980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llsgI-0003yQ-2E for importer2@patchew.org; Wed, 26 May 2021 08:30:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llsV7-0001dD-PD for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:05 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:40937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llsUz-00035n-U1 for qemu-devel@nongnu.org; Wed, 26 May 2021 08:19:05 -0400 Received: by mail-wr1-x433.google.com with SMTP id z17so901648wrq.7 for ; Wed, 26 May 2021 05:18:57 -0700 (PDT) Received: from localhost ([82.44.17.50]) by smtp.gmail.com with ESMTPSA id u132sm12625069wmg.31.2021.05.26.05.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 05:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5qHVT2mA2TWjPyo6mee0Tv5AQZrQhpH5e6Tzk+OdaYw=; b=pZ46IXtvzWEFNsVPXg7mulQ8YclaSoDz/LR2AJwKW/98JnspqYM5lq6kms1mhfuMbm I+mGHiOOKO5nDMB/vNRACFa8H60W89+LJV70Ro6RKOFDm8UUi/7eTHg5W4MOXj+5rll5 oWv7YT0QMTuV5SfL9nooMQlP7qA2fjgmQwsvNnVUXMmsICSRN+G7aSgEAvTxt0R71oCG /t6Y2vVyfWh4MZ+8v6U45MVw8kbTfZ9ser7YLm6A2UQhxYHQwDleY4eNFj9tmyd1akGx La94JAAsQIpeS0WOOaNp+sJgh51Sg1Kpi1XhldE1SYE7J1ZFCkYjFnlFglCs5/JCXm7E 6bxw== 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=5qHVT2mA2TWjPyo6mee0Tv5AQZrQhpH5e6Tzk+OdaYw=; b=btaw7bbVKioQ59LHZ8v2xxQYzmEO99PHcBMiEpuSU+hhW4J0M6bEE0VTXLf/q0JnLO B5sN+dBTuug6AQRlDKsu6aWGyVnZiUR98j6vDkb31ce+CPy7lIx54dngLpcjuidGsh98 pO1MsjiB5mYgRKsAZrHsQJ11rm1aWMN29Tht7Inh8yuqV/1zYgiv0iZkwmrq5961arF2 eLEHy6EcPIoWSo+SASfWefiKqV60s4KK5M35P6l2HJ/8e4WTl3DEDf23u/sLtOEr+qqh j7yt1uYmruTuZECu/8b2o3kFYvgVR4jpo05tYgtb1RJBD1l6h5bgzy41EeGGQCw9cLL5 jI2A== X-Gm-Message-State: AOAM530DXFqyUpqXXazteakXUiy/r4USXAZzONt8I0tx7ZADWtlpmJz6 wVF5zlUGjvFG64ekaDsi37aE/A== X-Google-Smtp-Source: ABdhPJzebsx/LvF1Quk/oR+/PuI19UCJneO2YtR/xGFbr5h7SBf1KzwoMp9MwZ+sEo1POs/IOjlGJQ== X-Received: by 2002:a05:6000:137a:: with SMTP id q26mr3186178wrz.216.1622031536174; Wed, 26 May 2021 05:18:56 -0700 (PDT) From: Jamie Iles To: qemu-arm@nongnu.org Subject: [PATCHv2 4/4] target/arm: use raise_exception_ra for stack limit exception Date: Wed, 26 May 2021 13:18:47 +0100 Message-Id: <20210526121847.1935454-5-jamie@nuviainc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210526121847.1935454-1-jamie@nuviainc.com> References: <20210526121847.1935454-1-jamie@nuviainc.com> 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=jamie@nuviainc.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jamie Iles , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Now that raise_exception_ra restores the state before raising the exception we can use restore_exception_ra to perform the state restore + exception raising without clobbering the PC/condbits. Cc: Richard Henderson Cc: Peter Maydell Signed-off-by: Jamie Iles --- target/arm/m_helper.c | 5 +---- target/arm/op_helper.c | 10 +--------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index d63ae465e1e7..c793dc486f0d 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -2600,10 +2600,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t mask= reg, uint32_t val) limit =3D is_psp ? env->v7m.psplim[false] : env->v7m.msplim[fa= lse]; =20 if (val < limit) { - CPUState *cs =3D env_cpu(env); - - cpu_restore_state(cs, GETPC(), true); - raise_exception(env, EXCP_STKOF, 0, 1); + raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); } =20 if (is_psp) { diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 3b3daa955598..23365b33feac 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -90,15 +90,7 @@ void HELPER(v8m_stackcheck)(CPUARMState *env, uint32_t n= ewvalue) * raising an exception if the limit is breached. */ if (newvalue < v7m_sp_limit(env)) { - CPUState *cs =3D env_cpu(env); - - /* - * Stack limit exceptions are a rare case, so rather than syncing - * PC/condbits before the call, we use cpu_restore_state() to - * get them right before raising the exception. - */ - cpu_restore_state(cs, GETPC(), true); - raise_exception(env, EXCP_STKOF, 0, 1); + raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); } } =20 --=20 2.30.2