Question about ia64 linux
Hello,
A question wrt to ia64 linux environment:
Is it possible to modify a running code (in a module or kernel) in ia64 linux? (It is not a good practise to do it. But, I need to check this out as it was done in ia32.....)
Probably, it is possible. I just wanted to see whether there are any issues one should be aware of other than serialization/flushing. There are couple of pages of documentation regarding self-modifying code in one of the ia64 software developers manual. I am curious whether there are any other notes/writeups or sample code where similar kind of things are done in ia64 linux. I really appreciate if some one can direct me to such doc or code (if they exist) which can give some
more ia64 specific information.
Thank you very much in advance.
Regards,
Raj
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now!
http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/
Quoted 3 lines
Is it possible to modify a running code (in a module or kernel) in ia64 linux? (It is not a good practise to do it. But, I need to check this out as it was done in ia32.....)
Yes it can be done. Whether it is good practice is in the eye of the beholder ... and depends a lot on what you are actually doing. If you have some 1950's code that reads auccessive elements from an array my modifying the code that loads the address ... then it's time to rewrite :-) If you have some on-the-fly code generation (e.g. a Just-in-time compilation system) ... then that's a lot more palatable.
Quoted 10 lines
Probably, it is possible. I just wanted to see whether there are any issues one should be aware of other than serialization/flushing. There are couple of pages of documentation regarding self-modifying code in one of the ia64 software developers manual. I am curious whether there are any other notes/writeups or sample code where similar kind of things are done in ia64 linux. I really appreciate if some one can direct me to such doc or code (if they exist) which can give some more ia64 specific information.
The software developers manual covers everything that you need to know. There are some code examples in the Linux kernel code (where we modify a load instruction to grab the physical address of an object, rather than the virtual address ... used because the address won't be known for sure until run-time). These aren't very dynamic though ... the instructions are patched during kernel initialization, and never touched again. Look at ia64_patch_vtop() in arch/kernel/ia64/patch.c
-Tony
Thanks for the comments/pointers Tony.
Regards,
Raj
Quoted 38 lines
From: "Luck, Tony" <[email protected]>
To: "Raj Pati" <[email protected]>, <[email protected]>
Subject: RE: Question about ia64 linux
Date: Sun, 21 Mar 2004 22:13:23 -0800Quoted 3 lines
Is it possible to modify a running code (in a module or kernel) in ia64 linux? (It is not a good practise to do it. But, I need to check this out as it was done in ia32.....)
Yes it can be done. Whether it is good practice is in the eye of the beholder ... and depends a lot on what you are actually doing. If you have some 1950's code that reads auccessive elements from an array my modifying the code that loads the address ... then it's time to rewrite :-) If you have some on-the-fly code generation (e.g. a Just-in-time compilation system) ... then that's a lot more palatable.
Quoted 10 lines
Probably, it is possible. I just wanted to see whether there are any issues one should be aware of other than serialization/flushing. There are couple of pages of documentation regarding self-modifying code in one of the ia64 software developers manual. I am curious whether there are any other notes/writeups or sample code where similar kind of things are done in ia64 linux. I really appreciate if some one can direct me to such doc or code (if they exist) which can give some more ia64 specific information.
The software developers manual covers everything that you need to know. There are some code examples in the Linux kernel code (where we modify a load instruction to grab the physical address of an object, rather than the virtual address ... used because the address won't be known for sure until run-time). These aren't very dynamic though ... the instructions are patched during kernel initialization, and never touched again. Look at
ia64_patch_vtop()inarch/kernel/ia64/patch.c
Quoted 1 line
-Tony
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now!
http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Tony
Tony> The software developers manual covers everything that Tony> you need to know.
True, but if you modify code in such a way that it affects a procedure's call-frame, then you need to patch the unwind info as well, and that's not discussed in these manuals. The Software Convention and Runtime Architecture does discuss unwind info, but doesn't directly address the issue of runtime-generated code. The libunwind API (http://www.hpl.hp.com/research/linux/libunwind/) has support for (efficiently) describing runtime-generated code but, alas, this API isn't used in the kernel yet. And even if it were, it's unlikely the dynamic unwind info support would be enabled for the kernel (not until someone demonstrates a real need for having a JIT in the kernel, at least ;-).
--david