str ax; ltr ax == general protection fault

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
rianquinn
Posts: 16
Joined: Thu Jan 21, 2010 9:31 pm

str ax; ltr ax == general protection fault

Post by rianquinn »

If I run the following in the Linux kernel (just as a test), I get a general protection fault (nasm syntax):

Code: Select all

test_tr:
    str ax
    ltr ax
    ret
I get a general protection fault. Looking at the manual, the only things that cause a GPF are:
- Setting a NULL selector (cannot be true since I am using the existing TSS)
- Index out of bounds (also cannot be true since I am using the existing TSS)
- TSS is not available (no idea what this means)

I suspect the "not available" must be the issue, but I'm not sure what this means. Any ideas why the above code would fail? My only guess is that you cannot change to the same TSS and must always change to a different TSS.

Thanks
- Rian
MDenham
Member
Member
Posts: 62
Joined: Sat Nov 10, 2012 1:16 pm

Re: str ax; ltr ax == general protection fault

Post by MDenham »

When you store the current task register, it's marked as busy.

You get a GPF trying to switch to a busy task.
rianquinn
Posts: 16
Joined: Thu Jan 21, 2010 9:31 pm

Re: str ax; ltr ax == general protection fault

Post by rianquinn »

The str operation says nothing about setting the busy bit, but ltr does say that:

"if the source selector points to a segment that is not a TSS or to one for a task that is already busy". My interpretation here is that you cannot load an already loaded TSS.

Thoughts?
- Rian
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: str ax; ltr ax == general protection fault

Post by Octocontrabass »

MDenham wrote:When you store the current task register, it's marked as busy.
When you load the task register, it's marked as busy.

Trying to load it a second time causes a fault because it's already marked as busy.
MDenham
Member
Member
Posts: 62
Joined: Sat Nov 10, 2012 1:16 pm

Re: str ax; ltr ax == general protection fault

Post by MDenham »

Octocontrabass wrote:
MDenham wrote:When you store the current task register, it's marked as busy.
When you load the task register, it's marked as busy.
Whoops. Bad wording on my part; I wasn't intending to imply that storing the current task register was what marked it as busy, just that you're storing one that is marked as busy.
Post Reply