From patchwork Sun Mar 14 17:59:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 400109 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2841481jai; Sun, 14 Mar 2021 11:20:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjq/dOxGhx5RJny6HOGwXogf62qomgmwG1ZM9Wj2SwWFJm+xx3PhPXtNs3Xel6M6Haq7eS X-Received: by 2002:a25:c2c4:: with SMTP id s187mr32207579ybf.292.1615746008277; Sun, 14 Mar 2021 11:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615746008; cv=none; d=google.com; s=arc-20160816; b=Wo0S91Bpuf+BUh4vJW+6+LMyZoXmgRjDZfXUkZMYVZzgnG43hVJHYyt6kuKCmSWYQU tXMHSqoenAjUMoJQYqJNMwxwOk2AVuTsSeJpyCkR75Io6PU5ATNfNNtA8zTUCVBzfTRa ajYcKaMDtIBZ+Ag+MDvh5SjCcjUoAbDz5jKRUelqau7j8jnFGrBWUzC8T/COxo4RKvvC oqfdQLmrFFhTgBRb18norszNUq6gRgQCZlapv1GCGqXccNYH0PnUkrc28RVmJ8uT3r// 2bSoqhApFnnuGwAAD2CAkMDcwtMQh8U+uOugfEfqk+7TSfjtKksg3bAQRtXT8QtO3kLs pRaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Y0taJkB4Fi6zr+Y5YPiFcKq9feU/8Hh2LxD7KqyF6Ng=; b=FlrDhjfcrhuTpNv2R38agSxVEVmHvH1UUkCfedfNthINyj9If7kWFvyoncuCxkzU5Q /wB/PLneyA7fPq/CzBNgn+wNEHYUXxFt6M6pLH5RGtDsfogJcJABsXUf3wVNBn0Izagg ltF1kVNNdlhvYcFkPVuDTwdmzcgTsiDUWeQpV69xjjb89+TNWAlF+gAwhjbs1b1G1IDA 1Z7XK3Z+3/j1c39TQuiO92xNXGeD8Ar8l3kKJX8KqFVuE3GVe6c9Rof646Mw8HIZMi1C oRlCbYRF2TrwBzL2GVsNTVchkwF6nE01UvSF7vW0DMgEPHX0u4u2FKXWZhH23oP8afzw I/yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WP0JpRHu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b67si13411711ybb.417.2021.03.14.11.20.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 14 Mar 2021 11:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WP0JpRHu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLVLT-0001FY-J7 for patch@linaro.org; Sun, 14 Mar 2021 14:20:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLV1e-0002di-OV for qemu-devel@nongnu.org; Sun, 14 Mar 2021 13:59:38 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:42548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLV1U-0002Df-9W for qemu-devel@nongnu.org; Sun, 14 Mar 2021 13:59:38 -0400 Received: by mail-qt1-x82f.google.com with SMTP id l13so7657806qtu.9 for ; Sun, 14 Mar 2021 10:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y0taJkB4Fi6zr+Y5YPiFcKq9feU/8Hh2LxD7KqyF6Ng=; b=WP0JpRHuD11UDt6ZWnIFTM2biYMr+AOGuVHDP6u04ioX8Ul9EMOi8UGAqQGRFyiXxt H16zPL3OdUgotfMPndSuJ9WPqWhUUHbxgI6pk64QmaEBa3GBTI/Zzz05C7oPgOuxDhzB g/LX2SZPYKcGmBHU4217DowmjNiBCpS7MbD5Ojw0HjCTPVXgxwwleBdcdWtqlccMacMa hNJhPYrwxc8UNO8Kp2YQliIpE7WrM88qlLT5PythSPzbUTBHTLwEQv0O8cwj9XGsPKO3 W6FqEciJ63QHUZaM7/gGOQatXMhcXk+SLhY/w1YMIFH/147Gpf0oxN06GiV9/Lh+pGEv ntSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y0taJkB4Fi6zr+Y5YPiFcKq9feU/8Hh2LxD7KqyF6Ng=; b=VrkGmLLl6TN6ulOqmtPddz9m6Jd7WK3erXDnIoCcP70skBjvQIUv9597FNnjGYS/fs +2QSSm3BLk49TIduXGIQerTmTVTFCibxex+yxnJXoVYFv+6wFBL0i/GRov02hShjFFrT kWdh411Nth32wMd7GDv0JOhDs7cQD+MAWcWwoRQ0vVaG0rXBhYv80RWZysSOBnpVpUck n6nRBUseJYsmLXPpriAqSvB9OCKuqGjUc+/DePLJXlFfMxLTa6NtJTmSCrPOyI92jNRg C9HU3rjVVcuD/CdAsXYu9u+nt7HbLXNKwcq0nrtRBP554gtUvq8ayyQRvHyEozmyeB9+ XOnQ== X-Gm-Message-State: AOAM530nshaHdb/ERlrcSH13KlXIVSR+u15UQe7M+b86JqvzkiBBuuQ/ 8JEZzwvn9hVmAAAtBpPfzEgOb4VFzhwJwxwO X-Received: by 2002:ac8:59d6:: with SMTP id f22mr6282495qtf.83.1615744767400; Sun, 14 Mar 2021 10:59:27 -0700 (PDT) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id c127sm10216240qkd.87.2021.03.14.10.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Mar 2021 10:59:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/16] target/ppc: Validate hflags with CONFIG_DEBUG_TCG Date: Sun, 14 Mar 2021 11:59:06 -0600 Message-Id: <20210314175906.1733746-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210314175906.1733746-1-richard.henderson@linaro.org> References: <20210314175906.1733746-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ivan@vmfacility.fr, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Verify that hflags was updated correctly whenever we change cpu state that is used by hflags. Signed-off-by: Richard Henderson --- target/ppc/cpu.h | 5 +++++ target/ppc/helper_regs.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 2f8d7fa13c..7ee5c9a66e 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2424,6 +2424,10 @@ void cpu_write_xer(CPUPPCState *env, target_ulong xer); */ #define is_book3s_arch2x(ctx) (!!((ctx)->insns_flags & PPC_SEGMENT_64B)) +#ifdef CONFIG_DEBUG_TCG +void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc, + target_ulong *cs_base, uint32_t *flags); +#else static inline void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *flags) { @@ -2431,6 +2435,7 @@ static inline void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc, *cs_base = 0; *flags = env->hflags; } +#endif void QEMU_NORETURN raise_exception(CPUPPCState *env, uint32_t exception); void QEMU_NORETURN raise_exception_ra(CPUPPCState *env, uint32_t exception, diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index b28037ca24..9df1098fec 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -43,7 +43,7 @@ void hreg_swap_gpr_tgpr(CPUPPCState *env) env->tgpr[3] = tmp; } -void hreg_compute_hflags(CPUPPCState *env) +static uint32_t hreg_compute_hflags_value(CPUPPCState *env) { target_ulong msr = env->msr; uint32_t ppc_flags = env->flags; @@ -147,9 +147,34 @@ void hreg_compute_hflags(CPUPPCState *env) hflags |= dmmu_idx << HFLAGS_DMMU_IDX; #endif - env->hflags = hflags | (msr & msr_mask); + return hflags | (msr & msr_mask); } +void hreg_compute_hflags(CPUPPCState *env) +{ + env->hflags = hreg_compute_hflags_value(env); +} + +#ifdef CONFIG_DEBUG_TCG +void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc, + target_ulong *cs_base, uint32_t *flags) +{ + uint32_t hflags_current = env->hflags; + uint32_t hflags_rebuilt; + + *pc = env->nip; + *cs_base = 0; + *flags = hflags_current; + + hflags_rebuilt = hreg_compute_hflags_value(env); + if (unlikely(hflags_current != hflags_rebuilt)) { + cpu_abort(env_cpu(env), + "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", + hflags_current, hflags_rebuilt); + } +} +#endif + void cpu_interrupt_exittb(CPUState *cs) { if (!kvm_enabled()) {