[PATCH 2/3] mips: make sp 16-byte aligned on N64/N32

Maciej W. Rozycki macro@linux-mips.org
Fri Dec 4 10:57:01 GMT 2020


On Mon, 30 Nov 2020, Adhemerval Zanella via Libc-alpha wrote:

> > MIPS N64/N32 ABI request stack pointer be 16-byte alinged
> > 
> 
> It seems to align what gcc assumes:
> 
> gcc/config/mips/mips.h
> 
>  364 #define TARGET_NEWABI               (mips_abi == ABI_N32 || mips_abi == ABI_64)
> 
> 2525 /* Treat LOC as a byte offset from the stack pointer and round it up
> 2526    to the next fully-aligned offset.  */
> 2527 #define MIPS_STACK_ALIGN(LOC) \
> 2528   (TARGET_NEWABI ? ROUND_UP ((LOC), 16) : ROUND_UP ((LOC), 8))

 This is correct (the alignment being twice the register width), although 
in this particular case obviously hardly matters in practice, as the 
syscall will switch to the kernel stack right away.  It's fine to get it 
fixed regardless of course, once a correct change has been proposed.

> (It would be easier that https://www.linux-mips.org/ could show 
> this information easier, I could only find the old o32 ABI documentation).

 We largely continue relying on old SGI ABI documentation, although there 
used to be a wiki hosted by MIPS Technologies (MTI) where such details 
were summarised.  Sadly with the demise of both companies this stuff is 
either gone or hard to track down, except for individual people's storage 
devices.

 See:

<https://web.archive.org/web/20180829093347/https://dmz-portal.mips.com/wiki/Main_Page>

for the old MTI wiki; unfortunately not all stuff has been archived.

 I can see if I can upload some stuff to linux-mips.org, either the wiki 
itself or my own FTP area I can link the wiki to, but mind that this site 
is under threat of disappearance as well and as much as I'd like to I may 
not be able to stop it.

> > @@ -48,8 +48,8 @@ NESTED (syscall, SZREG, ra)
> >  
> >  	REG_L s0, (sp)
> >  	cfi_restore (s0)
> > -	PTR_ADDIU sp, SZREG
> > -	cfi_adjust_cfa_offset (-SZREG)
> > +	PTR_ADDIU sp, 2 * SZREG
> > +	cfi_adjust_cfa_offset (-2 * 2 * SZREG)

 The updated CFA adjustment does not look right to me though.

  Maciej


More information about the Libc-alpha mailing list