[Experimental] Resizable BAR DXE driver

I’ve created this DXE driver to enable Resizable BAR on any supported system (PCIe 3.0 with 4G decoding). It works by hooking a function (PreprocessController) that the PciBus driver calls and setting up Resizable BAR to the user specified size if it’s supported.

You can download it here https://github.com/xCuri0/ReBarUEFI/releases. You must have 4G decoding enabled before enabling the driver with ReBarState. Use UEFITool (not NE) to insert the module at the end of the DXE driver section.

It’s configured through setting the ReBarState variable you can find a program to set it here. For Linux you can build ReBarState from source with CMake.

Please read the README on Github before replying to this thread

6 Likes

@Kuri0 Nice work! Though I am missing some things.
Are you really seeing performance improvement? Since even with lastest supported hardware you don’t always see improvement.
Second, I think your GPU isn’t supported so how you benefit from that?

@Blizz I can’t test performance on my motherboard since there isn’t enough PCI MMIOH resources for 8GB BAR I can only do 512mb (still higher than 256mb). It is possible to modify the BIOS (PciHostBridge module + DSDT) for more PCI MMIOH resources and I know where to but don’t have the assembly knowledge required.

RX 580 actually does support Resizable BAR if you use it with Nimez driver or Linux.

Would be better to see a performance test on a more recent CPU such as 7700k along with a recent AMD GPU (Nvidia 3000 should work too but less gains).

Tested with ASUS Z170 M8I and RTX 3090, seems not work.
Ffs inserted, bios flashed, above 4g enabled, the nvar value entered(16 is max, then get black screen until bios flash). And latest vBIOS which confirm support reBar.
Device manager still do not show Large Memory Range.

For me when I enter 9 (512mb) Windows shows the following message and I see Resizable BAR size changed

From what you’ve written it looks like a compatibility issue with the way Nvidia cards provide the ReBar sizes. All sizes above 15(32GB) which I think 3090 uses should behave the same. If possible send a screenshot of HWInfo like the one I posted.

I could later send a testing build to be run in EFI shell which just reads the sizes to see if there’s any issue there.

Here is testing build which just prints supported sizes post the output of what it says. Run it in EFI Shell with “load -nc ReBarTest.efi”
ReBarTest.zip (4.6 KB)

This is what it shows on my system (i renamed to ReBarTester but that doesn’t matter)



7 and 9 works, 10 or higher result black screen.
so it works, but bar size isn’t enough.

Looks like you have the same artificial MMIOH limitation issue as me. Fix is editing Dsdt and PciHostBridge to remove the limitation.

Send a screenshot of Device Manager Resources by Type like this. You can see I have only 16GB here which isn’t enough you likely have the same problem.

If you can send me your DSDT extracted from BIOS (not from when OS running) and I’ll show the modifications needed. Other modification needed is to PciHostBridge to allow more MMIOH space which you can do in Ghidra diassembler.

I didn’t try these modifications on my system since I don’t have a BIOS clip yet and editing DSDT is hard on this BIOS (you have to use a tool which modifies AmiBoardInfo assembly)

other problem I see is that Memory Base Address 1 is at 0xA0000000 which isn’t a 64 bit address (above 0xFFFFFFFF). It looks like 4G decoding is disabled because enabling it should make the GPU have a 64 bit address like you can see in my screenshot where it is 0x5C0000000.

Device Manager Resources by Type:
unknown
DSDT of M8I:
DSDT_M8I.zip (39.1 KB)
i’ve tried on Z170-DELUXE with RX 580 4GB also, with the Nimez driver:
default:


2^9 = 512 MB, seems works.

2^ 12 = 4 GB, before booted into system, keep black screen and CSM being enabled automatically, can see large memory range in device manager:

DSDT of Z170-DELUXE:
DSDT_DELUXE.zip (40.5 KB)

1 Like

2^ 12 = 4 GB, before booted into system, keep black screen

RX 580 does this with 4G decoding if you don’t have a working GOP VBIOS/modified VBIOS or have CSM enabled. If you have any modified VBIOS remove it (or change the BIOS switch) doing that gets GOP working for me.

Z170 M8I looks like it has proper Large Memory allocation (unlike my board) no idea why the BIOS won’t use it. Maybe check for Memory Remap or any similar settings in BIOS.

@Kuri0 hi, any guides on how to modify for more PCI MMIOH resource? I’m running Ivy Bridge i7-3770 and at wits end on enabling GPU-P for Hyper-V.
And how do I use ReBarState? I suppose it needs to be compiled?

hi, any guides on how to modify for more PCI MMIOH resource?

if you’re referring to the 64GB limit that can’t be be removed as it’s a hardware limitation (36 bit physical address on Ivy Bridge). The MMIOH limit I was talking about is the artificial one that the BIOS uses when allocating PCI resources which is usually around 16GB.

And yes ReBarState needs to be compiled I could send a binary if you want though.

Yes, I mean the artificial 16GB limit. Whenever I try to give Hyper-V VM 64bit MMIO above 512MB, which is the bare minimum, the VM cannot be started stating that it is above supported physical address. I figured my BIOS just had a broken Above 4G Decoding.

And yes, I’d like the compiled ReBarState for testing on my Z77X-D3H. I don’t have a supported GPU but still, it’s worth trying just for the sake of it.

I don’t really know how to remove the artificial 16GB limit it involves modifying PciHostBridge and is different with every BIOS. And also sometimes need DSDT modification.

Another test with ASRock Z370 Pro4 and RX 580.
BIOS 4.30 do not support ReBAR and 4.30B support.
Use 4.30 add ffs and enter value 32, got the same result with 4.30B.
Still need further test with NV card.

Afaik the problem is with PCI resource allocation in the BIOS. In my case (B75M-D3H) and several other Ivy Bridge users it doesn’t work with anything above 2GB and prazola’s Z97 appears to work upto 8GB.

Also seems that some boards like your Z170-DELUXE and Z170-P D3 on overclockers.ru have another problem where BIOS graphics don’t work when the GPU BAR address is in the 64 bit region and/or larger than 1GB.

It needs to be figured out how to patch/replace the PCI resource allocator to support larger sizes and use the full physical address range but I don’t have any knowledge on doing this. Hopefully someone figures it out eventually.

1 Like

Well, if we can get more eyes looking at this, even those issues can be fixed.

I think there is something different between NV and AMD card. RX 580 uses BAR0 so it have no problem in Z170 test, while NV 30 series use BAR1.

Wasn’t the RX 580 test done on a Z170 DELUXE and the 3090 test done on a Z170 M8I ? Though I would expect them to have similar PCI resource allocation there could be differences.

Atleast from looking at the code and the results of running the test build it appears the DXE driver doesn’t have any problems handling BAR 1.

It looks like the Z170 M8I + 3090 doesn’t want to use the 64 bit MMIO range (4G Decoding/MMIOH) for BAR 1 for some reason as 1GB (maximum size that works) is around the maximum you can get in the 32 bit range (PCI hole iirc).

Is there any useful POST code when it fails ? It probably will say something related to PCI resource allocation.