From 481bdfb2c5d07b52a4662abeea9e2e043bd777cd Mon Sep 17 00:00:00 2001 From: Albertchamberlain <2476271447@qq.com> Date: Tue, 12 May 2020 20:19:03 +0800 Subject: [PATCH] =?UTF-8?q?<=E4=B8=8A=E6=B8=B83.1=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E4=B8=AD=E6=96=87=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTORS.md | 4 ++- Interrupts/linux-interrupts-1.md | 42 +++++++++++++++++--------------- README.md | 2 +- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 26a9f3e..f1aecba 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -42,4 +42,6 @@ [@NeoCui](https://github.com/NeoCui) -[@narcijie](https://github.com/narcijie) \ No newline at end of file +[@narcijie](https://github.com/narcijie) + +[@Albertchamberlain](https://github.com/Albertchamberlain) diff --git a/Interrupts/linux-interrupts-1.md b/Interrupts/linux-interrupts-1.md index 257a290..586d95f 100644 --- a/Interrupts/linux-interrupts-1.md +++ b/Interrupts/linux-interrupts-1.md @@ -422,34 +422,36 @@ SYM_DATA(initial_gs, 所有被 `IST` 切换到新栈的中断门描述符都由 `set_intr_gate_ist` 函数初始化。例如: ```C -set_intr_gate_ist(X86_TRAP_NMI, &nmi, NMI_STACK); -... -... -... -set_intr_gate_ist(X86_TRAP_DF, &double_fault, DOUBLEFAULT_STACK); +static const __initconst struct idt_data def_idts[] = { + ... + INTG(X86_TRAP_NMI, nmi), + ... + INTG(X86_TRAP_DF, double_fault), ``` -其中 `&nmi` 和 `&double_fault` 是中断函数的入口地址: +其中 `&nmi` 和 `&double_fault` 在以下位置创建入口点: + +[arch/x86/kernel/entry_64.S](https://github.com/torvalds/linux/blob/master/arch/x86/entry/entry_64.S)中 + +```assembly +idtentry double_fault do_double_fault has_error_code=1 paranoid=2 read_cr2=1 +... +... +... +SYM_CODE_START(nmi) +... +... +... +SYM_CODE_END(nmi) +SYM_CODE_END(nmi) +``` +在以下位置给出了中断处理程序的声明 [arch/x86/include/asm/traps.h](https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/traps.h): ```C asmlinkage void nmi(void); asmlinkage void double_fault(void); ``` -定义在 [arch/x86/kernel/entry_64.S](https://github.com/torvalds/linux/blob/master/arch/x86/kernel/entry_64.S)中 - -```assembly -idtentry double_fault do_double_fault has_error_code=1 paranoid=2 -... -... -... -ENTRY(nmi) -... -... -... -END(nmi) -``` - 当一个中断或者异常发生时,新的 `ss` 选择器被强制置为 `NULL`,并且 `ss` 选择器的 `rpl` 域被设置为新的 `cpl`。旧的 `ss`、`rsp`、寄存器标志、`cs`、`rip` 被压入新栈。在 64 位模型下,中断栈帧大小固定为 8 字节,所以我们可以得到下面的栈: ``` diff --git a/README.md b/README.md index 8221455..ccdcbe6 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ |└ [2.10](https://github.com/MintCN/linux-insides-zh/blob/master/Initialization/linux-initialization-10.md)||未开始| | 3. [Interrupts](https://github.com/MintCN/linux-insides-zh/tree/master/Interrupts)||正在进行| |├ [3.0](https://github.com/MintCN/linux-insides-zh/blob/master/Interrupts/README.md)|[@littleneko](https://github.com/littleneko)|更新至[57279321](https://github.com/0xAX/linux-insides/commit/5727932167a2ff6a1e647081c85d081d4ed8b508)| -|├ [3.1](https://github.com/MintCN/linux-insides-zh/blob/master/Interrupts/linux-interrupts-1.md)||正在进行| +|├ [3.1](https://github.com/MintCN/linux-insides-zh/blob/master/Interrupts/linux-interrupts-1.md)|[@Albertchamberlain](https://github.com/Albertchamberlain)|更新至[e58c06bf](https://github.com/0xAX/linux-insides/commit/e58c06bfca60d4af25d92562de1ee9959992fc68)| |├ [3.2](https://github.com/MintCN/linux-insides-zh/blob/master/Interrupts/linux-interrupts-2.md)|[@narcijie](https://github.com/narcijie)|更新至[4d635117](https://github.com/0xAX/linux-insides/commit/4d6351172486e5c046a7d3db2286fc0d0d0d7789)| |├ [3.3](https://github.com/MintCN/linux-insides-zh/blob/master/Interrupts/linux-interrupts-3.md)||未开始| |├ [3.4](https://github.com/MintCN/linux-insides-zh/blob/master/Interrupts/linux-interrupts-4.md)||未开始|