intel / gvt-linux

Other
509 stars 95 forks source link

Motherboards with configurable aperture size or settable via EFI Shell script #131

Open eurodomenii opened 4 years ago

eurodomenii commented 4 years ago

The aperture size is very relevant for IGVT

Quoting from https://github.com/intel/gvt-linux/issues/6#issuecomment-353817255

Host always occupy 128MB aperture size. And each vgpu with vgpu type4 will occupy 128MB aperture size (you can reference to chapter 5.1) If your machine only with 256MB aperture size, you only can create one vgpu with vgpu type4. You can check your machine totally aperture size by “lspci –vv –s 0:00:02” For example, my machine aperture is configured to 1G. Region 2: Memory at 80000000 (64-bit, prefetchable) [size=1G]

Not to be confused with In BIOS the option named "aperture size" but not "Intel DVMT". https://github.com/intel/gvt-linux/issues/107#issuecomment-498549927

There are very few motherboards that allow, out of the box, an interface to configure aperture size

1) https://github.com/intel/gvt-linux/issues/107#issuecomment-499399922 “We have tried the(SUPERMICRO)C7Z370-CG-IW motherboard which is support modify aperture size.”

2) Gigabyte z390D http://download.gigabyte.eu/FileList/Manual/mb_manual_z390-d_e.pdf Options are: 128MB, 256MB, 512MB, 1024MB, and 2048MB.

One attractive choice would be C9Z390-CGW, but according to https://www.amazon.com/Supermicro-MBD-C9Z390-CGW-Motherboard-Intel-DisplayPort/dp/B07JHLQY8G review , there are issues with EFI Linux booting “Also I noticed weeks later that no Linux would boot which CSM disabled (I tried all kinds of distributions - Kernel Panic "Not all CPUs entered broadcast exception handler").”

Fortunately, analyzing the BIOS files from official motherboard website, it’s a nice surprise that most motherboards support larger values of aperture size, but the default is 256MB and isn’t configurable from interface.

Applying the know-how via https://www.win-raid.com/t5693f13-Determine-configurable-aperture-size-from-BIOS-file.html, the following motherboards have the values ( non configurable) -https://www.asus.com/Motherboards/ROG-STRIX-Z390-E-GAMING/ -https://www.gigabyte.com/Motherboard/Z390-DESIGNARE-rev-10 -https://www.msi.com/Motherboard/MAG-Z390M-MORTAR

0x590AE One Of: Aperture Size, VarStoreInfo (VarOffset/VarName): 0x968, VarStore: 0x1, QuestionId: 0x2746, Size: 1, Min: 0x0, Max 0xF, Step: 0x0 {05 91 BF 0B C0 0B 46 27 01 00 68 09 14 10 00 0F 00} 0x590BF One Of Option: 128MB, Value (8 bit): 0x0 {09 07 C1 0B 00 00 00} 0x590C6 One Of Option: 256MB, Value (8 bit): 0x1 (default) {09 07 C2 0B 30 00 01} 0x590CD One Of Option: 512MB, Value (8 bit): 0x3 {09 07 C3 0B 00 00 03} 0x590D4 One Of Option: 1024MB, Value (8 bit): 0x7 {09 07 C4 0B 00 00 07} 0x590DB One Of Option: 2048MB, Value (8 bit): 0xF {09 07 C5 0B 00 00 0F} 0x590E2 End One Of {29 02}

