From nobody Fri May 17 16:17:58 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=1603209508; cv=none; d=zohomail.com; s=zohoarc; b=D09Jwul8hLjf0Eg8Lp4M49PBsicznBE8OfCOZyJyBoRy0xEDW+6t13fleGH1FXIjquLCNTmvkeKATGWH3b5NIZFsePJHLv5GG/0mZxZln86qMOjubAq97o4+BYzapWLqGkQLCvD8dFEddYWtuWKdkB1y6+Q6NHZuK9RDWygnHQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209508; h=Content-Transfer-Encoding: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=XOCeDt/XshK6ncC0g9UgbF4Gv2PxS5XPW6TaNeQwZoc=; b=G7NO+2MXLK3iTSR5oX59kpHQA9miL2N8Z4cUuQcMemPEhqnRsgNrPlqGcyeQjrjdAm0dHB4ye/0ssCgkfzsZcGUl3Z84ZahTHcah90st8Wqmrl0TFu0NHtfeEWAU3QnIoQU4F1+2EQnHO7oFOM8bCU0bYDNYb4ODE7MPzalBCoY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209508478877.8812093540027; Tue, 20 Oct 2020 08:58:28 -0700 (PDT) Received: from localhost ([::1]:60224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu1r-0005zV-HF for importer@patchew.org; Tue, 20 Oct 2020 11:58:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0Y-00049M-Ql for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:06 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:45190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0V-0003pH-FN for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:06 -0400 Received: by mail-wr1-x42c.google.com with SMTP id e17so2770782wru.12 for ; Tue, 20 Oct 2020 08:57:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.56.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XOCeDt/XshK6ncC0g9UgbF4Gv2PxS5XPW6TaNeQwZoc=; b=tZHqj/4qIYoda6/BxM5FiSZthev/nTdKYHosS4UsZ1UgSUQ8KplFQLXjUR/CWwk/VM VAqhl6tNr7v4U1KlWryYSUsbDfGygNrXMLjAn0v+8PIeLdWyX+Cxk9Fq91n+QQtVPVK0 OpbztpwG3R6MyQ8lx3hmuQDw0Z3slfTe4pQxgn/604yUSO0CJ5t7M+SdSkRUTVXhtF/a xOuZfAQpv+t7znFuKyIocjz5vwekiEcFXrb6skwSY7eL4RF60CRkWZZ3Fb9JtbiTOt2q KQv6V/JlEDs7RELFt4pmHLfBTt4YoqnW0fTUU4EjQ70IXqtXtIr9j5Ri+z96RRv23C6V u0rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XOCeDt/XshK6ncC0g9UgbF4Gv2PxS5XPW6TaNeQwZoc=; b=W3ilkHsp7MAlJMhRYhxse5SEWZk1trZlcT9xB5p7eQCoOBvPnJj15UQ2dpTG3kci+B bmAz1fMOwnIjN1PjmKMGlzbER73hNhH/8E4PIr0PhUkQQt1s63g9CrKrfPJsaBeEpFj5 Cbe8kNcc6H+468ZMSTcBoi0T3kUOOSqFUHgPrYwmJLuQLJes5d5YSmXmGUqTh4JonheC Ihb/aDlx87UU/vhftMJkMmJAt9SvIqsS4LcJrUgcXCoI+96YGlZPvrJsk1iUx7+o4MoP wYOMQ5WskxHXyEVs9IQm3/hh9bZo9r5Z3OdN7IxhlDxW8NX9vjSho/c2ZheWEKw67HqN 2rCw== X-Gm-Message-State: AOAM530hIlNBYmlF6sU5cKPclCXrKRGcPVNrKEQDni5SQ3/qiWpidrrm KMfCEQOU45TRBU/AU1u54trptdSX1zO0aQ== X-Google-Smtp-Source: ABdhPJwboZ4UfVuz4A7gY+F7hoiDjeZNUsyWT/3PG7mvM5grmFqJRnN8qe7eLsAl+32nEaJDtzMrLg== X-Received: by 2002:adf:b353:: with SMTP id k19mr4198342wrd.216.1603209420838; Tue, 20 Oct 2020 08:57:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/41] target/arm: Fix SMLAD incorrect setting of Q bit Date: Tue, 20 Oct 2020 16:56:16 +0100 Message-Id: <20201020155656.8045-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The SMLAD instruction is supposed to: * signed multiply Rn[15:0] * Rm[15:0] * signed multiply Rn[31:16] * Rm[31:16] * perform a signed addition of the products and Ra * set Rd to the low 32 bits of the theoretical infinite-precision result * set the Q flag if the sign-extension of Rd would differ from the infinite-precision result (ie on overflow) Our current implementation doesn't quite do this, though: it performs an addition of the products setting Q on overflow, and then it adds Ra, again possibly setting Q. This sometimes incorrectly sets Q when the architecturally mandated only-check-for-overflow-once algorithm does not. For instance: r1 =3D 0x80008000; r2 =3D 0x80008000; r3 =3D 0xffffffff smlad r0, r1, r2, r3 This is (-32768 * -32768) + (-32768 * -32768) - 1 The products are both 0x4000_0000, so when added together as 32-bit signed numbers they overflow (and QEMU sets Q), but because the addition of Ra =3D=3D -1 brings the total back down to 0x7fff_ffff there is no overflow for the complete operation and setting Q is incorrect. Fix this edge case by resorting to 64-bit arithmetic for the case where we need to add three values together. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201009144712.11187-1-peter.maydell@linaro.org --- target/arm/translate.c | 58 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index d34c1d351a6..d8729e42c48 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -7401,21 +7401,59 @@ static bool op_smlad(DisasContext *s, arg_rrrr *a, = bool m_swap, bool sub) gen_smul_dual(t1, t2); =20 if (sub) { - /* This subtraction cannot overflow. */ + /* + * This subtraction cannot overflow, so we can do a simple + * 32-bit subtraction and then a possible 32-bit saturating + * addition of Ra. + */ tcg_gen_sub_i32(t1, t1, t2); + tcg_temp_free_i32(t2); + + if (a->ra !=3D 15) { + t2 =3D load_reg(s, a->ra); + gen_helper_add_setq(t1, cpu_env, t1, t2); + tcg_temp_free_i32(t2); + } + } else if (a->ra =3D=3D 15) { + /* Single saturation-checking addition */ + gen_helper_add_setq(t1, cpu_env, t1, t2); + tcg_temp_free_i32(t2); } else { /* - * This addition cannot overflow 32 bits; however it may - * overflow considered as a signed operation, in which case - * we must set the Q flag. + * We need to add the products and Ra together and then + * determine whether the final result overflowed. Doing + * this as two separate add-and-check-overflow steps incorrectly + * sets Q for cases like (-32768 * -32768) + (-32768 * -32768) + -= 1. + * Do all the arithmetic at 64-bits and then check for overflow. */ - gen_helper_add_setq(t1, cpu_env, t1, t2); - } - tcg_temp_free_i32(t2); + TCGv_i64 p64, q64; + TCGv_i32 t3, qf, one; =20 - if (a->ra !=3D 15) { - t2 =3D load_reg(s, a->ra); - gen_helper_add_setq(t1, cpu_env, t1, t2); + p64 =3D tcg_temp_new_i64(); + q64 =3D tcg_temp_new_i64(); + tcg_gen_ext_i32_i64(p64, t1); + tcg_gen_ext_i32_i64(q64, t2); + tcg_gen_add_i64(p64, p64, q64); + load_reg_var(s, t2, a->ra); + tcg_gen_ext_i32_i64(q64, t2); + tcg_gen_add_i64(p64, p64, q64); + tcg_temp_free_i64(q64); + + tcg_gen_extr_i64_i32(t1, t2, p64); + tcg_temp_free_i64(p64); + /* + * t1 is the low half of the result which goes into Rd. + * We have overflow and must set Q if the high half (t2) + * is different from the sign-extension of t1. + */ + t3 =3D tcg_temp_new_i32(); + tcg_gen_sari_i32(t3, t1, 31); + qf =3D load_cpu_field(QF); + one =3D tcg_const_i32(1); + tcg_gen_movcond_i32(TCG_COND_NE, qf, t2, t3, one, qf); + store_cpu_field(qf, QF); + tcg_temp_free_i32(one); + tcg_temp_free_i32(t3); tcg_temp_free_i32(t2); } store_reg(s, a->rd, t1); --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209726; cv=none; d=zohomail.com; s=zohoarc; b=kvn9VH7SPRWm2czE+lxD9EcPEbgGjb3JFbRIT/6VNuCaWuEup+Zm4BxHwAfm0MXH2lo3K7SBr9rEMi5G++t0y9Qu/fpe88LwB0JMqBpWJNGJObcC1OmVYhZM+OJqb59MSaQQJDTZpO4K39mDj8ey+g6wISOtRiiSo7Ix4KpVSrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209726; h=Content-Transfer-Encoding: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=hW/WffD7mpSuczr6jlz/cmphSo0bxHD9q1xWU7+BhZQ=; b=XpFC7zGW9MAXmpbW+LV0o/XlYlpeFevqc/ggtTRsCZWsrtcix94pT7wMqpzpED+zSyKOU0xYyNOl+idavvpdSkUoC3VEB0G95px600rZMzEJ0ZDETlpJ88xXAk5oIPkjb9fU7v7yKxilvlAVwSirh6+hUyZG+96Tat/H6UZMSsk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209726795804.3893661950808; Tue, 20 Oct 2020 09:02:06 -0700 (PDT) Received: from localhost ([::1]:40588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu4w-00011w-Oy for importer@patchew.org; Tue, 20 Oct 2020 12:01:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0b-0004Ab-2e for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:09 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:37715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0Y-0003qa-KR for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:08 -0400 Received: by mail-wm1-x32f.google.com with SMTP id c16so2512821wmd.2 for ; Tue, 20 Oct 2020 08:57:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hW/WffD7mpSuczr6jlz/cmphSo0bxHD9q1xWU7+BhZQ=; b=xPXLm48ZYbt4HC4VSmZz+LNnqFa5dakGiNH4VPmRXD0Zvyu9uYe/Tx8GalckW56+S+ tYTOG76sXKD+Xv7nlvyEclil0FEA9NL8b55cHTvVkb200YArW+8NmBfxFMG9imKXXp4S WZlMiMsF+oA77zXvt6oS6Q966mECvJQz+8RHgRvpj/QnJmBmN1KVMOIyvuPZ+hwZ+hbG 5bWwXYEqZWgLuVK88amys5KFGj6EqDiYU31Uic8FIb9+BWMuOKSUE+7BHfBfOKXiHGWS poawm/R3VdNzy1cnWp5ZlihYSCYwKwa+khH6shmzddpc6CHZFX8kQtjwlxRGtcJ8u2VC 8D+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hW/WffD7mpSuczr6jlz/cmphSo0bxHD9q1xWU7+BhZQ=; b=NiGi96OjahCvRE3rmMgVuLKqErrq+su70ZX7ZCnBLMf3mWDnLtx9m1fCOLwYvb/fJl mh1nyGQaceZqRnCTlYZNYQcxeErUmoW6LSOsWjTFuCvomDcr7vMLQxQXudOkzA9NHmMi d/BE/aAQKOP2Vw/svDalC50ZqNKXoNrm/kJN5PrUUm+vsAblvczrInO165MDCZEA6Qoq sSZzxyHY7YLFNzKJ9uQNYZkTxQYKDqnz6qMGjQqHX5OpXu1NWkAcseMpI/BQY1wfOjCz 9VUiI3the8IKnlXbmrFFrn8fMFEmZe1Xm48MqosfiyEwwRvhVMFw4xZbNqdvo/JJ197v osBw== X-Gm-Message-State: AOAM533jf3FltCSEMmoAWFWS+t3qA094bb1MtWlz2FvD52LZwhbR5ebb bLjROLQQP1iUj+9EcxRUb1cNOehor3CWfw== X-Google-Smtp-Source: ABdhPJw1AUZpeYO3CaeOq9AJ69ixoaj3dwfwKyI0M2R6zJCWT91tdhsrc9kzLvyiFCPQoRHgeosb0Q== X-Received: by 2002:a7b:c0d8:: with SMTP id s24mr3564224wmh.156.1603209424179; Tue, 20 Oct 2020 08:57:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/41] target/arm: AArch32 VCVT fixed-point to float is always round-to-nearest Date: Tue, 20 Oct 2020 16:56:17 +0100 Message-Id: <20201020155656.8045-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" For AArch32, unlike the VCVT of integer to float, which honours the rounding mode specified by the FPSCR, VCVT of fixed-point to float is always round-to-nearest. (AArch64 fixed-point-to-float conversions always honour the FPCR rounding mode.) Implement this by providing _round_to_nearest versions of the relevant helpers which set the rounding mode temporarily when making the call to the underlying softfloat function. We only need to change the VFP VCVT instructions, because the standard- FPSCR value used by the Neon VCVT is always set to round-to-nearest, so we don't need to do the extra work of saving and restoring the rounding mode. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201013103532.13391-1-peter.maydell@linaro.org --- target/arm/helper.h | 13 +++++++++++++ target/arm/vfp_helper.c | 23 ++++++++++++++++++++++- target/arm/translate-vfp.c.inc | 24 ++++++++++++------------ 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/target/arm/helper.h b/target/arm/helper.h index 8defd7c8019..774d2cddb5c 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -213,6 +213,19 @@ DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr) DEF_HELPER_3(vfp_sqtoh, f16, i64, i32, ptr) DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr) =20 +DEF_HELPER_3(vfp_shtos_round_to_nearest, f32, i32, i32, ptr) +DEF_HELPER_3(vfp_sltos_round_to_nearest, f32, i32, i32, ptr) +DEF_HELPER_3(vfp_uhtos_round_to_nearest, f32, i32, i32, ptr) +DEF_HELPER_3(vfp_ultos_round_to_nearest, f32, i32, i32, ptr) +DEF_HELPER_3(vfp_shtod_round_to_nearest, f64, i64, i32, ptr) +DEF_HELPER_3(vfp_sltod_round_to_nearest, f64, i64, i32, ptr) +DEF_HELPER_3(vfp_uhtod_round_to_nearest, f64, i64, i32, ptr) +DEF_HELPER_3(vfp_ultod_round_to_nearest, f64, i64, i32, ptr) +DEF_HELPER_3(vfp_shtoh_round_to_nearest, f16, i32, i32, ptr) +DEF_HELPER_3(vfp_uhtoh_round_to_nearest, f16, i32, i32, ptr) +DEF_HELPER_3(vfp_sltoh_round_to_nearest, f16, i32, i32, ptr) +DEF_HELPER_3(vfp_ultoh_round_to_nearest, f16, i32, i32, ptr) + DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) =20 DEF_HELPER_FLAGS_3(vfp_fcvt_f16_to_f32, TCG_CALL_NO_RWG, f32, f16, ptr, i3= 2) diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index 5666393ef79..abfdb6a8e23 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -393,12 +393,32 @@ float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *= env) return float64_to_float32(x, &env->vfp.fp_status); } =20 -/* VFP3 fixed point conversion. */ +/* + * VFP3 fixed point conversion. The AArch32 versions of fix-to-float + * must always round-to-nearest; the AArch64 ones honour the FPSCR + * rounding mode. (For AArch32 Neon the standard-FPSCR is set to + * round-to-nearest so either helper will work.) AArch32 float-to-fix + * must round-to-zero. + */ #define VFP_CONV_FIX_FLOAT(name, p, fsz, ftype, isz, itype) \ ftype HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \ void *fpstp) \ { return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); } =20 +#define VFP_CONV_FIX_FLOAT_ROUND(name, p, fsz, ftype, isz, itype) \ + ftype HELPER(vfp_##name##to##p##_round_to_nearest)(uint##isz##_t x, \ + uint32_t shift, \ + void *fpstp) \ + { \ + ftype ret; \ + float_status *fpst =3D fpstp; \ + FloatRoundMode oldmode =3D fpst->float_rounding_mode; \ + fpst->float_rounding_mode =3D float_round_nearest_even; \ + ret =3D itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); \ + fpst->float_rounding_mode =3D oldmode; \ + return ret; \ + } + #define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, ftype, isz, itype, ROUND, s= uff) \ uint##isz##_t HELPER(vfp_to##name##p##suff)(ftype x, uint32_t shift, \ void *fpst) \ @@ -412,6 +432,7 @@ uint##isz##_t HELPER(vfp_to##name##p##suff)(ftype x, ui= nt32_t shift, \ =20 #define VFP_CONV_FIX(name, p, fsz, ftype, isz, itype) \ VFP_CONV_FIX_FLOAT(name, p, fsz, ftype, isz, itype) \ +VFP_CONV_FIX_FLOAT_ROUND(name, p, fsz, ftype, isz, itype) \ VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, ftype, isz, itype, \ float_round_to_zero, _round_to_zero) \ VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, ftype, isz, itype, \ diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc index 28e0dba5f14..9b11b81f80d 100644 --- a/target/arm/translate-vfp.c.inc +++ b/target/arm/translate-vfp.c.inc @@ -3141,16 +3141,16 @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_= VCVT_fix_sp *a) /* Switch on op:U:sx bits */ switch (a->opc) { case 0: - gen_helper_vfp_shtoh(vd, vd, shift, fpst); + gen_helper_vfp_shtoh_round_to_nearest(vd, vd, shift, fpst); break; case 1: - gen_helper_vfp_sltoh(vd, vd, shift, fpst); + gen_helper_vfp_sltoh_round_to_nearest(vd, vd, shift, fpst); break; case 2: - gen_helper_vfp_uhtoh(vd, vd, shift, fpst); + gen_helper_vfp_uhtoh_round_to_nearest(vd, vd, shift, fpst); break; case 3: - gen_helper_vfp_ultoh(vd, vd, shift, fpst); + gen_helper_vfp_ultoh_round_to_nearest(vd, vd, shift, fpst); break; case 4: gen_helper_vfp_toshh_round_to_zero(vd, vd, shift, fpst); @@ -3200,16 +3200,16 @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_= VCVT_fix_sp *a) /* Switch on op:U:sx bits */ switch (a->opc) { case 0: - gen_helper_vfp_shtos(vd, vd, shift, fpst); + gen_helper_vfp_shtos_round_to_nearest(vd, vd, shift, fpst); break; case 1: - gen_helper_vfp_sltos(vd, vd, shift, fpst); + gen_helper_vfp_sltos_round_to_nearest(vd, vd, shift, fpst); break; case 2: - gen_helper_vfp_uhtos(vd, vd, shift, fpst); + gen_helper_vfp_uhtos_round_to_nearest(vd, vd, shift, fpst); break; case 3: - gen_helper_vfp_ultos(vd, vd, shift, fpst); + gen_helper_vfp_ultos_round_to_nearest(vd, vd, shift, fpst); break; case 4: gen_helper_vfp_toshs_round_to_zero(vd, vd, shift, fpst); @@ -3265,16 +3265,16 @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_= VCVT_fix_dp *a) /* Switch on op:U:sx bits */ switch (a->opc) { case 0: - gen_helper_vfp_shtod(vd, vd, shift, fpst); + gen_helper_vfp_shtod_round_to_nearest(vd, vd, shift, fpst); break; case 1: - gen_helper_vfp_sltod(vd, vd, shift, fpst); + gen_helper_vfp_sltod_round_to_nearest(vd, vd, shift, fpst); break; case 2: - gen_helper_vfp_uhtod(vd, vd, shift, fpst); + gen_helper_vfp_uhtod_round_to_nearest(vd, vd, shift, fpst); break; case 3: - gen_helper_vfp_ultod(vd, vd, shift, fpst); + gen_helper_vfp_ultod_round_to_nearest(vd, vd, shift, fpst); break; case 4: gen_helper_vfp_toshd_round_to_zero(vd, vd, shift, fpst); --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209874; cv=none; d=zohomail.com; s=zohoarc; b=J/KGqr8KMAtFeQkCavM/cyqTIs0Yv2ZAWt4qB2rV9mK6wPVYoI6XtCdW5QP0BzeeIuTgF9LwKhhoq3z57rBNFIfNGENO/7UzaPLowhFQd8itifealjL6bJyQwPYMfpnudD4SNv/s6d5iro0s3aGjfkKAyj49vpvo2QSN+JZJRaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209874; h=Content-Type:Content-Transfer-Encoding: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=kmrpujIYHxAX8yVXk3nU79vFEhUn765LzbagDMPL/ls=; b=n1SyI99L8m4rDF180ElYZ0oo48ZRd7lC6jJTcvRLmfC2wa4QNrPD+pG6FYDujPMCY1COxy344/UBpaypNnW6B6NXQ/CL5accnqK3Kp6ciarcFceSxRaXmhl0rKlSeiQnm2lkHauOFPSrpKlTmtlET40vhzFL0ij1a70zTUNiEs4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209874531636.4404639658011; Tue, 20 Oct 2020 09:04:34 -0700 (PDT) Received: from localhost ([::1]:49148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu7l-0004iW-Gu for importer@patchew.org; Tue, 20 Oct 2020 12:04:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0d-0004CP-M1 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:11 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:40657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0a-0003qu-Na for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:11 -0400 Received: by mail-wr1-x444.google.com with SMTP id h5so2780235wrv.7 for ; Tue, 20 Oct 2020 08:57:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kmrpujIYHxAX8yVXk3nU79vFEhUn765LzbagDMPL/ls=; b=I3Ekgn0PHJPOIjnwrPCcE+WZy1gNdgfDsmr8ZZaMos4fdqWIJNxR87/wP2sbEzODgV f7CgMoIuiAHDTAsKnMS2syKds55dJRVTK4d2duk+jpOTymbxnEdp36aTFYg/6TFVOMkL /2lVZm12T2QzWvaPSiJ14u0jbVUiTwYHVH0RpGHDJJ+pMb6iw+CoeUNFvX8NWVI+R24E V+2OaNh7vf2sTdfpJC70iATITolgSbn2zEvrv4vMDEDwwW0SiLBxnWMybk2D27XzP9bm 6ewLHI2M6Jj2KY7gJqTNz1ti6ooHOq/7odMzX2iwkoUTeL7ANiiTgUQSnt1frlyVmGob TVIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kmrpujIYHxAX8yVXk3nU79vFEhUn765LzbagDMPL/ls=; b=M5b2CcedyQUZofYtw0wPet/1rx4zjz1TS+XNOmVXDlz7b6+a4/vo4+0RSKlvnYKgQT mCutrzyBt6BTaY1mAmEtShNVIYHbttFtVTeD+nwUMpVLcneL734iagiDBUu0nN3JAqDN a9CWBDkS9GaL0VLtDGnHJlKz5OH4f8NuCfW5NVmchkck/PfpDCw/sBHGwXSLELesF5pR 9WkNInws3DKXey8xUYisJUup8ftqcl00Vg/LlzJznNc5PMRoUmtef8EY4+lRei+yrJkA jnBaTb7+7QruTpuMryqTlK7DnK6vLGEsmEhphJ7+jBXZEDHbsbcnMWRqfd8bq14o/53s jU0g== X-Gm-Message-State: AOAM532tNpu8Rkp/EzboK9PV4+MMDoVacdfHYeTEl8xMPf9Em19Pr7Yp aewqMWtSrHtPW6NZRNg8bUMWi2jZqTaSmQ== X-Google-Smtp-Source: ABdhPJx54GDznd2ryeFbsiLZ5EtK0ItJAIbYO3FCVv0P/b9LYu26RCKAeJgXOIyxQScJNqotN5clCQ== X-Received: by 2002:a5d:698e:: with SMTP id g14mr4134926wru.232.1603209426703; Tue, 20 Oct 2020 08:57:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/41] hw/arm/strongarm: Fix 'time to transmit a char' unit comment Date: Tue, 20 Oct 2020 16:56:18 +0100 Message-Id: <20201020155656.8045-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 The time to transmit a char is expressed in nanoseconds, not in ticks. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201014213601.205222-1-f4bug@amsat.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/strongarm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c index d7133eea6f9..ca7c385f313 100644 --- a/hw/arm/strongarm.c +++ b/hw/arm/strongarm.c @@ -935,7 +935,7 @@ struct StrongARMUARTState { uint8_t rx_start; uint8_t rx_len; =20 - uint64_t char_transmit_time; /* time to transmit a char in ticks*/ + uint64_t char_transmit_time; /* time to transmit a char in nanoseconds= */ bool wait_break_end; QEMUTimer *rx_timeout_timer; QEMUTimer *tx_timer; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210029; cv=none; d=zohomail.com; s=zohoarc; b=cJsS4kJR+AcmfxHZb8986GjED5G9LvRvzhW4aSkhBRKPjNEhpaRUiJc9b9CO0wZyFNECXV15SNQYFagbEdhfzOUggBVHAluk6H8o7DP905jdcvk3yIzBxqOoDmkN2KucMwM/jvB43Ovb693+Z+7wEsWD2rvhDOO1oA56XaMHuFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210029; h=Content-Type:Content-Transfer-Encoding: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=fcvS5KwPH9BB5sdq/tDFX01ywohiKwH2/PzxO6MFTBs=; b=i4Ul4k8JTsRR1Q8IeeQ9PNYGZSnTPxUeVubIkXkUM+nXKXd7bW6BldoQcH9JTYQW5nahVtAa9BeaKB2m4e91tS/5Piv9lTedvtVmklwb7u5CCeU9w9TVF8OHr7EWSvSQ+LGeZVB0Qcc0xlSW7jbyfXHCrsLcfIGyMNkBxM4TWLc= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210029523603.1170447934983; Tue, 20 Oct 2020 09:07:09 -0700 (PDT) Received: from localhost ([::1]:57568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuAG-0008E3-DM for importer@patchew.org; Tue, 20 Oct 2020 12:07:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0e-0004E1-Ab for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:13 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:40223) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0c-0003r3-GL for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:12 -0400 Received: by mail-wm1-x32d.google.com with SMTP id k18so2508274wmj.5 for ; Tue, 20 Oct 2020 08:57:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fcvS5KwPH9BB5sdq/tDFX01ywohiKwH2/PzxO6MFTBs=; b=K3DX9XUSEK3FlPH1aQN7+eCgkbAkO2G+wEI+cYNdxGzCW/Q0xbQm44+MpoehGGyou3 FGOK6nlWrgolZqbzDXDoT5SrovcWi+YO9MCBU4uUrwvorkZmZEqpSzIps8xosg+qZnGk HS+mP0/O54e7cWOTCHlU/4hr7vwTr+qLdvp/EoifYYM2+p/5Kx8TtXisMZSgoYjcMkeB nyEJLJoQCoweZDmfSkD4YwRrB1sI50wwzFwyRqN4Mbi1E7Fomo+irC8eOtrMT1it+KhS 27vPwEww+HhA6z53YFMXdP1DAywPLUhpGL5B410lKhkAaYPDAnYS1NJromwK9OfJOrv3 0j4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fcvS5KwPH9BB5sdq/tDFX01ywohiKwH2/PzxO6MFTBs=; b=fOnyrKN2EJ3AjjOf07X+JBWNmzGI6/O7M2gCnTdT7703prbcyHzoYbnDHdg9f4t4fF fgZrHCJ3yjV5qFnsnzbK4v/uVFmUN6WfLZ6lpsJHc2ibJ+21nU3uVAGwBWIHl7lUCu1K IO3v2eL4XGlwF3K3mt1zudog3ssU8njF2aviHMp2KlMb6RPSUn1vEfl6K0cp4Cci9SOt pkw9J0PMbpLAaq3aZ7TcTnENfCzH2oJANPWXjwHaYLpi51iJLeGpZL3/6zHcd84tOVW4 RtMT3HEVzW654q7vcNuv6uOzEFLVHWj2BtiwI7+mCn5/WszuMeX3Al7p2rKqQ6edng8s BNaQ== X-Gm-Message-State: AOAM533T81Wi6xG+0oitpGIuQZRt5ruFP3Ezqv0hZGBJkz2o/5tfZ2nl rR9gjRdNHPW7ChNQwPZHKEtFgiChfSvZmQ== X-Google-Smtp-Source: ABdhPJwii4ueGHX7QUXzAhF3XO4da7VD4BbngoPASGEJBDYTgeSTCloHng9xECvtJ/+FbARxx0U4lg== X-Received: by 2002:a1c:9d8e:: with SMTP id g136mr3660010wme.18.1603209428447; Tue, 20 Oct 2020 08:57:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/41] hw/arm: Restrict APEI tables generation to the 'virt' machine Date: Tue, 20 Oct 2020 16:56:19 +0100 Message-Id: <20201020155656.8045-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 While APEI is a generic ACPI feature (usable by X86 and ARM64), only the 'virt' machine uses it, by enabling the RAS Virtualization. See commit 2afa8c8519: "hw/arm/virt: Introduce a RAS machine option"). Restrict the APEI tables generation code to the single user: the virt machine. If another machine wants to use it, it simply has to 'select ACPI_APEI' in its Kconfig. Fixes: aa16508f1d ("ACPI: Build related register address fields via hardwar= e error fw_cfg blob") Acked-by: Michael S. Tsirkin Reviewed-by: Dongjiu Geng Acked-by: Laszlo Ersek Reviewed-by: Igor Mammedov Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201008161414.2672569-1-philmd@redhat.com Signed-off-by: Peter Maydell --- default-configs/devices/arm-softmmu.mak | 1 - hw/arm/Kconfig | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/default-configs/devices/arm-softmmu.mak b/default-configs/devi= ces/arm-softmmu.mak index 9a94ebd0bef..08a32123b4c 100644 --- a/default-configs/devices/arm-softmmu.mak +++ b/default-configs/devices/arm-softmmu.mak @@ -43,4 +43,3 @@ CONFIG_FSL_IMX7=3Dy CONFIG_FSL_IMX6UL=3Dy CONFIG_SEMIHOSTING=3Dy CONFIG_ALLWINNER_H3=3Dy -CONFIG_ACPI_APEI=3Dy diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index f303c6bead2..7d040827af4 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -26,6 +26,7 @@ config ARM_VIRT select ACPI_MEMORY_HOTPLUG select ACPI_HW_REDUCED select ACPI_NVDIMM + select ACPI_APEI =20 config CHEETAH bool --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209525; cv=none; d=zohomail.com; s=zohoarc; b=Q7+b0866n4l/Z83J6e+mfYwVjyRH5ConpPugHd0LHCPaMOy5/vMFerDFglhoFnFDjwNQW7IkOiDl+Q6ONpXOcMtFdV/G8SznoGELgSL1XSFaJik6Pff/U4EXXl9/x8ir2lynHdFvVnjZY76hs+RO3XsHEU+SSKva/6eC+XsrmLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209525; h=Content-Type:Content-Transfer-Encoding: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=AWepJclKfiAgqPbSX9Qr68AN9+jPvNJVchxr+m/neyg=; b=LwUGOyI0/15g9CaLruGvdX/ap5Z/WHPOOXDoRf2fgzEY//8HAXR7AWMFLPO8BhJVIa/RaE2Jeq2M5E7jzbB+t7xkVdhsuZQ3P8in2f8uQqEdwSvJq2yz9yK+5wmvRwScPEnp55CyjLZpykZo7mxuArrND56OELOw/5sC3Cec8BA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209525646223.76275543426777; Tue, 20 Oct 2020 08:58:45 -0700 (PDT) Received: from localhost ([::1]:33182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu27-0006Sr-Rl for importer@patchew.org; Tue, 20 Oct 2020 11:58:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0i-0004KI-9v for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:16 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:55005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0f-0003rN-Q8 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:15 -0400 Received: by mail-wm1-x330.google.com with SMTP id c77so2327929wmd.4 for ; Tue, 20 Oct 2020 08:57:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AWepJclKfiAgqPbSX9Qr68AN9+jPvNJVchxr+m/neyg=; b=aOmEgptLo8ivpRy4C4v9dFBWdO8AJR1ZGoQiFmcKw+lhRZP/pAdJuKBPEaYBf0v5AX S4l1UcwM8WlcTP6cj3KQL6iUipsz5yWGuxTICw2ZnHe4IB64jiIwfHHb/AXZEm2IJ36E 5Yug/0mp3qm/anPDSz/5WM7weiR9AvinvCZvvET88MFqGZi+Em7l9S586MnqaMXGund8 i8AbgeNvurYQq8vYkdjQiFwquAcJhtNcrwMKtkrKMj/sk2cSUFSRQ4z8tRSqCwS/8fva rJ1vMhZh5hkcAA8oA8iI6xIqp6s4DHBIY6TTGyAIDdSC1fbWCWOTRdgzrVX8k2WTAi8z sNZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AWepJclKfiAgqPbSX9Qr68AN9+jPvNJVchxr+m/neyg=; b=Wrzr+AtToU0hUwetzwDN35i/f13Xz03Od1cmWChpYhtpgnPnxgCbDRk2OvHlBg83tU X/G9ictEOQDQupau3koxTOO3fVNLBojH2nbf6xoG+EfxcRLt3jH+Ilzn+L7qL37bPdpG z45sBuBUKBXVvfIPvlnR9Odi5zwoIAg0fpSOHtZX/eCLXH1kZr1i9vmgN7g+GjQWEC8u Y+BCBzmUyOBmRlIoPUmU9GEnyF24jEqhlBqvbYq0KvyI9XHiaJ9M1onoG//dvf0d1fQU oyDoDqOyRkvdav3OUCbQQfWpY6JV6aOC5O+9nMWBn3J0rmE+SINgoHyWM+Yq/89XdDTb gnzQ== X-Gm-Message-State: AOAM532/OuyueP1QWRaPkHdrbL58KiL0jWzPiLrqfWer6NZvYejsIGS+ aeLse/lkJMTOe3ZVwoSNUNf6LermQ0damw== X-Google-Smtp-Source: ABdhPJzo/0yJme5lZisgA92dZ8ogifTeu6MabP+aXJMVSR0tfRARevb8sUkEDoudvAQNnYH2UnE0dQ== X-Received: by 2002:a1c:e403:: with SMTP id b3mr2883073wmh.79.1603209429793; Tue, 20 Oct 2020 08:57:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/41] hw/timer/bcm2835: Introduce BCM2835_SYSTIMER_COUNT definition Date: Tue, 20 Oct 2020 16:56:20 +0100 Message-Id: <20201020155656.8045-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+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-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 Use the BCM2835_SYSTIMER_COUNT definition instead of the magic '4' value. Reviewed-by: Luc Michel Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201010203709.3116542-2-f4bug@amsat.org Signed-off-by: Peter Maydell --- include/hw/timer/bcm2835_systmr.h | 4 +++- hw/timer/bcm2835_systmr.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/hw/timer/bcm2835_systmr.h b/include/hw/timer/bcm2835_s= ystmr.h index 7ce8f6ef4d8..43df7ee488c 100644 --- a/include/hw/timer/bcm2835_systmr.h +++ b/include/hw/timer/bcm2835_systmr.h @@ -16,6 +16,8 @@ #define TYPE_BCM2835_SYSTIMER "bcm2835-sys-timer" OBJECT_DECLARE_SIMPLE_TYPE(BCM2835SystemTimerState, BCM2835_SYSTIMER) =20 +#define BCM2835_SYSTIMER_COUNT 4 + struct BCM2835SystemTimerState { /*< private >*/ SysBusDevice parent_obj; @@ -26,7 +28,7 @@ struct BCM2835SystemTimerState { =20 struct { uint32_t status; - uint32_t compare[4]; + uint32_t compare[BCM2835_SYSTIMER_COUNT]; } reg; }; =20 diff --git a/hw/timer/bcm2835_systmr.c b/hw/timer/bcm2835_systmr.c index 3387a6214a2..ff8c5536610 100644 --- a/hw/timer/bcm2835_systmr.c +++ b/hw/timer/bcm2835_systmr.c @@ -134,7 +134,8 @@ static const VMStateDescription bcm2835_systmr_vmstate = =3D { .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { VMSTATE_UINT32(reg.status, BCM2835SystemTimerState), - VMSTATE_UINT32_ARRAY(reg.compare, BCM2835SystemTimerState, 4), + VMSTATE_UINT32_ARRAY(reg.compare, BCM2835SystemTimerState, + BCM2835_SYSTIMER_COUNT), VMSTATE_END_OF_LIST() } }; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210170; cv=none; d=zohomail.com; s=zohoarc; b=dvH8m4EqGjPfqGuMubExgOtxyF+YWx+NjyaAT5tbf4TntzUUbzdqQmRfIPAnLEWFpqgLt1bdEH2nkJ6aCPVb+MJXLbSf9tzpXOxNrBGyKDnoqtYPuWeqR3jORX3eLggMnMbjUxN7QOmJMp930hGVPRmn53rr2avoyizWRNUSDN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210170; h=Content-Type:Content-Transfer-Encoding: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=Kd2iaAhnpbWYek8ibS9jm05FXtFf4HAgQQsgMjJ49rw=; b=Bo05uBcnk19Pa47hwqpeDXr570YtYpkF82NZzOh0VQ/MseSRJc8ULn8TmBIUnqvgI0NLlNLMntKjiewHgkVnu7eBSqBbAvdGzxEJRc/CZvARpsK9kuJyJHBHbb9NF8vcUkxO19p57MIbmKAXRm6/V8/5E8+9todrqDOABmmIfLk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210170005937.3301295167279; Tue, 20 Oct 2020 09:09:30 -0700 (PDT) Received: from localhost ([::1]:37682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuCW-0003HH-Nc for importer@patchew.org; Tue, 20 Oct 2020 12:09:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0i-0004LD-KV for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:16 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:44982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0g-0003rf-7o for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:16 -0400 Received: by mail-wr1-x42c.google.com with SMTP id t9so2774733wrq.11 for ; Tue, 20 Oct 2020 08:57:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Kd2iaAhnpbWYek8ibS9jm05FXtFf4HAgQQsgMjJ49rw=; b=CpazxWvvvC/iO2gMyFJIpuwwLI+yZXePTmIIpM/0lpoTdrUyGB3YKfJDRSPfNXO8Kq OKqxo6a6RhtzErj1Xm94jhfy2bamgG+wmiuX4znnD3oNqz2bMqIGj9m+ABIhP6TbnkSP 3Q7nrD1K3iL3g9NvjRUnbJSua36R1cI8m8oTYuqqmrGtZKu944yd3SjfhR7iRfnE7ip7 y395zrr8Z5vbvUJmBLNW23TBZc4iXvHFqUGaqoJBFjr/4eZhb+KQAzZrXo/Pj8jUVdqy d65+EVaIF1gG56FAjOzKSoHwdZi2PHF+36iOXnZZujkZlF7TAB7x8NQ6q5KmbsycutNd xx5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kd2iaAhnpbWYek8ibS9jm05FXtFf4HAgQQsgMjJ49rw=; b=C5wMEDQmxq3SjfUcowodIUhl44RFsfcV736S1IIEDI/O1TszNOU5x5Fl9NqDWmYlM2 Qc4QlfTxERvJZsPSCOL2kMh3eas6uTbQSMCEwpTXMtuuadqcxXaUUlctYC19XMgLLO6n tN0lp02jpOSmSKOrkH4LJAN8zt7Rs5maF8OvNySakqXpUCErzn2bmNDTUlMCBA57Jdpe MWL7jzNSjzQg/FCqlP47xwWkpHRwhEBN9b7oyEz8xi8MdOjvhlkiKUSjS4rx8nt3+WaI kdz7+/4gKqwO36E0gPcGEnFiUtPzouO2iO5VvhQ61N+eiXnFylyl+CNHKRn2KZxgkdUC w9fg== X-Gm-Message-State: AOAM5330XsuBfnxIIQ/bE4HmlTPz+wJjsYFQ++qkDyvgU/98jmWqLPev zx5bUSBz3VimOvl8zzN8LHhm0+3hrEYRoQ== X-Google-Smtp-Source: ABdhPJzVG9hlpZArWe2cjy7jxW3pu67HEKVVvdOXN3WviOQEJjXLxTgquu08i8+fulm5jUZZKe7nHw== X-Received: by 2002:adf:fc83:: with SMTP id g3mr4267447wrr.200.1603209432518; Tue, 20 Oct 2020 08:57:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/41] hw/timer/bcm2835: Rename variable holding CTRL_STATUS register Date: Tue, 20 Oct 2020 16:56:21 +0100 Message-Id: <20201020155656.8045-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 The variable holding the CTRL_STATUS register is misnamed 'status'. Rename it 'ctrl_status' to make it more obvious this register is also used to control the peripheral. Reviewed-by: Luc Michel Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201010203709.3116542-3-f4bug@amsat.org Signed-off-by: Peter Maydell --- include/hw/timer/bcm2835_systmr.h | 2 +- hw/timer/bcm2835_systmr.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hw/timer/bcm2835_systmr.h b/include/hw/timer/bcm2835_s= ystmr.h index 43df7ee488c..f15788a78d8 100644 --- a/include/hw/timer/bcm2835_systmr.h +++ b/include/hw/timer/bcm2835_systmr.h @@ -27,7 +27,7 @@ struct BCM2835SystemTimerState { qemu_irq irq; =20 struct { - uint32_t status; + uint32_t ctrl_status; uint32_t compare[BCM2835_SYSTIMER_COUNT]; } reg; }; diff --git a/hw/timer/bcm2835_systmr.c b/hw/timer/bcm2835_systmr.c index ff8c5536610..b234e83824f 100644 --- a/hw/timer/bcm2835_systmr.c +++ b/hw/timer/bcm2835_systmr.c @@ -30,7 +30,7 @@ REG32(COMPARE3, 0x18) =20 static void bcm2835_systmr_update_irq(BCM2835SystemTimerState *s) { - bool enable =3D !!s->reg.status; + bool enable =3D !!s->reg.ctrl_status; =20 trace_bcm2835_systmr_irq(enable); qemu_set_irq(s->irq, enable); @@ -52,7 +52,7 @@ static uint64_t bcm2835_systmr_read(void *opaque, hwaddr = offset, =20 switch (offset) { case A_CTRL_STATUS: - r =3D s->reg.status; + r =3D s->reg.ctrl_status; break; case A_COMPARE0 ... A_COMPARE3: r =3D s->reg.compare[(offset - A_COMPARE0) >> 2]; @@ -82,7 +82,7 @@ static void bcm2835_systmr_write(void *opaque, hwaddr off= set, trace_bcm2835_systmr_write(offset, value); switch (offset) { case A_CTRL_STATUS: - s->reg.status &=3D ~value; /* Ack */ + s->reg.ctrl_status &=3D ~value; /* Ack */ bcm2835_systmr_update_irq(s); break; case A_COMPARE0 ... A_COMPARE3: @@ -133,7 +133,7 @@ static const VMStateDescription bcm2835_systmr_vmstate = =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_UINT32(reg.status, BCM2835SystemTimerState), + VMSTATE_UINT32(reg.ctrl_status, BCM2835SystemTimerState), VMSTATE_UINT32_ARRAY(reg.compare, BCM2835SystemTimerState, BCM2835_SYSTIMER_COUNT), VMSTATE_END_OF_LIST() --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209564; cv=none; d=zohomail.com; s=zohoarc; b=FvVjw0h93E1VBQYE5LQa/lXwwQnL4tUGnvgOU0MdiGUrF9EOZwiG8l8JY680Pa6Dq8bP8e5NP9yk03u+yJflDDMu6mBo8lCwChRM6LGVs3v5k6zJeOQm2zs99JJmTDim7TwHzRjECEH/xoFzMUM3Pfxnxp5pLP1wY5rwVQDa2YA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209564; h=Content-Type:Content-Transfer-Encoding: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=3DJEJXQVy0e3qPp5Ym6ZDssBuQPuQeXX0afaVS4fCT8=; b=HHRBRi3r2fbDxT6s0bDZVnq1TdYh6SN1IqovsQEU6LzBsQoTEAHLVx2zAUExU9hiILsCYJNqWLTj3RfbE26A0aIB5PNtGkCCu0+uGlNST6YaIp5UbG14KC6PJ0IffgPnuMdCYgNxEHCpsNBCWzx0BpSlpifHPuSAco9rLp+Yq/s= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209564158886.1229331258389; Tue, 20 Oct 2020 08:59:24 -0700 (PDT) Received: from localhost ([::1]:36246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu2k-0007he-4z for importer@patchew.org; Tue, 20 Oct 2020 11:59:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0k-0004R6-Vc for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:19 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:46998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0h-0003rm-IK for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id n6so2772448wrm.13 for ; Tue, 20 Oct 2020 08:57:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3DJEJXQVy0e3qPp5Ym6ZDssBuQPuQeXX0afaVS4fCT8=; b=DxGwIcbnSlgxI4zVwvpWL+wSunxB+4ztMQdgOjcDock1vhOakwr2zj3V/kV9Nsga54 NtbbyBOdqpdxKjtSsvNzp0jTpFdVnhEbSGbJsxJIvtO54RKsLZSsYt3xUtaRaNsAA1AK DQLHTFp7QId7g0ICawWwYAQrjX/29y+JSltBvc2dIrR0RyY74XsHIeXZ9SW1fRYEACuM M+zrTOjWvXB2M2LVvLS++irtWyQMi68kv6nkhgzFovRgb76Lnsou1dwVQnSsCgw2+aMM RDVYsywhQJ5lxu6dF60dGNfKkI4F4oRwkoTLrthCJSX1gMWQWftMMV0t077x/JOqfX67 cN8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3DJEJXQVy0e3qPp5Ym6ZDssBuQPuQeXX0afaVS4fCT8=; b=s9ZMDd0iSR06WrgmzmQo0Yt7z/qjsZdtvMKbTaSBj3GvY61hflEKUjhVNgQMcrxjqT bdylqwckBkOQ02BnfR1aMC4dbBODcPKiCDty8VAJAN6KcnQEMXC6NgO7rnB2y+I91dfB zG8XABFbd/oWM2Jg1jcg62gQriTO27eZ9kr9ZbxdgAXAC8x9DViyj/DD14Cqng6/WkGs gab1bjjkeVe4wvbNLVHkhICcFdIbJfpPdOPzhSyHGtXGjBCoyqsea7eaIKnRIFoh9A49 zUBxNjNW06akhyfycpR4En68zLfSHYkXaeX1yBZOXFkjt2ImRW53ByPPis+jr7paNkGL 07mg== X-Gm-Message-State: AOAM533mUdjjXMvoJE4HTUEs2nU37cP767JsX5RXqH38dyzfR6/cQn++ UXeWQ3TiR76bdauAH/BU9sAFJ+oiZr1TXA== X-Google-Smtp-Source: ABdhPJxdCBefMnOlng6LQUZhOxWF8dP5Q57jSL28pOD6zHFvj/YkcgqA+78Eoh8GeaRhUzi1jSsdbw== X-Received: by 2002:a5d:4f0b:: with SMTP id c11mr4204849wru.316.1603209433710; Tue, 20 Oct 2020 08:57:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/41] hw/timer/bcm2835: Support the timer COMPARE registers Date: Tue, 20 Oct 2020 16:56:22 +0100 Message-Id: <20201020155656.8045-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 This peripheral has 1 free-running timer and 4 compare registers. Only the free-running timer is implemented. Add support the COMPARE registers (each register is wired to an IRQ). Reference: "BCM2835 ARM Peripherals" datasheet [*] chapter 12 "System Timer": The System Timer peripheral provides four 32-bit timer channels and a single 64-bit free running counter. Each channel has an output compare register, which is compared against the 32 least significant bits of the free running counter values. When the two values match, the system timer peripheral generates a signal to indicate a match for the appropriate channel. The match signal is then fed into the interrupt controller. This peripheral is used since Linux 3.7, commit ee4af5696720 ("ARM: bcm2835: add system timer"). [*] https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals= .pdf Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Luc Michel Message-id: 20201010203709.3116542-4-f4bug@amsat.org Signed-off-by: Peter Maydell --- include/hw/timer/bcm2835_systmr.h | 11 +++++-- hw/timer/bcm2835_systmr.c | 48 ++++++++++++++++++++----------- hw/timer/trace-events | 6 ++-- 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/include/hw/timer/bcm2835_systmr.h b/include/hw/timer/bcm2835_s= ystmr.h index f15788a78d8..bd3097d746b 100644 --- a/include/hw/timer/bcm2835_systmr.h +++ b/include/hw/timer/bcm2835_systmr.h @@ -11,6 +11,7 @@ =20 #include "hw/sysbus.h" #include "hw/irq.h" +#include "qemu/timer.h" #include "qom/object.h" =20 #define TYPE_BCM2835_SYSTIMER "bcm2835-sys-timer" @@ -18,18 +19,24 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2835SystemTimerState, BCM= 2835_SYSTIMER) =20 #define BCM2835_SYSTIMER_COUNT 4 =20 +typedef struct { + unsigned id; + QEMUTimer timer; + qemu_irq irq; + BCM2835SystemTimerState *state; +} BCM2835SystemTimerCompare; + struct BCM2835SystemTimerState { /*< private >*/ SysBusDevice parent_obj; =20 /*< public >*/ MemoryRegion iomem; - qemu_irq irq; - struct { uint32_t ctrl_status; uint32_t compare[BCM2835_SYSTIMER_COUNT]; } reg; + BCM2835SystemTimerCompare tmr[BCM2835_SYSTIMER_COUNT]; }; =20 #endif diff --git a/hw/timer/bcm2835_systmr.c b/hw/timer/bcm2835_systmr.c index b234e83824f..67669a57ff3 100644 --- a/hw/timer/bcm2835_systmr.c +++ b/hw/timer/bcm2835_systmr.c @@ -28,20 +28,13 @@ REG32(COMPARE1, 0x10) REG32(COMPARE2, 0x14) REG32(COMPARE3, 0x18) =20 -static void bcm2835_systmr_update_irq(BCM2835SystemTimerState *s) +static void bcm2835_systmr_timer_expire(void *opaque) { - bool enable =3D !!s->reg.ctrl_status; + BCM2835SystemTimerCompare *tmr =3D opaque; =20 - trace_bcm2835_systmr_irq(enable); - qemu_set_irq(s->irq, enable); -} - -static void bcm2835_systmr_update_compare(BCM2835SystemTimerState *s, - unsigned timer_index) -{ - /* TODO fow now, since neither Linux nor U-boot use these timers. */ - qemu_log_mask(LOG_UNIMP, "COMPARE register %u not implemented\n", - timer_index); + trace_bcm2835_systmr_timer_expired(tmr->id); + tmr->state->reg.ctrl_status |=3D 1 << tmr->id; + qemu_set_irq(tmr->irq, 1); } =20 static uint64_t bcm2835_systmr_read(void *opaque, hwaddr offset, @@ -75,19 +68,33 @@ static uint64_t bcm2835_systmr_read(void *opaque, hwadd= r offset, } =20 static void bcm2835_systmr_write(void *opaque, hwaddr offset, - uint64_t value, unsigned size) + uint64_t value64, unsigned size) { BCM2835SystemTimerState *s =3D BCM2835_SYSTIMER(opaque); + int index; + uint32_t value =3D value64; + uint32_t triggers_delay_us; + uint64_t now; =20 trace_bcm2835_systmr_write(offset, value); switch (offset) { case A_CTRL_STATUS: s->reg.ctrl_status &=3D ~value; /* Ack */ - bcm2835_systmr_update_irq(s); + for (index =3D 0; index < ARRAY_SIZE(s->tmr); index++) { + if (extract32(value, index, 1)) { + trace_bcm2835_systmr_irq_ack(index); + qemu_set_irq(s->tmr[index].irq, 0); + } + } break; case A_COMPARE0 ... A_COMPARE3: - s->reg.compare[(offset - A_COMPARE0) >> 2] =3D value; - bcm2835_systmr_update_compare(s, (offset - A_COMPARE0) >> 2); + index =3D (offset - A_COMPARE0) >> 2; + s->reg.compare[index] =3D value; + now =3D qemu_clock_get_us(QEMU_CLOCK_VIRTUAL); + /* Compare lower 32-bits of the free-running counter. */ + triggers_delay_us =3D value - now; + trace_bcm2835_systmr_run(index, triggers_delay_us); + timer_mod(&s->tmr[index].timer, now + triggers_delay_us); break; case A_COUNTER_LOW: case A_COUNTER_HIGH: @@ -125,7 +132,14 @@ static void bcm2835_systmr_realize(DeviceState *dev, E= rror **errp) memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_systmr_ops, s, "bcm2835-sys-timer", 0x20); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); - sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); + + for (size_t i =3D 0; i < ARRAY_SIZE(s->tmr); i++) { + s->tmr[i].id =3D i; + s->tmr[i].state =3D s; + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->tmr[i].irq); + timer_init_us(&s->tmr[i].timer, QEMU_CLOCK_VIRTUAL, + bcm2835_systmr_timer_expire, &s->tmr[i]); + } } =20 static const VMStateDescription bcm2835_systmr_vmstate =3D { diff --git a/hw/timer/trace-events b/hw/timer/trace-events index b996d992000..7a4326d9566 100644 --- a/hw/timer/trace-events +++ b/hw/timer/trace-events @@ -77,9 +77,11 @@ nrf51_timer_write(uint8_t timer_id, uint64_t addr, uint3= 2_t value, unsigned size nrf51_timer_set_count(uint8_t timer_id, uint8_t counter_id, uint32_t value= ) "timer %u counter %u count 0x%" PRIx32 =20 # bcm2835_systmr.c -bcm2835_systmr_irq(bool enable) "timer irq state %u" +bcm2835_systmr_timer_expired(unsigned id) "timer #%u expired" +bcm2835_systmr_irq_ack(unsigned id) "timer #%u acked" bcm2835_systmr_read(uint64_t offset, uint64_t data) "timer read: offset 0x= %" PRIx64 " data 0x%" PRIx64 -bcm2835_systmr_write(uint64_t offset, uint64_t data) "timer write: offset = 0x%" PRIx64 " data 0x%" PRIx64 +bcm2835_systmr_write(uint64_t offset, uint32_t data) "timer write: offset = 0x%" PRIx64 " data 0x%" PRIx32 +bcm2835_systmr_run(unsigned id, uint64_t delay_us) "timer #%u expiring in = %"PRIu64" us" =20 # avr_timer16.c avr_timer16_read(uint8_t addr, uint8_t value) "timer16 read addr:%u value:= %u" --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209771; cv=none; d=zohomail.com; s=zohoarc; b=lFhESqJ9WP7OBuix9RVP+Vil6e0qlMspLdYgsD2nM8QA2n1JKq5J8Jnltzqv+n1UVA+J1yGCNTPHMX7Ypl4USTLyUuOgHDNo7ZjBncxk7ilHG/Om5nNIrn24mMZNfyxtgLqVbmcyEUjXdkgKP2nSjaQC9qkJbiTR7X1nVV1CjbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209771; h=Content-Type:Content-Transfer-Encoding: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=umDgoaAFU65XIcuyABXPoBx1y8XfLewihbQF8KPdG0g=; b=iZXyx+6ixuVrzrwC3Aeu7WdMmz4ml+7zGFS6mvzj4VjVrZAcCQdDAnaj5GRTFu6ekIC3oFKAZdutv1SHi+9D9FGm2yQ/+XDkssjuxZZaCaaLBy9yKFBPnUh6eueT0rZVhnWXprWFGYZMRxg+v18pX65JdavzjpdDnviINezd9Fk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209771391385.9018564314025; Tue, 20 Oct 2020 09:02:51 -0700 (PDT) Received: from localhost ([::1]:44808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu66-0002uX-4I for importer@patchew.org; Tue, 20 Oct 2020 12:02:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0l-0004Rf-5w for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:19 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35238) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0j-0003s2-16 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:18 -0400 Received: by mail-wr1-x441.google.com with SMTP id n15so2807650wrq.2 for ; Tue, 20 Oct 2020 08:57:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=umDgoaAFU65XIcuyABXPoBx1y8XfLewihbQF8KPdG0g=; b=XxyYz/ORAgoz7GvGylkg9QgB5BWZoGUaiO6fWRYuXA8vx0dEO2DOw6Eo4FYQMCpkUi WhCU/e9k7hnA9J8mfG4y/MkjIAX19CPHBGQOwd8chMa0K8tra69OICCEFhjdCa4EXsod YIxe/LWefGRoqnIFxYrFAh8f1aL1bQMJZM07jEAWmaz9K7KxM2B++4abC0lNOFItXJiR yNgSO1BPdTphpjWsQo6AWqqxhhsK6m2j6oj2kMsAu0V1E3KTHBBwfkt5zQp5w0n2TVYc bfpfMzrqI7m2Sk2Z+YQQ1gZ+RUYD6HCM6MjJ4f22gJCSTyxbjYnteQZjwPPeIhrNKhbN D8MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=umDgoaAFU65XIcuyABXPoBx1y8XfLewihbQF8KPdG0g=; b=CIt+txHSo4OyKncu9uRGyGjVhCsOaSjlbHlcKUPs9j3QTCKk90M8tYBy8JROkduq43 bjKOj1MwptoScT5q/6u0fGdHEFvlg0MYAe2vY9/C+rzfbC+IcftNO7Wy4trnsbBRi1N5 siA6yF5I3HXabYWziceiI6ezNATEGmELEtls2jQXxBQ8pAwimKjYeEMTH9yCnCaJy/Tk C1E34FGYperkm28UTAxcchU9Iu6UnlO0SnBFaUtRBcE27yAWEuT2Whiq3MBNhSvEwYnT a3RUTK6POGOca87+8HskrrlUDi5X614NhT2aJmx3lYOyI2rKaDKhwJC9ezU0e8zH55Gd cDUA== X-Gm-Message-State: AOAM533ent2axyLribeoSzZWGdDQuMHDQEXhLbGxwcda9BgXpk2PQEkw 9NAlLPTA+Uo5cOdq8J6Fi1hAjv6isgK/qg== X-Google-Smtp-Source: ABdhPJwRPX+CToeLCAGA5Jf4jv8hswaZ3FgHR+cepZIo/LYJ+ZyknaHRaxi8yAMO8k3sFKIgvuhyvQ== X-Received: by 2002:a5d:5604:: with SMTP id l4mr4149863wrv.140.1603209435303; Tue, 20 Oct 2020 08:57:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/41] hw/arm/bcm2835_peripherals: Correctly wire the SYS_timer IRQs Date: Tue, 20 Oct 2020 16:56:23 +0100 Message-Id: <20201020155656.8045-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 The SYS_timer is not directly wired to the ARM core, but to the SoC (peripheral) interrupt controller. Fixes: 0e5bbd74064 ("hw/arm/bcm2835_peripherals: Use the SYS_timer") Reviewed-by: Luc Michel Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201010203709.3116542-5-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/arm/bcm2835_peripherals.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 15c5c72e465..48909a43c32 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -171,8 +171,17 @@ static void bcm2835_peripherals_realize(DeviceState *d= ev, Error **errp) memory_region_add_subregion(&s->peri_mr, ST_OFFSET, sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systmr), 0)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 0, - qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ, - INTERRUPT_ARM_TIMER)); + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, + INTERRUPT_TIMER0)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 1, + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, + INTERRUPT_TIMER1)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 2, + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, + INTERRUPT_TIMER2)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 3, + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, + INTERRUPT_TIMER3)); =20 /* UART0 */ qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0)); --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210364; cv=none; d=zohomail.com; s=zohoarc; b=LD62j9gwvv+P+mhBXuVDMMfwx2isvw5CwMnrs2VcJOAyMSwKx80uLVJTBe9q80qHdsgOa6ke7iIPIWuc+ZaXJ0NtUVAtXublR3x0cPTacvdPgRulFF1IP85mHpEjeu0fNsTh165PAY3Xkzbtr23JTaX0+fye8qdAlCLB+Wy56NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210364; h=Content-Type:Content-Transfer-Encoding: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=Eh5U8ecL6PCEaGskhTVfu/80Yf2oWMJ0K7Nr8DysFCQ=; b=hb74hkV5HthksRegn8rcRjLtkDDWBR9C3m7VaqgSm0mqwdb2VA2Jn0A9EqtndO/mR/CktdhGd+yyS6OxnBcTLRZVRuIP12iUpukoBoOX3W2F9RPgDDmI1Pvbqtgp+3In07Sf7aZ6zhYmr35aU18o1/mG544s9GLVWCErdK01EOs= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210364955434.2845338390322; Tue, 20 Oct 2020 09:12:44 -0700 (PDT) Received: from localhost ([::1]:46140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuFf-0007Bo-Me for importer@patchew.org; Tue, 20 Oct 2020 12:12:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0n-0004WX-3Q for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:21 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0k-0003sM-HI for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:20 -0400 Received: by mail-wr1-x433.google.com with SMTP id t9so2775048wrq.11 for ; Tue, 20 Oct 2020 08:57:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Eh5U8ecL6PCEaGskhTVfu/80Yf2oWMJ0K7Nr8DysFCQ=; b=GokfDeyfM4zb4ZFnTXSUr9kgnWs8ouqsUMHliPR7c0uTybuYAa+GjesYO3MwaZnEqM U2E0tiXJSJcs+yvO+cVk1SVG67j+4DUgRR9p1kg49o1oKtojRMATPf81jHN/Ag3UML+0 jntLZeOFZ0aZ9IwIjJ2G5yr8G5gLlLGt6BbMzmvkCPmqG2sfOEKGtiR7Y6uyR3nH/4BO gPpZeTx7zH00xk1eLFQgxvlZz8TG8prsGwI39CQ443pJDzKdXNQ2Ka8qmAxvdvYfjXPt HHq9xXD/Y0q+B7s87PHY1363sIxNnaOwVJSkcGVr6eIAY7zU/M2luTl2Cbb4tHrZmhzO aV+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Eh5U8ecL6PCEaGskhTVfu/80Yf2oWMJ0K7Nr8DysFCQ=; b=NcI55m6ntfHLmaQPe9vv6673awGJTwV1b2q+6sxiJxUswKeM9JiPTYKIVOJN1nuwA2 syCyck0gjWvQtTSSk3a67WH/bgKnxOosPMwzCOdHL3A6RrNx1GlnS4GlkF1d6r94nT/q xTMX5wNGXtUyLOaF+lzeOtTYHpnq3Gtmsl5Wl3cGkRV6Be1eOOcI1dAyNrEZIK6B8Pe2 1se0WTF8P+mHz38M06oztnEMWFBcyYBYZyF3jpOo5mvw9dgZjK9RxELUSfHX7K1TtMUr Sv4wQ43SrHm8Lnw8DWeSaaWS1XVfPtDFaMop19ogXQ5+AtozxsO9nM/5VCffI7T+SR2H nphQ== X-Gm-Message-State: AOAM532VRNx5ysD54Gk7PfPawiqSSmBHvpPk2kxYHDR+A4t6wbhZJ8iJ KwOQwt2wTpNQ+XC0uwQUZjmOKQw2xz7eaQ== X-Google-Smtp-Source: ABdhPJyAV112sVTSq2aNnEBR6JUapoWBtaxeX0Zcv4tF+NI62oeERZtldYzoZFlj0p6Nf8UXSGj4zw== X-Received: by 2002:a05:6000:10c6:: with SMTP id b6mr4437028wrx.10.1603209436532; Tue, 20 Oct 2020 08:57:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/41] accel/tcg: Add tlb_flush_page_bits_by_mmuidx* Date: Tue, 20 Oct 2020 16:56:24 +0100 Message-Id: <20201020155656.8045-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson On ARM, the Top Byte Ignore feature means that only 56 bits of the address are significant in the virtual address. We are required to give the entire 64-bit address to FAR_ELx on fault, which means that we do not "clean" the top byte early in TCG. This new interface allows us to flush all 256 possible aliases for a given page, currently missed by tlb_flush_page*. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Message-id: 20201016210754.818257-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- include/exec/exec-all.h | 36 ++++++ accel/tcg/cputlb.c | 275 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 302 insertions(+), 9 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 66f9b4cca67..4707ac140ce 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -251,6 +251,25 @@ void tlb_flush_by_mmuidx_all_cpus(CPUState *cpu, uint1= 6_t idxmap); * depend on when the guests translation ends the TB. */ void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); + +/** + * tlb_flush_page_bits_by_mmuidx + * @cpu: CPU whose TLB should be flushed + * @addr: virtual address of page to be flushed + * @idxmap: bitmap of mmu indexes to flush + * @bits: number of significant bits in address + * + * Similar to tlb_flush_page_mask, but with a bitmap of indexes. + */ +void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, target_ulong addr, + uint16_t idxmap, unsigned bits); + +/* Similarly, with broadcast and syncing. */ +void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *cpu, target_ulong ad= dr, + uint16_t idxmap, unsigned bits= ); +void tlb_flush_page_bits_by_mmuidx_all_cpus_synced + (CPUState *cpu, target_ulong addr, uint16_t idxmap, unsigned bits); + /** * tlb_set_page_with_attrs: * @cpu: CPU to add this TLB entry for @@ -337,6 +356,23 @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced= (CPUState *cpu, uint16_t idxmap) { } +static inline void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, + target_ulong addr, + uint16_t idxmap, + unsigned bits) +{ +} +static inline void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *cpu, + target_ulong add= r, + uint16_t idxmap, + unsigned bits) +{ +} +static inline void +tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, target_ulong = addr, + uint16_t idxmap, unsigned bi= ts) +{ +} #endif /** * probe_access: diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 2bbbb3ab290..42ab79c1a58 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -409,12 +409,21 @@ void tlb_flush_all_cpus_synced(CPUState *src_cpu) tlb_flush_by_mmuidx_all_cpus_synced(src_cpu, ALL_MMUIDX_BITS); } =20 +static bool tlb_hit_page_mask_anyprot(CPUTLBEntry *tlb_entry, + target_ulong page, target_ulong mask) +{ + page &=3D mask; + mask &=3D TARGET_PAGE_MASK | TLB_INVALID_MASK; + + return (page =3D=3D (tlb_entry->addr_read & mask) || + page =3D=3D (tlb_addr_write(tlb_entry) & mask) || + page =3D=3D (tlb_entry->addr_code & mask)); +} + static inline bool tlb_hit_page_anyprot(CPUTLBEntry *tlb_entry, target_ulong page) { - return tlb_hit_page(tlb_entry->addr_read, page) || - tlb_hit_page(tlb_addr_write(tlb_entry), page) || - tlb_hit_page(tlb_entry->addr_code, page); + return tlb_hit_page_mask_anyprot(tlb_entry, page, -1); } =20 /** @@ -427,31 +436,45 @@ static inline bool tlb_entry_is_empty(const CPUTLBEnt= ry *te) } =20 /* Called with tlb_c.lock held */ -static inline bool tlb_flush_entry_locked(CPUTLBEntry *tlb_entry, - target_ulong page) +static bool tlb_flush_entry_mask_locked(CPUTLBEntry *tlb_entry, + target_ulong page, + target_ulong mask) { - if (tlb_hit_page_anyprot(tlb_entry, page)) { + if (tlb_hit_page_mask_anyprot(tlb_entry, page, mask)) { memset(tlb_entry, -1, sizeof(*tlb_entry)); return true; } return false; } =20 +static inline bool tlb_flush_entry_locked(CPUTLBEntry *tlb_entry, + target_ulong page) +{ + return tlb_flush_entry_mask_locked(tlb_entry, page, -1); +} + /* Called with tlb_c.lock held */ -static inline void tlb_flush_vtlb_page_locked(CPUArchState *env, int mmu_i= dx, - target_ulong page) +static void tlb_flush_vtlb_page_mask_locked(CPUArchState *env, int mmu_idx, + target_ulong page, + target_ulong mask) { CPUTLBDesc *d =3D &env_tlb(env)->d[mmu_idx]; int k; =20 assert_cpu_is_self(env_cpu(env)); for (k =3D 0; k < CPU_VTLB_SIZE; k++) { - if (tlb_flush_entry_locked(&d->vtable[k], page)) { + if (tlb_flush_entry_mask_locked(&d->vtable[k], page, mask)) { tlb_n_used_entries_dec(env, mmu_idx); } } } =20 +static inline void tlb_flush_vtlb_page_locked(CPUArchState *env, int mmu_i= dx, + target_ulong page) +{ + tlb_flush_vtlb_page_mask_locked(env, mmu_idx, page, -1); +} + static void tlb_flush_page_locked(CPUArchState *env, int midx, target_ulong page) { @@ -666,6 +689,240 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, ta= rget_ulong addr) tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS); } =20 +static void tlb_flush_page_bits_locked(CPUArchState *env, int midx, + target_ulong page, unsigned bits) +{ + CPUTLBDesc *d =3D &env_tlb(env)->d[midx]; + CPUTLBDescFast *f =3D &env_tlb(env)->f[midx]; + target_ulong mask =3D MAKE_64BIT_MASK(0, bits); + + /* + * If @bits is smaller than the tlb size, there may be multiple entries + * within the TLB; otherwise all addresses that match under @mask hit + * the same TLB entry. + * + * TODO: Perhaps allow bits to be a few bits less than the size. + * For now, just flush the entire TLB. + */ + if (mask < f->mask) { + tlb_debug("forcing full flush midx %d (" + TARGET_FMT_lx "/" TARGET_FMT_lx ")\n", + midx, page, mask); + tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime()); + return; + } + + /* Check if we need to flush due to large pages. */ + if ((page & d->large_page_mask) =3D=3D d->large_page_addr) { + tlb_debug("forcing full flush midx %d (" + TARGET_FMT_lx "/" TARGET_FMT_lx ")\n", + midx, d->large_page_addr, d->large_page_mask); + tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime()); + return; + } + + if (tlb_flush_entry_mask_locked(tlb_entry(env, midx, page), page, mask= )) { + tlb_n_used_entries_dec(env, midx); + } + tlb_flush_vtlb_page_mask_locked(env, midx, page, mask); +} + +typedef struct { + target_ulong addr; + uint16_t idxmap; + uint16_t bits; +} TLBFlushPageBitsByMMUIdxData; + +static void +tlb_flush_page_bits_by_mmuidx_async_0(CPUState *cpu, + TLBFlushPageBitsByMMUIdxData d) +{ + CPUArchState *env =3D cpu->env_ptr; + int mmu_idx; + + assert_cpu_is_self(cpu); + + tlb_debug("page addr:" TARGET_FMT_lx "/%u mmu_map:0x%x\n", + d.addr, d.bits, d.idxmap); + + qemu_spin_lock(&env_tlb(env)->c.lock); + for (mmu_idx =3D 0; mmu_idx < NB_MMU_MODES; mmu_idx++) { + if ((d.idxmap >> mmu_idx) & 1) { + tlb_flush_page_bits_locked(env, mmu_idx, d.addr, d.bits); + } + } + qemu_spin_unlock(&env_tlb(env)->c.lock); + + tb_flush_jmp_cache(cpu, d.addr); +} + +static bool encode_pbm_to_runon(run_on_cpu_data *out, + TLBFlushPageBitsByMMUIdxData d) +{ + /* We need 6 bits to hold to hold @bits up to 63. */ + if (d.idxmap <=3D MAKE_64BIT_MASK(0, TARGET_PAGE_BITS - 6)) { + *out =3D RUN_ON_CPU_TARGET_PTR(d.addr | (d.idxmap << 6) | d.bits); + return true; + } + return false; +} + +static TLBFlushPageBitsByMMUIdxData +decode_runon_to_pbm(run_on_cpu_data data) +{ + target_ulong addr_map_bits =3D (target_ulong) data.target_ptr; + return (TLBFlushPageBitsByMMUIdxData){ + .addr =3D addr_map_bits & TARGET_PAGE_MASK, + .idxmap =3D (addr_map_bits & ~TARGET_PAGE_MASK) >> 6, + .bits =3D addr_map_bits & 0x3f + }; +} + +static void tlb_flush_page_bits_by_mmuidx_async_1(CPUState *cpu, + run_on_cpu_data runon) +{ + tlb_flush_page_bits_by_mmuidx_async_0(cpu, decode_runon_to_pbm(runon)); +} + +static void tlb_flush_page_bits_by_mmuidx_async_2(CPUState *cpu, + run_on_cpu_data data) +{ + TLBFlushPageBitsByMMUIdxData *d =3D data.host_ptr; + tlb_flush_page_bits_by_mmuidx_async_0(cpu, *d); + g_free(d); +} + +void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, target_ulong addr, + uint16_t idxmap, unsigned bits) +{ + TLBFlushPageBitsByMMUIdxData d; + run_on_cpu_data runon; + + /* If all bits are significant, this devolves to tlb_flush_page. */ + if (bits >=3D TARGET_LONG_BITS) { + tlb_flush_page_by_mmuidx(cpu, addr, idxmap); + return; + } + /* If no page bits are significant, this devolves to tlb_flush. */ + if (bits < TARGET_PAGE_BITS) { + tlb_flush_by_mmuidx(cpu, idxmap); + return; + } + + /* This should already be page aligned */ + d.addr =3D addr & TARGET_PAGE_MASK; + d.idxmap =3D idxmap; + d.bits =3D bits; + + if (qemu_cpu_is_self(cpu)) { + tlb_flush_page_bits_by_mmuidx_async_0(cpu, d); + } else if (encode_pbm_to_runon(&runon, d)) { + async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon= ); + } else { + TLBFlushPageBitsByMMUIdxData *p + =3D g_new(TLBFlushPageBitsByMMUIdxData, 1); + + /* Otherwise allocate a structure, freed by the worker. */ + *p =3D d; + async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_2, + RUN_ON_CPU_HOST_PTR(p)); + } +} + +void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *src_cpu, + target_ulong addr, + uint16_t idxmap, + unsigned bits) +{ + TLBFlushPageBitsByMMUIdxData d; + run_on_cpu_data runon; + + /* If all bits are significant, this devolves to tlb_flush_page. */ + if (bits >=3D TARGET_LONG_BITS) { + tlb_flush_page_by_mmuidx_all_cpus(src_cpu, addr, idxmap); + return; + } + /* If no page bits are significant, this devolves to tlb_flush. */ + if (bits < TARGET_PAGE_BITS) { + tlb_flush_by_mmuidx_all_cpus(src_cpu, idxmap); + return; + } + + /* This should already be page aligned */ + d.addr =3D addr & TARGET_PAGE_MASK; + d.idxmap =3D idxmap; + d.bits =3D bits; + + if (encode_pbm_to_runon(&runon, d)) { + flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, r= unon); + } else { + CPUState *dst_cpu; + TLBFlushPageBitsByMMUIdxData *p; + + /* Allocate a separate data block for each destination cpu. */ + CPU_FOREACH(dst_cpu) { + if (dst_cpu !=3D src_cpu) { + p =3D g_new(TLBFlushPageBitsByMMUIdxData, 1); + *p =3D d; + async_run_on_cpu(dst_cpu, + tlb_flush_page_bits_by_mmuidx_async_2, + RUN_ON_CPU_HOST_PTR(p)); + } + } + } + + tlb_flush_page_bits_by_mmuidx_async_0(src_cpu, d); +} + +void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu, + target_ulong addr, + uint16_t idxmap, + unsigned bits) +{ + TLBFlushPageBitsByMMUIdxData d; + run_on_cpu_data runon; + + /* If all bits are significant, this devolves to tlb_flush_page. */ + if (bits >=3D TARGET_LONG_BITS) { + tlb_flush_page_by_mmuidx_all_cpus_synced(src_cpu, addr, idxmap); + return; + } + /* If no page bits are significant, this devolves to tlb_flush. */ + if (bits < TARGET_PAGE_BITS) { + tlb_flush_by_mmuidx_all_cpus_synced(src_cpu, idxmap); + return; + } + + /* This should already be page aligned */ + d.addr =3D addr & TARGET_PAGE_MASK; + d.idxmap =3D idxmap; + d.bits =3D bits; + + if (encode_pbm_to_runon(&runon, d)) { + flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, r= unon); + async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async= _1, + runon); + } else { + CPUState *dst_cpu; + TLBFlushPageBitsByMMUIdxData *p; + + /* Allocate a separate data block for each destination cpu. */ + CPU_FOREACH(dst_cpu) { + if (dst_cpu !=3D src_cpu) { + p =3D g_new(TLBFlushPageBitsByMMUIdxData, 1); + *p =3D d; + async_run_on_cpu(dst_cpu, tlb_flush_page_bits_by_mmuidx_as= ync_2, + RUN_ON_CPU_HOST_PTR(p)); + } + } + + p =3D g_new(TLBFlushPageBitsByMMUIdxData, 1); + *p =3D d; + async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async= _2, + RUN_ON_CPU_HOST_PTR(p)); + } +} + /* update the TLBs so that writes to code in the virtual page 'addr' can be detected */ void tlb_protect_code(ram_addr_t ram_addr) --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209700; cv=none; d=zohomail.com; s=zohoarc; b=cGUqCaS6RHBYEwVYTyWRglMJ/ipuKjYBbjxXSJ+sGv7J68wvtpyJwZG/cvE6j1BBuyH0gJqXG1hkj/ZeUIYJ6Z7r+Ygld2RKS0700uaQxw+i3Xlubby+PXQz7TgrdlbraoN1ooAEEYF30/8BcOF2YRHYV5bWKllO6hyhleBwsNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209700; h=Content-Type:Content-Transfer-Encoding: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=ZvUBhs8RA0L3oiYr8jUE+scCdZBTj6SeAlZ2duNtda0=; b=nZQFhF/16ky2tejE4YCbQyVHwFQ0f8x1FQYsoiTiHDNZ0R0PZbCRya4BzBEhg29Co4/NI6khg01z9xNZQrpVpjg4FsAcN6gh7jmrb1Rv9ixJA3Qxa8qfoDq/G0r6OJl11S9m+GrkjAFxfIhBAPhJBdYlFvrA13cEuDNjuGhvHkk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209700329323.96281922163223; Tue, 20 Oct 2020 09:01:40 -0700 (PDT) Received: from localhost ([::1]:40602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu4w-000127-JB for importer@patchew.org; Tue, 20 Oct 2020 12:01:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0n-0004YN-VH for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:21 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0m-0003sf-2l for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:21 -0400 Received: by mail-wr1-x443.google.com with SMTP id n6so2772777wrm.13 for ; Tue, 20 Oct 2020 08:57:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZvUBhs8RA0L3oiYr8jUE+scCdZBTj6SeAlZ2duNtda0=; b=iHlezuf2Dmzh+kmjYhmqYYFr5xWzf/KVMuDjkqhkt8JatnldzMkAXxaWzZVJvZxslG mK/TChnR50enmMo3FVqUYAy2YILJ95hDEdq9Zd9eOvO9K/2PP25VySPSDgBrVM1VESRc 2KVvB40LB08Vf0GNHb0y3kh9rDanAvquW1eApQSj6oT2m0rp//OBJicqxEJICfPK9HLp CnTbAFp1O2LlCYW+KAmA4QaBow7WJibOBaTiYguK9uGsgJIME+HSMAUTnwEedOYcWQi+ mg4ej/rlPTzOyzYLGLJ90ovuC/ad3AcgR2iXqu4r6RL/ju6cnr6OlUy25TcbmdsaiV5W V9qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZvUBhs8RA0L3oiYr8jUE+scCdZBTj6SeAlZ2duNtda0=; b=iDRpdn5vjvWyFw+ntNSutW3X7NcnBhuaHPfhDsgEyrwMEJte5EQ8u/vMx3xVd5Bk/a oime0N9UpQ7FbLyWMscNF5GQWgpAStTVb1qm4LVIlmSSiJ/drFIhc0qcgdWaXSVEiJ7x S8fMB87oLkoJGLks8AKyCFFh79ZmYSm/wCajzjex3HABCpBzPIgl73ka+JNOwKLjNc4d qedDE+j/zdtKoPs2pkft2+Vl5RuZYkNQOqQV7mbN+Ypk8L3r1s9NoT0wpqcgqqvlLFnM YKSPECgBaZMYL/Mx+PiYb+Ms26ZFW6DofPwh3L8wUlQdz2BST7I3w+2BbeL1HXMvq3RO 0lAw== X-Gm-Message-State: AOAM533/wo5lhgBYF+PZEuo1IJB5mo8VsuwmQkw140LQh5Y3K8TSMh4g 6sL2eIObHoWWA2Ons4dUWeVGjjhXIsDjSw== X-Google-Smtp-Source: ABdhPJzs0Pizu/S+W1UYbsc4UVF7VhlSljqfzPAih0x3zv2VlAw8am6x0QbyXUfoxV/zf5bxqdC7Ng== X-Received: by 2002:a5d:448b:: with SMTP id j11mr4194618wrq.129.1603209438183; Tue, 20 Oct 2020 08:57:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/41] target/arm: Use tlb_flush_page_bits_by_mmuidx* Date: Tue, 20 Oct 2020 16:56:25 +0100 Message-Id: <20201020155656.8045-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson When TBI is enabled in a given regime, 56 bits of the address are significant and we need to clear out any other matching virtual addresses with differing tags. The other uses of tlb_flush_page (without mmuidx) in this file are only used by aarch32 mode. Fixes: 38d931687fa1 Reported-by: Jordan Frank Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201016210754.818257-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 46 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index cd0779ff5fa..f49b045d366 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -50,6 +50,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_u= long address, #endif =20 static void switch_mode(CPUARMState *env, int mode); +static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx); =20 static int vfp_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) { @@ -4457,6 +4458,33 @@ static int vae1_tlbmask(CPUARMState *env) } } =20 +/* Return 56 if TBI is enabled, 64 otherwise. */ +static int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx, + uint64_t addr) +{ + uint64_t tcr =3D regime_tcr(env, mmu_idx)->raw_tcr; + int tbi =3D aa64_va_parameter_tbi(tcr, mmu_idx); + int select =3D extract64(addr, 55, 1); + + return (tbi >> select) & 1 ? 56 : 64; +} + +static int vae1_tlbbits(CPUARMState *env, uint64_t addr) +{ + ARMMMUIdx mmu_idx; + + /* Only the regime of the mmu_idx below is significant. */ + if (arm_is_secure_below_el3(env)) { + mmu_idx =3D ARMMMUIdx_SE10_0; + } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) + =3D=3D (HCR_E2H | HCR_TGE)) { + mmu_idx =3D ARMMMUIdx_E20_0; + } else { + mmu_idx =3D ARMMMUIdx_E10_0; + } + return tlbbits_for_regime(env, mmu_idx, addr); +} + static void tlbi_aa64_vmalle1is_write(CPUARMState *env, const ARMCPRegInfo= *ri, uint64_t value) { @@ -4593,8 +4621,9 @@ static void tlbi_aa64_vae1is_write(CPUARMState *env, = const ARMCPRegInfo *ri, CPUState *cs =3D env_cpu(env); int mask =3D vae1_tlbmask(env); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); + int bits =3D vae1_tlbbits(env, pageaddr); =20 - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, mask); + tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits= ); } =20 static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4608,11 +4637,12 @@ static void tlbi_aa64_vae1_write(CPUARMState *env, = const ARMCPRegInfo *ri, CPUState *cs =3D env_cpu(env); int mask =3D vae1_tlbmask(env); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); + int bits =3D vae1_tlbbits(env, pageaddr); =20 if (tlb_force_broadcast(env)) { - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, mask); + tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, = bits); } else { - tlb_flush_page_by_mmuidx(cs, pageaddr, mask); + tlb_flush_page_bits_by_mmuidx(cs, pageaddr, mask, bits); } } =20 @@ -4621,9 +4651,10 @@ static void tlbi_aa64_vae2is_write(CPUARMState *env,= const ARMCPRegInfo *ri, { CPUState *cs =3D env_cpu(env); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); + int bits =3D tlbbits_for_regime(env, ARMMMUIdx_E2, pageaddr); =20 - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_E2); + tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, + ARMMMUIdxBit_E2, bits); } =20 static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *r= i, @@ -4631,9 +4662,10 @@ static void tlbi_aa64_vae3is_write(CPUARMState *env,= const ARMCPRegInfo *ri, { CPUState *cs =3D env_cpu(env); uint64_t pageaddr =3D sextract64(value << 12, 0, 56); + int bits =3D tlbbits_for_regime(env, ARMMMUIdx_SE3, pageaddr); =20 - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, - ARMMMUIdxBit_SE3); + tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, + ARMMMUIdxBit_SE3, bits); } =20 static CPAccessResult aa64_zva_access(CPUARMState *env, const ARMCPRegInfo= *ri, --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209904; cv=none; d=zohomail.com; s=zohoarc; b=d7ZvHzJ/pvHN+o9bfRfMQzjUjkJurj70OCqv2T3FEszjjErA4Hy1rKg38cmlmyh7nz3rVf84DFvAeKe42rgp4XMWw9U60kGcmmWkTxFhvYgC72HTq+FsKcBRKNFBJ4GR0rz5dCAwPnTrL4fgKPbvFxs/q9b9F9tTwjfloumRWdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209904; h=Content-Transfer-Encoding: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=QNRMBc7L7Px2TBjGttbqCZn70Tii4/dN+nmw2tevPpo=; b=VhYlQJPq2p3aik+AMTPLgTcFqaE1mg/Ck3ChmE+9nh7Tg5oViccLhvxZIK4NmAqIAeaVB0iQupScFD35OTJwhhy3NCvkbSRM41Q92KzKOFg+NCvWp/qaJOJuEUXDkNjZE0YcOBVUEAVehuo/3M0zBw+lHF94stShBomawknxyOM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209904293249.05467145445436; Tue, 20 Oct 2020 09:05:04 -0700 (PDT) Received: from localhost ([::1]:51430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu8F-0005di-23 for importer@patchew.org; Tue, 20 Oct 2020 12:05:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0r-0004i5-VE for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:25 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:36995) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0n-0003sw-S7 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:25 -0400 Received: by mail-wr1-x42b.google.com with SMTP id h7so2793037wre.4 for ; Tue, 20 Oct 2020 08:57:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QNRMBc7L7Px2TBjGttbqCZn70Tii4/dN+nmw2tevPpo=; b=xHxG9fcuasFW/dRfjYB/3TzuLJ9gdDbLatfOI7oQIMJSkUi+ioSoW/pJwy7vU/eEMS 2sh/bv/eGUaRuOYA9EgLbqkCevRgehMK1aifLzGWsOo0UP2jBkarVLzKI4yKRmGYDasS tXH8Jyw1XtSdkYB+6MxW9YRVg95faELO9wwqKworjV+VDn1EY82vuEzIGkhdhRX4BRU1 PDR7sxTV0LfzPais/Sf29kwJVCEmvthC3I1wKFL7HeZZxeNbgTolrPY5fXTuRzh/7jM2 I5i2v3MDsgRAFVpFkOUkLFGMWZ+PiwphAOAixkpg70eJZ8oC7jjbUzDjWIU2WtLJnFdJ wSHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QNRMBc7L7Px2TBjGttbqCZn70Tii4/dN+nmw2tevPpo=; b=H5kT6TwuPxQ6Ch1uM9IskfANZBls/MXfK4rbY9uSDrusn30vWIaflDqhJp6W7xq/K6 Wq3R8KAoEZWKE4+9q/39D8lsXr+C3A1E6yCW8rOkWHU+EtPEHB4eUWXRnZ5IKNJqsMV2 lAn80p65iRxDuz62QqTSA5aR75iZonF6tQovPg+4QGQPNNakg9aiAvQ8t1AEpGx5ITCk DQTnrpRjaHeP9MUHz0AUa9FTJEXlvax26aBnpAWt8qbzdkUkcvg3RqKPXGARMuuU4GTx cP942c087dVq8I4m/zenL46NtB5G7Pkuvz+E/n5+OfNmnl4KAV5BCSevDNhB/DxvzBOo S3/w== X-Gm-Message-State: AOAM532oTdQQb32YTGtGAfceE0qGyF3U5GgEHwahHQXaqyqxPfkS8JTR P5vBYYTK+B37hbvHb8i+OI7RYDH/SCBsZg== X-Google-Smtp-Source: ABdhPJxFZiV1cSLeZprYGZjxqR//yGBAoj4nh1T+gifSGdlpI8+eL/P7Bx6ycgKjUBe3aMdmS6UMAw== X-Received: by 2002:adf:eb41:: with SMTP id u1mr4122257wrn.94.1603209439428; Tue, 20 Oct 2020 08:57:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/41] tests/qtest: Add npcm7xx timer test Date: Tue, 20 Oct 2020 16:56:26 +0100 Message-Id: <20201020155656.8045-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Havard Skinnemoen This test exercises the various modes of the npcm7xx timer. In particular, it triggers the bug found by the fuzzer, as reported here: https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg02992.html It also found several other bugs, especially related to interrupt handling. The test exercises all the timers in all the timer modules, which expands to 180 test cases in total. Reviewed-by: Tyrone Ting Signed-off-by: Havard Skinnemoen Message-id: 20201008232154.94221-2-hskinnemoen@google.com Signed-off-by: Peter Maydell --- tests/qtest/npcm7xx_timer-test.c | 562 +++++++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 2 files changed, 563 insertions(+) create mode 100644 tests/qtest/npcm7xx_timer-test.c diff --git a/tests/qtest/npcm7xx_timer-test.c b/tests/qtest/npcm7xx_timer-t= est.c new file mode 100644 index 00000000000..f08b0cd62ac --- /dev/null +++ b/tests/qtest/npcm7xx_timer-test.c @@ -0,0 +1,562 @@ +/* + * QTest testcase for the Nuvoton NPCM7xx Timer + * + * Copyright 2020 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" +#include "qemu/timer.h" +#include "libqtest-single.h" + +#define TIM_REF_HZ (25000000) + +/* Bits in TCSRx */ +#define CEN BIT(30) +#define IE BIT(29) +#define MODE_ONESHOT (0 << 27) +#define MODE_PERIODIC (1 << 27) +#define CRST BIT(26) +#define CACT BIT(25) +#define PRESCALE(x) (x) + +/* Registers shared between all timers in a module. */ +#define TISR 0x18 +#define WTCR 0x1c +# define WTCLK(x) ((x) << 10) + +/* Power-on default; used to re-initialize timers before each test. */ +#define TCSR_DEFAULT PRESCALE(5) + +/* Register offsets for a timer within a timer block. */ +typedef struct Timer { + unsigned int tcsr_offset; + unsigned int ticr_offset; + unsigned int tdr_offset; +} Timer; + +/* A timer block containing 5 timers. */ +typedef struct TimerBlock { + int irq_base; + uint64_t base_addr; +} TimerBlock; + +/* Testdata for testing a particular timer within a timer block. */ +typedef struct TestData { + const TimerBlock *tim; + const Timer *timer; +} TestData; + +const TimerBlock timer_block[] =3D { + { + .irq_base =3D 32, + .base_addr =3D 0xf0008000, + }, + { + .irq_base =3D 37, + .base_addr =3D 0xf0009000, + }, + { + .irq_base =3D 42, + .base_addr =3D 0xf000a000, + }, +}; + +const Timer timer[] =3D { + { + .tcsr_offset =3D 0x00, + .ticr_offset =3D 0x08, + .tdr_offset =3D 0x10, + }, { + .tcsr_offset =3D 0x04, + .ticr_offset =3D 0x0c, + .tdr_offset =3D 0x14, + }, { + .tcsr_offset =3D 0x20, + .ticr_offset =3D 0x28, + .tdr_offset =3D 0x30, + }, { + .tcsr_offset =3D 0x24, + .ticr_offset =3D 0x2c, + .tdr_offset =3D 0x34, + }, { + .tcsr_offset =3D 0x40, + .ticr_offset =3D 0x48, + .tdr_offset =3D 0x50, + }, +}; + +/* Returns the index of the timer block. */ +static int tim_index(const TimerBlock *tim) +{ + ptrdiff_t diff =3D tim - timer_block; + + g_assert(diff >=3D 0 && diff < ARRAY_SIZE(timer_block)); + + return diff; +} + +/* Returns the index of a timer within a timer block. */ +static int timer_index(const Timer *t) +{ + ptrdiff_t diff =3D t - timer; + + g_assert(diff >=3D 0 && diff < ARRAY_SIZE(timer)); + + return diff; +} + +/* Returns the irq line for a given timer. */ +static int tim_timer_irq(const TestData *td) +{ + return td->tim->irq_base + timer_index(td->timer); +} + +/* Register read/write accessors. */ + +static void tim_write(const TestData *td, + unsigned int offset, uint32_t value) +{ + writel(td->tim->base_addr + offset, value); +} + +static uint32_t tim_read(const TestData *td, unsigned int offset) +{ + return readl(td->tim->base_addr + offset); +} + +static void tim_write_tcsr(const TestData *td, uint32_t value) +{ + tim_write(td, td->timer->tcsr_offset, value); +} + +static uint32_t tim_read_tcsr(const TestData *td) +{ + return tim_read(td, td->timer->tcsr_offset); +} + +static void tim_write_ticr(const TestData *td, uint32_t value) +{ + tim_write(td, td->timer->ticr_offset, value); +} + +static uint32_t tim_read_ticr(const TestData *td) +{ + return tim_read(td, td->timer->ticr_offset); +} + +static uint32_t tim_read_tdr(const TestData *td) +{ + return tim_read(td, td->timer->tdr_offset); +} + +/* Returns the number of nanoseconds to count the given number of cycles. = */ +static int64_t tim_calculate_step(uint32_t count, uint32_t prescale) +{ + return (1000000000LL / TIM_REF_HZ) * count * (prescale + 1); +} + +/* Returns a bitmask corresponding to the timer under test. */ +static uint32_t tim_timer_bit(const TestData *td) +{ + return BIT(timer_index(td->timer)); +} + +/* Resets all timers to power-on defaults. */ +static void tim_reset(const TestData *td) +{ + int i, j; + + /* Reset all the timers, in case a previous test left a timer running.= */ + for (i =3D 0; i < ARRAY_SIZE(timer_block); i++) { + for (j =3D 0; j < ARRAY_SIZE(timer); j++) { + writel(timer_block[i].base_addr + timer[j].tcsr_offset, + CRST | TCSR_DEFAULT); + } + writel(timer_block[i].base_addr + TISR, -1); + } +} + +/* Verifies the reset state of a timer. */ +static void test_reset(gconstpointer test_data) +{ + const TestData *td =3D test_data; + + tim_reset(td); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, TCSR_DEFAULT); + g_assert_cmphex(tim_read_ticr(td), =3D=3D, 0); + g_assert_cmphex(tim_read_tdr(td), =3D=3D, 0); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + g_assert_cmphex(tim_read(td, WTCR), =3D=3D, WTCLK(1)); +} + +/* Verifies that CRST wins if both CEN and CRST are set. */ +static void test_reset_overrides_enable(gconstpointer test_data) +{ + const TestData *td =3D test_data; + + tim_reset(td); + + /* CRST should force CEN to 0 */ + tim_write_tcsr(td, CEN | CRST | TCSR_DEFAULT); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, TCSR_DEFAULT); + g_assert_cmphex(tim_read_tdr(td), =3D=3D, 0); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); +} + +/* Verifies the behavior when CEN is set and then cleared. */ +static void test_oneshot_enable_then_disable(gconstpointer test_data) +{ + const TestData *td =3D test_data; + + tim_reset(td); + + /* Enable the timer with zero initial count, then disable it again. */ + tim_write_tcsr(td, CEN | TCSR_DEFAULT); + tim_write_tcsr(td, TCSR_DEFAULT); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, TCSR_DEFAULT); + g_assert_cmphex(tim_read_tdr(td), =3D=3D, 0); + /* Timer interrupt flag should be set, but interrupts are not enabled.= */ + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); +} + +/* Verifies that a one-shot timer fires when expected with prescaler 5. */ +static void test_oneshot_ps5(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 256; + unsigned int ps =3D 5; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, CEN | PRESCALE(ps)); + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, CEN | CACT | PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count); + + clock_step(tim_calculate_step(count, ps) - 1); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, CEN | CACT | PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), <, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + + clock_step(1); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); + + /* Clear the interrupt flag. */ + tim_write(td, TISR, tim_timer_bit(td)); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); + + /* Verify that this isn't a periodic timer. */ + clock_step(2 * tim_calculate_step(count, ps)); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); +} + +/* Verifies that a one-shot timer fires when expected with prescaler 0. */ +static void test_oneshot_ps0(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 1; + unsigned int ps =3D 0; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, CEN | PRESCALE(ps)); + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, CEN | CACT | PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count); + + clock_step(tim_calculate_step(count, ps) - 1); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, CEN | CACT | PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), <, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + + clock_step(1); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); +} + +/* Verifies that a one-shot timer fires when expected with highest prescal= er. */ +static void test_oneshot_ps255(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D (1U << 24) - 1; + unsigned int ps =3D 255; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, CEN | PRESCALE(ps)); + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, CEN | CACT | PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count); + + clock_step(tim_calculate_step(count, ps) - 1); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, CEN | CACT | PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), <, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + + clock_step(1); + + g_assert_cmphex(tim_read_tcsr(td), =3D=3D, PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); +} + +/* Verifies that a oneshot timer fires an interrupt when expected. */ +static void test_oneshot_interrupt(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 256; + unsigned int ps =3D 7; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, IE | CEN | MODE_ONESHOT | PRESCALE(ps)); + + clock_step_next(); + + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_true(qtest_get_irq(global_qtest, tim_timer_irq(td))); +} + +/* + * Verifies that the timer can be paused and later resumed, and it still f= ires + * at the right moment. + */ +static void test_pause_resume(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 256; + unsigned int ps =3D 1; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, IE | CEN | MODE_ONESHOT | PRESCALE(ps)); + + /* Pause the timer halfway to expiration. */ + clock_step(tim_calculate_step(count / 2, ps)); + tim_write_tcsr(td, IE | MODE_ONESHOT | PRESCALE(ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count / 2); + + /* Counter should not advance during the following step. */ + clock_step(2 * tim_calculate_step(count, ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count / 2); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); + + /* Resume the timer and run _almost_ to expiration. */ + tim_write_tcsr(td, IE | CEN | MODE_ONESHOT | PRESCALE(ps)); + clock_step(tim_calculate_step(count / 2, ps) - 1); + g_assert_cmpuint(tim_read_tdr(td), <, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); + + /* Now, run the rest of the way and verify that the interrupt fires. */ + clock_step(1); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_true(qtest_get_irq(global_qtest, tim_timer_irq(td))); +} + +/* Verifies that the prescaler can be changed while the timer is runnin. */ +static void test_prescaler_change(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 256; + unsigned int ps =3D 5; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); + + /* Run a quarter of the way, and change the prescaler. */ + clock_step(tim_calculate_step(count / 4, ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, 3 * count / 4); + ps =3D 2; + tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); + /* The counter must not change. */ + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, 3 * count / 4); + + /* Run another quarter of the way, and change the prescaler again. */ + clock_step(tim_calculate_step(count / 4, ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count / 2); + ps =3D 8; + tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); + /* The counter must not change. */ + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count / 2); + + /* Run another quarter of the way, and change the prescaler again. */ + clock_step(tim_calculate_step(count / 4, ps)); + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count / 4); + ps =3D 0; + tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); + /* The counter must not change. */ + g_assert_cmpuint(tim_read_tdr(td), =3D=3D, count / 4); + + /* Run almost to expiration, and verify the timer didn't fire yet. */ + clock_step(tim_calculate_step(count / 4, ps) - 1); + g_assert_cmpuint(tim_read_tdr(td), <, count); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + + /* Now, run the rest of the way and verify that the timer fires. */ + clock_step(1); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); +} + +/* Verifies that a periodic timer automatically restarts after expiration.= */ +static void test_periodic_no_interrupt(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 2; + unsigned int ps =3D 3; + int i; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, CEN | MODE_PERIODIC | PRESCALE(ps)); + + for (i =3D 0; i < 4; i++) { + clock_step_next(); + + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); + + tim_write(td, TISR, tim_timer_bit(td)); + + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); + } +} + +/* Verifies that a periodict timer fires an interrupt every time it expire= s. */ +static void test_periodic_interrupt(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 65535; + unsigned int ps =3D 2; + int i; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, CEN | IE | MODE_PERIODIC | PRESCALE(ps)); + + for (i =3D 0; i < 4; i++) { + clock_step_next(); + + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); + g_assert_true(qtest_get_irq(global_qtest, tim_timer_irq(td))); + + tim_write(td, TISR, tim_timer_bit(td)); + + g_assert_cmphex(tim_read(td, TISR), =3D=3D, 0); + g_assert_false(qtest_get_irq(global_qtest, tim_timer_irq(td))); + } +} + +/* + * Verifies that the timer behaves correctly when disabled right before and + * exactly when it's supposed to expire. + */ +static void test_disable_on_expiration(gconstpointer test_data) +{ + const TestData *td =3D test_data; + unsigned int count =3D 8; + unsigned int ps =3D 255; + + tim_reset(td); + + tim_write_ticr(td, count); + tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); + + clock_step(tim_calculate_step(count, ps) - 1); + + tim_write_tcsr(td, MODE_ONESHOT | PRESCALE(ps)); + tim_write_tcsr(td, CEN | MODE_ONESHOT | PRESCALE(ps)); + clock_step(1); + tim_write_tcsr(td, MODE_ONESHOT | PRESCALE(ps)); + g_assert_cmphex(tim_read(td, TISR), =3D=3D, tim_timer_bit(td)); +} + +/* + * Constructs a name that includes the timer block, timer and testcase nam= e, + * and adds the test to the test suite. + */ +static void tim_add_test(const char *name, const TestData *td, GTestDataFu= nc fn) +{ + g_autofree char *full_name; + + full_name =3D g_strdup_printf("npcm7xx_timer/tim[%d]/timer[%d]/%s", + tim_index(td->tim), timer_index(td->timer), + name); + qtest_add_data_func(full_name, td, fn); +} + +/* Convenience macro for adding a test with a predictable function name. */ +#define add_test(name, td) tim_add_test(#name, td, test_##name) + +int main(int argc, char **argv) +{ + TestData testdata[ARRAY_SIZE(timer_block) * ARRAY_SIZE(timer)]; + int ret; + int i, j; + + g_test_init(&argc, &argv, NULL); + g_test_set_nonfatal_assertions(); + + for (i =3D 0; i < ARRAY_SIZE(timer_block); i++) { + for (j =3D 0; j < ARRAY_SIZE(timer); j++) { + TestData *td =3D &testdata[i * ARRAY_SIZE(timer) + j]; + td->tim =3D &timer_block[i]; + td->timer =3D &timer[j]; + + add_test(reset, td); + add_test(reset_overrides_enable, td); + add_test(oneshot_enable_then_disable, td); + add_test(oneshot_ps5, td); + add_test(oneshot_ps0, td); + add_test(oneshot_ps255, td); + add_test(oneshot_interrupt, td); + add_test(pause_resume, td); + add_test(prescaler_change, td); + add_test(periodic_no_interrupt, td); + add_test(periodic_interrupt, td); + add_test(disable_on_expiration, td); + } + } + + qtest_start("-machine npcm750-evb"); + qtest_irq_intercept_in(global_qtest, "/machine/soc/a9mpcore/gic"); + ret =3D g_test_run(); + qtest_end(); + + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 3987f960863..28d4068718e 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -138,6 +138,7 @@ qtests_arm =3D \ ['arm-cpu-features', 'microbit-test', 'm25p80-test', + 'npcm7xx_timer-test', 'test-arm-mptimer', 'boot-serial-test', 'hexloader-test'] --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209718; cv=none; d=zohomail.com; s=zohoarc; b=O/sgbinGSnfhsrdU6NuNIdbdsM9/U7gMEhT0LvSZ/WCvMInnwMNib9jQHunKsSWfYMx7jjpUnBpL4PQr1GYt4jDqJgqjDshndWEnQnrVESfTYETA7Y9ALiKPv256f15EqBCjczu0QtgXKc7N6q7uv3JS4V3mOMpuhcRr2DHtW8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209718; h=Content-Transfer-Encoding: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=QxPmVnrfSjFTEg3WYheghSIjLNIn+PX9t57cQEz8lUM=; b=LOludk6L610ShOgFO8K+jCxM1bhsQIzCKdImV5DcGKrmhugoIZZBDLCNb+448yswYqG6PMfZthII/KkuPN443TPcG7u/is9bFE68jWRCki0K0T/vdgOmAG6vRvO3N/iWYpSAlhohT6wJJt7p2mA+Hb/i65/73G4l4wz4qutSJQY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209717254651.0391234015019; Tue, 20 Oct 2020 09:01:57 -0700 (PDT) Received: from localhost ([::1]:41620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu5D-0001T7-CU for importer@patchew.org; Tue, 20 Oct 2020 12:01:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0q-0004dW-1w for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:24 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:38212) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0o-0003t2-6Q for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:23 -0400 Received: by mail-wm1-x32b.google.com with SMTP id b127so2507274wmb.3 for ; Tue, 20 Oct 2020 08:57:21 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QxPmVnrfSjFTEg3WYheghSIjLNIn+PX9t57cQEz8lUM=; b=k30pFzMaCBR0znJb+gqeyN4qH17fKLQDLH9FcGaL0A2XuPYetPnAY7pih4dyjuyLP2 IG71hxdGxiIcqEU4s41gZibY+4iJxFazj50AlXrLjqQph2/BLeYhKeklcaWd1SsdZQpb V55MXxN7WBgONnSUkowZMUE/fmdWhbMpdnVMjizixihskQwX3yaKmFu9ung4MQfwu1s8 7YMWoAiizERmKAI80tCzuYujsBZekSQFxucsn5/ObHv4Qg2YSAVfjAUWTlDLp6bxTTti uM7/TyUzoIVW0q3I8apJ9IVRcShMx0Q7PWu92FK9v/3n5y4q/wD9Hr6zWvGSKTqK4dC6 gbsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QxPmVnrfSjFTEg3WYheghSIjLNIn+PX9t57cQEz8lUM=; b=MXpzbefaRCpaLRY5pfKAmCeHpDLr5A4FajQqaqRV79aGO5lm6HH/n67RzphptIiKoJ O+A7if/1CDLzTi7C1Rp3qHP1mS3N44441AyEEnMqgoMqiRdayCy3WEOhIiIZb07NvLon NHtGN3dMPUDLk7BgZo+cXXO1uWeGPTDlYduSYICkdDSamHrV2BV4bkcwiBc3aIgtdxd9 c1onCC0aHbWfes2s/dhsgyzw1CzjaBCKflvTZaJOEklxh6wMlTMPJ3YsG05ktPgywx0P thNlVaXfX1IMPbMHKiCxcB45M8Q0D81Gud0mmgAvtUMLC3D+MjN4lIJP60IiIDoLhd2d 4XFg== X-Gm-Message-State: AOAM5309PSBX82pwJK3oN+snQ2w0qywtNeiIlNtaBvDYfAPVhCFNmEkX 3zuF8K9fUNHyqJs5MVtiJMKXHYojuaCCYg== X-Google-Smtp-Source: ABdhPJxA/GgGj76dkxxvXJ1vNzLrk73A79CCx+lXNLIUEbw5HY5S+jB6Se59LKZRM3FuB/I8zP8TRA== X-Received: by 2002:a7b:c345:: with SMTP id l5mr3586080wmj.123.1603209440443; Tue, 20 Oct 2020 08:57:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/41] loads-stores.rst: add footnote that clarifies GETPC usage Date: Tue, 20 Oct 2020 16:56:27 +0100 Message-Id: <20201020155656.8045-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Current documentation is not too clear on the GETPC usage. In particular, when used outside the top level helper function it causes unexpected behavior. Signed-off-by: Emanuele Giuseppe Esposito Message-id: 20201015095147.1691-1-e.emanuelegiuseppe@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- docs/devel/loads-stores.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst index 9a944ef1af6..59c1225391c 100644 --- a/docs/devel/loads-stores.rst +++ b/docs/devel/loads-stores.rst @@ -93,7 +93,13 @@ guest CPU state in case of a guest CPU exception. This = is passed to ``cpu_restore_state()``. Therefore the value should either be 0, to indicate that the guest CPU state is already synchronized, or the result of ``GETPC()`` from the top level ``HELPER(foo)`` -function, which is a return address into the generated code. +function, which is a return address into the generated code [#gpc]_. + +.. [#gpc] Note that ``GETPC()`` should be used with great care: calling + it in other functions that are *not* the top level + ``HELPER(foo)`` will cause unexpected behavior. Instead, the + value of ``GETPC()`` should be read from the helper and passed + if needed to the functions that the helper calls. =20 Function names follow the pattern: =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210494; cv=none; d=zohomail.com; s=zohoarc; b=ToWocSsM3bPPSsiu/ubDchkbFnuUoXTk1nw0hz1FG0k1aP5t/i/zBXXsu4JyM6Cn9yf3UOAjzBuiJWUpHoGrbz8P5HUTiFuiVvnYghZQw2l1vbc1b+0VnKwwLouVXNYb2qA/6XMc70r4bdn3vWXmRC2suut9joC+r5+PRgtgNIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210494; h=Content-Type:Content-Transfer-Encoding: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=L0lYmOUonCsI2H/sVY4IV71YZ7WBk/jN9yG1LepsCeQ=; b=QUfQEbAQmUpyL8K9pD9PkfEFynKqRU2ykcW6GzW5IBrIhU0TizRvS8Qpol5jqLtSE+1MYuDxxXOOVWA1PZRaF5MvIhzpj8eqNyaoLAmelzPkQX4PWX9Axd0l31f1lcqJsw/rFqWkNK9k+bcwVZP1thtH7yfG2R23fEdaNhNSdEA= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160321049434285.13654020767535; Tue, 20 Oct 2020 09:14:54 -0700 (PDT) Received: from localhost ([::1]:54334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuHl-0002A2-BV for importer@patchew.org; Tue, 20 Oct 2020 12:14:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0r-0004hM-Lc for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:25 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:56274) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0p-0003tJ-3z for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:25 -0400 Received: by mail-wm1-x32b.google.com with SMTP id a72so2329650wme.5 for ; Tue, 20 Oct 2020 08:57:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=L0lYmOUonCsI2H/sVY4IV71YZ7WBk/jN9yG1LepsCeQ=; b=VSpgnK1LEpn0kGA3tyU60mbWTI15NvlO9OZqUz/GPAqw/w6xLBJ5J5Lrlphy/szOBP fcGUMkCjVJYYEM6i+TDKoyXwQy+R0yCl/Fz9Z6AGBurZMrWCu94DSZSn5oyu6FTwuj5M CvZg+Yv7P0kcw4J7cvY2wI450FDjglYedmDTl64NGIBBxDVEPhllVso/Tp3nOo/smaLO zIp3OHTi6IiNgFrm2ZNiiOd2dabrTiqhvtn0T2lvU8WAYBHJxf7qY8+/wFKfHng6lHiM BV/stjT/Wv8J7WNeTvVIW+tjG4pQRFtCPKvhSEutNoSuTp0fR6v7ACJzOGRqKgh5HXxo Q4Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L0lYmOUonCsI2H/sVY4IV71YZ7WBk/jN9yG1LepsCeQ=; b=N2iDOgcxzc97zsBTJ52PuGJrkdIL3HbGAX++WpjZzBbIPAchD93SL6YRp1DPep/1ea /6JagGoCy/sQnMFZ45abchq16l4cV7n2YyacP1q8cpkDVyoA1Cs06df3yymsDCNCTVKl g5arT3rQOJGJRTTf+IDFk6zL6ScJ8t7cVo2MLGwjOxXsG/J9kfXafDAm/7znJV3Q9QGT HbxqUmqspDgWSeMij1kgmP02q7/bxBRx9OhVeohbu6mqBk65AK2rNtKpFd0opEhi7uXN lG+nqUsZwpPjzqs3DDbPffwFCdV9Bi6InsHHToX3mV8lXU18wQw0BX/QLtH6G/6UWjvC NXsA== X-Gm-Message-State: AOAM5307SiPs2mzldfi0n4/HIXgMXhxiFg9kLT3bh2jA+rYL+3NT3Ys2 IPSxHye5sExRGRPH8Yq1013ElPWXwykgyA== X-Google-Smtp-Source: ABdhPJw9xpDEM6/8lvjdRXuPRhqj3rooHKWmbhCBef9cHUlvi+ezrysOKpV6h2RyDPY10GnD5rFM0A== X-Received: by 2002:a1c:b40b:: with SMTP id d11mr3543359wmf.152.1603209441497; Tue, 20 Oct 2020 08:57:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/41] hw/intc/bcm2835_ic: Trace GPU/CPU IRQ handlers Date: Tue, 20 Oct 2020 16:56:28 +0100 Message-Id: <20201020155656.8045-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 Add trace events for GPU and CPU IRQs. Reviewed-by: Luc Michel Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201017180731.1165871-2-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/intc/bcm2835_ic.c | 4 +++- hw/intc/trace-events | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/intc/bcm2835_ic.c b/hw/intc/bcm2835_ic.c index 53ab8f58810..9000d995e81 100644 --- a/hw/intc/bcm2835_ic.c +++ b/hw/intc/bcm2835_ic.c @@ -18,6 +18,7 @@ #include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" +#include "trace.h" =20 #define GPU_IRQS 64 #define ARM_IRQS 8 @@ -51,7 +52,6 @@ static void bcm2835_ic_update(BCM2835ICState *s) set =3D (s->gpu_irq_level & s->gpu_irq_enable) || (s->arm_irq_level & s->arm_irq_enable); qemu_set_irq(s->irq, set); - } =20 static void bcm2835_ic_set_gpu_irq(void *opaque, int irq, int level) @@ -59,6 +59,7 @@ static void bcm2835_ic_set_gpu_irq(void *opaque, int irq,= int level) BCM2835ICState *s =3D opaque; =20 assert(irq >=3D 0 && irq < 64); + trace_bcm2835_ic_set_gpu_irq(irq, level); s->gpu_irq_level =3D deposit64(s->gpu_irq_level, irq, 1, level !=3D 0); bcm2835_ic_update(s); } @@ -68,6 +69,7 @@ static void bcm2835_ic_set_arm_irq(void *opaque, int irq,= int level) BCM2835ICState *s =3D opaque; =20 assert(irq >=3D 0 && irq < 8); + trace_bcm2835_ic_set_cpu_irq(irq, level); s->arm_irq_level =3D deposit32(s->arm_irq_level, irq, 1, level !=3D 0); bcm2835_ic_update(s); } diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 527c3f76cae..22782b3f089 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -199,3 +199,7 @@ nvic_sysreg_write(uint64_t addr, uint32_t value, unsign= ed size) "NVIC sysreg wri heathrow_write(uint64_t addr, unsigned int n, uint64_t value) "0x%"PRIx64"= %u: 0x%"PRIx64 heathrow_read(uint64_t addr, unsigned int n, uint64_t value) "0x%"PRIx64" = %u: 0x%"PRIx64 heathrow_set_irq(int num, int level) "set_irq: num=3D0x%02x level=3D%d" + +# bcm2835_ic.c +bcm2835_ic_set_gpu_irq(int irq, int level) "GPU irq #%d level %d" +bcm2835_ic_set_cpu_irq(int irq, int level) "CPU irq #%d level %d" --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210063; cv=none; d=zohomail.com; s=zohoarc; b=laJ5qTxX6FAtpS3nwkg0mQLsd0pZoD74qjxjOzzp8/0M0Hb4PicYFsrhNS1DbnzlR0gstpiNTRM7ZIBRHUan+sbMDTwbsURC152OPiOfmwGAdnVGarIX5xgU5IG7DwH4rPiwBLXj0t+CMF9qKZcroxCGS2Qw/p1ggQYw1DZMXTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210063; h=Content-Type:Content-Transfer-Encoding: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=2iFviitDl5greJ6XddSkN6uHSPkj+fpazfKldoUVZt8=; b=Mx79wDBSaBpWR+sjq1cpOBXRAJRF4d7GnamuzE9ke9GEr+Z08+H0uvK9FYAQcdMm2Rt6cD28x8zedY78YqlKqNSelwlzR0dqOep9Vv17w6IgjvD5bC2YZdoudrKr721gpk/WMrrJAzxDGpnbqKSulFtznFwKpocD8+ah27XEYPY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210063050646.5558264916021; Tue, 20 Oct 2020 09:07:43 -0700 (PDT) Received: from localhost ([::1]:60016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuAn-0000ne-VO for importer@patchew.org; Tue, 20 Oct 2020 12:07:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0s-0004jX-De for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:26 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:37994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0q-0003tZ-Ip for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:26 -0400 Received: by mail-wr1-x434.google.com with SMTP id n18so2798417wrs.5 for ; Tue, 20 Oct 2020 08:57:24 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2iFviitDl5greJ6XddSkN6uHSPkj+fpazfKldoUVZt8=; b=kd4VcaY0DFoqvGN15E4DZTFUflmEr6vKYi124fLVdTnq9H7I4/+McAm9p7MKmyNO9B Ws4Iac3TfkpZ1PDOe2ZLw9wBayJJJK4Y8gE1d+DbF3VAFlcIpDJ8AGa/qNAY+hJtMfTF JzdBtGMQrJ10WH68DUKwCrK3UNFhZ5Mi6d/Fj4jw6GYhVZmfxMzXvEQ6Qpq42Pa7f3u2 LBatwBJXs7YJY3bqBNO4XqBMePA/JX5Cwqck3rr3S+m0tgxUfe1c72GfqkGaKxROdfSJ hzORFx3nyETdKN9I70EhUiuDOHkaKdpx7/QftKRFPj+VFTyQ1RBdXzJ3mKMk/rYEuldt 9y5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2iFviitDl5greJ6XddSkN6uHSPkj+fpazfKldoUVZt8=; b=IkDMnFxnH4reVLVEw26fZDRVWeS5YxpSlX5XtDcT7vWFhVidy7SX5a65HOAKUQqVdo cPkWQMoC8o5/laLUOi0CrAjKbDhhjbh91ySl+Mo+FmuCCsVI5oQopZZQygHJdTmkg61U zWiEgFdRbwpd3cATkLjEaL96VHcAZjRCk4Xt8IEy8GATp5KC2x7gypC+iLUScO570gkY sXNlhRaNocDDLtvkzI72/oO2K2t2Y/e0NES7C//8vH30xnrQrKkqGu3kNdL6f4085nNR fpXtusIKioNPKaKeqdjP1n8xSu8S2yITJ0qGJn2OUpRIDhJK4AuNS+vVoH+J7KBQDbBg m9Lw== X-Gm-Message-State: AOAM533f9JuJiR3ipX1Lqy8Z5Ht4qsFf7kh8wWS7Q/2BRAxBVx0fvB/y 8Lebzd8hQdoPDcdfmkQbCo68MtnhHUwZ5Q== X-Google-Smtp-Source: ABdhPJyaNyiUXbbVS8jl4Uo4DTPTgpqM5rP7hNatAxHg8K3JKp6D9bb95g4cN/7gd8vj/xU6J6Y4Ag== X-Received: by 2002:adf:ee4c:: with SMTP id w12mr4132007wro.22.1603209442814; Tue, 20 Oct 2020 08:57:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/41] hw/intc/bcm2836_control: Use IRQ definitions instead of magic numbers Date: Tue, 20 Oct 2020 16:56:29 +0100 Message-Id: <20201020155656.8045-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 The IRQ values are defined few lines earlier, use them instead of the magic numbers. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201017180731.1165871-3-f4bug@amsat.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/bcm2836_control.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/intc/bcm2836_control.c b/hw/intc/bcm2836_control.c index 53dba0080ca..2ead76ffdce 100644 --- a/hw/intc/bcm2836_control.c +++ b/hw/intc/bcm2836_control.c @@ -157,22 +157,22 @@ static void bcm2836_control_set_local_irq(void *opaqu= e, int core, int local_irq, =20 static void bcm2836_control_set_local_irq0(void *opaque, int core, int lev= el) { - bcm2836_control_set_local_irq(opaque, core, 0, level); + bcm2836_control_set_local_irq(opaque, core, IRQ_CNTPSIRQ, level); } =20 static void bcm2836_control_set_local_irq1(void *opaque, int core, int lev= el) { - bcm2836_control_set_local_irq(opaque, core, 1, level); + bcm2836_control_set_local_irq(opaque, core, IRQ_CNTPNSIRQ, level); } =20 static void bcm2836_control_set_local_irq2(void *opaque, int core, int lev= el) { - bcm2836_control_set_local_irq(opaque, core, 2, level); + bcm2836_control_set_local_irq(opaque, core, IRQ_CNTHPIRQ, level); } =20 static void bcm2836_control_set_local_irq3(void *opaque, int core, int lev= el) { - bcm2836_control_set_local_irq(opaque, core, 3, level); + bcm2836_control_set_local_irq(opaque, core, IRQ_CNTVIRQ, level); } =20 static void bcm2836_control_set_gpu_irq(void *opaque, int irq, int level) --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210209; cv=none; d=zohomail.com; s=zohoarc; b=QaRAHqkfWb3m366UgV/0TQ/RtdpBLlTeZpOQKPo4Bf6PVCigktKjMoVVHVUmNKzWczVF+4rGsxO/J51pVi2raH+9hahC+uvN8+BRyMibs7zmEdMIKkE6mvN8m8LtWG+oO3ZpkVSxs+HI4+tqhCZdMQ6EqQfkIq67Na4eO6ceF9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210209; h=Content-Type:Content-Transfer-Encoding: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=3DOt0L/FWDsEDahIMvaggmBdwk9GrrLY6As/3hpqnqg=; b=DXX4D7ps5KcfJnR4w+WqAwpBxWwU1stHhb/P/v3Lw4RnRMBepwS5Me7t+ouf/8Y0V+BGX3p3ShQRee6o5u5YmzS0FbPg6riu1oG713QJF19qJoP5BQlxU9O/Sq/ji/q0OVT5SkiJDVdWpUuSIJF41fGZFBGGKGZ2tAANoSISOO0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210209755748.8979241168217; Tue, 20 Oct 2020 09:10:09 -0700 (PDT) Received: from localhost ([::1]:40074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuDA-0004Mb-CU for importer@patchew.org; Tue, 20 Oct 2020 12:10:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0u-0004pL-Iv for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:28 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0s-0003u2-OP for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:28 -0400 Received: by mail-wm1-x342.google.com with SMTP id d3so2505672wma.4 for ; Tue, 20 Oct 2020 08:57:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3DOt0L/FWDsEDahIMvaggmBdwk9GrrLY6As/3hpqnqg=; b=nVk0pXBGBImtakvLTzo/t2hY05/ucoSTfUGEtHXF1oeyZ9bieTnk+NKyqOWpfJG4Kr 9eFZJdJoyH2UvwgiyaOrdkcrc667q1h/RANQ9vf/TxOsUpioN9J+VMH0wG2iQMjM96Pz iyV3rWjtcjlR24I0435qDUur9MCPunX51Lvgp/H1UpSCbbUKXTVnwgPz4oOps0Rr3HV9 GmCNnBsden/6ubydHF31pWMeFYTfE7u39AI0TGP3qLFlerSA46ukHGqxdIX47XVobwy9 cTgSjl1X+PwNqWTV/+w4kUsk+S3dDfdsRWXr+LYiBybGK6MOeom2H02ckxyfkkpcvRXe Tv4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3DOt0L/FWDsEDahIMvaggmBdwk9GrrLY6As/3hpqnqg=; b=e999erS4w1u6J4G+e0njK4Ucx/C8u65ONmQteYGc/bLIvtgcy2mEypY16guwZg5aDd Lw2KrbKTTgWgzPcYlhuAPjmUGXaRLz3k7nwZWUb4EMnN0vACH7ZAR5TuuMTNuu580MJg xtam10WdV+tT6nthEmUmIqsY7+9rfWONRJQHvGfIjoc2RY3fWz8PlB0MPtAq7ZPmK0VF f2BEtuhq6OUE4k9nMFIaDZX21Phw5OIPz1kP2ACdAWG8Y7rYtMXfHQwbcNVD/MnR7I0J 7z63KjLhfcB2a8Ek8l5S9g9K10ymFG6saDxCFEN2BESqrb7X6UDo8C9f5wL7pGWyiuBb hiOg== X-Gm-Message-State: AOAM532MnKFoyRwgKl8mvPJ94owSn7cjl8mge+XVrM6dM1nQarjkCYox o085HT9gXd2wmEamAJsvs8TVuvO1owf8dg== X-Google-Smtp-Source: ABdhPJzGCyh8O0+5A5R763WRXTjvCYpMaY4jMhbEls1wWIhN7g33oC2OrFr/xgpnFY+3XTShE2vIHA== X-Received: by 2002:a05:600c:210f:: with SMTP id u15mr3799312wml.53.1603209444999; Tue, 20 Oct 2020 08:57:24 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/41] target/arm: Remove redundant mmu_idx lookup Date: Tue, 20 Oct 2020 16:56:30 +0100 Message-Id: <20201020155656.8045-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson We already have the full ARMMMUIdx as computed from the function parameter. For the purpose of regime_has_2_ranges, we can ignore any difference between AccType_Normal and AccType_Unpriv, which would be the only difference between the passed mmu_idx and arm_mmu_idx_el. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Vincenzo Frascino Tested-by: Vincenzo Frascino Message-id: 20201008162155.161886-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/mte_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c index 5615c6706cb..734cc5ca675 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -563,8 +563,7 @@ static void mte_check_fail(CPUARMState *env, uint32_t d= esc, =20 case 2: /* Tag check fail causes asynchronous flag set. */ - mmu_idx =3D arm_mmu_idx_el(env, el); - if (regime_has_2_ranges(mmu_idx)) { + if (regime_has_2_ranges(arm_mmu_idx)) { select =3D extract64(dirty_ptr, 55, 1); } else { select =3D 0; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210395; cv=none; d=zohomail.com; s=zohoarc; b=dxe5Jxo1HiaxOX7JsjYwaTJ/5zXB0oGfr32vAu3XRvDWF2IIlCGcVLglhNdBdIUirSK4kua/oNk5u7pIHoyQAZONnpZFi0A0h5YPLCEhiBxBOGQPlkn7AsB2cTwC9rFjdjy+TiewWt5576U4BrnHOjObuacPKzKQ+vqQa6xi+P8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210395; h=Content-Transfer-Encoding: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=YrWpQQEYvZIHm9mkqIONBrLjRZ1+eXAY+UxoL4kTIS0=; b=kUoiiTnQWSURV9c13W/QzxMH3OXUWST2CJbp7HJz8fSVfTIyvRMJFKLU86FXzjAkg5ALKKW5Dli59LncCGJo+UKC9BD0y6DXzXgAwRMb6ReRP48yH0kj0YdUUmg7gxZUE6kZf+CJvfUn8uOqhTextjVUJAYaY6g6uPCulZkOqic= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210395425425.01713486197787; Tue, 20 Oct 2020 09:13:15 -0700 (PDT) Received: from localhost ([::1]:48282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuGA-00083Z-7c for importer@patchew.org; Tue, 20 Oct 2020 12:13:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0v-0004sR-LF for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:29 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:36400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0t-0003uF-Pw for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:29 -0400 Received: by mail-wm1-x344.google.com with SMTP id e2so2518360wme.1 for ; Tue, 20 Oct 2020 08:57:27 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YrWpQQEYvZIHm9mkqIONBrLjRZ1+eXAY+UxoL4kTIS0=; b=yAHf7kFlaxIEgwDyjWOgdm/yGabp+ZT9/9GbzRDVYx01XXC0AXwR0+865VuhP6IldK TCXCuHWqE0Dsx0zxgkaF6n6nx/l+li9utrFqkP5a3dWyTMX/1Ns8lYYMVk73qXjtg5qA +iFlG5Y9S5/Km6RkzGiqpI89UgmFgzxrGHGQscVgui6KnHIdkStBOgFx1uQn2zY7KxGS J8otvZlwKXRBcmKNJ3Wr7XsgkedcJNaqn0JHPSzkiwFHn2v6Djv9B2j5kKyneHQl552R 6/YT9N443RjT9j/nN1dUIXQKj9FwUF9wZlpNmgvB5pF5v04a+dCoWcT8gzzwpQftoJTI QO8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YrWpQQEYvZIHm9mkqIONBrLjRZ1+eXAY+UxoL4kTIS0=; b=C1GoWHXv6zg6AIdbK4v3G9etyJHBwpjIwKyTaWqgax6uDPldOzPdMr1hkitTfrWWcl ud3vzcbjaHi18gOxuqwdfQAoHjiJ0pGGp15fpRriViPLQQ3NIxmyIaQ5eiwmo80MEJnH yLZwkh/0bL4RaLKZsPw1wLXS5U4oNGbHKHnKDPtbKXR3gwEUb74/hM2fR2gb2t8eOLyx JAx09qS4DCutgt0GZXm0QbX16ueKjLBW0lAq0cL6Dbu1ZZgC2hLZBNkM4lCZrRSnm0gh 9hutQy2ap81gN+d3DL++VHy6SvOUaWxzNO+s5HBOMxe1AmwlmVMvL1GlUMwpozS49bSs YcYw== X-Gm-Message-State: AOAM533877U9x6GGnZlRsbGpKBqFeQjF1/ynM2Tveccq8xFQMR/4FB4S 48cvIFfAG0MbIkdailRmU+dcO2vQt5wiXg== X-Google-Smtp-Source: ABdhPJx+unsmbc1nmgY6rJINK0BVCSiptlORu1RNkYIwzv7ZjyPzGkjPCOqt/sXcyDRT8m0jCFX4GQ== X-Received: by 2002:a7b:c741:: with SMTP id w1mr3705675wmk.67.1603209446053; Tue, 20 Oct 2020 08:57:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/41] target/arm: Fix reported EL for mte_check_fail Date: Tue, 20 Oct 2020 16:56:31 +0100 Message-Id: <20201020155656.8045-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::344; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson The reporting in AArch64.TagCheckFail only depends on PSTATE.EL, and not the AccType of the operation. There are two guest visible problems that affect LDTR and STTR because of this: (1) Selecting TCF0 vs TCF1 to decide on reporting, (2) Report "data abort same el" not "data abort lower el". Reported-by: Vincenzo Frascino Signed-off-by: Richard Henderson Reviewed-by: Vincenzo Frascino Tested-by: Vincenzo Frascino Message-id: 20201008162155.161886-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/mte_helper.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c index 734cc5ca675..153bd1e9df8 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -525,14 +525,10 @@ static void mte_check_fail(CPUARMState *env, uint32_t= desc, reg_el =3D regime_el(env, arm_mmu_idx); sctlr =3D env->cp15.sctlr_el[reg_el]; =20 - switch (arm_mmu_idx) { - case ARMMMUIdx_E10_0: - case ARMMMUIdx_E20_0: - el =3D 0; + el =3D arm_current_el(env); + if (el =3D=3D 0) { tcf =3D extract64(sctlr, 38, 2); - break; - default: - el =3D reg_el; + } else { tcf =3D extract64(sctlr, 40, 2); } =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210800; cv=none; d=zohomail.com; s=zohoarc; b=a2uT0z/CkQsD4NSELIhQ+wRqeYNo2kt/lyl/ADFf1CaMNMEm8oEF026RTHixxCKNE5cpCg2xmVa/Thbc0yYR0/mDExiGRSnW7RqVF5vYkKglUC7XVRyqWJtea2Cga5Z4p3YvffTiUmq5BYLKsUhwHuebpCoY+e502/w5sDZXSn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210800; h=Content-Transfer-Encoding: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=FowuUdgPQYyMq4aZYTGoaCziepWA2LAbbAYSLaMy7xQ=; b=hflZE7jsSF9c8VT6ivrNh02b3whX90mOtLo3OkHHjI/cR+7ACMbNhoyQ+c1wzlbIA5YR01vY4fkKhRmh26TbEbr/BtOv9uemzzrJE8J1XpL3KBrIm9Q0oISimTKpu7KCAY4OlGfXg1XR0VMQZC3Bk7tTVYmRnbmyHOpjsg27qDw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160321080029761.12723457602624; Tue, 20 Oct 2020 09:20:00 -0700 (PDT) Received: from localhost ([::1]:43018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuMh-00018K-IK for importer@patchew.org; Tue, 20 Oct 2020 12:19:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0x-0004wX-AJ for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:31 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34145) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0v-0003ue-Fv for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:30 -0400 Received: by mail-wr1-x444.google.com with SMTP id i1so2798468wro.1 for ; Tue, 20 Oct 2020 08:57:29 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FowuUdgPQYyMq4aZYTGoaCziepWA2LAbbAYSLaMy7xQ=; b=pNpp+dS3ZiyI+fdLUaV6f3Hw6HhMIc/4VL/LNTCDCdWgemUBdBZaJnVznVNItm9zTX AjP584Lu2N89OEJD74v71dIiRLnp8AkdROjSatHiEMvs7wy5wKHHDm88F61oMCT7VZIc NI2puEatX5uJe5x9g3ClHKagqt6gDR8YsghYZxlOLUqnSjJJ99wiHrQbrfY9fUasn9oV 42bZtgmP2zc4jEcfmumTuDHw6ikJVhNssdk3oYDIbLShoyIldB5UrjcCLjOTbY+D+aN2 Gj1f3ZFcUsUZe5nnLnh3E5UoMNy80O+0R/KH5F1KsHE227uAGKgfvUkPNXXMeIlTfiaD ui9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FowuUdgPQYyMq4aZYTGoaCziepWA2LAbbAYSLaMy7xQ=; b=a6tr8Qq8i3Tfo0+6hX4J5VduZOxIyEpsWd0bAEcyptWztZOmJS48zPQr06s/RqCqHp sZOsH5pKZQX/Ef8eqajDYtX3K6kbnl9XA+GtdY2J+YoAlqPOfZBeLO5cVuFPKd6mtnYK TRgPbu1pzmy9VEnEkylLU/q/Nkj9gBlMwMk94AjSYvYTLZH0nYKFMHt3glY+pe97hMLV HyWvCtZTRE566zkTuaeCOk6Viw8d/CZSzXHhbwKjianeAuSkU4euPJbTpl28AzsoihZL gma3VVuw3+T4i/x9r1x+qhk7N0KXIuFk4qArcDuVqzi7Qr7nBG2M/01vVfoumQW0n5TL aDsw== X-Gm-Message-State: AOAM531RFELbnbl+CfAw+HrnqEOSZtgW280MuUlGwNEePn00ReK/j+/X kEKBD8/wcfd4v6lnXgpDTDDyqcf1l2aXyg== X-Google-Smtp-Source: ABdhPJwWTqz1HMYPevrosE9msjy2s0ezWFwmQ0ohm17UrD6oKnSTxhSxIkrEwZGOHwh+6oqufDoLkA== X-Received: by 2002:a05:6000:1084:: with SMTP id y4mr4074898wrw.138.1603209447264; Tue, 20 Oct 2020 08:57:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/41] target/arm: Ignore HCR_EL2.ATA when {E2H,TGE} != 11 Date: Tue, 20 Oct 2020 16:56:32 +0100 Message-Id: <20201020155656.8045-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::444; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson Unlike many other bits in HCR_EL2, the description for this bit does not contain the phrase "if ... this field behaves as 0 for all purposes other than", so do not squash the bit in arm_hcr_el2_eff. Instead, replicate the E2H+TGE test in the two places that require it. Reported-by: Vincenzo Frascino Signed-off-by: Richard Henderson Reviewed-by: Vincenzo Frascino Tested-by: Vincenzo Frascino Message-id: 20201008162155.161886-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 9 +++++---- target/arm/helper.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index ae99725d2b5..5460678756d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1252,10 +1252,11 @@ static inline bool allocation_tag_access_enabled(CP= UARMState *env, int el, && !(env->cp15.scr_el3 & SCR_ATA)) { return false; } - if (el < 2 - && arm_feature(env, ARM_FEATURE_EL2) - && !(arm_hcr_el2_eff(env) & HCR_ATA)) { - return false; + if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { + uint64_t hcr =3D arm_hcr_el2_eff(env); + if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) { + return false; + } } sctlr &=3D (el =3D=3D 0 ? SCTLR_ATA0 : SCTLR_ATA); return sctlr !=3D 0; diff --git a/target/arm/helper.c b/target/arm/helper.c index f49b045d366..97bb6b8c01b 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6906,10 +6906,11 @@ static CPAccessResult access_mte(CPUARMState *env, = const ARMCPRegInfo *ri, { int el =3D arm_current_el(env); =20 - if (el < 2 && - arm_feature(env, ARM_FEATURE_EL2) && - !(arm_hcr_el2_eff(env) & HCR_ATA)) { - return CP_ACCESS_TRAP_EL2; + if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { + uint64_t hcr =3D arm_hcr_el2_eff(env); + if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) { + return CP_ACCESS_TRAP_EL2; + } } if (el < 3 && arm_feature(env, ARM_FEATURE_EL3) && --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209917; cv=none; d=zohomail.com; s=zohoarc; b=WahdBS7FxV5SK5bz4lmdIuGAAJp7beKV7RakaUo0tK/Koel61C85K3n9ZH1KUtwtvZBjlwz66YR/2M1vKjeqMy2gxrh0bhhpETzRcx9aCQ7eW05yBxmEqQuIB3d1G9hREaMLzQe3u4+lF7gtkUz315B7ZH7zb/qZAEJmWH/gni8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209917; h=Content-Type:Content-Transfer-Encoding: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=+9ZaCuqJ8zy5+WF6Ipq45D8XTLEwaZjQqev+UaIXemI=; b=IauJpa54FrxTNWZ2MR5hdXdL1punWfM/UBHTCkJT8iWl9BrYCPzfqwJadxn0wO3jhjr55x28h3Hkh3PtZvtPhSti5S8bNG0zx+HRxPZmrzmYtFyr4d3B4Wg02Z3jjikaakUDbdqDygXhBOkisnT8NiRi0J/vLilCCQpHcrbEeck= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209917978239.55858459903914; Tue, 20 Oct 2020 09:05:17 -0700 (PDT) Received: from localhost ([::1]:52070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu8S-0005um-ST for importer@patchew.org; Tue, 20 Oct 2020 12:05:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0y-00050E-Jh for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:32 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:40611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0w-0003uu-Oj for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:32 -0400 Received: by mail-wr1-x42f.google.com with SMTP id h5so2782044wrv.7 for ; Tue, 20 Oct 2020 08:57:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+9ZaCuqJ8zy5+WF6Ipq45D8XTLEwaZjQqev+UaIXemI=; b=QZrlTwjEkBaMCIC1d/uvrI3vrqCVEHp7+92sHuyrYVaZxMTX72RivHo5WM7t9qV8hZ iUQNRR+ybj+680OQjeCcIN6Ll6Jlu6C9ZGSsnctXevi6XOpgIB4W3sefhHwyZv50/iii 3eJiArHg439X37qBet2fK9OJFjaAxaq5xmTq/DhR+c86UJtR7xashc3IvUKzuBDW3kH5 rPvgVkpekLUXB/GBI2PQfrTNjsEq8m2++I+dHu3U7Uyr6yzS4IdevlcSAB+clc+K+Dgr xuCFbNCuFjcAEf5v3IKvufxYTQ+63S2as8UF46j8l+o+036THgWaeg6tHiFqdUdByye+ f1Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+9ZaCuqJ8zy5+WF6Ipq45D8XTLEwaZjQqev+UaIXemI=; b=EbUgfN+3hDLVBrSBTrsPRUzlLGoZFzBSgYr+S4YFr2qYLL62b5hFnA4PhKWcTfDtsU 4IbqOiw0d9i2ME4LkXUvO/lwpmX4zWPHYN5mriYBc9rc0UMDAwd/yLKmL2M6uHALDSej A4zWil6Vhn+o+Sm2PyG3gN0+no+Msn0GMaBp/is+ogkBY0JGLqdJFPHiPe6jKFkKR+G/ Edzs+GhHjk2bef5eyn9v/XuJxWcrItg7v0SCSgP1zFFiX0g+EoL/M//kS18g4EwcGjwS VIfZ/noDip6MRCpl6BtWlsaBv5l1UsFD8oS63O+X+yPrXctlCB3LnWIUWGxJKEGfeq5D fIpA== X-Gm-Message-State: AOAM532XIhW5x6UZezSqrDXHe4yX4qH2J+mFNFoQTeTjKHq2R7486KD0 Gn/7fSxpdbHbWLfypajordhxzwAfEc+j7Q== X-Google-Smtp-Source: ABdhPJxq7gh9PEd6vbWOE9fr9pBr46y0RZ69WtV1ie28M7HbLr/vAH66VJGbsxNFfMR8g6HW/TdWZg== X-Received: by 2002:a5d:5604:: with SMTP id l4mr4150749wrv.140.1603209449025; Tue, 20 Oct 2020 08:57:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/41] microbit_i2c: Fix coredump when dump-vmstate Date: Tue, 20 Oct 2020 16:56:33 +0100 Message-Id: <20201020155656.8045-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+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-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Peng Liang VMStateDescription.fields should be end with VMSTATE_END_OF_LIST(). However, microbit_i2c_vmstate doesn't follow it. Let's change it. Fixes: 9d68bf564e ("arm: Stub out NRF51 TWI magnetometer/accelerometer dete= ction") Reported-by: Euler Robot Signed-off-by: Peng Liang Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201019093401.2993833-1-liangpeng10@huawei.com Signed-off-by: Peter Maydell --- hw/i2c/microbit_i2c.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i2c/microbit_i2c.c b/hw/i2c/microbit_i2c.c index 80247398208..e92f9f84ea8 100644 --- a/hw/i2c/microbit_i2c.c +++ b/hw/i2c/microbit_i2c.c @@ -83,6 +83,7 @@ static const VMStateDescription microbit_i2c_vmstate =3D { .fields =3D (VMStateField[]) { VMSTATE_UINT32_ARRAY(regs, MicrobitI2CState, MICROBIT_I2C_NREGS), VMSTATE_UINT32(read_idx, MicrobitI2CState), + VMSTATE_END_OF_LIST() }, }; =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603209953; cv=none; d=zohomail.com; s=zohoarc; b=cueXtcCho25sBOKj08k+bgxI36Exwebgh/l4gHVId7RnRYClYm7b4K9NvSNVnHzqvyUsPyc773yd/K2PILOktN9QA610Qk2crVGJD06R6PhH3qMzGApHFwREnR2bwcjhpTVK0BAPypt5m3NVjvq4R4NPw4ApuFFCIvcVMASnNkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603209953; h=Content-Type:Content-Transfer-Encoding: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=aiSyOYix0/dW9DlAA5bSO54twllkW4GLLUBLNeGd4rE=; b=oADJKDh/PMfduTQ7v2DTzHetSLMiwxcbSdsguCSIOhYMFWArzJqb7X0nLpm0l4Oa7ciPkeUgmNe0mpiFEc04CJY5u1CNJpN8fuReHIDLIxYrjpqK4NO9MGwNYrcrE/Tes9wOhxx6ZTDE4flrxOjWEgEITAAtKvVfDZ4aB3rKUa4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603209953755855.8408294725828; Tue, 20 Oct 2020 09:05:53 -0700 (PDT) Received: from localhost ([::1]:53288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUu92-0006Pd-LD for importer@patchew.org; Tue, 20 Oct 2020 12:05:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu0z-000531-S2 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:33 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:41873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0x-0003v7-Vx for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:33 -0400 Received: by mail-wr1-x441.google.com with SMTP id s9so2784557wro.8 for ; Tue, 20 Oct 2020 08:57:31 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aiSyOYix0/dW9DlAA5bSO54twllkW4GLLUBLNeGd4rE=; b=DJCOG8D4ZSoVm0+Il4H2fF01Q1mVTv3yJ+p3+ZZ7B8P7bEGR6/yrSN+FrOWtybMktD wyR8KSNUocrKJAsyGtSp6WiqOsMGuSkJteSNgSsUF3o9z/J7kqPKSQYeIBe0+jXeDNas NeGmbirh0O+/w7E7aoQLpTNmhmg4claKNU+btvuTPU1PTlPGCl78ljIgoNOv4BM9gO5e PD2OwErDHay2b4TevSVigug0dT053/BS13Sve3GNbty1ollJpYWyb6eDpCJQfengFVao WzXIC/P9vD0sN3GlZpvuCtdHe9EjyAl2rT3Ab9XQoMpTiDbtNq7ZRm9PYtjOjYcs79qp Ds9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aiSyOYix0/dW9DlAA5bSO54twllkW4GLLUBLNeGd4rE=; b=K2em0ZsDSFNfPgjNuZxlDmxsWQd4LOdrWRgWelhEBx67eltgfTf+quU0xW5Pttx/BY SCxwzFuNZKi+2pU2AuvWPY1GaNZZAcEQ8vdq8fBayKsdPBNzHVtyzYkCOdM/r8GjkUQi gZM5oVbbmGh+wUC6aOlNCUmgtE7QdOs1fNGtMm77xgLM7hsjFp33PBrKexMUUkN68r87 CJfQ8j7baMbHtvmJWJwOwLteZbXfUPvPeJp3JCgUcFn3xSqwhuMLu94anvv88zRVsrHW UmEJ0bkj7NAmM1rEsTVwTxMAJBKMfsWaWPMJcynDUSt+NU1o9FEVsj27O+flfCnzxqnD MnGQ== X-Gm-Message-State: AOAM530mYsuJCcLaWxd0fIzRI8VwOO1blA4vTheggrVHbby4poh95ljQ 9yeATAAF5jy6r6WmurTXUPvXRDzWU01jIQ== X-Google-Smtp-Source: ABdhPJwSzW1/2eeEi5M8EVdp8mEPPOR76+A+exOzW4lI7b6YmxoKdqyx6QGeC9rTFSA0Sxmnk6vuZg== X-Received: by 2002:adf:fc51:: with SMTP id e17mr4133922wrs.45.1603209450410; Tue, 20 Oct 2020 08:57:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/41] hw/arm/nseries: Fix loading kernel image on n8x0 machines Date: Tue, 20 Oct 2020 16:56:34 +0100 Message-Id: <20201020155656.8045-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 Commit 7998beb9c2e removed the ram_size initialization in the arm_boot_info structure, however it is used by arm_load_kernel(). Initialize the field to fix: $ qemu-system-arm -M n800 -append 'console=3DttyS1' \ -kernel meego-arm-n8x0-1.0.80.20100712.1431-vmlinuz-2.6.35~rc4-129.1-n8= x0 qemu-system-arm: kernel 'meego-arm-n8x0-1.0.80.20100712.1431-vmlinuz-2.6.= 35~rc4-129.1-n8x0' is too large to fit in RAM (kernel size 1964608, RAM siz= e 0) Noticed while running the test introduced in commit 050a82f0c5b ("tests/acceptance: Add a test for the N800 and N810 arm machines"). Fixes: 7998beb9c2e ("arm/nseries: use memdev for RAM") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Tested-by: Thomas Huth Message-id: 20201019095148.1602119-1-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/arm/nseries.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index e48092ca047..76fd7fe9854 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -1318,6 +1318,7 @@ static void n8x0_init(MachineState *machine, g_free(sz); exit(EXIT_FAILURE); } + binfo->ram_size =3D machine->ram_size; =20 memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, machine->ram); --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210531; cv=none; d=zohomail.com; s=zohoarc; b=bcnqjMN8zAwWXxZh1FNondZlwUmE/vMIESKswqA2xltzQMMNYp7hYJctpadMME5nA6VmT7Ms7R3sG5zvWFyZegk98dhbn+HjvUwvgq9vM7eHEN4GtYagc//wd4bMlqrbs4OZOUcNXoINL9s2UuaHqDLU+qI3dul5/QOW6qmxPH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210531; h=Content-Transfer-Encoding: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=j7iHUHHmz4RqWM4N7aL1RyNr3+GkDqXbbSx38e4eHPk=; b=hobGb8dwK/ylQHV++mKBakhEXae7O0REPv2yYqWoKEPaSgCz7cVbSODdXfbyouV34aJS912MhlPcSU/jY8gEIw4NLPjgF3bUANCqFFD31IH72W5KP19T4/OVWrPQCz46lIIEqzjZk0ouYNk3XAcHmRmr7xxFuOqFfw2VztL6d20= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16032105313001011.859273585995; Tue, 20 Oct 2020 09:15:31 -0700 (PDT) Received: from localhost ([::1]:56380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuIM-00030E-6D for importer@patchew.org; Tue, 20 Oct 2020 12:15:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu10-00055k-UQ for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:34 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:33401) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu0z-0003vG-66 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:34 -0400 Received: by mail-wm1-x32a.google.com with SMTP id z22so1452718wmi.0 for ; Tue, 20 Oct 2020 08:57:32 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=j7iHUHHmz4RqWM4N7aL1RyNr3+GkDqXbbSx38e4eHPk=; b=FDFhhZi552G8FOW7VGye7skGMFplaIeIkGpSIrjLAipuhcxJ2LiDWQT5GLPk2alpG8 VvidlP6SyB9WeqEX4oBPv7/dra1j/QwbpqVrzMvMV6yH82RytcAAQjgvUK7VDlTIZbj9 OV4HUl8iyb8Zm9Ka4J1r/1D+Y1XAASGhomqH58gPi1dUhcUr1UQiP7LmbrwASQW69Ndh pUfGSO/+e/jTjsztyMCOlz/LVApttd+/vO/cgs6bf8xuJ+9LxexnaXgwWbzEpt2HoxF6 Ai3KCrNtXv0qpvPmuSdhtA6Qd8wxjMmde/x/BTZzDVeapzkBIxREAFDYdrCEhU32xHat 0sig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j7iHUHHmz4RqWM4N7aL1RyNr3+GkDqXbbSx38e4eHPk=; b=kaXNz4ZtdhrdbggYxw2XLeL2WzPjXB2qowuQyCRYSsvJNrGK7C0DUULbgGTawOFBlh wl3raSIrbYwJRcEMsHguy7bH0RWaPPHy9MzAEsoBtrkgEmpTxSUWDuBolOjE2wXegERx walo8I8lRkyB6GzkYxJQ1f7Q8+z1ZtiFxutw+TSVsqP/uOSNxfd0I9otpq7Zg+Xc58JS rSPV8lLWE9/nMadGOkKEUgBHGpk2yufy5xo3Nbk1AYJu8kz6vAirMiy53HJRFQPoqa3G 9psVS9c+1xfGq9PELHKe3temiRrzJAFFEdHanXg+ph3bqw2tcGjEj2FdWhVobP0/dQYl +tgQ== X-Gm-Message-State: AOAM532AunQ8bdPcFm35ui89FXK1BCMXesWnhJYzc5JIfjB9D4FfFo7I u46TTH4a8FMHDV7ayZU0YWzUG7hEUMXJ/A== X-Google-Smtp-Source: ABdhPJw69PPnfpgH/b51BCXEhsOGBDodEkHEcE/DCRJul8Hekp64jpPLuAuLl+XedIcARyxoXmXAbQ== X-Received: by 2002:a1c:2b05:: with SMTP id r5mr3592839wmr.179.1603209451522; Tue, 20 Oct 2020 08:57:31 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/41] decodetree: Fix codegen for non-overlapping group inside overlapping group Date: Tue, 20 Oct 2020 16:56:35 +0100 Message-Id: <20201020155656.8045-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" For nested groups like: { [ pattern 1 pattern 2 ] pattern 3 } the intended behaviour is that patterns 1 and 2 must not overlap with each other; if the insn matches neither then we fall through to pattern 3 as the next thing in the outer overlapping group. Currently we generate incorrect code for this situation, because in the code path for a failed match inside the inner non-overlapping group we generate a "return" statement, which causes decode to stop entirely rather than continuing to the next thing in the outer group. Generate a "break" instead, so that decode flow behaves as required for this nested group case. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20201019151301.2046-2-peter.maydell@linaro.org --- scripts/decodetree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 60fd3b5e5f6..c1bf3cfa85f 100644 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -548,7 +548,7 @@ class Tree: output(ind, ' /* ', str_match_bits(innerbits, innermask), ' */\n') s.output_code(i + 4, extracted, innerbits, innermask) - output(ind, ' return false;\n') + output(ind, ' break;\n') output(ind, '}\n') # end Tree =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210950; cv=none; d=zohomail.com; s=zohoarc; b=GPNTbSqfDDdQ+WxXibYRLgTJo+M/abqBmYSpD/0htmtaeKYFG56lt3pYMFR2z+QmAA6liX2kpNNXUZJDKx0ep440KIangMAsm3x6ZILvM1CRZBzNf9B4zGjfJg1qBQeWA6CfkPrare5rOE4ZE9JSOTgVHjvOYRwBScnssJYW9vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210950; h=Content-Transfer-Encoding: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=sIAi5r7A9lqSQC4Z5WHs2lvugjZeX45vrZcdLwzrlnk=; b=XIaMGxvZRJGclvuvEs8m+FQKRhgAJ6a21PCWc7r6LMOeb/59rCoMqxsZ7fwvVCyTpvOutpP8LESX1O481wHICj534SBPK5ByZXC+p92FRpJFqTBb9N+3+kijFlsZCNQV7r4udR80b4tL2JaFJ+0oTMKN0caSekTSc1X7dC+4JSo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210950354528.2838780431355; Tue, 20 Oct 2020 09:22:30 -0700 (PDT) Received: from localhost ([::1]:51812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuP6-0004td-V7 for importer@patchew.org; Tue, 20 Oct 2020 12:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu12-00059S-Cp for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:36 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:55009) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu10-0003vY-D0 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:36 -0400 Received: by mail-wm1-x331.google.com with SMTP id c77so2329390wmd.4 for ; Tue, 20 Oct 2020 08:57:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sIAi5r7A9lqSQC4Z5WHs2lvugjZeX45vrZcdLwzrlnk=; b=excKchh7CPnHdIPj9hzWnwWz8PRaL4flMaXnu4z24a3JKLQUeoRsnXV515y4NcDhBT +0Z6nMqQYD1boT04o2n39/ho6ha5H4C/zCj4o1kp0t1xldPdmqPBFYhIpJYqCQ9m5JS3 FzbJGdgFctAoEBT1hLq3Jb1zypRiW5KfWQU8rJoRWjVt4k1fdq7q1MIw1HblUj4GqQZl m2nAryils9q0SzdvEcRrSo9LZ02eKOJZ8QX4MdULBSYSw1jn0H+sfT6frjdqStIFNv57 kfgTVlOvZZdrFPaCVVA36HqQm0WUNQTbPMWLv8oWEk9D/AhxnP2v7gRTUb1lX9wDJBaZ hczw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sIAi5r7A9lqSQC4Z5WHs2lvugjZeX45vrZcdLwzrlnk=; b=NaKfDFuN6r3vAmmxYUV0bU/Kn/YBkDZWCTj2L2vAHtCb0GlnkV6Lfjte+AYsqp+TRK Xf0Ajs3bGMgizwwcm2oFkAro+EiC9nPIkQtwRRTz18dsH/xsvPSiitHI4Et7oYGB3D4p KGItvp6xM3aJE/uNIIIOaZX3kkAsCYf1UGOkRvQ3h6MO91fug2qG5tKqB8aiQD+5Fh+i mABrWSM8YrTPIfTaw+xsw7gbtS/KkVPNrCANPqpAjHI/Sc2BMr7CUpVej3zUAMclnShi 1P5SXopuvwXae/vPRMieGY7DTunQUxg2HvcDAMcpsc5bUUIIG9byeKafIDk896qzrTQT vvJA== X-Gm-Message-State: AOAM5316lIF0HZCAHXEm9NxwOSzaBOO0PPc6oW5r77ebP/9xvMuR5OtZ GUigp35Rank0hmrvYjVPaCiLMe3HLr+t8A== X-Google-Smtp-Source: ABdhPJw1YzsI7jVeutPfoXD7xhLyaqvtYUCMbKG4ndzdFUsnaVqqG71hO0+xjTsGoooQoXvxvqintw== X-Received: by 2002:a1c:6807:: with SMTP id d7mr3515076wmc.38.1603209452643; Tue, 20 Oct 2020 08:57:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/41] target/arm: Implement v8.1M NOCP handling Date: Tue, 20 Oct 2020 16:56:36 +0100 Message-Id: <20201020155656.8045-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From v8.1M, disabled-coprocessor handling changes slightly: * coprocessors 8, 9, 14 and 15 are also governed by the cp10 enable bit, like cp11 * an extra range of instruction patterns is considered to be inside the coprocessor space We previously marked these up with TODO comments; implement the correct behaviour. Unfortunately there is no ID register field which indicates this behaviour. We could in theory test an unrelated ID register which indicates guaranteed-to-be-in-v8.1M behaviour like ID_ISAR0.CmpBranch >=3D 3 (low-overhead-loops), but it seems better to simply define a new ARM_FEATURE_V8_1M feature flag and use it for this and other new-in-v8.1M behaviour that isn't identifiable from the ID registers. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201019151301.2046-3-peter.maydell@linaro.org --- target/arm/cpu.h | 1 + target/arm/m-nocp.decode | 10 ++++++---- target/arm/translate-vfp.c.inc | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index cfff1b5c8fe..74392fa0295 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1985,6 +1985,7 @@ enum arm_features { ARM_FEATURE_VBAR, /* has cp15 VBAR */ ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ ARM_FEATURE_M_MAIN, /* M profile Main Extension */ + ARM_FEATURE_V8_1M, /* M profile extras only in v8.1M and later */ }; =20 static inline int arm_feature(CPUARMState *env, int feature) diff --git a/target/arm/m-nocp.decode b/target/arm/m-nocp.decode index 7182d7d1217..28c8ac6b94c 100644 --- a/target/arm/m-nocp.decode +++ b/target/arm/m-nocp.decode @@ -29,14 +29,16 @@ # If the coprocessor is not present or disabled then we will generate # the NOCP exception; otherwise we let the insn through to the main decode. =20 +&nocp cp + { # Special cases which do not take an early NOCP: VLLDM and VLSTM VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 0000 0000 # TODO: VSCCLRM (new in v8.1M) is similar: #VSCCLRM 1110 1100 1-01 1111 ---- 1011 ---- ---0 =20 - NOCP 111- 1110 ---- ---- ---- cp:4 ---- ---- - NOCP 111- 110- ---- ---- ---- cp:4 ---- ---- - # TODO: From v8.1M onwards we will also want this range to NOCP - #NOCP_8_1 111- 1111 ---- ---- ---- ---- ---- ---- cp=3D10 + NOCP 111- 1110 ---- ---- ---- cp:4 ---- ---- &nocp + NOCP 111- 110- ---- ---- ---- cp:4 ---- ---- &nocp + # From v8.1M onwards this range will also NOCP: + NOCP_8_1 111- 1111 ---- ---- ---- ---- ---- ---- &nocp cp=3D10 } diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc index 9b11b81f80d..a7ed9bc81b9 100644 --- a/target/arm/translate-vfp.c.inc +++ b/target/arm/translate-vfp.c.inc @@ -3459,7 +3459,7 @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VL= LDM_VLSTM *a) return true; } =20 -static bool trans_NOCP(DisasContext *s, arg_NOCP *a) +static bool trans_NOCP(DisasContext *s, arg_nocp *a) { /* * Handle M-profile early check for disabled coprocessor: @@ -3472,7 +3472,11 @@ static bool trans_NOCP(DisasContext *s, arg_NOCP *a) if (a->cp =3D=3D 11) { a->cp =3D 10; } - /* TODO: in v8.1M cp 8, 9, 14, 15 also are governed by the cp10 enable= */ + if (arm_dc_feature(s, ARM_FEATURE_V8_1M) && + (a->cp =3D=3D 8 || a->cp =3D=3D 9 || a->cp =3D=3D 14 || a->cp =3D= =3D 15)) { + /* in v8.1M cp 8, 9, 14, 15 also are governed by the cp10 enable */ + a->cp =3D 10; + } =20 if (a->cp !=3D 10) { gen_exception_insn(s, s->pc_curr, EXCP_NOCP, @@ -3489,6 +3493,15 @@ static bool trans_NOCP(DisasContext *s, arg_NOCP *a) return false; } =20 +static bool trans_NOCP_8_1(DisasContext *s, arg_nocp *a) +{ + /* This range needs a coprocessor check for v8.1M and later only */ + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { + return false; + } + return trans_NOCP(s, a); +} + static bool trans_VINS(DisasContext *s, arg_VINS *a) { TCGv_i32 rd, rm; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603211051; cv=none; d=zohomail.com; s=zohoarc; b=LXVYU8OxkpbJldy6b+wBxWfgXLYfjkwc1evy+i3UUKgYdywuOESoEkuiTUuIntjQXy2U1QalPUjpW/rxFphD8R16r7cpk/0PtdNpeRYrCUZ/No8MyHqdTTx8IkGGww+MNwqddVYnfER0sA4aqaudyi5uda4S76iiod4YNGp+dVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603211051; h=Content-Transfer-Encoding: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=8KRcR896eTNIkcAGmEKMZi3H1fH2UuiC+mfMQfLP/y4=; b=ZSVKJIueGLjLTdMuEGmzg4zfJDptP+zJuIo2iSaDCuQ7t77Jrp4T14V/SrnQpuaMpNQ4r48cxyqdzdybdVehGH9Evr3SwyJCAXZAqBF5I6LqGTNXhHPR+PBaV3Hpaor9UpxALBQY3LpOFx+axtjuYYLHYHExDqwL3h5bztVd1Io= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603211051527321.9958236285361; Tue, 20 Oct 2020 09:24:11 -0700 (PDT) Received: from localhost ([::1]:60242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuQk-0008PG-PQ for importer@patchew.org; Tue, 20 Oct 2020 12:24:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu13-0005CQ-GJ for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:37 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:55012) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu11-0003vi-J1 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:37 -0400 Received: by mail-wm1-x334.google.com with SMTP id c77so2329457wmd.4 for ; Tue, 20 Oct 2020 08:57:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8KRcR896eTNIkcAGmEKMZi3H1fH2UuiC+mfMQfLP/y4=; b=csfqae+4soZWwe2Qt9jYbebR9/DLwOXST/hzsr5BHWWsfDxvIdaGtaiTSSU1wbr6M5 Ew0jANFUT0V4XzCjXhcegnPWj/lTjN7Mf3pPHxNOaVf8OZTJi3iGAcmThkEuDXFe4Bzb JMdI4NkddRGVrpnPAFQoqvPAnsIci3iJ71ceOwvHRl1EqGuygmcLKc3Wv8oQCWX0oPS9 wQRRtYGAZdwRpDd2RLAFZOgt7GfpjGIoYwC1exFshigrXAQwcAMVq3t5vFX2kD+4n6qo rkhEpoVo4uv+Pl0lqPrCRemfUpFFykGZPZZBp2gX57Qu+5cwoRwjXB1SEIAAV4y8xg9l 8dQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8KRcR896eTNIkcAGmEKMZi3H1fH2UuiC+mfMQfLP/y4=; b=JCGcsUYTbP8dU/WY0435yJbPGJ4ER8eIeeDc7tDHORdAA4XcRJeJboEukGiWMbAN4W Z0bFrXhMmnqk4Ru/nOVPxCnXKLcEknh5cyeCkU4L2lBJTjFVj9dBOpETfM7Nb+H2EYsh 4n78Eb6k6Nva+f0YYXffFG0gIYIHpiNcZlIAxsTXyrEdqIw5CdfsUUDygWG2iCbFtW3h f2gBzC9N72rhcLus7uEc4xm6U3kN0xUaI/WrpQPMhbTYWu1g9BUycL3SDWjrQR5mf0LN o74lGlTV+w2EGa2eZxwFOYNZiXN4y6h9txdVPYG2F3t589LOgNqLZlwZGz1SJi1BS+GA bExw== X-Gm-Message-State: AOAM531EtbxU8BXzlo/cxaVN/NBhsuyVmo8TOBvkzHJjgDPe2+K2ZFzf f9V3wDwk/3OlMvjFS3PLdgDcr9fNIFtWBA== X-Google-Smtp-Source: ABdhPJyllytvVLzUxYolgxYCwnWhCawhs+fGmLSCz5GZ+28cIjGDybUAsUnTwZffjbyPTPfwDYTjag== X-Received: by 2002:a7b:c345:: with SMTP id l5mr3586958wmj.123.1603209453793; Tue, 20 Oct 2020 08:57:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/41] target/arm: Implement v8.1M conditional-select insns Date: Tue, 20 Oct 2020 16:56:37 +0100 Message-Id: <20201020155656.8045-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" v8.1M brings four new insns to M-profile: * CSEL : Rd =3D cond ? Rn : Rm * CSINC : Rd =3D cond ? Rn : Rm+1 * CSINV : Rd =3D cond ? Rn : ~Rm * CSNEG : Rd =3D cond ? Rn : -Rm Implement these. Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20201019151301.2046-4-peter.maydell@linaro.org --- target/arm/t32.decode | 3 +++ target/arm/translate.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 7069d821fde..d8454bd814e 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -90,6 +90,9 @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... ....= @s_rrr_shi } RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi =20 +# v8.1M CSEL and friends +CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 + # Data-processing (register-shifted register) =20 MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \ diff --git a/target/arm/translate.c b/target/arm/translate.c index d8729e42c48..9f2201ca577 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8262,6 +8262,66 @@ static bool trans_IT(DisasContext *s, arg_IT *a) return true; } =20 +/* v8.1M CSEL/CSINC/CSNEG/CSINV */ +static bool trans_CSEL(DisasContext *s, arg_CSEL *a) +{ + TCGv_i32 rn, rm, zero; + DisasCompare c; + + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { + return false; + } + + if (a->rm =3D=3D 13) { + /* SEE "Related encodings" (MVE shifts) */ + return false; + } + + if (a->rd =3D=3D 13 || a->rd =3D=3D 15 || a->rn =3D=3D 13 || a->fcond = >=3D 14) { + /* CONSTRAINED UNPREDICTABLE: we choose to UNDEF */ + return false; + } + + /* In this insn input reg fields of 0b1111 mean "zero", not "PC" */ + if (a->rn =3D=3D 15) { + rn =3D tcg_const_i32(0); + } else { + rn =3D load_reg(s, a->rn); + } + if (a->rm =3D=3D 15) { + rm =3D tcg_const_i32(0); + } else { + rm =3D load_reg(s, a->rm); + } + + switch (a->op) { + case 0: /* CSEL */ + break; + case 1: /* CSINC */ + tcg_gen_addi_i32(rm, rm, 1); + break; + case 2: /* CSINV */ + tcg_gen_not_i32(rm, rm); + break; + case 3: /* CSNEG */ + tcg_gen_neg_i32(rm, rm); + break; + default: + g_assert_not_reached(); + } + + arm_test_cc(&c, a->fcond); + zero =3D tcg_const_i32(0); + tcg_gen_movcond_i32(c.cond, rn, c.value, zero, rn, rm); + arm_free_cc(&c); + tcg_temp_free_i32(zero); + + store_reg(s, a->rd, rn); + tcg_temp_free_i32(rm); + + return true; +} + /* * Legacy decoder. */ --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603211221; cv=none; d=zohomail.com; s=zohoarc; b=G87BY7d8f/m+vzvhseSgdLb/Ow3PCQ/eKydWXjddi5G3XxCJJNp3yIwuVm9RSEljBOTrh7iQ0WVg4XiOFIhQSLTsGsjdF2N7+alj5Z48OAAcjQmROAJontnSLO4Q2/39yxVp+M36q8zLBvMwvtDJ9+P65ZsdNVPQ9AI5x8+1d3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603211221; h=Content-Transfer-Encoding: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=452WvsOKSS6Cw7iRBfcJym1U9FO5tRal3JTyFbLON80=; b=IQ8YKLVStxm7GYUcgDyXCvV0XUBKH0RnBISB89MSsG5HRKKIg8xSlR1kKzMOiJjsvxVbiOoKu266JLaN1+CUFoY40I0cviGm8+qZUDB6v2/7SJvd3i415aBmbISzwPUg/ZfvuLiKl3pmMdeuYNVQ/V9mBShzVTpIqNu3ZViA2jY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160321122124325.577120154816953; Tue, 20 Oct 2020 09:27:01 -0700 (PDT) Received: from localhost ([::1]:38778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuTU-00038o-EU for importer@patchew.org; Tue, 20 Oct 2020 12:27:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu14-0005F6-MX for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:38 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:50247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu12-0003vt-SQ for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:38 -0400 Received: by mail-wm1-x334.google.com with SMTP id 13so2340069wmf.0 for ; Tue, 20 Oct 2020 08:57:36 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=452WvsOKSS6Cw7iRBfcJym1U9FO5tRal3JTyFbLON80=; b=t8C/dkCsqvyPn7dIL5MQ1+ppkufVbVX31PaNafhpFmVBC8FN2w+0XCGC/5v45J2kAe kQu3TrqlN1x8nyoduLBvZ7HJUyekjKqjoE+cQrvKa44lADmagVmha9I1cf386gJvKwcn NiMF8LiQiX7ke9DpL7b3nTi5+79TfKpx7aC4NcKTBwSqzIuL23mYiFlJZPm7cdB8tdn4 L3MdV1O48E7ScmBGrqbeXGy1TRzOFhMa5iBXdJiA2fGqJTG/ogBoMlp+nF6r0t+iALQU /Q3hy2YhjUmf62WVtSZhelM69T0LK4Tn2lv2pQ1ToeG+FKm4zjLeQwxHfRsc8Cr2+njq vvhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=452WvsOKSS6Cw7iRBfcJym1U9FO5tRal3JTyFbLON80=; b=MjruZ9x2iNaLAq1sXVZMrpN9BvDtecjLSmxTFcQmdmaDmzNdFp7lqMEHnSZS5UyY9n dVBqBS5RnIqwL6pA5s9k3UWvswURw3wXXcu+eEMWddlimdnviww2P0cB1pxFe0UZWEuA atXFySdjmRbg9smETta7IDQKb1uQjSnq1fnkOgDSYyse+NWRF9g1se3CzTEtSj7WclOD qxJ14ndBk8R59NjW1nE+kcHLWY3VxZv1bPf7MHoEbAFfK/nSF5Vb+tSLfhpj0/ixNO+w PJvmPPAbsjjca5tiYjVjhMleATXS7zzuTHD99Ths/ij20/KvdxQt9lx8P8mgGxLsk9bP s8kA== X-Gm-Message-State: AOAM532uB6LAZIeti4rlEZsFKo2+9X49OlELYZ+mRdGHoA2WVSGhG7yO FrLNIQ/VD5QCgcqt41n+yEuD4Mt8YwJ+YA== X-Google-Smtp-Source: ABdhPJxqfsqKu4dgXXRcUtaqhSzCTKGcflmewb1l12iRqK/YK6gXZXcyvF5+nsBM4KiWNosWH7GWHA== X-Received: by 2002:a1c:8093:: with SMTP id b141mr3613022wmd.139.1603209455054; Tue, 20 Oct 2020 08:57:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/41] target/arm: Make the t32 insn[25:23]=111 group non-overlapping Date: Tue, 20 Oct 2020 16:56:38 +0100 Message-Id: <20201020155656.8045-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The t32 decode has a group which represents a set of insns which overlap with B_cond_thumb because they have [25:23]=3D111 (which is an invalid condition code field for the branch insn). This group is currently defined using the {} overlap-OK syntax, but it is almost entirely non-overlapping patterns. Switch it over to use a non-overlapping group. For this to be valid syntactically, CPS must move into the same overlapping-group as the hint insns (CPS vs hints was the only actual use of the overlap facility for the group). The non-overlapping subgroup for CLREX/DSB/DMB/ISB/SB is no longer necessary and so we can remove it (promoting those insns to be members of the parent group). Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20201019151301.2046-5-peter.maydell@linaro.org --- target/arm/t32.decode | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/target/arm/t32.decode b/target/arm/t32.decode index d8454bd814e..7d5e000e82c 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -296,8 +296,8 @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 ...= . @rdm { # Group insn[25:23] =3D 111, which is cond=3D111x for the branch below, # or unconditional, which would be illegal for the branch. - { - # Hints + [ + # Hints, and CPS { YIELD 1111 0011 1010 1111 1000 0000 0000 0001 WFE 1111 0011 1010 1111 1000 0000 0000 0010 @@ -310,20 +310,18 @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .= ... @rdm # The canonical nop ends in 0000 0000, but the whole rest # of the space is "reserved hint, behaves as nop". NOP 1111 0011 1010 1111 1000 0000 ---- ---- + + # If imod =3D=3D '00' && M =3D=3D '0' then SEE "Hint instructions", = above. + CPS 1111 0011 1010 1111 1000 0 imod:2 M:1 A:1 I:1 F:1 mode:5 \ + &cps } =20 - # If imod =3D=3D '00' && M =3D=3D '0' then SEE "Hint instructions", ab= ove. - CPS 1111 0011 1010 1111 1000 0 imod:2 M:1 A:1 I:1 F:1 mode:5 \ - &cps - # Miscellaneous control - [ - CLREX 1111 0011 1011 1111 1000 1111 0010 1111 - DSB 1111 0011 1011 1111 1000 1111 0100 ---- - DMB 1111 0011 1011 1111 1000 1111 0101 ---- - ISB 1111 0011 1011 1111 1000 1111 0110 ---- - SB 1111 0011 1011 1111 1000 1111 0111 0000 - ] + CLREX 1111 0011 1011 1111 1000 1111 0010 1111 + DSB 1111 0011 1011 1111 1000 1111 0100 ---- + DMB 1111 0011 1011 1111 1000 1111 0101 ---- + ISB 1111 0011 1011 1111 1000 1111 0110 ---- + SB 1111 0011 1011 1111 1000 1111 0111 0000 =20 # Note that the v7m insn overlaps both the normal and banked insn. { @@ -351,7 +349,7 @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 ...= . @rdm HVC 1111 0111 1110 .... 1000 .... .... .... \ &i imm=3D%imm16_16_0 UDF 1111 0111 1111 ---- 1010 ---- ---- ---- - } + ] B_cond_thumb 1111 0. cond:4 ...... 10.0 ............ &ci imm=3D%i= mm21 } =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210072; cv=none; d=zohomail.com; s=zohoarc; b=d17faI32gqxpvhq3vmHeAB0UNWKcAhv+j03FzxjKxpmSR1EaBqU9+srC1DrOCssIwTBDTXt/vfOsGMQwxD31wCejiAmWTtvKKmbiPIzhqxCFoN4Dl4h4Meqkovb1psM13+4UNO+3q4hz+tbdDWYHN//8Jnoo372RjapeZ3UXSkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210072; h=Content-Transfer-Encoding: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=1TAKmnrXBfL6eR3DBczCUzOiCIS8y/1ety/iZUsCGWo=; b=DVo990sRX/yc3wiZ4nqSdxNnarQqjlNUqiGHMALw65MAgVRekyR7g64M1yV9RSq5koDskBX3hp2vnE4QyMn4kqgIyOgfk8UrLLmGA48H7tAuBt7a+z7SH0aTOUkBvsnc1d1Xf19d3MJOIPpmUIwjE4oySXKZQjiu/+8ZDLPq5a8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210072035636.6182816806062; Tue, 20 Oct 2020 09:07:52 -0700 (PDT) Received: from localhost ([::1]:60508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuAw-0000zw-Tx for importer@patchew.org; Tue, 20 Oct 2020 12:07:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu15-0005Hm-O1 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:39 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:35868) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu14-0003w6-1I for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:39 -0400 Received: by mail-wm1-x329.google.com with SMTP id e2so2519114wme.1 for ; Tue, 20 Oct 2020 08:57:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1TAKmnrXBfL6eR3DBczCUzOiCIS8y/1ety/iZUsCGWo=; b=zyunfGmtNVncBEf5Ay26fz6kmDe8+2y54N+7Te8xyjAEL/4mySA6rfhOaeouHKj96h TQnT5SLhxbfNDkEqooV/RGvMUGOoR5ND6Wwc39kqW54z1vDtpkIv1+tGJ1FxeYuH+zNO sX2fH6LD6We2gIIbp54wcHrMiSJ6Auc3p4fWhsVei1Pjq9k6FFFssDLGCVUbwLKBxQGe L3sak0MaU68dS+Ye3Y0St+grK20/Q0KC5TS2/3WtRX++Yjkfag6tS81s06fDRRbtXqOM Xv9p7OAWzp2SKnLyFxZoFbUj/ZsMT0tEiMZgFMZ2DczO7KDgp1kvdEKZCfEzHE70cLpT 1D/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1TAKmnrXBfL6eR3DBczCUzOiCIS8y/1ety/iZUsCGWo=; b=M22bPef0idxIKqdT7WWx28VVL2nCdUYhPcuXIW45/igdi/evX0HwdWebaNGNiD9Rr7 7U1vtg/imNc8ED2SkExQ3GC50u3FdTD4P+61GeNgnp9wEbNArMjwnLhyZgeVJu/PFM7g WF3jHbaH7IA02ck+slEFz8MfN+44rT0L03tkeT3QN+ej5Y8jS0oyKJvXiJoKRUWTGQ+k mftiuHqeCJ87IB3ytS8NGeac8yBKul8Kk8oYgcbtfNywq+wKAum9x6IxAjK828LHMDOF zPYmIRqIMLCMGlqkebt6w5jvyIqgUoyQcv52PHig8zZRiPCewM8eYTOiEanxxV+Mglqu UMuQ== X-Gm-Message-State: AOAM533sPXsZDR0k6lP45/xcmusdQLA3mphORMElcvfPLRAVXZC/3c3m Fa7NWZ+a9ukr+VUy0okbqWiCCOWyzeOSfQ== X-Google-Smtp-Source: ABdhPJxDYBb9c5svNh/4mW31Tb8OxvkbB05ZzqVYUrOSGXyDRFD6f8XcA0BxLGnzUiFNIzxeZoO/9Q== X-Received: by 2002:a1c:e403:: with SMTP id b3mr2884543wmh.79.1603209456318; Tue, 20 Oct 2020 08:57:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/41] target/arm: Don't allow BLX imm for M-profile Date: Tue, 20 Oct 2020 16:56:39 +0100 Message-Id: <20201020155656.8045-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" The BLX immediate insn in the Thumb encoding always performs a switch from Thumb to Arm state. This would be totally useless in M-profile which has no Arm decoder, and so the instruction does not exist at all there. Make the encoding UNDEF for M-profile. (This part of the encoding space is used for the branch-future and low-overhead-loop insns in v8.1M.) Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20201019151301.2046-6-peter.maydell@linaro.org --- target/arm/translate.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/arm/translate.c b/target/arm/translate.c index 9f2201ca577..dc3a4031db7 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -7918,6 +7918,14 @@ static bool trans_BLX_i(DisasContext *s, arg_BLX_i *= a) { TCGv_i32 tmp; =20 + /* + * BLX would be useless on M-profile; the encoding space + * is used for other insns from v8.1M onward, and UNDEFs before that. + */ + if (arm_dc_feature(s, ARM_FEATURE_M)) { + return false; + } + /* For A32, ARM_FEATURE_V5 is checked near the start of the uncond blo= ck. */ if (s->thumb && (a->imm & 2)) { return false; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210232; cv=none; d=zohomail.com; s=zohoarc; b=c3ntiU+pP36T11DjT/oGcTmlRAIhih+qxqOWo7kAEkIPzPg9GONBa65PLKz4sXqNGgJgaOlCREDNzWTNoLzr9RNejWpMSPVr5tZxGeaH/cM1Aa2H06ebJIRNpss1penezwmVrtbprqAyRjM5C85puMwxDXchLzVSTCifOQn0kO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210232; h=Content-Transfer-Encoding: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=HYBBDc+WV+vlafN0QjaHU6ktbJtXUHBdXwQ70Lil4Sw=; b=UAjF8kRYMRzdqieGZt3jhw7BvcDLh7XQNbEfiFyX1cMzd3OS9VAD7ZhwI6rzRKlw0TdlMleVGApSqUQmiImRVpELMdf7Uue0erFueSQxs1gPodmhsA419d/YBnRxqGliP/LIfBYtC/Aa0bumTKTMAtf4JUHgZpT2l9aSMJg9LTk= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160321023241397.3535972180299; Tue, 20 Oct 2020 09:10:32 -0700 (PDT) Received: from localhost ([::1]:40552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuDX-0004ZB-Dd for importer@patchew.org; Tue, 20 Oct 2020 12:10:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu17-0005Ll-C8 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:41 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:43606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu15-0003wL-BN for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:40 -0400 Received: by mail-wr1-x435.google.com with SMTP id g12so2785623wrp.10 for ; Tue, 20 Oct 2020 08:57:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HYBBDc+WV+vlafN0QjaHU6ktbJtXUHBdXwQ70Lil4Sw=; b=zSB/BVlD9bCmP/hB44yakp2DAAByNFxjKFSwbGF5P6ha/ipv/FDt3yCyA+yo4L1462 rhYbkwAvDRIF/a+reQv0SP6oqLSEHpXhBx9FuPP7OHIv16AtFcIgtqdt4lQjGZinqtSg oaLDjoGEY7ZkEWulRxeu7CcNezaTn7xOUKb3IjHHrv/jA61B5vD/H2J5yDKS98HXbH+L alqnXbnBjv1FGjBOy6fdAttTM+LIiQd14qI/VFWDXAeRb8JBQNLDVOyzaed3RTPPsl9/ opmoVSeL+6Ka3IoA85EA79KkGh0l8sD1B9rmSHLzUqXp6G3f/8qkEmp2qX9ah8PUjU0J pJ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HYBBDc+WV+vlafN0QjaHU6ktbJtXUHBdXwQ70Lil4Sw=; b=IM5Ntd4Hbzwjut+/XLWwSNFYfWxEbdVtThSzlHq/Dl6clIof3cMKCTRFlYE9De/hzL 7c2qr2ZEHnXYmWnvHlEKVl4cwciOv1+IjMYCyGR+T50bKppcIemCmvkKAmjSaC2oI8id QMDjRQ9Bh68Th+HR3IR0ek+CR6U7GN6aLnjKWyRe4GH+9t6EysrrYYVHFZKlXhPnx7yz e1zgAe88ajKI00/cqYFtTSIRPo8qw9eeFhAN4FOqn106rQQG7UKWrfXyQw7+tzsLEfCf xMha4xFsxiT9vMos0jq7WJFz97h4ifeyurUXmwgrtEislXPcJlHQEmJ2O67mU2ywfFv9 KIAA== X-Gm-Message-State: AOAM533Hj5WJLHj+EpphZ4PMRkfmBA4hvTeWaiPLgJUdGFNOs2E8YkRE 8SLxVv7YP+TTdKrIzJOD9KixgKUlmBi3bw== X-Google-Smtp-Source: ABdhPJwP/GgUSJXYca2Vs8zKHJTVqJtGh1/6FnVP2/ZTc3pu1gA4bTxI72CT/kojKm0nlPLD0QMIow== X-Received: by 2002:adf:ee4c:: with SMTP id w12mr4132965wro.22.1603209457536; Tue, 20 Oct 2020 08:57:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/41] target/arm: Implement v8.1M branch-future insns (as NOPs) Date: Tue, 20 Oct 2020 16:56:40 +0100 Message-Id: <20201020155656.8045-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" v8.1M implements a new 'branch future' feature, which is a set of instructions that request the CPU to perform a branch "in the future", when it reaches a particular execution address. In hardware, the expected implementation is that the information about the branch location and destination is cached and then acted upon when execution reaches the specified address. However the architecture permits an implementation to discard this cached information at any point, and so guest code must always include a normal branch insn at the branch point as a fallback. In particular, an implementation is specifically permitted to treat all BF insns as NOPs (which is equivalent to discarding the cached information immediately). For QEMU, implementing this caching of branch information would be complicated and would not improve the speed of execution at all, so we make the IMPDEF choice to implement all BF insns as NOPs. Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20201019151301.2046-7-peter.maydell@linaro.org --- target/arm/cpu.h | 6 ++++++ target/arm/t32.decode | 13 ++++++++++++- target/arm/translate.c | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 74392fa0295..a432f301f11 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3473,6 +3473,12 @@ static inline bool isar_feature_aa32_arm_div(const A= RMISARegisters *id) return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; } =20 +static inline bool isar_feature_aa32_lob(const ARMISARegisters *id) +{ + /* (M-profile) low-overhead loops and branch future */ + return FIELD_EX32(id->id_isar0, ID_ISAR0, CMPBRANCH) >=3D 3; +} + static inline bool isar_feature_aa32_jazelle(const ARMISARegisters *id) { return FIELD_EX32(id->id_isar1, ID_ISAR1, JAZELLE) !=3D 0; diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 7d5e000e82c..3015731a8d0 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -648,4 +648,15 @@ MRC 1110 1110 ... 1 .... .... .... ... 1 = .... @mcr =20 B 1111 0. .......... 10.1 ............ @branch24 BL 1111 0. .......... 11.1 ............ @branch24 -BLX_i 1111 0. .......... 11.0 ............ @branch24 +{ + # BLX_i is non-M-profile only + BLX_i 1111 0. .......... 11.0 ............ @branch24 + # M-profile only: loop and branch insns + [ + # All these BF insns have boff !=3D 0b0000; we NOP them all + BF 1111 0 boff:4 ------- 1100 - ---------- 1 # BFL + BF 1111 0 boff:4 0 ------ 1110 - ---------- 1 # BFCSEL + BF 1111 0 boff:4 10 ----- 1110 - ---------- 1 # BF + BF 1111 0 boff:4 11 ----- 1110 0 0000000000 1 # BFX, BFLX + ] +} diff --git a/target/arm/translate.c b/target/arm/translate.c index dc3a4031db7..a5ebe568804 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -7971,6 +7971,26 @@ static bool trans_BLX_suffix(DisasContext *s, arg_BL= X_suffix *a) return true; } =20 +static bool trans_BF(DisasContext *s, arg_BF *a) +{ + /* + * M-profile branch future insns. The architecture permits an + * implementation to implement these as NOPs (equivalent to + * discarding the LO_BRANCH_INFO cache immediately), and we + * take that IMPDEF option because for QEMU a "real" implementation + * would be complicated and wouldn't execute any faster. + */ + if (!dc_isar_feature(aa32_lob, s)) { + return false; + } + if (a->boff =3D=3D 0) { + /* SEE "Related encodings" (loop insns) */ + return false; + } + /* Handle as NOP */ + return true; +} + static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) { TCGv_i32 addr, tmp; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210691; cv=none; d=zohomail.com; s=zohoarc; b=XF9s5jqr2GYdvfhNaU6gQnm9zharzlDoHODOzjomnJLx+QnQBIKLVvQ07VWz0d5b1hWQgf5cbUUcCkrffKHNis7ATe+6kakFk1ASXdSaX7g9KfIqElnHgt5IolkupuWco9mhj4rFqxZwqnqXB6UAdZEB2iVoqAZbOngrsOIiEog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210691; h=Content-Transfer-Encoding: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=G63/MCjBMVEHxKf61b0I8Aw8yQgPaMtYsABsXjS/00w=; b=J1VD2GGTHGCe3V00Bxd7ns6L2ZxI0d2q1C9S5IDamcjFQzum4gv1ee5lGWYAwjJO/nSTXp5a1ya/Ve/lW9RTRwfyR8/nHcloi5qyCGLa9OkoOZ7GkltKIFxRuJpBh5+/PC8meNhwQTO3kgus7qrgQ0zhH1srwOj3DEhPROERi3c= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210691596211.30005562828978; Tue, 20 Oct 2020 09:18:11 -0700 (PDT) Received: from localhost ([::1]:36468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuKw-0006pA-Nh for importer@patchew.org; Tue, 20 Oct 2020 12:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu18-0005Oy-Ka for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:42 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:56280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu16-0003wc-Gt for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:42 -0400 Received: by mail-wm1-x32f.google.com with SMTP id a72so2330734wme.5 for ; Tue, 20 Oct 2020 08:57:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=G63/MCjBMVEHxKf61b0I8Aw8yQgPaMtYsABsXjS/00w=; b=Y4rXxpIrLb9TjL8NBixZlUIo6oS+sTWJbYwpiBwoFhHhwF4uTvKqVdbF43qQU+J6DL P//GUf98J2WMZikjRHCzIzi4H2D4HtBF7YG8fN+L7YBBHeOEnWzlDzOdA0lKykIVDIyD 7yZMx0phrx2/UUaQiiXwWxJKn8X+fF1MDlDBFECWtkLPODhPA64R9dFnGtU1/BXfBllO MGUkz2QlLK8Vx2F73baI/X9bxXyTO5nQlNutK1P+OTFQrj6iZke4wt3zb0OJ0VZBnsXT FZUw0wbESvigghvB73iowj7QFVX3JgGlK3phJYxiGsH3e9awiArRIcG6e24nN08K7LM4 5mKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G63/MCjBMVEHxKf61b0I8Aw8yQgPaMtYsABsXjS/00w=; b=uBe5EcI6f68zOawfILZlSrxCDF6m0l28XbYgeHJylOoi6PT8wNHkqDuTPx5nYpCRpI 5LO1PprJWEPkqKTiG5wbIU/dCv3UTBNe3ySRorZTE2q8mW/RvGxNJxTS4fS8ufxc7684 XUiNaxbt4yWQaa4oLFePpEFsTRtTqnK+2MPlS/uMo5Tsa5vpnf1Crp1soLk0hiHqK1ny aDZiLJ2DdoUGLzMYONDKJl98QnjStB7jcufsanbFfL0B53tvSALbPIHS9HtJojy+M1mW bOUig4rDaf6Op7JLSt/39QiP3BzLcGBRvHOixkUesEchglM7mT2aITUOQs8NTcgLqP5g af7Q== X-Gm-Message-State: AOAM531nE5ImJGzT82k3MlXGZ++yZQi0MR/HrYfMcvTGD8id0Dr4A86w CfcTb0OSmD+7Zx47Tbmnp19BjQsb/0EUWg== X-Google-Smtp-Source: ABdhPJwU3W1gGgG/JdwiDIdcL9gkcdEgeBoyqnkHxclJFG4AGGZZumAsNERx2JBxJKJ1wJflS1FcFA== X-Received: by 2002:a1c:cc07:: with SMTP id h7mr3802986wmb.55.1603209458707; Tue, 20 Oct 2020 08:57:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/41] target/arm: Implement v8.1M low-overhead-loop instructions Date: Tue, 20 Oct 2020 16:56:41 +0100 Message-Id: <20201020155656.8045-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" v8.1M's "low-overhead-loop" extension has three instructions for looping: * DLS (start of a do-loop) * WLS (start of a while-loop) * LE (end of a loop) The loop-start instructions are both simple operations to start a loop whose iteration count (if any) is in LR. The loop-end instruction handles "decrement iteration count and jump back to loop start"; it also caches the information about the branch back to the start of the loop to improve performance of the branch on subsequent iterations. As with the branch-future instructions, the architecture permits an implementation to discard the LO_BRANCH_INFO cache at any time, and QEMU takes the IMPDEF option to never set it in the first place (equivalent to discarding it immediately), because for us a "real" implementation would be unnecessary complexity. (This implementation only provides the simple looping constructs; the vector extension MVE (Helium) adds some extra variants to handle looping across vectors. We'll add those later when we implement MVE.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201019151301.2046-8-peter.maydell@linaro.org --- target/arm/t32.decode | 8 ++++ target/arm/translate.c | 93 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 3015731a8d0..8152739b52b 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -659,4 +659,12 @@ BL 1111 0. .......... 11.1 ............ = @branch24 BF 1111 0 boff:4 10 ----- 1110 - ---------- 1 # BF BF 1111 0 boff:4 11 ----- 1110 0 0000000000 1 # BFX, BFLX ] + [ + # LE and WLS immediate + %lob_imm 1:10 11:1 !function=3Dtimes_2 + + DLS 1111 0 0000 100 rn:4 1110 0000 0000 0001 + WLS 1111 0 0000 100 rn:4 1100 . .......... 1 imm=3D%lob_i= mm + LE 1111 0 0000 0 f:1 0 1111 1100 . .......... 1 imm=3D%lob_i= mm + ] } diff --git a/target/arm/translate.c b/target/arm/translate.c index a5ebe568804..38371db5401 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -2490,17 +2490,23 @@ static void gen_goto_tb(DisasContext *s, int n, tar= get_ulong dest) s->base.is_jmp =3D DISAS_NORETURN; } =20 -static inline void gen_jmp (DisasContext *s, uint32_t dest) +/* Jump, specifying which TB number to use if we gen_goto_tb() */ +static inline void gen_jmp_tb(DisasContext *s, uint32_t dest, int tbno) { if (unlikely(is_singlestepping(s))) { /* An indirect jump so that we still trigger the debug exception. = */ gen_set_pc_im(s, dest); s->base.is_jmp =3D DISAS_JUMP; } else { - gen_goto_tb(s, 0, dest); + gen_goto_tb(s, tbno, dest); } } =20 +static inline void gen_jmp(DisasContext *s, uint32_t dest) +{ + gen_jmp_tb(s, dest, 0); +} + static inline void gen_mulxy(TCGv_i32 t0, TCGv_i32 t1, int x, int y) { if (x) @@ -7991,6 +7997,89 @@ static bool trans_BF(DisasContext *s, arg_BF *a) return true; } =20 +static bool trans_DLS(DisasContext *s, arg_DLS *a) +{ + /* M-profile low-overhead loop start */ + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_lob, s)) { + return false; + } + if (a->rn =3D=3D 13 || a->rn =3D=3D 15) { + /* CONSTRAINED UNPREDICTABLE: we choose to UNDEF */ + return false; + } + + /* Not a while loop, no tail predication: just set LR to the count */ + tmp =3D load_reg(s, a->rn); + store_reg(s, 14, tmp); + return true; +} + +static bool trans_WLS(DisasContext *s, arg_WLS *a) +{ + /* M-profile low-overhead while-loop start */ + TCGv_i32 tmp; + TCGLabel *nextlabel; + + if (!dc_isar_feature(aa32_lob, s)) { + return false; + } + if (a->rn =3D=3D 13 || a->rn =3D=3D 15) { + /* CONSTRAINED UNPREDICTABLE: we choose to UNDEF */ + return false; + } + if (s->condexec_mask) { + /* + * WLS in an IT block is CONSTRAINED UNPREDICTABLE; + * we choose to UNDEF, because otherwise our use of + * gen_goto_tb(1) would clash with the use of TB exit 1 + * in the dc->condjmp condition-failed codepath in + * arm_tr_tb_stop() and we'd get an assertion. + */ + return false; + } + nextlabel =3D gen_new_label(); + tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_R[a->rn], 0, nextlabel); + tmp =3D load_reg(s, a->rn); + store_reg(s, 14, tmp); + gen_jmp_tb(s, s->base.pc_next, 1); + + gen_set_label(nextlabel); + gen_jmp(s, read_pc(s) + a->imm); + return true; +} + +static bool trans_LE(DisasContext *s, arg_LE *a) +{ + /* + * M-profile low-overhead loop end. The architecture permits an + * implementation to discard the LO_BRANCH_INFO cache at any time, + * and we take the IMPDEF option to never set it in the first place + * (equivalent to always discarding it immediately), because for QEMU + * a "real" implementation would be complicated and wouldn't execute + * any faster. + */ + TCGv_i32 tmp; + + if (!dc_isar_feature(aa32_lob, s)) { + return false; + } + + if (!a->f) { + /* Not loop-forever. If LR <=3D 1 this is the last loop: do nothin= g. */ + arm_gen_condlabel(s); + tcg_gen_brcondi_i32(TCG_COND_LEU, cpu_R[14], 1, s->condlabel); + /* Decrement LR */ + tmp =3D load_reg(s, 14); + tcg_gen_addi_i32(tmp, tmp, -1); + store_reg(s, 14, tmp); + } + /* Jump back to the loop start */ + gen_jmp(s, read_pc(s) - a->imm); + return true; +} + static bool op_tbranch(DisasContext *s, arg_tbranch *a, bool half) { TCGv_i32 addr, tmp; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210097; cv=none; d=zohomail.com; s=zohoarc; b=leBiQZRILshKz+feUzFEi2rsJD2eU1lMyNo2OzizKxk/xsQyCrbQdQwEOi0Aa10MiGrlkwNEkUtDOxIxHoBMSQ6o3K2jnAY7eYz/1NjZp1L1ByDI2P9EZHQdeJIUcq2C4fAXZ8DKfgmeLW24Ty1Y9DeRbkt3XKrZcKD9+oLqZLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210097; h=Content-Transfer-Encoding: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=MFt0HJYduCxRDucX1qFyNIPEc+06fjbqfzPFCHDeuQk=; b=EFnO/ZU/Jk/ljUOPkkXwLgtOO1pFSzZF7i2z3rSZepAnf3BslNLIgOTwR2CCF3z1+sM73+4/1FNTePKLDcrj0P1ndMgt8wY40q+393cB+vdfJMCdhZrPv0puCsFwCzGZu1U/AiybGwLyy7roRuHYsJjUvtpHOivXRZyj6Rt1MI0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210097849299.62700380043145; Tue, 20 Oct 2020 09:08:17 -0700 (PDT) Received: from localhost ([::1]:33546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuBM-0001V5-KG for importer@patchew.org; Tue, 20 Oct 2020 12:08:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu19-0005RP-HE for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:43 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:52280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu17-0003wl-NS for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:43 -0400 Received: by mail-wm1-x329.google.com with SMTP id c194so2328057wme.2 for ; Tue, 20 Oct 2020 08:57:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MFt0HJYduCxRDucX1qFyNIPEc+06fjbqfzPFCHDeuQk=; b=t3uoBQ30DOQd3283w3zBhzPTd7pnDe6vEocOjr6Tz0Yu2N47tsrOjhhhnNFSUBin5S vamdTTkziW9wp7POayi+eiF1StWmg9IRlImKRmeJ0SepN2DuoUcWQBdmbDALK2x1XokC CJUhYI2WF8efc9e60WjMLV46dRj10YvQyN8ycUNFzljs2idofH10zu4Ms1quArppoO1w MmuIuOycvEGu5zZyMipFIvh1IOolgI52LZCmpDIO2B5nw67Ul7qmhDLQyBh5pNxabByP +ESATxhXoDhg0ekZ7Hoqb6uLXgKwBsZhKzJrzGgGVZ06HknYRAMNbW4qN0SXZWCKFpZp eo/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MFt0HJYduCxRDucX1qFyNIPEc+06fjbqfzPFCHDeuQk=; b=DXthykrJPleAU0Rue3N1dqEcrY/ZuX17vPj/VgsEvpnnFVitr+2EZODdNebSpLw0h4 aN0xw731+epAxy5kKD1+sw+4Y8aktrvgEGf6XT6cAVplvxgkTkXpY1TMIRmEDeyuI88x Q0f71jgqqEorF+KmNVmZDZDS0CQMtlXvor4yPJNV+N7iIdCOvj9Ktz4y2GG3ONCiAIlL k/sk4vr3rLIJL29g6V8rN2Dkp4bv0o0ipRdRSx0gotPK8mptj/8YYEnJlttq7rPYIzRX ABf3ZJz1ynZe9pmW51ehY4A4hkfwh4MjHy7m7jAgdUUynTA/ZzPzDqcEyLGLt3/XQnTv 5yYA== X-Gm-Message-State: AOAM5336ECiiv6VVPgs6b8S25I69k0dsLghCIXmEd9uUVhxmpQ8KE6J+ gQxwy+0zBOVrbdb7SRseQxtJe9p8lyw+cA== X-Google-Smtp-Source: ABdhPJwJ5clXD5XQv48E0vRtF5nkybCSGJGhLwMra4uht78lF0FT5D38Sus2X6Q1rNzwGsnXqNy7bg== X-Received: by 2002:a7b:cc89:: with SMTP id p9mr2924874wma.4.1603209460115; Tue, 20 Oct 2020 08:57:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/41] target/arm: Fix has_vfp/has_neon ID reg squashing for M-profile Date: Tue, 20 Oct 2020 16:56:42 +0100 Message-Id: <20201020155656.8045-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" In arm_cpu_realizefn(), if the CPU has VFP or Neon disabled then we squash the ID register fields so that we don't advertise it to the guest. This code was written for A-profile and needs some tweaks to work correctly on M-profile: * A-profile only fields should not be zeroed on M-profile: - MVFR0.FPSHVEC,FPTRAP - MVFR1.SIMDLS,SIMDINT,SIMDSP,SIMDHP - MVFR2.SIMDMISC * M-profile only fields should be zeroed on M-profile: - MVFR1.FP16 In particular, because MVFR1.SIMDHP on A-profile is the same field as MVFR1.FP16 on M-profile this code was incorrectly disabling FP16 support on an M-profile CPU (where has_neon is always false). This isn't a visible bug yet because we don't have any M-profile CPUs with FP16 support, but the change is necessary before we introduce any. Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20201019151301.2046-9-peter.maydell@linaro.org --- target/arm/cpu.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 056319859fb..186ee621a65 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1429,17 +1429,22 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) u =3D cpu->isar.mvfr0; u =3D FIELD_DP32(u, MVFR0, FPSP, 0); u =3D FIELD_DP32(u, MVFR0, FPDP, 0); - u =3D FIELD_DP32(u, MVFR0, FPTRAP, 0); u =3D FIELD_DP32(u, MVFR0, FPDIVIDE, 0); u =3D FIELD_DP32(u, MVFR0, FPSQRT, 0); - u =3D FIELD_DP32(u, MVFR0, FPSHVEC, 0); u =3D FIELD_DP32(u, MVFR0, FPROUND, 0); + if (!arm_feature(env, ARM_FEATURE_M)) { + u =3D FIELD_DP32(u, MVFR0, FPTRAP, 0); + u =3D FIELD_DP32(u, MVFR0, FPSHVEC, 0); + } cpu->isar.mvfr0 =3D u; =20 u =3D cpu->isar.mvfr1; u =3D FIELD_DP32(u, MVFR1, FPFTZ, 0); u =3D FIELD_DP32(u, MVFR1, FPDNAN, 0); u =3D FIELD_DP32(u, MVFR1, FPHP, 0); + if (arm_feature(env, ARM_FEATURE_M)) { + u =3D FIELD_DP32(u, MVFR1, FP16, 0); + } cpu->isar.mvfr1 =3D u; =20 u =3D cpu->isar.mvfr2; @@ -1475,16 +1480,18 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) u =3D FIELD_DP32(u, ID_ISAR6, FHM, 0); cpu->isar.id_isar6 =3D u; =20 - u =3D cpu->isar.mvfr1; - u =3D FIELD_DP32(u, MVFR1, SIMDLS, 0); - u =3D FIELD_DP32(u, MVFR1, SIMDINT, 0); - u =3D FIELD_DP32(u, MVFR1, SIMDSP, 0); - u =3D FIELD_DP32(u, MVFR1, SIMDHP, 0); - cpu->isar.mvfr1 =3D u; + if (!arm_feature(env, ARM_FEATURE_M)) { + u =3D cpu->isar.mvfr1; + u =3D FIELD_DP32(u, MVFR1, SIMDLS, 0); + u =3D FIELD_DP32(u, MVFR1, SIMDINT, 0); + u =3D FIELD_DP32(u, MVFR1, SIMDSP, 0); + u =3D FIELD_DP32(u, MVFR1, SIMDHP, 0); + cpu->isar.mvfr1 =3D u; =20 - u =3D cpu->isar.mvfr2; - u =3D FIELD_DP32(u, MVFR2, SIMDMISC, 0); - cpu->isar.mvfr2 =3D u; + u =3D cpu->isar.mvfr2; + u =3D FIELD_DP32(u, MVFR2, SIMDMISC, 0); + cpu->isar.mvfr2 =3D u; + } } =20 if (!cpu->has_neon && !cpu->has_vfp) { --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210406; cv=none; d=zohomail.com; s=zohoarc; b=QnPLRPboV5wwiN/fkSJeXadFqJGrJMiifdT9ZgDBqHiINsZE6YlslZ9iBK7cFcnt5qOvRdI2Hfa2RksHTWLDj+SPtWI8gt0rJ7FbVevyRvq7qPiXZXJIlnDujVxQG2NjcBEj95tgvRaZrTCwvu14i89aajMp+FnxUFicv8D6P2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210406; h=Content-Transfer-Encoding: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=XUl/ktQBgt0jm/lkqBECj09xhOXM9wD4kdunxxEyOrg=; b=HRRYDVyhHOrUQmZJOdLaWeNkVvZ0xYRoTn+LQSwvGTIJITrmKy8/YgoEUo3ZLOqGehps8eFsnAHhxaBjlRYUGHCCWaSgIhgxydjDAvsJhNyO/MgBcVcHswe7gKzYfuXdPKoXoOEpuQui4747Yqiw1W5ZZ08JijDEnw0h45FjeF4= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210406509708.509389135814; Tue, 20 Oct 2020 09:13:26 -0700 (PDT) Received: from localhost ([::1]:48874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuGL-0008IA-Fo for importer@patchew.org; Tue, 20 Oct 2020 12:13:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1C-0005Tm-0X for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:47 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:40227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu19-0003ww-JX for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:45 -0400 Received: by mail-wm1-x32c.google.com with SMTP id k18so2510943wmj.5 for ; Tue, 20 Oct 2020 08:57:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XUl/ktQBgt0jm/lkqBECj09xhOXM9wD4kdunxxEyOrg=; b=TGeWpeBWpQIt21r3HA9OMxIUIYAV0voUbizywSWhsUvu24t+lBxYGO46JcegAKeTxo h0mBipeTaH14Tx+R7Di9P366jJHzM9VBa1IaY9rfwiu+voYglG+fS4cNqtlCrpEOjoUN fwvj1CH9eS3jJezoG8N3bJTa7EADRbIEN0ETsb8WS3p9vDVz1U1URa7Np+kN/SnrvyG8 9yHvU2SayeCgPmYIfTpkX1oIcYHJbYRVkMUyAo6xnSXG+cy4QavVimAJo38vLdEWuucM cp/CuWMREJHXmBExgX/xxqQydQE/VUVVr7uchJr9KpGj+sRDMXawEqrJwaZSzPCewXd0 umUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XUl/ktQBgt0jm/lkqBECj09xhOXM9wD4kdunxxEyOrg=; b=eNVrhj3+m7PdHaz6i/+uCv53ReIRM8MupReyi0i5dytix7D2EYNw9JU0YfolNhApVr youvzmVc8TrgfQzWV4Akce+omX9SVcfZ3mcrkMbzEVZYgxrVT+oKg70Kfi5kXWV9w6gs R65YCc1Kd8hWtYV7FjPmJPzdRnorr89LiG5WdkDg2eeIOdFj0wuAOsUrokoRNSzP9hQh JGhjNlMV8wkDFTjCN3PBxvGdwxZmqx2i55Poto3eqyH1QuJKBnbtfoayTkYo6+8KwOvR zVqh18zpETdsxtmLvrD7znMPGPn/kCXCxb8BWRhXZ2OoNf7i/KJlhlCLbau7uBUO/k44 Z9hw== X-Gm-Message-State: AOAM530CObvd359EF1R6HN2YGCgiPC+yAx79TfoVvaMWNAudZ7fzT6Y8 5Da2MRtDq+9pNGZGL2zbuZ58iJusRh5BvA== X-Google-Smtp-Source: ABdhPJzm5Qt/Eo+t/TowNDHrlj4TRJcIXt13obYLPJ2YdnA/FvmFPK9tJRvNO65calbwFjsQqALlEg== X-Received: by 2002:a1c:2b05:: with SMTP id r5mr3593511wmr.179.1603209461453; Tue, 20 Oct 2020 08:57:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/41] target/arm: Allow M-profile CPUs with FP16 to set FPSCR.FP16 Date: Tue, 20 Oct 2020 16:56:43 +0100 Message-Id: <20201020155656.8045-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" M-profile CPUs with half-precision floating point support should be able to write to FPSCR.FZ16, but an M-profile specific masking of the value at the top of vfp_set_fpscr() currently prevents that. This is not yet an active bug because we have no M-profile FP16 CPUs, but needs to be fixed before we can add any. The bits that the masking is effectively preventing from being set are the A-profile only short-vector Len and Stride fields, plus the Neon QC bit. Rearrange the order of the function so that those fields are handled earlier and only under a suitable guard; this allows us to drop the M-profile specific masking, making FZ16 writeable. This change also makes the QC bit correctly RAZ/WI for older no-Neon A-profile cores. This refactoring also paves the way for the low-overhead-branch LTPSIZE field, which uses some of the bits that are used for A-profile Stride and Len. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201019151301.2046-10-peter.maydell@linaro.org --- target/arm/vfp_helper.c | 47 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index abfdb6a8e23..364856498c4 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -194,36 +194,45 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t= val) val &=3D ~FPCR_FZ16; } =20 - if (arm_feature(env, ARM_FEATURE_M)) { + vfp_set_fpscr_to_host(env, val); + + if (!arm_feature(env, ARM_FEATURE_M)) { /* - * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits - * and also for the trapped-exception-handling bits IxE. + * Short-vector length and stride; on M-profile these bits + * are used for different purposes. + * We can't make this conditional be "if MVFR0.FPShVec !=3D 0", + * because in v7A no-short-vector-support cores still had to + * allow Stride/Len to be written with the only effect that + * some insns are required to UNDEF if the guest sets them. + * + * TODO: if M-profile MVE implemented, set LTPSIZE. */ - val &=3D 0xf7c0009f; + env->vfp.vec_len =3D extract32(val, 16, 3); + env->vfp.vec_stride =3D extract32(val, 20, 2); } =20 - vfp_set_fpscr_to_host(env, val); + if (arm_feature(env, ARM_FEATURE_NEON)) { + /* + * The bit we set within fpscr_q is arbitrary; the register as a + * whole being zero/non-zero is what counts. + * TODO: M-profile MVE also has a QC bit. + */ + env->vfp.qc[0] =3D val & FPCR_QC; + env->vfp.qc[1] =3D 0; + env->vfp.qc[2] =3D 0; + env->vfp.qc[3] =3D 0; + } =20 /* * We don't implement trapped exception handling, so the * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) * - * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC - * (which are stored in fp_status), and the other RES0 bits - * in between, then we clear all of the low 16 bits. + * The exception flags IOC|DZC|OFC|UFC|IXC|IDC are stored in + * fp_status; QC, Len and Stride are stored separately earlier. + * Clear out all of those and the RES0 bits: only NZCV, AHP, DN, + * FZ, RMode and FZ16 are kept in vfp.xregs[FPSCR]. */ env->vfp.xregs[ARM_VFP_FPSCR] =3D val & 0xf7c80000; - env->vfp.vec_len =3D (val >> 16) & 7; - env->vfp.vec_stride =3D (val >> 20) & 3; - - /* - * The bit we set within fpscr_q is arbitrary; the register as a - * whole being zero/non-zero is what counts. - */ - env->vfp.qc[0] =3D val & FPCR_QC; - env->vfp.qc[1] =3D 0; - env->vfp.qc[2] =3D 0; - env->vfp.qc[3] =3D 0; } =20 void vfp_set_fpscr(CPUARMState *env, uint32_t val) --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603211436; cv=none; d=zohomail.com; s=zohoarc; b=EAqQ5CpIXMaK4Tc8COTSahxmzvB5WHo7ARrZcrK6HuPDwqRj5I27+dA1sLNyPsIz34b8BdXRjI0vdpD0/MfxyZniFlmPXZ+85ciFbkLqAtG0vpkPR2+eqfMhBoF3L5Me9Wwd9juIxMv2Ydsg3azE9jPCNnls4PMES1YKVQHBe8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603211436; h=Content-Transfer-Encoding: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=Gsl0pskRk7KVMoTzUTHvyTGRlhYkpRENSDWVHkehmtc=; b=FUx5Jh3BKNc2TR95U43SJOwhZIXifyusuIw0U5Vy85fTtpRu6P/+1wlim8r0nPC/TisO6fY4OLX35pfa/OqVSa9WUy2twJVg1KQsYnzYHGX1iG+NCNuSNZvoKESu6TZGYsdtJRr77mmkXKzZkkApH2jDMgteMa4nc9y5GxNXX/I= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603211436534449.77116419408367; Tue, 20 Oct 2020 09:30:36 -0700 (PDT) Received: from localhost ([::1]:48260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuWx-0007Su-IV for importer@patchew.org; Tue, 20 Oct 2020 12:30:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1F-0005VT-J8 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:50 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:50248) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1B-0003x7-LN for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:49 -0400 Received: by mail-wm1-x334.google.com with SMTP id 13so2340673wmf.0 for ; Tue, 20 Oct 2020 08:57:44 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Gsl0pskRk7KVMoTzUTHvyTGRlhYkpRENSDWVHkehmtc=; b=m73dAuA1JZ5oC/Y422H3e6Rk5ZBmkNMz4sMcY0MC5dWSCslKWfbnQQtzX9hDvY2F2/ C9/xiGkJYw60eRuA0RzDP/M9i1MC+b5woh7CQ6y9UTX949yMB0/zcTqQtv3P0VQ5w6Ak i8CutoqYIW/kxo8YcbBOVwW/6EnmZ/PNYHt1Sip0pnwODXXmlqg6rIBY0+TnRPBLCHbB o0qJrPmpG8T6+nl+K5ZgpQNUWpW7ykGp5QYKJ5ldwPb1b1V+4XHaXfxV1BaePJredD1m 8zAu83+OKnnG+dux4U+kPT1MsxIPkfQQ/5PXmrqql8Y7f5L+ahe0BYpFIyUqYdAxbDYH RDcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gsl0pskRk7KVMoTzUTHvyTGRlhYkpRENSDWVHkehmtc=; b=f5f6dHwU5qqcBPz84u/G/YEz7RUstZU3H6mUAcsiwXOv68MOTkabtQL5FfKotLpZ5h tnAUTJpcVBmNCl5bu7Y7wwKLIUtNs1zko/Znl5rxIh58WW+s/o+mzbLj0FMzxFrT3kss PNppzyY4FQNSCZl3+1Xa/k/YC1dy60GaT17uI6ZShBv28RuTg93QP/XYWnbO5VKX1ezW fCbJkp8LYnyq03ZPuRCdw6DIEtwQpaaSZvfsJpjpPO75NMxR68eDSxLjxWzfj3ZR76Kl CM081NDnUzlcf/URAobSMvcreqxXw7kEtoCUuW4TNPuFmKj7nmtSbej5deBCl0PgEMGZ GciQ== X-Gm-Message-State: AOAM530mjR0LVLVoQUFr2owdjdDauENPS9Y/A5bre+YNb8bOjNHe20UW WmeRB0r2KrwzOXF60bmoM3fYRo8y0KDxGg== X-Google-Smtp-Source: ABdhPJy2AbGgFOhJoA08OHIBZHGZpfZyzw6iLTCdbZ69rkSXV4fUkwWScINli6CVCPhuMrx3fn4HKw== X-Received: by 2002:a7b:c189:: with SMTP id y9mr3436297wmi.141.1603209463092; Tue, 20 Oct 2020 08:57:43 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/41] target/arm: Implement FPSCR.LTPSIZE for M-profile LOB extension Date: Tue, 20 Oct 2020 16:56:44 +0100 Message-Id: <20201020155656.8045-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" If the M-profile low-overhead-branch extension is implemented, FPSCR bits [18:16] are a new field LTPSIZE. If MVE is not implemented (currently always true for us) then this field always reads as 4 and ignores writes. These bits used to be the vector-length field for the old short-vector extension, so we need to take care that they are not misinterpreted as setting vec_len. We do this with a rearrangement of the vfp_set_fpscr() code that deals with vec_len, vec_stride and also the QC bit; this obviates the need for the M-profile only masking step that we used to have at the start of the function. We provide a new field in CPUState for LTPSIZE, even though this will always be 4, in preparation for MVE, so we don't have to come back later and split it out of the vfp.xregs[FPSCR] value. (This state struct field will be saved and restored as part of the FPSCR value via the vmstate_fpscr in machine.c.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20201019151301.2046-11-peter.maydell@linaro.org --- target/arm/cpu.h | 1 + target/arm/cpu.c | 9 +++++++++ target/arm/vfp_helper.c | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a432f301f11..49cd5cabcf2 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -549,6 +549,7 @@ typedef struct CPUARMState { uint32_t fpdscr[M_REG_NUM_BANKS]; uint32_t cpacr[M_REG_NUM_BANKS]; uint32_t nsacr; + int ltpsize; } v7m; =20 /* Information associated with an exception about to be taken: diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 186ee621a65..07492e9f9a4 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -255,6 +255,15 @@ static void arm_cpu_reset(DeviceState *dev) uint8_t *rom; uint32_t vecbase; =20 + if (cpu_isar_feature(aa32_lob, cpu)) { + /* + * LTPSIZE is constant 4 if MVE not implemented, and resets + * to an UNKNOWN value if MVE is implemented. We choose to + * always reset to 4. + */ + env->v7m.ltpsize =3D 4; + } + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { env->v7m.secure =3D true; } else { diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index 364856498c4..01b9d8557f7 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -174,6 +174,12 @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | (env->vfp.vec_len << 16) | (env->vfp.vec_stride << 20); =20 + /* + * M-profile LTPSIZE overlaps A-profile Stride; whichever of the + * two is not applicable to this CPU will always be zero. + */ + fpscr |=3D env->v7m.ltpsize << 16; + fpscr |=3D vfp_get_fpscr_from_host(env); =20 i =3D env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3= ]; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210273; cv=none; d=zohomail.com; s=zohoarc; b=Q52F/mBkx3om8oNCyzh6ItVrwiXw4NA93WM8AcYozx+XPQZkAeavUY0A8nGCor3xEv5bnMDtZRXVODRi2oEdRzSPmWupHBGQmT5AJLTHoK61eOJHIAjYPLNCHlaUEAQrbigQMsYHuLN1fsTkQ1pOmnLvIQi+n5KgEYfJ2sMm9xE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210273; h=Content-Transfer-Encoding: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=uyEwIt2mg5JkbXvyiGTkqHRg5zYJZwzlbNrkrnMgxtg=; b=jhRgbL6F96xq0PRglH+fc1AZ37juAOKzJe9JvE7hOUJl6/+fHnjQsi1bajQ8+Z2rXaEYmxsaqJkLK0g5c/HqLOpvNoM//LfHKWRrkfwDiofWYRQ7+iOTJ+JzUw4Yb/sTnHNQxY3Sp5Q/bR9/j5ypZ50inx7jI1cmd5zTxqngDhY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210273699781.4466847253085; Tue, 20 Oct 2020 09:11:13 -0700 (PDT) Received: from localhost ([::1]:41888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuEC-00059u-LP for importer@patchew.org; Tue, 20 Oct 2020 12:11:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1H-0005WI-BJ for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:51 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:50690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1D-0003xE-Bs for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:51 -0400 Received: by mail-wm1-x341.google.com with SMTP id 13so2340750wmf.0 for ; Tue, 20 Oct 2020 08:57:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uyEwIt2mg5JkbXvyiGTkqHRg5zYJZwzlbNrkrnMgxtg=; b=afJQHmT9Ni6S4be+PKiH8C8N/xKG93yKBoObSbCpQ8pRzfHxMAEmVQYIy5N4w7nx5l 92QS0zrwN4kHvI27MMrki5+YUoz/X5JQlE+fzM5R/KK6YkS8KaLazOOrEh3lrK3jJyj6 lEAJLQyExJeCREbGEuiqFcw2pWBgZZzy8d1u5oH3g6geqL0nL18SYWMFuoOaJnjIrYSy UtmOECvX6IELIsqPQ9xFBkvnIOndTuozGcCvYk50mnB1TNAX5Sq2IpfajJocRCNWOTWA WCpv/XIs8vURF85tdWMFhcuR1souB4QeT2NUoC3Mqc3aLnaHQZaJkCdeYSqzJmSD7WGH 9kdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uyEwIt2mg5JkbXvyiGTkqHRg5zYJZwzlbNrkrnMgxtg=; b=PZJcOxiXEDve7+oL8TP60KJNBmCtOQvBER+EP5cR3v6MgIQ/XOmJONn7s7cDytDGup YPY0VRc6E0OloPj4H0LgIddJEP6skOTtkB6vpzD+FYERRfOHikvK+9wUDTWMZXerc3xz 4ctOvVB5j3/YeFOHu5a8BdC77NIKmVXWekV61Zryj0OB/cEbTQWKBZdYljZeEO7wxqU8 32zY5ZocLqaLvNF+7JQC5CVEf/4CcyFg4BT5+9Gs9QiCUj9wBo4j62+ZbU+VUCmAE7bu cZVMmew31HUNENjVcGKC3vbqs+424PSYjb9Ab1WCRXIp71kI7bsoNz7U2QscBLyBuBMC kljw== X-Gm-Message-State: AOAM532doWdA7PFIBxkIeThbK31tRlIt4bPYemQcS96iWIyUB5oHKinb i/5mquy5hsKni4uvM0acHxL/8wgNx2tyhg== X-Google-Smtp-Source: ABdhPJw9Iti8CF7NkgwkzybBsEy7qyNpF6vbNjAHP7gZyCBenXbexJX0F/L67oMmyAkaHLfp/77aGg== X-Received: by 2002:a7b:c4cb:: with SMTP id g11mr3659843wmk.88.1603209464484; Tue, 20 Oct 2020 08:57:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 30/41] linux-user/aarch64: Reset btype for signals Date: Tue, 20 Oct 2020 16:56:45 +0100 Message-Id: <20201020155656.8045-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::341; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson The kernel sets btype for the signal handler as if for a call. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/aarch64/signal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index d50c1ae5838..b591790c22e 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -506,10 +506,16 @@ static void target_setup_frame(int usig, struct targe= t_sigaction *ka, + offsetof(struct target_rt_frame_record, tramp); } env->xregs[0] =3D usig; - env->xregs[31] =3D frame_addr; env->xregs[29] =3D frame_addr + fr_ofs; - env->pc =3D ka->_sa_handler; env->xregs[30] =3D return_addr; + env->xregs[31] =3D frame_addr; + env->pc =3D ka->_sa_handler; + + /* Invoke the signal handler as if by indirect call. */ + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { + env->btype =3D 2; + } + if (info) { tswap_siginfo(&frame->info, info); env->xregs[1] =3D frame_addr + offsetof(struct target_rt_sigframe,= info); --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210838; cv=none; d=zohomail.com; s=zohoarc; b=aWVoweNMCvk9wXMUQN1YqIYo/U7qZkMUJu1kgR4npZuZPOYUBuMZVqPGs3seg5Mepq3SQapZ6MwaDTNTtiOWlHSscjzlWTgr9SpDXewqycSjOywRKApUgsYkTwf70iZwj30Pw3OZz2ERJORcS/VFN43f/rF0x3eG7YpQocREcro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210838; h=Content-Transfer-Encoding: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=24XJoNPc8DTNqAEsM0sOYnp5VshSzc0j1PLW+SwTh3Q=; b=nQg7e7A6HFLMOJ0g2yvqn650A9Mt6Jrdsq5kHyF5hG+OobbyLDAiulxXRJWGiNnSa0skUGZlEF0fDZ7gEsDxiw1qsmJe/jRAL5wdDpcPGC52RjZMoFi2eVr2yEViOFOe1N2/sw+hskuP4uAY8MRF7V9h0pQNUqqrpR6EJLz5jSE= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210838831190.91751732467378; Tue, 20 Oct 2020 09:20:38 -0700 (PDT) Received: from localhost ([::1]:45226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuNJ-00023E-Tu for importer@patchew.org; Tue, 20 Oct 2020 12:20:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1H-0005XK-PF for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:52 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:50692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1D-0003xN-Gd for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:51 -0400 Received: by mail-wm1-x343.google.com with SMTP id 13so2340819wmf.0 for ; Tue, 20 Oct 2020 08:57:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=24XJoNPc8DTNqAEsM0sOYnp5VshSzc0j1PLW+SwTh3Q=; b=aj1G23Ik8CU6OUJ4eGwiJxMgEW5fcICviPcPd3Ojg9BlE57fkSdC08WBpp2xyLmbpr jdgTjVlx/toYvbjl/m0fiKS4f1BVgWkb3Zgs/ZZXBbkbUc1aAd2skzuykQqaKYCU2hok lH00e245uROQ0sn1TOLHh637AR+9ExkSQU8yx1/aG3uBPZShvUbBxvpgH3q+FZfWEgan mQC1vZr41jds9hfNzWVHLMNCoZL7jHhWSy1491jY0qcfhIERNXj5OwvTF1jq0Qlw1J07 lVMEPRvW/3Tlv45rDFmWSEG1l6Xwhmkv7dU4ZPEuoQs7d45DEfFstLPyc/fVfP+kv/P2 z+JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=24XJoNPc8DTNqAEsM0sOYnp5VshSzc0j1PLW+SwTh3Q=; b=a8/PEPZ6ZpTgKEhWOkYdOMbytLeUnj7t7k8RX9whh4IM41Xfry6zKDVdsEQ6nYkb+/ G14aHRgAnvI4uSbJaIU0ZwDL33BDVBKyvkCavMnIDYo9kWYjX0DiB7ZA6gGZo/xRB3Qr HGZF0/0RlpN4nf4nP/JimJ1KXmLiNWx1+y0n7H6+3HY7qKTjcnSo/FqtL0SsyGvI7Lxd 8oAicOzJagxqXmKoLY0RTXOnUa/4nCf2YlMsoq0/XBTFwkHPguVRuaHVdkw/3vH6Qleu 13ABO8gZKteqchqbCgqwEVu7dDCYYAUzNxULMBzCDXOZOHCsJOyIOuBulza2gbsFVwQu vRfA== X-Gm-Message-State: AOAM531RDt3s+P5rjj4MyjvU4guMobSOOfiKbNbgpgKEjtb2lLH0IY2h 2maViQGq89adH54Fvg/ywPItNNUcboOrEw== X-Google-Smtp-Source: ABdhPJzzuEgcVpAsqBFYq3S0EPXIWjyNle/LaPWk0vU4M37uxc9+XMBlXUZQ1Jut35rYgUgpnuUtkg== X-Received: by 2002:a1c:8093:: with SMTP id b141mr3613706wmd.139.1603209465513; Tue, 20 Oct 2020 08:57:45 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 31/41] linux-user: Set PAGE_TARGET_1 for TARGET_PROT_BTI Date: Tue, 20 Oct 2020 16:56:46 +0100 Message-Id: <20201020155656.8045-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::343; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson Transform the prot bit to a qemu internal page bit, and save it in the page tables. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- include/exec/cpu-all.h | 2 ++ linux-user/syscall_defs.h | 4 ++++ target/arm/cpu.h | 5 +++++ linux-user/mmap.c | 16 ++++++++++++++++ target/arm/translate-a64.c | 6 +++--- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 61e13b50382..656a2a87888 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -274,6 +274,8 @@ extern intptr_t qemu_host_page_mask; /* FIXME: Code that sets/uses this is broken and needs to go away. */ #define PAGE_RESERVED 0x0020 #endif +/* Target-specific bits that will be used via page_get_flags(). */ +#define PAGE_TARGET_1 0x0080 =20 #if defined(CONFIG_USER_ONLY) void page_dump(FILE *f); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 731c3d5341a..cabbfb762dd 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1277,6 +1277,10 @@ struct target_winsize { #define TARGET_PROT_SEM 0x08 #endif =20 +#ifdef TARGET_AARCH64 +#define TARGET_PROT_BTI 0x10 +#endif + /* Common */ #define TARGET_MAP_SHARED 0x01 /* Share changes */ #define TARGET_MAP_PRIVATE 0x02 /* Changes are private */ diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 49cd5cabcf2..c18a9167665 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3445,6 +3445,11 @@ static inline MemTxAttrs *typecheck_memtxattrs(MemTx= Attrs *x) #define arm_tlb_bti_gp(x) (typecheck_memtxattrs(x)->target_tlb_bit0) #define arm_tlb_mte_tagged(x) (typecheck_memtxattrs(x)->target_tlb_bit1) =20 +/* + * AArch64 usage of the PAGE_TARGET_* bits for linux-user. + */ +#define PAGE_BTI PAGE_TARGET_1 + /* * Naming convention for isar_feature functions: * Functions which test 32-bit ID registers should have _aa32_ in diff --git a/linux-user/mmap.c b/linux-user/mmap.c index f2615634201..00c05e6a0f1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -83,6 +83,22 @@ static int validate_prot_to_pageflags(int *host_prot, in= t prot) *host_prot =3D (prot & (PROT_READ | PROT_WRITE)) | (prot & PROT_EXEC ? PROT_READ : 0); =20 +#ifdef TARGET_AARCH64 + /* + * The PROT_BTI bit is only accepted if the cpu supports the feature. + * Since this is the unusual case, don't bother checking unless + * the bit has been requested. If set and valid, record the bit + * within QEMU's page_flags. + */ + if (prot & TARGET_PROT_BTI) { + ARMCPU *cpu =3D ARM_CPU(thread_cpu); + if (cpu_isar_feature(aa64_bti, cpu)) { + valid |=3D TARGET_PROT_BTI; + page_flags |=3D PAGE_BTI; + } + } +#endif + return prot & ~valid ? 0 : page_flags; } =20 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 71888083417..072754fa24d 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14507,10 +14507,10 @@ static void disas_data_proc_simd_fp(DisasContext = *s, uint32_t insn) */ static bool is_guarded_page(CPUARMState *env, DisasContext *s) { -#ifdef CONFIG_USER_ONLY - return false; /* FIXME */ -#else uint64_t addr =3D s->base.pc_first; +#ifdef CONFIG_USER_ONLY + return page_get_flags(addr) & PAGE_BTI; +#else int mmu_idx =3D arm_to_core_mmu_idx(s->mmu_idx); unsigned int index =3D tlb_index(env, mmu_idx, addr); CPUTLBEntry *entry =3D tlb_entry(env, mmu_idx, addr); --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210557; cv=none; d=zohomail.com; s=zohoarc; b=icMsU0aYwwkOy/DF9Jee7W9YJaRGw0wE6iBfE+6c5St77EgkfxsYOtg2xhSisQtFfyurixBBltkeQoMzLhs8MCwTafM/NaAVOyWNKgxlMi9XhaFoJ2T4R30ZrMsITrRlYHqPMyIRZZ6iTia6J59EATME7g13COsNtRCfDz5llMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210557; h=Content-Transfer-Encoding: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=Fr3Yb3O1oESiwTEzLYt93gIX3QkvXqf7yJZArc/ujso=; b=VfiNe9ETXaZHbo+97wEBiktxemZkAH7+UKY+I7R3bf3t1fJI4D7w/8ouglGgqWtqNgvdYdVnZdINjoYB65KjdqijUKVtE9O1R0MxznlppgeeLjlno+xZU3coy5EJacoQbdXzHiidKNgqIWBUCNaGOf9Rjd7v5dyVko7qU1NM2U0= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210557899859.1555679960818; Tue, 20 Oct 2020 09:15:57 -0700 (PDT) Received: from localhost ([::1]:57116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuIm-0003Jz-AM for importer@patchew.org; Tue, 20 Oct 2020 12:15:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1J-0005YM-12 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:53 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:37722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1F-0003xU-7w for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:52 -0400 Received: by mail-wm1-x330.google.com with SMTP id c16so2516141wmd.2 for ; Tue, 20 Oct 2020 08:57:48 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Fr3Yb3O1oESiwTEzLYt93gIX3QkvXqf7yJZArc/ujso=; b=C672Cu3JFdyt38RRTAdG4YSqIYL4ZdUytgUQr+z0NiL1qWcWBXh4fcvgKMD/XESBZx rV1SalTaexCWVKIjH7A8/nfTebIe1hB9TGOOYtFRvcDdWFpbQ6oF3ax35n0xt52Uzq+N CwPDdalXRITRgMBQyL5mJwcJYjSK6sioeWXNWI5yrc/pl+pjZm1FzQwPR/DHqojwOzrm tGnnNysZeTAGqjdn50z03NvPgPw81Xn5V7bUwvgDE0jQNuRcLQAeVUo+RH+cwIsPvY9j Z52TpieQqDdc1jm2cHgzvEWgouL5m3t8dcCU04UoSzG4xsfCGlJjfqiHgiMa45Vm2lWh HTeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fr3Yb3O1oESiwTEzLYt93gIX3QkvXqf7yJZArc/ujso=; b=Ct5oZAd1sz1m4Z/0ysYnt4/OntGOe74FV8YmyeH/wyt4K8SaIOBPUOX0DUcrAcLcRH BDAmE4jIdpQeLKp54pohDEZuFUC9GoLTGZ3TvLWRJFtsjHLuNFdrdJNPxHDY9KSCzOrS iOQMcX/XyeUZatVS08VPxUg7XaQycf+1pu06GIawJCnVflzxYwAIX/tE3nZ1fE5m7y2v dd/EhetuVLYhuA5VE2lFzYIYcXPnejs8SWKj7mZjTMiVFKsxeIJmMjpwR+vG1SJ9QHwd 4P4Oml5mhE/NGrCwzZVa3fAWILPB8kk+pFBw57tqeLRe0ay/Yxgg/Ez21GCdRjqF78JR hHrQ== X-Gm-Message-State: AOAM531c4cLW2qO9W7ChxBfFmSSmqJU+XWEKPzjUbC3GJMZZanF0ceqq jBj93IAJ6nShddIl2HsGVe3nCcMciwf7IQ== X-Google-Smtp-Source: ABdhPJx9Y/+3S9IXp3VApiriH0bz7TCD144/5m+WEaMlOQOt+1opNi7vuGrHXOVaGXsmEKe1iC0bbA== X-Received: by 2002:a1c:7518:: with SMTP id o24mr3769359wmc.137.1603209467023; Tue, 20 Oct 2020 08:57:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 32/41] include/elf: Add defines related to GNU property notes for AArch64 Date: Tue, 20 Oct 2020 16:56:47 +0100 Message-Id: <20201020155656.8045-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson These are all of the defines required to parse GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils. Other missing defines related to other GNU program headers and notes are elided for now. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- include/elf.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/elf.h b/include/elf.h index c117a4d1ab0..10126ff809a 100644 --- a/include/elf.h +++ b/include/elf.h @@ -26,9 +26,13 @@ typedef int64_t Elf64_Sxword; #define PT_NOTE 4 #define PT_SHLIB 5 #define PT_PHDR 6 +#define PT_LOOS 0x60000000 +#define PT_HIOS 0x6fffffff #define PT_LOPROC 0x70000000 #define PT_HIPROC 0x7fffffff =20 +#define PT_GNU_PROPERTY (PT_LOOS + 0x474e553) + #define PT_MIPS_REGINFO 0x70000000 #define PT_MIPS_RTPROC 0x70000001 #define PT_MIPS_OPTIONS 0x70000002 @@ -1657,6 +1661,24 @@ typedef struct elf64_shdr { #define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */ #define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension r= egs */ =20 +/* Defined note types for GNU systems. */ + +#define NT_GNU_PROPERTY_TYPE_0 5 /* Program property */ + +/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). = */ + +#define GNU_PROPERTY_STACK_SIZE 1 +#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2 + +#define GNU_PROPERTY_LOPROC 0xc0000000 +#define GNU_PROPERTY_HIPROC 0xdfffffff +#define GNU_PROPERTY_LOUSER 0xe0000000 +#define GNU_PROPERTY_HIUSER 0xffffffff + +#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000 +#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1u << 0) +#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1u << 1) + /* * Physical entry point into the kernel. * --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210702; cv=none; d=zohomail.com; s=zohoarc; b=SGVKOSGB3Y7Fnss9tv/7jF+djueYRQGtC2bh3zxUImiZrVv9Ot2o1lMa1qgNnUFhszg5Ew3wj2gk5SEFrAyIo4daYIsbMYh0Sud0tEAOjwwIwtY+KbBW8X40i8/qwdOaeQt+jU5lhs7f6+cAsxNraPAhxpPjeYYW59ykmU5L3to= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210702; h=Content-Type:Content-Transfer-Encoding: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=Z0HMWgiSgaHAnfHC4nGM232rOSwhB2ZkX8mExK/8DHQ=; b=WLOJy1BvqVOHUps9JtI/dNlOIHZmCzZvyvGfUwyoN2m75wb8JhpbLX1LG3xTdUclpzETylMS9aJ0Po4RP9PZglKbjkwluoBHXU1VID8b1776cSgvyKRuzw15X1ss22sdS1S6slN9J/nd2UuQva6f2YEj07YWweggP38Yi1aGGSM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210702294769.1494995423456; Tue, 20 Oct 2020 09:18:22 -0700 (PDT) Received: from localhost ([::1]:37186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuL7-00077a-HM for importer@patchew.org; Tue, 20 Oct 2020 12:18:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1J-0005Z4-G8 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:54 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:51981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1G-0003xd-VY for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:53 -0400 Received: by mail-wm1-x329.google.com with SMTP id d81so2330608wmc.1 for ; Tue, 20 Oct 2020 08:57:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Z0HMWgiSgaHAnfHC4nGM232rOSwhB2ZkX8mExK/8DHQ=; b=G6ljUV3lqm+5uTyg2aKi5HDLvCYnCRKuE4qYkWIxTlt0VJtFg4kGGxouDq9B2q58gd Bn55M20jqF3aKx2Bj6TjNGK3fTvmUSu09uTdLyUDa2BBRtX6xQl3hVZvWpbHgru/ocpG yorRThli/rEdYw5Ev02ca/FdjrAwQnowSgirvgkWm2JctModYdtSTS2hS38EAk9AJUDp t6CFlIKNOsBroPpatgxuXqDzBUoyHSjrLZW85D6+6gqIY9zVX8LX0oJjNgXJ0oapc/q0 jjeNYqL5M0FE3SZKwydGZ/uDowviPX13KTiArQHFjA3t7Lb/d1E2U9/tsSaepAXEL8HK 4TLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z0HMWgiSgaHAnfHC4nGM232rOSwhB2ZkX8mExK/8DHQ=; b=nwnDSsljjKpbQwire8mGcen+m25ES2EKWA6jE/DAZyi1Q8S4YlCXJpD1n9rMyNlXFw +NXxmeOTQBFIyNSCkJPBkqX1Qoo928UxHt37xIj4kTjxROXurL7sNBnGRc01mqNU4bLA O15ShpQgBSiMX6+wxJMFvGAtP6okl/B0a9vHQGwsaVJDMl4OaWFmA6i3nGMncG9yYPxB wp7PlWChDrsRi/umcs5+21kzUijLPZXX+JcHm0ZvIsAySMwVYBs0Y1WW451GoCjPAqc2 l4uiZ5ksPsfX/1NrmjlK55/5Chc3Xr6cLuBM81FmRh8B+trXVvvTshgnno3Y2F2/O0vZ lHaA== X-Gm-Message-State: AOAM531SetcQ3HM3uV+97MtpZV/7fzuUWzQFRz1IXmVoPQSJoo04Pi4N Wp0NQ9n1uFyLxYx4Y7bZtKz9qFAm3m4Vaw== X-Google-Smtp-Source: ABdhPJwdWIW9lWwtB9bcHX5smUjYTCMPsuyu+AKGnByy9Q3D5OHdaYWc6wLY+a24/qFzfIL9p0mb6A== X-Received: by 2002:a7b:c750:: with SMTP id w16mr3458978wmk.136.1603209468042; Tue, 20 Oct 2020 08:57:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 33/41] linux-user/elfload: Avoid leaking interp_name using GLib memory API Date: Tue, 20 Oct 2020 16:56:48 +0100 Message-Id: <20201020155656.8045-34-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 Fix an unlikely memory leak in load_elf_image(). Fixes: bf858897b7 ("linux-user: Re-use load_elf_image for the main binary.") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-5-richard.henderson@linaro.org Message-Id: <20201003174944.1972444-1-f4bug@amsat.org> Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- linux-user/elfload.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f6022fd7049..1a3150df7c0 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2584,13 +2584,13 @@ static void load_elf_image(const char *image_name, = int image_fd, info->brk =3D vaddr_em; } } else if (eppnt->p_type =3D=3D PT_INTERP && pinterp_name) { - char *interp_name; + g_autofree char *interp_name =3D NULL; =20 if (*pinterp_name) { errmsg =3D "Multiple PT_INTERP entries"; goto exit_errmsg; } - interp_name =3D malloc(eppnt->p_filesz); + interp_name =3D g_malloc(eppnt->p_filesz); if (!interp_name) { goto exit_perror; } @@ -2609,7 +2609,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, errmsg =3D "Invalid PT_INTERP entry"; goto exit_errmsg; } - *pinterp_name =3D interp_name; + *pinterp_name =3D g_steal_pointer(&interp_name); #ifdef TARGET_MIPS } else if (eppnt->p_type =3D=3D PT_MIPS_ABIFLAGS) { Mips_elf_abiflags_v0 abiflags; @@ -2961,7 +2961,7 @@ int load_elf_binary(struct linux_binprm *bprm, struct= image_info *info) if (elf_interpreter) { info->load_bias =3D interp_info.load_bias; info->entry =3D interp_info.entry; - free(elf_interpreter); + g_free(elf_interpreter); } =20 #ifdef USE_ELF_CORE_DUMP --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603211654; cv=none; d=zohomail.com; s=zohoarc; b=SqSxSUiDzwCh0NpD1wu/0bVZBJtHEE7K3Hz8BbFSBup7luTulCVQNUbxNDwCITHIhhZbPwY8WzNO6TfWHhNmnFLFL/V3PYngyKH8djedcTrYphH9ROP47KXgOBvQ0Y3vtQiuLDUf44vMqe0eZzHVXHeMt+Fya5ychc1LM/cTcuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603211654; h=Content-Type:Content-Transfer-Encoding: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=5nfpzWU6BWZQ/unvn/jtnNuBbIIj9jq3hDXWSf3EW64=; b=XbhaUlKTgPMUcG1acw4+12iES7/AbvvzYFw8RCo6f6iUPjbSImRfLKowMNqjZYSpNgtoqFuO5acLiSrzdKhEb4udH4VWQTQUAPJbwLoFkMDtU9iE0TK60FAhm/f/K4XYA864Zk2AIyf4+ahUtJKcIXsEE4oqNOK/m9F9fk/DWbU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603211654636430.5877952738108; Tue, 20 Oct 2020 09:34:14 -0700 (PDT) Received: from localhost ([::1]:55720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuaT-0002Y8-Fl for importer@patchew.org; Tue, 20 Oct 2020 12:34:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1K-0005a9-RD for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:54 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:40663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1H-0003xo-0F for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:54 -0400 Received: by mail-wr1-x441.google.com with SMTP id h5so2783520wrv.7 for ; Tue, 20 Oct 2020 08:57:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5nfpzWU6BWZQ/unvn/jtnNuBbIIj9jq3hDXWSf3EW64=; b=HGoG4XUh3DL0F8obt22WCybl0g//prPVx+o72G1ITdvpwt3pyGpCEw0RPz+d5yZVDE AjswTHNn2R2CBtgmbz5wdheTTbAJCI8xTv04TGDvPdaIQPfgh1sflPXgUsTeyQGrpJL9 Sl93tWpzSjP+wjiiCSOTq3IuSrfxy15Kzwf7sy+i6jqr0ayejP8aI/OmbsO0SmiwX7HW IDtWZpD2oCj6cWh/BF8Z3ZDoDfpBbpeiYKjbq5wqR/UBdAZA2FfR44SPMEeLo0Tg/+TY uo1uDzT/5vG/gLbEA43TSBFwx+Z47UnyB4MGwT2iP9QeTeD3w4hjkEvv/tLuj39Mr0fR 2AnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5nfpzWU6BWZQ/unvn/jtnNuBbIIj9jq3hDXWSf3EW64=; b=FTKO+oa65Sf2OhcrKiGfDiQXCmXKUIoErtiuAZQhny1m3wMqaZT9MeRJhkKtAjixfC ybA9kCuGTFIgo+4oJ2ej74YJt9aVBArxNSYY8424hLmWMZHbnCb7alzlIvfalRfLdu9f z+duudx3/IPE6M2SmacpdzTqzUOq5Vd68i3agFFPefs19sXKNgOSnEot/3Wp/j6TRjFB KC8qpqBEJeiKkfYfT8eR6OWzlfnbjiVQodKXIiifTr7KI5iPHxkGOiVslvjXGkj98Pjc 03s3E24Z/CGEVfTSh68gOyuMuCaru0sGvqPDkIbZ/aokwo0QAJixvpPlTr8zOSx2rbyc K4lw== X-Gm-Message-State: AOAM530Y6yK/JExWYCSD2UnrqCHDeyqBKaxgp/8fmFewxztELMYNLoXc GphZRfmJz8pxn6I1ruADz3pBocJU6eoJTg== X-Google-Smtp-Source: ABdhPJwZMerkEdTq3/vyE5ficgxRR5GfXmsi2uHVXgNYWwOaDMdDDO0s7bwLmOjPRkpsOQDNzT185w== X-Received: by 2002:a5d:4ed2:: with SMTP id s18mr4281079wrv.36.1603209469250; Tue, 20 Oct 2020 08:57:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 34/41] linux-user/elfload: Fix coding style in load_elf_image Date: Tue, 20 Oct 2020 16:56:49 +0100 Message-Id: <20201020155656.8045-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson Fixing this now will clarify following patches. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201016184207.786698-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/elfload.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 1a3150df7c0..290ef70222b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2531,9 +2531,15 @@ static void load_elf_image(const char *image_name, i= nt image_fd, abi_ulong vaddr, vaddr_po, vaddr_ps, vaddr_ef, vaddr_em, vaddr= _len; int elf_prot =3D 0; =20 - if (eppnt->p_flags & PF_R) elf_prot =3D PROT_READ; - if (eppnt->p_flags & PF_W) elf_prot |=3D PROT_WRITE; - if (eppnt->p_flags & PF_X) elf_prot |=3D PROT_EXEC; + if (eppnt->p_flags & PF_R) { + elf_prot |=3D PROT_READ; + } + if (eppnt->p_flags & PF_W) { + elf_prot |=3D PROT_WRITE; + } + if (eppnt->p_flags & PF_X) { + elf_prot |=3D PROT_EXEC; + } =20 vaddr =3D load_bias + eppnt->p_vaddr; vaddr_po =3D TARGET_ELF_PAGEOFFSET(vaddr); --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210425; cv=none; d=zohomail.com; s=zohoarc; b=IwOMdzBqVK2kuRfUNHqikls74wBlraWc9KmscQA1BsyInpzgEz+9YMNX1YDXbwW1o4pqLdXCH16ZcC3hqKoD/rg0qFdcTpTeTNWZQpRiNQYNP3k9ApftXVDPUfjXKDDFVCJaRmAFQCmvANB198sEwRJbkPp9LhgNKSezRXqGk7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210425; h=Content-Type:Content-Transfer-Encoding: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=RtcPvqNCOS79G2dgK0yUnCFnAWOUpfEt7w3PR2fLO38=; b=gzBP1enndanLBX12+4zMyr3jejf5SKtWFFr6561k+/KWSkyf0s2ndcoVgvNOKk2cLyAgTzsxpMfXBdX3wF2yFHVhA1WA0jTXot6jwNQsirZGTX6m1g4b8ZNAJtN8PDfxQ9NG7LvV2oP0yttswnmHbeVJoMD0w9i5D3DvIzvSE1Y= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210425385927.9931561463359; Tue, 20 Oct 2020 09:13:45 -0700 (PDT) Received: from localhost ([::1]:50028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuGe-0000Nb-8M for importer@patchew.org; Tue, 20 Oct 2020 12:13:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1L-0005bT-C6 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:56 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1I-0003y3-OF for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:55 -0400 Received: by mail-wm1-x343.google.com with SMTP id a72so2331641wme.5 for ; Tue, 20 Oct 2020 08:57:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RtcPvqNCOS79G2dgK0yUnCFnAWOUpfEt7w3PR2fLO38=; b=jnungbFoI3TRJTAOm1lXL+oJp8v28bYk50DK+TFDxmyrpxDGyinyCYnIGY/hozYrfR REP3AVhzgVwD01Xj2BcyDDZfXhLAjtqdOYbn63KBb9yD46VPs0HLoswu1YHawSa4/Na9 optrtuWh4Qct/SzE5Hj0W9VAQWj2hui2EoYG+Kz+a43ER0XQIoOKijsxjAv2Bdp1s5Om Cq4brvuzhVGZsSloFRiFO7JZyw/2YVFhLADxkne39f2cz/tiiFr3pUt1cdQqA83rF8XG nwkhjY6GQPx/IKydxzN7gVUw0HJhtt/kPtpR5O0l/DxqpLepFZspIpJRFiGpnw4nVpGF RczA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RtcPvqNCOS79G2dgK0yUnCFnAWOUpfEt7w3PR2fLO38=; b=rqNYVmmKHdbWwrRVsBCYxDs2pXnlRmcWYp7HgFiSuti0lEMvkZXYfCR+O4/tWnelxe jp8DJCbY2EV2H/0hPPNsZUngHpei3G9AT8UN0uK1kAFe1smBiXqytaH0uAF+w2XucGPQ cLo/4HBB+b67PAKk5+p82IFyucZbhMSduWiXS05XFcF3GWLHLUHKICLa5N/TFVEujm0y odkABNtgHVCqcpaihAC9a0IfNfIrtUpGwwp+0onoQYnTKjMzad3i4mpq8Yr0H71SMWHR PHqMRNl/PQgM/nqdjT0qwiaauRq1l5SVOD84hC+2mEso+8abxVFdgVmiFsxXuU4AD1WL 1sng== X-Gm-Message-State: AOAM532oFVYhGFGjr2xYQm10HZSA8zErF+JLSFE/GHT10OZwYz2zN2Bv kGLspT5BMl9KDW29nzLcWv/TDhuoGoLJZw== X-Google-Smtp-Source: ABdhPJxsUd7wY8n9dqYbsAAV3q5oKszA0EtD8PIkdvBxbQH7IC9dR31KqTSHPAo1tayy2QiM40NQKw== X-Received: by 2002:a1c:cc07:: with SMTP id h7mr3803798wmb.55.1603209470976; Tue, 20 Oct 2020 08:57:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 35/41] linux-user/elfload: Adjust iteration over phdr Date: Tue, 20 Oct 2020 16:56:50 +0100 Message-Id: <20201020155656.8045-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson The second loop uses a loop induction variable, and the first does not. Transform the first to match the second, to simplify a following patch moving code between them. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201016184207.786698-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/elfload.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 290ef70222b..210592aa90a 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2426,17 +2426,18 @@ static void load_elf_image(const char *image_name, = int image_fd, loaddr =3D -1, hiaddr =3D 0; info->alignment =3D 0; for (i =3D 0; i < ehdr->e_phnum; ++i) { - if (phdr[i].p_type =3D=3D PT_LOAD) { - abi_ulong a =3D phdr[i].p_vaddr - phdr[i].p_offset; + struct elf_phdr *eppnt =3D phdr + i; + if (eppnt->p_type =3D=3D PT_LOAD) { + abi_ulong a =3D eppnt->p_vaddr - eppnt->p_offset; if (a < loaddr) { loaddr =3D a; } - a =3D phdr[i].p_vaddr + phdr[i].p_memsz; + a =3D eppnt->p_vaddr + eppnt->p_memsz; if (a > hiaddr) { hiaddr =3D a; } ++info->nsegs; - info->alignment |=3D phdr[i].p_align; + info->alignment |=3D eppnt->p_align; } } =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210571; cv=none; d=zohomail.com; s=zohoarc; b=EFreF1Zisy83UpUC7y0bUjFK/jiszC+U5WGnVgebJIPZjgdB4fHp7GZPgHpHH4UV/5FGJH/xh4WSuFMisYqbhae/sH2XAb1BjIcCL9Ld4QFB+Sf6emrYQr4a9QVkffP3Jm9D7y++tb093oZH+c7C2v5OoOn5RYlS5nIIUmc8xt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210571; h=Content-Transfer-Encoding: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=yLHP+MWM/kiQHhSksWpmIgOl71BV9WcE6VdFocoDUmM=; b=D+JAI1fiLlM9aF6g3+ZtpkK2HPKn6lMflWuOo2MOwt1jMl/VduGTcKjYupKFub+ynzc72tG4OEQ/KHS5TJcVFxqfDmoAhrxtlzzrWcYOP6Zmflo9zCpX6vmI63ET1lT2IrVrrERRieYD9qCw71Tc9f7L2yuOdXzmeq1oiKK71bY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210571986692.2111834697439; Tue, 20 Oct 2020 09:16:11 -0700 (PDT) Received: from localhost ([::1]:58308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuJ0-0003uC-TT for importer@patchew.org; Tue, 20 Oct 2020 12:16:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1N-0005cC-Aq for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:57 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:55474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1K-0003yA-Ez for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:57 -0400 Received: by mail-wm1-x342.google.com with SMTP id a72so2331703wme.5 for ; Tue, 20 Oct 2020 08:57:53 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yLHP+MWM/kiQHhSksWpmIgOl71BV9WcE6VdFocoDUmM=; b=ZUgpZsMCHfjVYDKXz1bdTr0OOwB7ZSyfRxRBihqoS3gHhCcbNvDUCfRTPD3bOlkpgY W1rSq/pfHQg3diwd53N1kvridyx6c32WeeVlGPmFc0+D1B4icZzurAZRQz3Q1/K6Qa2c JWxe8hB4aJXY2jeIBQ6ATLtMUCLLC+UHUmZc947o7fWhwe7ysZafdlJRPM8GXjW6ok7j c52w73r4N9aF2ThE1UVwMq3wGmx2iU/JcWtFSou9wQfbFqwZhnYGf1spO+q2QdCD6wuz 9mgDIsE0eTZSWMRdV2xW2t8cr3Z3eTj3BiKAl2ucR9qO2B6zTZn78mEgXb/2uHbHq4W8 KZnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yLHP+MWM/kiQHhSksWpmIgOl71BV9WcE6VdFocoDUmM=; b=uVRqwCmP0NwxwIK0E8on5AODdWJ0SrdjOOJO2HvpWmdUPrMBWzIaxEaWszhJ2fha7u 7bYzRAILa9PobTTrMcTUH+YVLTmPiG9jOelVV0NrUTdvxgBStzqi+b+LMDeOfrlXYqUJ qANtYKxPqq9JxsyuLfNeyMp8SrB/1tf4gOA+bgqH4igpfOlWkkt2dIXYz0iGE9IbMG3T eE2uB8XdkrcZ5VoxVYcS43PVEZjYI4jtLUDhLm7ZDEBzByQcG3QMQghDAhOuqNu4xSm1 nzcFXJGxepEMRO4fMrNgDwKXTLhffwqDDPtEsDPxYt8f7iJusQpccOtLWTAHc23ReBPo LJAA== X-Gm-Message-State: AOAM533S37wQ4kQH8k0G/QmG1bQJ0nC7BC6W7NxhWxcY7wbCkVfQAz+h 2/7yCjMmTjVpEo4cMcg66TDtqTFS0Mj+ww== X-Google-Smtp-Source: ABdhPJyJwc6Im9u/mR08HkGqduHDUQAGU2yuhpEFzRQkSl/qsdF0ight27oaaa0cISnfDPW/tpesow== X-Received: by 2002:a7b:c349:: with SMTP id l9mr3607936wmj.148.1603209471934; Tue, 20 Oct 2020 08:57:51 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 36/41] linux-user/elfload: Move PT_INTERP detection to first loop Date: Tue, 20 Oct 2020 16:56:51 +0100 Message-Id: <20201020155656.8045-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::342; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson For BTI, we need to know if the executable is static or dynamic, which means looking for PT_INTERP earlier. Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-8-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- linux-user/elfload.c | 60 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 210592aa90a..107a628a9ee 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2421,8 +2421,10 @@ static void load_elf_image(const char *image_name, i= nt image_fd, =20 mmap_lock(); =20 - /* Find the maximum size of the image and allocate an appropriate - amount of memory to handle that. */ + /* + * Find the maximum size of the image and allocate an appropriate + * amount of memory to handle that. Locate the interpreter, if any. + */ loaddr =3D -1, hiaddr =3D 0; info->alignment =3D 0; for (i =3D 0; i < ehdr->e_phnum; ++i) { @@ -2438,6 +2440,33 @@ static void load_elf_image(const char *image_name, i= nt image_fd, } ++info->nsegs; info->alignment |=3D eppnt->p_align; + } else if (eppnt->p_type =3D=3D PT_INTERP && pinterp_name) { + g_autofree char *interp_name =3D NULL; + + if (*pinterp_name) { + errmsg =3D "Multiple PT_INTERP entries"; + goto exit_errmsg; + } + interp_name =3D g_malloc(eppnt->p_filesz); + if (!interp_name) { + goto exit_perror; + } + + if (eppnt->p_offset + eppnt->p_filesz <=3D BPRM_BUF_SIZE) { + memcpy(interp_name, bprm_buf + eppnt->p_offset, + eppnt->p_filesz); + } else { + retval =3D pread(image_fd, interp_name, eppnt->p_filesz, + eppnt->p_offset); + if (retval !=3D eppnt->p_filesz) { + goto exit_perror; + } + } + if (interp_name[eppnt->p_filesz - 1] !=3D 0) { + errmsg =3D "Invalid PT_INTERP entry"; + goto exit_errmsg; + } + *pinterp_name =3D g_steal_pointer(&interp_name); } } =20 @@ -2590,33 +2619,6 @@ static void load_elf_image(const char *image_name, i= nt image_fd, if (vaddr_em > info->brk) { info->brk =3D vaddr_em; } - } else if (eppnt->p_type =3D=3D PT_INTERP && pinterp_name) { - g_autofree char *interp_name =3D NULL; - - if (*pinterp_name) { - errmsg =3D "Multiple PT_INTERP entries"; - goto exit_errmsg; - } - interp_name =3D g_malloc(eppnt->p_filesz); - if (!interp_name) { - goto exit_perror; - } - - if (eppnt->p_offset + eppnt->p_filesz <=3D BPRM_BUF_SIZE) { - memcpy(interp_name, bprm_buf + eppnt->p_offset, - eppnt->p_filesz); - } else { - retval =3D pread(image_fd, interp_name, eppnt->p_filesz, - eppnt->p_offset); - if (retval !=3D eppnt->p_filesz) { - goto exit_perror; - } - } - if (interp_name[eppnt->p_filesz - 1] !=3D 0) { - errmsg =3D "Invalid PT_INTERP entry"; - goto exit_errmsg; - } - *pinterp_name =3D g_steal_pointer(&interp_name); #ifdef TARGET_MIPS } else if (eppnt->p_type =3D=3D PT_MIPS_ABIFLAGS) { Mips_elf_abiflags_v0 abiflags; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210845; cv=none; d=zohomail.com; s=zohoarc; b=N0QdrBkxS/KpSrT87W6Qh9gUuLMwsHQS3CQWVsTo9dg4aKl0bZlajNXaou/yPDWDw8ce3x9yTIL0CxqaXQZfo9LMwNoVRaZxOGnYlsDI4RsdqRlq31pGB2HmYp2zXMdUYTF7PU36wIWVxUkakemym5eHYxP8Wlmb7PWSvXm+Iks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210845; h=Content-Type:Content-Transfer-Encoding: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=QqP01R21sgmyFZ/I6+4QMRt1fDE0WU4Y2e7+0/E2OkY=; b=kxcAi0VaOuj9Xi+s5XlbCMH/veDPQ5Yv32yDqgtcZtDCxuGhBz/665R4CORiEBdGhrW3+ITazx8KKfAdlB+9O8CWMdtF0emnemChwHVjzInVGAXWjbBAgfw+kRdTncPih+6K8skZmqgKhRLd26ZYQveXjU2UOrmgnASnBd/fFyY= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210845318300.17547091876327; Tue, 20 Oct 2020 09:20:45 -0700 (PDT) Received: from localhost ([::1]:45792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuNQ-0002H3-GH for importer@patchew.org; Tue, 20 Oct 2020 12:20:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1Q-0005hV-09 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:58:00 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:37718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1L-0003yP-0m for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:59 -0400 Received: by mail-wm1-x32b.google.com with SMTP id c16so2516622wmd.2 for ; Tue, 20 Oct 2020 08:57:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QqP01R21sgmyFZ/I6+4QMRt1fDE0WU4Y2e7+0/E2OkY=; b=GNwmwZm9oGYypAdpzLftVzAn4085kwNhqERV2Cg/ww0sowf/7GgdgKWYG5ZdffamTd 2b0mSZKEHDsawhEdZ7UgBGji9WIpsfiaw+SheTUuBAn9CKuqNy1tuAURNLDEAfPjWs5r yLG+vX2ixjxXx3lmg25hdzOC8OZWt5wyPoa2rn/LI00HwQKm3shhURjXcczIKUR+jwMH E3/a8n/QXgLtohJZL57uHnrUiVebeE6AwmNcgvKsuPRfixe9aeO/TGi73nctWSueTbuj Qy3jGA6t4rrRTL4VT/MfFviV1l9ALlToPyA3ELaxqctUMdM1gS34Zbj0W1Xvx1tjiN9R UsHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QqP01R21sgmyFZ/I6+4QMRt1fDE0WU4Y2e7+0/E2OkY=; b=tKeBrmNIv2qm0BFayLJO5/AkkBtQIBdChBSCOxEGf+UtGqMu8K8+9ThzzedXvrZJTi ARJgbKLuqS/SV3WMFrflCw8yt6SrTterV+0PIVDw5NTOZIT0hoAqRkjgnkzQHVR76Bcl I/5pGAFX649L4RIoF0C7fdl0Hb6PksuQfwmMjoQfnAW6omsyjkk1+pmhUmPiSrW5enD+ YVPBrBnhX+BDg0Uy6Pwun1LT4zwXdBIHvmzwxDri9zyeW5H3zze1IeFJ9zbO2YD44Nmo Ehy8kUhc5C7N2IySuGGycl/2WjV6q0rgr2oEiFnsY9+I6d2mJhU25xP9psZSsnNJQXn/ CTKg== X-Gm-Message-State: AOAM531VlH1csY3eSXYLFxmR25loni2vGoT4o2W7ALGiAE7iRdJhOXv7 MVTxGC+Wy/QJoM6TEyjaYIgTz3jxDU5Cdg== X-Google-Smtp-Source: ABdhPJyg0a6ODJtSNPGFYf3+Oq/RKS3FDhJqPjU0JaU9lWk/DDyn+Wmx3VbuGKLFpyX5iLOTKRMgRA== X-Received: by 2002:a7b:c081:: with SMTP id r1mr3592726wmh.158.1603209473039; Tue, 20 Oct 2020 08:57:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/41] linux-user/elfload: Use Error for load_elf_image Date: Tue, 20 Oct 2020 16:56:52 +0100 Message-Id: <20201020155656.8045-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, T_SPF_TEMPERROR=0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson This is a bit clearer than open-coding some of this with a bare c string. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201016184207.786698-9-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/elfload.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 107a628a9ee..56fbda93d02 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -12,6 +12,7 @@ #include "qemu/guest-random.h" #include "qemu/units.h" #include "qemu/selfmap.h" +#include "qapi/error.h" =20 #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -2392,15 +2393,16 @@ static void load_elf_image(const char *image_name, = int image_fd, struct elf_phdr *phdr; abi_ulong load_addr, load_bias, loaddr, hiaddr, error; int i, retval; - const char *errmsg; + Error *err =3D NULL; =20 /* First of all, some simple consistency checks */ - errmsg =3D "Invalid ELF image for this architecture"; if (!elf_check_ident(ehdr)) { + error_setg(&err, "Invalid ELF image for this architecture"); goto exit_errmsg; } bswap_ehdr(ehdr); if (!elf_check_ehdr(ehdr)) { + error_setg(&err, "Invalid ELF image for this architecture"); goto exit_errmsg; } =20 @@ -2444,13 +2446,11 @@ static void load_elf_image(const char *image_name, = int image_fd, g_autofree char *interp_name =3D NULL; =20 if (*pinterp_name) { - errmsg =3D "Multiple PT_INTERP entries"; + error_setg(&err, "Multiple PT_INTERP entries"); goto exit_errmsg; } + interp_name =3D g_malloc(eppnt->p_filesz); - if (!interp_name) { - goto exit_perror; - } =20 if (eppnt->p_offset + eppnt->p_filesz <=3D BPRM_BUF_SIZE) { memcpy(interp_name, bprm_buf + eppnt->p_offset, @@ -2459,11 +2459,11 @@ static void load_elf_image(const char *image_name, = int image_fd, retval =3D pread(image_fd, interp_name, eppnt->p_filesz, eppnt->p_offset); if (retval !=3D eppnt->p_filesz) { - goto exit_perror; + goto exit_read; } } if (interp_name[eppnt->p_filesz - 1] !=3D 0) { - errmsg =3D "Invalid PT_INTERP entry"; + error_setg(&err, "Invalid PT_INTERP entry"); goto exit_errmsg; } *pinterp_name =3D g_steal_pointer(&interp_name); @@ -2520,7 +2520,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, (ehdr->e_type =3D=3D ET_EXEC ? MAP_FIXED : 0), -1, 0); if (load_addr =3D=3D -1) { - goto exit_perror; + goto exit_mmap; } load_bias =3D load_addr - loaddr; =20 @@ -2587,7 +2587,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, image_fd, eppnt->p_offset - vaddr_po); =20 if (error =3D=3D -1) { - goto exit_perror; + goto exit_mmap; } } =20 @@ -2623,7 +2623,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, } else if (eppnt->p_type =3D=3D PT_MIPS_ABIFLAGS) { Mips_elf_abiflags_v0 abiflags; if (eppnt->p_filesz < sizeof(Mips_elf_abiflags_v0)) { - errmsg =3D "Invalid PT_MIPS_ABIFLAGS entry"; + error_setg(&err, "Invalid PT_MIPS_ABIFLAGS entry"); goto exit_errmsg; } if (eppnt->p_offset + eppnt->p_filesz <=3D BPRM_BUF_SIZE) { @@ -2633,7 +2633,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, retval =3D pread(image_fd, &abiflags, sizeof(Mips_elf_abif= lags_v0), eppnt->p_offset); if (retval !=3D sizeof(Mips_elf_abiflags_v0)) { - goto exit_perror; + goto exit_read; } } bswap_mips_abiflags(&abiflags); @@ -2658,13 +2658,16 @@ static void load_elf_image(const char *image_name, = int image_fd, =20 exit_read: if (retval >=3D 0) { - errmsg =3D "Incomplete read of file header"; - goto exit_errmsg; + error_setg(&err, "Incomplete read of file header"); + } else { + error_setg_errno(&err, errno, "Error reading file header"); } - exit_perror: - errmsg =3D strerror(errno); + goto exit_errmsg; + exit_mmap: + error_setg_errno(&err, errno, "Error mapping file"); + goto exit_errmsg; exit_errmsg: - fprintf(stderr, "%s: %s\n", image_name, errmsg); + error_reportf_err(err, "%s: ", image_name); exit(-1); } =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210733; cv=none; d=zohomail.com; s=zohoarc; b=nnLvxAChrEAogMRkAOC1jkIq3JIzecyE2BTM0m7riAs5GDpUga+XttM/CBu7jOPYBO9vFizH+tZrhztkNZge68rbg5yZfUjgxlRz3NDk247TM8/4BEtJAEuXq3nGI0v7nLqsN7SjuD++S3nWIJbN8NI9Kvy+F2ErPcc1JgmNfk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210733; h=Content-Type:Content-Transfer-Encoding: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=XT6Iram+4m2dzPuKNhFGf6Ll1daGrbT5FFIybyhVjnU=; b=TI9Ln9y8aXuJe5ou/4maqunU/cFrPW27XB31wccLDf2j+iiwYlWThb1/KaersZ0EGnJZ5PVAD8ehdUTUgIfTqqy6QhrzP0q6UG65N65He6nq41eer3kZF9g1IUhADZr+/hPAN1BczUK6h8CViBQUgZ5tqAGm+S3o272b00Vf5V8= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210733361192.71437533752862; Tue, 20 Oct 2020 09:18:53 -0700 (PDT) Received: from localhost ([::1]:38462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuLc-0007gW-Gv for importer@patchew.org; Tue, 20 Oct 2020 12:18:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1P-0005f4-5y for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:59 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1N-0003yd-08 for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:57:58 -0400 Received: by mail-wr1-x443.google.com with SMTP id n18so2800834wrs.5 for ; Tue, 20 Oct 2020 08:57:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XT6Iram+4m2dzPuKNhFGf6Ll1daGrbT5FFIybyhVjnU=; b=ddOfYoVovijzVtt/7T8yhNCSKRIw76G+qZX6iaFVStKIH+9a3Clrt5DyzVD7auzW9t rJbrjel8vwN8cBaZbuizZubIOoovRdx8DWbMvkOkoXBl0wWnPIdAB+oDLiMxB17JPgz3 l/1+E2JNTbMGDczisPgGtj0SReaTLfSd2fPxtvC9Lt5kVtqAM1YTlofviEOy/r1ppSB5 2JOeRjuHeKhInVvPVsZ0rZDU8J4gDsWbhk3Nxbck8XZxn7RtIH3cdDB2VSyqQU6Pi2dx PyrMf4z2BDikVEA5LiPFAxe+/zMiifX52zmzPDts7PfWgp7yrj3vpv29DpNybp0ZWgHw /GEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XT6Iram+4m2dzPuKNhFGf6Ll1daGrbT5FFIybyhVjnU=; b=ACV3DtcyYaJvUM2hMhuiLn105SNyCPbKjjYYgS+qN4r5I1yzYPMBvJNZ8e9j8efWcN xTWg0T56GOXU6WuK3lpTGicZY9/cJ5HvwH+nTiv16Baf3/F349RkqYobAFZDRPFC8fju w8FKtgfRH0exENjcqF4zMFwmCtauF50TWLFExk6Litliohls0nK6j1/6Vl+DEM7G/3Qj qIYpJwH6lFu/+RyGBFJ6tcJNxqBIQuS31wxeFDcKxL8RMDsnRYeM9sGGkR2p4cDEPKVh Fsem6xUe7loIA+GdVn6BtlV3DwcG695NACSWfuCOIo/BUncSerXlk/xiHOBI9zan7Xmr NbeA== X-Gm-Message-State: AOAM530XBsMQ/yR1QkLQnzGCg/JbuL9stQjOPD0JngXLR/Hmhru2gghy AGEGeaKuq9fK0CA7wFLgpuCO9oXefQo25g== X-Google-Smtp-Source: ABdhPJyxGpL9a7/O76L4j2qJ8fUQiO4aa9gpT9QdqSbUVXwyMwcf4pJIzry2yy+ZAVozL8OLq8ZMdw== X-Received: by 2002:adf:f3d2:: with SMTP id g18mr4188542wrp.367.1603209474265; Tue, 20 Oct 2020 08:57:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 38/41] linux-user/elfload: Use Error for load_elf_interp Date: Tue, 20 Oct 2020 16:56:53 +0100 Message-Id: <20201020155656.8045-39-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson This is slightly clearer than just using strerror, though the different forms produced by error_setg_file_open and error_setg_errno isn't entirely convenient. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20201016184207.786698-10-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/elfload.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 56fbda93d02..04c04bc2602 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2675,26 +2675,27 @@ static void load_elf_interp(const char *filename, s= truct image_info *info, char bprm_buf[BPRM_BUF_SIZE]) { int fd, retval; + Error *err =3D NULL; =20 fd =3D open(path(filename), O_RDONLY); if (fd < 0) { - goto exit_perror; + error_setg_file_open(&err, errno, filename); + error_report_err(err); + exit(-1); } =20 retval =3D read(fd, bprm_buf, BPRM_BUF_SIZE); if (retval < 0) { - goto exit_perror; + error_setg_errno(&err, errno, "Error reading file header"); + error_reportf_err(err, "%s: ", filename); + exit(-1); } + if (retval < BPRM_BUF_SIZE) { memset(bprm_buf + retval, 0, BPRM_BUF_SIZE - retval); } =20 load_elf_image(filename, fd, info, NULL, bprm_buf); - return; - - exit_perror: - fprintf(stderr, "%s: %s\n", filename, strerror(errno)); - exit(-1); } =20 static int symfind(const void *s0, const void *s1) --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603211101; cv=none; d=zohomail.com; s=zohoarc; b=GNTeD/LMUB16SlCfSQ6XuCpWUEhmImGL4MMqrxHfZADWYTVDTALkKMOIqhQu492sEeZ/jrHsEVpisgNb8U3s+5QeF5AgcJIUC4h91NtrWlYlG4DEv6GSWuQcKV27pDsSABofG/LpUXK6a2xxOLvDIqslITE9UqCUr8z1KN4jPHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603211101; h=Content-Transfer-Encoding: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=6VhfjSQ7dadSBZQDzl5o3+J5jUl822Cfki/U1O75AEo=; b=RFofsV8Yf1q3fCfViaVNJLko2tsJsweQNDxlAELkXFXNrZFaWYfcQS8/2WrzcI7Nc/3ioer0YQkC/JPCz2Hh3W4gLhmjeSzqYnYM8Xjce6kxnE5xWHgCGO4fFVo12f2g8Bgwh9izOnrPPQzveeBdUwWl4mwUhwwh67yX3LEHjAw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603211101503396.75451604204477; Tue, 20 Oct 2020 09:25:01 -0700 (PDT) Received: from localhost ([::1]:33804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuRX-0000pL-12 for importer@patchew.org; Tue, 20 Oct 2020 12:24:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1R-0005lt-Ld for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:58:01 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:42974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1N-0003yl-JS for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:58:01 -0400 Received: by mail-wr1-x42e.google.com with SMTP id j7so2774469wrt.9 for ; Tue, 20 Oct 2020 08:57:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6VhfjSQ7dadSBZQDzl5o3+J5jUl822Cfki/U1O75AEo=; b=wiSxlMapMBn7yCYtzwiLitJDdFIsYpXfa/RQ8Op7fhSAqpMh3uHDe7xna2TvRhSL0q XQ17FAy64NW3BB8v6Y+9LNjzMkVzLKFF/HfCRKWnixhSYo73e39WsgvQAeRN5czqx78b 2WyxAabIN7rhopmbMHsu06gr3CTzd9LqgooRyFT9mBSw2gh5qExPHkD1ekB42opJS8FT msaWhQehcS3n5RMxbwKWayHNcusqeRJSsyqkJAIeChLtSiMOBPTKuhe5H1zGZi2B/eLJ pAI+coUnj6EDxkPuM3wwZzvRVMoEvpGUXe8jAv5zka034I/HMEu233fQWsOs8+PglT51 0Kpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6VhfjSQ7dadSBZQDzl5o3+J5jUl822Cfki/U1O75AEo=; b=uED1Q+dVuQgDejWjbzOHl7s34w5S0+Shl9F8JX0AiwvPUng19DpOfxaI/N26afkKqs 6WZtG4qTCIH3pxgpLApCwW66fZ/h4wlsTouSmJJW7Wite6s9OWrCSMuMiVJLRpkRaGwL 8IkajtomTxiokNh/AN1JuzfuyKyrBQYb24TTkUU7OYNscU95YvNXoY7TZJb5Mm1lCpHm EVVQSFwumY9uCT6lfNioogKC4CI9RkVNGzoOxrjhRxuzMQmN+nch2ne54jKvnsv6cdRI Hr6yLC8peAVmj7WdfPtUdVOLN3rVNvcLQJXFyt3Z8Ub0Qtjy2VgqGEzbH7YU9bn40Af6 a2Zg== X-Gm-Message-State: AOAM531ligEvmptGsUAXyW7bnmQukavNLZHVX4SW/ACiEAGC9BNmkvAk pXOAUaQxk68cjg5SZQUy7uDyr3veviNCmA== X-Google-Smtp-Source: ABdhPJyiLCuTmO5mLtWS9X5LTVM6fXCUw3ommdKCc5OT1dJkt5QAUUNXSeDFLMHgirosboCksFtBRw== X-Received: by 2002:adf:dd46:: with SMTP id u6mr4271482wrm.295.1603209475700; Tue, 20 Oct 2020 08:57:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 39/41] linux-user/elfload: Parse NT_GNU_PROPERTY_TYPE_0 notes Date: Tue, 20 Oct 2020 16:56:54 +0100 Message-Id: <20201020155656.8045-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson This is generic support, with the code disabled for all targets. Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-11-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- linux-user/qemu.h | 4 ++ linux-user/elfload.c | 157 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 941ca997228..534753ca125 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -61,6 +61,10 @@ struct image_info { abi_ulong interpreter_loadmap_addr; abi_ulong interpreter_pt_dynamic_addr; struct image_info *other_info; + + /* For target-specific processing of NT_GNU_PROPERTY_TYPE_0. */ + uint32_t note_flags; + #ifdef TARGET_MIPS int fp_abi; int interp_fp_abi; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 04c04bc2602..428dcaa1528 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1522,6 +1522,15 @@ static void elf_core_copy_regs(target_elf_gregset_t = *regs, =20 #include "elf.h" =20 +static bool arch_parse_elf_property(uint32_t pr_type, uint32_t pr_datasz, + const uint32_t *data, + struct image_info *info, + Error **errp) +{ + g_assert_not_reached(); +} +#define ARCH_USE_GNU_PROPERTY 0 + struct exec { unsigned int a_info; /* Use macros N_MAGIC, etc for access */ @@ -2373,6 +2382,150 @@ void probe_guest_base(const char *image_name, abi_u= long guest_loaddr, "@ 0x%" PRIx64 "\n", (uint64_t)guest_base); } =20 +enum { + /* The string "GNU\0" as a magic number. */ + GNU0_MAGIC =3D const_le32('G' | 'N' << 8 | 'U' << 16), + NOTE_DATA_SZ =3D 1 * KiB, + NOTE_NAME_SZ =3D 4, + ELF_GNU_PROPERTY_ALIGN =3D ELF_CLASS =3D=3D ELFCLASS32 ? 4 : 8, +}; + +/* + * Process a single gnu_property entry. + * Return false for error. + */ +static bool parse_elf_property(const uint32_t *data, int *off, int datasz, + struct image_info *info, bool have_prev_typ= e, + uint32_t *prev_type, Error **errp) +{ + uint32_t pr_type, pr_datasz, step; + + if (*off > datasz || !QEMU_IS_ALIGNED(*off, ELF_GNU_PROPERTY_ALIGN)) { + goto error_data; + } + datasz -=3D *off; + data +=3D *off / sizeof(uint32_t); + + if (datasz < 2 * sizeof(uint32_t)) { + goto error_data; + } + pr_type =3D data[0]; + pr_datasz =3D data[1]; + data +=3D 2; + datasz -=3D 2 * sizeof(uint32_t); + step =3D ROUND_UP(pr_datasz, ELF_GNU_PROPERTY_ALIGN); + if (step > datasz) { + goto error_data; + } + + /* Properties are supposed to be unique and sorted on pr_type. */ + if (have_prev_type && pr_type <=3D *prev_type) { + if (pr_type =3D=3D *prev_type) { + error_setg(errp, "Duplicate property in PT_GNU_PROPERTY"); + } else { + error_setg(errp, "Unsorted property in PT_GNU_PROPERTY"); + } + return false; + } + *prev_type =3D pr_type; + + if (!arch_parse_elf_property(pr_type, pr_datasz, data, info, errp)) { + return false; + } + + *off +=3D 2 * sizeof(uint32_t) + step; + return true; + + error_data: + error_setg(errp, "Ill-formed property in PT_GNU_PROPERTY"); + return false; +} + +/* Process NT_GNU_PROPERTY_TYPE_0. */ +static bool parse_elf_properties(int image_fd, + struct image_info *info, + const struct elf_phdr *phdr, + char bprm_buf[BPRM_BUF_SIZE], + Error **errp) +{ + union { + struct elf_note nhdr; + uint32_t data[NOTE_DATA_SZ / sizeof(uint32_t)]; + } note; + + int n, off, datasz; + bool have_prev_type; + uint32_t prev_type; + + /* Unless the arch requires properties, ignore them. */ + if (!ARCH_USE_GNU_PROPERTY) { + return true; + } + + /* If the properties are crazy large, that's too bad. */ + n =3D phdr->p_filesz; + if (n > sizeof(note)) { + error_setg(errp, "PT_GNU_PROPERTY too large"); + return false; + } + if (n < sizeof(note.nhdr)) { + error_setg(errp, "PT_GNU_PROPERTY too small"); + return false; + } + + if (phdr->p_offset + n <=3D BPRM_BUF_SIZE) { + memcpy(¬e, bprm_buf + phdr->p_offset, n); + } else { + ssize_t len =3D pread(image_fd, ¬e, n, phdr->p_offset); + if (len !=3D n) { + error_setg_errno(errp, errno, "Error reading file header"); + return false; + } + } + + /* + * The contents of a valid PT_GNU_PROPERTY is a sequence + * of uint32_t -- swap them all now. + */ +#ifdef BSWAP_NEEDED + for (int i =3D 0; i < n / 4; i++) { + bswap32s(note.data + i); + } +#endif + + /* + * Note that nhdr is 3 words, and that the "name" described by namesz + * immediately follows nhdr and is thus at the 4th word. Further, all + * of the inputs to the kernel's round_up are multiples of 4. + */ + if (note.nhdr.n_type !=3D NT_GNU_PROPERTY_TYPE_0 || + note.nhdr.n_namesz !=3D NOTE_NAME_SZ || + note.data[3] !=3D GNU0_MAGIC) { + error_setg(errp, "Invalid note in PT_GNU_PROPERTY"); + return false; + } + off =3D sizeof(note.nhdr) + NOTE_NAME_SZ; + + datasz =3D note.nhdr.n_descsz + off; + if (datasz > n) { + error_setg(errp, "Invalid note size in PT_GNU_PROPERTY"); + return false; + } + + have_prev_type =3D false; + prev_type =3D 0; + while (1) { + if (off =3D=3D datasz) { + return true; /* end, exit ok */ + } + if (!parse_elf_property(note.data, &off, datasz, info, + have_prev_type, &prev_type, errp)) { + return false; + } + have_prev_type =3D true; + } +} + /* Load an ELF image into the address space. =20 IMAGE_NAME is the filename of the image, to use in error messages. @@ -2467,6 +2620,10 @@ static void load_elf_image(const char *image_name, i= nt image_fd, goto exit_errmsg; } *pinterp_name =3D g_steal_pointer(&interp_name); + } else if (eppnt->p_type =3D=3D PT_GNU_PROPERTY) { + if (!parse_elf_properties(image_fd, info, eppnt, bprm_buf, &er= r)) { + goto exit_errmsg; + } } } =20 --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210986; cv=none; d=zohomail.com; s=zohoarc; b=j87RlQ0kCWH1kKXGOX23O8oEzv+JdCbQIiXEHOCJ28XWlHExfFrUCpKkYStzOS+xwkaFW/3tPuMWbLwbJfpmPmUcfmvpAEnVBNqXXocZkkpwKraNK6+VVQKWU5D3NpS/PjctKoz/hIkokwSHOLalLs1h0Pmutru5sh0XB3emfNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210986; h=Content-Transfer-Encoding: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=8R4Ou6ltaxWaVYPwl0wl/jMrZU+UDDkqwU0qcucYDcc=; b=ULuHZ8dJnZNWw2h4uarY2LVQWZv8ta86GSuadiaVj8qyq46YZhNeO6RjGZrBMBwWibGh7/ZfJWV6NeMKDwFWVvg3LA7WmDWQhzfFnIvLhNNXb01CWi7yiS0196plasyjipj1o0kOnGnZATXYpFXVZAPrRRlo4DUW4hMY/nHQQ04= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160321098691313.291262988735639; Tue, 20 Oct 2020 09:23:06 -0700 (PDT) Received: from localhost ([::1]:54052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuPi-0005qo-00 for importer@patchew.org; Tue, 20 Oct 2020 12:23:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1Q-0005jt-Th for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:58:00 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:42977) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1O-0003yt-TK for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:58:00 -0400 Received: by mail-wr1-x431.google.com with SMTP id j7so2774569wrt.9 for ; Tue, 20 Oct 2020 08:57:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8R4Ou6ltaxWaVYPwl0wl/jMrZU+UDDkqwU0qcucYDcc=; b=RdhuRvpOrnQ5qr4ztKa5yLNPCj52DQ1E9balA/C6PW6zucqfoFU226FZDcbdJTvGPM OZZhdTr+jgSxem1wMNN1ZDRWbiYDlCUd5lFCpK+8rovHDkBgfpPAiU3P2AGJtQVbNL3W PQWRv6N2HyYKU0ZalMm5XAbN0FwV0raAl/6s5FswlT0QtG12nvzknDIgMSFL/sAtfucu 4THzsPBRm+eADL2a25Gxkw9qvzOzcWotrvVMMzcThPwrqDAbefcX5UQDwl+0+5RfBar7 7g+zGrCu3fdMVM4aZCm86EtH7HvGUUIV1oYcgi6mfkbQJXNJ/Yy7IBsZp8jv+hzfMDNo n9Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8R4Ou6ltaxWaVYPwl0wl/jMrZU+UDDkqwU0qcucYDcc=; b=lFXu6i70z6/20I2c66nMdjizX0gBHOhMB8WImwbsslrETR/RrBgNrNARUEZgHftIeA h10VPwOlF8AVqdcKdK0nnDPKMr6aRm4mzntxxvrtiLpW6hiOuD5bd5fNOQLhrv2GlXSW +SAoLYRLjy2T5Qy9NyK7Gv/Vp3FJ40TOolsdtlYzCnu9PCOAobp19HWjai3bIHxQYL4A uAtdgYyCC3zGTbCTj/NiouR6cF5CPXf+OCw1cLvI+P6uBzTq1gxcIT44cPuY+VsxmBHk nWee6N0xFOE0MnokV8WExDsDzKy08WQlh/GnqDYJgDtLTnOg6rafixl2WO4mrLzxpiC2 0qkw== X-Gm-Message-State: AOAM530m7mORaQUKX9x/MU5kWDSxPca7Y71wt3RyCqJWQulWM/CdyZtA Y6FYYhGbOUvk7TgIp62JRlRUAi/y5Pf45w== X-Google-Smtp-Source: ABdhPJyJQA8JF5TfCTVSysBO3omCT3pxmJZqyw5XWu2AwXzgVNU7+k5ckDO5aIbutorlg/+Kb2J0Jg== X-Received: by 2002:adf:f246:: with SMTP id b6mr4265868wrp.111.1603209477126; Tue, 20 Oct 2020 08:57:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 40/41] linux-user/elfload: Parse GNU_PROPERTY_AARCH64_FEATURE_1_AND Date: Tue, 20 Oct 2020 16:56:55 +0100 Message-Id: <20201020155656.8045-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-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::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Richard Henderson Use the new generic support for NT_GNU_PROPERTY_TYPE_0. Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-12-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- linux-user/elfload.c | 48 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 428dcaa1528..bf8c1bd2533 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1522,6 +1522,28 @@ static void elf_core_copy_regs(target_elf_gregset_t = *regs, =20 #include "elf.h" =20 +/* We must delay the following stanzas until after "elf.h". */ +#if defined(TARGET_AARCH64) + +static bool arch_parse_elf_property(uint32_t pr_type, uint32_t pr_datasz, + const uint32_t *data, + struct image_info *info, + Error **errp) +{ + if (pr_type =3D=3D GNU_PROPERTY_AARCH64_FEATURE_1_AND) { + if (pr_datasz !=3D sizeof(uint32_t)) { + error_setg(errp, "Ill-formed GNU_PROPERTY_AARCH64_FEATURE_1_AN= D"); + return false; + } + /* We will extract GNU_PROPERTY_AARCH64_FEATURE_1_BTI later. */ + info->note_flags =3D *data; + } + return true; +} +#define ARCH_USE_GNU_PROPERTY 1 + +#else + static bool arch_parse_elf_property(uint32_t pr_type, uint32_t pr_datasz, const uint32_t *data, struct image_info *info, @@ -1531,6 +1553,8 @@ static bool arch_parse_elf_property(uint32_t pr_type,= uint32_t pr_datasz, } #define ARCH_USE_GNU_PROPERTY 0 =20 +#endif + struct exec { unsigned int a_info; /* Use macros N_MAGIC, etc for access */ @@ -2545,7 +2569,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, struct elfhdr *ehdr =3D (struct elfhdr *)bprm_buf; struct elf_phdr *phdr; abi_ulong load_addr, load_bias, loaddr, hiaddr, error; - int i, retval; + int i, retval, prot_exec; Error *err =3D NULL; =20 /* First of all, some simple consistency checks */ @@ -2712,6 +2736,26 @@ static void load_elf_image(const char *image_name, i= nt image_fd, info->brk =3D 0; info->elf_flags =3D ehdr->e_flags; =20 + prot_exec =3D PROT_EXEC; +#ifdef TARGET_AARCH64 + /* + * If the BTI feature is present, this indicates that the executable + * pages of the startup binary should be mapped with PROT_BTI, so that + * branch targets are enforced. + * + * The startup binary is either the interpreter or the static executab= le. + * The interpreter is responsible for all pages of a dynamic executabl= e. + * + * Elf notes are backward compatible to older cpus. + * Do not enable BTI unless it is supported. + */ + if ((info->note_flags & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) + && (pinterp_name =3D=3D NULL || *pinterp_name =3D=3D 0) + && cpu_isar_feature(aa64_bti, ARM_CPU(thread_cpu))) { + prot_exec |=3D TARGET_PROT_BTI; + } +#endif + for (i =3D 0; i < ehdr->e_phnum; i++) { struct elf_phdr *eppnt =3D phdr + i; if (eppnt->p_type =3D=3D PT_LOAD) { @@ -2725,7 +2769,7 @@ static void load_elf_image(const char *image_name, in= t image_fd, elf_prot |=3D PROT_WRITE; } if (eppnt->p_flags & PF_X) { - elf_prot |=3D PROT_EXEC; + elf_prot |=3D prot_exec; } =20 vaddr =3D load_bias + eppnt->p_vaddr; --=20 2.20.1 From nobody Fri May 17 16:17:58 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=1603210993; cv=none; d=zohomail.com; s=zohoarc; b=dq1smIjN2QHlczuqoiBQPK/+3pI3G29FCEc4LDyi12bw9ish7HpE0fR4jpKzNg/k+bP0Iqoyjr5AVBC+C1AZEuPmIJAusy3yxyiyiKv8OjMYLAyfckzQz14zhKG+KUvz2qR0X2N45FZCgIDVcjjSwQA9sLP1DU4VCdwGMNT3mf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603210993; h=Content-Type:Content-Transfer-Encoding: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=f8/1JxRNXiQfS/sYrMzJ3HfEdQEeKQ2a5ahg7I9AWr4=; b=ed1cFy/waXquHXxBvCL76Nj2nbzSs0OJNektsDt25bBX0NeFxWZyXdKYeWFhraEUwGQGIkQGOLOZDNMrS59xu4cq8WCmn9fwSFNdcIkaVDyNh1rqbsMcg2PJcYJbYrig4pj8SdFrZxFaIGwAMguJpGIb7DxMuslOwip5G2xY7kg= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603210993228994.3190914913226; Tue, 20 Oct 2020 09:23:13 -0700 (PDT) Received: from localhost ([::1]:54720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUuPo-00069i-7H for importer@patchew.org; Tue, 20 Oct 2020 12:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUu1S-0005oO-KA for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:58:02 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:34879) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUu1Q-0003z3-9J for qemu-devel@nongnu.org; Tue, 20 Oct 2020 11:58:02 -0400 Received: by mail-wr1-x429.google.com with SMTP id n15so2811092wrq.2 for ; Tue, 20 Oct 2020 08:57:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v6sm3780205wrp.69.2020.10.20.08.57.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 08:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=f8/1JxRNXiQfS/sYrMzJ3HfEdQEeKQ2a5ahg7I9AWr4=; b=VVEcaUpclEVnxrG4J1Etc1DYTbK9gX1CQThKIqIaXscJhRQ7kKun3nzBSV733fXgiG LWT+ZJBYVrSwTMw+ltK/w9nm97cHuOpo0nLR/9KZqWSDzzIxv4Gy0q2HImlu7kIMcOGf +Ff5gbl94HlwL7M5Pjk/auJ0kP3uL4NTc/BCQRrmnGBfpvplgbnOQFL5/JpMe+BTrjTU xzPzhwV2MnF2DkET9TNGhmdp72/1o5ib5JKIpktrLGzr15EDrgvwaPSu05AVCVPTkHr8 uIzshWYTVbiPUqe+FANXbh/xyWmeoCl2P8bO+X0rswoOjZ/A6SgouF7tfCPbM6gfTK1s TGAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f8/1JxRNXiQfS/sYrMzJ3HfEdQEeKQ2a5ahg7I9AWr4=; b=KUwL+104biWbkoJ/cOad6vccOS+8pe1hZBda2InMcKnU+ameJadGyl7TdMorfTUq6A O3BhNVk5Me3pPfdxYMPRWn3Aj9t/BJVHRsx/ISnk0QOGW0yV09BeSzanOmj9W9ucDvKV qyEqKJdyvGUZq9xbcS7z5HnCg6ce8dTP7htOiNmgtmPVAUIq5V53V5eJ5nehwBSQ5OvU T26hgjwzEmzKt5A9fNPGfE6VjBM0Xc9tBkqwVc2sCh4hRBSCOhMBQ+MqxMWpxIGXJbs/ 5RnNUJjpjGa5CKZC74kldCIBJSLBz4Qt4mCj+KKREHHVtKSImNgv/KJFiRF05Jh50+Zd SwgQ== X-Gm-Message-State: AOAM5303506kqaMTXsh4ZxesdbvjPA4VhhnAWBUFTbVqPuoxjNmq6z/S Xr40zuJ2HX0TvOBwP8iNoYldqGDELp4FUQ== X-Google-Smtp-Source: ABdhPJxaobs/kXvQGALA6FkEM1CF2GTRvfs0ArpNFFFQ9TSbniZebahZ45WPZsCjzgpLZkDitqyCYg== X-Received: by 2002:adf:8bdd:: with SMTP id w29mr4677591wra.276.1603209478464; Tue, 20 Oct 2020 08:57:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 41/41] tests/tcg/aarch64: Add bti smoke tests Date: Tue, 20 Oct 2020 16:56:56 +0100 Message-Id: <20201020155656.8045-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201020155656.8045-1-peter.maydell@linaro.org> References: <20201020155656.8045-1-peter.maydell@linaro.org> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson The note test requires gcc 10 for -mbranch-protection=3Dstandard. The mmap test uses PROT_BTI and does not require special compiler support. Acked-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20201016184207.786698-13-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- tests/tcg/aarch64/bti-1.c | 62 +++++++++++++++++ tests/tcg/aarch64/bti-2.c | 108 ++++++++++++++++++++++++++++++ tests/tcg/aarch64/bti-crt.inc.c | 51 ++++++++++++++ tests/tcg/aarch64/Makefile.target | 10 +++ tests/tcg/configure.sh | 4 ++ 5 files changed, 235 insertions(+) create mode 100644 tests/tcg/aarch64/bti-1.c create mode 100644 tests/tcg/aarch64/bti-2.c create mode 100644 tests/tcg/aarch64/bti-crt.inc.c diff --git a/tests/tcg/aarch64/bti-1.c b/tests/tcg/aarch64/bti-1.c new file mode 100644 index 00000000000..61924f0d7a4 --- /dev/null +++ b/tests/tcg/aarch64/bti-1.c @@ -0,0 +1,62 @@ +/* + * Branch target identification, basic notskip cases. + */ + +#include "bti-crt.inc.c" + +static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc) +{ + uc->uc_mcontext.pc +=3D 8; + uc->uc_mcontext.pstate =3D 1; +} + +#define NOP "nop" +#define BTI_N "hint #32" +#define BTI_C "hint #34" +#define BTI_J "hint #36" +#define BTI_JC "hint #38" + +#define BTYPE_1(DEST) \ + asm("mov %0,#1; adr x16, 1f; br x16; 1: " DEST "; mov %0,#0" \ + : "=3Dr"(skipped) : : "x16") + +#define BTYPE_2(DEST) \ + asm("mov %0,#1; adr x16, 1f; blr x16; 1: " DEST "; mov %0,#0" \ + : "=3Dr"(skipped) : : "x16", "x30") + +#define BTYPE_3(DEST) \ + asm("mov %0,#1; adr x15, 1f; br x15; 1: " DEST "; mov %0,#0" \ + : "=3Dr"(skipped) : : "x15") + +#define TEST(WHICH, DEST, EXPECT) \ + do { WHICH(DEST); fail +=3D skipped ^ EXPECT; } while (0) + + +int main() +{ + int fail =3D 0; + int skipped; + + /* Signal-like with SA_SIGINFO. */ + signal_info(SIGILL, skip2_sigill); + + TEST(BTYPE_1, NOP, 1); + TEST(BTYPE_1, BTI_N, 1); + TEST(BTYPE_1, BTI_C, 0); + TEST(BTYPE_1, BTI_J, 0); + TEST(BTYPE_1, BTI_JC, 0); + + TEST(BTYPE_2, NOP, 1); + TEST(BTYPE_2, BTI_N, 1); + TEST(BTYPE_2, BTI_C, 0); + TEST(BTYPE_2, BTI_J, 1); + TEST(BTYPE_2, BTI_JC, 0); + + TEST(BTYPE_3, NOP, 1); + TEST(BTYPE_3, BTI_N, 1); + TEST(BTYPE_3, BTI_C, 1); + TEST(BTYPE_3, BTI_J, 0); + TEST(BTYPE_3, BTI_JC, 0); + + return fail; +} diff --git a/tests/tcg/aarch64/bti-2.c b/tests/tcg/aarch64/bti-2.c new file mode 100644 index 00000000000..6dc8908b5a5 --- /dev/null +++ b/tests/tcg/aarch64/bti-2.c @@ -0,0 +1,108 @@ +/* + * Branch target identification, basic notskip cases. + */ + +#include +#include +#include +#include +#include + +#ifndef PROT_BTI +#define PROT_BTI 0x10 +#endif + +static void skip2_sigill(int sig, siginfo_t *info, void *vuc) +{ + ucontext_t *uc =3D vuc; + uc->uc_mcontext.pc +=3D 8; + uc->uc_mcontext.pstate =3D 1; +} + +#define NOP "nop" +#define BTI_N "hint #32" +#define BTI_C "hint #34" +#define BTI_J "hint #36" +#define BTI_JC "hint #38" + +#define BTYPE_1(DEST) \ + "mov x1, #1\n\t" \ + "adr x16, 1f\n\t" \ + "br x16\n" \ +"1: " DEST "\n\t" \ + "mov x1, #0" + +#define BTYPE_2(DEST) \ + "mov x1, #1\n\t" \ + "adr x16, 1f\n\t" \ + "blr x16\n" \ +"1: " DEST "\n\t" \ + "mov x1, #0" + +#define BTYPE_3(DEST) \ + "mov x1, #1\n\t" \ + "adr x15, 1f\n\t" \ + "br x15\n" \ +"1: " DEST "\n\t" \ + "mov x1, #0" + +#define TEST(WHICH, DEST, EXPECT) \ + WHICH(DEST) "\n" \ + ".if " #EXPECT "\n\t" \ + "eor x1, x1," #EXPECT "\n" \ + ".endif\n\t" \ + "add x0, x0, x1\n\t" + +extern char test_begin[], test_end[]; + +asm("\n" +"test_begin:\n\t" + BTI_C "\n\t" + "mov x2, x30\n\t" + "mov x0, #0\n\t" + + TEST(BTYPE_1, NOP, 1) + TEST(BTYPE_1, BTI_N, 1) + TEST(BTYPE_1, BTI_C, 0) + TEST(BTYPE_1, BTI_J, 0) + TEST(BTYPE_1, BTI_JC, 0) + + TEST(BTYPE_2, NOP, 1) + TEST(BTYPE_2, BTI_N, 1) + TEST(BTYPE_2, BTI_C, 0) + TEST(BTYPE_2, BTI_J, 1) + TEST(BTYPE_2, BTI_JC, 0) + + TEST(BTYPE_3, NOP, 1) + TEST(BTYPE_3, BTI_N, 1) + TEST(BTYPE_3, BTI_C, 1) + TEST(BTYPE_3, BTI_J, 0) + TEST(BTYPE_3, BTI_JC, 0) + + "ret x2\n" +"test_end:" +); + +int main() +{ + struct sigaction sa; + + void *p =3D mmap(0, getpagesize(), + PROT_EXEC | PROT_READ | PROT_WRITE | PROT_BTI, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (p =3D=3D MAP_FAILED) { + perror("mmap"); + return 1; + } + + memset(&sa, 0, sizeof(sa)); + sa.sa_sigaction =3D skip2_sigill; + sa.sa_flags =3D SA_SIGINFO; + if (sigaction(SIGILL, &sa, NULL) < 0) { + perror("sigaction"); + return 1; + } + + memcpy(p, test_begin, test_end - test_begin); + return ((int (*)(void))p)(); +} diff --git a/tests/tcg/aarch64/bti-crt.inc.c b/tests/tcg/aarch64/bti-crt.in= c.c new file mode 100644 index 00000000000..47805f4e35b --- /dev/null +++ b/tests/tcg/aarch64/bti-crt.inc.c @@ -0,0 +1,51 @@ +/* + * Minimal user-environment for testing BTI. + * + * Normal libc is not (yet) built with BTI support enabled, + * and so could generate a BTI TRAP before ever reaching main. + */ + +#include +#include +#include +#include + +int main(void); + +void _start(void) +{ + exit(main()); +} + +void exit(int ret) +{ + register int x0 __asm__("x0") =3D ret; + register int x8 __asm__("x8") =3D __NR_exit; + + asm volatile("svc #0" : : "r"(x0), "r"(x8)); + __builtin_unreachable(); +} + +/* + * Irritatingly, the user API struct sigaction does not match the + * kernel API struct sigaction. So for simplicity, isolate the + * kernel ABI here, and make this act like signal. + */ +void signal_info(int sig, void (*fn)(int, siginfo_t *, ucontext_t *)) +{ + struct kernel_sigaction { + void (*handler)(int, siginfo_t *, ucontext_t *); + unsigned long flags; + unsigned long restorer; + unsigned long mask; + } sa =3D { fn, SA_SIGINFO, 0, 0 }; + + register int x0 __asm__("x0") =3D sig; + register void *x1 __asm__("x1") =3D &sa; + register void *x2 __asm__("x2") =3D 0; + register int x3 __asm__("x3") =3D sizeof(unsigned long); + register int x8 __asm__("x8") =3D __NR_rt_sigaction; + + asm volatile("svc #0" + : : "r"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x8) : "memory= "); +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index e7249915e7e..d7d33e293c0 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -25,6 +25,16 @@ run-pauth-%: QEMU_OPTS +=3D -cpu max run-plugin-pauth-%: QEMU_OPTS +=3D -cpu max endif =20 +# BTI Tests +# bti-1 tests the elf notes, so we require special compiler support. +ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_BTI),) +AARCH64_TESTS +=3D bti-1 +bti-1: CFLAGS +=3D -mbranch-protection=3Dstandard +bti-1: LDFLAGS +=3D -nostdlib +endif +# bti-2 tests PROT_BTI, so no special compiler support required. +AARCH64_TESTS +=3D bti-2 + # Semihosting smoke test for linux-user AARCH64_TESTS +=3D semihosting run-semihosting: semihosting diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh index be51bdb5a4a..e1b70e25f23 100755 --- a/tests/tcg/configure.sh +++ b/tests/tcg/configure.sh @@ -240,6 +240,10 @@ for target in $target_list; do -march=3Darmv8.3-a -o $TMPE $TMPC; then echo "CROSS_CC_HAS_ARMV8_3=3Dy" >> $config_target_mak fi + if do_compiler "$target_compiler" $target_compiler_cflags \ + -mbranch-protection=3Dstandard -o $TMPE $TMPC; then + echo "CROSS_CC_HAS_ARMV8_BTI=3Dy" >> $config_target_mak + fi ;; esac =20 --=20 2.20.1