Skip to contentSkip to conversation

Fix stack handling in acpi_wakeup.S

PATCH Pavel Machek 4 participants 4 messages Feb 12, 2003 – Feb 15, 2003

lore
Share & tools
lore
#0 lore raw

Hi!

This fixes stack handling in acpi_wakeup.S, and makes stack smaller so that wakeup code actually fits inside memory allocated for it. Plus someone renamed .L1432 to something meaningfull. Please apply,
Pavel

arch/i386/kernel/acpi_wakeup.S +9 -7
@@ -31,7 +31,7 @@
 	movw	%cs, %ax
 	movw	%ax, %ds					# Make ds:0 point to wakeup_start
 	movw	%ax, %ss
-	mov	wakeup_stack - wakeup_code, %sp			# Private stack is needed for ASUS board
+	mov	$(wakeup_stack - wakeup_code), %sp		# Private stack is needed for ASUS board
 	movw	$0x0e00 + 'S', %fs:(0x12)
 
 	pushl	$0						# Kill any dangerous flags
@@ -159,12 +159,14 @@
 	.code32
 	ALIGN
 
+.org	0x800
+wakeup_stack_begin:	# Stack grows down
 
-.org	0x2000
+.org	0xff0		# Just below end of page
 wakeup_stack:
-.org	0x3000
 ENTRY(wakeup_end)
-.org	0x4000
+	
+.org	0x1000
 
 wakeup_pmode_return:
 	movl	$__KERNEL_DS, %eax
@@ -274,7 +276,7 @@
 
 ENTRY(do_suspend_lowlevel)
 	cmpl $0,4(%esp)
-	jne .L1432
+	jne ret_point
 	call save_processor_state
 
 	movl %esp, saved_context_esp
@@ -287,7 +289,7 @@
 	movl %edi, saved_context_edi
 	pushfl ; popl saved_context_eflags
 
-	movl $.L1432,saved_eip
+	movl $ret_point,saved_eip
 	movl %esp,saved_esp
 	movl %ebp,saved_ebp
 	movl %ebx,saved_ebx
@@ -299,7 +301,7 @@
 	addl $4,%esp
 	ret
 	.p2align 4,,7
-.L1432:
+ret_point:
 	movl $__KERNEL_DS,%eax
 	movw %ax, %ds
 	movl saved_context_esp, %esp
Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#1 lore raw
Quoted 5 lines · Pavel Machek

Hi!

This fixes stack handling in acpi_wakeup.S, and makes stack smaller so that wakeup code actually fits inside memory allocated for it. Plus someone renamed .L1432 to something meaningfull. Please apply,

I am confused. If I apply your patch, I get a failure to resume (precise symptoms below) on both boards I've tried it on. Applying this obviously broken patch 'fixes' it:

i386/kernel/acpi.c Thu Feb 13 19:07:36 2003 renamed from i386/kernel/acpi.c.orig Thu Feb 13 19:07:34 2003 +1 -1
@@ -483,6 +483,7 @@
        if (!acpi_wakeup_address)
                return 1;
        init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD);
+       memset((void *)acpi_wakeup_address, 0, 0x3000);
        memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end
- &wakeup_start);
        acpi_copy_wakeup_routine(acpi_wakeup_address);

If I reserve the whole three pages I scribble on in the above patch (and which we used to scribble on), by calling alloc_bootmem_low(3*PAGE_SIZE) in acpi_reserve_bootmem(), then the failure to resume returns. I _need_ to scribble on whatever's after us :)

Failure mode is as follows:

Upon resume, _all_ processes with a userspace VM will oops on being rescheduled. In every case, %eip is zero and %esp is the very top of the 8KiB area allocated for the task structure and stack. For example:

portmap left refrigerator

Unable to handle kernel NULL pointer dereference at virtual address

00000000
printing eip:
00000000
*pde = 00000000

