[Release] Resizable BAR BIOS EFI Module

Hi guys,

I followed the instructions on Kurio0’s GitHub, didn’t see the note in here to insert the ffs before PciHostBridge entry. Instead I inserted it at the very end of the volume. Do you think it matters? Am going to go ahead and try flashing again after inserting it there.

I’m using a 3080 (VBIOS is up to date and supports ReBar)
Gigabyte Z170x Gaming 7, 4G Decoding is on, 6700k cpu

After flashing, what is the best possible way to determine that ReBar is now supported, before I even run ReBarState and set any values?

UPDATE:

I placed the driver before PciHostBridge and flashed my bios. I see the following in HWINFO, but whatever I put into ReBarState.exe doesn’t seem to do anything. I don’t get a popup in HWINFO saying anything has changed. I saw something about leaving CSM Support enabled? Open to trying some things if anyone here has ideas.

Try placing the driver after at the end of the volume instead maybe it’s not loading. Does running RebarState again show that it has set the value ?

If you do leave CSM On and/or 4G Decode off it will result in black screen if the module is working.

1 Like

Thanks for your quick response. It turns out ReBarState.exe does work, it just requires a reboot on my system for the changes to show. I am able to see the Resizable BAR1 Supported Size increasing. I am able to increase it up on 1GB on my setup. 2GB or more leads to a black screen on post, requiring a reset of the BIOS by clearing the CMOS.
I didn’t actually look at HWINFO before flashing my BIOS, so I’m not actually sure if doing that changed anything. Would it have said no Resizable BAR Support if I didn’t insert the module?

I just tried testing to see if I could notice any performance improvement, but it’s hard to be certain. Elden ring has a pretty noticeable 10% increase if you force ReBar on for the game on an Nvidia card. To do so you need to use Nvidia Profile Inspector, which I did on this system now. The thing is, NVCP still reports Resizable Bar: No. So if the Nvidia driver can’t detect that it’s available, it makes me think it will continue use the standard 256MB BAR Size, even though I am able to successfully increase it. I wonder if that would be something worth looking into, surely we need the Nvidia driver to recognize the modifications we have made? Not sure if the AMD driver picks it up on your end

Same problem on my system but with 4GB and several others it relates to the BIOS not being able to handle Large BARs I have no idea how to fix it. The hardware itself is capable of doing it

Would it have said no Resizable BAR Support if I didn’t insert the module?

It shows as long as your GPU supports even if BIOS doesn’t.

The thing is, NVCP still reports Resizable Bar: No

My guess is that Nvidia needs the full BAR size to work. AMD doesn’t though and shows it enabled and performance improvements with 2GB BAR

It needs to be figured out how to patch the UEFI PCI driver to work with Large BARs (above 2GB) which I have no idea how to do. Also make sure 4G decode is enabled because that cause it to not work too.

1 Like

Interesting, I think you may be right about that Nvidia limitation with it looking for a specific size, or a large enough size for it to say Yes. I pulled up GPU-Z which lists everything as good, and also sees the 1GB BAR Size I was able to set

Well it would def be awesome if we could figure out how to increase the size in the BIOS if the hardware supports it. On the other hand Nvidia users can probably make use of this now, if only it worked with smaller maximum BAR sizes (according to your idea)

Precision X1 says it’s on too, only NVCP says No.

I’m pretty confident it works. Just that with a 1GB BAR Size, the increase isn’t as impressive

I think Z170 board BIOS has a feature where they force the GPU BARs to be in the 32-bit range which makes anything above 1GB not work. Are you sure CSM is off ?

1 Like

Yep, confident CSM is indeed off. I could try turning it back on, but I understand that would likely have a negative effect if anything. I did a bit more testing and am confident ReBar is indeed working even though NVCP says “No” but the other apps like GPU-Z and Precision X1 say “Yes”. On Elden Ring, I used nvidia profile inspector to either enable/disable ReBar support for the game and compared at the same location. When enabling ReBar support for the game, GPU usage increases to 99% instead of 98%, power usage on the GPU incrases by about 20w, and the FPS is increased by around 4% in my test scene. I have another machine with native support for ReBar and a similar GPU (3090 instead of a 3080), so when I get a chance I’ll do the same comparison and see if a platform with native support and a larger BAR size shows a larger increase than 4% with the 1GB bar size. In the past I had measured about 8% to 9% from turning ReBar on but that was in a different scene.

I’m really glad to see that it all does indeed work. The question remaining now is how much more performance is being left on the table due to the 1GB Bar size limit we reached on my Z170X Gaming 7 mobo

1 Like

I tried placing the DXE driver both at the end of the volume and above PciHostBridge. I also applied the PciBus patch for Haswell(with MMTool replace method). The motherboard is an Asus Z97i-plus. However, re-bar is still not available. ReBarState can’t find the variable and is not able to write any value.

