strange interrupt problem with bochs?

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
jinglexy
Posts: 15
Joined: Sat Mar 10, 2007 1:05 am

strange interrupt problem with bochs?

Post by jinglexy »

Code: Select all

	sti();
	__asm__ __volatile__("ud2a\n\t");
	*(int*)2 = 3;
	CKernel::syshalt();
the "ud2a" can trap into interrupt,
but "*(int*)2 = 3;" can't work?
why it's in bochs?
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Re: strange interrupt problem with bochs?

Post by bluecode »

Code: Select all

*(int*)2 = 3;
That would only cause a pagefault if the page at virtual address 0 is not mapped or you do not have enough rights to write that page.
jinglexy
Posts: 15
Joined: Sat Mar 10, 2007 1:05 am

Re: strange interrupt problem with bochs?

Post by jinglexy »

bluecode wrote:

Code: Select all

*(int*)2 = 3;
That would only cause a pagefault if the page at virtual address 0 is not mapped or you do not have enough rights to write that page.
hi,
i only mapped 3G~4G virtual address, and alloc 32M for bochs,

Code: Select all

void CTrap::test_trap(UNUSED int n)
{
        *(int *)0x2 = 3;			// failed trap in fault
        *(int *)0x40000020 = 3;		// failed trap in fault

        __asm__ __volatile__("ud2a\n\t");	// success trap in fault
}
 
thanks
jinglexy
Posts: 15
Joined: Sat Mar 10, 2007 1:05 am

Re: strange interrupt problem with bochs?

Post by jinglexy »

Code: Select all

void CTrap::test_trap(UNUSED int n)
{
        *(int *)0x2 = 3;			// failed trap in fault
        *(int *)0x40000020 = 3;		// success trap in fault

        __asm__ __volatile__("ud2a\n\t");	// success trap in fault
}
i made a little mistake, address 0x40000020 traps in gear,
all runs ok.
thanks
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

did you forget to unmap the first 4M ? (tlb flushes and all)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jinglexy
Posts: 15
Joined: Sat Mar 10, 2007 1:05 am

Post by jinglexy »

Combuster wrote:did you forget to unmap the first 4M ? (tlb flushes and all)
maybe i forgot, the first 4M memory setup by grub, i just take reference of linux-2.4, and din't see unmap in linux.
kernel only init addresss 3G~3G+memsize , nothing exception
Post Reply