Page 1 of 1

Exception 13 in bochs

Posted: Mon Apr 18, 2011 10:40 am
by richi18007
I'm using the following snippet in order to load the LDT for the file , and i get an error as interrupt 13

Code: Select all

void Switch_To_Address_Space(struct User_Context *userContext)
{
	ushort_t ldtSelector;
	ldtSelector = userContext-> ldtSelector;
	__asm__ __volatile__ ( __asm__ __volatile__ (
	"Lldt% 0"
	: 
	:  "A" (ldtSelector)
	);  
}
Can anybody please tell me what's the error about .The dump of the error is as below

Re: Exception 13 in bochs

Posted: Mon Apr 18, 2011 4:34 pm
by Combuster
Bochs gives you the exact error: the provided selector has TI (bit 3) set, and loading an LDT from an existing LDT is not allowed.

Your inline assembly is suspect here. You tell lldt to use a register of gcc's choice (%0) while you force the argument into EAX:EDX ("A"), which needs not be the same (apart from the fact that using the eax-edx pair is just wrong)

Re: Exception 13 in bochs

Posted: Tue Apr 19, 2011 2:40 am
by Fanael
Combuster wrote:You tell lldt to use a register of gcc's choice (%0) while you force the argument into EAX:EDX ("A"), which needs not be the same
Actually, it has to be the same, because GCC can choose between EDX:EAX, EDX:EAX and EDX:EAX ("A"). If it's not, it's a bug in the compiler.