From patchwork Mon Aug 12 10:15:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13760398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50114C3DA7F for ; Mon, 12 Aug 2024 10:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mAQKjCfVDbFPY8Bci62QPwDNz8mKQfUPFp6jyx/bl7k=; b=xL/g2LRWzm83HFqQZoB66NC+SZ vh9JUZXsfoZXcRZtyE6+ZdNsdAp1Kt4OET83K44hZA4LtA90vKoeT2oYBS8a8FuHLeAbrx2SHR4hl dN/5HsRfia73/d6+UJ8sTckofGIgLGZAqkJey3zxHpQOLKBdwMBxi875Svl7vEHcDoZpYyWlUcn7z +RiJ6LA2eKGm3RTUhCq93apvM2uHrK6DSnHM+D6s/89iMVY2zQzl52yw/2G2EJhpTPtMkNk8d7sWY 2AuAPufTz/sKIqGbUglN02pI2j1czzuCQCpdmxs1YX4+tor77cjnRSBB+nmu2hOrISbCEH7pscF05 T+28QNaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdSBP-0000000Haei-3vCv; Mon, 12 Aug 2024 10:21:47 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdS60-0000000HZhv-2Zjd for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 10:16:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 458A2106F; Mon, 12 Aug 2024 03:16:38 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 897223F6A8; Mon, 12 Aug 2024 03:16:11 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: akos.denke@arm.com, andre.przywara@arm.com, luca.fancellu@arm.com, mark.rutland@arm.com, maz@kernel.org Subject: [BOOT-WRAPPER v2 08/10] Simplify spin logic Date: Mon, 12 Aug 2024 11:15:53 +0100 Message-Id: <20240812101555.3558589-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240812101555.3558589-1-mark.rutland@arm.com> References: <20240812101555.3558589-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_031612_816744_FCD704B4 X-CRM114-Status: GOOD ( 14.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The logic for initial boot is more complicated than it needs to be, with both first_spin() having a special case for CPU0 that requires an additional argument to be passed to spin(). Simplify this by moving the special-case logic for CPU0 into first_spin(). This removes the need to provide a dummy mailbox for CPU0 to spin on, simplfiies callers of first_spin() and spin(), which no longer need to pass a dummy mailbox or 'is_entry' for CPU0. Signed-off-by: Mark Rutland Acked-by: Marc Zyngier Cc: Akos Denke Cc: Andre Przywara Cc: Luca Fancellu Reviewed-by: Andre Przywara --- arch/aarch64/spin.S | 11 +---------- common/boot.c | 20 ++++++++------------ common/psci.c | 2 +- include/boot.h | 2 +- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/arch/aarch64/spin.S b/arch/aarch64/spin.S index 375f732..a7879d4 100644 --- a/arch/aarch64/spin.S +++ b/arch/aarch64/spin.S @@ -23,15 +23,6 @@ ASM_FUNC(start_bootmethod) * Primary CPU (x0 = 0) jumps to kernel, the other ones wait for an * address to appear in mbox */ - adr x3, mbox - adr x4, kernel_address - cmp x0, #0 - csel x1, x3, x4, ne + adr x1, mbox mov x2, #0 bl first_spin - - .align 3 -kernel_address: - .long 0 - - .ltorg diff --git a/common/boot.c b/common/boot.c index 29d53a4..4417649 100644 --- a/common/boot.c +++ b/common/boot.c @@ -27,7 +27,7 @@ const unsigned long id_table[] = { CPU_IDS }; * @invalid: value of an invalid address, 0 or -1 depending on the boot method * @is_entry: when true, pass boot parameters to the kernel, instead of 0 */ -void __noreturn spin(unsigned long *mbox, unsigned long invalid, int is_entry) +void __noreturn spin(unsigned long *mbox, unsigned long invalid) { unsigned long addr = invalid; @@ -36,13 +36,6 @@ void __noreturn spin(unsigned long *mbox, unsigned long invalid, int is_entry) addr = *mbox; } - if (is_entry) -#ifdef KERNEL_32 - jump_kernel(addr, 0, ~0, (unsigned long)&dtb, 0); -#else - jump_kernel(addr, (unsigned long)&dtb, 0, 0, 0); -#endif - jump_kernel(addr, 0, 0, 0, 0); unreachable(); @@ -60,12 +53,15 @@ void __noreturn first_spin(unsigned int cpu, unsigned long *mbox, unsigned long invalid) { if (cpu == 0) { - *mbox = (unsigned long)&entrypoint; - sevl(); - spin(mbox, invalid, 1); + unsigned long addr = (unsigned long)&entrypoint; +#ifdef KERNEL_32 + jump_kernel(addr, 0, ~0, (unsigned long)&dtb, 0); +#else + jump_kernel(addr, (unsigned long)&dtb, 0, 0, 0); +#endif } else { *mbox = invalid; - spin(mbox, invalid, 0); + spin(mbox, invalid); } unreachable(); diff --git a/common/psci.c b/common/psci.c index 5ae4255..19cc315 100644 --- a/common/psci.c +++ b/common/psci.c @@ -57,7 +57,7 @@ static int psci_cpu_off(void) branch_table[cpu] = PSCI_ADDR_INVALID; - spin(branch_table + cpu, PSCI_ADDR_INVALID, 0); + spin(branch_table + cpu, PSCI_ADDR_INVALID); unreachable(); } diff --git a/include/boot.h b/include/boot.h index 459d1d5..18b805d 100644 --- a/include/boot.h +++ b/include/boot.h @@ -12,7 +12,7 @@ #include #include -void __noreturn spin(unsigned long *mbox, unsigned long invalid, int is_entry); +void __noreturn spin(unsigned long *mbox, unsigned long invalid); void __noreturn first_spin(unsigned int cpu, unsigned long *mbox, unsigned long invalid_addr);