From nobody Thu Apr 3 10:24:53 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1742907920; cv=none; d=zohomail.com; s=zohoarc; b=NkKS+KgzozLhLnPGBVi04R0+YI5qlxOFXW6DNt/w12j6FbPXiMxofH5wN3cMz6wsY67uauT2+Ni34xD3IgK2UqYf9qPhh9SpIXuASxG95TtCAvAYHyZlIMVW19bWB40eIK9Q8l6Bz3CJMS81c6K5VHwSeyuCYn9KFHaxLp3ZEj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742907920; h=Content-Type: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=rHkl1CLLTMtxzzv7to/S3wSbPsj8b4TlffAoIJKx3UM=; b=YFOyTs2FA2IvkmHXgLymkEchyEbPvqFf4gE3Mj0g5jQo+c7kxweQVqhKPF+Fei2eZtDeLtPBRhEtQgnf0/B7ge6msd2zcpHtoWCdPiHyxnqToKki6kQtxga0BfxqSi0KrL5uuz+4YL/ZR1oUSNeqArakt8PVCbfVhGn92MnYbnI= 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 1742907920717142.98515437398237; Tue, 25 Mar 2025 06:05:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tx3wK-0001ES-Id; Tue, 25 Mar 2025 09:03:32 -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 1tx3vP-0000pF-8T for qemu-devel@nongnu.org; Tue, 25 Mar 2025 09:02:45 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tx3vM-000824-Vp for qemu-devel@nongnu.org; Tue, 25 Mar 2025 09:02:34 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-43ce71582e9so38535275e9.1 for ; Tue, 25 Mar 2025 06:02:31 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3997f9e66a7sm13670849f8f.76.2025.03.25.06.02.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Mar 2025 06:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742907750; x=1743512550; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rHkl1CLLTMtxzzv7to/S3wSbPsj8b4TlffAoIJKx3UM=; b=VUTu5RSWfwR0TBwN7s4Ng7ylnc+06k55gxqq6tnlvTs7SsxJ9aNj52AfnNfNV8uy39 qu39VAgyWQYk0hAenXqsdjJFJ6nMqobjD7DFgGMpGpXdEjJSzPi3hOe48OGxw1Mf5ZXo hjRlGOESHiPLDRE3nLUmkYitzPgzHlULqS/QCrml8BmlgP4xmyO522rz/4TyDt2CnoVH /31hVLsiTXmB/7MGtDGIp/0tuL5XwLPwadSaFxdK+K3Bmls4cwwVuRYF2OGKTBZJmksF +ZZ3v55seCO7zWo3nPRle3X9M1KeI3hBKw6yAYD8ZXZ+4HDiMhcdgO6/WgbokD+qksne gBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742907750; x=1743512550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rHkl1CLLTMtxzzv7to/S3wSbPsj8b4TlffAoIJKx3UM=; b=H2GfN0fZOwWGy4kvEKINgBhzrDVLLmgHLfFjyTXf2E19RlS6xWjfc0W0H2SYxCux4X ljQhJdog75CaYI2/9MqH/2gaphQYUfJtxnG+pNTCvQIkkrhv6Gr8lHxmhMTBYYk1MTgx N+JkpvthAJuvxoknGQpT2gTxrfg9EFfFecqsY6N92+sk+HvJXQD1PzO7jncGy64gBOYO SG7OCNOLEFz7yyRIEGXgc3jT/ViEyENyCl3acIG0q6OyWSO+7ZNWdhvAkpZEOh0KOJtH ORuqRGqoRsQGyVYogLFJJ2Q+nuih7JDZuYFv+F285B5fLVnDx9hESdsYA2cjIgZDhn7b VCdA== X-Gm-Message-State: AOJu0Yy3LPPNpxUzqJB6Q3SV8NsAdbn7XtG74XYtIVLyKBrlsdP2clBG ECY/oy9HPDHFt02ZfA5pv91UskYvaqJDnZ36wvTsMmcmP129/SOdTjgBdRbRmEYszZJPtwrPwme w X-Gm-Gg: ASbGncuET6+0cLlH+raenLrio3yYmjb3vXjl6jb3AtTXYmPIUP+lBbxQEJln3cA3Fvc JrIfkpEtm6d7HDI0VWaWtpj0SgMUvPAibSocSzE+qf16qbT0wf8C1YQl2rSWwScYv2SjwunSjzK vF2ksOShhMhhsuDmqgZq0lZylKLWi80/eIFNJO/LJMBNDx6xQy3MQ0KJSQjmVrKUkIdV1m3DYlO gfG0yJMkBBSfUuYWoXNXk3nZSWqJ2Aj9928gTO+6LorrYNuuS4PGqvJKpGgTzUo53j5lzMNlmlc qADH3HbMDHcTZVzjbEZBTgLqVxJw5SOWWwfR6Ny9B+rLRULPsAww0PFotzt2ayqBNVM4XEcUSaG S0XQIKRj1OCsbrHbRaW0vrKPoMRFKIw== X-Google-Smtp-Source: AGHT+IFFDabTZixO+e5sAR1FX1lGbsGU7mFepQeZGMHMboFlwZ4ePzjLUfieuUPI1GSRjfgrNgbTVg== X-Received: by 2002:a05:6000:1f8f:b0:391:2dea:c984 with SMTP id ffacd0b85a97d-3997f8f6129mr14693864f8f.11.1742907748366; Tue, 25 Mar 2025 06:02:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Eduardo Habkost , Zhao Liu , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Anton Johansson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Paolo Bonzini , Nicholas Piggin , Richard Henderson , qemu-ppc@nongnu.org Subject: [PATCH-for-10.1 1/5] target/i386: Use explicit little-endian LD/ST API Date: Tue, 25 Mar 2025 14:02:16 +0100 Message-ID: <20250325130221.76116-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250325130221.76116-1-philmd@linaro.org> References: <20250325130221.76116-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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=ham 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 @linaro.org) X-ZM-MESSAGEID: 1742907922615019000 The x86 architecture uses little endianness. Directly use the little-endian LD/ST API. Mechanical change using: $ end=3Dle; \ for acc in uw w l q tul; do \ sed -i -e "s/ld${acc}_p(/ld${acc}_${end}_p(/" \ -e "s/st${acc}_p(/st${acc}_${end}_p(/" \ $(git grep -wlE '(ld|st)t?u?[wlq]_p' target/i386/); \ done Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20241004163042.85922-10-philmd@linaro.org> --- target/i386/gdbstub.c | 24 ++++++++++----------- target/i386/tcg/system/excp_helper.c | 4 ++-- target/i386/xsave_helper.c | 32 ++++++++++++++-------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index 04c49e802d7..9262cf46b0a 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -94,10 +94,10 @@ static int gdb_read_reg_cs64(uint32_t hflags, GByteArra= y *buf, target_ulong val) static int gdb_write_reg_cs64(uint32_t hflags, uint8_t *buf, target_ulong = *val) { if (hflags & HF_CS64_MASK) { - *val =3D ldq_p(buf); + *val =3D ldq_le_p(buf); return 8; } - *val =3D ldl_p(buf); + *val =3D ldl_le_p(buf); return 4; } =20 @@ -231,7 +231,7 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray = *mem_buf, int n) static int x86_cpu_gdb_load_seg(X86CPU *cpu, X86Seg sreg, uint8_t *mem_buf) { CPUX86State *env =3D &cpu->env; - uint16_t selector =3D ldl_p(mem_buf); + uint16_t selector =3D ldl_le_p(mem_buf); =20 if (selector !=3D env->segs[sreg].selector) { #if defined(CONFIG_USER_ONLY) @@ -287,15 +287,15 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t = *mem_buf, int n) if (n < CPU_NB_REGS) { if (TARGET_LONG_BITS =3D=3D 64) { if (env->hflags & HF_CS64_MASK) { - env->regs[gpr_map[n]] =3D ldtul_p(mem_buf); + env->regs[gpr_map[n]] =3D ldq_le_p(mem_buf); } else if (n < CPU_NB_REGS32) { - env->regs[gpr_map[n]] =3D ldtul_p(mem_buf) & 0xffffffffUL; + env->regs[gpr_map[n]] =3D ldq_le_p(mem_buf) & 0xffffffffUL; } return sizeof(target_ulong); } else if (n < CPU_NB_REGS32) { n =3D gpr_map32[n]; env->regs[n] &=3D ~0xffffffffUL; - env->regs[n] |=3D (uint32_t)ldl_p(mem_buf); + env->regs[n] |=3D (uint32_t)ldl_le_p(mem_buf); return 4; } } else if (n >=3D IDX_FP_REGS && n < IDX_FP_REGS + 8) { @@ -306,8 +306,8 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) } else if (n >=3D IDX_XMM_REGS && n < IDX_XMM_REGS + CPU_NB_REGS) { n -=3D IDX_XMM_REGS; if (n < CPU_NB_REGS32 || TARGET_LONG_BITS =3D=3D 64) { - env->xmm_regs[n].ZMM_Q(0) =3D ldq_p(mem_buf); - env->xmm_regs[n].ZMM_Q(1) =3D ldq_p(mem_buf + 8); + env->xmm_regs[n].ZMM_Q(0) =3D ldq_le_p(mem_buf); + env->xmm_regs[n].ZMM_Q(1) =3D ldq_le_p(mem_buf + 8); return 16; } } else { @@ -315,7 +315,7 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) case IDX_IP_REG: return gdb_write_reg(env, mem_buf, &env->eip); case IDX_FLAGS_REG: - env->eflags =3D ldl_p(mem_buf); + env->eflags =3D ldl_le_p(mem_buf); return 4; =20 case IDX_SEG_REGS: @@ -341,10 +341,10 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t = *mem_buf, int n) return 4; =20 case IDX_FP_REGS + 8: - cpu_set_fpuc(env, ldl_p(mem_buf)); + cpu_set_fpuc(env, ldl_le_p(mem_buf)); return 4; case IDX_FP_REGS + 9: - tmp =3D ldl_p(mem_buf); + tmp =3D ldl_le_p(mem_buf); env->fpstt =3D (tmp >> 11) & 7; env->fpus =3D tmp & ~0x3800; return 4; @@ -362,7 +362,7 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *m= em_buf, int n) return 4; =20 case IDX_MXCSR_REG: - cpu_set_mxcsr(env, ldl_p(mem_buf)); + cpu_set_mxcsr(env, ldl_le_p(mem_buf)); return 4; =20 case IDX_CTL_CR0_REG: diff --git a/target/i386/tcg/system/excp_helper.c b/target/i386/tcg/system/= excp_helper.c index 6876329de21..f00bb15afe0 100644 --- a/target/i386/tcg/system/excp_helper.c +++ b/target/i386/tcg/system/excp_helper.c @@ -85,7 +85,7 @@ static bool ptw_translate(PTETranslate *inout, hwaddr add= r) static inline uint32_t ptw_ldl(const PTETranslate *in, uint64_t ra) { if (likely(in->haddr)) { - return ldl_p(in->haddr); + return ldl_le_p(in->haddr); } return cpu_ldl_mmuidx_ra(in->env, in->gaddr, in->ptw_idx, ra); } @@ -93,7 +93,7 @@ static inline uint32_t ptw_ldl(const PTETranslate *in, ui= nt64_t ra) static inline uint64_t ptw_ldq(const PTETranslate *in, uint64_t ra) { if (likely(in->haddr)) { - return ldq_p(in->haddr); + return ldq_le_p(in->haddr); } return cpu_ldq_mmuidx_ra(in->env, in->gaddr, in->ptw_idx, ra); } diff --git a/target/i386/xsave_helper.c b/target/i386/xsave_helper.c index 996e9f3bfef..fc10bfa6718 100644 --- a/target/i386/xsave_helper.c +++ b/target/i386/xsave_helper.c @@ -43,8 +43,8 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint= 32_t buflen) for (i =3D 0; i < CPU_NB_REGS; i++) { uint8_t *xmm =3D legacy->xmm_regs[i]; =20 - stq_p(xmm, env->xmm_regs[i].ZMM_Q(0)); - stq_p(xmm + 8, env->xmm_regs[i].ZMM_Q(1)); + stq_le_p(xmm, env->xmm_regs[i].ZMM_Q(0)); + stq_le_p(xmm + 8, env->xmm_regs[i].ZMM_Q(1)); } =20 header->xstate_bv =3D env->xstate_bv; @@ -58,8 +58,8 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint= 32_t buflen) for (i =3D 0; i < CPU_NB_REGS; i++) { uint8_t *ymmh =3D avx->ymmh[i]; =20 - stq_p(ymmh, env->xmm_regs[i].ZMM_Q(2)); - stq_p(ymmh + 8, env->xmm_regs[i].ZMM_Q(3)); + stq_le_p(ymmh, env->xmm_regs[i].ZMM_Q(2)); + stq_le_p(ymmh + 8, env->xmm_regs[i].ZMM_Q(3)); } } =20 @@ -101,10 +101,10 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, = uint32_t buflen) for (i =3D 0; i < CPU_NB_REGS; i++) { uint8_t *zmmh =3D zmm_hi256->zmm_hi256[i]; =20 - stq_p(zmmh, env->xmm_regs[i].ZMM_Q(4)); - stq_p(zmmh + 8, env->xmm_regs[i].ZMM_Q(5)); - stq_p(zmmh + 16, env->xmm_regs[i].ZMM_Q(6)); - stq_p(zmmh + 24, env->xmm_regs[i].ZMM_Q(7)); + stq_le_p(zmmh, env->xmm_regs[i].ZMM_Q(4)); + stq_le_p(zmmh + 8, env->xmm_regs[i].ZMM_Q(5)); + stq_le_p(zmmh + 16, env->xmm_regs[i].ZMM_Q(6)); + stq_le_p(zmmh + 24, env->xmm_regs[i].ZMM_Q(7)); } =20 #ifdef TARGET_X86_64 @@ -177,8 +177,8 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *= buf, uint32_t buflen) for (i =3D 0; i < CPU_NB_REGS; i++) { const uint8_t *xmm =3D legacy->xmm_regs[i]; =20 - env->xmm_regs[i].ZMM_Q(0) =3D ldq_p(xmm); - env->xmm_regs[i].ZMM_Q(1) =3D ldq_p(xmm + 8); + env->xmm_regs[i].ZMM_Q(0) =3D ldq_le_p(xmm); + env->xmm_regs[i].ZMM_Q(1) =3D ldq_le_p(xmm + 8); } =20 env->xstate_bv =3D header->xstate_bv; @@ -191,8 +191,8 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *= buf, uint32_t buflen) for (i =3D 0; i < CPU_NB_REGS; i++) { const uint8_t *ymmh =3D avx->ymmh[i]; =20 - env->xmm_regs[i].ZMM_Q(2) =3D ldq_p(ymmh); - env->xmm_regs[i].ZMM_Q(3) =3D ldq_p(ymmh + 8); + env->xmm_regs[i].ZMM_Q(2) =3D ldq_le_p(ymmh); + env->xmm_regs[i].ZMM_Q(3) =3D ldq_le_p(ymmh + 8); } } =20 @@ -241,10 +241,10 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void= *buf, uint32_t buflen) for (i =3D 0; i < CPU_NB_REGS; i++) { const uint8_t *zmmh =3D zmm_hi256->zmm_hi256[i]; =20 - env->xmm_regs[i].ZMM_Q(4) =3D ldq_p(zmmh); - env->xmm_regs[i].ZMM_Q(5) =3D ldq_p(zmmh + 8); - env->xmm_regs[i].ZMM_Q(6) =3D ldq_p(zmmh + 16); - env->xmm_regs[i].ZMM_Q(7) =3D ldq_p(zmmh + 24); + env->xmm_regs[i].ZMM_Q(4) =3D ldq_le_p(zmmh); + env->xmm_regs[i].ZMM_Q(5) =3D ldq_le_p(zmmh + 8); + env->xmm_regs[i].ZMM_Q(6) =3D ldq_le_p(zmmh + 16); + env->xmm_regs[i].ZMM_Q(7) =3D ldq_le_p(zmmh + 24); } =20 #ifdef TARGET_X86_64 --=20 2.47.1