idt and paging

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
northfuse2005

idt and paging

Post by northfuse2005 »

hi
i just enabled paging, but my idt doesn't work now. with bochs, it returns the following message: (when i try to invoke the divide by zero error)

Code: Select all

[CPU] prefetch: RIP -> CS.limit
i can't figure it out. my idt was working fine before i enabled paging. any help would be appreciated. thanks
Tim

Re:idt and paging

Post by Tim »

The first thing I would check would be the limit on the code segment.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:idt and paging

Post by Pype.Clicker »

maybe you could try to locate the message in BOCHS sources and then run bochs in a debugger , setting a breakpoint where the error is reported and inspect the virtual CPU's state (like IDT descriptor content, RIP value, CS limit, etc).
Tim

Re:idt and paging

Post by Tim »

Or just read bochsout.txt, and look at the EIP register and the CS segment descriptor.
northfuse2005

Re:idt and paging

Post by northfuse2005 »

hey- thanks for the help.

another question- i've setup the page directories and tables, but how do i map physical addresses to virtual addresses, and how do i know it works when i do?
northfuse2005

Re:idt and paging

Post by northfuse2005 »

virtual memory makes since, but i can't get it to work. i enable pagin, map a physical address to a virtual address, but the only way to access the data at the address is through the virtual address. it doesn't make sense.
bkilgore

Re:idt and paging

Post by bkilgore »

sure it does...that's the way paging works. Once you enable paging, the memory unit interprets every address you try to access as a virtual address. So if you try to access memory at it's physical address, the memory unit will try to interpret that physical address as a virtual address, which won't work well at all, or at least won't do what you are expecting it to do.

The only ways to access that memory at its physical address is to a) disable paging, or b) identity-map that address, or tell the memory unit that the virtual address maps to the same physical address.

In other words, if the physical address of the memory is 0x20000, you have to map that virtual address to the same physical address. Then you wil be able to address that memory using either 0x20000, or the other virtual address you assigned it when allocating.

But there's no real point to doing this as you only need to reference it through it's virtual address, and if you add two references to the same physical address, you're just wasting virtual address space.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:idt and paging

Post by Pype.Clicker »

northfuse2005 wrote: virtual memory makes since, but i can't get it to work. i enable pagin, map a physical address to a virtual address, but the only way to access the data at the address is through the virtual address. it doesn't make sense.
of course, you must make sure to have the page directory itself mapped somewhere or you'll be unable to change the memory mapping once paging will be enabled.
northfuse2005

Re:idt and paging

Post by northfuse2005 »

sorry- i messed up when typing my post. i mean't to say that even after enabling paging, the only way to access the memory is through the physical address, even if that page table (and directory) aren't mapped to the physical address.
Post Reply