xCuri0 / ReBarUEFI

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

GA-X79-UP4 (Sandy Bridge-E) semi-working with ReBAR ≤1GB #9

Closed aquamacho1 closed 6 months ago

aquamacho1 commented 1 year ago

Hi, so i did manage to unlock ReBAR on my Sandy Bridge - E motherboard (GA-X79-UP4), by modding bios with UEFITool, but values greater than 1GB = my motherboard just straight trying recovery from second bios, which it fails, then reboots and tries again to ∞, until i manually do recovery by pressing reset and power buttons at the same time for 10 seconds, then it flashes 2nd bios to M.

I've also tried those secret setup_var's

setup_var 0x12E 0x1
setup_var 0x9 0x1
setup_var 0xF 0x1
setup_var 0x16 0x1
setup_var 0x1C 0x2
setup_var 0x4F 0x2
setup_var 0x6C 0x0
setup_var 0x4 0x1
setup_var 0xC 0x5
setup_var 0xD 0x5
setup_var 0x17 0x1
setup_var 0xF5 0x0
setup_var 0xD8 0x1
setup_var 0x55 0x1

PCIe Sub Decode, VarStoreInfo (VarOffset/VarName): 0x12E
Relaxed Ordering, VarStoreInfo (VarOffset/VarName): 0x9
Extended Synch, VarStoreInfo (VarOffset/VarName): 0xF
AtomicOp Requester Enable, VarStoreInfo (VarOffset/VarName): 0x16
Target Link Speed, VarStoreInfo (VarOffset/VarName): 0x1C
Server Class, VarStoreInfo (VarOffset/VarName): 0x4F
Energy Performance, VarStoreInfo (VarOffset/VarName): 0x6C
Above 4G Decoding, VarStoreInfo (VarOffset/VarName): 0x4
Maximum Payload, VarStoreInfo (VarOffset/VarName): 0xC
Maximum Read Request, VarStoreInfo (VarOffset/VarName): 0xD
AtomicOp Egress Blocking, VarStoreInfo (VarOffset/VarName): 0x17
DRAM RAPL BWLIMIT, VarStoreInfo (VarOffset/VarName): 0xF5
DCA Support, VarStoreInfo (VarOffset/VarName): 0xD8
Local APIC Mode, VarStoreInfo (VarOffset/VarName): 0x55

explorer_r9nwFCwmuy

aquamacho1 commented 1 year ago

I`ve checked the bios, seems like i do not have any options called CSM, or above 4G decode. Edit: found the CSM option, will try to increase values above 1GB now.

Update: It did nothing, still the same behaviour :( Update: i think the problem is that i do not have 4G decode on my motherboard.

xCuri0 commented 1 year ago

@aquamacho1 you need to enable the hidden 4G Decoding setting.

i can't be replying to everyone so i created a wiki page detailing how to do it Enabling hidden 4G decoding.

i'm closing this issue since your board does have 4g decoding just that it's a hidden setting. if there are any problems still after 4g decoding enabled i can re open it

aquamacho1 commented 1 year ago

@xCuri0 thx for your help, but it seems i have a problems with enabling it. I did exactly step by step what wiki told, but in the end grub console says that i have GUID mismatch, and values are wrong for example (im entering 0x4 offset, but instead it says 0x04 and 0x01) P21106-033006 1 IFR.txt

0x43213     Form: , FormId: 0x404 {01 86 04 04 02 00}
0x43219         One Of: Above 4G Decoding, VarStoreInfo (VarOffset/VarName): 0x4, VarStore: 0x1, QuestionId: 0x5, Size: 1, Min: 0x0, Max 0x0, Step: 0x0 {05 A6 D8 09 D9 09 05 00 01 00 04 00 10 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00}
0x4323F             One Of Option: Disabled, Value (8 bit): 0x0 (default) {09 0E 04 00 30 00 00 00 00 00 00 00 00 00}
0x4324D             One Of Option: Enabled, Value (8 bit): 0x1 {09 0E 03 00 00 00 01 00 00 00 00 00 00 00}

explorer_ZQdsTMdSfN

aquamacho1 commented 1 year ago

Or i messed up 5. step in the guide, do i rename modGRUBShell.efi to bootx64.efi and replace stock bootx64.efi with renamed modGRUBShell.efi right? cos if i just copying modGRUBShell.efi to EFI/Boot/, nothing happens at boot, and my windows usb just booting to the installation.

xCuri0 commented 1 year ago

@aquamacho1 GUID mismatch doesn't matter. 0x04 and 0x4 are the same number so not a problem

Yes you do have to rename it

aquamacho1 commented 1 year ago

Well, either i did something wrong or it just doen`t work, 1024mb is still my limit.

