Page 1 of 1

How to enable AVX in a UEFI application?

Posted: Sun Feb 04, 2018 9:56 pm
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?

Re: How to enable AVX in a UEFI application?

Posted: Sun Feb 04, 2018 10:11 pm
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

Re: How to enable AVX in a UEFI application?

Posted: Sun Feb 04, 2018 10:48 pm
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>