Oops: 0000
CPU:    0
EIP:    0060:[<00000000>]    Not tainted
EFLAGS: 00010046

EIP is at 0x0
eax: 000000a8 ebx: 08054db0 ecx: 00000003 edx: ffffffff
esi: 08054db0 edi: 08054db0 ebp: bffffd3c esp: ce14e000
ds: 007b es: 007b ss: 0068
Process portmap (pid: 550, threadinfo=ce14c000 task=ce4f80a0)

Stack:
Call Trace:
                                                                                                                                                      
Code:  Bad EIP value.
Signature · 1 line
dwmw2
#2 lore raw
In reply to Pavel Machek

Hi Pavel

I applied this patch to 2.5.60 and when doing the software suspend it did manage to start the freezing process (process X into refrigerator etc...) but crashed once in ide.c - apologies I do not have any more details and I cannot reproduce that one.

Doing software suspend now will freeze all procs and hang on the last one:

# echo 4 > /proc/acpi/sleep

...
=<proc> entered refrigerator
=| entered refrigerator

-> hang

This happens both with 2.5.60 plus Pavel acpi_wakeup.S patch and vanilla 2.5.61, also with or withour X running.

My machine is a Sony Vaio VX71P, details can be found here:

http://lamis.wyrdweb.com/~alfredh/vaio_vx71p/

/alfred

Quoted 63 lines · Pavel Machek

Hi!

This fixes stack handling in acpi_wakeup.S, and makes stack smaller so that wakeup code actually fits inside memory allocated for it. Plus someone renamed .L1432 to something meaningfull. Please apply,
Pavel

arch/i386/kernel/acpi_wakeup.S +9 -7
@@ -31,7 +31,7 @@
 	movw	%cs, %ax
 	movw	%ax, %ds					# Make ds:0 point to wakeup_start
 	movw	%ax, %ss
-	mov	wakeup_stack - wakeup_code, %sp			# Private stack is needed for ASUS board
+	mov	$(wakeup_stack - wakeup_code), %sp		# Private stack is needed for ASUS board
 	movw	$0x0e00 + 'S', %fs:(0x12)
 
 	pushl	$0						# Kill any dangerous flags
@@ -159,12 +159,14 @@
 	.code32
 	ALIGN
 
+.org	0x800
+wakeup_stack_begin:	# Stack grows down
 
-.org	0x2000
+.org	0xff0		# Just below end of page
 wakeup_stack:
-.org	0x3000
 ENTRY(wakeup_end)
-.org	0x4000
+	
+.org	0x1000
 
 wakeup_pmode_return:
 	movl	$__KERNEL_DS, %eax
@@ -274,7 +276,7 @@
 
 ENTRY(do_suspend_lowlevel)
 	cmpl $0,4(%esp)
-	jne .L1432
+	jne ret_point
 	call save_processor_state
 
 	movl %esp, saved_context_esp
@@ -287,7 +289,7 @@
 	movl %edi, saved_context_edi
 	pushfl ; popl saved_context_eflags
 
-	movl $.L1432,saved_eip
+	movl $ret_point,saved_eip
 	movl %esp,saved_esp
 	movl %ebp,saved_ebp
 	movl %ebx,saved_ebx
@@ -299,7 +301,7 @@
 	addl $4,%esp
 	ret
 	.p2align 4,,7
-.L1432:
+ret_point:
 	movl $__KERNEL_DS,%eax
 	movw %ax, %ds
 	movl saved_context_esp, %esp
Signature · 1 line
Alfred E. Heggestad <[email protected]>
#3 lore raw

Hi!

Quoted 5 lines

I applied this patch to 2.5.60 and when doing the software suspend it did manage to start the freezing process (process X into refrigerator etc...) but crashed once in ide.c - apologies I do not have any more details and I cannot reproduce that one.

this patch has nothing to do with swsusp. I do not know what goes wrong in ide.c, but this patch is for orthogonal issue.

Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.