@valip
The ReBarDxe driver does not create a variable. You have to run ReBarState enter a value to create the variable, reboot and it should work.

I think these Z97 boards have a problem writing variables. I’ve seen 3 different people say Z97 board can’t write variables. I saw one person with an X99 board have the same issue from having Windows installed in legacy mode with CSM on but I don’t think that’s the issue you have.

If you can create an issue on GitHub would be better to help solve this issue. What error code does ReBarState say ?

1 Like

I get
Failed to write ReBarState UEFI variable
GetLastError: 5

I tried linux and it succeeds. However, after reboot rebar is still disabled.
Here’s what I see on Linux(I get the same thing after reboot)

ReBarState variable doesn't exist / Disabled. Enter a value to create it
...
Enter ReBarState Value
      0: Disabled 
Above 0: Maximum BAR size set to 2^x MB 
     32: Unlimited BAR size
9
Writing value of 9 / 512 MB to ReBarState 
Successfully wrote ReBarState UEFI variable

If I run again before reboot

Enter ReBarState Value
      0: Disabled 
Above 0: Maximum BAR size set to 2^x MB 
     32: Unlimited BAR size
9
Writing value of 9 / 512 MB to ReBarState 
Failed to remove old variable
Failed to write ReBarState UEFI variable

When you run again before reboot on Linux does it show the value that you previously entered ?

Seems like these boards have a problem writing EFI variables. Need to figure out how to fix it

See if dmesg shows anything useful after you get the error

1 Like

No, it prompts again that the variable doesn’t exist. BTW, how can I verify that the module loads? If I disable 4G decode and CSM, I’m still able to boot fine. I though this module will cause black screen if these are not configured properly. Or is this only after rebar is enabled?

I’ll create a github issue.

how can I verify that the module loads

no way sadly

I though this module will cause black screen if these are not configured properly

only if it’s enabled

Looking on Google it seems like some Hackintosh users run into the same problem on these boards EFI Variable Store on Aptio V (Haswell-E and up) - UEFI | InsanelyMac

1 Like

dmesg doesn’t show anything related.

These are all efi logs

[    0.000000] efi: EFI v2.31 by American Megatrends
[    0.000000] efi: ESRT=0xdef56898 ACPI 2.0=0xddb24000 ACPI=0xddb24000 SMBIOS=0xdef56518 
[    0.037428] efi_bgrt: Ignoring BGRT: invalid image address
[    0.037487] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
[    0.194794] pci 0000:01:00.0: BAR 1: assigned to efifb
[    0.204931] Registered efivars operations
[    0.329188] efifb: probing for efifb
[    0.329202] efifb: No BGRT, not showing boot graphics
[    0.329203] efifb: framebuffer at 0xe0000000, using 8640k, total 8640k
[    0.329204] efifb: mode is 1920x1080x32, linelength=8192, pages=1
[    0.329205] efifb: scrolling: redraw
[    0.329206] efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
[    1.291169] tsc: Refined TSC clocksource calibration: 3497.971 MHz
[    6.128012] systemd[1]: Starting Load Kernel Module efi_pstore...
[    6.149647] pstore: Registered efi as persistent store backend
[    6.152762] systemd[1]: modprobe@efi_pstore.service: Succeeded.
[    6.152995] systemd[1]: Finished Load Kernel Module efi_pstore.

@valip
Haven’t read it fully but this might help https://www.reddit.com/r/hackintosh/comments/jw7qf1/haswell_asus_z97_big_sur_update_and_installation/

He takes the NvramSmi module from an older working BIOS and uses it on the new one. The problem is that NvramSmi has a variable whitelist in it. Maybe I will add a patch to the UEFIPatch later so it’s easier if it works for you

1 Like

I’ll try the NvramSmi replacement approach. If I can’t find an old enough bios for the same board, do you think a module from a different board(also Asus Z97) would work?

Replacing NvramSmi with an older version does work. I can enable rebar. I played with different sizes and found that it works up to 1GB. At 2GB it gets stuck at post, at 4GB and 8GB I can boot into Windows but I can only get output from the integrated GPU. The discrete GPU is detected by HWInfo(not by GPU-Z though ) and does show the configured bar size.

@valip
Can you show a screenshot of Device Manager showing the Resources tab of it (with 8GB BAR) ? I think BIOS isn’t assigning the GPU a BAR address. Did you try the other UEFIPatches ?

Also send a screenshot of Device Manager View → Resources By Type showing Large Memory

1 Like

Looks like it’s not assigning anything.
I checked the other patches by searching the pattern. The only one that matched was the PciBus patch.

Hi, i have successfully enabled ReBAR on my X79-UP4 motherboard, but sadly i can`t go past 1gb size, entering more just results in a black screen. Is there a way to get more, also is there a way to enable Above 4G decode on this board, or check if its even on?
CSM is Disabled in bios i think. (Under Windows 8 features, CSM module is set to run “Never”)