From nobody Thu Jan 23 05:44:12 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=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1737569417; cv=none; d=zohomail.com; s=zohoarc; b=fut0WF+vhfloAPlUFSts6BxwgY0n3BwcJXw/ypNwuVCJTFTp7IzHien+g1rvjE+xJwI/XDsPL1T0PnBwJoZm6YPwM+2JBvZagCHN2JbqNHgMx4iiseGlQiHP3Vs4Jddo4ClJe4I3xV7WTzz2VUQx1q1xCaeWDMTcOsSSUFdxNgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737569417; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9QRXDoPPcL/duLz+uXYv2PH1xo4kMQURNRe197Qz7uQ=; b=DCYBLfmrPZ0cpsxr187NVcky1dbNtc0WwLH8Aoz2qx+MQ9hkFL1Ma6CEKv2rTp5I2f7urfdTSLhSbWwvwbhEpHNKGzmLfXIXmZZ4dNGygB6vCeHWr/vh8qUvCFF8ofHJ4mcQAE9VA+mAFxsrtpsTzb4uyuxcvx0mK6UQS2sFqrs= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737569417390861.3740283082168; Wed, 22 Jan 2025 10:10:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tafAR-0001FS-2P; Wed, 22 Jan 2025 13:09:31 -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 1tafAN-0001ET-2D for qemu-devel@nongnu.org; Wed, 22 Jan 2025 13:09:27 -0500 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tafAG-0001Hz-PS for qemu-devel@nongnu.org; Wed, 22 Jan 2025 13:09:26 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EB3D15C5807; Wed, 22 Jan 2025 18:08:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34068C4CED2; Wed, 22 Jan 2025 18:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737569359; bh=MzWUDml3Pamg2cGR5MkDCjpAy+lkVpxOz1kL+37m3LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sj1Uq4THQcQYv76UGD07d+7BrYo0fFmNKK9I1AQwIZXer7Dt9ZqTSXkm2qtKalKY7 CiJZHZB8HDWUa3tUvEVpbOALrItoUlDcrWbuJIMxDES6T1AueGTuBttiDPkMBmIr9F ndXOjZCI4puX8/pn55MoTuWUMmqvcT6KPK0xK6cKoJULp0ApSOgle6QeGilAy8Bu8i a22gEJAXhFOcb7os/V2Z+DgUHDeiClNplBv1NrUPtglP/mNpPQJcfrwAIClrdwqJXk uEZqSU2rHr8g9CfiwtvdWOfX4+OcStE6ATDGQCE6TtJNyqAtNNjhTqWaC0gxpTfH9u gJSu70SKsB5LQ== From: deller@kernel.org To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson Subject: [PATCH 2/2] hw/hppa: Fix booting Linux kernel with initrd Date: Wed, 22 Jan 2025 19:09:13 +0100 Message-ID: <20250122180913.18667-3-deller@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250122180913.18667-1-deller@kernel.org> References: <20250122180913.18667-1-deller@kernel.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=2604:1380:4641:c500::1; envelope-from=deller@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -73 X-Spam_score: -7.4 X-Spam_bar: ------- X-Spam_report: (-7.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.996, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @kernel.org) X-ZM-MESSAGEID: 1737569418497019000 From: Helge Deller Commit 20f7b890173b ("hw/hppa: Reset vCPUs calling resettable_reset()") broke booting the Linux kernel with initrd which may have been provided on the command line. The problem is, that the mentioned commit zeroes out initial registers which were preset with addresses for the Linux kernel and initrd. Fix it by adding proper variables which are set shortly before starting the firmware. Signed-off-by: Helge Deller Fixes: 20f7b890173b ("hw/hppa: Reset vCPUs calling resettable_reset()") Cc: Philippe Mathieu-Daud=C3=A9 --- hw/hppa/machine.c | 48 +++++++++++++++++++---------------------------- target/hppa/cpu.h | 4 ++++ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 4bcc66cd6f..0dd1908214 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -356,7 +356,6 @@ static void machine_HP_common_init_tail(MachineState *m= achine, PCIBus *pci_bus, uint64_t kernel_entry =3D 0, kernel_low, kernel_high; MemoryRegion *addr_space =3D get_system_memory(); MemoryRegion *rom_region; - unsigned int smp_cpus =3D machine->smp.cpus; SysBusDevice *s; =20 /* SCSI disk setup. */ @@ -482,8 +481,8 @@ static void machine_HP_common_init_tail(MachineState *m= achine, PCIBus *pci_bus, kernel_low, kernel_high, kernel_entry, size / KiB); =20 if (kernel_cmdline) { - cpu[0]->env.gr[24] =3D 0x4000; - pstrcpy_targphys("cmdline", cpu[0]->env.gr[24], + cpu[0]->env.cmdline_or_bootorder =3D 0x4000; + pstrcpy_targphys("cmdline", cpu[0]->env.cmdline_or_bootorder, TARGET_PAGE_SIZE, kernel_cmdline); } =20 @@ -513,32 +512,22 @@ static void machine_HP_common_init_tail(MachineState = *machine, PCIBus *pci_bus, } =20 load_image_targphys(initrd_filename, initrd_base, initrd_size); - cpu[0]->env.gr[23] =3D initrd_base; - cpu[0]->env.gr[22] =3D initrd_base + initrd_size; + cpu[0]->env.initrd_base =3D initrd_base; + cpu[0]->env.initrd_end =3D initrd_base + initrd_size; } } =20 if (!kernel_entry) { /* When booting via firmware, tell firmware if we want interactive - * mode (kernel_entry=3D1), and to boot from CD (gr[24]=3D'd') - * or hard disc * (gr[24]=3D'c'). + * mode (kernel_entry=3D1), and to boot from CD (cmdline_or_bootor= der=3D'd') + * or hard disc (cmdline_or_bootorder=3D'c'). */ kernel_entry =3D machine->boot_config.has_menu ? machine->boot_con= fig.menu : 0; - cpu[0]->env.gr[24] =3D machine->boot_config.order[0]; + cpu[0]->env.cmdline_or_bootorder =3D machine->boot_config.order[0]; } =20 - /* We jump to the firmware entry routine and pass the - * various parameters in registers. After firmware initialization, - * firmware will start the Linux kernel with ramdisk and cmdline. - */ - cpu[0]->env.gr[26] =3D machine->ram_size; - cpu[0]->env.gr[25] =3D kernel_entry; - - /* tell firmware how many SMP CPUs to present in inventory table */ - cpu[0]->env.gr[21] =3D smp_cpus; - - /* tell firmware fw_cfg port */ - cpu[0]->env.gr[19] =3D FW_CFG_IO_BASE; + /* Keep initial kernel_entry for first boot */ + cpu[0]->env.kernel_entry =3D kernel_entry; } =20 /* @@ -675,18 +664,19 @@ static void hppa_machine_reset(MachineState *ms, Rese= tType type) cpu[i]->env.gr[5] =3D CPU_HPA + i * 0x1000; } =20 - /* already initialized by machine_hppa_init()? */ - if (cpu[0]->env.gr[26] =3D=3D ms->ram_size) { - return; - } - cpu[0]->env.gr[26] =3D ms->ram_size; - cpu[0]->env.gr[25] =3D 0; /* no firmware boot menu */ - cpu[0]->env.gr[24] =3D 'c'; - /* gr22/gr23 unused, no initrd while reboot. */ + cpu[0]->env.gr[25] =3D cpu[0]->env.kernel_entry; + cpu[0]->env.gr[24] =3D cpu[0]->env.cmdline_or_bootorder; + cpu[0]->env.gr[23] =3D cpu[0]->env.initrd_base; + cpu[0]->env.gr[22] =3D cpu[0]->env.initrd_end; cpu[0]->env.gr[21] =3D smp_cpus; - /* tell firmware fw_cfg port */ cpu[0]->env.gr[19] =3D FW_CFG_IO_BASE; + + /* reset static fields to avoid starting Linux kernel & initrd on rebo= ot */ + cpu[0]->env.kernel_entry =3D 0; + cpu[0]->env.initrd_base =3D 0; + cpu[0]->env.initrd_end =3D 0; + cpu[0]->env.cmdline_or_bootorder =3D 'c'; } =20 static void hppa_nmi(NMIState *n, int cpu_index, Error **errp) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 083d4f5a56..beea42d105 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -268,6 +268,10 @@ typedef struct CPUArchState { struct {} end_reset_fields; =20 bool is_pa20; + + target_ulong kernel_entry; /* Linux kernel was loaded here */ + target_ulong cmdline_or_bootorder; + target_ulong initrd_base, initrd_end; } CPUHPPAState; =20 /** --=20 2.47.0