This is the mail archive of the systemtap@sources.redhat.com mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Hitachi djprobe mechanism


* Karim Yaghmour (karim@opersys.com) wrote:
> 
> Masami Hiramatsu wrote:
> > I think so. the size of smallest jmp instruction is 2 bytes on i386,
> > but the smallest instruction is 1byte on i386 (ex. pushl %esi).
> > I will try to add safety check routine in sched() and do_IRQ().
> 
> I'm sorry, I'm probably missing something. What will the checks in
> sched() and do_IRQ() do to avoid problems?
> 

I suggest this approach :

* Using a landing zone for the probe initially filled with something like :

(for a 5 bytes jmp instruction)

local_irq_save ("pushfl ; popl %0 ; cli")
nop
nop
nop
nop
local_irq_restore ("pushl %0 ; popfl")

It will protect from interruptions (therefore preemption) in the landing zone on
every CPU.

* Let's see what the code alteration function could do :

You may then change the cli instruction from the local_irq_save for an int3
instruction. You then simply check that no other CPU has interrupts disabled
(use an IPI). You are then sure that no other CPU is in the zone you want to
modify (or has an address falling in this zone as a return address from an
interrupt).

The only problem you will have is if an NMI comes in at the middle of the nops.
But hey! The processors won't answer to your low priority IPI until the NMI
handler has finished and interrupts are reenabled.

Once you known that your zone

int3
nop
nop
nop
nop

is protected, you just have to change those 5 bytes for your jmp (make sure that
int3 is the last one to be changed).

* Then int3 handler could simply return to the exact spot at the pushl %0.


The downside of this approach is that it needs a marker in the code and has a
small impact on a system performance when it is not traced.

Any comments ?


Mathieu


OpenPGP public key:              http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint:     8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]