我是否弹出错误code推某些例外情况,从中断处理程序返回前栈? [英] Do I have to pop the error code pushed to stack by certain exceptions before returning from the interrupt handler?

查看:123
本文介绍了我是否弹出错误code推某些例外情况,从中断处理程序返回前栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经加载的IDT表256项,都指向类似的处理程序:

I have loaded an idt table with 256 entries, all pointing to similar handlers:


  • 例外8和10-14,推异常号(这些例外推错误code自动)

  • 换了别人,推一个虚拟的错误code和异常号;

  • 然后跳转到一个通用处理器

因此​​,当通用处理器进入,堆栈正确对齐,并包含异常/中断号,错误code(这可能只是一个虚拟的),EFLAGS,CS和EIP。

So when the common handler enters, the stack is properly aligned and contains the exception/interrupt number, error code (which may just be a dummy), eflags, cs and eip.

我的问题关于从中断处理程序返回。我使用 IRET 取出异常号和从堆栈错误code后返回,但这并不异常NR 8工作;如果我离开的错误code堆栈上,则返回正常!

My question regards returning from the interrupt handler. I use iret to return after taking out the exception number and the error code from the stack, but this doesn't work for exception nr 8; if I leave the error code on the stack, then it returns fine!

问题:


  • 请我得离开堆栈上的错误code表示把错误code有异常?如果是这样,怎么做 IRET 确定其是否具有弹出一个错误code或不?

  • 只要我能中断时我总是得到异常8(双误),但随后一切都正常运行(我开发一个爱好OS)。这是正常的行为,或者我有一个错误的地方?

  • do I have to leave the error code on the stack for exceptions that put the error code there? If so, how does iret determine whether it has to pop an error code or not?
  • as soon as I enable interrupts I always get exception 8 (double fault), but then everything runs fine (I'm developing a hobby OS). Is this normal behavior or do I have a bug somewhere?

推荐答案

如果CPU的推错误code自动,处理程序的必须之前弹出它 IRET 。在 IRET 指令不知道你来自哪里,如果它是一个错误,陷阱或外部中断。它总是相同的,并且它假定有堆栈上没有错误code。

If the CPU pushed an error code automatically, the handler must pop it before the iret. The iret instruction doesn't know where you're coming from, if it's a fault, a trap or an external interrupt. It always does the same, and it assumes that there's no error code on the stack.

从SDM(软件开发人员手册),第3卷,第5章第5.13节标题为错误code报价:

Quoting from the SDM (Software Developer's Manual), Volume 3, Chapter 5, section 5.13 titled Error Code:

错误code被压入堆栈
  作为一个双字或字(取决于
  默认的中断,陷阱,或任务
  浇口尺寸)。为了保持对齐堆栈
  对于双推,上半部分
  错误code的保留。注意
  该错误code未弹出时
  该IRET指令被执行以
  从异常处理程序返回,所以
  处理程序必须删除错误code
  之前执行的回报。

The error code is pushed on the stack as a doubleword or word (depending on the default interrupt, trap, or task gate size). To keep the stack aligned for doubleword pushes, the upper half of the error code is reserved. Note that the error code is not popped when the IRET instruction is executed to return from an exception handler, so the handler must remove the error code before executing a return.

您可以找到 IA-32软件开发人员手册这里:<一href=\"http://www.intel.com/products/processor/manuals/\">http://www.intel.com/products/processor/manuals/

第3卷第1部分,第5章,介绍了异常和中断处理。第2卷第1部分具有用于 IRET 指令规范。

Volume 3 part 1, chapter 5, describes exception and interrupt handling. Volume 2 part 1 has the spec for the iret instruction.

这篇关于我是否弹出错误code推某些例外情况,从中断处理程序返回前栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