
Dear Leif Lindholm,
In message 50214A38.3000305@arm.com you wrote:
Most architectures keep the global data pointer (gd) in a register.
This may, or may not be. You should not make any assumptions on how gd is implemented.
When using the external app API, because they are calling us rather than we calling them, this register can be corrupted.
How can this be? The caller should always use the same register convention as we do - otherwise we are in a much deeper trouble. It is up to the caller to make sure it uses the published API (resp. ABI).
The attached (trivial) patch saves the gd pointer at api_init(), and restores it on every entry to syscall(). This may want to be put behind an ifdef for those architectures that don't use a dedicated register.
This is wrong. You make assumptions here why may be correct, but may be wrong as well. If we were to implement this, you would have to make sure it always works, no matter how gd is implemented on a specific board / platform. But I doubt this is the right approach. This should be done by the caller.
BTW: Please also note that there are a few coding style errors. Checkpatch says:
WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt WARNING: please, no spaces at the start of a line (2 x)
Best regards,
Wolfgang Denk