From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E137C433ED for ; Thu, 20 May 2021 11:55:13 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8690961090 for ; Thu, 20 May 2021 11:55:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8690961090 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pBT3dflOulYs6iTHLGAc2dtwGOXsuMaU4fcAMgZ2mks=; b=jNIR9tvO1R0Du6HtRUrsZMxRyf z8XLUbrf6gs9DMMeuFDl5jCTnd8KrCl30kdMeBv0KS9k+XoixRo0NxHmonYnNKOPmvf8tDUPHSEOU ybjeyxKrUVWw7j/fx7IKWA37JwmW0f6yVKJjwQKUaCtFCuVvfNGIxmm05Rfocx9EuBa19Np+0DvKh vSECLs0O04X8Gb4tDsa0Gk21IQwF25GuWUFZwxj6X9CKoZ0rKwfC/HKOX7WHRB8YykpKHmBGgugoZ Afzi1upAAOzMc6RlvMaG6SfTxFHdnHMGAZ0B0lSvPxdPIjK00F1QwBcHbS9x/nEFgCUFz4Oqf9ul1 sLbgb3Pw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljhEw-000dAO-Jl; Thu, 20 May 2021 11:53:23 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljhCZ-000cDY-Ol for linux-arm-kernel@desiato.infradead.org; Thu, 20 May 2021 11:50:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sPY2YeVOcmwKf8Ts9TTuQ4jHQWh1ePRPFWfJcT6Onms=; b=uwTHRjqy7GLfjTwfnCNYMFPdaG 9Vx6f+hlyuGWekMpygfj+YfZhyIo5jiNokoWS336cCXuwvdXAFuph6u3P6LZV/cHV0dTkqy/7lMMp HbHHl7rmhSKD6UTLfWaHInKuUnKws6p9vOcuOH96jN3Cvt/U3zxxvOydzuj4hO1Bx3fTl4q6p4thA 7LAFFQ43mvup4OAixmqC4F3hsvYaPgvFXfJsLDvU5CdZddvmmIaALfa86XkpNf8re/gA2zlC6AOP6 qLf2nCqIF348USkoqS8oAwguVAKSf4FIzR6A0kJHpMvSw4tH0CGakEnXoI2M6sd7/GxLbjH0n6rmi 2ZbarO1A==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljhCW-00GH5l-Ga for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 11:50:54 +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 E873A101E; Thu, 20 May 2021 04:50:51 -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 96BAC3F73D; Thu, 20 May 2021 04:50:50 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: ardb@kernel.org, broonie@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, madvenka@linux.microsoft.com, mark.rutland@arm.com, maz@kernel.org, suzuki.poulose@arm.com, will@kernel.org Subject: [PATCH 5/6] arm64: smp: unify task and sp setup Date: Thu, 20 May 2021 12:50:30 +0100 Message-Id: <20210520115031.18509-6-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210520115031.18509-1-mark.rutland@arm.com> References: <20210520115031.18509-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210520_045052_662576_C6C66D10 X-CRM114-Status: GOOD ( 10.76 ) 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Once we enable the MMU, we have to initialize: * SP_EL0 to point at the active task * SP to point at the active task's stack * SCS_SP to point at the active task's shadow stack For all tasks (including init_task), this information can be derived from the task's task_struct. Let's unify __primary_switched and __secondary_switched to consistently acquire this information from the relevant task_struct. At the same time, let's fold this together with initializing a task's final frame. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: James Morse Cc: Marc Zyngier Cc: Suzuki Poulose Cc: Will Deacon --- arch/arm64/kernel/head.S | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 9be95e11367d..e83b2899dce5 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -395,15 +395,24 @@ SYM_FUNC_START_LOCAL(__create_page_tables) SYM_FUNC_END(__create_page_tables) /* + * Initialize CPU registers with task-specific and cpu-specific context. + * * Create a final frame record at task_pt_regs(current)->stackframe, so * that the unwinder can identify the final frame record of any task by * its location in the task stack. We reserve the entire pt_regs space * for consistency with user tasks and kthreads. */ - .macro setup_final_frame + .macro init_cpu_task tsk, tmp + msr sp_el0, \tsk + + ldr \tmp, [\tsk, #TSK_STACK] + add sp, \tmp, #THREAD_SIZE sub sp, sp, #PT_REGS_SIZE + stp xzr, xzr, [sp, #S_STACKFRAME] add x29, sp, #S_STACKFRAME + + scs_load \tsk, \tmp .endm /* @@ -412,22 +421,16 @@ SYM_FUNC_END(__create_page_tables) * x0 = __PHYS_OFFSET */ SYM_FUNC_START_LOCAL(__primary_switched) - adrp x4, init_thread_union - add sp, x4, #THREAD_SIZE - adr_l x5, init_task - msr sp_el0, x5 // Save thread_info + adr_l x4, init_task + init_cpu_task x4, x5 adr_l x8, vectors // load VBAR_EL1 with virtual msr vbar_el1, x8 // vector table address isb - stp xzr, x30, [sp, #-16]! + stp x29, x30, [sp, #-16]! mov x29, sp -#ifdef CONFIG_SHADOW_CALL_STACK - adr_l scs_sp, init_shadow_call_stack // Set shadow call stack -#endif - str_l x21, __fdt_pointer, x5 // Save FDT pointer ldr_l x4, kimage_vaddr // Save the offset between @@ -459,8 +462,7 @@ SYM_FUNC_START_LOCAL(__primary_switched) 0: #endif bl switch_to_vhe // Prefer VHE if possible - add sp, sp, #16 - setup_final_frame + ldp x29, x30, [sp], #16 bl start_kernel ASM_BUG() SYM_FUNC_END(__primary_switched) @@ -648,12 +650,7 @@ SYM_FUNC_START_LOCAL(__secondary_switched) ldr x2, [x0, #CPU_BOOT_TASK] cbz x2, __secondary_too_slow - ldr x1, [x2, #TSK_STACK] - add sp, x1, #THREAD_SIZE - - msr sp_el0, x2 - scs_load x2, x3 - setup_final_frame + init_cpu_task x2, x1 #ifdef CONFIG_ARM64_PTR_AUTH ptrauth_keys_init_cpu x2, x3, x4, x5 -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel