All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Pingfan Liu <piliu@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Pasha Tatashin <pasha.tatashin@soleen.com>
Subject: Re: [PATCH 4/4] arm64: kexec: Change relocate_kernel to C code
Date: Tue, 2 Apr 2024 10:55:08 +0100	[thread overview]
Message-ID: <ZgvV_FR-5I6Pu8D-@FVFF77S0Q05N> (raw)
In-Reply-To: <20240328115656.24090-5-piliu@redhat.com>

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 <piliu@redhat.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
> 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

      reply	other threads:[~2024-04-02  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 11:56 [PATCH 0/4] arm64: kexec: translate relocate_kernel.S to C languange Pingfan Liu
2024-03-28 11:56 ` [PATCH 1/4] arm64: relocate: Let __relocate_new_kernel_start align on SZ_4K Pingfan Liu
2024-03-28 11:56 ` [PATCH 2/4] arm64: mm: Provide prot param in trans_pgd_idmap_page()'s prototype Pingfan Liu
2024-03-28 11:56 ` [PATCH 3/4] arm64: kexec: Introduce d_size to carry cacheline size information Pingfan Liu
2024-03-28 11:56 ` [PATCH 4/4] arm64: kexec: Change relocate_kernel to C code Pingfan Liu
2024-04-02  9:55   ` Mark Rutland [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZgvV_FR-5I6Pu8D-@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=piliu@redhat.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.