From nobody Wed Feb 11 08:13:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1615598097; cv=none; d=zohomail.com; s=zohoarc; b=ipJA0hvfuPjkPKhRT+p9Nlt/eMsw1TI8pY1RcVc+tOU1k1UIcKRzG9BDZ9tmuv194UyAaFBcQibt8auAsiwzWYHRVWvwWH25kXvrW5V2m8Nc4IZdVsfjzemkOfyFXm3vE9VJfOhLxjvq6+8xwd2/M50ZU8XC4tlLWaF+AqLX1xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615598097; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y0taJkB4Fi6zr+Y5YPiFcKq9feU/8Hh2LxD7KqyF6Ng=; b=R/Pt7Lbbw/EeHimu3bc9P4kuIXiz6e+jRdDkzjJDS16Uz5dM1+/8ctRTET1Dte0pRZ+GkcTs2peOpm4IkpMDafzL4B1HFV+sRX/qBLq6UkCySsDGERLKZqAud9xAPycoDsrf5tkq1eghbun35V3AC/qirw9e2EF3sPd6EP6WKSM= 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 1615598096990246.1297853703678; Fri, 12 Mar 2021 17:14:56 -0800 (PST) Received: from localhost ([::1]:43836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKsro-0007lN-14 for importer@patchew.org; Fri, 12 Mar 2021 20:14:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKse8-0007St-0t for qemu-devel@nongnu.org; Fri, 12 Mar 2021 20:00:48 -0500 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:43909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKse0-0003W7-Q3 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 20:00:47 -0500 Received: by mail-qk1-x72e.google.com with SMTP id b130so26277412qkc.10 for ; Fri, 12 Mar 2021 17:00:39 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id l129sm5602078qkd.76.2021.03.12.17.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 17:00:39 -0800 (PST) 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=OE4VoXoTlJ+QCJtywr+QwMnlrg3ZkLDbfEve1JlrEeWenJ6gO/gAKJuHT6EXgUZDTk Sdz3+zCcrMjKxHlTHetb3pyxoZXQOpJCvDoDThVljhBDY+TlrQpoLzvZ43NxXbL+lIXi BpVipYU0NqBWGZWZjJcDk1GAY0ru+a1QTfJbGATOp70abxB04ru0OZfB2yIaqQ7LGf2R y/eaiDF286hp/daiwjPGOSGh7vrmWfOHrvCs4cBV3TC7CBsSxMc4/43A7XEpmXaVOksI azMlLVKWdf3mI0Kd+vRfNm8KJAyp5uRj+FkS3nwrYQDq+dW3EmwavZbuPhaEcWaSfq5s 6K/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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y0taJkB4Fi6zr+Y5YPiFcKq9feU/8Hh2LxD7KqyF6Ng=; b=tycMt9l0vVIE09yviJy7ll0A6R060nqgcXJt7BVY6YSff9f1h5XjtxO9+p/3SIkXl3 rqnwOTajh1CmMANFSCBhcNXq+aTlm9i5BYwX43E6AUilaPXUCwRytzry7lvxvALhKsnI /5mMmt/TsVQUPZ5mrypBLrvJaRPnuEY26jLRFoJ3eF+SBVUSPrBPMdmgjF+h7UHmLrFK pNU/egriKbol0OsIRuBmOuYx7/5C2xoG+/LLN7Erfu47W9r62ABb05HJo4D1FRiCBgrM ClI8h8Pwr7pSyJjLMOiBU5cCL/P/NSydDfJFJeq3hy95M+6xH5HUNWdvz7J8M2GQWw+Q up4g== X-Gm-Message-State: AOAM530r4rZHbj88/VB/v+HUoE2RFypbfrJfl1wrUFIb5WQg86zFdq3Y TZHthDAa28yCNf461892bSxI0XXR/Ckp1AyQ X-Google-Smtp-Source: ABdhPJylvDABJkWJ67kUOfzN8jq4uJGposil8XRnlWoDP8JtMPWmHEbbIXOsH8esQc+S+XQTi1dtRQ== X-Received: by 2002:a37:6888:: with SMTP id d130mr15136116qkc.368.1615597239400; Fri, 12 Mar 2021 17:00:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/15] target/ppc: Validate hflags with CONFIG_DEBUG_TCG Date: Fri, 12 Mar 2021 19:00:18 -0600 Message-Id: <20210313010018.819153-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210313010018.819153-1-richard.henderson@linaro.org> References: <20210313010018.819153-1-richard.henderson@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=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.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=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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(-) 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 xe= r); */ #define is_book3s_arch2x(ctx) (!!((ctx)->insns_flags & PPC_SEGMENT_64B)) =20 +#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 *f= lags) { @@ -2431,6 +2435,7 @@ static inline void cpu_get_tb_cpu_state(CPUPPCState *= env, target_ulong *pc, *cs_base =3D 0; *flags =3D env->hflags; } +#endif =20 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] =3D tmp; } =20 -void hreg_compute_hflags(CPUPPCState *env) +static uint32_t hreg_compute_hflags_value(CPUPPCState *env) { target_ulong msr =3D env->msr; uint32_t ppc_flags =3D env->flags; @@ -147,9 +147,34 @@ void hreg_compute_hflags(CPUPPCState *env) hflags |=3D dmmu_idx << HFLAGS_DMMU_IDX; #endif =20 - env->hflags =3D hflags | (msr & msr_mask); + return hflags | (msr & msr_mask); } =20 +void hreg_compute_hflags(CPUPPCState *env) +{ + env->hflags =3D 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 =3D env->hflags; + uint32_t hflags_rebuilt; + + *pc =3D env->nip; + *cs_base =3D 0; + *flags =3D hflags_current; + + hflags_rebuilt =3D hreg_compute_hflags_value(env); + if (unlikely(hflags_current !=3D 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()) { --=20 2.25.1