xCuri0 / ReBarUEFI

Resizable BAR for (almost) any UEFI system
MIT License
1.31k stars 59 forks source link

Boots into windows but unable to access bios with ReBAR at or greater than 4gb #4

Open SqueakyAlex opened 1 year ago

SqueakyAlex commented 1 year ago

Easily managed to set it up and get it running. After some quick testing I found out that...

1gb = According to Radeon drivers (ver22.10.2) and GPU-Z, ReBAR gets enabled, works as expected. 2gb = Halts on bootlogo, unable to enter bios. Need to reset bios. 4gb+ = Boots into Windows but unable to see bootlogo during boot and unable to enter bios, trying to enter bios using the Windows troubleshooting menu also fails. (tested up to 16gb with the same behavior)

Did some benchmarks on 4gb and 16gb to test for system instability, all seemed fine except that I was unable to see the bootlogo on boot or access the bios which can be confusing because during the whole booting process it does seem like the computer has failed to post.

rebar enabled

xCuri0 commented 1 year ago

CSM is off right ? Don't believe what GPU-Z says about CSM or 4G decode because it's often wrong

SqueakyAlex commented 1 year ago

Yes, verified that CSM is off and 4G decode is enabled.

I do get a performance boost when its set to 4gb+, its just that I'm unable to enter the bios and the screens stay off during boot until windows logon screen shows.

Just noticed on your winraid forum post that someone else is having a similar problem with the same board, just diff gpu.

xCuri0 commented 1 year ago

@SqueakyAlex yeah the bios probably needs patching. I had to patch my bios (gigabyte b75m-d3h) to get BARs over 2GB to work. But I haven't made a patch to fix this issue since I don't have it.

Can you send a screenshot of Device Manager resources tab for your GPU when using 1GB BAR ?

SqueakyAlex commented 1 year ago

1GB Bar gpu resources 1gb

Some unrequested extras 4GB Bar gpu resources 4gb

16GB Bar gpu resources 16gb

Had not noticed before, high definition audio bus gets disabled when using 4GB+ bar. Hi Def Audio Bus no resources

xCuri0 commented 1 year ago

@SqueakyAlex the issue of High Definition Audio Bus not having enough resources can be fixed by patching the PciHostBridge module's call to AddMemorySpace to increase the size it uses (and DSDT QWordMemory too if needed).

EDIT: This isn't the case, AddMemorySpace adds a 64GB region which is more than enough

image

SqueakyAlex commented 1 year ago

Assuming your patches would not work for Skylake, I spent a few hours checking pcihostbrige on ghidra and came to the conclusion that I don’t know what I’m looking for and that I know nothing about assembly.

Eventually I did try your patches and as expected the result was "No patches can be applied to input file"

I did manage to extract my DSDT and found this

                CreateDWordField (BUF0, \_SB.PCI0._Y0E._MIN, M1MN)  // _MIN: Minimum Base Address
                CreateDWordField (BUF0, \_SB.PCI0._Y0E._MAX, M1MX)  // _MAX: Maximum Base Address
                CreateDWordField (BUF0, \_SB.PCI0._Y0E._LEN, M1LN)  // _LEN: Length
                Store (M32L, M1LN) /* \_SB_.PCI0._CRS.M1LN */
                Store (M32B, M1MN) /* \_SB_.PCI0._CRS.M1MN */
                Subtract (Add (M1MN, M1LN), One, M1MX) /* \_SB_.PCI0._CRS.M1MX */
                If (LGreaterEqual (OSYS, 0x07D6))
                {
                    If (LEqual (M64L, Zero))
                    {
                        CreateQWordField (BUF0, \_SB.PCI0._Y0F._LEN, MSLN)  // _LEN: Length
                        Store (Zero, MSLN) /* \_SB_.PCI0._CRS.MSLN */
                    }
                    Else
                    {
                        CreateQWordField (BUF0, \_SB.PCI0._Y0F._LEN, M2LN)  // _LEN: Length
                        CreateQWordField (BUF0, \_SB.PCI0._Y0F._MIN, M2MN)  // _MIN: Minimum Base Address
                        CreateQWordField (BUF0, \_SB.PCI0._Y0F._MAX, M2MX)  // _MAX: Maximum Base Address
                        Store (M64L, M2LN) /* \_SB_.PCI0._CRS.M2LN */
                        Store (M64B, M2MN) /* \_SB_.PCI0._CRS.M2MN */
                        Subtract (Add (M2MN, M2LN), One, M2MX) /* \_SB_.PCI0._CRS.M2MX */
                    }
                }
