ReBarUEFI:为几乎所有 UEFI 系统启用 Resizable BAR
ReBarUEFI: Resizable BAR for almost any UEFI system

原始链接: https://github.com/xCuri0/ReBarUEFI

该项目提供了一个 UEFI DXE 驱动程序(ReBarDxe),旨在为非官方支持的系统开启“可调整大小的基址寄存器”(Resizable BAR)功能,从而显著提升性能,尤其是针对英特尔 Arc 系列显卡。 **关键要求与设置:** * **固件修改:** 用户必须将 ReBarDxe 模块添加到 UEFI 固件中,并通常需要通过 UEFIPatch 应用特定补丁,以解决 64 位 BAR 兼容性问题或扩大 MMIO 空间。 * **配置:** 刷入固件后,必须开启“4G 以上解码”(4G Decoding)并关闭 CSM。随后,使用 `ReBarState` 工具设置所需的 BAR 大小(通常为 32GB 或无限制)。 * **局限性:** 该方案主要针对 Windows(需要修改 BIOS);对于 Linux 用户,若系统支持 4G 解码,有时可通过在内核参数中添加 `pci=realloc` 实现类似效果。 **重要注意事项:** * **稳定性:** 若因设置了不支持的 BAR 大小导致无法开机,通常可通过清除 CMOS 重置为默认设置。 * **文档资料:** 项目 Wiki 中提供了详细指南,包括针对旧平台(X79/X99)的特定补丁及 DSDT 修改方法。 * **适用范围:** 此方案与 `NvStrapsReBar` 不同,后者是专门针对 NVIDIA Turing(16/20 系列)架构显卡定制的。

**ReBarUEFI** 是一个开源项目,旨在通过定制的 UEFI 固件修改,为旧款或不受支持的计算机系统启用“可调整大小的基地址寄存器”(Resizable BAR)支持。 **什么是 ReBar?** 传统上,PCIe 设备(如 GPU)与 CPU 通信时会被限制在 256MB 的内存窗口内,导致数据必须分块传输。Resizable BAR 移除了这一限制,允许 CPU 一次性访问整个 GPU 显存。这显著降低了系统开销,通常能为游戏和专业应用带来 5% 到 15% 的性能提升。虽然现代硬件原生支持此功能,但在旧款主板的 BIOS 中,该功能往往缺失或被禁用。 **项目意义:** * **延长寿命:** 用户成功利用该工具为旧硬件(如 X79/X99 工作站)“注入活力”,使其能与现代 GPU 有效协同工作。 * **社区关注:** 该项目引发了关于固件修改的广泛讨论,用户分享了关于 BIOS 修补、硬件变砖风险,以及 PCIe 特性被制造商重命名(如 AMD 的“显存智取技术/Smart Access Memory”)的历史等经验。 * **可访问性:** 尽管存在风险,该项目提供了一种绕过原始设备制造商(OEM)限制的方法,让用户能在制造商认定为“过时”的硬件上使用高性能内存映射技术。
相关文章

原文

GitHub Actions ReBarDxe GitHub Actions ReBarState Downloads

A UEFI DXE driver to enable Resizable BAR on systems which don't support it officially. This provides performance benefits and is even required for Intel Arc GPUs to function optimally.

screenshot showing cpu-z, gpu-z and amd software

If using an NVIDIA Turing GPU (20 or 16 series) see NvStrapsReBar for enabling Resizable BAR on it.

  • (optional) 4G Decoding enabled. See wiki page Enabling hidden 4G decoding if you can't find an option for it. Without 4G Decoding you will be limited to 1GB BAR and in some cases 512MB you can try to increase this upto 2GB by reducing TOLUD
  • (optional) BIOS support for Large BARs. Patches exist to fix most issues relating to this

Follow the wiki guide Adding FFS module and continue through the steps. It covers adding the module and the additional modifications needed if required.

Once running the modified firmware make sure that 4G decoding is enabled and CSM is off.