xCuri0 commented 1 year ago

@aquamacho1 did you try setting it to 0x0, rebooting, setting it to 0x1 and then again rebooting ? that's what i had to do to get it working on my mobo

if that doesn't work you can try using setup_var_3 instead of setup_var for all the commands

aquamacho1 commented 1 year ago

Yes, i did tried doing that method to, but still nothing (i mean black screen after increasing value of rebar to more than 1GB), i will try setup_var_3 now.

aquamacho1 commented 1 year ago

Nope, i think setup_var_3 and setup_var are the same thing right? var_3 shows same values as before. I wonder if this is something to do with fact that intel says that my mobo only supports PCI 2.0 by default maybe? When i had Nvidia 1060 gpu, by default i had to use hack to get PCI 3.0 working with this https://nvidia.custhelp.com/app/answers/detail/a_id/3135/~/geforce-gen3-support-on-x79-platform

xCuri0 commented 1 year ago

@aquamacho1 if pcie 3.0 wasn't working you wouldn't be able to use rebar at all. your screenshot also shows working pcie 3.0

maybe you could try using AMIBCP to change it's Access/Use from default to enabled and then enabling it. also these x79 boards seem to have a ton of hidden bios options so maybe another setting is causing the problem.

aquamacho1 commented 1 year ago

is this important? its off by default to, but i think i need enable this to right to get 4g decode?

0x46344         One Of: PCIe Sub Decode, VarStoreInfo (VarOffset/VarName): 0x12E, VarStore: 0x1, QuestionId: 0xA9, Size: 1, Min: 0x0, Max 0x0, Step: 0x0 {05 A6 9B 03 9C 03 A9 00 01 00 2E 01 10 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00}
0x4636A             One Of Option: Disabled, Value (8 bit): 0x0 (default) {09 0E 29 03 30 00 00 00 00 00 00 00 00 00}
0x46378             One Of Option: Enabled, Value (8 bit): 0x1 {09 0E 28 03 00 00 01 00 00 00 00 00 00 00}
0x46386         End One Of {29 02}

Din`t help.

xCuri0 commented 1 year ago

@aquamacho1 probably not needed as it's disabled by default on my motherboard and 4g decode with 8gb bar still works

aquamacho1 commented 1 year ago

try using AMIBCP to change it's Access/Use from default to enabled and then enabling it

@xCuri0 AMIBCP can`t open my bios file, or i dont know how to open it Do i extract Intel image as is from bios file with UEFITool right? UEFITool_cy2J3lLjdl and then open it with AMIBCP ?

xCuri0 commented 1 year ago

@aquamacho1 correct AMIBCP version for your board is v4.55 it opens for me. Also did you try using the newer F7 version bios maybe it fixes this issue ?

aquamacho1 commented 1 year ago

Also did you try using the newer F7 version bios maybe it fixes this issue ?

I did not yet, will do if nothing works.

