AVX Support

Programming, for all ages and all languages.
Post Reply
tsdnz
Member
Member
Posts: 333
Joined: Sun Jun 16, 2013 4:09 am

AVX Support

Post 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
tsdnz
Member
Member
Posts: 333
Joined: Sun Jun 16, 2013 4:09 am

Re: AVX Support

Post by tsdnz »

The instruction causing the exception is vldmxcsr
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: AVX Support

Post 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
tsdnz
Member
Member
Posts: 333
Joined: Sun Jun 16, 2013 4:09 am

Re: AVX Support

Post 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
Post Reply