支持分页的Intel 32位保护模式会导致三重故障

时间:2013-05-01 00:46:58

标签: x86 kernel paging intel protected-mode

我正在开发一个业余爱好者操作系统,我在身份映射和启用分页方面遇到了麻烦。我正在使用Bochs模拟器,我有以下错误消息:=

00691299602e [CPU0] interrupt():门描述符无效sys seg(vector = 0x0e)

00691299602e [CPU0] interrupt():门描述符无效sys seg(vector = 0x08)

00691299602i [CPU0] CPU处于保护模式(活动)

00691299602i [CPU0] CS.d_b = 32位

00691299602i [CPU0] SS.d_b = 32位

00691299602i [CPU0] | EAX = e0000011 EBX = 00000209 ECX = 00000f9f EDX = 00000f9f

00691299602i [CPU0] | ESP = 0000ff5c EBP = 00000001 ESI = 00000209 EDI = 0001d000

00691299602i [CPU0] | IOPL = 0 id vip vif ac vm RF nt of df if tf SF zf af PF cf

00691299602i [CPU0] | SEG选择器基极限G D

00691299602i [CPU0] | SEG sltr(指数| ti | rpl)基本限制G D

00691299602i [CPU0] | CS:0008(0001 | 0 | 0)00000000 fffffff 1 1

00691299602i [CPU0] | DS:0018(0003 | 0 | 0)00000000 fffffff 1 1

00691299602i [CPU0] | SS:0018(0003 | 0 | 0)00000000 ffffffff 1 1

00691299602i [CPU0] | ES:0018(0003 | 0 | 0)00000000 ffffffff 1 1

00691299602i [CPU0] | FS:0018(0003 | 0 | 0)00000000 ffffffff 1 1

00691299602i [CPU0] | GS:0018(0003 | 0 | 0)00000000 ffffffff 1 1

00691299602i [CPU0] | EIP = 00102764(00102764)

00691299602i [CPU0] | CR0 = 0xe0000011 CR2 = 0xe0000011

00691299602i [CPU0] | CR3 = 0x00014000 CR4 = 0x00000000

00691299602i [CPU0] 0x00102764>> add byte ptr ds:[eax],al:0000

00691299602e [CPU0]异常():没有解决方案的第3(13)个异常,关闭状态为 00h,重置

我要做的是身份映射整个可用的ram,以及我正在使用的代码 这样做是:=

printk(" page_limit [%d]\n",page_limit);
for(i=0,virt=0; i < NR_PAGES; ++i,virt += PAGE_SIZE) {
    frame = (PAGE_SIZE * (i % 1024));
    if(i < page_limit) {
        page = 0;
        PT_SET_ATTRIB(page, PTE_PRESENT);
        PT_SET_ATTRIB(page, PTE_READ_WRITE);
        PT_SET_FRAME(page, frame);
        KERNEL_PAGE_TABLE[i] = page;
    } else {
        page = 0;
        PT_SET_ATTRIB(page, PTE_PRESENT);
        PT_SET_ATTRIB(page, PTE_READ_WRITE);
        PT_SET_ATTRIB(page, PTE_USER);
        PT_SET_FRAME(page, frame);
        KERNEL_PAGE_TABLE[i] = page;
    }
}

printk(" page_limit [%d]\n",page_limit);
for(i = 0, frame = (unsigned)KERNEL_PAGE_TABLE; 
        i < NR_PAGE_TABLES; ++i, frame += PAGE_SIZE) {
    if(i < page_limit) {
        page = 0;
        PD_SET_ATTRIB(page, PDE_PRESENT);
        PD_SET_ATTRIB(page, PDE_READ_WRITE);
        PD_SET_FRAME(page, frame);
        KERNEL_PAGE_DIR[i] = page;
    } else {
        page = 0;
        PD_SET_ATTRIB(page, PDE_PRESENT);
        PD_SET_ATTRIB(page, PDE_READ_WRITE);
        PD_SET_ATTRIB(page, PDE_USER);
        PD_SET_FRAME(page, frame);
        KERNEL_PAGE_DIR[i] = page;
    }
}

Where the following macros are defined :=

#define PD_SET_ATTRIB(entry, attrib) \
    (entry) |= (attrib);

#define PD_SET_FRAME(entry, addr) \
    (entry) = ((entry) & ~0xFFFFF000) | (addr << 12);

类似于PT_SET_ATTRIB和PT_SET_FRAME。我认为映射是错误的, Bochs停止的实际行看起来像引用空指针:=

add byte ptr ds:[eax], al : 0000

但它看起来也像CPU试图加载页面错误和双故障处理程序 最终三重故障导致CPU复位。我希望有人可以提供帮助 指出错误。

由于

0 个答案:

没有答案