Page 1 of 1

Enable AVX and AVX2 instruction sets on Ubuntu

Posted: 24. Aug 2022, 09:26
by marko_m
Hi,

I'm trying to enable AVX and AVX2 instruction sets on Ubuntu 22.04 guest, Windows host.

I can't see avx or avx2 when I run

Code: Select all

grep avx /proc/cpuinfo
on the guest.

I have tried to enable AVX and AVX2 instruction sets with:

Code: Select all

VBoxManage setextradata "guest_name" VBoxInternal/CPUM/IsaExts/AVX 1
VBoxManage setextradata "guest_name" VBoxInternal/CPUM/IsaExts/AVX2 1
I also have read that Hyper-V and AVX are mutually exclusive in Windows, so I tried to disable Hyper-V on Windows: control panel -> programs and features -> turn windows features on or off -> unchecked Hyper-V. Then opened services.msc and stopped and disabled "HV Host Service". Then rebooted.

I have not disabled virtualization in BIOS, because I can't access it (this is a work laptop with BitLocker).

Hyper-V still seems to be enabled, because I can still see these entries in the log:
00:00:01.021895 NEM: WHvCapabilityCodeHypervisorPresent is TRUE, so this might work...
...
00:00:01.023706 NEM: Disable Hyper-V if you need X2APIC for your guests!
...
00:00:01.069075 CPUM: SetGuestCpuIdFeature: Enabled Hypervisor Present bit
...
00:00:02.072380 HTT - Hyper-Threading Technology = 1 (1)
...
00:00:02.072410 HVP - Hypervisor Present (we're a guest) = 1 (1)
...
00:00:02.072511 Raw Hypervisor CPUID Leaves
00:00:02.072512 Leaf/sub-leaf eax ebx ecx edx
00:00:02.072513 Gst: 40000000/0000 40000001 4b4d564b 564b4d56 0000004d
00:00:02.072514 Hst: 4000000b 7263694d 666f736f 76482074
00:00:02.072516 Gst: 40000001/0000 01000089 00000000 00000000 00000000
00:00:02.072517 Hst: 31237648 00000000 00000000 00000000
...
And the log entries concerning AVX seem to indicate that that extradata is set ok, but AVX instruction sets are still not enabled (on the guest):
00:00:00.917638 Extradata overrides:
00:00:00.917647 VBoxInternal/CPUM/IsaExts/AVX="1"
00:00:00.917679 VBoxInternal/CPUM/IsaExts/AVX2="1"
...
00:00:00.918005 [/CPUM/IsaExts/] (level 2)
00:00:00.918006 AVX <integer> = 0x0000000000000001 (1)
00:00:00.918006 AVX2 <integer> = 0x0000000000000001 (1)
...
00:00:02.072407 AVX - AVX support = 0 (1)
...
00:00:02.072416 AVX2 - Advanced Vector Extensions 2 = 0 (1)
Any tips on disabling HTT and enabling AVX on my virtual machine?

Re: Enable AVX and AVX2 instruction sets on Ubuntu

Posted: 24. Aug 2022, 14:01
by scottgus1
No ideas here about AVX/2, but see this about disabling Hyper-V: HMR3Init: Attempting fall back to NEM (Hyper-V is active)

Re: Enable AVX and AVX2 instruction sets on Ubuntu

Posted: 25. Aug 2022, 07:09
by marko_m
Thank you, scottgus1,

I had already seen this page... And I forgot from my original question that I had issued the command:

Code: Select all

bcdedit /set {current} hypervisorlaunchtype off
When I run command

Code: Select all

bcdedit
I can see the line:
hypervisorlaunchtype Off
I have also checked from Windows features that none of these services are installed (these have been reported to cause issues):

any *guard
Containers
Hyper-V
Virtual machine platform
Windows hypervisor platform
Windows sandbox
Windows subsystem for Linux

Memory integrity from Core isolation in Windows Security is disabled (also reported to cause issues).

I have tested these switches for VBoxManage, too (although I don't really know what they are):

Code: Select all

VBoxManage.exe modifyvm guest_name --paravirtprovider none --hwvirtex off --nested-hw-virt off
I also tried to set CPUID manually by issuing command:

Code: Select all

VBoxManage.exe modifyvm guest_name --cpuidset 1 000806ec 01100800 fedaf387 bfebfbff
but this doesn't do anything either. The CPUID does not change.

Re: Enable AVX and AVX2 instruction sets on Ubuntu

Posted: 26. Aug 2022, 13:18
by scottgus1
marko_m wrote:I had already seen this page
Good! Is the green turtle gone? No green turtle is the deciding factor for Virtualbox, to say if Hyper-V is truly disabled.
marko_m wrote:I have tested these switches for VBoxManage, too (although I don't really know what they are):
This sort of random modification is called thrashing, and it often breaks more than it fixes. Paravirtualization helps the VM OS run in a VM better, so does hwvirtex, so turn those back on. nested-hw-virt only comes into play if you're running another hypervisor in the VM, also called nested virtualization. No idea how much changing these broke the VM; it may be time to start over with a new VM.

After you confirm fixing the above, please Start the VM from full normal shutdown, not save-state. Run until you see the problem happen, then shut down the VM from within the VM's OS if possible. If not possible, close the Virtualbox window for the VM with the Power Off option set.

Right-click the VM in the main Virtualbox window's VM list, choose Show Log. Save the far left tab's log, zip it, and post the zip file, using the forum's Upload Attachment tab.