xCuri0 commented 1 year ago

@SqueakyAlex Just send a screenshot of Device Manager showing Resources By Type Large Memory it will show how much the space the DSDT gives.

The only patches I developed are for Ivy Bridge systems and maybe a few Haswell ones which is why it finds nothing to patch. I hope that more patches are contributed in the future because I can't test hardware that I don't have.

SqueakyAlex commented 1 year ago

devman large memory

If I didnt mess up, thats about 64GB?

Pentium320 commented 1 year ago

Hi, Looks, like I'm having the same issue on X99 platform, maybe there is something, that could be helpful.

Behaviour is the same as in this thread after applying ReBAR patch: up to 1024M (2^10) - ReBAR seems to be working as intended 2048M (2^11) - system doesn't post at all, speaker gives 8 beeps (AFAIK it indicates GPU error). CMOS reset needed. 4096M (2^12) and above - unable to enter BIOS, no Post Screen, speaker gives 5 beeps, PC boots directly into Windows and ReBAR seems to be working. AMD HD Audio is broken (error code: 12). Performance has increased a bit.

Screenshot 2022-11-07 163425fsafas

CSM disabled, 4G decode enabled.

If there is anything useful, that I could provide to resolve the issue, tell me. Thanks for your work!

xCuri0 commented 1 year ago

If anyone wants to try and develop patches to fix it you can search for "ffffffff000" in the PciBus module on your disassembler to find the code that reads the BAR size and categorizes them as 32-bit (4/5) or 64-bit (6/7).

soulpower11 commented 1 year ago

My High Definition Audio Bus got disabled too image

Not sure what to do as I am new to bios modding

xCuri0 commented 1 year ago

Try booting Linux with 4GB+ BAR and seeing what dmesg says.

zirblazer commented 1 year ago

Try booting Linux with 4GB+ BAR and seeing what dmesg says.

Unrelated to your ReBarUEFI, but while testing different Above 4G settings to do comparisons on PCIe Root Port default allocations between AMI BIOS and Coreboot to track a bug, I discovered that recent amdgpu versions can enable Above 4G Decoding and ReBAR completely OS side even if they're disabled on Firmware: https://github.com/Dasharo/dasharo-issues/issues/245 This means than with AMD cards is a hit-or-miss to check Linux unless you're paying attention to original allocations before amdgpu forces a PCI MMIO reconfiguration. Or maybe if amdgpu has a parameter to disable this default behavior and obey Firmware resource allocation.

xCuri0 commented 1 year ago

One Asrock X99 Taichi user on win-raid found this out image

So try disabling the option Above 4G Decoding Patch using the IFR method if it's hidden

Dadovvv commented 11 months ago

can anyone tell me how to disable Above 4g Decoding Patch? what line should i edit and what?

i extracted body from my bios where search find 4g decoding but im unable to find any string related to above 4g decoding patch. is that mean i cant disable 4g Decoding patch or ?

xCuri0 commented 11 months ago

@Dadovvv please read wiki common issues and fixes. if you can't find the string then the setting doesn't exist

Igo131 commented 4 months ago

One Asrock X99 Taichi user on win-raid found this out image

So try disabling the option Above 4G Decoding Patch using the IFR method if it's hidden

This works only for mobos that don't have native Above 4G Decoding option or i should try this even if i have the switch in my mobo? Disabling Above 4G Decoding option in GA-Z170m-D3H bios while ReBarState is on leads me to B1InitializeLirary failed 0xc00000bb code on a distorted and freezed BIOS splash screen (first seconds screen is normal and i can enter bios but the OS won't load further).

MrAnonymous7122 commented 2 months ago

Hi, I have a H110M-R which has a LGA1151 socket. For me, display blacks out mid way through the booting process (it's past the boot screen with del for bios and then past the asus logo with win11 spin). My CPU does has an iGPU but the problem is I didn't build this PC myself and the motherboard IO shield has something physically blocking the port from being used. Is there anyway around this or do I have to remove the motherboard from the case and remove the blocker? I'm not sure if this is relevant but the mouse and keyboard are still receiving power and it shuts down normally upon pressing the power button on the case.

MrAnonymous7122 commented 2 months ago

Strangely, after writing this comment it works? It's booted to windows normally and display and sound work fine through HDMI. I will add to working motherboards in a sec.

mirh commented 2 months ago

FWIW I had found out that when I'm just using the igp of my i5-9600K (on a Z390 GAMING X with F10i bios) I'm getting a black screen with aperture sizes higher than 1024MB.