Page 1 of 1
jump_protected: gate type 11 unsupported
Posted: Mon May 23, 2011 5:44 am
by Igor1024
Hi everybody.
Does anyone know what subj means (Bochs error message). I'm trying find bug in tasks, but don't know where start. The sense of this message will help me.
If you have Bochs error message list, please, let me to know or just give a link ( google didn't help me).
Re: jump_protected: gate type 11 unsupported
Posted: Mon May 23, 2011 7:19 am
by egos
Show the code.
Re: jump_protected: gate type 11 unsupported
Posted: Mon May 23, 2011 7:25 am
by Combuster
It's usually a broken gdt/idt. Other than that: egos +1: there's little more to tell without code and/or memory dumps of the relevant areas.
Re: jump_protected: gate type 11 unsupported
Posted: Mon May 23, 2011 7:07 pm
by Igor1024
Memory at addresses 109000h-112000h - TSS's area. It has descriptor at GDT and rises no problems. Then there is one TSS, located at 109000h, size>67h. I fill parts of it by
Code: Select all
set_TSS:
push es
mov ax,20h;TSS_area selector;
mov es,ax
xor eax,eax
xor edi,edi
mov cx,26
cld
rep stosd
xor edi,edi
mov eax,cr3
mov ebx,print_hi;function
xor ecx,ecx ;EFLAGS. Can leave it unsaved?
mov edx,500h ;New ESP value
mov [es:di+28],eax;CR3
mov [es:di+32],ebx;EIP
mov [es:di+36],ecx;EFLAGS
mov [es:di+56],edx;ESP
mov al,8h
mov [es:di+76],al;code
mov al,10h
mov [es:di+84],al;ds
pop es
ret
Code: Select all
call set_TSS;prepare structure
mov ax,28h;TSS selector
ltr ax
mov bx,GDT+(8*5)
and byte [es:bx+5],11111101b;clear busy flag
jmp 28h:0;start task execution
'hi_string' just prints string and ends by iret.
Re: jump_protected: gate type 11 unsupported
Posted: Mon May 23, 2011 11:01 pm
by Combuster
;clear busy flag
Tasks are not reentrant. You are trying to hack your way around the protection that was designed to prevent you from doing stupid things in the first place...
Re: jump_protected: gate type 11 unsupported
Posted: Mon May 23, 2011 11:53 pm
by rdos
Combuster wrote:;clear busy flag
Tasks are not reentrant. You are trying to hack your way around the protection that was designed to prevent you from doing stupid things in the first place...
It is usually necesary to do this "hack" when doing software-taskswitching and having one TSS per task. As soon as you load TR with a TSS selector, it would be marked as busy. However, there is no work-around for switching to yourself.
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 12:24 am
by Igor1024
What else could have caused error?
About busy flag: I've read that it's set when load TR, but deleting code of unsetting B flag doesn't help;
Error occurs when jump to task; Have no ideas about where made mistake.
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 12:36 am
by Combuster
rdos wrote:It is usually necesary to do this "hack" when doing software-taskswitching and having one TSS per task.
No and no. One TSS per task is usually an indication of hardware task switching. If you are modifying busy bits means you plan on changing TR at any point, and therefore perform hardware task switches.
And even hardware task switching, including cooperative and preemptive scheduling, can be done without repeated toggling of busy bits.
Error occurs when jump to task; Have no ideas about where made mistake.
Tasks are not reentrant
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 12:50 am
by Igor1024
You mean that task is executed since ltr? So, when jump to new task #GP is generated because that TSS is taken by another task.
Sorry if I grasp slowly, want sleep very much...
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 1:30 am
by egos
Then there is one TSS descriptor, located at 109000h
TSS descriptor or TSS? Show hardcoded TSS descriptor or how you are initializing it.
Code: Select all
mov [es:di+28],eax;CR3
mov [es:di+32],ebx;EIP
mov [es:di+36],ecx;EFLAGS
mov [es:di+56],edx;ESP
mov al,8h
mov [es:di+76],al;code
mov al,10h
mov [es:di+84],al;ds
16-bit addressing is a wrong practice. What is the selector ss field will hold?
There is no reason to do so.
ltr is enough.
If you use software task switching just set fields for kernel stack pointer and TSS terminator.
You mean that task is executed since ltr?
The primary task is executed since initial code was started.
ltr just validates task environment for multitasking.
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 1:51 am
by Igor1024
To
egos:
1)TSS:
Code: Select all
db 0FFh,0FFh,0,90h,10h,89h,8Fh,0;don't care about the limit - code is just example
2)SS holds nothing. 'Task' doesn't use stack at all.
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 2:21 am
by rdos
Igor1024 wrote:What else could have caused error?
About busy flag: I've read that it's set when load TR, but deleting code of unsetting B flag doesn't help;
Error occurs when jump to task; Have no ideas about where made mistake.
You first load current task with a TSS, then you try to switch to this same TSS, which is not valid.
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 2:22 am
by egos
Igor1024 wrote:1)TSS:
Code: Select all
db 0FFh,0FFh,0,90h,10h,89h,8Fh,0;don't care about the limit - code is just example
Cool size for TSS: (0FFFFFh+1)*4096
Try to use limit 67h and this terminator:
or limit 68h and this one:
Igor1024 wrote:2)SS holds nothing. 'Task' doesn't use stack at all.
If you will switch to this task the registers will be loaded automatically including ss. And what's happens when ss will be loaded with NULL selector?
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 2:37 am
by rdos
Combuster wrote:rdos wrote:It is usually necesary to do this "hack" when doing software-taskswitching and having one TSS per task.
No and no. One TSS per task is usually an indication of hardware task switching. If you are modifying busy bits means you plan on changing TR at any point, and therefore perform hardware task switches.
Not so. Software taskwitching still needs to save registers somewhere, still need IO-permission bitmaps in the TR, as well as stacks for all used rings. There is no reason not to save the registers in the usual TSS-area, and by reloading TR there is no need to patch IO bitmap and stacks on every context switch.
Re: jump_protected: gate type 11 unsupported
Posted: Tue May 24, 2011 3:17 am
by Igor1024
You first load current task with a TSS, then you try to switch to this same TSS, which is not valid.
I meant the same thing, but my English is far to be perfect.
Cool size for TSS: (0FFFFFh+1)*4096
Yep. Epic mega helloworld
Seriously it had normal size; I just experimented with descriptor; I thought the problem is in it;
Igor1024 wrote:2)SS holds nothing. 'Task' doesn't use stack at all.
If you will switch to this task the registers will be loaded automatically including ss. And what's happens when ss will be loaded with NULL selector?
#GP!