Skip to contentSkip to conversation

generic: mips: support harts to boot from mips_warm_boot

PATCH Superseded Chao-ying Fu 2 participants 3 messages Jul 22, 2025 – Jul 23, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 generic: mips: support harts to boot from mips_warm_boot

We program reset base for harts (other than hart 0) to boot at mips_warm_boot that jumps to _start_warm. This helps to skip some code sequence to speed up.

---
 platform/generic/mips/p8700.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
platform/generic/mips/p8700.c +17 -0
index 888a45c..8c93ebf 100644
@@ -140,6 +140,20 @@ static void power_up_other_cluster(u32 hartid)
 }
 #endif
 
+static void __attribute__((naked,no_instrument_function,aligned(4096)))
+mips_warm_boot(void)
+{
+  __asm__ __volatile__(
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	);
+}
+
 static int mips_hart_start(u32 hartid, ulong saddr)
 {
 	unsigned int stat;
@@ -150,6 +164,9 @@ static int mips_hart_start(u32 hartid, ulong saddr)
 	if (hartid == 0)
 		return SBI_ENOTSUPP;
 
+	/* Change reset base to mips_warm_boot */
+	write_gcr_co_reset_base(hartid, (unsigned long)mips_warm_boot, local_p);
+
 	if (cpu_hart(hartid) == 0) {
 		/* Ensure its coherency is disabled */
 		write_gcr_co_coherence(hartid, 0, local_p);
Signature · 7 lines
2.47.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#1 lore raw

Hi Chao-ying,

Quoted 14 lines · Chao-ying Fu

We program reset base for harts (other than hart 0) to boot at mips_warm_boot that jumps to _start_warm. This helps to skip some code sequence to speed up.

---
 platform/generic/mips/p8700.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
platform/generic/mips/p8700.c +0 -0
index 888a45c..8c93ebf 100644

platform/generic/mips/p8700.c static void power_up_other_cluster(u32 hartid) · line 143

Quoted 4 lines
platform/generic/mips/p8700.c +1 -0
@@ -140,6 +140,20 @@ static void power_up_other_cluster(u32 hartid)
 }
 #endif
 
+static void __attribute__((naked,no_instrument_function,aligned(4096)))

Please follow Jess's suggestion and use an assembly file like we already do for platform/generic/andes/sleep.S. This will be more reliable than forever fighting the compiler to keep it from inserting any instructions on its own. (Are you _sure_ that this list of attributes covers every toolchain and configuration?)

Regards,
Samuel

Quoted 26 lines
platform/generic/mips/p8700.c +16 -0
+mips_warm_boot(void)
+{
+  __asm__ __volatile__(
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	);
+}
+
 static int mips_hart_start(u32 hartid, ulong saddr)
 {
 	unsigned int stat;
@@ -150,6 +164,9 @@ static int mips_hart_start(u32 hartid, ulong saddr)
 	if (hartid == 0)
 		return SBI_ENOTSUPP;
 
+	/* Change reset base to mips_warm_boot */
+	write_gcr_co_reset_base(hartid, (unsigned long)mips_warm_boot, local_p);
+
 	if (cpu_hart(hartid) == 0) {
 		/* Ensure its coherency is disabled */
 		write_gcr_co_coherence(hartid, 0, local_p);
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
#2 lore raw
Quoted 21 lines · Samuel Holland

Hi Chao-ying,

Quoted 17 lines · Chao-ying Fu

We program reset base for harts (other than hart 0) to boot at mips_warm_boot that jumps to _start_warm. This helps to skip some code sequence to speed up.

---
 platform/generic/mips/p8700.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
platform/generic/mips/p8700.c +0 -0
index 888a45c..8c93ebf 100644
@@ -140,6 +140,20 @@ static void power_up_other_cluster(u32 hartid)
 }
 #endif
 
Quoted 7 lines

platform/generic/mips/p8700.c static void power_up_other_cluster(u32 hartid) · line 143

Quoted 1 line
platform/generic/mips/p8700.c +1 -0
+static void __attribute__((naked,no_instrument_function,aligned(4096)))

Please follow Jess's suggestion and use an assembly file like we already do for platform/generic/andes/sleep.S. This will be more reliable than forever fighting the compiler to keep it from inserting any instructions on its own. (Are you _sure_ that this list of attributes covers every toolchain and configuration?)

Hi Sam,

Ok. I will change to use an assembly file and send out v3 soon,
similar to sleep.S.
Thanks a lot!

Regards,
Chao-ying

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi