From 30eee293292080dcf72ed2a4ac48efc3e13d1f40 Mon Sep 17 00:00:00 2001 From: Rohan Bafna Date: Tue, 26 Aug 2025 17:29:16 -0400 Subject: [PATCH] Fix off-by-one error in the record count returned by do_e820 %ebx is set to 0 when the last e820 record is returned, which means that %bp was not incremented for the last record; this change moves the increment of %bp to earlier in the function, before %ebx is tested, and after the magic number returned by e820 is checked, so that %bp is incremented once for every entry. Also move the test for %ecx=0 (meaning the entry should be skipped) for correctness. It doesn't look like qemu ever actually sets %ecx to 0 in practice though. --- bootblock/e820.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootblock/e820.S b/bootblock/e820.S index 68f19f9..24dca78 100644 --- a/bootblock/e820.S +++ b/bootblock/e820.S @@ -53,11 +53,11 @@ do_e820: cmp %edx, %eax jne .e820f + jcxz .skipent + inc %bp test %ebx, %ebx je .e820f - jcxz .skipent cmp $20, %cl - inc %bp add $24, %di .skipent: test %ebx, %ebx -- 2.47.3