From patchwork Fri Oct 4 16:30:35 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: 832762 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp872791wra; Fri, 4 Oct 2024 09:41:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUY2W3q+q/SCFNR7bfM6hg50fx3CdV76AjiRY43Z1E6etd93gNT+c+WXAdAhn0W4RemAq2w6Q==@linaro.org X-Google-Smtp-Source: AGHT+IFBQy/iB99exhyTGtjTmoTjASlmviY2aHrLeJ3zFJQDWg0D6zyYN9YTsRjtSOjn+BDJa3Ia X-Received: by 2002:a05:600c:21c4:b0:42c:af06:71b with SMTP id 5b1f17b1804b1-42f87e4e24amr16517725e9.28.1728060085896; Fri, 04 Oct 2024 09:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728060085; cv=none; d=google.com; s=arc-20240605; b=FLeDxD0SNkv3A/0Z6KMpdfdW9+ZulxesOC5ctOd5rvPgsXUzJYHpTgxm9NbU19OCPe ykr84oaqxV9wRboVjo1BABZWoJ8nNbM1tDREBS+ZnBAcQvrz1OvW3XQLZ3dgnmEojO73 HJmqFF/2agqdZtVey8PmGv+VLq3Iaz43yf54ZMGoy//zdMSkLny88dmNnfSrymZttW2K qIF8lqhllQJjMM6l2E88xdMv6uTLNB9sHhZIRk4XKLYqbs4o/iQpebQLd6K04DAPgOGo oqvRX/JuC9gBXhJW6HuKI/8vstPiDv8yUpxpXoFu5/qUeALJtH5zGBcpauAy+62YOkBF PV/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=6M7F9MlipNOYzrQaom9GAgFYoDMLlj7tvvuZZcP6m74=; fh=Cyx8393Oz+CWhBBtvLnsw/Ha6TQ3OyuB9akIVJXTJlY=; b=IqtLW9oNudT2x8nyQ1YxQ5WmHILlQ3tEUrfxb33RMKgoY9TXuMB04XTzaM6iV3ghPz C6TwMc4A9qkr5awMP7XHXDdt7E8yUd61Le/RTn6AOhLzgYLJCRALvrWgPmtGkwpas5iT CmSmoWu3kqurfa2kI+VWmhEl7KVeSbbvYChuvFG73uJrvDbo/v9LwDaqjICe638yK2Su sOk/H1ub97O9ty1Gw6U3pl0wHLDOdAfXB6RBf7kw7v02XwPk617OoEAV0Lx4BzQtSxgQ skMmwLGDh5tQwbKvLaFrDMhrww/HHbZQLLPfeuppO6Y/36zC/XFCI36rEwqqr2FzYHf3 ODwQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZYz+7t0T; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-37d1695e9d1si17829f8f.443.2024.10.04.09.41.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Oct 2024 09:41:25 -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=pass header.i=@linaro.org header.s=google header.b=ZYz+7t0T; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swlJH-0005lp-U4; Fri, 04 Oct 2024 12:37:44 -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 1swlHN-00012F-N6 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:49 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1swlHE-0006XK-D4 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:35:39 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5398e7dda5fso2436446e87.0 for ; Fri, 04 Oct 2024 09:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728059733; x=1728664533; 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=6M7F9MlipNOYzrQaom9GAgFYoDMLlj7tvvuZZcP6m74=; b=ZYz+7t0TtaAPsYKGt8H5gHvKwveX6NZfEZcJ6CoTN2XjjBAEVW0dbDdjVtJVM9tBvV 1s4d/0gDwgYrY/3ObyVbCpuOSw0hHN74XeHcezXNRg81KqkL1m4MAjzugw2kMEsRrIUo 5FNqAuIkbZKIzQE/SN6FOxdcQ2M57zNE6mgtYMUQjFLFWSR/MtobeRWtv9K+PL+gHPdX ALGiA+QjQaRsXAJ58mbdEPerSo6Z3Ar79/LMMzv9jHSr93x+L4WdwUpPGyCaK1qet6vW mCpq1KKzu0Cuddb17ZQtox93HgIWcquQqjEuRa/882NwM9IiieYu/mHQ/zHL91z0frnB BJ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728059733; x=1728664533; 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=6M7F9MlipNOYzrQaom9GAgFYoDMLlj7tvvuZZcP6m74=; b=J1jVMBGKTP09vSVmjPq7H5OhKg9wghMyx83Seg+Q2TuNOXyO2206ft10Kh/T+IbvLe iXuqmkDX/+56lJzZGS8PBbAt5VtuLuSE/hWhnbixrGtEfvgm5+pL2KLW2Ow83Ta71DUN 8tZ/njeBWQwK/SU0pjNEHMfv2kixvMQMk7cl16Cin4z1IYup2foY9Ie/MzKlMFEazrQe bzM/M98BeTU77eb5mmvamp8bI3BpnwUw9S1Ii9pALL5g7FRv0VeKU3pfBJWqGS4Ebyiy H+JdhgqiB2hGLilxTOUOQpZRnfTFgxF0XitFKVcIbhkyVr1oaABbTfpvI3iCXa5iGA8c JVnQ== X-Gm-Message-State: AOJu0YxLNSqwiGwEP2ZUHptOoUJs63sxaVXyUh1kchn0iVP+AugIJEKH dGR9mYLGkoYBxbM83CpQXllHcHAy6QlEnNRkEjV0xU9zurSDqSWK3XVV6DlGE/22CPZcYQE+5fL 6QBoIQQ== X-Received: by 2002:a05:6512:1387:b0:539:955b:43d0 with SMTP id 2adb3069b0e04-539ab9d0ad2mr2091898e87.47.1728059733102; Fri, 04 Oct 2024 09:35:33 -0700 (PDT) Received: from localhost.localdomain ([91.223.100.150]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539aff23e0bsm1307e87.243.2024.10.04.09.35.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Oct 2024 09:35:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Thomas Huth , Richard Henderson , Pierrick Bouvier , qemu-ppc@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 19/25] hw/sparc: Use explicit big-endian LD/ST API Date: Fri, 4 Oct 2024 13:30:35 -0300 Message-ID: <20241004163042.85922-20-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241004163042.85922-1-philmd@linaro.org> References: <20241004163042.85922-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The SPARC architecture uses big endianness. Directly use the big-endian LD/ST API. for a in uw w l q;do sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" $(git grep -wlE '(ld|st)u?[wlq]_p' hw/sparc/);done Signed-off-by: Philippe Mathieu-Daudé --- hw/sparc/leon3.c | 42 +++++++++++++++++++++--------------------- hw/sparc/sun4m.c | 6 +++--- hw/sparc64/sun4u.c | 6 +++--- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 6aaa04cb191..021b5070128 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -78,21 +78,21 @@ typedef struct ResetData { static uint32_t *gen_store_u32(uint32_t *code, hwaddr addr, uint32_t val) { - stl_p(code++, 0x82100000); /* mov %g0, %g1 */ - stl_p(code++, 0x84100000); /* mov %g0, %g2 */ - stl_p(code++, 0x03000000 + + stl_be_p(code++, 0x82100000); /* mov %g0, %g1 */ + stl_be_p(code++, 0x84100000); /* mov %g0, %g2 */ + stl_be_p(code++, 0x03000000 + extract32(addr, 10, 22)); /* sethi %hi(addr), %g1 */ - stl_p(code++, 0x82106000 + + stl_be_p(code++, 0x82106000 + extract32(addr, 0, 10)); /* or %g1, addr, %g1 */ - stl_p(code++, 0x05000000 + + stl_be_p(code++, 0x05000000 + extract32(val, 10, 22)); /* sethi %hi(val), %g2 */ - stl_p(code++, 0x8410a000 + + stl_be_p(code++, 0x8410a000 + extract32(val, 0, 10)); /* or %g2, val, %g2 */ - stl_p(code++, 0xc4204000); /* st %g2, [ %g1 ] */ + stl_be_p(code++, 0xc4204000); /* st %g2, [ %g1 ] */ return code; } @@ -112,13 +112,13 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr) /* If we are running on a secondary CPU, jump directly to the kernel. */ - stl_p(p++, 0x85444000); /* rd %asr17, %g2 */ - stl_p(p++, 0x8530a01c); /* srl %g2, 0x1c, %g2 */ - stl_p(p++, 0x80908000); /* tst %g2 */ + stl_be_p(p++, 0x85444000); /* rd %asr17, %g2 */ + stl_be_p(p++, 0x8530a01c); /* srl %g2, 0x1c, %g2 */ + stl_be_p(p++, 0x80908000); /* tst %g2 */ /* Filled below. */ sec_cpu_branch_p = p; - stl_p(p++, 0x0BADC0DE); /* bne xxx */ - stl_p(p++, 0x01000000); /* nop */ + stl_be_p(p++, 0x0BADC0DE); /* bne xxx */ + stl_be_p(p++, 0x01000000); /* nop */ /* Initialize the UARTs */ /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */ @@ -133,17 +133,17 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr) p = gen_store_u32(p, 0x80000318, 3); /* Now, the relative branch above can be computed. */ - stl_p(sec_cpu_branch_p, 0x12800000 - + (p - sec_cpu_branch_p)); + stl_be_p(sec_cpu_branch_p, 0x12800000 + + (p - sec_cpu_branch_p)); /* JUMP to the entry point */ - stl_p(p++, 0x82100000); /* mov %g0, %g1 */ - stl_p(p++, 0x03000000 + extract32(kernel_addr, 10, 22)); - /* sethi %hi(kernel_addr), %g1 */ - stl_p(p++, 0x82106000 + extract32(kernel_addr, 0, 10)); - /* or kernel_addr, %g1 */ - stl_p(p++, 0x81c04000); /* jmp %g1 */ - stl_p(p++, 0x01000000); /* nop */ + stl_be_p(p++, 0x82100000); /* mov %g0, %g1 */ + stl_be_p(p++, 0x03000000 + extract32(kernel_addr, 10, 22)); + /* sethi %hi(kernel_addr), %g1 */ + stl_be_p(p++, 0x82106000 + extract32(kernel_addr, 0, 10)); + /* or kernel_addr, %g1 */ + stl_be_p(p++, 0x81c04000); /* jmp %g1 */ + stl_be_p(p++, 0x01000000); /* nop */ } static void leon3_cpu_reset(void *opaque) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index d52e6a7213f..f375f0d389b 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -271,9 +271,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename, if (*initrd_size > 0) { for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) { ptr = rom_ptr(KERNEL_LOAD_ADDR + i, 24); - if (ptr && ldl_p(ptr) == 0x48647253) { /* HdrS */ - stl_p(ptr + 16, INITRD_LOAD_ADDR); - stl_p(ptr + 20, *initrd_size); + if (ptr && ldl_be_p(ptr) == 0x48647253) { /* HdrS */ + stl_be_p(ptr + 16, INITRD_LOAD_ADDR); + stl_be_p(ptr + 20, *initrd_size); break; } } diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 4ece1ac1ffc..e591e5a741a 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -210,9 +210,9 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename, if (*initrd_size > 0) { for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) { ptr = rom_ptr(*kernel_addr + i, 32); - if (ptr && ldl_p(ptr + 8) == 0x48647253) { /* HdrS */ - stl_p(ptr + 24, *initrd_addr + *kernel_addr); - stl_p(ptr + 28, *initrd_size); + if (ptr && ldl_be_p(ptr + 8) == 0x48647253) { /* HdrS */ + stl_be_p(ptr + 24, *initrd_addr + *kernel_addr); + stl_be_p(ptr + 28, *initrd_size); break; } }