This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/66960] Add interrupt attribute to x86 backend


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66960

--- Comment #14 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Goswin von Brederlow from comment #13)

> > > 
> > > In a kernel there will always be some exception that simply prints a
> > > register dump and stack backtrace. So again how do you access the original
> > > register contents?
> > 
> > You need to do that yourself.
> 
> Which means __attribute__ ((interrupt)) can't be used for exceptions half
> the time.

That is true if the interrupt handler must be written in such way.

> > > Secondly why pass error_code as argument if is already on the stack and
> > > could be accessed through the frame pointer? The argument register (amd64)
> > > would have to be saved on the stack too causing an extra push/pop. But if it
> > > is passed as argument then why not pop it before the call to keep the stack
> > > frame the same as for interrupts (assuming the saved registers are not
> > > included in the frame)?
> > 
> > error_code is a pseudo parameter, which is mapped to error code on stack
> > pushed by CPU.  You can write a simple code to see it yourself.
> 
> Couldn't the same trick be used for registers? Pass them as pseudo
> parameters and they either resolve to the location on the stack where gcc
> did save them or become the original register unchanged.

No.  We only do it for data pushed onto stack by CPU.

> > > If it is not poped or saved registers are included in the frame then the
> > > exception stack frame differs from the interrupt frame (extra error_code and
> > > extra register). They should not use the same structure, that's just
> > > confusing.
> > > 
> > >     'no_caller_saved_registers' attribute
> > > 
> > >     Use this attribute to indicate that the specified function has no
> > >     caller-saved registers.  That is, all registers are callee-saved.
> > > 
> > > Does that include the argument registers (if the function takes arguments)?
> > 
> > Yes.
> > 
> > > Wouldn't it be more flexible to define a list of registers that the function
> > > will clobber?
> > 
> > How do programmer know which registers will be clobbered?
> 
> The programmer writes the function. He declares what registers will be
> clobbered and gcc will add the necessary code to preserve any other
> registers it uses inside the function.

When you write in C, you don't deal with registers directly, which are
taken care of by compiler.  If you want to control exactly how registers
are handled, you need to write in ASM.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]