[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: fpstate stack alignment
On Thu, 11 Jan 2018, Martin Husemann wrote:
> Hey folks,
> "recently" (probably after the last compiler update) my krups kernel
> started to fail early during boot when initializing the fpu.
> I needed this patch to get past this:
> Index: cpu.c
> RCS file: /cvsroot/src/sys/arch/sparc/sparc/cpu.c,v
> retrieving revision 1.250
> diff -u -p -r1.250 cpu.c
> --- cpu.c 2 Dec 2017 00:48:05 -0000 1.250
> +++ cpu.c 11 Jan 2018 19:12:41 -0000
> @@ -956,7 +956,7 @@ mp_resume_cpus_ddb(void)
> fpu_init(struct cpu_info *sc)
> - struct fpstate fpstate;
> + struct fpstate fpstate __aligned(16);
> int fpuvers;
> savefpstate(&fpstate) uses std to store %f0 to the pointer passed, and this
> is where it fails for me w/o that alignement.
> I guess we have been lucky before - or did we bork stack alignment recently?
Something definitely broke. The ELF SPARC PSABI-3 dictates that the OS
should keep the stack doubleword aligned. The compiler should generate
code that keeps stack frames doubleword aligned. So whatever code is
initially setting up the stack is broken and violating the ELF ABI.
> With this applied the kernel gets to mounting root, but then just resets
> w/o any problem indication - need to investigate that in more detail
> another day.
Not surprising. If you take a trap, the stack pointer is misaligned and
the trap code tries to save the FP state on the stack before traps are
re-enabled, the CPU will watchdog reset.
Best to figure out what's causing the stack aligment problems and fix it.
Main Index |
Thread Index |