From 93dd23b65dd8819c850055ab8941308d41e52628 Mon Sep 17 00:00:00 2001 From: wuyuxin Date: Mon, 16 Nov 2020 20:31:05 +0800 Subject: [PATCH 1/3] Update linux-initialization-2.md --- Initialization/linux-initialization-2.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Initialization/linux-initialization-2.md b/Initialization/linux-initialization-2.md index 55c1b17..4046604 100644 --- a/Initialization/linux-initialization-2.md +++ b/Initialization/linux-initialization-2.md @@ -115,7 +115,11 @@ Where: * `Offset` - is offset to entry point of an interrupt handler; * `DPL` - Descriptor Privilege Level; * `P` - Segment Present flag; -* `Segment selector` - a code segment selector in GDT or LDT +* `Segment selector` - a code segment selector in GDT or LDT (actually it always point to GDT in linux) +```C +#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8) // 0000 0000 0001 0000 +#define GDT_ENTRY_KERNEL_CS 2 +``` * `IST` - provides ability to switch to a new stack for interrupts handling. And the last `Type` field describes type of the `IDT` entry. There are three different kinds of gates for interrupts: @@ -164,7 +168,7 @@ where `NUM_EXCEPTION_VECTORS` expands to `32`. As we can see, We're filling only and inserts an interrupt gate to the `IDT` table which is represented by the `&idt_descr` array. -The `early_idt_handler_array` array is declaredd in the [arch/x86/include/asm/segment.h](https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/segment.h) header file and contains addresses of the first `32` exception handlers: +The `early_idt_handler_array` array is declared in the [arch/x86/include/asm/segment.h](https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/segment.h) header file and contains addresses of the first `32` exception handlers: ```C #define EARLY_IDT_HANDLER_SIZE 9 From eb6d1204a9b6396dd82cfbb95a8f628facb3e9ce Mon Sep 17 00:00:00 2001 From: wuyuxin Date: Mon, 16 Nov 2020 20:33:15 +0800 Subject: [PATCH 2/3] Update contributors.md --- contributors.md | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.md b/contributors.md index fabb0af..618908f 100644 --- a/contributors.md +++ b/contributors.md @@ -131,3 +131,4 @@ Thank you to all contributors: * [Sebastian Fricke](https://github.com/initBasti) * [Zhouyi Zhou](https://github.com/zhouzhouyi-hub) * [Mingzhe Yang](https://github.com/Mutated1994) +* [Yuxin Wu](https://github.com/chaffz) From af6b5d82b590736eb6a5a6f7298bb2e700e67b83 Mon Sep 17 00:00:00 2001 From: wuyuxin Date: Mon, 16 Nov 2020 20:44:51 +0800 Subject: [PATCH 3/3] Update linux-initialization-2.md --- Initialization/linux-initialization-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Initialization/linux-initialization-2.md b/Initialization/linux-initialization-2.md index 4046604..d2d4664 100644 --- a/Initialization/linux-initialization-2.md +++ b/Initialization/linux-initialization-2.md @@ -115,7 +115,7 @@ Where: * `Offset` - is offset to entry point of an interrupt handler; * `DPL` - Descriptor Privilege Level; * `P` - Segment Present flag; -* `Segment selector` - a code segment selector in GDT or LDT (actually it always point to GDT in linux) +* `Segment selector` - a code segment selector in GDT or LDT (actually in linux, it must point to a valid descriptor in your GDT.) ```C #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8) // 0000 0000 0001 0000 #define GDT_ENTRY_KERNEL_CS 2