All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: ACPI: preserve the ebx value in acpi_copy_wakeup_routine
@ 2007-06-01 10:09 Zhang Rui
  2007-06-01 10:17 ` Pavel Machek
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang Rui @ 2007-06-01 10:09 UTC (permalink / raw)
  To: linux-acpi; +Cc: lenb, pavel, kevin.tian

From: Tian Kevin <kevin.tian@intel.com>

Register %ebx serves as the "global offset table base register"
for position-independent code. For absolute code, %ebx serves
as a local register and has no specified role in the function
calling sequence. In either case, a function must preserve the
register value for the caller.

acpi_copy_wakeup_routine overrides %ebx without saving it,
this may corrupt the called data.

Kevin found that most time the value of Sx is saved in %esi,
however sometimes compiler also uses %ebx. When this happens,
suspends fails since sleep value in ebx is changed by
acpi_copy_wakeup_routine.

The same funtion in X86_64 doesn't have this problem.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 arch/i386/kernel/acpi/wakeup.S |    2 ++
 1 files changed, 2 insertions(+)

Index: linux-2.6.22-rc3/arch/i386/kernel/acpi/wakeup.S
===================================================================
--- linux-2.6.22-rc3.orig/arch/i386/kernel/acpi/wakeup.S	2007-05-31 17:23:56.000000000 +0800
+++ linux-2.6.22-rc3/arch/i386/kernel/acpi/wakeup.S	2007-05-31 17:24:08.000000000 +0800
@@ -230,6 +230,7 @@ bogus_magic:
 #
 ENTRY(acpi_copy_wakeup_routine)
 
+	pushl	%ebx
 	sgdt	saved_gdt
 	sidt	saved_idt
 	sldt	saved_ldt
@@ -263,6 +264,7 @@ ENTRY(acpi_copy_wakeup_routine)
 	movl	%edx, video_flags - wakeup_start (%eax)
 	movl	$0x12345678, real_magic - wakeup_start (%eax)
 	movl	$0x12345678, saved_magic
+	popl	%ebx
 	ret
 
 save_registers:

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

* Re: [PATCH]: ACPI: preserve the ebx value in acpi_copy_wakeup_routine
  2007-06-01 10:09 [PATCH]: ACPI: preserve the ebx value in acpi_copy_wakeup_routine Zhang Rui
@ 2007-06-01 10:17 ` Pavel Machek
  2007-06-01 10:27   ` Zhang, Rui
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2007-06-01 10:17 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-acpi, lenb, kevin.tian

Hi!

> From: Tian Kevin <kevin.tian@intel.com>
> 
> Register %ebx serves as the "global offset table base register"
> for position-independent code. For absolute code, %ebx serves
> as a local register and has no specified role in the function
> calling sequence. In either case, a function must preserve the
> register value for the caller.
> 
> acpi_copy_wakeup_routine overrides %ebx without saving it,
> this may corrupt the called data.
> 
> Kevin found that most time the value of Sx is saved in %esi,
> however sometimes compiler also uses %ebx. When this happens,
> suspends fails since sleep value in ebx is changed by
> acpi_copy_wakeup_routine.
> 
> The same funtion in X86_64 doesn't have this problem.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Looks okay to me. That routine also corrupts ecx and edx, hopefully
that's okay?
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* RE: [PATCH]: ACPI: preserve the ebx value in acpi_copy_wakeup_routine
  2007-06-01 10:17 ` Pavel Machek
@ 2007-06-01 10:27   ` Zhang, Rui
  2007-06-04 10:37     ` Pavel Machek
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Rui @ 2007-06-01 10:27 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-acpi, lenb, Tian, Kevin

According to the SYSTEM V APPLICATION BINARY INTERFACE,
Intel386 Architecture:
"ecx and edx: Scratch registers have no specified role in the standard calling
sequence. Functions do not have to preserve their values for the
caller."

