Ignore:
Timestamp:
Feb 10, 2009, 3:01:57 AM (12 years ago)
Author:
gb
Message:

Try to handle the case of suspending a Windows thread that's in the
middle of restore_windows_context() more sanely/completely, especially
on win32.

Move the code that's concerned with this into a separate function
(pc_luser_restore_windows_context), which always overwrites some or
all of the context as of thread suspend with the context that the
suspended thread is trying to restore (e.g., whatever pc-lusering
we do always has the effect of causing the thread to resume at the
point where restore_windows_context() would have completed.

Since restore_windows_context() is only used to return from an
exception, clear tcr->pending_exception_context when we've got
things to a known point.

Define ia32_iret_frame in x86-constants32.h.

Use iret to restore flags/cs:eip on ia32.

Ensure that the last thing that win32_restore_context() does before
the iret is to reload %rcx/%ecx from the context (kept in %rcx/%ecx),
so suspending in the middle of restore_lisp_context() - before the iret -
just has to find the context being restored in %rcx/%ecx (it doesn't
matter where we are in the process of restoring it.)

If we're at the iret, just emulate the (machine-specific) effects of
the iret.

Need to make sure that this isn't grossly broken on win64, and need
to look at interrupt (vice suspend) code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/x86-asmutils64.s

    r11695 r11710  
    265265        __(movq win64_context.R14(%rcx),%r14)
    266266        __(movq win64_context.R15(%rcx),%r15)
    267 Xrestore_windows_context_load_rcx:               
     267        /* This must be the last thing before the iret, e.g., if we're
     268        interrupted before the iret, the context we're returning to here
     269        is still in %rcx.  If we're interrupted -at- the iret, then
     270        everything but that which the iret will restore has been restored. */
    268271        __(movq win64_context.Rcx(%rcx),%rcx)
    269272Xrestore_windows_context_iret:           
     
    284287        .globl C(restore_windows_context_start)
    285288        .globl C(restore_windows_context_end)
    286         .globl C(restore_windows_context_load_rcx)
    287289        .globl C(restore_windows_context_iret)
    288290C(restore_windows_context_start):  .quad Xrestore_windows_context_start
    289291C(restore_windows_context_end): .quad Xrestore_windows_context_end
    290 C(restore_windows_context_load_rcx):  .quad Xrestore_windows_context_load_rcx
    291292C(restore_windows_context_iret): .quad Xrestore_windows_context_iret
    292293        .text
Note: See TracChangeset for help on using the changeset viewer.