On Wed, Feb 01, 2006 at 08:44:43PM +0100, Johannes Stezenbach wrote: > If I understand this correctly, gdbserver should check the > register size supported by the OS, and communicate this to gdb? > > I'm using a Linux kernel with CONFIG_32BIT, and if I understand > the ptrace interface correctly, the registers as seen through > ptrace are 32bit then, even though the CPU has 64bit registers. Correct. On 32-bit kernels Linux will largely forget about the 64-bitness of the processor. User processes will run with 64-bit (UX bit) disabled, so they're never able to anything 64-bitish. The kernel will only save and restore the lower 32-bit of registers, so the upper 32-bit will be lost. That means only using the $zero register as 64-bit register is safe and that's exploited by clear_page(). There are a few place where 64-bit loads and stores are needed because particular hardware doesn't like being talked to with 32-bit accesses; those accesses need make sure they're not interrupted or bad things happen. See the code for *readq() and write() in <asm/io.h>. Ages ago I tried leaving all the 64-bit functionality available as far as possible even in 32-bit kernels. It turned out to be example messy and I was happy to have gotten rid of it, I think in 2.1.14. > (I have no idea if the cp0 status suggested by others in this > thread reflect CONFIG_32BIT vs. CONFIG_64BIT on Linux.) On 32-bit kernels Linux will clear c0_status.kx, c0_status.ux and c0_status.fr - on hardware were those bits exist at all, that is. On 64-bit kernels Linux will set c0_status.kx. It will also always set c0_status.ux which means 64-bit operations are legal even for 32-bit processes. To my knowledge nobody is exploiting that; I guess it could be exploited for a faster memcpy and similar. Finally c0_status.fr which will be set according to the ABI of the process, that is it'll be cleared for o32 and set for N32 and N64 processes. Ralf