Giter Club home page Giter Club logo

Comments (32)

xCuri0 avatar xCuri0 commented on May 27, 2024 2

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

from rebaruefi.

xCuri0 avatar xCuri0 commented on May 27, 2024 1

@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

from rebaruefi.

sidex15 avatar sidex15 commented on May 27, 2024

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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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.

from rebaruefi.

ysc3839 avatar ysc3839 commented on May 27, 2024

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?

from rebaruefi.

magicalz avatar magicalz commented on May 27, 2024

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

from rebaruefi.

magicalz avatar magicalz commented on May 27, 2024

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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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

from rebaruefi.

NoUserNameForYou avatar NoUserNameForYou commented on May 27, 2024

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?

from rebaruefi.

xCuri0 avatar xCuri0 commented on May 27, 2024

@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

from rebaruefi.

xCuri0 avatar xCuri0 commented on May 27, 2024

@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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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.

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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

from rebaruefi.

xCuri0 avatar xCuri0 commented on May 27, 2024

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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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.

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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

from rebaruefi.

xCuri0 avatar xCuri0 commented on May 27, 2024

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

from rebaruefi.

BartekJablonski avatar BartekJablonski commented on May 27, 2024

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

from rebaruefi.

 avatar commented on May 27, 2024

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!

from rebaruefi.

CNduan avatar CNduan commented on May 27, 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

from rebaruefi.

xCuri0 avatar xCuri0 commented on May 27, 2024

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

from rebaruefi.

NoUserNameForYou avatar NoUserNameForYou commented on May 27, 2024

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.

from rebaruefi.

 avatar commented on May 27, 2024

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

from rebaruefi.

jakeman2048 avatar jakeman2048 commented on May 27, 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
                        }
                }

from rebaruefi.

Joris-truly avatar Joris-truly commented on May 27, 2024

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

from rebaruefi.

ziddey avatar ziddey commented on May 27, 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 :(

from rebaruefi.

ZLHuo avatar ZLHuo commented on May 27, 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?

from rebaruefi.

xCuri0 avatar xCuri0 commented on May 27, 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

from rebaruefi.

ZLHuo avatar ZLHuo commented on May 27, 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!

from rebaruefi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.