From: Michael Chang Date: Tue, 1 Dec 2015 15:49:38 +0000 (+0300) Subject: i386: fix TSC calibration using PIT X-Git-Tag: 2.02-beta3~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a03c1034f6062e69075056c8f31b90e159ce5244;p=thirdparty%2Fgrub.git i386: fix TSC calibration using PIT Condition was accidentally reversed, so PIT calibration always failed when PIT was present and always succeeded when PIT was missing, but in the latter case resulted in absurdly fast clock. Reported and tested by Vitaly Kuznetsov --- diff --git a/grub-core/kern/i386/tsc_pit.c b/grub-core/kern/i386/tsc_pit.c index 0c0488c1b..67990bfa6 100644 --- a/grub-core/kern/i386/tsc_pit.c +++ b/grub-core/kern/i386/tsc_pit.c @@ -49,7 +49,7 @@ grub_pit_wait (void) | GRUB_PIT_SPK_TMR2, GRUB_PIT_SPEAKER_PORT); - if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) { + if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00) { ret = 1; /* Wait. */ while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00);