From nobody Tue May 7 14:35:22 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575899222; cv=none; d=zohomail.com; s=zohoarc; b=WKrEWCRjnpTUI1U7+ojE8b2hqSZoc+8gsPWasNiMmTzBEg/JtXmx+ln+VQ36SzgJVL+yIaMPFXEWLiKwNbKTRe8z0+hvcPGiyse9J9ILJiJKZM7WRSfu1B21hF1FFj8CmkEkmVf3lyqFRDiup/BC0rjq5yUSLDvxaZH3rNRexi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575899222; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=gxSwZyfeXxijSS52FpvVEEVrVieTj0X+VbLn4u/MPlA=; b=g1I6J+FivmowqG0gN3G7ADG9IhI/P0uCK/tP0kMCH4m7d0R4wMkKauj7ml9ire8LVoOl4pALMowfZ10lIG0hutHSw4EBhA1TrMmO2QKuu5qpS77J1ak5Kqf4FhsXZsnXySKrUHd/G2l5Xj7U6NXIUcsHnUJuRx9x992wx37sPFU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail 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 1575899222859109.85042297860787; Mon, 9 Dec 2019 05:47:02 -0800 (PST) Received: from localhost ([::1]:40376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieJNN-0001CL-9Z for importer@patchew.org; Mon, 09 Dec 2019 08:47:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55959) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieJMV-0000VV-3o for qemu-devel@nongnu.org; Mon, 09 Dec 2019 08:46:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieJMR-0004CO-NF for qemu-devel@nongnu.org; Mon, 09 Dec 2019 08:46:04 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36457 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ieJMR-0004AP-J3 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 08:46:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-2wA0zExYMlaUMLVu6bu2QQ-1; Mon, 09 Dec 2019 08:46:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D11B5801E74; Mon, 9 Dec 2019 13:45:59 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-146.brq.redhat.com [10.40.205.146]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 345A81001938; Mon, 9 Dec 2019 13:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575899162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gxSwZyfeXxijSS52FpvVEEVrVieTj0X+VbLn4u/MPlA=; b=cPvCuArRulQSABAb1qbQ2T/tlyjogvfP9ESsqav4Ayx0L8gJejSqNGLoXNfzzToXCd/f1y jPjeY3FMDdNDaSFDXIq93Whq4I3xLEgcbIXQAJHNqQapGjVwWfs+5TtJbi3D/D474Bznyf 1bcHOtwy4HORrRMnY8clbSnxA1wOou0= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH] target/arm: Display helpful message when hflags mismatch Date: Mon, 9 Dec 2019 14:45:52 +0100 Message-Id: <20191209134552.27733-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 2wA0zExYMlaUMLVu6bu2QQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Instead of crashing in a confuse way, give some hint to the user about why we aborted. He might report the issue without having to use a debugger. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Tested-by: Niek Linnenbank --- target/arm/helper.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 0bf8f53d4b..6bfb62672b 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11348,6 +11348,20 @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, = int el) env->hflags =3D rebuild_hflags_a64(env, el, fp_el, mmu_idx); } =20 +static inline void assert_hflags_rebuild_correctly(CPUARMState *env) +{ +#ifdef CONFIG_DEBUG_TCG + uint32_t env_flags_current =3D env->hflags; + uint32_t env_flags_rebuilt =3D rebuild_hflags_internal(env); + + if (unlikely(env_flags_current !=3D env_flags_rebuilt)) { + fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08= x)\n", + env_flags_current, env_flags_rebuilt); + abort(); + } +#endif +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -11355,9 +11369,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_= ulong *pc, uint32_t pstate_for_ss; =20 *cs_base =3D 0; -#ifdef CONFIG_DEBUG_TCG - assert(flags =3D=3D rebuild_hflags_internal(env)); -#endif + assert_hflags_rebuild_correctly(env); =20 if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { *pc =3D env->pc; --=20 2.21.0