From nobody Sun Sep 28 16:38:07 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=yandex.ru ARC-Seal: i=1; a=rsa-sha256; t=1757940535; cv=none; d=zohomail.com; s=zohoarc; b=ehy3FPnk19naX3tm6v7hno/egcTaEYXaGljrj+St/h6aPDCGUOSMG0R3Ft5HbWRof3YLV6KTtT9hOjbZvNXZOXHQJgtmeWgTrnPLX3Ismc+tt6CYxZbZ3dK0Zh9nHH2ZcKohXaOwF91lbYDXnxQFtHTMEi02jND6Gxqgfbbn1mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757940535; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GAkEQW9/oBNuV+QIcNUtxT7Jhur2BTbBORvnpc90fP4=; b=HoTaocWgVlvwmGAfXtqFnsHiuUxx1aFidTEz+ckRXPeNZs1NGkoobJv8EZGTEk3CycbzBdGjVxVGOmwL1oxdm2Ai5NwvgsmVlFsR6+8hT2lbjWF2jbDk8xzUjA5dDl2Hp4dtnAh1EPrwalhw5YTZcIRECb33vyHVtndq8NgjGMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175794053552381.0878215786795; Mon, 15 Sep 2025 05:48:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uy8cf-0004yx-As; Mon, 15 Sep 2025 08:48:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uy8c0-0004iV-7t; Mon, 15 Sep 2025 08:47:17 -0400 Received: from forward102d.mail.yandex.net ([178.154.239.213]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uy8bp-0002aI-TL; Mon, 15 Sep 2025 08:47:13 -0400 Received: from mail-nwsmtp-smtp-production-main-84.klg.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-84.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:3928:0:640:8b00:0]) by forward102d.mail.yandex.net (Yandex) with ESMTPS id 38BDBC01CE; Mon, 15 Sep 2025 15:46:54 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-84.klg.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id okOftstMV4Y0-xK4pKaOx; Mon, 15 Sep 2025 15:46:53 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1757940413; bh=GAkEQW9/oBNuV+QIcNUtxT7Jhur2BTbBORvnpc90fP4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=W88KMW56fX2+EO+N/dpl9GNO13mc6klx4tcJBaV0N9+aQCaSXYLopkJHcgEmZSmJu LcoCuAG2Vg8Q5hoFCw6wEoPu54qd/eprlJdWYoyoZf6a7lzLMrUPfzMr8THKjearNV uUqPaHujP39Q8T9bOly0m4uy2N938X+3Feuf3X0s= Authentication-Results: mail-nwsmtp-smtp-production-main-84.klg.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Danila Zhebryakov To: qemu-devel@nongnu.org Cc: Riku Voipio , Ilya Leoshkevich , Laurent Vivier , Chinmay Rath , Richard Henderson , David Hildenbrand , Thomas Huth , qemu-s390x@nongnu.org, Paolo Bonzini , Nicholas Piggin , qemu-ppc@nongnu.org, Danila Zhebryakov Subject: [PATCH v3 4/4] target/ppc: fix GDB stub to work correctly with LE pages Date: Mon, 15 Sep 2025 15:46:50 +0300 Message-ID: <20250915124650.435777-5-d.zhebryakov@yandex.ru> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250915124650.435777-1-d.zhebryakov@yandex.ru> References: <20250915124650.435777-1-d.zhebryakov@yandex.ru> 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=178.154.239.213; envelope-from=d.zhebryakov@yandex.ru; helo=forward102d.mail.yandex.net X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex.ru) X-ZM-MESSAGEID: 1757940536904116600 Content-Type: text/plain; charset="utf-8" GDB is expected to be set to the endianness of the currently running code, = which may be in LE page. Bswap the registers accordingly. Signed-off-by: Danila Zhebryakov --- target/ppc/gdbstub.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 3b28d4e21c..89c783894c 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -19,6 +19,8 @@ */ #include "qemu/osdep.h" #include "cpu.h" +#include "accel/tcg/probe.h" +#include "exec/tlb-flags.h" #include "exec/gdbstub.h" #include "gdbstub/helpers.h" #include "internal.h" @@ -84,7 +86,20 @@ static int ppc_gdb_register_len(int n) void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len) { #ifndef CONFIG_USER_ONLY - if (!FIELD_EX64(env->msr, MSR, LE)) { + bool le_page =3D false; + + if (env->mmu_model =3D=3D POWERPC_MMU_BOOKE206) { + CPUTLBEntryFull *full; + void *host; + int mmu_idx =3D ppc_env_mmu_index(env, true); + + probe_access_full_mmu(env, env->nip, 0, MMU_INST_FETCH, mmu_idx, + &host, &full); + + le_page =3D full->tlb_fill_flags & TLB_BSWAP; + } + + if (!le_page && !FIELD_EX64(env->msr, MSR, LE)) { /* do nothing */ } else if (len =3D=3D 4) { bswap32s((uint32_t *)mem_buf); --=20 2.47.2