ReBarUEFI icon indicating copy to clipboard operation
ReBarUEFI copied to clipboard

Missing 4G decoding on Gigabyte Z97X-Gaming 3

Open BartekJablonski opened this issue 2 years ago • 36 comments

MOBO: Gigabyte Z97X-Gaming 3 BIOS: F8e (not available on GB page, i got it from Support. This bios add TPM 2.0) CPU: Intel Xeon E3-1285L v4 GPU: RX 6900XT CSM disabled, SecureBoot enabled, TPM 2.0 Enabled

Im curious to check if Re-Bar can work on my motherboard using this instruction: https://github.com/xCuri0/ReBarUEFI/wiki/Enabling-hidden-4G-decoding

Im stuck on 4 step. I find 4G Decod using UEFITOOL, extracted body, next i used [IRFExtractor_0.3.6] to save output file. Output file doesn't contain "4G Decod".

I attached original bios file and txt output.

Z97XGAMING3.zip Section_Freeform_subtype_GUID_97E409E6-4CC1-11D9-81F6-000000000000_Setup_Setup_body IFR.txt

BartekJablonski avatar Nov 11 '22 10:11 BartekJablonski

seems like the it is not included in the setup configuration in the bios... and only counted as a Bios String...

sidex15 avatar Nov 12 '22 01:11 sidex15

I checked older bioses. F8d and F7 do not include 4G Decod as a string. F6 have one mention, but still not included in txt output.

BartekJablonski avatar Nov 12 '22 08:11 BartekJablonski

My motherboard is MSI B75A-G43. GPU-Z says above 4G decode is disabled and I found "Above 4G" in step 1 but nothing in step 4. Is this mean there's is no way to make rebar work?

ysc3839 avatar Nov 25 '22 13:11 ysc3839

My Gigabyte B85M-D3H(rev.1.2) has the same issue. "4G Decod" string exist but IRFExtractor can not extract it to txt.

magicalz avatar Dec 21 '22 07:12 magicalz

Update: when I locate the offset in hex-editor which has been found in UEFITool, I can see a string "Above 4G Decoding. Enables or Disables 64bit capable Devices to be Decoded in Above 4G Address Space".

It looks like just a description string but not a configuration.

97E409E6-4CC1-11D9-81F6-000000000000_Setup_Setup_body.zip

4G Decod_offset string_in_hex-editor

BTW, actually the Resizable BAR is working(<= 1G) after I added the FFS module, even if Above 4G decoding is disable. My modded bios: modded_bios_F3_ReBar_patched.zip

reBarEnable

pcibus

magicalz avatar Dec 25 '22 07:12 magicalz

I did the same thing. Added FFS module unlock ReBar <= 1GB without 4G Decoding. image I will try do patch for Broadwell

BartekJablonski avatar Feb 15 '23 11:02 BartekJablonski

Unfortunately, I have not been able to get ReBar to run above 1GB. Nevertheless I have a higher minimum FPS.

BartekJablonski avatar Feb 16 '23 08:02 BartekJablonski

A guy on winraid has added options from strings into his settings

https://winraid.level1techs.com/t/add-option-in-ami-uefi-bios-menu-how-to/31609/15

Perhaps we can do the same for 4g decode?

NoUserNameForYou avatar Mar 04 '23 18:03 NoUserNameForYou

@NoUserNameForYou Can you try this in grub-mod-setup_var

  1. setup_var 0x3 0x0
  2. Reboot
  3. setup_var 0x3 0x1
  4. Reboot and see if you have 4G decode working

Make sure you're running patched BIOS also before doing this. There's also another method directly manipulating PCH and PCI setup variables to enable 4G decoding which we can try if this doesn't work

xCuri0 avatar Mar 06 '23 04:03 xCuri0

@NoUserNameForYou don't really think anything more can be tried other than swapping pcihostbridge or maybe pcibus modules with a similar motherboard that supports 4g decoding.

asm patching is complicated because it would require addition of code which isn't easy

xCuri0 avatar Mar 07 '23 08:03 xCuri0

