This is a record for my own passthrough setup, I can finally use a single laptop for windows gaming and linux programming at the same time.
My G14 is GA402RJ(6800HS + 6700s) with MT7922 WiFi/BT card.
At this time, BIOS version is 309.
TLDR: see next section
You need sufficient knowledge about UEFI, QEMU, PCIe, linux. You need a working linux system for this setup (linux will be the host).
Resizable BAR/SAM is not supported in passed-through windows guest yet (confirmed that in my RX460D and 5700xt machine). The first thing is to disable it in bios. Obviously, G14's bios is typical "laptop" bios that no advanced options shown in the menu.
So let's try a little hack to do this. First, get a bios from asus site, unzip it and find it's a UEFI capsule (good job asus).
Use UEFITool to extract it and search keyword 'Resize', then find it is located in PciDynamicSetup
Then extract that efi file and use Universal-IFR-Extractor or IFRExtractor-RS to scan it, then we found
0x8A64 Form Set: PCI Subsystem Settings [ACA9F304-21E2-4852-9875-7FF4881D67A5], ClassGuid0 [93039971-8545-4B04-B45E-32EB8326040E] {0E A7 04 F3 A9 AC E2 21 52 48 98 75 7F F4 88 1D 67 A5 06 00 02 00 01 71 99 03 93 45 85 04 4B B4 5E 32 EB 83 26 04 0E}
0x8A8B Guid: [0F0B1735-87A0-4193-B266-538C38AF48CE] {5F 15 35 17 0B 0F A0 87 93 41 B2 66 53 8C 38 AF 48 CE 03 88 00}
0x8AA0 Guid: [0F0B1735-87A0-4193-B266-538C38AF48CE] {5F 15 35 17 0B 0F A0 87 93 41 B2 66 53 8C 38 AF 48 CE 04 00 00}
0x8AB5 Default Store: , DefaultId: 0x0 {5C 06 00 00 00 00}
0x8ABB Default Store: , DefaultId: 0x1 {5C 06 00 00 01 00}
0x8AC1 VarStore: VarStoreId: 0xCCCC [ACA9F304-21E2-4852-9875-7FF4881D67A5], Size: 0x8, Name: PCI_COMMON {24 21 04 F3 A9 AC E2 21 52 48 98 75 7F F4 88 1D 67 A5 CC CC 08 00 50 43 49 5F 43 4F 4D 4D 4F 4E 00}
0x8AE2 Form: PCI Subsystem Settings, FormId: 0x1 {01 86 01 00 06 00}
0x8AE8 Subtitle: Statement.Prompt: 00.00, Flags: 0x0 {02 87 40 00 00 00 00}
0x8AEF End {29 02}
0x8AF1 Subtitle: Statement.Prompt: , Flags: 0x0 {02 87 02 00 00 00 00}
0x8AF8 End {29 02}
0x8AFA Subtitle: Statement.Prompt: PCI Settings Common for all Devices:, Flags: 0x0 {02 87 07 00 00 00 00}
0x8B01 End {29 02}
0x8B03 Suppress If {0A 82}
0x8B05 64 Bit Unsigned Int: 0x1 {45 8A 01 00 00 00 00 00 00 00}
0x8B0F 64 Bit Unsigned Int: 0x0 {45 0A 00 00 00 00 00 00 00 00}
0x8B19 Equal {2F 02}
0x8B1B End {29 02}
0x8B1D Checkbox: Above 4G Decoding, VarStoreInfo (VarOffset/VarName): 0x3, VarStore: 0xCCCC, QuestionId: 0x7006 {06 8E 0C 00 0D 00 06 70 CC CC 03 00 10 00}
0x8B2B Default: DefaultId: 0x0, Value (8 bit): 0x1 {5B 06 00 00 00 01}
0x8B31 End {29 02}
0x8B33 End If {29 02}
0x8B35 Checkbox: Re-Size BAR Support, VarStoreInfo (VarOffset/VarName): 0x4, VarStore: 0xCCCC, QuestionId: 0x702B {06 8E 10 00 11 00 2B 70 CC CC 04 00 10 00}
0x8B43 Default: DefaultId: 0x0, Value (8 bit): 0x1 {5B 06 00 00 00 01}
0x8B49 End {29 02}
0x8B4B Suppress If {0A 82}
0x8B4D 64 Bit Unsigned Int: 0x1 {45 8A 01 00 00 00 00 00 00 00}
0x8B57 64 Bit Unsigned Int: 0x0 {45 0A 00 00 00 00 00 00 00 00}
0x8B61 Equal {2F 02}
0x8B63 End {29 02}
0x8B65 Checkbox: SR-IOV Support, VarStoreInfo (VarOffset/VarName): 0x5, VarStore: 0xCCCC, QuestionId: 0x7007 {06 8E 12 00 13 00 07 70 CC CC 05 00 10 00}
0x8B73 Default: DefaultId: 0x0, Value (8 bit): 0x0 {5B 06 00 00 00 00}
0x8B79 End {29 02}
0x8B7B End If {29 02}
...
This option is located at PCI_COMMON
store offset 0x4.
This will disable Resizeable BAR, and harm a little performance at real machine Windows (I can't tell the difference).
If not doing this, guest windows amd driver will give you a code 43, linux is not affected.
This may BRICK your device, at your own risk!
Use grub-mod-setup_var to modify it:
# disable Resizable BAR
setup_var_cv PCI_COMMON 0x4 0x1 0x0
# optional you can enable sriov also
setup_var_cv PCI_COMMON 0x5 0x1 0x1
Not sure which version of kernel is minimal for this setup, but for my case, it's 5.17.1-arch1-1
My kernel args is root=UUID=someuuid rw vsyscall=emulate iommu=pt pci=nommconf
, only iommu=pt
matters.
modprobe.d configs is decribed in files: etc_modprobe.d_kvm.conf at /etc/modprobe.d/kvm.conf, etc_modprobe.d_vfio.conf at /etc/modprobe.d/vfio.conf (filename does not matter, you can name it any.conf)
Then regenerate your initcpio/initramdisk:
# for arch with mkinitcpio:
sudo mkinitcpio -P
Reboot system with newly generated initcpio, then
sudo ./hugepages.sh
sudo ./net.sh
./start.sh
Your VM should work fine.
@Hyphone Just use it as you like. But in fact, I applied refunding for my ga402rj, I will sell it if they reject refunding and will never buy asus laptops. My laptop have returned two times, the first time the main board is broken, second time screen or gpu is broken, the last time is keyboard, I just got tired of returning. So I may not be able to contribute other things in the asus-linux project.