[Release] Resizable BAR BIOS EFI Module

Yet, I want to try to fix it if possible. Just thought sharing here what I have found, maybe someone else stumbled upon this problem too so it would also save them some effort.

Hello, May I ask if you have perfectly used Resizebar on P8Z77-V?

If available, I hope you can share it, thanks a lot!

The unaligned Raw file issue is due to the requirement of starting at the 8th byte.
Here is how it is supposed to be (injected, pre-patch)

UEFITool’s solution was to delete the Pad-file and replace it with the amount of needed FFs at Volume 3 free space, so the Raw file would start at the 8th byte.


As you can see in my previous post (under option 5), when added two Pad-files one after another aligned the Raw file correctly, hence there was no error about it.

Notice in the pictures how before some of the Pad-files there are FFs (empty data) - it is there for alignment only. You can also find it after some modules (you’ll find 00 at the buttom of the module, marking that the module has ended) and it comes in order to align correctly the next module.

Perhaps there is a limitation of the maximum number of FFs that can be inserted for alignment before it is being recognized as part of the BIOS, or maybe the data / header checksum needs to be adjusted after adding more FFs (if so I didn’t manage to succeed doing it).

Here is my try of aligning the Raw file


You can see pre-existed FFs that UEFITool added for alignement (after it deleted the Pad-file) compared to the previous picture. In here I added the deleted Pad-file again and inserted FFs so the Raw file would start at the 8th byte. Sadnly it was not enough.

If anyone here knows how to deal with this error or how to approach this I would appreciate your help a lot!
Thanks for reading, every if you don’t have a solution to offer.

1 Like

Asus P9X79-Pro?

Yeah. I am aware the bug Kuri0 mentioned, I am trying to fix it.

ReBar modded bios with Runtime module patches. Paddings are preserved.

I used a method from 2014. It was proposed for phoenix legacy bios mods to deal with insufficent space to manipulate modules.
The problem with paddings occurs when one or another module changes in size. UEFI compression can be compared to the way .png images are compressed. A sequence of FF FF FF FF is much easier to compress than 01 02 03 04. If we can’t grow or duplicate paddings in order to achieve proper alignment, why not to edit the module?

3 Likes

I am attempting to enable Resizable BAR on my Dell Optiplex 7060 with the latest BIOS version (v1.28.0) running Ubuntu 22.04 in order to improve driver performance on my Intel Arc A380 GPU. Following a guide to enable hidden 4G decoding, I identified the VarOffset values in Setup for “CSM Support” and “Above 4GB MMIO BIOS assignment”:

0x55A2C One Of: CSM Support, VarStoreInfo (VarOffset/VarName): 0x11AD, VarStore: 0x1, QuestionId: 0x2805, Size: 1, Min: 0x0, Max 0x1, Step: 0x0 {05 91 BE 17 BF 17 05 28 01 00 AD 11 14 10 00 01 00}
0x55A3D         Default: DefaultId: 0x0, Value (8 bit): 0x1 {5B 06 00 00 00 01}
0x55A43         One Of Option: Disabled, Value (8 bit): 0x0 {09 07 04 00 00 00 00}
0x55A4A         One Of Option: Enabled, Value (8 bit): 0x1 (default MFG) {09 07 03 00 20 00 01}
0x55A51 End One Of {29 02}

0x566F3 One Of: Above 4GB MMIO BIOS assignment, VarStoreInfo (VarOffset/VarName): 0x8E1, VarStore: 0x1, QuestionId: 0x5A4, Size: 1, Min: 0x0, Max 0x1, Step: 0x0 {05 91 A4 08 A5 08 A4 05 01 00 E1 08 10 10 00 01 00}
0x56704         Default: DefaultId: 0x0, Value (8 bit): 0x1 {5B 06 00 00 00 01}
0x5670A         One Of Option: Enabled, Value (8 bit): 0x1 {09 07 95 00 00 00 01}
0x56711         One Of Option: Disabled, Value (8 bit): 0x0 {09 07 96 00 00 00 00}
0x56718 End One Of {29 02}

