Page 1 of 1
bochs error
Posted: Fri Jan 02, 2009 9:12 pm
by yemista
Im trying to run my boot image with bochs and i get this error over and over again.
I did not attach the log file because it ended up being 3 megs with this error repeating over and over
LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
Re: bochs error
Posted: Fri Jan 02, 2009 9:37 pm
by JohnnyTheDon
You are attempting to run corrupted code or are using the LOCK prefix incorrectly. The LOCK prefix is used to lock the bus so other processors in an SMP system don't access the memory at the same time as another processor. Most likely, you are executing a jump to a unintened memory location.
I remember seeing bochs initialize memory as 0xf0530000 (or something like that). Since the lock prefix is 0xf0 and the opcode from the error message is 0x53, that's probably your issue.
Please post some code (and in the future please post some code in your first post, or someone will just ask for it later).
Re: bochs error
Posted: Sat Jan 03, 2009 4:00 am
by Combuster
You can also snip out the lock errors from the dump. Interesting is what happened just before the error (few lines before the first unallowed lock prefix), and what the state is during the error (the dump afterwards). The reason you are flooded with the message is because of the BIOS just IRETing every exception, going back to the bad opcode getting you stuck in an endless loop.
You can also use bochs to singlestep through your code and see where your code goes where it should not.
Re: bochs error
Posted: Sat Jan 03, 2009 9:11 am
by yemista
Yes you were right, I was jumping to a bad location. I fixed it, but now I have a new problem. I tried loading a small test kernel to ffff:0000 and then jumping to that location, but the kernel code wont execute and the screen just flashes, however, when I change the location to ffff:0500, the kernel code executes, so Im guessing that A20 is not really enabled and its wrapping around and overwriting ISR code at 0000. This is just a guess, because I took to enable A20 from
http://www.osdever.net/tutorials/a20.php and it checks to make sure the A20 was enabled. Also, I know bochs has a debugger, but I use open suse and it downloaded the bochs rpm for me, so I tried to download and install it myself with the debugger options, but the configure script tells me it cant find the x11 libraries. Maybe this is the wrong forum for this, but maybe its common?
Re: bochs error
Posted: Sat Jan 03, 2009 11:17 am
by Firestryke31
Isn't FFFF:0000 the very tail end of the BIOS ROM (i.e. there's still another 16 bytes left)? And in fact isn't it where the CPU goes when it first starts?
That would explain the 'reset,' because you're not actually writing to that area, and just doing a 'soft' reset. That is, if I happen to be right...
Re: bochs error
Posted: Sat Jan 03, 2009 12:24 pm
by yemista
Oh, I thought that was the start of the 1MB mark? but yes I changed it to ffff:001f and it worked. thank you
Re: bochs error
Posted: Sat Jan 03, 2009 1:48 pm
by Firestryke31
It actually resolves to the physical address 0x000FFFF0 + 0x0000 = 0x000FFFF0 (Segment * 16 + offset), so your revised address resolves to 0x000FFFF0 + 0x001F = 0x0010000F.
IMHO the 16-bit segment:offset scheme is annoying, but it was invented before I was born, so not much I can do about it.
Re: bochs error
Posted: Sat Jan 03, 2009 1:50 pm
by yemista
ok, now if i want to load the kernel at just above the 1MB mark, and then jump to it and be in protected mode, I have to setup gdt entries whose base is the address i jump to, which in this case is ffff:001f, and then do
jmp 0x08:0000 right after I set the bit in cr0, and I should be in pmode? I dont know how to comfirm if im there or not