Skip to content

在调试中发现embassy_preempt的堆栈区域和opensbi或uboot踩踏,hart1报错(hart1上运行的是opensbi)

U-Boot SPL 2026.01-rc4-00010-ge55a81c36843-dirty (Jan 01 1980 - 00:00:00 +0000)
DDR version: dc2e84f0.
Trying to boot from SPI
UART logger initialized
==H=a OrSt In0i tsk Siptparintegd  c=ol=d=b
oOoStI
leHta:rt  OS4I nsiktiHpopoiknBge gcionl dcboomotp
  tHaedrt
 O2S sInkiitp:pi nAbgo ucto ltdob oocatl
pH Iarnitt _3H eskaip
 pOinSIgn ciotl:d Ibnooitt_
ngHaapr t co0m: plJeumtepid
InO StIon iptay:l oAbaodu tat t 0o xc8a0l4l00 O00S_0
  itStackAllocator
OSInit: OS_InitStackAllocator completed
OSInit: About to call init_platform
OSInit: init_platform completed
bSInit: A
 sobuti _ttora cpa_lelr roGlr:ob halaSrytn1:cE xtercaup0to:r i
roleSIganil t:in GsltorbuactlSioynnc Ehaxendcluteror  fcaiomlpelde t(eedr
  Or SI-2n)it
 A
: sbobiu_tt rtoap c_ealrrl orOS:_ Ihanirtt1Ta:s tkIrdaple0
0 OmScaInusite=: 0OxS0_00In0i0t0T0a00sk00I0dl00e 02c ommptlvaetl=ed0x
o 0S0I00n0it0:0 0A00bo0u00t0 t0
: csbalil_ tOrSap_I_enritroErve: nthaLirts1t
t tOSrIanpi0:t:  mOeSp_c=In0xit00Ev00en00tL00is4t00 c04o0mp0l4e tmsedta
=u=s=== 0xOS0I0n00it00 C0ao0mp0l0e01te8d00 =
bi=
  H_terlalop,_e Errmboras: syha Prrte1:em pttr aop0n :V irsai=0onx0F0iv00e02!0
40003d2e sp=0x000000004004ae30                                                00
sbi_trap_error: hart1: trap0: gp=0x0000000000000000 tp=0x000000004004b000
sbi_trap_error: hart1: trap0: s0=0x000000004004aeb0 s1=0x000000004004b0e0
sbi_trap_error: hart1: trap0: a0=0x00000000400003c8 a1=0x00000003fffffc00
sbi_trap_error: hart1: trap0: a2=0x000000004004ae30 a3=0x0000000000000000
sbi_trap_error: hart1: trap0: a4=0x000000004004ae30 a5=0x0000000040040238
sbi_trap_error: hart1: trap0: a6=0x0000000100010c00 a7=0x000000004004ae58
sbi_trap_error: hart1: trap0: s2=0x000000004004b000 s3=0x0000000040043220
sbi_trap_error: hart1: trap0: s4=0x0000000040043230 s5=0x0000000040043238
sbi_trap_error: hart1: trap0: s6=0x0000000000000001 s7=0x0000000000000005
sbi_trap_error: hart1: trap0: s8=0x0000000000002000 s9=0x0000000040043924
sbi_trap_error: hart1: trap0: s10=0x0000000000000000 s11=0x0000000000000000
sbi_trap_error: hart1: trap0: t0=0x0000000000002000 t1=0x0000000000000000
sbi_trap_error: hart1: trap0: t2=0x0000000000001000 t3=0x0000000000000000
sbi_trap_error: hart1: trap0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart1: trap0: t6=0x0000000000000000

发现之前将embassy_preempt放在0x80400000实际上是非法地址,星光2的启动阶段内存安排是这样的

alt text

为了保证之后embassy_preempt和linux之间不互相踩踏内存,需要在各个系统间设定一块embassy_preempt专用的内存区域

先将原先的0x80400000改为0x40800000,产生spl阶段错误

SPL: Unsupported Boot Device!
SPL: failed to boot from all boot devices

改为0x81000000,opensbi能成功进入uboot,但embassy_preempt跳转后hart0崩溃

U-Boot SPL 2026.01-rc4-00010-ge55a81c36843-dirty (Jan 01 1980 - 00:00:00 +0000)
DDR version: dc2e84f0.
Trying to boot from SPI
rt0: trap0: t0=0x0000040000000000 t1=0x0000000000000000
sbi_trap_error: hart0: trap0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: trap0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: trap0: t6=0x0000000000000000

OpenSBI v1.7-90-g8442b8df
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name               : StarFive VisionFive 2 v1.3B
Platform Features           : medeleg
Platform HART Count         : 5
Platform IPI Device         : aclint-mswi
Platform Timer Device       : aclint-mtimer @ 4000000Hz
Platform Console Device     : uart8250
Platform HSM Device         : ---
Platform PMU Device         : ---
Platform Reboot Device      : pm-reset
Platform Shutdown Device    : pm-reset
Platform Suspend Device     : ---
Platform CPPC Device        : ---
Firmware Base               : 0x40000000
Firmware Size               : 365 KB
Firmware RW Offset          : 0x40000
Firmware RW Size            : 109 KB
Firmware Heap Offset        : 0x4e000
Firmware Heap Size          : 53 KB (total), 0 KB (reserved), 13 KB (used), 39 KB (free)
Firmware Scratch Size       : 4096 B (total), 416 B (used), 3680 B (free)
Runtime SBI Version         : 3.0
Standard SBI Extensions     : base
Experimental SBI Extensions : none

猜测是仍然内存被踩踏,只是由原先embassy_preempt破坏opensbi的内存区域变成opensbi破坏embassy_preempt的内存区域