OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 2:55 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: try to change cs register to point to kernel segment
PostPosted: Wed May 13, 2020 2:56 am 
Offline
Member
Member

Joined: Sat Aug 18, 2018 8:44 pm
Posts: 127
I was trying some weird things to understand the behavior of linux(32 bit)..

one of them is to manually assign the cs register to the kernel segment, of course
that gets me a segmentation fault termination... just curious what is the flow of events that
lead all the way to segmentation fault....why syscall and int 0x80 are only possible ways to enter
kernel mode???


Top
 Profile  
 
 Post subject: Re: try to change cs register to point to kernel segment
PostPosted: Wed May 13, 2020 4:14 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
You might want to read the Intel Programmer's Manuals.


Top
 Profile  
 
 Post subject: Re: try to change cs register to point to kernel segment
PostPosted: Wed May 13, 2020 5:07 am 
Offline
Member
Member

Joined: Sat Feb 08, 2020 11:11 am
Posts: 106
Yes.. There are only a handful of ways to enter switch modes. Try reading about call gates, interrupt gates task gates, trap gates, etc.


Top
 Profile  
 
 Post subject: Re: try to change cs register to point to kernel segment
PostPosted: Sat May 23, 2020 7:38 am 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 am
Posts: 402
ITchimp wrote:
I was trying some weird things to understand the behavior of linux(32 bit)..

one of them is to manually assign the cs register to the kernel segment, of course
that gets me a segmentation fault termination... just curious what is the flow of events that
lead all the way to segmentation fault....


The segmentation fault will have started with (I think) General Protection Fault as a result of trying to use a privileged segment in user mode.

Once linux gets control in the GPF handler, it'll post a SIGSEGV signal to the process. Now, SIGSEGV can be caught, and if so, when the returning from the GPF handler, linux will arrange for the SIGSEGV handler to be invoked in the user process. This is how some programs capture errors like this and produce crash reports rather than just dumping core.

Of course, the default action for SIGSEGV is to terminate with a core dump (if core dumps are enabled).

ITchimp wrote:
why syscall and int 0x80 are only possible ways to enter
kernel mode???


It's the basic protection mechanism. By entering through a known door, the OS can frisk you to ensure what you're doing is safe.


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: Bing [Bot], DotBot [Bot], Google [Bot] and 151 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