But, modifying BIOS, could be challenging ( see full history of https://www.win-raid.com/t5693f13-Determine-configurable-aperture-size-from-BIOS-file.html ) .

The post https://www.win-raid.com/t2281f16-Add-option-in-AMI-UEFI-bios-menu-how-to.html#msg45335, suggests another approach “Everything is possible with enough dedication, but it's much easier to write a script for EFI shell to switch that setting than modify BIOS Setup. “

Such a script could be useful for a wide range of users. Any idea how to implement this for latest Ubuntu/Debian?

Thanks!

cosmicdan commented 4 years ago

Hey there,

I was successful in modifying the hidden aperture size setting in my MSI Z370 SLI Plus motherboard with this customized GRUB: https://github.com/datasone/grub-mod-setup_var

You can chainload this .efi via your existing GRUB, then do e.g. this command to set an aperture of 2GB on your system (using the VarOffset you provided, which is BIOS or M/B specific):

setup_var2 0x968 0xF

...this change is written to nvram immediately, but I recommend following that command with a reboot.

I've not looked into any automated way of doing this, since it rarely needs to be done (like a BIOS reflash or CMOS clear - but CMOS clear may not be a problem if your have config preset slots in your UEFI setup).

Good luck!

gbdrbob commented 4 years ago

The instructions on the win-raid forums are spread out over quite a long thread, there are more concise, yet detailed, instructions on how to modify a hidden bios setting in the Opencore documentation. The opencore people are interested in changing a different setting (CFG Lock) just substitute "Aperture" for every instance of "CFG Lock" in the instructions, the process is the same.

For example, following the instructions from opencore, I found this entry in the file created by running ifrextract on my bios setup.bin:

0x3A140 One Of: Aperture Size, VarStoreInfo (VarOffset/VarName): 0x2B9, VarStore: 0x1, QuestionId: 0x2759, Size: 1, Min: 0x0, Max 0x1F, Step: 0x0 {05 91 AC 07 AD 07 59 27 01 00 B9 02 14 10 00 1F 00} 0x3A151 One Of Option: 128MB, Value (8 bit): 0x0 {09 07 AE 07 00 00 00} 0x3A158 One Of Option: 256MB, Value (8 bit): 0x1 (default) {09 07 AF 07 30 00 01} 0x3A15F One Of Option: 512MB, Value (8 bit): 0x3 {09 07 B0 07 00 00 03} 0x3A166 One Of Option: 1024MB, Value (8 bit): 0x7 {09 07 B1 07 00 00 07} 0x3A16D One Of Option: 2048MB, Value (8 bit): 0xF {09 07 B2 07 00 00 0F} 0x3A174 One Of Option: 4096MB, Value (8 bit): 0x1F {09 07 B3 07 00 00 1F} 0x3A17B End One Of {29 02}

So to increase the aperture on my board to 1024MB I issued the following command in the modified grub UEFI shell:

setup_var 0x2B9 0x7

edit: fixed link to open core doc

presslab-us commented 4 years ago

I was able to increase my ASRock H410M-itx/ac aperture size from the default of 256MB to 512MB. If I tried to go higher the board would not POST.

I needed to use the grub_setup_var located here: https://github.com/XDleader555/grub_setup_var

And with UEFI v1.20 the command for 512MB is setup_var SaSetup 0xAF 0x3

kvn1351 commented 3 years ago

I ended up here as I was researching why on earth my Proxmox machine didn't let me assign more than 2 5_4 GVT-g mdevs. I opened a Thread about it here https://forum.proxmox.com/threads/intel-gvt-g-cant-assign-more-than-one-5_4-mdev.87250/.

The staff member mentioned video memory, so I ended up here. Having thinkered a lot with hackintoshes, I first thought he meant the DMVT allocation size, also because it was the only setting related to video memory in my bios. It turned out that it was hidden of course... God I hate the industry sometimes.

The default was set to only 256M

root@prox:~# lspci -vv -s 00:02.0
        (...)
        Region 2: Memory at 90000000 (64-bit, prefetchable) [size=256M]

So for the ASUS PRIME B460-PLUS (with an i10400) on BIOS Version 1603, here's how to fix it (tools and docs):

Place the modified grub.efi on a FAT32 formatted USB under /EFI/BOOT/ and rename it to bootx64.efi. Boot it up in UEFI mode.

The command I ended up using was: GRUB: setup_var_cv SaSetup 0x44 0x1 0x7

0xF, although it should be accepted, doesn't Post just as others have mentioned. Thus 1GB is the maximum I suppose.

By the way, I had to perform a CMOS reset as there was no display output with 0xF.

I hope this will help someone.

Update 2024 (things have improved a lot):

ljurgs commented 1 year ago

I also had an issue where I could only have 1x 5_4 OR 2x 5_8 GVT-g mdevs and 256M was the default on an ASUS W480 ACE with a W-1270 Xeon. I used the https://github.com/datasone/setup_var.efi UEFI executable. The following was extracted from the latest BIOS:

OneOf Prompt: "Aperture Size", Help: "Select the Aperture Size
Note : Above 4GB MMIO BIOS assignment is automatically enabled when selecting 2048MB aperture. To use this feature, please disable CSM Support.", QuestionFlags: 0x14, QuestionId: 0x2756, VarStoreId: 0x16, VarOffset: 0x44, Flags: 0x10, Size: 8, Min: 0x0, Max: 0xF, Step: 0x0
  OneOfOption Option: "128MB" Value: 0
  OneOfOption Option: "256MB" Value: 1, Default, MfgDefault
  OneOfOption Option: "512MB" Value: 3
  OneOfOption Option: "1024MB" Value: 7
  OneOfOption Option: "2048MB" Value: 15
End 

The corresponding VarStore was:

VarStore Guid: 72C5E28C-7783-43A1-8767-FAD73FCCAFA4, VarStoreId: 0x16, Size: 0x502, Name: "SaSetup"

It lists up to 0xF (2GB) however anything higher than 0x3 (512MB) would prevent the system from POSTing and I was forced to remove the CMOS battery and try again.

The successful command in my case was:

.\setup_var.efi 0x44 0x3 -n SaSetup
kakosmakos commented 3 months ago

The command I ended up using was: GRUB: setup_var_cv SaSetup 0x44 0x1 0x7

Hello. Could you tell me how to find out these values for the motherboard? I’ve looked at your links, downloaded UEFITool, ran it on my computer, but it doesn’t respond to commands and doesn’t create a bios dump. Maybe there are links to instructions on how to use these tools? Google didn’t help me, or I searched poorly.

kvn1351 commented 1 month ago

The command I ended up using was: GRUB: setup_var_cv SaSetup 0x44 0x1 0x7

Hello. Could you tell me how to find out these values for the motherboard? I’ve looked at your links, downloaded UEFITool, ran it on my computer, but it doesn’t respond to commands and doesn’t create a bios dump. Maybe there are links to instructions on how to use these tools? Google didn’t help me, or I searched poorly.

I've posted an update above.