wyoos icon indicating copy to clipboard operation
wyoos copied to clipboard

Probable bug in gdt.cpp

Open sorjon02 opened this issue 7 years ago • 5 comments

Line 35 in gdt.cpp reads: "if (limit <= 65536)". This is a reference to a memory adress, and a memory adress always start at 0. I recognize the number 65536 as 2^16 so the correct line should probably be "if (limit < 65536)", allowing for memory address from 0 to 65535. Please examine the code and check if I have noticed a bona fide bug.

sorjon02 avatar May 12 '17 18:05 sorjon02

Not a bug from what I can tell. The GDT and IDT have a limit that is unique. The value 1 needs to be subtracted from the real limit (per the Intel documentation). GDT and IDT are designed so that a limit of 0 isn't possible. He checks that the pre-adjusted limit <= 65536. 65536 will be stored as 65536-1 (65535).

mpetch avatar Apr 30 '18 12:04 mpetch