Skip to content

Commit 7ad37df

Browse files
author
H. Peter Anvin
committed
[x86 setup] VGA: Clear the Protect bit before setting the vertical height
If the user has asked for the vertical height registers to be recomputed by setting bit 15 in the video mode number, we do so without clearing the Protect bit in the Vertical Retrace Register before setting the Overflow register. As a result, if the VGA BIOS had set the Protect bit, the write to the Overflow register will be dropped, and bits [9:8] of the vertical height will be left unchanged. This is a bug imported from the assembly version of this code. It was pointed out by Etienne Lorrain. Cc: Etienne Lorrain <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 5593eaa commit 7ad37df

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/i386/boot/video.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static void vga_recalc_vertical(void)
195195
{
196196
unsigned int font_size, rows;
197197
u16 crtc;
198-
u8 ov;
198+
u8 pt, ov;
199199

200200
set_fs(0);
201201
font_size = rdfs8(0x485); /* BIOS: font size (pixels) */
@@ -206,7 +206,12 @@ static void vga_recalc_vertical(void)
206206

207207
crtc = vga_crtc();
208208

209+
pt = in_idx(crtc, 0x11);
210+
pt &= ~0x80; /* Unlock CR0-7 */
211+
out_idx(pt, crtc, 0x11);
212+
209213
out_idx((u8)rows, crtc, 0x12); /* Lower height register */
214+
210215
ov = in_idx(crtc, 0x07); /* Overflow register */
211216
ov &= 0xbd;
212217
ov |= (rows >> (8-1)) & 0x02;

0 commit comments

Comments
 (0)