Instruction unavailable error

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
hanumant
Posts: 21
Joined: Mon Jul 23, 2007 10:16 pm

Instruction unavailable error

Post by hanumant »

HI
I had a lot of trouble with higher half kerenl so i decided to drop that idea, though i did want to enable paging . My kernel loads at 1 MB mark
ALso prior to the paging, I setup the gdt as specified by BRAN tutorial, base 0 seg limit = 0xFFFFF(code and data descriptors)

and for paging i do this.
unsigned long pagedir[1024] __attribute__((aligned(4096)));
unsigned long *pagedir_ptr = 0;
pagedir_ptr = (char *)pagedir; /*I am guessing the pagedir address is its physical address at this point*/

int k;
for(k = 0;k < 1024;k++)
{
pagedir[k] = 0;
}

pagedir[0] = 0x00000083; /*to set size to 4MB */
pagedir[1] = 0x00000083;

/* asm volatile ( "mov %0, %%eax\n"
"mov %%eax, %%cr3\n"
"mov %%cr0, %%eax\n"
"mov %%cr4, %%eax\n"
"orl %%eax, 0x00000010\n" /* to have 4MB and 4Kb pages*/
"mov %%eax, %%cr4\n"
"mov %%cr0, %%eax\n"
"orl 0x80000000, %%eax\n"
"mov %%eax, %%cr0\n" :: "m" (pagedir_ptr));

Bochs output :
just before reset
00043383085i[CPU0 ] | SEG selector base limit G D
00043383085i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00043383085i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00043383085i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00043383085i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00043383085i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00043383085i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00043383085i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00043383085i[CPU0 ] | EIP=00101038 (00101038)
00043383085i[CPU0 ] | CR0=0x80000011 CR1=0 CR2=0x00106080
00043383085i[CPU0 ] | CR3=0x00106850 CR4=0x00000000
00043383085i[CPU0 ] (instruction unavailable) page not present
00043383085e[CPU0 ] exception(): 3rd (14) exception with no resolution, shutdown status

I dont understand, I am setting the PSE bit in cr4, it shows PSE as 0. Is there something wrong with the way I am doing this??
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

Despite your best efforts cr3 is not aligned on a page boundary...

Regards,
John.
hanumant
Posts: 21
Joined: Mon Jul 23, 2007 10:16 pm

Post by hanumant »

I just noticed that , what should i do?????
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

You could try hard-coding the address of the page directory.

Code: Select all

unsigned long *pagedir = some address you know is free and page aligned;
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

or you could use something like the following (GCC):

Code: Select all

extern unsigned long pagedir[1024];

asm
( ".align 4096;"
  ".globl pagedir; pagedir:"
  ".long  0;"
  ".align 4096;"
);
Author of COBOS
Post Reply