Are xmm-registers saved with a (task) context switch
Hi!
I want to use the xmm0 register (from the SSE2 extension of a Core2Duo CPU) to do atomic 64bit write/read accesses in 32 bit x86 mode.
My question is: Will the xmm[0..7] registers be saved with a task context switch when running Xenomai real time tasks in user space or do I have to take care to save them on the stack before using (and restoring them afterwards). Is it save to use these registers or will they be used by Xenomai (or Linux) internally?
Thanks for any answer on that question.
Regards
Mathias
Signature · 5 lines
Mathias Koehrer [email protected] Jetzt komfortabel bei Arcor-Digital TV einsteigen: Mehr Happy Ends, mehr Herzschmerz, mehr Fernsehen! Erleben Sie 50 digitale TV Programme und optional 60 Pay TV Sender, einen elektronischen Programmführer mit Movie Star Bewertungen von TV Movie. Außerdem, aktuelle Filmhits und spannende Dokus in der Arcor-Videothek. Infos unter www.arcor.de/tv
Quoted 9 lines · M. Koehrer
Hi!
I want to use the xmm0 register (from the SSE2 extension of a Core2Duo CPU) to do atomic 64bit write/read accesses in 32 bit x86 mode.
My question is: Will the xmm[0..7] registers be saved with a task context switch when running Xenomai real time tasks in user space or do I have to take care to save them on the stack before using (and restoring them afterwards). Is it save to use these registers or will they be used by Xenomai (or Linux) internally?Thanks for any answer on that question.
The xmm register are saved by the FPU switching routines. Note however, that depending on the x86 you are using the xmm registers are aliased to the FPU register or are separate registers. So, on machines where the xmm registers are aliased to normal FPU registers, you have to do the save restore on your own if you want to use MMX, SSE, or SSE2 and use FPU instructions in the same thread.
Signature · 1 line
Gilles
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · M. Koehrer
Hi!
I want to use the xmm0 register (from the SSE2 extension of a Core2Duo CPU) to do atomic 64bit write/read accesses in 32 bit x86 mode.
My question is: Will the xmm[0..7] registers be saved with a task context switch when running Xenomai real time tasks in user space or do I have to take care to save them on the stack before using (and restoring them afterwards). Is it save to use these registers or will they be used by Xenomai (or Linux) internally?
Quoted 8 lines
Quoted 1 line
Thanks for any answer on that question.
The xmm register are saved by the FPU switching routines. Note however, that depending on the x86 you are using the xmm registers are aliased to the FPU register or are separate registers. So, on machines where the xmm registers are aliased to normal FPU registers, you have to do the save restore on your own if you want to use MMX, SSE, or SSE2 and use FPU instructions in the same thread.
This probably applies to very old CPUs, xmm are separate registers now.
Signature · 1 line
Gilles
Re: [Xenomai-help] Are xmm-registers saved with a (task) context
Hi Gilles,
thanks for your response.
With the MMX registers, you are right. They are actually aliased with the FPU registers. However, the XMM registers (SSE, SSE2) are not aliased.
The aliased MMX registers AND the not-aliased XMM registers are available with today's CPUs, i.e. you still have to take card when using MMX registers.
(All information according to Intel's 64 and IA-32 Architectures
Software Developer’s Manual, Volume 1, Chapters 9,10,11)
Quoted 1 line
From your mail before I assume that the (not-aliased) XMM registers are saved with the switching routine
and can be used without have to save/restore them.
Regards
Mathias
Quoted 9 lines
Quoted 6 lines
The xmm register are saved by the FPU switching routines. Note however, that depending on the x86 you are using the xmm registers are aliased to the FPU register or are separate registers. So, on machines where the xmm registers are aliased to normal FPU registers, you have to do the save restore on your own if you want to use MMX, SSE, or SSE2 and use FPU instructions in the same thread.
This probably applies to very old CPUs, xmm are separate registers now.
Signature · 5 lines
Mathias Koehrer [email protected] Jetzt komfortabel bei Arcor-Digital TV einsteigen: Mehr Happy Ends, mehr Herzschmerz, mehr Fernsehen! Erleben Sie 50 digitale TV Programme und optional 60 Pay TV Sender, einen elektronischen Programmführer mit Movie Star Bewertungen von TV Movie. Außerdem, aktuelle Filmhits und spannende Dokus in der Arcor-Videothek. Infos unter www.arcor.de/tv
Re: [Xenomai-help] Are xmm-registers saved with a (task) context
Quoted 10 lines · M. Koehrer
Hi Gilles,
thanks for your response.
With the MMX registers, you are right. They are actually aliased with the FPU registers. However, the XMM registers (SSE, SSE2) are not aliased.
The aliased MMX registers AND the not-aliased XMM registers are available with today's CPUs, i.e. you still have to take card when using MMX registers.
(All information according to Intel's 64 and IA-32 Architectures
Software Developer's Manual, Volume 1, Chapters 9,10,11)
Quoted 2 lines
From your mail before I assume that the (not-aliased) XMM registers are saved with the switching routine and can be used without have to save/restore them.
Ok. My memories were a bit imprecise. The whole question boils down to know whether the "fxsave" instruction saves the XMM registers. I think it does, but you would probably better check in the documentation.
Signature · 1 line
Gilles
Re: [Xenomai-help] Are xmm-registers saved with a (task) context
Hi Gilles.
Quoted 3 lines
Ok. My memories were a bit imprecise. The whole question boils down to know whether the "fxsave" instruction saves the XMM registers. I think it does, but you would probably better check in the documentation.
Ok, I have looked in the Intel documentation
for the FXSAVE operation:
"Saves the current state of the x87 FPU, MMX technology, XMM, and MXCSR registers to a 512-byte memory location specified in the destination operand."
Thus means, every thing is fine and I can used the XMM registers without risk.
Thanks for the support.
Mathias
Signature · 5 lines
Mathias Koehrer [email protected] Jetzt komfortabel bei Arcor-Digital TV einsteigen: Mehr Happy Ends, mehr Herzschmerz, mehr Fernsehen! Erleben Sie 50 digitale TV Programme und optional 60 Pay TV Sender, einen elektronischen Programmführer mit Movie Star Bewertungen von TV Movie. Außerdem, aktuelle Filmhits und spannende Dokus in der Arcor-Videothek. Infos unter www.arcor.de/tv