From nobody Wed Nov 5 20:03:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537436157120483.13448534420183; Thu, 20 Sep 2018 02:35:57 -0700 (PDT) Received: from localhost ([::1]:49065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2vNA-0006ge-6p for importer@patchew.org; Thu, 20 Sep 2018 05:35:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2vM0-0006Kw-NI for qemu-devel@nongnu.org; Thu, 20 Sep 2018 05:34:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g2vLw-0007OO-Kw for qemu-devel@nongnu.org; Thu, 20 Sep 2018 05:34:32 -0400 Received: from mail.sysgo.com ([176.9.12.79]:42314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2vLu-0007HJ-Hl; Thu, 20 Sep 2018 05:34:28 -0400 From: Roman Kapl To: Date: Thu, 20 Sep 2018 11:34:09 +0200 Message-Id: <20180920093409.7433-1-rka@sysgo.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 176.9.12.79 Subject: [Qemu-devel] [PATCH] target/ppc: fix dcbz, dcbzep, dcbtst and insn type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, David Gibson , qemu-ppc@nongnu.org, Alexander Graf , Roman Kapl Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" dcbz was broken with the refactoring introduced in the External PID patch. = The GETPC() call is moved directly to the helper in this patch, to report corre= ct PC address. The issue did not always manifest: if the compiler decided to inli= ne the call, the PC wound up being correct. So in order to reproduce, use a de= bug build. A problem in dcbzep, which did not perform external PID access in its slow = path was also fixed. dcbtst opcode is now fixed, it was swapped with dcbtstep. I also misunderstood the instruction registration mechanism and the instruc= tions were not truly limited to BookE 2.06. The PPC_CACHE/PPC_INTEGER type mask w= as changed to PPC_NONE. Fixes: ea8073c10d ("target/ppc: add external PID support") Signed-off-by: Roman Kapl --- This fixes the sandalfoot image boot. And thanks to PMM for spotting the GE= TPC issue. target/ppc/mem_helper.c | 15 ++++++++++----- target/ppc/translate.c | 20 +++++++++----------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 0c39141ab7..9d140dc4a3 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -141,12 +141,13 @@ void helper_stsw(CPUPPCState *env, target_ulong addr,= uint32_t nb, } } =20 -static void helper_dcbz_common(CPUPPCState *env, target_ulong addr, - uint32_t opcode, int mmu_idx) +static void dcbz_common(CPUPPCState *env, target_ulong addr, + uint32_t opcode, bool epid, uintptr_t pc) { target_ulong mask, dcbz_size =3D env->dcache_line_size; uint32_t i; void *haddr; + int mmu_idx =3D epid ? PPC_TLB_EPID_STORE : env->dmmu_idx; =20 #if defined(TARGET_PPC64) /* Check for dcbz vs dcbzl on 970 */ @@ -172,19 +173,23 @@ static void helper_dcbz_common(CPUPPCState *env, targ= et_ulong addr, } else { /* Slow path */ for (i =3D 0; i < dcbz_size; i +=3D 8) { - cpu_stq_data_ra(env, addr + i, 0, GETPC()); + if (epid) { + cpu_stq_eps_ra(env, addr + i, 0, pc); + } else { + cpu_stq_data_ra(env, addr + i, 0, pc); + } } } } =20 void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t opcode) { - helper_dcbz_common(env, addr, opcode, env->dmmu_idx); + dcbz_common(env, addr, opcode, false, GETPC()); } =20 void helper_dcbzep(CPUPPCState *env, target_ulong addr, uint32_t opcode) { - helper_dcbz_common(env, addr, opcode, PPC_TLB_EPID_STORE); + dcbz_common(env, addr, opcode, true, GETPC()); } =20 void helper_icbi(CPUPPCState *env, target_ulong addr) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 41322fb9c4..3e279bcbc9 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -6881,24 +6881,22 @@ GEN_HANDLER_E(mcrxrx, 0x1F, 0x00, 0x12, 0x007FF801,= PPC_NONE, PPC2_ISA300), GEN_HANDLER(mtmsr, 0x1F, 0x12, 0x04, 0x001EF801, PPC_MISC), GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000000, PPC_MISC), GEN_HANDLER(dcbf, 0x1F, 0x16, 0x02, 0x03C00001, PPC_CACHE), -GEN_HANDLER_E(dcbfep, 0x1F, 0x1F, 0x03, 0x03C00001, PPC_CACHE, PPC2_BOOKE2= 06), +GEN_HANDLER_E(dcbfep, 0x1F, 0x1F, 0x03, 0x03C00001, PPC_NONE, PPC2_BOOKE20= 6), GEN_HANDLER(dcbi, 0x1F, 0x16, 0x0E, 0x03E00001, PPC_CACHE), GEN_HANDLER(dcbst, 0x1F, 0x16, 0x01, 0x03E00001, PPC_CACHE), -GEN_HANDLER_E(dcbstep, 0x1F, 0x1F, 0x01, 0x03E00001, PPC_CACHE, PPC2_BOOKE= 206), +GEN_HANDLER_E(dcbstep, 0x1F, 0x1F, 0x01, 0x03E00001, PPC_NONE, PPC2_BOOKE2= 06), GEN_HANDLER(dcbt, 0x1F, 0x16, 0x08, 0x00000001, PPC_CACHE), -GEN_HANDLER_E(dcbtep, 0x1F, 0x1F, 0x09, 0x00000001, PPC_CACHE, PPC2_BOOKE2= 06), -GEN_HANDLER(dcbtst, 0x1F, 0x1F, 0x07, 0x00000001, PPC_CACHE), -GEN_HANDLER_E(dcbtstep, 0x1F, 0x16, 0x07, 0x00000001, PPC_CACHE, PPC2_BOOK= E206), +GEN_HANDLER_E(dcbtep, 0x1F, 0x1F, 0x09, 0x00000001, PPC_NONE, PPC2_BOOKE20= 6), +GEN_HANDLER(dcbtst, 0x1F, 0x16, 0x07, 0x00000001, PPC_CACHE), +GEN_HANDLER_E(dcbtstep, 0x1F, 0x1F, 0x07, 0x00000001, PPC_NONE, PPC2_BOOKE= 206), GEN_HANDLER_E(dcbtls, 0x1F, 0x06, 0x05, 0x02000001, PPC_BOOKE, PPC2_BOOKE2= 06), GEN_HANDLER(dcbz, 0x1F, 0x16, 0x1F, 0x03C00001, PPC_CACHE_DCBZ), -GEN_HANDLER_E(dcbzep, 0x1F, 0x1F, 0x1F, 0x03C00001, - PPC_CACHE_DCBZ, PPC2_BOOKE206), +GEN_HANDLER_E(dcbzep, 0x1F, 0x1F, 0x1F, 0x03C00001, PPC_NONE, PPC2_BOOKE20= 6), GEN_HANDLER(dst, 0x1F, 0x16, 0x0A, 0x01800001, PPC_ALTIVEC), GEN_HANDLER(dstst, 0x1F, 0x16, 0x0B, 0x01800001, PPC_ALTIVEC), GEN_HANDLER(dss, 0x1F, 0x16, 0x19, 0x019FF801, PPC_ALTIVEC), GEN_HANDLER(icbi, 0x1F, 0x16, 0x1E, 0x03E00001, PPC_CACHE_ICBI), -GEN_HANDLER_E(icbiep, 0x1F, 0x1F, 0x1E, 0x03E00001, - PPC_CACHE_ICBI, PPC2_BOOKE206), +GEN_HANDLER_E(icbiep, 0x1F, 0x1F, 0x1E, 0x03E00001, PPC_NONE, PPC2_BOOKE20= 6), GEN_HANDLER(dcba, 0x1F, 0x16, 0x17, 0x03E00001, PPC_CACHE_DCBA), GEN_HANDLER(mfsr, 0x1F, 0x13, 0x12, 0x0010F801, PPC_SEGMENT), GEN_HANDLER(mfsrin, 0x1F, 0x13, 0x14, 0x001F0001, PPC_SEGMENT), @@ -7205,7 +7203,7 @@ GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER) #undef GEN_LDEPX #define GEN_LDEPX(name, ldop, opc2, opc3) = \ GEN_HANDLER_E(name##epx, 0x1F, opc2, opc3, = \ - 0x00000001, PPC_INTEGER, PPC2_BOOKE206), + 0x00000001, PPC_NONE, PPC2_BOOKE206), =20 GEN_LDEPX(lb, DEF_MEMOP(MO_UB), 0x1F, 0x02) GEN_LDEPX(lh, DEF_MEMOP(MO_UW), 0x1F, 0x08) @@ -7251,7 +7249,7 @@ GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER) #undef GEN_STEPX #define GEN_STEPX(name, ldop, opc2, opc3) = \ GEN_HANDLER_E(name##epx, 0x1F, opc2, opc3, = \ - 0x00000001, PPC_INTEGER, PPC2_BOOKE206), + 0x00000001, PPC_NONE, PPC2_BOOKE206), =20 GEN_STEPX(stb, DEF_MEMOP(MO_UB), 0x1F, 0x06) GEN_STEPX(sth, DEF_MEMOP(MO_UW), 0x1F, 0x0C) --=20 2.11.0