diff --git a/arch/arm/core/aarch64/switch.S b/arch/arm/core/aarch64/switch.S
index d61c37d63dc3bc3d4d9df04e581c6cfaefb71d3e..c9497f0f38579ce2055d024925d81d7aa7e2ce39 100644
--- a/arch/arm/core/aarch64/switch.S
+++ b/arch/arm/core/aarch64/switch.S
@@ -32,18 +32,25 @@ GDATA(_kernel)
 GTEXT(z_arm64_context_switch)
 SECTION_FUNC(TEXT, z_arm64_context_switch)
 	/* addr of callee-saved regs in thread in x2 */
-	ldr	x2, =_thread_offset_to_callee_saved
-	add	x2, x2, x1
+	ldr	x3, =_thread_offset_to_callee_saved
+	add	x2, x1, x3
 
 	/* Save the current SP */
-	mov	x1, sp
+	mov	x4, sp
 
 	stp	x19, x20, [x2, ___callee_saved_t_x19_x20_OFFSET]
 	stp	x21, x22, [x2, ___callee_saved_t_x21_x22_OFFSET]
 	stp	x23, x24, [x2, ___callee_saved_t_x23_x24_OFFSET]
 	stp	x25, x26, [x2, ___callee_saved_t_x25_x26_OFFSET]
 	stp	x27, x28, [x2, ___callee_saved_t_x27_x28_OFFSET]
-	stp	x29, x1, [x2, ___callee_saved_t_x29_sp_OFFSET]
+	stp	x29, x4, [x2, ___callee_saved_t_x29_sp_OFFSET]
+
+#ifdef CONFIG_SMP
+	/* save old thread into switch handle which is required by
+	 * wait_for_switch
+	 */
+	 str	x1, [x1, #___thread_t_switch_handle_OFFSET]
+#endif
 
 #ifdef CONFIG_THREAD_LOCAL_STORAGE
 	/* Grab the TLS pointer */
@@ -139,12 +146,6 @@ context_switch:
 	/* Get old thread from x1 */
 	sub	x1, x1, ___thread_t_switch_handle_OFFSET
 
-#ifdef CONFIG_SMP
-	/* save old thread into switch handle which is required by
-	 * wait_for_switch
-	 */
-	 str	x1, [x1, #___thread_t_switch_handle_OFFSET]
-#endif
 	/* Switch thread */
 	bl	z_arm64_context_switch