[Release] Resizable BAR BIOS EFI 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

Hello @luchino ,

What are you trying to do?

X570 should not need a ReBAR mod.

Edit: Resizable Bar added as of BIOS Ver. 4.0

Best regards,

-68k

Greetings,

Has anyone had any luck with a Lenovo M920s (or any Lenovo for that matter that uses the same flash tools)?

I’ve had no issue creating the patched BIOS, but I cannot get the Lenovo flash tool to actually accept the BIOS and flash it. It errors out and says that the file doesn’t match (or it’s too old). I have disabled the BIOS option that locks out rolling back the BIOS. (I think it’s called BIOS rollback protection?)

Any thoughts on how to force it to flash the modded BIOS?

You can try dumping and modding only the bios_region, if the FD is unlocked for writing.
Enable the Service Mode (ME_DIS jumper) for dumping and writing, using the Intel FPT tool form the correct SKU of the chipset ME FW.

image

I get “can’t set variable using efi(0x00000000000000001a)” and “SetVariable call returned Security Violation.” in grub setup_var and AMISetupWriter.
What I want to do is to enable Above 4G Decoding and Resizable BAR.

SH510R4

SH510000.104

FPTW64.exe -i
Intel (R) Flash Programming Tool Version: 15.0.35.1951
Copyright (C) 2005 - 2021, Intel Corporation. All rights reserved.

Reading HSFSTS register… Flash Descriptor: Valid

--- Flash Devices Found ---
ID:0xEF4018    Size: 16384KB (131072Kb)

--- Flash Image Information --
Signature: VALID
Number of Flash Components: 1
    Component 1 - 16384KB (131072Kb)
Regions:
    DESC           - Base: 0x00000000, Limit: 0x00000FFF
    BIOS           - Base: 0x00418000, Limit: 0x00FFFFFF
    CSME           - Base: 0x00023000, Limit: 0x00417FFF
    GbE            - Base: 0x00021000, Limit: 0x00022FFF
    PDR            - NOT PRESENT
    EC             - Base: 0x00001000, Limit: 0x00020FFF
Master Region Access:
    BIOS           - ID: Read: 0xFFFF, Write: 0xFFFF
    CSME           - ID: Read: 0xFFFF, Write: 0xFFFF
    GbE            - ID: Read: 0xFFFF, Write: 0xFFFF
    EC             - ID: Read: 0xFFFF, Write: 0xFFFF

Total Accessible SPI Memory: 16384KB, Total Installed SPI Memory: 16384KB

FPT Operation Successful.

Hello @bonbax

I believe the Above 4G setting is already available to you. It looks to be enabled by default too.

Check here

Main>Advanced>PCI Subsystem Settings

In Windows look at the GPU-Z ReBAR tab to check the requirements

Best regards,

-68k

Thanks for the reply.

I have checked and it does not seem to be enabled in my environment.
Is this a CPU or OS revision issue?
At least there is no menu in the BIOS (UEFI) to set 4 above and resize ber.

Also check Chipset, System Agent (SA) Configuration: