From patchwork Fri Nov 8 15:43:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 2008599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=S9jWg/eN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XlNfZ1x3tz1xy0 for ; Sat, 9 Nov 2024 02:49:26 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9RAR-0006On-7t; Fri, 08 Nov 2024 10:44:59 -0500 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 1t9RA0-0005ZL-5z for qemu-ppc@nongnu.org; Fri, 08 Nov 2024 10:44:33 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9R9y-0005gy-8k for qemu-ppc@nongnu.org; Fri, 08 Nov 2024 10:44:31 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4315abed18aso20064345e9.2 for ; Fri, 08 Nov 2024 07:44:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731080669; x=1731685469; 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=zZt7LLYaGK4gLd7N4XPj6yKOClYWTX3p+vA4olh24GE=; b=S9jWg/eNnVWpra7kLz+hDJCIcNCA6qZe0wMZXK1WrDZMiWaeixpscavNpmJQ143Cv1 mhOBnXfsxl/25i+Ph1Jete7Tof05lQvqrHQT4I92vVVK4Cfnn3bLU28x7dOT/rRHK/fq LRgYoDbIy//szUJPgtOSk6ckRNAhuTJ2u1j049Y2/GYN1EExP21tpV+1/6u93th3rWhp A0DidWMVEACNYRVNeWxLV+Kkj2V+LXqpSsNjv/9RJD+vRcixunNW9ilD8ajpW2LIyYkG ywbltn+SBJdYru81jwqV3hGi5yvraXpYl7mLFzCk7YK/XRO4cybMoufkUoJXoXniQTB+ 0AcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731080669; x=1731685469; 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=zZt7LLYaGK4gLd7N4XPj6yKOClYWTX3p+vA4olh24GE=; b=G+jJd+0uCwGbsDoGg/5HYujUIEjAmRRWWHSFVIG4MEZrgABqAnbzrJopcu89P07fWj ORaBq86ZdEVm92WhLkZLEigl+meYWfM5DsQML0PnR86agYXLzh8K1CGlCqBfhaOrHHwu WOPC3k3FiI5LxnhEbaW7moN8AmBaYuurwzvvuqQy4xU46YHxF4erBqxxxecqlJF0BpeU EkikaQDnbtQHZdpICMg3+s1MyScZrZ9G1n0v7Auo1P7kK7UXbjtKj6hLpkA4nNPKt16V hCxBGPggMiwI44vRugRm0ukimUqh4z6lqjZZW2mhhqkjvhIxp27U7IdDxsXCMMeojway 2bxg== X-Forwarded-Encrypted: i=1; AJvYcCXyIQpRO4tBqbkq9mn2NCvPrSJTSBGjqKFxivwfSZq0o2GPf1zcqVDoWGxgcNNHDgp82r349vDmkA==@nongnu.org X-Gm-Message-State: AOJu0Yy7YB/KGCXY/KNR0C4xb3XPSkbpMow2W1tkN0BHkHcilKIoQKi6 gQ7OGdktzBJcniZP8XykRfvdmnB8iDHfiqZu95ed0pEKqpewJDWoiYTAkKAsO1k= X-Google-Smtp-Source: AGHT+IEHI5h3XsffnKUeY8YXQP+sHrMubWc20BUSml0N5bJw1VD7eBUobRAX4ssgnj3+YA7f0xhYzw== X-Received: by 2002:a5d:59c3:0:b0:37d:37b2:385d with SMTP id ffacd0b85a97d-381f186319fmr2860087f8f.12.1731080668871; Fri, 08 Nov 2024 07:44:28 -0800 (PST) Received: from localhost.localdomain ([89.101.134.25]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed99681csm5368641f8f.49.2024.11.08.07.44.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 08 Nov 2024 07:44:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Anton Johansson Cc: Jason Wang , Paolo Bonzini , Richard Henderson , devel@lists.libvirt.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Edgar E. Iglesias" , Thomas Huth , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Peter Maydell , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v3 14/17] target/microblaze: Consider endianness while translating code Date: Fri, 8 Nov 2024 15:43:14 +0000 Message-ID: <20241108154317.12129-15-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108154317.12129-1-philmd@linaro.org> References: <20241108154317.12129-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Consider the CPU ENDI bit, swap instructions when the CPU endianness doesn't match the binary one. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/microblaze/cpu.h | 7 +++++++ target/microblaze/translate.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 3e5a3e5c60..6d540713eb 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -412,6 +412,13 @@ void mb_tcg_init(void); /* Ensure there is no overlap between the two masks. */ QEMU_BUILD_BUG_ON(MSR_TB_MASK & IFLAGS_TB_MASK); +static inline bool mb_cpu_is_big_endian(CPUState *cs) +{ + MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); + + return !cpu->cfg.endi; +} + static inline void cpu_get_tb_cpu_state(CPUMBState *env, vaddr *pc, uint64_t *cs_base, uint32_t *flags) { diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 0b466db694..5595ae4fad 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -709,7 +709,7 @@ static void record_unaligned_ess(DisasContext *dc, int rd, static inline MemOp mo_endian(DisasContext *dc) { - return MO_TE; + return dc->cfg->endi ? MO_LE : MO_BE; } static bool do_load(DisasContext *dc, int rd, TCGv addr, MemOp mop, @@ -1646,7 +1646,8 @@ static void mb_tr_translate_insn(DisasContextBase *dcb, CPUState *cs) dc->tb_flags_to_set = 0; - ir = translator_ldl(cpu_env(cs), &dc->base, dc->base.pc_next); + ir = translator_ldl_swap(cpu_env(cs), &dc->base, dc->base.pc_next, + mb_cpu_is_big_endian(cs) != TARGET_BIG_ENDIAN); if (!decode(dc, ir)) { trap_illegal(dc, true); }