linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* help with access_process_vm
@ 2004-12-14 19:25 Fabiano Ramos
  2004-12-14 20:31 ` Chris Wright
  0 siblings, 1 reply; 4+ messages in thread
From: Fabiano Ramos @ 2004-12-14 19:25 UTC (permalink / raw)
  To: LKML

Hi all.

I am trying to write/read to/from a process image (to be more
specific, replace an instruction with a 0xCC trap) from within a debug
handler.  I mean, a debug handler will be fired
(via eflags) and I want to make sure the process will stop again at a
given address.

My new handler, called do_debug_new replaces the old do_debug. From inside it,
I do something like

       task = current;
       ....
       access_process_vm(task, addr, &oldvalue, sizeof(oldvalue), 0);
       newvalue= oldvalue;
       ptr = (char *) &newvalue;
       *ptr = 0xCC; 
       access_process_vm(task, addr, &newvalue, sizeof(newvalue), 1);
        ....

But the first time a call access_process_vm, dmesg shows me:
     
Debug: sleeping function called from invalid context at include/linux/rwsem.h:43
in_atomic():0, irqs_disabled():1
 [<c01145ac>] __might_sleep+0x8c/0xa0
 [<c011c69b>] access_process_vm+0x4b/0x1d0
 [<c010c830>] do_debug_new+0xd0/0x190
 [<c038c755>] schedule+0x275/0x460
 [<c0105c2d>] error_code+0x2d/0x40

What I am missing? Do I need some syncronization? Can the debug
handler run in the
context of a process that was not the one that caused the debug trap?

Thanks a lot
Fabiano

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: help with access_process_vm
  2004-12-14 19:25 help with access_process_vm Fabiano Ramos
@ 2004-12-14 20:31 ` Chris Wright
  2004-12-14 20:52   ` Fabiano Ramos
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wright @ 2004-12-14 20:31 UTC (permalink / raw)
  To: ramos_fabiano; +Cc: LKML

* Fabiano Ramos (fabiano.ramos@gmail.com) wrote:
> But the first time a call access_process_vm, dmesg shows me:
>      
> Debug: sleeping function called from invalid context at include/linux/rwsem.h:43
> in_atomic():0, irqs_disabled():1
>  [<c01145ac>] __might_sleep+0x8c/0xa0
>  [<c011c69b>] access_process_vm+0x4b/0x1d0
>  [<c010c830>] do_debug_new+0xd0/0x190
>  [<c038c755>] schedule+0x275/0x460
>  [<c0105c2d>] error_code+0x2d/0x40
> 
> What I am missing?

The access_process_vm() call is doing down_read(), which could sleep,
with irqs disabled.  That's what's wrong.

thanks,
-chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: help with access_process_vm
  2004-12-14 20:31 ` Chris Wright
@ 2004-12-14 20:52   ` Fabiano Ramos
  2004-12-15 10:52     ` Jirka Kosina
  0 siblings, 1 reply; 4+ messages in thread
From: Fabiano Ramos @ 2004-12-14 20:52 UTC (permalink / raw)
  To: Chris Wright; +Cc: LKML

> 
> The access_process_vm() call is doing down_read(), which could sleep,
> with irqs disabled.  That's what's wrong.
> 



Is it possible to put the process that caused the trap to sleep, call
schedule and
defer this access_process_vm to later on with irqs enabled and only than resume
the faulty process?

I want to write the the faulty process image.

Thanks
Fabiano

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: help with access_process_vm
  2004-12-14 20:52   ` Fabiano Ramos
@ 2004-12-15 10:52     ` Jirka Kosina
  0 siblings, 0 replies; 4+ messages in thread
From: Jirka Kosina @ 2004-12-15 10:52 UTC (permalink / raw)
  To: ramos_fabiano; +Cc: LKML

On Tue, 14 Dec 2004, Fabiano Ramos wrote:

> Is it possible to put the process that caused the trap to sleep, call
> schedule and defer this access_process_vm to later on with irqs enabled
> and only than resume the faulty process?

How would you ever reschedule that? There is no way scheduler can schedule 
interrupt contexts.

Try thinking about using some bottom half mechanisms which is kernel 
providing. Also consider this as offtopic here, should go to linux kernel 
newbies malinglist.

Cheers,

-- 
JiKos.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-15 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-14 19:25 help with access_process_vm Fabiano Ramos
2004-12-14 20:31 ` Chris Wright
2004-12-14 20:52   ` Fabiano Ramos
2004-12-15 10:52     ` Jirka Kosina

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).