On Tue, 25 Dec 2007, yossi wrote:

> Hope this is the right place for this kind of questions.
>
> I'm trying to create a kernel instrumentation tool on Solaris 10.  It works 
> by overwriting specific functions with assembly code that diverts execution 
> path and later resume it.
>
> This works well on Solaris 10 Update 4 on Intel platforms.  I've encountered 
> a problem porting to SPARC (Solaris 10 6/06 on UltraSPARC-IIIi):
>
> Apparently on SPARC, kernel text pages other than the current module are not 
> writable.  Using hat_getattr() I can tell that they don't have PROT_WRITE.  
> However, trying to to use hat_setattr() causes the system to crash without 
> even generating a crash dump.
>
> Doing the same to text pages that belong to the same module succeeds.  One 
> thing I've noticed is that the local pages are 8K, while other kernel text 
> pages are 4MB.  I'm not sure whether or not this is related.
>
> I'll appreciate any feedback on this, what might be the cause and what other 
> alternatives may be available.

The nucleus page (the 4MB "initial kernel text") is special, but I'm not 
deeply enough into SPARC to know the details without reading the source.

Wrt. to feedback, three things:

a) DTrace seems to be quite a viable kernel instrumentation tool; wouldn't
    you think it a good idea to work with the DTrace community on extending
    its features instead of reinventing the wheel ?

b) DTrace has solved this problem before, see the sourcecode for the FBT
    provider on SPARC. It creates a temporary writable mapping via explicit
    hat_devload() for the purpose of modifying a module's text seg.

c) Not really surprised by the behaviour; that the kernel attempts to use
    large pages (one size of which happens to be 4MB on SPARC) has benefits
    on performance, and that you cannot, unless you load/unload a module,
    write text seems a reliability feature. Why have it otherwise ?

Best wishes,
FrankH.

>
>
> Thanks
> Yossi
>
>
> This message posted from opensolaris.org
> _______________________________________________
> opensolaris-code mailing list
> [email protected]
> http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
>

------------------------------------------------------------------------------
No good can come from selling your freedom, not for all the gold in the world,
for the value of this heavenly gift far exceeds that of any fortune on earth.
------------------------------------------------------------------------------
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to