From patchwork Tue May 4 05:52:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 430818 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp3497959jao; Mon, 3 May 2021 23:12:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVMS9m8juSZkAx/5pFwM2/h3Ikk1FlOh47nLPgVDD9oCF8By3IUJMsWU7Pq9M5ALN2OOZS X-Received: by 2002:a05:622a:1309:: with SMTP id v9mr20726514qtk.133.1620108761132; Mon, 03 May 2021 23:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620108761; cv=none; d=google.com; s=arc-20160816; b=nxTLXgyNYnf8yHft5vT3iRktDSVxug4VWqpUy+x9gaQ1XX+ScO9P/D+vH1mHzIH9Bw HyYzV21L+8Hp0m+Og2ebdH4VoM5K1ufjJWMvEojiy5TLITHiQ9063tIASy/CUx5H5pTZ EUD+QfFrUdX0u3RJbgxffi8jzGzhXsv2ZOCC9EYfbOl4Bwp+bU/hVPSuvf0VwvgDlWeM jhVdGcc9PGKPqQGLej6MMnbcCwOsgQVqeUSBhMBI6AYrq9nWeACIto3DyXHFUmvVZ7qU wjycfpav7OBMWirTzF1Eex0cPgLHaNjXF0a2fa81rN1KBs9VWWnnd/euBP2tAcl5lzio U84w== 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=woEJAS8b5msPl7RpTC3T/RC+M3NXFRr1ABPp/0eVKNQ=; b=BLuRqyA8GA3UGArgTCvQFwKhNOThtfjccXgWu6SjhwAQgBFUhMHsB8cWcL2jRBzRZL fBmvjc0PnguLXSqajdByMTzODTQHL7vPceorT9daDTbZ+q5MWuY4uI+WpL8BhuS8q88y xusi7mTa7fr3hTFnoMqfrnq8lMtHHqYFjCuIch6IVCSuNzHcKge04NBJjPaUYNNoQ6gZ eSykvM2AdlX2uWnCMULY5XciQAO90PcGFf3J0JFLHLYYrv39copuv1VMAeqtyFXsNEP/ bNpew059dC/q0rp8OunUFDC21nLSVkP5tYRnEDuAuokQJQ8de6tHpu1/3wH7ibu8tMve i8rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=GWWgbX9N; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c6si1120265qtd.256.2021.05.03.23.12.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 May 2021 23:12:41 -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=@gibson.dropbear.id.au header.s=201602 header.b=GWWgbX9N; 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" Received: from localhost ([::1]:51938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldoIS-0003jb-G8 for patch@linaro.org; Tue, 04 May 2021 02:12:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldo08-0005KM-HP; Tue, 04 May 2021 01:53:44 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:39689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldo04-0004o5-K3; Tue, 04 May 2021 01:53:43 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4FZ8CK6f1gz9sXS; Tue, 4 May 2021 15:53:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1620107597; bh=sCuff11fEliXRuJdwQKxzTDCAkDLJs5IHy1UGt0Z4sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GWWgbX9NvZERlsoa7sLo19BqB0OCR7TupQZfWJJVJZ8V662dD4eV8bCrG/v2GViXG ZUytIdDmkKbADSwhNDjfRaDzHMNivUYYBhdAcA4irFo6lUUZt5lXoLSbZ+SoQoW+op RpIkhdpqrP4vmAE7MDMvroObBAvb1eIkCNcqK1UQ= From: David Gibson To: peter.maydell@linaro.org, groug@kaod.org Subject: [PULL 19/46] target/ppc: Validate hflags with CONFIG_DEBUG_TCG Date: Tue, 4 May 2021 15:52:45 +1000 Message-Id: <20210504055312.306823-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210504055312.306823-1-david@gibson.dropbear.id.au> References: <20210504055312.306823-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: Richard Henderson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Verify that hflags was updated correctly whenever we change cpu state that is used by hflags. Signed-off-by: Richard Henderson Message-Id: <20210323184340.619757-11-richard.henderson@linaro.org> Signed-off-by: David Gibson --- target/ppc/cpu.h | 5 +++++ target/ppc/helper_regs.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) -- 2.31.1 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 3d021f61f3..69fc9a2831 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2425,6 +2425,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) { @@ -2432,6 +2436,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 5411a67e9a..3723872aa6 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; @@ -155,8 +155,33 @@ 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) {