The Grub mod setup var method did not unlock 4G Decoding. I also discovered a strange bug with Unreal Engine games. When I have ReBar enabled for 1GB, games on UE can only allocate 1GB of VRAM, causing performance to drop dramatically. It affected Sea of Thieves, Contraband Police and Chernobylite, propably every UE4 games. Other engine e.g: Dying Light 2 gain performance and the game can allocate more than 6+GB VRAM, as it should.

EDIT: I did more tests. Other ReBar size for example manual 256MB, 512MB causing 256MB and 512MB max allocation of memory in Unreal Engine games. Im thinking about TOLUD method, to get 2GB BAR, but now im not sure now.

BartekJablonski avatar Mar 18 '23 18:03 BartekJablonski

@BartekJablonski I've seen others report similar issues on Polaris GPUs but didn't know it happened on RDNA too. Also 2GB does have this issue too just that it will happen at 2GB VRAM.

Sucks that AMD doesn't allow for per game rebar like NVIDIA so this issue could be mitigated

xCuri0 avatar Mar 18 '23 18:03 xCuri0

It was a fun adventure to squeeze the last sweat out of that Broadwell. I am glad that I was able to participate in this :)

BartekJablonski avatar Mar 18 '23 18:03 BartekJablonski

@BartekJablonski You mention 256mb causes the issue, but isn't that the default size no rebar ?

xCuri0 avatar Mar 18 '23 18:03 xCuri0

I'll straighten the whole thing out a bit In ReBar 9 and 10 AMD Settings says that ReBar is supported and I can turn it off via drivers. Disabling it will allocate up to 256MB, although GPU-Z will not change the BAR0 and BAR1 values ReBar State: 0 (disabled). AMD Settings: ReBar Unsupported. UE Games can allocate all memory. ReBar State: 8 (256MB). AMD Settings: ReBar Unsupported. UE Games can allocate all memory. ReBar State: 9 (512MB). AMD Settings: ReBar Supported. UE Games can allocate 512MB Only. ReBar State: 10 (1024MB). AMD Settings: ReBar Supported. UE Games can allocate 1024MB Only. Also check out the pics of what it looks like. https://imgur.com/a/Zdr5n52

EDIT: I'm curious about the difference in performance with ReBar 8 and ReBar 0. The difference is in the BAR1 values.

BartekJablonski avatar Mar 18 '23 18:03 BartekJablonski

Source 2 games are also affected to this VRAM allocation bug.

BartekJablonski avatar Mar 27 '23 10:03 BartekJablonski

Unity Engine game are also affected to this VRAM allocation bug, but i find out workaround for this. DXVK fixed it. Contraband Police (Unity Game) had this bug. I tried DXVK and now game can utilize more than 1GB VRAM :p In general, the game itself runs better on DXVK, even without ReBar enabled

BartekJablonski avatar May 07 '23 08:05 BartekJablonski

Yeah, DXVK also fixed allocation bug in Sea of Thieves (UE4 game)

BartekJablonski avatar May 07 '23 17:05 BartekJablonski

@BartekJablonski dxvk often reduces performance tho, we are enabling rebar to get more fps

xCuri0 avatar May 07 '23 18:05 xCuri0

I know that, but it depends on hardware. Obviously im cpu bottlenecked and take f.e Contraband Police. Native DX11 65FPS -> DXVK 85FPS -> DXVK+ReBar 1GB 92FPS Sea of Thieves Native VS DXVK+ReBar 1GB gave very similar results. I wanted to share this finding

BartekJablonski avatar May 07 '23 18:05 BartekJablonski

