kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: tobias@gambas-buch.de (Tobias Boege)
To: kernelnewbies@lists.kernelnewbies.org
Subject: linux segment
Date: Fri, 2 Nov 2012 10:32:44 +0100	[thread overview]
Message-ID: <20121102093244.GD544@aurora> (raw)
In-Reply-To: <CAPihQtvynmCZMhpGP6Gb+m80ycZ8i2-8b3WwQFoJrqn0O73Ggg@mail.gmail.com>

On Tue, 30 Oct 2012, Fan Yang wrote:
> 2012/10/29 Mulyadi Santosa <mulyadi.santosa@gmail.com>
> 
> > Hi Fan...
> >
> > On Sun, Oct 28, 2012 at 9:02 PM, Fan Yang <lljyangfan@gmail.com> wrote:
> > >
> > > [root at shell--box kernel_mod]# dmesg -c
> > > **********************************
> > > cs 60 96
> > > ds 7b 123
> > > ss 68 104
> > > es 7b 123
> > > fs d8 216
> > > gs e0 224
> > > **********************************
> > >
> > > The cs and ds in the kernel space is 60 and 7b. But the kernel define the
> > > KERNEL_CS as 60 and the KERNEL_DS as 7b.  Where am I wrong?
> > >
> >
> >
> > you print CS and DS twice, once during init and once during exit of
> > your kernel module. So, which one do you want to confirm?
> >
> > All in all, I have a guess that you see such number (DS belongs to
> > user space in kernel module) because IIRC kernel module loading is
> > done using syscall and with the help of modprobe helper.
> >
> > Thus, it is important to access user space during that stage, hence DS
> > still using user space data segment.
> >
> >
> > --
> > regards,
> >
> > Mulyadi Santosa
> > Freelance Linux trainer and consultant
> >
> > blog: the-hydra.blogspot.com
> > training: mulyaditraining.blogspot.com
> >
> 
> Hi  Mulyadi Santosa
>    I get the same result during the kernel module init and exit. Then I try
> to add a syscall to print these registers, and nothing changed. It is
> strange.

> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

(Weird, this is the third time, I have to send this. If anybody gets this
message multiple times, I apologise but my mail is not in the archives.)

If Mulyadi is right and we need DS to be USER_DS to access user space (I
really don't know, sorry, but maybe there is something in your <uaccess.h>?)
then your attempt to try with a syscall couldn't yield other values because
one trait of syscalls is that they can access user space.

This means you would get DS = USER_DS precisely _because_ you are in a
syscall. Module init and exit are, too, just some stack frames above one and
thus fall into this category as well.

But shouldn't it be possible to register a timer and then print the
segment registers? Timers are fired in softirq context and, hence, have no
connection to user space.

Regards,
Tobi

  parent reply	other threads:[~2012-11-02  9:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24 12:04 linux segment Fan Yang
2012-10-26 23:53 ` Mulyadi Santosa
2012-10-27  7:49 ` Jun Hu
2012-10-28 14:02   ` Fan Yang
2012-10-28 14:20     ` Fan Yang
2012-10-29  7:32     ` Mulyadi Santosa
2012-10-30  0:44       ` Fan Yang
2012-10-30  6:04         ` Mulyadi Santosa
2012-11-02  9:32         ` Tobias Boege [this message]
2013-06-20  9:02 ` Baoquan He
2013-06-20 10:01   ` Fan Yang
2013-06-20 13:40     ` Baoquan He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121102093244.GD544@aurora \
    --to=tobias@gambas-buch.de \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).