Best regards,
Zhang.Rui(Ray)

 
-----Original Message-----
From: Pavel Machek [mailto:pavel@ucw.cz] 
Sent: 2007年6月1日 18:17
To: Zhang, Rui
Cc: linux-acpi@vger.kernel.org; lenb@kernel.org; Tian, Kevin
Subject: Re: [PATCH]: ACPI: preserve the ebx value in acpi_copy_wakeup_routine

Hi!

> From: Tian Kevin <kevin.tian@intel.com>
> 
> Register %ebx serves as the "global offset table base register"
> for position-independent code. For absolute code, %ebx serves
> as a local register and has no specified role in the function
> calling sequence. In either case, a function must preserve the
> register value for the caller.
> 
> acpi_copy_wakeup_routine overrides %ebx without saving it,
> this may corrupt the called data.
> 
> Kevin found that most time the value of Sx is saved in %esi,
> however sometimes compiler also uses %ebx. When this happens,
> suspends fails since sleep value in ebx is changed by
> acpi_copy_wakeup_routine.
> 
> The same funtion in X86_64 doesn't have this problem.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Looks okay to me. That routine also corrupts ecx and edx, hopefully
that's okay?
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH] ACPI: preserve the ebx value in acpi_copy_wakeup_routine
@ 2007-06-02 22:11 Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2007-06-02 22:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Pavel Machek, Len Brown, Tian Kevin, Zhang Rui, Pavel Machek,
	LKML, Andi Kleen

From: Tian Kevin <kevin.tian@intel.com>

Register %ebx serves as the "global offset table base register"
for position-independent code. For absolute code, %ebx serves
as a local register and has no specified role in the function
calling sequence. In either case, a function must preserve the
register value for the caller.

acpi_copy_wakeup_routine overrides %ebx without saving it,
this may corrupt the called data.

Kevin found that most time the value of Sx is saved in %esi,
however sometimes compiler also uses %ebx. When this happens,
suspends fails since sleep value in ebx is changed by
acpi_copy_wakeup_routine.

The same funtion in X86_64 doesn't have this problem.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Looks-okay-to: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 arch/i386/kernel/acpi/wakeup.S |    2 ++
 1 files changed, 2 insertions(+)

Index: linux-2.6.22-rc3/arch/i386/kernel/acpi/wakeup.S
===================================================================
--- linux-2.6.22-rc3.orig/arch/i386/kernel/acpi/wakeup.S	2007-05-31 17:23:56.000000000 +0800
+++ linux-2.6.22-rc3/arch/i386/kernel/acpi/wakeup.S	2007-05-31 17:24:08.000000000 +0800
@@ -230,6 +230,7 @@ bogus_magic:
 #
 ENTRY(acpi_copy_wakeup_routine)
 
+	pushl	%ebx
 	sgdt	saved_gdt
 	sidt	saved_idt
 	sldt	saved_ldt
@@ -263,6 +264,7 @@ ENTRY(acpi_copy_wakeup_routine)
 	movl	%edx, video_flags - wakeup_start (%eax)
 	movl	$0x12345678, real_magic - wakeup_start (%eax)
 	movl	$0x12345678, saved_magic
+	popl	%ebx
 	ret
 
 save_registers:
-

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

* Re: [PATCH]: ACPI: preserve the ebx value in acpi_copy_wakeup_routine
  2007-06-01 10:27   ` Zhang, Rui
@ 2007-06-04 10:37     ` Pavel Machek
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2007-06-04 10:37 UTC (permalink / raw)
  To: Zhang, Rui; +Cc: linux-acpi, lenb, Tian, Kevin

Hi!

> According to the SYSTEM V APPLICATION BINARY INTERFACE,
> Intel386 Architecture:
> "ecx and edx: Scratch registers have no specified role in the standard calling
> sequence. Functions do not have to preserve their values for the
> caller."

Thanks for confirming.
								Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

end of thread, other threads:[~2007-06-04 10:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-01 10:09 [PATCH]: ACPI: preserve the ebx value in acpi_copy_wakeup_routine Zhang Rui
2007-06-01 10:17 ` Pavel Machek
2007-06-01 10:27   ` Zhang, Rui
2007-06-04 10:37     ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2007-06-02 22:11 [PATCH] " Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.