Preliminary analysis of instruction lengths in x86 kernel
Karim Yaghmour
karim@opersys.com
Sat Jul 30 20:27:00 GMT 2005
Here's for the fun of it a sample analysis of instruction lengths:
For a 2.6.11-rc1-mm1 kernel configured for my desktop:
Total number of instructions (.text only): 879983
Number of instructions of 4 bytes or less: 646767 (73%)
Number of instructions of 5 bytes and more: 233216 (27%)
For a 2.6.12.3 x86 kernel configured for my laptop:
Total number of instructions (.text only): 747529
Number of instructions of 4 bytes or less: 518694 (69%)
Number of instructions of 5 bytes and more: 228835 (31%)
For a 2.4.26 x86 kernel configured for my laptop:
Total number of instructions (.text only): 475764
Number of instructions of 4 bytes or less: 352559 (74%)
Number of instructions of 5 bytes and more: 123205 (26%)
This doesn't include an analysis of any of the loadable modules. It
would be hard to come up with any definitive results as these counts
will depend largely on kernel configuration. I guess a larger sample
would provide a better idea. But for the current purposes, the above
sample should suffice.
Anything that attempts to insert random jmps (5 bytes) will only
apply to 1/4 of the kernel, and that's if no further limitations
are imposed by the context of the instruction being replaced (ex.:
copy_to_user()).
I've created a script that does the work of splitting instructions
according to length and counts them. I've posted it here:
http://marc.theaimsgroup.com/?l=linux-kernel&m=112275407616066&w=2
Karim
--
Author, Speaker, Developer, Consultant
Pushing Embedded and Real-Time Linux Systems Beyond the Limits
http://www.opersys.com || karim@opersys.com || 1-866-677-4546
More information about the Systemtap
mailing list