Ignore:
Timestamp:
Apr 8, 2017, 12:26:55 AM (8 years ago)
Author:
Ben Rietbroek
Message:

Prevent LVM CRC-check indicating OK on zero sectors [v1.1.1-testing]

When 'LVM_InitCRCTable' is not called yet, an LVM CRC-check on a sector
with all zeros would indicate a valid LVM CRC. Eventhough this is not
the case _after_ 'LVM_InitCRCTable' has been called, we rule out this
situation to guard agains coding bugs.

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bootcode/regular/other.asm

    r95 r101  
    562562        ret
    563563MBR_TeletypeSyncPos     EndP
     564
     565; Check if a memory block is all zeros
     566; IN  : BX pointer to memblock
     567;       CX length to check, zero length is interpreted as block is zero
     568; OUT : ZF=1 block if all zeros
     569; NOTE: Segment used is DS, which should be the same as ES
     570IsMemBlockZero  Proc    Near    Uses ax di
     571        push    es          ; Save ES just to be sure
     572        push    ds          ; Segment to use
     573        pop     es          ; Pop in ES because ES is required for scasb
     574        mov     di, bx      ; Pointer to memblock
     575        xor     al, al      ; Compare to zero
     576        repe    scasb       ; Scan the block, will leave ZF=1 if all zeros
     577        mov     bx, di      ; Update pointer (points past last byte compared)
     578        pop     es          ; Restore ES
     579        ret
     580IsMemBlockZero  EndP
     581
     582; Check if a loaded sector is all zeros
     583; IN  : BX pointer to memblock
     584; OUT : ZF=1 block if all zeros
     585; NOTE: Segment used is DS, which should be the same as ES
     586IsSectorZero    Proc    Near    Uses cx
     587        mov     cx, sector_size ; Normal size of a sector (512 bytes)
     588        call    IsMemBlockZero  ; Check the memory block
     589        ret
     590IsSectorZero    EndP
Note: See TracChangeset for help on using the changeset viewer.