How to enable AVX in a UEFI application?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
poby
Posts: 24
Joined: Wed Sep 21, 2016 9:39 am

How to enable AVX in a UEFI application?

Post by poby »

I have a simple working UEFI application except avx instructions don't work. Host supports AVX and I'm using the latest version of virtualbox which supports avx and the following works (doesn't hang)

Code: Select all

movdqa    xmm0, dqword[testmem]
testmem is defined elsewhere as

Code: Select all

align 32
testmem:   rb   128
However the following causes the program to hang up, and not proceed.

Code: Select all

vmovdqa    ymm0, qqword[testmem]
I have tried enabling AVX with

Code: Select all

mov     rcx, 0
xgetbv
or      rax, 0007h
xsetbv 
But it doesn't help.

What am I missing?
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: How to enable AVX in a UEFI application?

Post by BrightLight »

I enable AVX this way.

Code: Select all

	; enable AVX
	mov rax, cr4
	or eax, 0x40000
	mov cr4, rax

	mov rcx, 0
	xgetbv

	or eax, 6
	mov rcx, 0
	xsetbv
You know your OS is advanced when you stop using the Intel programming guide as a reference.
poby
Posts: 24
Joined: Wed Sep 21, 2016 9:39 am

Re: How to enable AVX in a UEFI application?

Post by poby »

omarrx024 wrote:I enable AVX this way.

Code: Select all

	; enable AVX
	mov rax, cr4
	or eax, 0x40000
	mov cr4, rax

	mov rcx, 0
	xgetbv

	or eax, 6
	mov rcx, 0
	xsetbv
THANK YOU SOOOO MUCH!!! I've spent hours googling and reading intel manuals etc and your code just works! Awesome man!

=D> =D> =D> =D>
Post Reply