From patchwork Thu Dec 22 21:55:45 2022 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: 635953 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp125712pvb; Thu, 22 Dec 2022 13:56:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXtWwXSbhR8zEzFWD2B1Dfud4gJH7rSNuBkN8UHGQXLvNgJ+d70Uen6G+DWT3OdHHpiVHc6V X-Received: by 2002:a0c:e98e:0:b0:4c7:8c96:d2ca with SMTP id z14-20020a0ce98e000000b004c78c96d2camr7250710qvn.15.1671746196240; Thu, 22 Dec 2022 13:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671746196; cv=none; d=google.com; s=arc-20160816; b=GWcp4y61Un/yUB9lp73z6O13oubQPSxl6+iGJmhO7uLIo4mkkSMg8kBXikTSAxxVq1 2r0E0qf11RUf2IAzThUvTeWtE+yAk1RwD8dGo+uai4yAOkpuCuXrIv/BP+QYPfHyoMkF QhApGu0UDHs2NGfyLfpb+n1Iow3yiehdJ9NfWxkxwBS9LZjRAAXqDfARlNolNAOFWdQ4 +VkQlri4mdfvHyfvj5QHzck7gV9c4uKefoCHFaV5ynYqpp0swI3hlp4zTsp8T27ajb7I UsCbT5Ca5mJyPn+cZ6ut91PWt4Yo45q1at8tujK9cLC3c3WI80XaatizHVENKqnzy1kX bXJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=AlbISwcoF8H6Ar9FnAMnX+v9JsbwYxtSUgLoTP68Yao=; b=HL+1CG45MdpDwSJ1HVjANZHuYQ4KZUb/7sKsuivTVdPpvQ8EIWsDyC262L9YZXq3J+ UnWHQ5FWqV9Cp0e0+9gxwwOKn6dFwmXMkQTLZ3I5AaUBdcpqyLeh1qLGatiSaFq2pkEC hMwmhNms8242YDq/hO4BCSH95ffrf49z/Pr8YpVA0skLg+M3aIbtH/zPChtXVuBW4W0N l4bPrwQKNSOUoppbuPQCk4pVVnvJfwmDrTUoxq6cDLH714smEdRwda35HkFvIq55s6Cj dVhsKF7CAtvVM2/EYlnuNUX6ngLT7eXgM9Yx5YrVsoWjLx30os8LNOeP1FE+xWIG5w4S rJgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TjwkXWpK; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6-20020a0562140d4600b004c6e2c3972fsi594528qvr.584.2022.12.22.13.56.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Dec 2022 13:56:36 -0800 (PST) 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=TjwkXWpK; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8TY2-00061M-Mu; Thu, 22 Dec 2022 16:56:18 -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 1p8TY1-000617-V3 for qemu-devel@nongnu.org; Thu, 22 Dec 2022 16:56:17 -0500 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p8TY0-0007A8-8f for qemu-devel@nongnu.org; Thu, 22 Dec 2022 16:56:17 -0500 Received: by mail-ed1-x532.google.com with SMTP id i9so4765411edj.4 for ; Thu, 22 Dec 2022 13:56:15 -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=AlbISwcoF8H6Ar9FnAMnX+v9JsbwYxtSUgLoTP68Yao=; b=TjwkXWpK7sWdeaEkSOn7VT6qF7d7U8U4y7e75Dbmw4WyOYjJiSn2Q59SoqZ1U0M5Cs gZ+aKXgZPEwZ7TrwDS5W0ocFtv2inntkkeITuG51lYDt57W6sjYJmUpVFRlEjeI4Po3f v/mH+76S7WXUvektN2uPZMGkc7ytKYvLhYis5wdpWThDm70iXsHNqBaQDaMCaFNo6fZ5 h3T09DbKCeVju37PxiP4bqAbs+iB2ymmQkHDFUM8159OPpqA8/CqEHGOa7cMPWtl7bHZ CqhKMjgc/ae3eARHs7O9q+vDgnfrmlANQYVAr1rQWcj0rksi6T/UVvcERFoLoJxGJij8 L6lg== 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=AlbISwcoF8H6Ar9FnAMnX+v9JsbwYxtSUgLoTP68Yao=; b=UV4g4fjEmxcisLiCO4kj7NYkAqZ7cQdtlFaV0OTKQmC7sCUceXNh1jDgwM100UYedE gmec/E3/AfzirNlKRSlc6xYag20XAIW4dAwIAKjRU1VNPh/zHyH9Zm/KI+v9NYUPfWk/ 4jEnlMk9bmEC0djGhwXUU8b5JWApyLgEwQrUkx/XzxfL7Cn703S1RXNhGAtppnfiK+hT Gh7pZsUPu9Yb9PfOG7M+FS8EeLcm18YzxEfN6eohbPWssrq8/K5IcyjKABDZFYDxdFnt o878DbUqJpIG1HuTDj+hKvWnr+2lAHkEBfwL2mphnbZDJKIgNn00/etohsJg1R9DTilw f6dg== X-Gm-Message-State: AFqh2kqgbQhzRN/yrJIpq6reB+oz7Rb91R2C0fdc08jhMw0pdWupApms NkrhW/R/ES2pa4EvsqdvaUNzlpcVTsdM1LIZF2I= X-Received: by 2002:a05:6402:25c6:b0:478:5688:7c9f with SMTP id x6-20020a05640225c600b0047856887c9fmr11440513edb.29.1671746174701; Thu, 22 Dec 2022 13:56:14 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id g24-20020a50ec18000000b0046b847d6a1csm792523edr.21.2022.12.22.13.56.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 22 Dec 2022 13:56:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Igor Mitsyanko , Joel Stanley , Havard Skinnemoen , Peter Maydell , "Edgar E. Iglesias" , =?utf-8?q?C=C3=A9dric_Le_Go?= =?utf-8?q?ater?= , Alistair Francis , qemu-arm@nongnu.org, Tyrone Ting Subject: [PATCH 2/6] hw/arm/raspi: Fix smpboot[] on big-endian hosts Date: Thu, 22 Dec 2022 22:55:45 +0100 Message-Id: <20221222215549.86872-3-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 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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 ARM CPUs fetch instructions in little-endian. smpboot[] encoded instructions are written in little-endian. This is fine on little-endian host, but on big-endian ones the smpboot[] array ends swapped. Use the const_le32() macro so the instructions are always in little-endian in the smpboot[] array. Fixes: 1df7d1f930 ("raspi: add raspberry pi 2 machine") Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/raspi.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 92d068d1f9..72572a45c2 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -125,18 +125,18 @@ static const char *board_type(uint32_t board_rev) static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) { static const uint32_t smpboot[] = { - 0xe1a0e00f, /* mov lr, pc */ - 0xe3a0fe00 + (BOARDSETUP_ADDR >> 4), /* mov pc, BOARDSETUP_ADDR */ - 0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5;get core ID */ - 0xe7e10050, /* ubfx r0, r0, #0, #2 ;extract LSB */ - 0xe59f5014, /* ldr r5, =0x400000CC ;load mbox base */ - 0xe320f001, /* 1: yield */ - 0xe7953200, /* ldr r3, [r5, r0, lsl #4] ;read mbox for our core*/ - 0xe3530000, /* cmp r3, #0 ;spin while zero */ - 0x0afffffb, /* beq 1b */ - 0xe7853200, /* str r3, [r5, r0, lsl #4] ;clear mbox */ - 0xe12fff13, /* bx r3 ;jump to target */ - 0x400000cc, /* (constant: mailbox 3 read/clear base) */ + const_le32(0xe1a0e00f), /* mov lr, pc */ + const_le32(0xe3a0fe00 + (BOARDSETUP_ADDR >> 4)), /* mov pc, BOARDSETUP_ADDR */ + const_le32(0xee100fb0), /* mrc p15, 0, r0, c0, c0, 5;get core ID */ + const_le32(0xe7e10050), /* ubfx r0, r0, #0, #2 ;extract LSB */ + const_le32(0xe59f5014), /* ldr r5, =0x400000CC ;load mbox base */ + const_le32(0xe320f001), /* 1: yield */ + const_le32(0xe7953200), /* ldr r3, [r5, r0, lsl #4] ;read mbox for our core*/ + const_le32(0xe3530000), /* cmp r3, #0 ;spin while zero */ + const_le32(0x0afffffb), /* beq 1b */ + const_le32(0xe7853200), /* str r3, [r5, r0, lsl #4] ;clear mbox */ + const_le32(0xe12fff13), /* bx r3 ;jump to target */ + const_le32(0x400000cc), /* (constant: mailbox 3 read/clear base) */ }; /* check that we don't overrun board setup vectors */ @@ -162,17 +162,17 @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) * a rom blob, so that the reset for ROM contents zeroes them for us. */ static const uint32_t smpboot[] = { - 0xd2801b05, /* mov x5, 0xd8 */ - 0xd53800a6, /* mrs x6, mpidr_el1 */ - 0x924004c6, /* and x6, x6, #0x3 */ - 0xd503205f, /* spin: wfe */ - 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */ - 0xb4ffffc4, /* cbz x4, spin */ - 0xd2800000, /* mov x0, #0x0 */ - 0xd2800001, /* mov x1, #0x0 */ - 0xd2800002, /* mov x2, #0x0 */ - 0xd2800003, /* mov x3, #0x0 */ - 0xd61f0080, /* br x4 */ + const_le32(0xd2801b05), /* mov x5, 0xd8 */ + const_le32(0xd53800a6), /* mrs x6, mpidr_el1 */ + const_le32(0x924004c6), /* and x6, x6, #0x3 */ + const_le32(0xd503205f), /* spin: wfe */ + const_le32(0xf86678a4), /* ldr x4, [x5,x6,lsl #3] */ + const_le32(0xb4ffffc4), /* cbz x4, spin */ + const_le32(0xd2800000), /* mov x0, #0x0 */ + const_le32(0xd2800001), /* mov x1, #0x0 */ + const_le32(0xd2800002), /* mov x2, #0x0 */ + const_le32(0xd2800003), /* mov x3, #0x0 */ + const_le32(0xd61f0080), /* br x4 */ }; static const uint64_t spintables[] = {