Version 0.0.78

process.c(234) 

Segment register es is set to the same as ds and ss in _ret_from_syscall.
It's not saved on entry to _syscall_int either.

Hmm, looking at that it needs somebody to go through one instruction at
a time very carefully. Eg AX and SI are stashed in the code segment,
they could be stashed in the DS. Interrupts don't have to be
disabled 'cause you can use the SS feature:
   mov  ss,ax
   mov  sp,[bx]

In fact by judicious use of the stack and '__segoff' you probably don't
need any code segment stashing ... except I'm a little confused where
the user registers are stored, there's space in the task struct but
it looks like it isn't being used ?

FX: A little later:  I've attached a new insertion in process.c for you
    lot to destroy ..

-- 
Rob.                          (Robert de Bath <http://poboxes.com/rdebath>)
                    <rdebath @ poboxes.com> <http://www.cix.co.uk/~mayday>

On Tue, 3 Aug 1999, Greg Haerr wrote:

> : One other thing I noticed is that you trash the es register, the C library
> : treats this as callee saves, like si & di, but if I do that round every
> : int $80 it'll go an defeat this vfork() thing :-)
> : 
>       It's important that the ELKS kernel save all segment registers
> and si, di, just like the C library standard.  I thought I looked thru irq.c
> and irqtab.c and found that es is saved.  Where do you notice
> that it's trashed?
> 
> Greg
> 
!
!       System Call Vector
!
!       On entry we are on the wrong stack, DS, ES are wrong
!

        .globl _syscall_int
!
!       System calls enter here with ax as function and bx,cx,dx as
!       parameters (and di,si if elks_syscall in elksemu is to be believed)
!       syscall returns a value in ax
!
_syscall_int:
!
!       We know the process DS, we can discard it (indeed may change it)
!
        push ax
        push bx
        mov ax,cs
        add ax,#__segoff
        mov ds,ax
!
!       Find our TCB
!
        mov bx,_current
!
!       Stash user mode stack - needed for stack checking!
!
        pop 8[bx]
        pop 6[bx]
        mov 2[bx],sp
        mov 20[bx],es
!
!       Finish switching to the right things
!
        mov ss,ax
        mov sp,[bx]

        mov es,ax
        cld
!
!       Stack is now right, we can take interrupts OK
!
        sti
        push    si
        push    di
        push    dx
        push    cx
        push    8[bx]           ! saved bx
        mov     ax,6[bx]        ! restore ax
#ifdef CONFIG_STRACE
!
!       strace(syscall#, params...)
!

Reply via email to