public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gaurav Dhiman <gaurav4lkg@gmail.com>
To: "liyu@WAN" <liyu@ccoss.com.cn>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Question] How get instruction pointer of user space ???
Date: Wed, 31 Aug 2005 17:53:09 +0530	[thread overview]
Message-ID: <1e33f57105083105237975882d@mail.gmail.com> (raw)
In-Reply-To: <43157F88.60900@ccoss.com.cn>

On 8/31/05, liyu@WAN <liyu@ccoss.com.cn> wrote:
> Hi everyone:
> 
>     I am implemnting one ioctl() in one character device.
> 
>     That need know instruction pointer of user space. I am on i386
> platform.
> I can sure I am in process context. and enter kernel by system call way.
> 
>     As I known, in default case, each task have one kernel stack, its length
> is THREAD_SIZE(2 pages),  and current_thread_info() is at its top. the
> struct pt_regs is at bottom of this stack.
> 
>     so I write the code like here:
> 
>     pt_regs = ((struct pt_regs *)(THREAD_SIZE + current_thread_info()))+1;

try doing the following, I amnot sure of it, just try it.

pt_regs = (struct pt_regs *) (((int *)(THREAD_SIZE + current)) -
(sizeof(pt_regs) + 1));

>     return pt_regs->eip;
> 
>     but it do not work! even, I get segment fault and kernel Oops at
> sometime.
> 
>     Also, I am sure current_thread_info() return right value of current
> user task.
> 
>     Any idea on here?
> 
>     thanks
> 
> 
>                                                                    sailor.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

      reply	other threads:[~2005-08-31 12:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-31  9:59 [Question] How get instruction pointer of user space ??? liyu@WAN
2005-08-31 12:23 ` Gaurav Dhiman [this message]

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=1e33f57105083105237975882d@mail.gmail.com \
    --to=gaurav4lkg@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liyu@ccoss.com.cn \
    /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