All of lore.kernel.org
 help / color / mirror / Atom feed
* Interrupts handling
@ 2015-06-17 11:22 Alexander Kuleshov
  2015-06-17 11:24 ` Alexander Kuleshov
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Kuleshov @ 2015-06-17 11:22 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I have a question about interrupt handling in Linux kernel for x86_64.
As we can read in the
64-ia-32-architectures-software-developer-vol-3a-part-1-manual, when
an interurpt/exception occurs, the handler's stack contains SS, RSP,
RFLAGS, CS, RIP and error code. My question is: does processor push
this register on the stack when an interrupt occurs or kernel must
push it?

In the arch/x86/kernel/entry_64.S we can see following code in the
idtentry macro:

.ifeq \has_error_code
pushq_cfi $-1
.endif

where pushq_cfi is:

.macro pushq_cfi reg
    pushq \reg
    CFI_ADJUST_CFA_OFFSET 8
.endm

First of all what does it mean $-1 here? I have write simple assembly
program and I see:

push 0xffffffffffffffff

in the gdb. The second question, if processor pushes error code and
other during interrupt why we push it here?

Thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Interrupts handling
  2015-06-17 11:22 Interrupts handling Alexander Kuleshov
@ 2015-06-17 11:24 ` Alexander Kuleshov
  2015-06-21 15:04   ` Mulyadi Santosa
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Kuleshov @ 2015-06-17 11:24 UTC (permalink / raw)
  To: kernelnewbies

Ah, I understood, $-1 is just -1 here. But why we push it - 0xffffffffffffffff?

2015-06-17 17:22 GMT+06:00 Alexander Kuleshov <alex0xax@gmail.com>:
> Hello,
>
> I have a question about interrupt handling in Linux kernel for x86_64.
> As we can read in the
> 64-ia-32-architectures-software-developer-vol-3a-part-1-manual, when
> an interurpt/exception occurs, the handler's stack contains SS, RSP,
> RFLAGS, CS, RIP and error code. My question is: does processor push
> this register on the stack when an interrupt occurs or kernel must
> push it?
>
> In the arch/x86/kernel/entry_64.S we can see following code in the
> idtentry macro:
>
> .ifeq \has_error_code
> pushq_cfi $-1
> .endif
>
> where pushq_cfi is:
>
> .macro pushq_cfi reg
>     pushq \reg
>     CFI_ADJUST_CFA_OFFSET 8
> .endm
>
> First of all what does it mean $-1 here? I have write simple assembly
> program and I see:
>
> push 0xffffffffffffffff
>
> in the gdb. The second question, if processor pushes error code and
> other during interrupt why we push it here?
>
> Thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Interrupts handling
  2015-06-17 11:24 ` Alexander Kuleshov
@ 2015-06-21 15:04   ` Mulyadi Santosa
  0 siblings, 0 replies; 3+ messages in thread
From: Mulyadi Santosa @ 2015-06-21 15:04 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Jun 17, 2015 at 6:24 PM, Alexander Kuleshov <alex0xax@gmail.com>
wrote:

> Ah, I understood, $-1 is just -1 here. But why we push it -
> 0xffffffffffffffff?
>
> 2015-06-17 17:22 GMT+06:00 Alexander Kuleshov <alex0xax@gmail.com>:
> > Hello,
> >
> > I have a question about interrupt handling in Linux kernel for x86_64.
> > As we can read in the
> > 64-ia-32-architectures-software-developer-vol-3a-part-1-manual, when
> > an interurpt/exception occurs, the handler's stack contains SS, RSP,
> > RFLAGS, CS, RIP and error code. My question is: does processor push
> > this register on the stack when an interrupt occurs or kernel must
> > push it?
> >
> > In the arch/x86/kernel/entry_64.S we can see following code in the
> > idtentry macro:
> >
> > .ifeq \has_error_code
> > pushq_cfi $-1
> > .endif
> >
> > where pushq_cfi is:
> >
> > .macro pushq_cfi reg
> >     pushq \reg
> >     CFI_ADJUST_CFA_OFFSET 8
> > .endm
> >
> > First of all what does it mean $-1 here? I have write simple assembly
> > program and I see:
> >
> > push 0xffffffffffffffff
> >
> > in the gdb. The second question, if processor pushes error code and
> > other during interrupt why we push it here?
> >
> > Thank you.
>

Hi

Please don't top post, even replying to yourself :)

IMHO, pushing -1 is to signify this is error code. Later, (just my guess),
the error code will be pushed too.



-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150621/e4841bdc/attachment.html 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-21 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-17 11:22 Interrupts handling Alexander Kuleshov
2015-06-17 11:24 ` Alexander Kuleshov
2015-06-21 15:04   ` Mulyadi Santosa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.