Fix stack handling in acpi_wakeup.S

Fix stack handling in acpi_wakeup.S

Post by Pavel Mache » Thu, 13 Feb 2003 23:00:13



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

--- clean/arch/i386/kernel/acpi_wakeup.S        2003-02-11 17:40:33.000000000 +0100

        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)


        .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:

 ENTRY(do_suspend_lowlevel)
        cmpl $0,4(%esp)
-       jne .L1432
+       jne ret_point
        call save_processor_state


        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

        addl $4,%esp
        ret
        .p2align 4,,7
-.L1432:
+ret_point:
        movl $__KERNEL_DS,%eax
        movw %ax, %ds
        movl saved_context_esp, %esp

--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Fix stack handling in acpi_wakeup.S

Post by David Woodhous » Fri, 14 Feb 2003 21:50:26



> 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:

--- arch/i386/kernel/acpi.c.orig        Thu Feb 13 19:07:34 2003

        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.

--
dwmw2
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Fix stack handling in acpi_wakeup.S

Post by Alfred E. Heggesta » Sun, 16 Feb 2003 14:20:12


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


> 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

> --- clean/arch/i386/kernel/acpi_wakeup.S   2003-02-11 17:40:33.000000000 +0100
> +++ linux/arch/i386/kernel/acpi_wakeup.S   2003-02-11 12:51:03.000000000 +0100

>    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

>    .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

>  ENTRY(do_suspend_lowlevel)
>    cmpl $0,4(%esp)
> -  jne .L1432
> +  jne ret_point
>    call save_processor_state

>    movl %esp, saved_context_esp

>    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

>    addl $4,%esp
>    ret
>    .p2align 4,,7
> -.L1432:
> +ret_point:
>    movl $__KERNEL_DS,%eax
>    movw %ax, %ds
>    movl saved_context_esp, %esp

--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Fix stack handling in acpi_wakeup.S

Post by Pavel Mache » Sun, 16 Feb 2003 20:00:16


Hi!

Quote:> 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.
--
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
 
 
 

1. acpi_wakeup fixes: Patch?

It seems you have been trying to correct the acpi_wakeup code (back at 17
Dec). Has that been merged to Linus' tree?

I got 2.5.58 today, acpi_wakeup.S is still dated 16 Dec and that patch
regarding the location of the wakeup asm code (see the '2.5.51: sleep
broken') has not reached me through Linus' patches.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Basic network / routing question

3. acpi_wakeup fixes

4. telnetd fails opening pty, "all network ports in use

5. Handling stack-overflow?

6. VT220 and VT320 Termcap Entries

7. SIGnal handling and stacking in UNIX.

8. Help: My Sun does not show up in the XDM chooser anymore ....

9. Long standing bug in alternate stack handling

10. Custom SIGSEGV handler for handling stack pointer overwrites

11. How is the KeepAliveTime in the TCP/IP protocol stack handled in Linux?

12. fixing module autoload stacking

13. [0/1] acpi_wakeup.S