Received: by 2002:a17:906:779e:b0:94e:fe67:1757 with SMTP id s30csp2892235ejm; Mon, 24 Apr 2023 08:28:42 -0700 (PDT) X-Google-Smtp-Source: AKy350b6nL6j27Mie5P3iFXv9xUSTG2FATslfa/mRImT/Bc7Wzb6t+iEB1Y4/YUL8r6B+/MfAWVA X-Received: by 2002:ac8:5a54:0:b0:3ef:4c4b:7e4c with SMTP id o20-20020ac85a54000000b003ef4c4b7e4cmr19941254qta.31.1682350121535; Mon, 24 Apr 2023 08:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682350121; cv=none; d=google.com; s=arc-20160816; b=MW8i8/4j66fIHv3froyLfdL3ul3ipZyJc+rX9UxXCBalAWgDUlMWnS5hIz70gSvtsK bglhyv09Xh3lvc0FqT9FPBWO8EezQuUge4hSXPT12KKOkPAMEUlmrjiIfPvdms51ux1H FvdLGXMYyCntelmJ7UnQP7yO43HJ5uAQ9aDBhOMxs2oqDISh0BXfdbVM8IuVaJjP8XXp gmcVTphezp7AMA72O0Xe2Wl6XmcFWDnBIVjR+XYfMh3ewC4PQjIsNwcwXNOaarcFwU9s M3FNNP5KEUuYecGFo8iIQe9wDxFC23XFCskPocuokC5VlRYIQTJDZhNMkCdfOzfPfNly bZgg== 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=5geIGOhKXTNOnUumAZpLeK5JvkWsmSTZmE66oiXbKTA=; b=KY4yS0QujW6v2qOqboUo5nB5pwNNIs6QcbqKYcgVPR/crgwBWk/J84j9/JTbJ9Zntq 47OGGRjRBJ/rzYOR2xSyr9vpIH1q699JZ6PqG/5HCH1qq3ideF4TUXKQCtX7njbGqLVn xdkHMyWcPpJl+CtsZcJsmHY7GMF+RwA3lNtfRHIiUBYIib+Mi1GuQuNRp9rS3iecWZoD hm4kmVG/SjpB8jXUTyKNkX/ox1LY1R6z60dnaaOrqXATSQJJCKRGZfJazQ/I9KNjTwY5 xIlvCv0ccaf6y8NAP/7J9fyZufrytnNT/Gc6h4L57F1MkGEqwaXZSTv02WI5UDyWaecK TCow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qCgxDrzJ; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=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 s8-20020a05622a178800b003e4de7ad52csi7323365qtk.566.2023.04.24.08.28.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Apr 2023 08:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=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=qCgxDrzJ; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=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 1pqy6F-0006kk-OM; Mon, 24 Apr 2023 11:27:31 -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 1pqy69-0006jQ-Pa for qemu-arm@nongnu.org; Mon, 24 Apr 2023 11:27:29 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqy65-0006sp-LD for qemu-arm@nongnu.org; Mon, 24 Apr 2023 11:27:25 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-2f55ffdbaedso2880895f8f.2 for ; Mon, 24 Apr 2023 08:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682350040; x=1684942040; 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=5geIGOhKXTNOnUumAZpLeK5JvkWsmSTZmE66oiXbKTA=; b=qCgxDrzJL3LSqI1wVDFaTIGojdBAyr0bJzIWpUmhDIWkmCI8b3/VQ181bQyGx1O9U3 VItbssMh+OI4giOAbPky5htwDBVF+6D2FTHU1LOqaF5TGC4swGQsoB8QZ6bRcxX0UXnl TqWTxKEHhgIEt48jgvjGox/XdGIc+avTXRUUyVxY8ka/Jm0K7LV1TX2VQNuwAUQ8kOX0 9oJaRVBpPU1GEIuHJkFFSNjmMcHDSkSv5YqPrX6DszAboAdiT/gVsf6VCI9+kTCtl7lu 6QP74g4Hcl+M+lb+0XIebn7/D9QGp1BewotjRNyG+2KrQ60NMmHxhECeY03wVWXPh7Zb VmOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682350040; x=1684942040; 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=5geIGOhKXTNOnUumAZpLeK5JvkWsmSTZmE66oiXbKTA=; b=G0zd3RAGgvLx9yEP9TzMUFYoNm2XPV6L2cstinets5K5/7Lxlk3D4WluxCCZDoNRXQ VwLFI8CfzKT2Lx1h0iNxap0SpRXX9ZhFHpuOHgV1A3IsrhIfbf3o6ayOgW4xajdbevjr FXmsQkhmZH+MwcQzFxCykWE5rij3NER4VJJGzCvah0K0qLR0Xw+WLE8WzTCW4ZFiya8g MwZ3AUv78iT74EmgTF2a7rLX9fEZxOKBRAEuX5Z87LjvqYWFtbXenvYeNX+5lgTBWcG+ 5497+pfnzIldCozUqBufD1jHm8m5oEuSexqn786nYDwscsaG/ChmrkPtLc2eNSUkkGbk mHkw== X-Gm-Message-State: AAQBX9eYzFub6rEgzvkYwu31FkiU1Q3ufDT9S0dww4gUDoB/B8SE8+2A L7lBlp7xlDGrk3KEd/uu89ChMUqoY2zMs0WSdT4= X-Received: by 2002:adf:fc11:0:b0:2f9:95b4:450a with SMTP id i17-20020adffc11000000b002f995b4450amr9730401wrr.25.1682350040318; Mon, 24 Apr 2023 08:27:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id b1-20020a5d45c1000000b002fdeafcb132sm10971517wrs.107.2023.04.24.08.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 08:27:20 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jeffery , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 2/3] hw/arm/aspeed: Use arm_write_bootloader() to write the bootloader Date: Mon, 24 Apr 2023 16:27:16 +0100 Message-Id: <20230424152717.1333930-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424152717.1333930-1-peter.maydell@linaro.org> References: <20230424152717.1333930-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: o6Q0WHW/Ule2 From: Cédric Le Goater When writing the secondary-CPU stub boot loader code to the guest, use arm_write_bootloader() instead of directly calling rom_add_blob_fixed(). This fixes a bug on big-endian hosts, because arm_write_bootloader() will correctly byte-swap the host-byte-order array values into the guest-byte-order to write into the guest memory. Cc: qemu-stable@nongnu.org Signed-off-by: Cédric Le Goater [PMM: Moved the "make arm_write_bootloader() function public" part to its own patch; updated commit message to note that this fixes an actual bug; adjust to the API changes noted in previous commit] Signed-off-by: Peter Maydell --- hw/arm/aspeed.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index c1f2b9cfcab..0b29028fe11 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -200,33 +200,35 @@ struct AspeedMachineState { static void aspeed_write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) { - static const uint32_t poll_mailbox_ready[] = { + AddressSpace *as = arm_boot_address_space(cpu, info); + static const ARMInsnFixup poll_mailbox_ready[] = { /* * r2 = per-cpu go sign value * r1 = AST_SMP_MBOX_FIELD_ENTRY * r0 = AST_SMP_MBOX_FIELD_GOSIGN */ - 0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5 */ - 0xe21000ff, /* ands r0, r0, #255 */ - 0xe59f201c, /* ldr r2, [pc, #28] */ - 0xe1822000, /* orr r2, r2, r0 */ + { 0xee100fb0 }, /* mrc p15, 0, r0, c0, c0, 5 */ + { 0xe21000ff }, /* ands r0, r0, #255 */ + { 0xe59f201c }, /* ldr r2, [pc, #28] */ + { 0xe1822000 }, /* orr r2, r2, r0 */ - 0xe59f1018, /* ldr r1, [pc, #24] */ - 0xe59f0018, /* ldr r0, [pc, #24] */ + { 0xe59f1018 }, /* ldr r1, [pc, #24] */ + { 0xe59f0018 }, /* ldr r0, [pc, #24] */ - 0xe320f002, /* wfe */ - 0xe5904000, /* ldr r4, [r0] */ - 0xe1520004, /* cmp r2, r4 */ - 0x1afffffb, /* bne */ - 0xe591f000, /* ldr pc, [r1] */ - AST_SMP_MBOX_GOSIGN, - AST_SMP_MBOX_FIELD_ENTRY, - AST_SMP_MBOX_FIELD_GOSIGN, + { 0xe320f002 }, /* wfe */ + { 0xe5904000 }, /* ldr r4, [r0] */ + { 0xe1520004 }, /* cmp r2, r4 */ + { 0x1afffffb }, /* bne */ + { 0xe591f000 }, /* ldr pc, [r1] */ + { AST_SMP_MBOX_GOSIGN }, + { AST_SMP_MBOX_FIELD_ENTRY }, + { AST_SMP_MBOX_FIELD_GOSIGN }, + { 0, FIXUP_TERMINATOR } }; + static const uint32_t fixupcontext[FIXUP_MAX] = { 0 }; - rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready, - sizeof(poll_mailbox_ready), - info->smp_loader_start); + arm_write_bootloader("aspeed.smpboot", as, info->smp_loader_start, + poll_mailbox_ready, fixupcontext); } static void aspeed_reset_secondary(ARMCPU *cpu, -- 2.34.1