Next run ReBarState which can be found in Releases (if you're on Linux build with CMake) and set the Resizable BAR size. In most cases you should be able to use 32 (unlimited) without issues but you might need to use a smaller BAR size if 32 doesn't work

If Resizable BAR works for you reply to List of working motherboards so I can add it to the list. Most firmware will accept unsigned/patched modules with Secure Boot on so you won't have any problems running certain games.

If you have any issues after enabling Resizable BAR see Common Issues (and fixes)

The module is added to the UEFI firmware's DXE volume so it gets executed on every boot. The ReBarDxe module replaces the function PreprocessController of PciHostBridgeResourceAllocationProtocol with a function that checks for Resizable BAR capability and then sets it to the size from the ReBarState NVRAM variable after running the original function.

The new PreprocessController function later gets called during PCI enumeration by the PciBus module which will detect the new BAR size and allocate it accordingly.

AliExpress X99 Tutorial by Miyconst

Resizable BAR on LGA 2011-3 X99

Instructions for applying UEFIPatch not included as it isn't required for these X99 motherboards. You can follow them below.

Most UEFI firmwares have problems handling 64-bit BARs so several patches were created to fix these issues. You can use UEFIPatch to apply these patches located in the UEFIPatch folder. See wiki page Using UEFIPatch for more information on using UEFIPatch. Make sure to check that pad files aren't changed and if they are use the workaround

  • <4GB BAR size limit removal
  • <16GB BAR size limit removal
  • <64GB BAR size limit removal
  • Prevent 64-bit BARs from being downgraded to 32-bit
  • Increase MMIO space from 16-32GB to full usage of 512GB/39-bit range (Skylake/Kaby Lake/Coffee Lake)
  • Increase MMIO space from 8-16GB to full usage of 512GB/39-bit range (Haswell/Broadwell). The issue of older patches being limited to 64GB has been fixed.
  • Increase MMIO space from 16GB to full usage of 64GB/36-bit range (Sandy/Ivy Bridge). Requires DSDT modification on certain motherboards. See wiki page DSDT Patching for more information.
  • Remove NVRAM whitelist to solve ReBarState GetLastError: 5
  • Fix USB 3 ports not working in BIOS with 4G Decoding enabled (Ivy Bridge/Haswell/Broadwell)
  • X79 Above 4G Decoding fix

Use the provided buildffs.py script after cloning inside an edk2 tree to build the DXE driver. ReBarState can be built on Windows or Linux using CMake. See wiki page Building for more information.

Will it work on a PCIe Gen2 system ?

Previously it was thought that it won't work on PCIe Gen2 systems but one user had it work with an i5 2500k.

Can I use Resizable BAR on my system without modifying BIOS ?

You can use Linux with 4G Decoding on, recent versions will automatically resize and allocate GPU BARs. If your BIOS doesn't have the 4G decoding option (make sure to check hidden) or DSDT is faulty you can then follow the Arch wiki guide for DSDT modification using modifications from DSDT Patching and boot with pci=realloc in your kernel command line. Currently there is no known method to get it on Windows without BIOS modification

I set an unsupported BAR size and my system won't boot

Clear CMOS and Resizable BAR should be disabled. In some cases it may be necessary to remove the CMOS battery for Resizable BAR to disable.

Will less than optimal BAR sizes still give a performance increase ?

On my system with an i5 3470 and Sapphire Nitro+ RX 580 8GB with Resizable BAR enabled in driver I get an upto 12% FPS increase with 2GB BAR size.

  • @dsanke, @cursemex, @dripsnek, @val3nt33n, @Mak3rde and @romulus2k4 for testing/helping develop patches

  • The Linux kernel especially the amdgpu driver

  • EDK2 for the base that all OEM UEFI follows

  • Ghidra which was used to patch UEFI modules to workaround artificial limitations

  • @vit9696 for the NVRAM whitelist patches

  • @ZOXZX for helping with the X79 Above 4G patches

  • @NikolajSchlej for developing UEFITool/UEFIPatch

  • QEMU/OVMF made testing hooking way easier although it didn't have any resizable BAR devices so the only way I could test it was on my actual PC.

联系我们 contact @ memedata.com