jump_protected: gate type 11 unsupported

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
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

jump_protected: gate type 11 unsupported

Post 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).
Last edited by Igor1024 on Mon May 23, 2011 11:59 pm, edited 1 time in total.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: jump_protected: gate type 11 unsupported

Post by egos »

Show the code.
If you have seen bad English in my words, tell me what's wrong, please.
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:

Re: jump_protected: gate type 11 unsupported

Post 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.
"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 ]
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

Re: jump_protected: gate type 11 unsupported

Post 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.
Last edited by Igor1024 on Tue May 24, 2011 1:44 am, edited 1 time in total.
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:

Re: jump_protected: gate type 11 unsupported

Post 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...
"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 ]
rdos
Member
Member
Posts: 3310
Joined: Wed Oct 01, 2008 1:55 pm

Re: jump_protected: gate type 11 unsupported

Post 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. #-o
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

Re: jump_protected: gate type 11 unsupported

Post 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.
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:

Re: jump_protected: gate type 11 unsupported

Post 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
"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 ]
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

Re: jump_protected: gate type 11 unsupported

Post 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...
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: jump_protected: gate type 11 unsupported

Post 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?

Code: Select all

        jmp 28h:0;start task execution
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.
If you have seen bad English in my words, tell me what's wrong, please.
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

Re: jump_protected: gate type 11 unsupported

Post 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.
rdos
Member
Member
Posts: 3310
Joined: Wed Oct 01, 2008 1:55 pm

Re: jump_protected: gate type 11 unsupported

Post 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.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: jump_protected: gate type 11 unsupported

Post 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:

Code: Select all

  dw 0,68h
or limit 68h and this one:

Code: Select all

  dw 0,68h
  db 0FFh
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?
If you have seen bad English in my words, tell me what's wrong, please.
rdos
Member
Member
Posts: 3310
Joined: Wed Oct 01, 2008 1:55 pm

Re: jump_protected: gate type 11 unsupported

Post 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.
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

Re: jump_protected: gate type 11 unsupported

Post 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!
Post Reply