meanwhile found these, how do i enable it? (im sorry, but i`ve never before modded bioses using hex) AMIBCP_4 55_vrlW0GP1Yf AMIBCP says that it visible, but i dont have all those options in bios menu.

AMIBCP_4 55_Y3JudeF4QA

so i just set both optimal and failsafe to enable?

i only have those in drop down menu, no enable option there

AMIBCP_4 55_Qi3x75mzml

xCuri0 commented 1 year ago

@aquamacho1 don't change anything except Access/Use to USER on Above 4G decoding. Otherwise you might get no boot. All this will do is make the option visible in the BIOS

aquamacho1 commented 1 year ago

Flashed modded bios with 4G enabled by dafault, but no dice, checked with the grub console, it is was enabled right after bios flash. Interesting thing, after i got to windows and checked GPU-Z, above 4G Decode listed as disabled.

@xCuri0 i have dual bioses on this board, i flashed M bios like 30 times in the past two days XD

xCuri0 commented 1 year ago

I guess you can try the F7 bios then

aquamacho1 commented 1 year ago

I guess you can try the F7 bios then

Nope, all the same, can you give me your mobo name? i will check what options are enabled between your and mine. Maybe will find something. Also changing Access/Use to USER didnt`t helped with 4G option being visible, still was hidden.

xCuri0 commented 1 year ago

@aquamacho1 Gigabyte B75M-D3H

aquamacho1 commented 1 year ago

@aquamacho1 Gigabyte B75M-D3H

what rev?, i dont think its matters. Mine mobo has 2 rev. and both of them have same bioses, i literally flashed bios from another rev. chrome_WFKdMjypeq

xCuri0 commented 1 year ago

iirc it's 1.1

aquamacho1 commented 1 year ago

So using your guide on DSDT patching from wiki, i`ve extracted and decoded AmiBoardInfo --> DSDT.aml --> DSDTMod.dsl and found this in there:

            Device (VTDR)
            {
                Name (_HID, EisaId ("PNP0C02") /* PNP Motherboard Resources */)  // _HID: Hardware ID
                Name (_UID, 0x04)  // _UID: Unique ID
                Name (BUF0, ResourceTemplate ()
                {
                    Memory32Fixed (ReadOnly,
                        0x00000000,         // Address Base
                        0x00002000,         // Address Length
                        _Y0E)
                })
                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If ((VTD0 == 0xFFFFFFFF))
                    {
                        Return (Zero)
                    }

                    Return (0x0F)
                }

                Method (_CRS, 0, Serialized)  // _CRS: Current Resource Settings
                {
                    CreateDWordField (BUF0, \_SB.PCI0.VTDR._Y0E._BAS, VBR0)  // _BAS: Base Address
                    CreateDWordField (BUF0, \_SB.PCI0.VTDR._Y0E._LEN, VLT0)  // _LEN: Length
                    VBR0 = VTD0 /* \VTD0 */
                    If ((VTD0 == 0xFFFFFFFF))
                    {
                        VLT0 = Zero
                    }

                    Return (BUF0) /* \_SB_.PCI0.VTDR.BUF0 */
                }
            }

Does this somehow related to the issue? Does this line reffering to above 4G Decode? Name (_UID, 0x04) // _UID: Unique ID (i think its something else)

Anyway, here is full file if you wanna look at it DSDTMod.zip

I do not have anything similar to this in my DSDT file :(

                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
                M2LN = 0x0000000400000000
                If ((TUUD >= 0x1000))
                {
                    M2MN = (TUUD << 0x14)
                }
                Else
                {
                    M2MN = 0x0000000100000000
                }

                M2MX = ((M2MN + M2LN) - One)
xCuri0 commented 1 year ago

this is the relevant code

                QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
                    0x0000000000000000, // Granularity
                    0x0000000000000000, // Range Minimum
                    0x0000000000000000, // Range Maximum
                    0x0000000000000000, // Translation Offset
                    0x0000000000000000, // Length
                    ,, _Y05, AddressRangeMemory, TypeStatic)
                    {
                        CreateDWordField (CRS1, \_SB.PCI0._Y05._MIN, MN8L)  // _MIN: Minimum Base Address
                        Local0 = (0xB4 + 0x04)
                        CreateDWordField (CRS1, Local0, MN8H)
                        MN8L = MABL /* \_SB_.PCI0.MABL */
                        MN8H = MABH /* \_SB_.PCI0.MABH */
                        CreateDWordField (CRS1, \_SB.PCI0._Y05._MAX, MX8L)  // _MAX: Maximum Base Address
                        Local1 = (0xBC + 0x04)
                        CreateDWordField (CRS1, Local1, MX8H)
                        CreateDWordField (CRS1, \_SB.PCI0._Y05._LEN, LN8L)  // _LEN: Length
                        Local2 = (0xCC + 0x04)
                        CreateDWordField (CRS1, Local2, LN8H)
                        MN8L = MABL /* \_SB_.PCI0.MABL */
                        MN8H = MABH /* \_SB_.PCI0.MABH */
                        LN8L = MALL /* \_SB_.PCI0.MALL */
                        LN8H = MALH /* \_SB_.PCI0.MALH */
                        MX8L = MAML /* \_SB_.PCI0.MAML */
                        MX8H = MAMH /* \_SB_.PCI0.MAMH */
                    }

I do find it weird they are using CreateDWordField which can't hold a 64-bit address instead of CreateQWordField . Can you send a screenshot of Device Manager showing View -> Resources by Type Large Memory (like the below screenshot). It should show the resource range the DSDT gives. image

aquamacho1 commented 1 year ago

@xCuri0 i don`t have large memory :cry

explorer_4lKwSlgYMT mmc_pubLK8XJk3

aquamacho1 commented 1 year ago

mmc_kBbNsN0IXe

This is it then?, its locked by my motherboard, and there is no way to patch this right?

xCuri0 commented 1 year ago

@aquamacho1 4G decoding is on ? if you were getting resources error in windows with 4g decoding on that means the BIOS is still allocating the device properly and can be fixed with DSDT. otherwise it's very hard to fix (BIOS patching)

aquamacho1 commented 1 year ago

@xCuri0 problem is i didn`t got to windows a single time after 1G size increase, mobo just boot loops or gets stuck at boot with black screen

4G decoding is on ?

Well, in the grub console it shows 0x01, so i think it is, unless 4G Decode is broken on this board.

aquamacho1 commented 1 year ago

@xCuri0 can you help me figure out what do i put in these? i have two of them, one is _Y05 and another is _Y0B, both are the same 0x0000000000000000 values.

                    0x0000000000000000, // Granularity - judging by another values in the file, i leave this as is
                    0x0000000000000000, // Range Minimum - what do i put here ?
                    0x0000000000000000, // Range Maximum - here 
                    0x0000000000000000, // Translation Offset - leave this as is 
                    0x0000000000000000, // Length - and here ?

My cpu address size are 46 bits physical, 48 bits virtual Do i ever try this ?

xCuri0 commented 1 year ago

If you can't POST DSDT edit won't help. It only will help if you have problems booting Windows (with Linux working). I'm not sure about those DSDT values I've only edited the CreateQWordField stuff

aquamacho1 commented 1 year ago

@xCuri0 Yep, you right. I think those 0x0000000000000000 values is not the problem. I"ve just checked DSDT file from mobo in #1 post. That X79 Supermicro x9dri-ln4f+ had working ReBAR, but has the same exact values as mine (in the AmiBoardInfo region) and the rest X79 bioses that i`ve checked. I think key is that it has MMIOH in it (that you can change), i think this is the problem, or smth else that i dont know.

aquamacho1 commented 1 year ago

I completely forgot to mention that i 've used REBAR Legacy On.reg file, without it there are no option to enable bar in amd control panel. Im done trying stuff for now, maybe someone will eventually figure this out. Also, maybe presence of iGPU on the mobo plays a role here somehow.

aquamacho1 commented 1 year ago

@xCuri0 soooo i've checked mine PCIBus.efi file, it looks alright, any ideas?

Can you clarify, if gpu-z shows 2 bars, that means its not working properly or at all right?

javaw_eFast86prF

aquamacho1 commented 1 year ago

@xCuri0 Can you please make a screenshot like above of a region where PciHostBridge patch is supposed to be, i will check my PciRootBridge.

# PciHostBridge | Remove <4GB BAR size limit in SubmitResources (Ivy Bridge)

xCuri0 commented 1 year ago

I don't think that's the cause. 2GB would work then

You can download the BIOS for an Ivy bridge mobo with the code such as B75M-D3H or P8Z77-V Pro and extract the PE32 module from PciHostBridge with UEFITool to see it.

aquamacho1 commented 1 year ago

@xCuri0 so i think i maybe found the problem in my case, on my mobo ReBarUEFI driver is allocating its space not from virtual space, but from System Board Resources instead

            Device (IOH)
            {
                Name (_HID, EisaId ("PNP0C01") /* System Board */)  // _HID: Hardware ID
                Name (_UID, 0x0A)  // _UID: Unique ID
                Name (IOHM, ResourceTemplate ()
                {
                    Memory32Fixed (ReadWrite,
                        0xFC000000,         // Address Base
                        0x01000000,         // Address Length
                        )
                    Memory32Fixed (ReadWrite,
                        0xFD000000,         // Address Base
                        0x01000000,         // Address Length
                        )
                    Memory32Fixed (ReadWrite,
                        0xFE000000,         // Address Base
                        0x00B00000,         // Address Length
                        )
                    Memory32Fixed (ReadWrite,
                        0xFEB00000,         // Address Base
                        0x00100000,         // Address Length
                        )
                    Memory32Fixed (ReadWrite,
                        0xFED00400,         // Address Base
                        0x0003FC00,         // Address Length
                        )
                    Memory32Fixed (ReadWrite,
                        0xFED45000,         // Address Base
                        0x000BB000,         // Address Length
                        )

Those two sections is what appears to be my ReBAR values (1GB and 256M respectively)

                    Memory32Fixed (ReadWrite,
                        0xFEB00000,         // Address Base
                  -->   0x00100000,         // Address Length
                        )
                    Memory32Fixed (ReadWrite,
                        0xFED00400,         // Address Base
                  -->   0x0003FC00,         // Address Length
                        )
aquamacho1 commented 1 year ago

And i think this section probably is what responsible for mine problems booting bigger ReBAR values.

                    Memory32Fixed (ReadWrite,
                        0x00000000,         // Address Base
                        0x00000000,         // Address Length
                        _Y0C)
                })
                Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
                {
                    If (LAPB)
                    {
                        CreateDWordField (IOHM, \_SB.PCI0.IOH._Y0C._BAS, APB)  // _BAS: Base Address
                        CreateDWordField (IOHM, \_SB.PCI0.IOH._Y0C._LEN, APL)  // _LEN: Length
                        APB = LAPB /* \LAPB */
                        APL = LAPL /* \LAPL */
                    }

                    Return (IOHM) /* \_SB_.PCI0.IOH_.IOHM */
                }
            }

This code is missing on Jingsha and supermicro boards.

Also, i think another reason is to do with this name IOHM:

Device (IOH)
            {
                Name (_HID, EisaId ("PNP0C01") /* System Board */)  // _HID: Hardware ID
                Name (_UID, 0x0A)  // _UID: Unique ID
                Name (IOHM, ResourceTemplate ()
                {

Mine X79 - Name (IOHM, ResourceTemplate () Jingsha X79M-S - Name (_CRS, ResourceTemplate () Supermicro - Name (_CRS, ResourceTemplate ()

IOHM is not used anywhere but in this script and name.

aquamacho1 commented 1 year ago

@xCuri0 when im trying rebuild DSDT.dsl, im getting so much errors, do you by any chance know why there are so many? This is was stock file without any changes after decompile. Maximum error count (200) exceeded badcode.zip

WindowsTerminal_oRxv6coRaV

xCuri0 commented 1 year ago

@aquamacho1 you have to manually fix each error which isn't easy tbh especially when there are so many. my DSDT only had 2 and were fixable with a few google searches.

aquamacho1 commented 1 year ago

@xCuri0 i can't find any of the code from badcode file in the stock file O_o, there is something wrong here. Oh wait, nvm i'm trolling, badcode came with iasl :D, but still. Okay, progress, using iasl from 2013~ish, there now only 12 errors.

aquamacho1 commented 1 year ago

@xCuri0 i did compiled DSDT with both 2013 and 2022 IASL without an errors, but resulting files are identical to decompiled. Amiboardinfotool creates amiboardinfo.efi from compiled before DSDT, but its 325kb in size and its has some spagetti code at the beginning and the rest is similar to decompiled. I give up :( If someone will develop or want to try something, i can be guinea pig for testing.

aquamacho1 commented 1 year ago

Update: So from MacOS using MaciASL in legacy mode i`ve edited and recompiled DSDT with those lines removed/edited below and some more, but no luck, these related to something else i guess. https://github.com/xCuri0/ReBarUEFI/issues/9#issuecomment-1311420328 https://github.com/xCuri0/ReBarUEFI/issues/9#issuecomment-1311438724

xCuri0 commented 1 year ago

@aquamacho1 to my knowledge DSDT editing won't solve problems where you can't even POST. Only if you can't boot OS or OS gives no resources error it can help

aquamacho1 commented 1 year ago

@xCuri0 i was thinking about replacing PCIBus or Rootbridge\other drivers from another mobo, but im scared it may cause damage to the board or gpu :(

aquamacho1 commented 1 year ago

@xCuri0 do you know if there is a way to modify PciRootBridge anyhow? i mean if there no way to edit those, its over for my board, i think problem in my case is MMIO code is missing from PciRootBridge and IvtQpiandMrcInit. All other X79 boards on which ReBAR works have this part in bios, and on your board and X99 and up it works because memory values already in 64bit. Huanan and Supermicro X79 boards have auto adjust MMIO values at startup in PciRootBridge:

javaw_P4NsYcETMo

javaw_Fh2kirycXd

javaw_xhIhV3osbO

This part is probably why i have no boot after entering values above 1GB.

javaw_muxC0bJEIK There is like 10KB of code is missing in PciRootBridge my case.

xCuri0 commented 1 year ago

@aquamacho1 the problem is it's not allocating addresses in the 64-bit region. i don't know anything about modifying PciRootBridge though

XManPro79 commented 1 year ago

Just a consideration...while the x79 platform supports PCIE 3.0... the 3930K supports only PCIe 2.0 as per the Ark website; try using a 22nm chip that supports PCIe 3.0 and you may get your ReBAR working. It does require 3.0 as far as I understand.

xCuri0 commented 1 year ago

@XManPro79 PCIe Gen3 isn't needed for rebar. Rebar does work here but not at full size because of firmware bug

aquamacho1 commented 1 year ago

Well, out of complete boredom, and after AMD borked my 1G rebar, i have returned to this, and i have some progress: Edited DSDT again, this time using tutorial from rebar wiki like this:

            QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
                0x0000000000000000, // Granularity
                0x0000008000000000, // Range Minimum
                0x000000FFFFFFFFFF, // Range Maximum
                0x0000000000000000, // Translation Offset
                0x0000008000000000, // Length
                ,, _Y05, AddressRangeMemory, TypeStatic)

And

            QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
                0x0000000000000000, // Granularity
                0x0000000000010000, // Range Minimum
                0x00000000000FFFFF, // Range Maximum
                0x0000000000000000, // Translation Offset
                0x0000000000010000, // Length
                ,, _Y0B, AddressRangeMemory, TypeStatic)

And now i have this: Безымянный And my sound from Realtek onboard audio is gone. But i still can`t enable rebar larger than 1G

Any ideas @xCuri0 ?

aquamacho1 commented 1 year ago

So i need to move GPU and PCI to PCI bridge to Large memory like this right? image Or these two will move to large memory after changing rebar to smth larger than 1G on their own?