DSDT.aml.zip Hi Everyone, need some help with DSDT. (my motherboard doesn't have 4G decoding, and would like to attempt with Linux) I am getting errors after doing iasl DSDTMod.dsl, initially it was just a Syntax error, but after I removed ARG0, now I am getting 1 error, but a bunch of warnings and remarks. I'm not sure If I did anything wrong or how about to fixing this. I've attached the files. If anyone can help me or guide me through this is appreciated.

I7-4770 Haswell CPU Asus Z87-A motherboard

Thanks!

ghost avatar Aug 21 '23 12:08 ghost

试试 UEFITool 替换附件中 pcibus模块 我的主板用的是同样技嘉品牌Z97-HD3 2.1 可以打开1G 以上 Bar 这个模块是我从华擎Z97-EXTREME 中已启用 Bar 中提取 这似乎是技嘉主板PCIBUS模块的问题 地址是:https://winraid.level1techs.com/t/request-resizable-bar-added-to-asrock-z97-extreme-6-v2-80a/91036/2 PCIBUS.zip

CNduan avatar Oct 06 '23 01:10 CNduan

@xYuuna go to the lines mentioned and remove Arg0, it says this at the bottom of the DSDT editing wiki page.

xCuri0 avatar Oct 23 '23 15:10 xCuri0

If anyone wants to try a project of getting 4G decoding on these motherboards here's what you have to do

Here are comparisons of BIOS with vs without 4G decoding

Gigabyte B75M-D3H (Good) image

ASRock IMB-180 (Bad) image

You can see the check for 4G decoding DAT_800028e9 == '\x01' on the B75 used to increase the maximum address from 0xffffffff (4GB) to the maximum 64-bit for AllocateMemorySpace (0x20)

Also in the main function you can see the AddMemorySpace (0x18) doesn't add the Above 4GB MMIO region.

Gigabyte B75M-D3H (Good) image

ASRock IMB-180 (Bad), there's an error with the disassembly on 32-bit AddMemorySpace but it doesn't matter.

image

These are the hooks needed, you can find alot of examples on hooking UEFI services.

AddMemorySpace hook

Check if it is type 3 (MMIO) to additionally add another AddMemorySpace call (make sure to use the original function!) which extends from top of memory (end of last type 2 region) to 64GB, there have been issues trying to patch Haswell to use full 512GB so stick to 64GB for now. Here is UEFI memory map which should help understanding this

It should check if the new memory space was already added as the function gets called multiple times, if so it should not add it again.

image

AllocateMemorySpace hook

Check an NVRAM variable which can be configured by user, similar to ReBarState (can also take the CMOS reset protection from ReBarUEFI too) and check if enabled. If so, when type is 3 (MMIO) and maximum address equals 0xffffffff (4GB) change it to 0xffffffffffffffff (maximum UINT64).

This will allocate resources in the 64-bit region added by the previous hook. It needs to be user configurable with NVRAM variable to allow CSM to be disabled in BIOS before.

Last (and easiest) step would be adding the DSDT for it which you can find in the wiki.

@sidex15 @ysc3839 @magicalz @NoUserNameForYou @xYuuna @AbraxasVi @LordAdo96

xCuri0 avatar Oct 23 '23 15:10 xCuri0

I'm too much of a brainlet to make any sense out of this but thank you for your discoveries.

BTW, sorry I had to delete my discord account.

NoUserNameForYou avatar Oct 27 '23 17:10 NoUserNameForYou

@xCuri0 thanks for that write up, really appreciate you taking the time. Though this is way beyond my level, I don't even know where to begin. Hopefully someone with more expertise tries this and figures out an easier way to patch/add this :)

ghost avatar Oct 31 '23 20:10 ghost

@xCuri0 :) MOBO: Gigabyte Z97X-UD5H-BK BIOS: F8 CPU: Intel i5-4670K GPU: Intel A380

I'm also unable to find the 4G Decode option with UEFITool. The stock DSDT seems to account for 4G Decoding, but when I bypass that M64L conditional I get the expanded root bus in the OS, but anything above 1G resizebar won't POST. I'm guessing that M64L bit needs to be actually toggled somehow, instead of bypassed in order for the PCIBus to work? Either that or find/hack together a PCIBus module?

Stock DSDT section:

                If ((Local1 >= 0x07D9))
                {
                    If ((M64L == Zero))
                    {
                        CreateDWordField (BUF0, \_SB.PCI0._Y1E._LEN, MSLN)  // _LEN: Length
                        MSLN = Zero
                    }
                    Else
                    {
                        CreateQWordField (BUF0, \_SB.PCI0._Y1E._LEN, M2LN)  // _LEN: Length
                        CreateQWordField (BUF0, \_SB.PCI0._Y1E._MIN, M2MN)  // _MIN: Minimum Base Address
                        CreateQWordField (BUF0, \_SB.PCI0._Y1E._MAX, M2MX)  // _MAX: Maximum Base Address
                        M2LN = M64L /* External reference */
                        M2MN = M64B /* External reference */
                        M2MX = ((M2MN + M2LN) - One)
                    }
                }

My attempt at bypassing:

               If ((Local1 >= 0x07D9))
                {
                        CreateQWordField (BUF0, \_SB.PCI0._Y1E._LEN, M2LN)  // _LEN: Length
                        CreateQWordField (BUF0, \_SB.PCI0._Y1E._MIN, M2MN)  // _MIN: Minimum Base Address
                        CreateQWordField (BUF0, \_SB.PCI0._Y1E._MAX, M2MX)  // _MAX: Maximum Base Address

                        // 39-bit for Haswell and up
                        M2MX = 0x8000000000 - One
                        If ((TUUD >= 0x1000))
                        {
                            M2MN = (TUUD << 0x14)
                        }
                        Else
                        {
                            M2MN = 0x100000000
                        }
                }

jakeman2048 avatar Mar 03 '24 20:03 jakeman2048

MOBO: GA-X99-Gaming 5 BIOS F23c CPU: Intel i7-5930K GPU: RTX 3070

Same issue, stuck on finding the '4G Decod in txt' step. I appreciate the support and write-up above, @xCuri0, but it's a bit too impenetrably written for non-programmers. I'm unsure where to start :)

I've added my extracted text. Perhaps it could serve as an example of how to trace the '4g decod' flag?

Section_PE32_image_Setup_Setup_body.efi.0.0.en-US.ifr.txt

Joris-truly avatar Mar 24 '24 14:03 Joris-truly

@jakeman2048 aren't you then missing M2LN = ((M2MX - M2MN) + One)

Also, after removing the stray Arg0, I still can't compile:

PS D:\Work> D:\Programs\iasl.exe -ve .\DSDT.dsl

Intel ACPI Component Architecture
ASL+ Optimizing Compiler/Disassembler version 20230628
Copyright (c) 2000 - 2023 Intel Corporation

./DSDT.dsl   9112:         Device (SDMA)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

./DSDT.dsl   9161:         Device (I2C0)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

./DSDT.dsl   9282:         Device (I2C1)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

./DSDT.dsl   9400:         Device (SPI0)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

./DSDT.dsl   9481:         Device (SPI1)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

./DSDT.dsl   9574:         Device (UA00)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

./DSDT.dsl   9655:         Device (UA01)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

./DSDT.dsl   9748:         Device (SDHC)
Error    6141 -   Missing dependency ^  (Device object requires a _HID or _ADR)

ASL Input:     ./DSDT.dsl -  596415 bytes   7624 keywords      0 source lines

Compilation failed. 8 Errors, 134 Warnings, 169 Remarks
No AML files were generated due to compiler error(s)

Is it safe to force with -f? Or should I be doing something with these:

Scope (_SB.PCI0)
{
    Device (SDMA)
    {
    }
}

Since I'm using a 4gb rx480, I was hoping reducing tolud would be enough for 2gb rebar. I have tolud set to 1gb (minimum option), but still no post :(

ziddey avatar Apr 02 '24 20:04 ziddey

试试 UEFITool 替换附件中 pcibus模块 我的主板用的是同样技嘉品牌Z97-HD3 2.1 可以打开1G 以上 Bar 这个模块是我从华擎Z97-EXTREME 中已启用 Bar 中提取 这似乎是技嘉主板PCIBUS模块的问题 地址是:https://winraid.level1techs.com/t/request-resizable-bar-added-to-asrock-z97-extreme-6-v2-80a/91036/2 PCIBUS.zip

I've attempted to replace the pcibus module in the Z97-HD3 firmware; however, I'm still unable to set BAR larger than 1G. Could you provide a more detailed explanation on how to successfully implement this?

ZLHuo avatar May 02 '24 15:05 ZLHuo