Page 1 of 1

AVX Support

Posted: Thu May 18, 2017 3:25 pm
by tsdnz
Hi, I am adding AVX support to my OS.

Does AVX only work in protected mode?
I get an Invalid Opcode exception
I have setup AVX support and the server has AVX
Under exceptions in the docs it looks like AVX is only supported in Protected Mode.

Anyone else come across this?

Ali

Re: AVX Support

Posted: Thu May 18, 2017 3:29 pm
by tsdnz
The instruction causing the exception is vldmxcsr

Re: AVX Support

Posted: Fri May 19, 2017 9:03 am
by JAAman
Intel volume 2, section LDMXCSR wrote: Note: In VEX-encoded versions, VEX.vvvv is reserved and must be 1111b, otherwise instructions will #UD.
Intel LDMXCSR: Exceptions wrote: #UD If VEX.vvvv ≠ 1111B.
also, Intel manual volume 2, 2.4.5 Exceptions Type 5 includes a table (labeled table 2-22 in my latest edition) gives a list of causes of various causes for exceptions in various modes

in #UD in RMode for type 5 exception-class can be caused by:
-VEX prefix
-legacy SSE instructions if CR0.EM=1 or CR4.OSFXSR=0
-if preceded by lock instruction
-if any corresponding CPUID feature flag is 0

there is nothing in the "ldmxcsr" section that says it only works in PMode

Re: AVX Support

Posted: Fri May 19, 2017 5:29 pm
by tsdnz
Cheers for the reply, it reminded me to have another look.

I had two issues.
  • Forgot to xsetbv to enable the features. AVX, SSE, FPU.
  • Then I forgot to do this for each core, I was only setting this in BSP, which made the other cores crash, and I was only showing BSP on the screen at the time to try to figue this out, which made me think it was BSP exception.
Thanks for your reply.

Ali