Wednesday, April 4, 2012

back porting native_rdmsr_safe_regs

This function is used by new Linux kernels and I need to port it back to an old 2.6.9 kernel. The compiler complains that cannot find the reference to this function and its brother ( native_wrmsr_safe_regs).

Then I used vim/cscope to search symbols/text for native_wrmsr_safe_regs, but cannot find anything about it. Google it gave the same result. After some time, I used gitk to check the log of a related c file and found out these two functions are defined in an assembly file, by using macros.

Then I happily copied that assembly file (msr-reg.S) to the old kernel source. But this time I got some weird errors as "invalid character '(' in mnemonic". Then I google for this for some time and noticed that there is some definitions in "link/linkage.h". For example, ENTRY used in the msr-reg.S is defined there.

Finally I found out "ENDPROC" used in msr-reg.S is not in my version of linkage.h. After copy that definition, the compiler does not complain about these functions again.

No comments: