Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing 4G decoding on Gigabyte Z97X-Gaming 3 #14

Open
BartekJablonski opened this issue Nov 11, 2022 · 36 comments
Open

Missing 4G decoding on Gigabyte Z97X-Gaming 3 #14

BartekJablonski opened this issue Nov 11, 2022 · 36 comments
Labels
bios issue with firmware that needs patching help wanted Extra attention is needed

Comments

@BartekJablonski
Copy link

BartekJablonski commented Nov 11, 2022

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

@xCuri0 xCuri0 added the help wanted Extra attention is needed label Nov 11, 2022
@sidex15
Copy link

sidex15 commented Nov 12, 2022

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

@BartekJablonski
Copy link
Author

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.

@ysc3839
Copy link

ysc3839 commented Nov 25, 2022

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?

@magicalz
Copy link

magicalz commented Dec 21, 2022

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

@magicalz
Copy link

magicalz commented Dec 25, 2022

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

@BartekJablonski
Copy link
Author

BartekJablonski commented Feb 15, 2023

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

@BartekJablonski
Copy link
Author

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

@NoUserNameForYou
Copy link

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?

@xCuri0
Copy link
Owner

xCuri0 commented Mar 6, 2023

@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
Copy link
Owner

xCuri0 commented Mar 7, 2023

@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

@BartekJablonski
Copy link
Author

BartekJablonski commented Mar 18, 2023

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.

@xCuri0
Copy link
Owner

xCuri0 commented Mar 18, 2023

@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

@BartekJablonski
Copy link
Author

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 :)

@xCuri0
Copy link
Owner

xCuri0 commented Mar 18, 2023

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

@BartekJablonski
Copy link
Author

BartekJablonski commented Mar 18, 2023

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
Copy link
Author

BartekJablonski commented Mar 27, 2023

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

@BartekJablonski
Copy link
Author

BartekJablonski commented May 7, 2023

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
Copy link
Author

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

@xCuri0
Copy link
Owner

xCuri0 commented May 7, 2023

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

@BartekJablonski
Copy link
Author

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

@ghost
Copy link

ghost commented Aug 21, 2023

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!

@CNduan
Copy link

CNduan commented Oct 6, 2023

试试 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

@xCuri0
Copy link
Owner

xCuri0 commented Oct 23, 2023

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

@xCuri0
Copy link
Owner

xCuri0 commented Oct 23, 2023

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

@NoUserNameForYou
Copy link

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.

@ghost
Copy link

ghost commented Oct 31, 2023

@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 :)

@xCuri0 xCuri0 added the bios issue with firmware that needs patching label Dec 3, 2023
@xCuri0 xCuri0 changed the title Gigabyte Z97X-Gaming 3 hidden 4G Decoding Missing 4G decoding on Gigabyte Z97X-Gaming 3 Feb 8, 2024
@jakeman2048
Copy link

jakeman2048 commented Mar 3, 2024

@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
                        }
                }

@Joris-truly
Copy link

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

@ziddey
Copy link

ziddey commented Apr 2, 2024

@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 :(

@ZLHuo
Copy link

ZLHuo commented May 2, 2024

试试 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?

@xCuri0
Copy link
Owner

xCuri0 commented May 2, 2024

@ZLHuo there a bunch of other modules too not just pcibus

i think pcihostbridge and some sa related module.

i dont think it will be easy to implement tbh

@ZLHuo
Copy link

ZLHuo commented May 2, 2024

@xCuri0
I understand, there's a lot of work to be done.
Achieving a BAR size of 1 GB is truly satisfying. Thank you for your exceptional project!

@SaulGoodman1337
Copy link

@ZLHuo there a bunch of other modules too not just pcibus

i think pcihostbridge and some sa related module.

i dont think it will be easy to implement tbh

Hi,
I have a GA-Z97N-Gaming 5 here that I would like to use. I can't quite get my head around the patching here yet.
Can you tell me roughly whether it works with my board? I was able to add the module to the bios, but I've already failed with the 4G.
I can't find anything with UEFITool. Will DSDT patching help me here?
I am not planning to use windows, only Linux.

@xCuri0
Copy link
Owner

xCuri0 commented May 14, 2024

if you're using linux you don't need to even flash rebardxe, there's a linux section on dsdt patching wiki just follow that

@ivan49k
Copy link

ivan49k commented Jun 1, 2024

@xCuri0 Can you tell me about method directly manipulating PCH and PCI setup variables to enable 4G decoding?

@xCuri0
Copy link
Owner

xCuri0 commented Jun 1, 2024

@ivan49k someone tried and it doesn't work, the uefi has been built without the code for 4g decoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bios issue with firmware that needs patching help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests