public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.23-rc1] APM detection logic bug fix
@ 2007-07-23 22:25 Mikael Pettersson
  2007-07-23 22:34 ` H. Peter Anvin
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael Pettersson @ 2007-07-23 22:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: H. Peter Anvin

Starting with kernel 2.6.23-rc1, the i386 APM driver fails
on several of my machines with the message:

apm: BIOS not found

This happens because of a bug in the i386 boot code rewrite
from assembler to C. The original assembly code had the
following code in its APM BIOS presence test (boot/setup.S):

	andw	$0x02, %cx			# Is 32 bit supported?
	je	done_apm_bios			# No 32-bit, no (good) APM BIOS

That is, the code bails out if bit 2 is zero.

In the new C version, this is coded as (boot/apm.c):

	if (cx & 0x02)		/* 32 bits supported? */
		return -1;

Here we see that the test has been accidentally inverted.

The fix is to negate the test. I've verified that this
allows the APM driver to work again on my affected machines.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>

diff -rupN linux-2.6.23-rc1/arch/i386/boot/apm.c linux-2.6.23-rc1.apm-detect-fix/arch/i386/boot/apm.c
--- linux-2.6.23-rc1/arch/i386/boot/apm.c	2007-07-23 02:32:03.000000000 +0200
+++ linux-2.6.23-rc1.apm-detect-fix/arch/i386/boot/apm.c	2007-07-23 23:51:17.000000000 +0200
@@ -40,7 +40,7 @@ int query_apm_bios(void)
 	if (bx != 0x504d)	/* "PM" signature */
 		return -1;
 
-	if (cx & 0x02)		/* 32 bits supported? */
+	if (!(cx & 0x02))		/* 32 bits supported? */
 		return -1;
 
 	/* Disconnect first, just in case */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2.6.23-rc1] APM detection logic bug fix
  2007-07-23 22:25 [PATCH 2.6.23-rc1] APM detection logic bug fix Mikael Pettersson
@ 2007-07-23 22:34 ` H. Peter Anvin
  0 siblings, 0 replies; 2+ messages in thread
From: H. Peter Anvin @ 2007-07-23 22:34 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: linux-kernel

Mikael Pettersson wrote:
> Starting with kernel 2.6.23-rc1, the i386 APM driver fails
> on several of my machines with the message:
> 
> apm: BIOS not found
> 
> This happens because of a bug in the i386 boot code rewrite
> from assembler to C. The original assembly code had the
> following code in its APM BIOS presence test (boot/setup.S):
> 
> 	andw	$0x02, %cx			# Is 32 bit supported?
> 	je	done_apm_bios			# No 32-bit, no (good) APM BIOS
> 
> That is, the code bails out if bit 2 is zero.
> 
> In the new C version, this is coded as (boot/apm.c):
> 
> 	if (cx & 0x02)		/* 32 bits supported? */
> 		return -1;
> 
> Here we see that the test has been accidentally inverted.
> 
> The fix is to negate the test. I've verified that this
> allows the APM driver to work again on my affected machines.
> 
> Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
> 

Thanks, applied.

	-hpa

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-23 22:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23 22:25 [PATCH 2.6.23-rc1] APM detection logic bug fix Mikael Pettersson
2007-07-23 22:34 ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox