linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: Use mov_q to load KPTI_NG_PTE_FLAGS/SWAPPER_R*_MMUFLAGS
@ 2022-07-21 12:42 Marc Zyngier
  2022-07-21 15:21 ` Catalin Marinas
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Zyngier @ 2022-07-21 12:42 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Will Deacon, Catalin Marinas, Mark Rutland, pcc, Ard Biesheuvel,
	kernel-team

With f7b4c3b82e7d ("arm64: set UXN on swapper page tables"),
the kernel fails to build:

arch/arm64/kernel/head.S: Assembler messages:
arch/arm64/kernel/head.S:334: Error: immediate cannot be moved by a single instruction
arch/arm64/kernel/head.S:343: Error: immediate cannot be moved by a single instruction
arch/arm64/kernel/head.S:354: Error: immediate cannot be moved by a single instruction
arch/arm64/kernel/head.S:379: Error: immediate cannot be moved by a single instruction

as the constants that inherit SWAPPER_P*_FLAGS cannot be loaded
using a single 'mov' instruction. Move over to mov_q to fix this.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kernel/head.S | 8 ++++----
 arch/arm64/mm/proc.S     | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index cefe6a73ee54..aa7c58689f68 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -331,7 +331,7 @@ SYM_FUNC_START_LOCAL(create_idmap)
 	adrp	x0, init_idmap_pg_dir
 	adrp	x3, _text
 	adrp	x6, _end + MAX_FDT_SIZE + SWAPPER_BLOCK_SIZE
-	mov	x7, SWAPPER_RX_MMUFLAGS
+	mov_q	x7, SWAPPER_RX_MMUFLAGS
 
 	map_memory x0, x1, x3, x6, x7, x3, IDMAP_PGD_ORDER, x10, x11, x12, x13, x14, EXTRA_SHIFT
 
@@ -340,7 +340,7 @@ SYM_FUNC_START_LOCAL(create_idmap)
 	adrp	x2, init_pg_dir
 	adrp	x3, init_pg_end
 	bic	x4, x2, #SWAPPER_BLOCK_SIZE - 1
-	mov	x5, SWAPPER_RW_MMUFLAGS
+	mov_q	x5, SWAPPER_RW_MMUFLAGS
 	mov	x6, #SWAPPER_BLOCK_SHIFT
 	bl	remap_region
 
@@ -351,7 +351,7 @@ SYM_FUNC_START_LOCAL(create_idmap)
 	bfi	x22, x21, #0, #SWAPPER_BLOCK_SHIFT		// remapped FDT address
 	add	x3, x2, #MAX_FDT_SIZE + SWAPPER_BLOCK_SIZE
 	bic	x4, x21, #SWAPPER_BLOCK_SIZE - 1
-	mov	x5, SWAPPER_RW_MMUFLAGS
+	mov_q	x5, SWAPPER_RW_MMUFLAGS
 	mov	x6, #SWAPPER_BLOCK_SHIFT
 	bl	remap_region
 
@@ -376,7 +376,7 @@ SYM_FUNC_START_LOCAL(create_kernel_mapping)
 	adrp	x3, _text			// runtime __pa(_text)
 	sub	x6, x6, x3			// _end - _text
 	add	x6, x6, x5			// runtime __va(_end)
-	mov	x7, SWAPPER_RW_MMUFLAGS
+	mov_q	x7, SWAPPER_RW_MMUFLAGS
 
 	map_memory x0, x1, x5, x6, x7, x3, (VA_BITS - PGDIR_SHIFT), x10, x11, x12, x13, x14
 
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 7837a69524c5..e5578a6e80c0 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -293,7 +293,7 @@ SYM_FUNC_START(idmap_kpti_install_ng_mappings)
 	isb
 
 	mov	temp_pte, x5
-	mov	pte_flags, #KPTI_NG_PTE_FLAGS
+	mov_q	pte_flags, KPTI_NG_PTE_FLAGS
 
 	/* Everybody is enjoying the idmap, so we can rewrite swapper. */
 	/* PGD */
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: Use mov_q to load KPTI_NG_PTE_FLAGS/SWAPPER_R*_MMUFLAGS
  2022-07-21 12:42 [PATCH] arm64: Use mov_q to load KPTI_NG_PTE_FLAGS/SWAPPER_R*_MMUFLAGS Marc Zyngier
@ 2022-07-21 15:21 ` Catalin Marinas
  2022-07-21 16:10   ` Marc Zyngier
  0 siblings, 1 reply; 3+ messages in thread
From: Catalin Marinas @ 2022-07-21 15:21 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: linux-arm-kernel, Will Deacon, Mark Rutland, pcc, Ard Biesheuvel,
	kernel-team

On Thu, Jul 21, 2022 at 01:42:44PM +0100, Marc Zyngier wrote:
> With f7b4c3b82e7d ("arm64: set UXN on swapper page tables"),
> the kernel fails to build:
> 
> arch/arm64/kernel/head.S: Assembler messages:
> arch/arm64/kernel/head.S:334: Error: immediate cannot be moved by a single instruction
> arch/arm64/kernel/head.S:343: Error: immediate cannot be moved by a single instruction
> arch/arm64/kernel/head.S:354: Error: immediate cannot be moved by a single instruction
> arch/arm64/kernel/head.S:379: Error: immediate cannot be moved by a single instruction
> 
> as the constants that inherit SWAPPER_P*_FLAGS cannot be loaded
> using a single 'mov' instruction. Move over to mov_q to fix this.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>

Thanks for the fix Marc, this only applies to -next. We could either
revert Peter's patch [1] in -next but keep it for 5.19 or simply drop it
from for-next/fixes and send it to stable post 5.19. I'm more inclined
to do the latter.

Catalin

[1] https://lore.kernel.org/r/20220719234909.1398992-1-pcc@google.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: Use mov_q to load KPTI_NG_PTE_FLAGS/SWAPPER_R*_MMUFLAGS
  2022-07-21 15:21 ` Catalin Marinas
@ 2022-07-21 16:10   ` Marc Zyngier
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2022-07-21 16:10 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arm-kernel, Will Deacon, Mark Rutland, pcc, Ard Biesheuvel,
	kernel-team

On Thu, 21 Jul 2022 16:21:55 +0100,
Catalin Marinas <catalin.marinas@arm.com> wrote:
> 
> On Thu, Jul 21, 2022 at 01:42:44PM +0100, Marc Zyngier wrote:
> > With f7b4c3b82e7d ("arm64: set UXN on swapper page tables"),
> > the kernel fails to build:
> > 
> > arch/arm64/kernel/head.S: Assembler messages:
> > arch/arm64/kernel/head.S:334: Error: immediate cannot be moved by a single instruction
> > arch/arm64/kernel/head.S:343: Error: immediate cannot be moved by a single instruction
> > arch/arm64/kernel/head.S:354: Error: immediate cannot be moved by a single instruction
> > arch/arm64/kernel/head.S:379: Error: immediate cannot be moved by a single instruction
> > 
> > as the constants that inherit SWAPPER_P*_FLAGS cannot be loaded
> > using a single 'mov' instruction. Move over to mov_q to fix this.
> > 
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> 
> Thanks for the fix Marc, this only applies to -next. We could either
> revert Peter's patch [1] in -next but keep it for 5.19 or simply drop it
> from for-next/fixes and send it to stable post 5.19. I'm more inclined
> to do the latter.

Agreed, this seems like a sensible decision. This is unlikely to
affect a large user base at this stage anyway.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-21 16:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-21 12:42 [PATCH] arm64: Use mov_q to load KPTI_NG_PTE_FLAGS/SWAPPER_R*_MMUFLAGS Marc Zyngier
2022-07-21 15:21 ` Catalin Marinas
2022-07-21 16:10   ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).