I then disabled Secure Boot, booted into modGrubShell.efi from a flash drive, and ran the following commands:

setup_var 0x11ad 0x0
setup_var 0x8e1 0x1
exit

Resizable BAR was not enabled upon reboot so I tried again using setup_var_3 but it still did not work. After reading around this forum some more I found some Dell users had also set “Legacy Option ROMs” to enabled before running setup_var. When I did this, I noticed that reading CSM Support offset 0x11ad prior to making any changes now returned “1” (Enabled) instead of “0” (Disabled), but frustratingly I still see messages that indicate my modifications have not taken effect: "[drm] Using a reduced BAR size of 256MiB. Consider enabling 'Resizable BAR' or similar, if available in the BIOS."

It seems like none of the variables I set persists upon reboot. If I make a change with setup_var, exit, then boot back into modGrubShell.efi, the values read from offsets 0x11ad and 0x8e1 have been reset to their original values. This is my first time messing around with UEFI variables and I may be missing something obvious here…any guidance would be greatly appreciated. Thanks!

For reference, here are the extracted BIOS files and UEFITool / Universal IFR Extractor output I am working with: 22.83 MB file on MEGA

Did you insert ReBar module?

What do you mean? I’m on kernel version 6.5.0-25-generic with the i915 driver:

sudo lspci -vvvs 04:00.0

04:00.0 VGA compatible controller: Intel Corporation Device 56a5 (rev 05) (prog-if 00 [VGA controller])
	Subsystem: ASRock Incorporation Device 6006
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin ? routed to IRQ 135
	Region 0: Memory at a2000000 (64-bit, non-prefetchable) [size=16M]
	Region 2: Memory at 90000000 (64-bit, prefetchable) [size=256M]
	Expansion ROM at a3000000 [disabled] [size=2M]
	Capabilities: [40] Vendor Specific Information: Len=0c <?>
	Capabilities: [70] Express (v2) Endpoint, MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset+ SlotPowerLimit 0.000W
		DevCtl:	CorrErr- NonFatalErr- FatalErr- UnsupReq-
			RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+ FLReset-
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- NonFatalErr- FatalErr- UnsupReq+ AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
			ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp+
		LnkCtl:	ASPM Disabled; RCB 64 bytes, Disabled- CommClk-
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s (ok), Width x1 (ok)
			TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Range B, TimeoutDis+ NROPrPrP- LTR+
			 10BitTagComp+ 10BitTagReq+ OBFF Not Supported, ExtFmt+ EETLPPrefix-
			 EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
			 FRS- TPHComp- ExtTPHComp-
			 AtomicOpsCap: 32bit- 64bit- 128bitCAS-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR+ OBFF Disabled,
			 AtomicOpsCtl: ReqEn-
		LnkCap2: Supported Link Speeds: 2.5GT/s, Crosslink- Retimer- 2Retimers- DRS-
		LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
			 Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
			 Compliance De-emphasis: -6dB
		LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete- EqualizationPhase1-
			 EqualizationPhase2- EqualizationPhase3- LinkEqualizationRequest-
			 Retimer- 2Retimers- CrosslinkRes: unsupported
	Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable+ 64bit+
		Address: 00000000fee003f8  Data: 0000
		Masking: 00000000  Pending: 00000000
	Capabilities: [d0] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold-)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [100 v1] Alternative Routing-ID Interpretation (ARI)
		ARICap:	MFVC- ACS-, Next Function: 0
		ARICtl:	MFVC- ACS-, Function Group: 0
	Capabilities: [420 v1] Physical Resizable BAR
		BAR 2: current size: 256MB, supported: 256MB 512MB 1GB 2GB 4GB 8GB
	Capabilities: [400 v1] Latency Tolerance Reporting
		Max snoop latency: 3145728ns
		Max no snoop latency: 3145728ns
	Kernel driver in use: i915
	Kernel modules: i915

First of all, THANKS A TON!

I’m going to need some time to understand what you did there exactly, still got a lot to learn.

Thanks you for your time and effort!! Appreciate your help :slight_smile:.

1 Like

I mean the bios must support Resizable BAR in order to enable it. Is it in there?

There’s no option explicitly called “Resizable BAR” in my Universal IFR Extractor dump but I was under the impression that the presence of “Above 4GB MMIO BIOS assignment” means it is supported. I also compiled the latest Rust version of the IFR Extractor and it produced a description that the other did not: "Enable/Disable above 4GB MemoryMappedIO BIOS assignment This is enabled automatically when Aperture Size is set to 2048MB."

So you skipped the main step.

Turns out solution was even simpler than any workaround offered.

After patching DSDT and reinjecting it to the BIOS, Pad-files went corrupted again. Now that I know it is caused due to the way UEFITool solves unalignment, I injected the patched DSDT to the patched BIOS shown on my previous post in option 7 (where I manually added a Pad-file and caused unalignment to the Raw file) hoping that the change of size in the Runtime module and the change of size in the AmiBoardInfo module would together realign the Raw file as needed to insert the Pad-file.
EDIT: EVEN SIMPLER! Just patch the BIOS, now that it has corrupted Pad-files inject the patched DSDT module to fix the corruption. Note that this solution would work only if more than one patched module that exists before the Raw files have changed their size.

Conclusion: First, patch both your modules and DSDT and then fix padding (either add the Pad-file manually using any Hex Editor or insert using UEFITool) cause you might not even need to do anything to fix padding.
If you are still encountering problems and unable to solve padding issue after trying everything, perhaps it means that only one module before the Raw file has changed its size. In this case, please turn to @Sweet_Kitten’s wonderful solution.

P.S. Here is a link to the BIOS if anyone else here has the board, to save you some effort.

1 Like

Sorry if I sound obtuse, but what did I skip? My understanding is that recent kernels automatically resize the BAR when >4GB MMIO is enabled in the BIOS settings (Improving performance - ArchWiki):

[    2.770600] i915 0000:04:00.0: BAR 2: no space for [mem size 0x200000000 64bit pref]
[    2.770601] i915 0000:04:00.0: BAR 2: failed to assign [mem size 0x200000000 64bit pref]
[    2.771401] i915 0000:04:00.0: [drm] Failed to resize BAR2 to 8192M (-ENOSPC)

I inspected the contents of Setup with efivar -p -n ec87d643-eba4-4bb5-a1e5-3f3e36b20da9-Setup and found that offset 0x8e1 (>4GB MMIO BIOS assignment) is still 0 for some reason…so I tried again, this time with setup_var.efi:

Here I changed:

  • CSM Support (0x11ad): 0 → 0 [Disabled]
  • >4GB MMIO BIOS assignment (0x8e1): 0 → 1 [Disabled to Enabled]
  • Aperture Size (0x82b): 1 → 0xf [256MB to 2048MB]

Upon rebooting I did another efivar dump for comparison, but only Aperture Size changed and >4GB MMIO remains disabled:

diff setup.log setup_updated.log
138c138
< 00000820  00 00 00 00 00 01 02 00  03 00 03 01 00 00 01 01  |................|
---
> 00000820  00 00 00 00 00 01 02 00  03 00 03 0f 00 00 01 01  |................|

Edit: I also tried applying the “Linux no 4G Decoding fix” DSDT patch and there’s no discernible difference: dsdt_mod_linux_no_4g_decoding.zip (271.1 KB)
Setting pci=realloc to the kernel arguments from grub doesn’t do anything, either.

