Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: philippe@jhunix.hcf.jhu.edu (Philippe Pouliquen)
Subject: Re: Alpha Assmebly question: LDQ_U r31_zero,0(r30_sp) showing up?!
Date: 17 Jan 1994 22:20:36 -0500	[thread overview]
Message-ID: <2hfki4INNj0h@jhunix.hcf.jhu.edu> (raw)
In-Reply-To: ASAH.94Jan16212209@ginsberg.cs.Berkeley.EDU

In article <ASAH.94Jan16212209@ginsberg.cs.Berkeley.EDU> asah@cs.Berkeley.EDU (Adam Sah) writes:
>
>What does the following alpha assembly instruction _do_?
>
>LDQ_U r31_zero,0(r30_sp)
>
>According to the manual, it reads the memory address out of stack pointer,
>  masking over misalignment, and drops it off in the bit bucket, without
>  changing r30_sp.
>
>In other words, nothing.
>
>And yet, I see this pop up all the time when I examine code output from the
>  C compiler, both gcc as well as native cc.
>
>What am I missing?
>
>
>--
>Thanks again,
>-A.Sah'94                     ...Adam Sah...asah@cs.Berkeley.EDU...
>                    Only ask yourself questions that you can find answers to.


I don't know. :-)

But I do have a some guesses. The instruction may be an expensive NOP.
Or it could be some technique required to flush a buffer of some sort
on the CPU. Or it might be a way of testing the stack pointer to make
sure its valid (not pointing to 'invalid' space).

Consider the following:
- User program messes with the stack pointer.
- User program does a system call.
- Kernel uses user stack to get system call arguments and ends up making
the user program uid root (because the stack pointer pointed to where
the kernel stores the user programs uid in the user space.)

A quick test of the stack pointer before a system call would prevent
this. (However, if you coded things up in assembler, bypassing cc and
libc, you could get around it.)

As far as 'gcc' goes, it uses 'cc' to generate code for things that
'it doesn't already know how to do'. Therefore, 'gcc' might simply be
incorporating code produced by 'cc'.

Philippe Pouliquen
philippe@zeus.ece.jhu.edu


  reply	other threads:[~1994-01-18  3:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-01-17  5:22 Alpha Assmebly question: LDQ_U r31_zero,0(r30_sp) showing up?! Adam Sah
1994-01-18  3:20 ` Philippe Pouliquen [this message]
1994-01-19  2:14   ` Jon Kay
1994-01-19 20:46 ` Joseph Martin
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox