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 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 25F80CD1284 for ; Tue, 2 Apr 2024 09:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dzUmNDIat4cf71aAjc/EM0Et3pi+FLXIdPbu9M7yPQw=; b=oQsR1ePBfs+qAU gh0cBtGADiCqNw3phiNKrhoTAItzAlwRiLULsZ6zXiUMbOh6tFGvNjtP3JsFEpaFmbK+cvyHrWRF5 9EAhSjeWhxvXJfxg9dceiSy/bK4/1VRB0rbDEgNH1ca0/5Kh5qWg9pv9/CXFlX6wINzn9cc3u5n90 cGpvtfxptjvPuSF9XcLubMmNKvpERxT6mZ2zhwqbVo1dFi86ykJwLjoNf2qTkQrhILkP9DQT3FXx4 QfZ1VWqBq8xlHFzB3yvBcEbKBoDwsq3lx9Uurw1glOBip80KnZCTJDp8C0C0IqsKVmjSdKBTWN6op GDMK882VSVAzppj0vjtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrare-0000000AWPM-2EKA; Tue, 02 Apr 2024 09:55:34 +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 1rrarb-0000000AWOI-2FI5 for linux-arm-kernel@lists.infradead.org; Tue, 02 Apr 2024 09:55:32 +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 2D6301042; Tue, 2 Apr 2024 02:56:02 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.18.33]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DE0803F766; Tue, 2 Apr 2024 02:55:28 -0700 (PDT) Date: Tue, 2 Apr 2024 10:55:08 +0100 From: Mark Rutland To: Pingfan Liu Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Ard Biesheuvel , Kees Cook , Pasha Tatashin Subject: Re: [PATCH 4/4] arm64: kexec: Change relocate_kernel to C code Message-ID: References: <20240328115656.24090-1-piliu@redhat.com> <20240328115656.24090-5-piliu@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240328115656.24090-5-piliu@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240402_025531_649222_6EC53D5A X-CRM114-Status: GOOD ( 17.66 ) 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: , 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 On Thu, Mar 28, 2024 at 07:56:54PM +0800, Pingfan Liu wrote: > The kexec_relocate.o is a self-contained section, and it should be PIE. > > Beside that, C function call requires stack, which is built on the idmap > of the rear of kimage->control_code_page. > > Signed-off-by: Pingfan Liu > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Ard Biesheuvel > Cc: Kees Cook > Cc: Mark Rutland > Cc: Pasha Tatashin > To: linux-arm-kernel@lists.infradead.org > --- > arch/arm64/kernel/Makefile | 1 + > arch/arm64/kernel/asm-offsets.c | 10 -- > arch/arm64/kernel/machine_kexec.c | 9 +- > arch/arm64/kernel/relocate_kernel.S | 100 -------------- > arch/arm64/kernel/relocate_kernel.c | 197 ++++++++++++++++++++++++++++ > arch/arm64/kernel/vmlinux.lds.S | 1 + > 6 files changed, 206 insertions(+), 112 deletions(-) > delete mode 100644 arch/arm64/kernel/relocate_kernel.S > create mode 100644 arch/arm64/kernel/relocate_kernel.c > +static void __kexec_section turn_mmu_off(void) > +{ > + u64 tmp = INIT_SCTLR_EL1_MMU_OFF; > + > + /* pre_disable_mmu_workaround */ > +#ifdef CONFIG_QCOM_FALKOR_ERRATUM_E1041 > + isb(); > +#endif > + write_sysreg(tmp, sctlr_el1); > + isb(); > +} Disabling the MMU cannot be done from C; as soon as we write to SCTLR_EL1 (even before the ISB) we cannot safely access the stack until that has been explcitly cleaned+invalidated to the PoC (and that has to be done by VA). I don't think we should bother trying to move this to C; the MMU-off portions should remain as asssembly. If you want to move the MMU-on portions to C, then *maybe* that's worthwhile, but given the diffstat I reckon it's better to leave this all as asm for now. We can make this more legibile without converting it to C. Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel