OSDev.org

The Place to Start for Operating System Developers
It is currently Sun May 19, 2024 10:32 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Memory paging and interruptions
PostPosted: Thu Feb 08, 2007 1:55 am 
Offline

Joined: Mon Dec 04, 2006 5:34 pm
Posts: 22
Well,... I was wondering if it's possible for an application to have no pages to the kernel, but still be able to make a syscall.

For example the application calls :

int $0x80

This calls linux-compatible interruption.

Now I don't want to page the interruption handler to the application. It seems that cr0 and cr3 aren't altered when int is called, so I was wondering if it's possible for the system to jump to a non-mapped area upon receiving an interrupt. Obviously no, but still... I wonder if it's really impossible.

Any clue about that is welcome :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 2:09 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Provided you have a valid ESP0/SS0, it can be done:

- application calls INT xxx
- processor loads ESP and SS from the TSS, CS and EIP from the IDT and jumps to that location.
- Processor generates a pagefault as the code does not exists
- Pagefault handler pages in the interrupt handler
- Pagefault handler resumes execution
- The interrupt is restarted and the syscall is executed

Alternatively, you can force a GPF on the INT call, check which int is called and act accordingly.

In either case, read the manuals for more info.

_________________
"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 ]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 4:58 am 
Offline
Member
Member

Joined: Sun Dec 31, 2006 11:56 am
Posts: 75
Location: Germany
Quote:
Now I don't want to page the interruption handler to the application
You should do that. Your application does not need write access to this page, but what's the problem if it sees this handler in memory ? If you want to change from user to kernel mode you can use Task Gates, but it's slow and needs a lot of extra work.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 5:46 am 
Offline

Joined: Mon Dec 04, 2006 5:34 pm
Posts: 22
Ok, so I'll just have to have a readonly page somewhere in process memory to handle interrupts, which will just switch to kernel pages and give control back to kernel.

Thanks a lot :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group