From nobody Wed Sep 17 06:39:38 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=1671746200; cv=none; d=zohomail.com; s=zohoarc; b=m3RKo8xs7pvNHj1yiw0vcL9zKr4CwmscbJqS2lsQXylx14BBskqEFjcRrNvlLJbFBTXZcLvHnRAJyU7tBECTul69+poez2Uee508ZMkucv+CcBkSm7aFaIl0bbZhPpfHj6tO9LbVmPfY9L2w+og/6ltlXSNGkPaT8IcYivE6QzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671746200; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XrBY8xhhloPHHStYYTzLZIUBphfWCL1Sr3LvXL9Y2+E=; b=O0UH37LPD767oDrYSUjSc4AoF19YGgMpBEvkMoPh1reCybPxMrI+bNJ4a4IAlaKNpwigoorPB6+Io+X6+radf9ZNPCuHQ/mU63bxuHca9ShVqx5t4Ar2cKQQkfloJH9IWOMcAB6JWUV7awsENSenibXx/GtsWKDBW2soi9F1oCk= 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 1671746200099769.5145704252232; Thu, 22 Dec 2022 13:56:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8TYB-00063b-4V; Thu, 22 Dec 2022 16:56:27 -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 1p8TY9-00062T-HU for qemu-devel@nongnu.org; Thu, 22 Dec 2022 16:56:25 -0500 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p8TY7-0007AX-Tb for qemu-devel@nongnu.org; Thu, 22 Dec 2022 16:56:25 -0500 Received: by mail-ed1-x52a.google.com with SMTP id d14so4727089edj.11 for ; Thu, 22 Dec 2022 13:56:23 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id k6-20020aa7d2c6000000b00467c3cbab6fsm791917edr.77.2022.12.22.13.56.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 22 Dec 2022 13:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=XrBY8xhhloPHHStYYTzLZIUBphfWCL1Sr3LvXL9Y2+E=; b=vZZzVd2GmPjInNPlJIQ7HLDrLVkDwzvBoAawnQ3s64Se3LU/32AzmhOvbDfL/oUoQG jrzmdjznaxldhfv2Eiv60h3JKNPCkLEivxWEpFR3eUj+3+0IFgc6c1qWveXW51sqJIf6 muL5K9YYLzKof4V+nUeLeqGRYmPGS9unr70lZLWPbKmiQQ1FNWVeUF8xrMLukjz4s3wG lM4RxS/ydo+esz3Se40mIhj0g+hI9HomJbp0X5ewuY8dDcsAJQfBfv3Kmd19cgnEnDaq 8XhqdDlRYuR+rQ5LzRSTbDMhJmOFCPiC1axyOXliDhH9jNX5cq3FYtQklxrH2nXkfjV8 ARVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XrBY8xhhloPHHStYYTzLZIUBphfWCL1Sr3LvXL9Y2+E=; b=J+o9USfXg5waRPVYdARA7Lt8oIi/GIk7Vo/Kdox3jKf9CyBsXM1xVxTxDQvELhebAC WkWj9XB71fZZHAEuBiJZ4x8J6Q76Ufc1mmVlsq4WkYKy1c//xw6Pg3sySmN6KlFaTFdX yPdAu26L6O+rEagCGBqO6Yfcj8RgLn5PMX+/pqaP9x+FUdxdNtnHP4uxzutZU9Uz1unH Tmmttf6ObkkHPccTwZwtTWXvs0XZvug2OSWIogq8EMG1gd4FyOcrVGUgOjObTe1D7V/v fVVVMaL7Zr+nao9kxERnNYvwnNQvsybrcrtLei0HUUmIrwxwwKgtK6iRTcbiHD/84EvP d2MA== X-Gm-Message-State: AFqh2koA7pCiYGmFiQSf6++47+6Lrbsj6s6x/PScNnmt75uEhINwKe24 tcdyI+72KjKFjXOzw2iqAYpDFFHInsfDn3zCr80= X-Google-Smtp-Source: AMrXdXvJWZGKtgF0u8IpdXQ57xPzM/UvjNEFZBGsVuVZ+HieahWzQ7cKHXxf2anpT90WjkVOXAWlEQ== X-Received: by 2002:a05:6402:1cce:b0:472:1b3b:35f1 with SMTP id ds14-20020a0564021cce00b004721b3b35f1mr7556762edb.21.1671746182342; Thu, 22 Dec 2022 13:56:22 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrew Jeffery , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Igor Mitsyanko , Joel Stanley , Havard Skinnemoen , Peter Maydell , "Edgar E. Iglesias" , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Alistair Francis , qemu-arm@nongnu.org, Tyrone Ting Subject: [PATCH 3/6] hw/arm/exynos4210: Remove tswap32() calls and constify smpboot[] Date: Thu, 22 Dec 2022 22:55:46 +0100 Message-Id: <20221222215549.86872-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221222215549.86872-1-philmd@linaro.org> References: <20221222215549.86872-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::52a; envelope-from=philmd@linaro.org; helo=mail-ed1-x52a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1671746202366100011 ARM CPUs fetch instructions in little-endian. smpboot[] encoded instructions are written in little-endian. We call tswap32() on the array. tswap32 function swap a 32-bit value if the target endianness doesn't match the host one. Otherwise it is a NOP. * On a little-endian host, the array is stored as it. tswap32() is a NOP, and the vCPU fetches the instructions as it, in little-endian. * On a big-endian host, the array is stored as it. tswap32() swap the instructions to little-endian, and the vCPU fetches the instructions as it, in little-endian. Using tswap() on system emulation is a bit odd: while the target particularities might change the system emulation, the host ones (such its endianness) shouldn't interfere. We can simplify by using const_le32() to always store the instructions in the array in little-endian, removing the need for the dubious tswap(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/exynos4210.c | 48 ++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c index 8dafa2215b..89ee83456d 100644 --- a/hw/arm/exynos4210.c +++ b/hw/arm/exynos4210.c @@ -468,35 +468,29 @@ static const MemoryRegionOps exynos4210_chipid_and_om= r_ops =3D { } }; =20 -void exynos4210_write_secondary(ARMCPU *cpu, - const struct arm_boot_info *info) +void exynos4210_write_secondary(ARMCPU *cpu, const struct arm_boot_info *i= nfo) { - int n; - uint32_t smpboot[] =3D { - 0xe59f3034, /* ldr r3, External gic_cpu_if */ - 0xe59f2034, /* ldr r2, Internal gic_cpu_if */ - 0xe59f0034, /* ldr r0, startaddr */ - 0xe3a01001, /* mov r1, #1 */ - 0xe5821000, /* str r1, [r2] */ - 0xe5831000, /* str r1, [r3] */ - 0xe3a010ff, /* mov r1, #0xff */ - 0xe5821004, /* str r1, [r2, #4] */ - 0xe5831004, /* str r1, [r3, #4] */ - 0xf57ff04f, /* dsb */ - 0xe320f003, /* wfi */ - 0xe5901000, /* ldr r1, [r0] */ - 0xe1110001, /* tst r1, r1 */ - 0x0afffffb, /* beq */ - 0xe12fff11, /* bx r1 */ - EXYNOS4210_EXT_GIC_CPU_BASE_ADDR, - 0, /* gic_cpu_if: base address of Internal GIC CPU interf= ace */ - 0 /* bootreg: Boot register address is held here */ + const uint32_t smpboot[] =3D { + const_le32(0xe59f3034), /* ldr r3, External gic_cpu_if */ + const_le32(0xe59f2034), /* ldr r2, Internal gic_cpu_if */ + const_le32(0xe59f0034), /* ldr r0, startaddr */ + const_le32(0xe3a01001), /* mov r1, #1 */ + const_le32(0xe5821000), /* str r1, [r2] */ + const_le32(0xe5831000), /* str r1, [r3] */ + const_le32(0xe3a010ff), /* mov r1, #0xff */ + const_le32(0xe5821004), /* str r1, [r2, #4] */ + const_le32(0xe5831004), /* str r1, [r3, #4] */ + const_le32(0xf57ff04f), /* dsb */ + const_le32(0xe320f003), /* wfi */ + const_le32(0xe5901000), /* ldr r1, [r0] */ + const_le32(0xe1110001), /* tst r1, r1 */ + const_le32(0x0afffffb), /* beq */ + const_le32(0xe12fff11), /* bx r1 */ + const_le32(EXYNOS4210_EXT_GIC_CPU_BASE_ADDR), + cpu_to_le32(info->gic_cpu_if_addr), /* base address of Internal GI= C CPU interface */ + cpu_to_le32(info->smp_bootreg_addr) /* Boot register address is he= ld here */ }; - smpboot[ARRAY_SIZE(smpboot) - 1] =3D info->smp_bootreg_addr; - smpboot[ARRAY_SIZE(smpboot) - 2] =3D info->gic_cpu_if_addr; - for (n =3D 0; n < ARRAY_SIZE(smpboot); n++) { - smpboot[n] =3D tswap32(smpboot[n]); - } + rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot), info->smp_loader_start); } --=20 2.38.1