Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[modrom] Avoid clobbering near jump with checksum
A jump instruction starts at the third byte of an option ROM image, and
it is required that the bytes in the whole image add up to zero. To
achieve this, a checksum byte is usually placed after the jump. The jump
can be either a short jump (2 bytes, EB xx) or a near jump (3 bytes,
E9 xx xx). gPXE's romprefix.S uses a near jump, but modrom.pl assumed
a short jump, and clobbered the high byte of the offset. This caused
modrom-modified gPXE ROM images to crash the system during POST.

Fix by making modrom.pl place the checksum at byte 6, like makerom.pl does.

Signed-off-by: Marty Connor <mdc@etherboot.org>
  • Loading branch information
rwcr authored and Marty Connor committed Oct 15, 2009
1 parent 3fa2779 commit b0b0b8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/modrom.pl
Expand Up @@ -131,9 +131,9 @@ ($$)
sub checksum ($) {
my ($romref) = @_;

substr($$romref, 5, 1) = "\x00";
substr($$romref, 6, 1) = "\x00";
my $sum = unpack('%8C*', $$romref);
substr($$romref, 5, 1) = chr(256 - $sum);
substr($$romref, 6, 1) = chr(256 - $sum);
# Double check
$sum = unpack('%8C*', $$romref);
if ($sum != 0) {
Expand Down

0 comments on commit b0b0b8f

Please sign in to comment.