From patchwork Tue Mar 23 18:43:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 406952 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4733487jai; Tue, 23 Mar 2021 12:34:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMz0wJDnoVd9N3IDMd20eaPcPPBLmKL9NS/cTB+zH/8zrieP59W5a1vM1OJwseqmATlo/3 X-Received: by 2002:a05:6e02:92f:: with SMTP id o15mr6183019ilt.111.1616528050156; Tue, 23 Mar 2021 12:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616528050; cv=none; d=google.com; s=arc-20160816; b=t31/9bOKDTPSoazyxoAbH5F4tJKAEqrwWtfFzxZ2S2kNvF3Y0xanPl3ec4U6SaQSYs 7tyJCNwAYhsgMhFsRAanGinD0Ld7ChF+g21XHM18SXrPRQVy6Liu1nLNPqXsKJJnQmEw 8VOBkIH1q3TzV+l1nAEX0cMEfvqo+ClDVAJuhN6H918DAwddWwQVGrR6v1RDnjXEhvO6 ZtvpIFhyrDIa5yihxey2+B8D/sKa1i8vLiP5iWdcM0lkVHU26y/4Kzf1QkeEGYoWyEeq JOxmEySZmZfEps6e+1uzngpOSb/CdIbwaXO5vuKeEHT7FAWNIMTmVGCia1InGpMh2QBQ mKsg== 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=7hjRKYvKwPhnZczNplHlGNdiwX+bsNrNu6SiB/+LyZA=; b=D60i8KsfsaXFtHNXuYtmLs5DE3fiBgiOJh5xVLFn8Z80ubLpmhP2CrF1MqjbqydAN0 P5wptcT6wgdqWoEohDDAYcYDZQIpdsZT10vi0GcpFZg3wqRKIvIaLcJVbwTOyHXzwgAe RrUMlDAr2qqachm/TccW6GTk5hBN4lv2qZMpTBvGCp5bFutoCIYA193cqmPRyZTP9dmw vwPoKZ0MFMBaHsA9PvZtteK+JnbXiwzxPntZO6JCP/4qNh4CTUo/LILD+J1xN+94u75p lQskxweCpF1tbDosFEBgNUhSyDQXBV4fy1h5ELkfdunji9r09jQto8yDGmIhjyEGJVQR dfbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SQ+27xqY; 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 t7si12464669jaj.40.2021.03.23.12.34.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Mar 2021 12:34:10 -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=SQ+27xqY; 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]:54400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOmn1-0007qq-Tm for patch@linaro.org; Tue, 23 Mar 2021 15:34:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOm0x-0008MR-Hp for qemu-devel@nongnu.org; Tue, 23 Mar 2021 14:44:27 -0400 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]:38543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lOm0N-0003hH-3s for qemu-devel@nongnu.org; Tue, 23 Mar 2021 14:44:27 -0400 Received: by mail-oi1-x230.google.com with SMTP id f9so18099230oiw.5 for ; Tue, 23 Mar 2021 11:43:48 -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=7hjRKYvKwPhnZczNplHlGNdiwX+bsNrNu6SiB/+LyZA=; b=SQ+27xqYoHWPUGePhOitizEXdptaRcrdXHQgtC4NW9zjekptoDHGDF81yh0ntBfEG6 EMP2KScax0ugWNK1FwUDxaIiPrjEveOM0W6nxIhmyMcLBAyCdk8cG7PeiP+gYvsM8zz3 dQqKwVBIXCRCB8krnm70V4xRj3+NTy0SVi+gOPeImUCizWNF5i02wp0ehd2cvyolQgoo zM1v5dIbVyHq9qXwgyFE4a10Kgjrei35ihYJGb0R3EOvv14UQfU79N8PgiEu2PmN3oob yVbLiQAS5ETJEOUTDbOPns0z5TflCj3uPmUo6j5ZmuMwYBD2OYwjvLj0VEREQnTANLoa dWuw== 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=7hjRKYvKwPhnZczNplHlGNdiwX+bsNrNu6SiB/+LyZA=; b=FFygN3echDfi6l30ELVJApBS2FiFU7xLjxE7fExYap0Bz1IzQBQlafN/LhV6NB1IuP 0eCKfgNQY323nHe2++q9q6Jbg4/n+8rcbqKnT3cF/3HFTTyy6dLahWM6gKuZaf9cl5RB HnrA8Xed30dOw1ilrjXLbVqXXkYSjwoZ2WVoRQQlBmTsLKN1H+AfteDEHDrDJ9BoOcGB OTRUpNGKeHufMIzQ5RdmjfcTeKLfLiEjR4BWjLOLHLF7ZhBZrMq0WZUhE/Fh3CHgWTaw CRnOqVtZc2xqn63KcGcXiCJt3yVAUl5cQfT8Df5utVuy8JkQ/o1/QQwAEpWte6+F2rDy PA2w== X-Gm-Message-State: AOAM530TQzzBt+afaa8AHGR0ZT5brbcfG8pU2V5/8qHZ6KIn/OFu6ilU sy1XRpjIe/cJIaYs7sjnEzBqbrO4Z9pXr9iL X-Received: by 2002:a05:6808:b09:: with SMTP id s9mr4369537oij.36.1616525028288; Tue, 23 Mar 2021 11:43:48 -0700 (PDT) Received: from localhost.localdomain (171.189-204-159.bestelclientes.com.mx. [189.204.159.171]) by smtp.gmail.com with ESMTPSA id x23sm3902825ood.28.2021.03.23.11.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 11:43:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 04/10] target/ppc: Put dbcr0 single-step bits into hflags Date: Tue, 23 Mar 2021 12:43:34 -0600 Message-Id: <20210323184340.619757-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323184340.619757-1-richard.henderson@linaro.org> References: <20210323184340.619757-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::230; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x230.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: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Because these bits were not in hflags, the code generated for single-stepping on BookE was essentially random. Recompute hflags when storing to dbcr0. Reviewed-by: David Gibson Signed-off-by: Richard Henderson --- target/ppc/helper_regs.c | 24 +++++++++++++++++------- target/ppc/misc_helper.c | 3 +++ target/ppc/translate.c | 11 ----------- 3 files changed, 20 insertions(+), 18 deletions(-) -- 2.25.1 diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index df9673b90f..e345966b6b 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -114,13 +114,23 @@ void hreg_compute_hflags(CPUPPCState *env) hflags |= le << MSR_LE; } - if (ppc_flags & POWERPC_FLAG_BE) { - QEMU_BUILD_BUG_ON(MSR_BE != HFLAGS_BE); - msr_mask |= 1 << MSR_BE; - } - if (ppc_flags & POWERPC_FLAG_SE) { - QEMU_BUILD_BUG_ON(MSR_SE != HFLAGS_SE); - msr_mask |= 1 << MSR_SE; + if (ppc_flags & POWERPC_FLAG_DE) { + target_ulong dbcr0 = env->spr[SPR_BOOKE_DBCR0]; + if (dbcr0 & DBCR0_ICMP) { + hflags |= 1 << HFLAGS_SE; + } + if (dbcr0 & DBCR0_BRT) { + hflags |= 1 << HFLAGS_BE; + } + } else { + if (ppc_flags & POWERPC_FLAG_BE) { + QEMU_BUILD_BUG_ON(MSR_BE != HFLAGS_BE); + msr_mask |= 1 << MSR_BE; + } + if (ppc_flags & POWERPC_FLAG_SE) { + QEMU_BUILD_BUG_ON(MSR_SE != HFLAGS_SE); + msr_mask |= 1 << MSR_SE; + } } if (msr_is_64bit(env, msr)) { diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index b04b4d7c6e..002958be26 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -215,6 +215,9 @@ void helper_store_403_pbr(CPUPPCState *env, uint32_t num, target_ulong value) void helper_store_40x_dbcr0(CPUPPCState *env, target_ulong val) { + /* Bits 26 & 27 affect single-stepping. */ + hreg_compute_hflags(env); + /* Bits 28 & 29 affect reset or shutdown. */ store_40x_dbcr0(env, val); } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index a85b890bb0..7912495f28 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7923,17 +7923,6 @@ static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) if ((hflags >> HFLAGS_BE) & 1) { ctx->singlestep_enabled |= CPU_BRANCH_STEP; } - if ((env->flags & POWERPC_FLAG_DE) && msr_de) { - ctx->singlestep_enabled = 0; - target_ulong dbcr0 = env->spr[SPR_BOOKE_DBCR0]; - if (dbcr0 & DBCR0_ICMP) { - ctx->singlestep_enabled |= CPU_SINGLE_STEP; - } - if (dbcr0 & DBCR0_BRT) { - ctx->singlestep_enabled |= CPU_BRANCH_STEP; - } - - } if (unlikely(ctx->base.singlestep_enabled)) { ctx->singlestep_enabled |= GDBSTUB_SINGLE_STEP; }