Skip to content

Commit 10b7a85

Browse files
committed
[FREELDR] Fix the DPTE validity check, addendum to commit 4190b48
Which is also an addendum to commit b3f11cf (r17484). The Enhanced Disk Drive Specification tells us that if the (far) pointer to the Device Parameter Table Extension is set to FFFF:FFFF, the pointer is invalid. However there are some BIOSes, incl UEFI ones when running in Legacy mode (e.g. GIGABYTE UEFI DualBIOS), that set this pointer to 0000:0000 instead, which is also an invalid value.
1 parent 4ffe8e8 commit 10b7a85

File tree

1 file changed

+4
-2
lines changed
  • boot/freeldr/freeldr/arch/i386/pc

1 file changed

+4
-2
lines changed

boot/freeldr/freeldr/arch/i386/pc/pcdisk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,10 @@ DiskGetExtendedDriveParameters(
346346
if (Ptr[0] >= 0x1e)
347347
{
348348
// Ptr[13]: offset, Ptr[14]: segment
349-
TRACE("EDD configuration parameters: %x:%x\n", Ptr[14], Ptr[13]);
350-
if (Ptr[13] != 0xffff && Ptr[14] != 0xffff)
349+
TRACE("EDD configuration parameters (DPTE): %x:%x\n", Ptr[14], Ptr[13]);
350+
/* The DPTE pointer is valid if it's != FFFF:FFFF (per the Enhanced Disk
351+
* Drive Specification), but also, when it's != 0000:0000 (broken BIOSes) */
352+
if (!(Ptr[13] == 0xFFFF && Ptr[14] == 0xFFFF) && !(Ptr[13] == 0 && Ptr[14] == 0))
351353
{
352354
PUCHAR SpecPtr = (PUCHAR)(ULONG_PTR)((Ptr[14] << 4) + Ptr[13]);
353355
TRACE("SpecPtr: 0x%x\n", SpecPtr);

0 commit comments

Comments
 (0)