[    0.010971] ACPI: DSDT ACPI table found in initrd [kernel/firmware/acpi/dsdt_mod.aml][0x4536d]
[    0.010996] modified: [mem 0x0000000063083000-0x0000000063083fff] ACPI NVS
[    0.011004] modified: [mem 0x000000007638e000-0x00000000763d336c] ACPI NVS
[    0.011008] modified: [mem 0x0000000079aad000-0x0000000079b29fff] ACPI data
[    0.011010] modified: [mem 0x0000000079b2a000-0x0000000079fe6fff] ACPI NVS
[    0.011062] ACPI: Early table checksum verification disabled
[    0.011065] ACPI: RSDP 0x0000000079AC6000 000024 (v02 DELL  )
[    0.011069] ACPI: XSDT 0x0000000079AC60B0 0000DC (v01 DELL   CBX3     01072009 AMI  00010013)
[    0.011075] ACPI: FACP 0x0000000079B0B718 000114 (v06 DELL   CBX3     01072009 AMI  00010013)
[    0.011080] ACPI: Table Upgrade: override [DSDT-DELL  - CBX3   ]
[    0.011083] ACPI: DSDT 0x0000000079AC6218 Physical table override, new table: 0x000000007638E000
[    0.011086] ACPI: DSDT 0x000000007638E000 04536D (v02 DELL   CBX3     0107200A INTL 20200925)

hi i have a asus a320m-k and i installed the rebardxe.ffs module into the bios and flashed it using a flash programmer ch341a and it boots normally but using rebarstate.exe dosent change the barsize at all it stays at 4gb always even if i put a lower or higher value

here is the original bios ans well as the modded one (which i got by reading the bios using afuwin.exe as it was currently installed):

Try to take off the cmos battery, turn the psu on but dont turn the pc on, and then try to reprogram the bios chip using CH341A again with your modded bios, make sure you do have your stock bios backup (not pure bios from asus).

If it doesnt work, try to turn off the psu, and then try again. So no cmos, no psu power flowing through, and just ch341a that powers your bios chip.

I found another section in my BIOS called PciDynamicSetup where the extracted .efi contains plain text related to enabling/disabling 4G Decoding:
Above 4G DecodingGlobally Enables or Disables 64bit capable Devices to be Decoded in Above 4G Address Space (Only if System Supports 64 bit PCI Decoding).Disable Above 4G DecodingDisables 64bit capable Device Resources to be Allocated in Above 4G Address Space

Curiously, neither Universal IFR Extractor nor IFRExtractor RS includes “4G Decoding” in their output. They only extract a PCI Subsystem Settings form containing a Hot-Plug Support checkbox along with empty forms for PCI Device Settings, PCI Express GEN 1 Settings, PCI Express GEN 2 Settings, and PCI Hot-Plug Settings.

This is what I see inside PCI_COMMON:

GUID: aca9f304-21e2-4852-9875-7ff4881d67a5
Name: "PCI_COMMON"
Attributes:
	Non-Volatile
	Boot Service Access
	Runtime Service Access
Value:
00000000  00 00 01 00 00 00

The only set byte corresponds to the offset of Hot-Plug Support. Is there any way to figure out what the other bytes represent, or am I going to have to take the Russian roulette route?

There’s no option explicitly called “Resizable BAR” in my Universal IFR Extractor dump but I was under the impression that the presence of “Above 4GB MMIO BIOS assignment” means it is supported.

Not really. A card may come with huge BAR size but no resizable BAR compatibility. As your BIOS doesn’t support adjusting resizable BAR then you will be stuck with typically a default size of 256MiB. You need to add resizable BAR support yourself.

Aperture Size (0x82b): 1 → 0xf [256MB to 2048MB]

This is for integrated graphics (in CPU), not discrete graphics.

The only set byte corresponds to the offset of Hot-Plug Support. Is there any way to figure out what the other bytes represent, or am I going to have to take the Russian roulette route?

No need, it’s not unusual for BIOS to be left with old unused data that doesn’t do anything.

Hello all!
I have tried to follow some guide for applying the patch to a bios of an AsRock X570 (AMI Aptio V)

I have tried to use UEFITool + UBU for the problem of checksum without any success.

I would appreciate any help if you can guide me step by step or if you have no time to explain,
please offer me a modded bios

https://pg.asrock.com/mb/AMD/X570%20Phantom%20Gaming%20X/index.it.asp#BIOS