From: Juan Perez-Sanchez <lithoxs@gmail.com>
To: linux-8086 <linux-8086@vger.kernel.org>
Subject: [PATCH 4 of 5] General improvements to arch dependent code
Date: Tue, 29 May 2012 15:15:31 -0500 [thread overview]
Message-ID: <CAD6VGuY5ppAxi=Lu9wb6ijvuRTjHrXN4NOhV6vRpdCES7UV1wQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 612 bytes --]
Hi,
This patch corrects the following problems.
1. Fixed race condition where static variables "stashed_si" and
"sc_tmp" were used after reenabling interrupts.
2. Made the assembly function "syscall_int" faster, use less code size
and without the need to use the static variables "stashed_si" and
"sc_tmp".
3. Removed unused functions "save_regs" and "load_regs", and the now
unused variables "stashed_si" and "sc_tmp".
There is a reduction of 16 bytes in code size.
The kernel was built and the Image tested in qemu and dioscuri
emulators. Also tested in a ppro pc booting from floppy.
Greetings,
Juan
[-- Attachment #2: elksE.patch --]
[-- Type: application/octet-stream, Size: 4357 bytes --]
diff -Nurb elks.orig/arch/i86/kernel/irqtab.c elks/arch/i86/kernel/irqtab.c
--- elks.orig/arch/i86/kernel/irqtab.c 2012-05-24 16:58:24.000000000 -0500
+++ elks/arch/i86/kernel/irqtab.c 2012-05-24 17:41:07.000000000 -0500
@@ -39,23 +39,12 @@
#ifndef CONFIG_ROMCODE
.globl cseg_stashed_ds
- .globl cseg_stashed_si
- .globl cseg_sc_tmp
.even
cseg_stashed_ds:
.word 0
-
-;from process.c
-
-cseg_stashed_si:
- .word 0
-cseg_sc_tmp:
- .word 0
-
-
#endif
diff -Nurb elks.orig/arch/i86/kernel/process.c elks/arch/i86/kernel/process.c
--- elks.orig/arch/i86/kernel/process.c 2012-05-11 13:26:27.000000000 -0500
+++ elks/arch/i86/kernel/process.c 2012-05-24 17:37:13.000000000 -0500
@@ -46,14 +46,10 @@
#ifdef CONFIG_ROMCODE
#define stashed_ds [0]
-#define stashed_si [14]
-#define sc_tmp [16]
#else
#define stashed_ds cseg_stashed_ds
-#define stashed_si cseg_stashed_si
-#define sc_tmp cseg_sc_tmp
#ifndef S_SPLINT_S
#asm
@@ -67,8 +63,6 @@
*/
.extern cseg_stashed_ds
- .extern cseg_stashed_si ; Now in irqtab.c
- .extern cseg_sc_tmp
/* and now code */
@@ -95,8 +89,6 @@
#asm
.text
-#if 1
-
.globl _tswitch
_tswitch:
@@ -117,64 +109,9 @@
pop di
popf
pop bp ! BP of schedule()
- xor ax,ax
- ret
-
-#else
-
- .globl _save_regs
-
-_save_regs:
-!
-! Save the CPU registers (note: only need those which bcc would
-! expect to be preserved through a function call)
-!
- pop ax ! Return address save
- push bp ! /* schedule()'s bp */
- pushf
- push di
- push si
- push bx
- push dx
-!
-! Store KSP
-!
- mov bx,_current
- mov [bx],sp
- push ax ! Return with the stack altered.
- ret
-/*
- * Unlike save_regs this does not return to the caller
- * but to the caller's caller.
- */
- .globl _load_regs
-
-_load_regs:
-!
-! Recover KSP
-!
- mov bx,_current
- mov ax,[bx]
- mov sp,ax
-!
-! Pull CPU state off the stack
-!
- pop dx
- pop bx
- pop si
- pop di
- popf
-!
-! Now we basically spoof the return code of schedule()
-!
- pop bp ! BP of schedule()
- mov sp,bp ! As schedule() would do on its return to get SP
- pop bp ! Recover caller BP
xor ax,ax ! Set ax=0, as this may be fork() return from child
ret ! thus to caller of schedule()
-#endif
-
!
! System Call Vector
!
@@ -193,67 +130,50 @@
!
! We know the process DS, we can discard it (indeed may change it)
!
- cli
-
- push ax
-
+! Save si and free an index register
+!
+ push si
+!
+! Load kernel data segment
+!
#ifdef CONFIG_ROMCODE
- mov ax,#CONFIG_ROM_IRQ_DATA
+ mov si,#CONFIG_ROM_IRQ_DATA
+ mov ds,si
#else
- mov ax,cs
+ seg cs
#endif
-
- mov ds,ax
- pop ax
-
- mov sc_tmp,ax
-!
-! Save si and free an index register
-!
- mov stashed_si, si
- mov si,bx
-
- mov ax,stashed_ds
- mov ds,ax ;the org DS of kernel
-
+ mov ds,stashed_ds ! the org DS of kernel
!
! Find our TCB
!
- mov bx,_current
+ mov si,_current
+ mov si,[si] ! pops si and
+ pop -2[si] ! save si in kernel stack
!
! Stash user mode stack - needed for stack checking!
!
- mov ax,sp
- mov 2[bx],ax
+ mov si,_current
+ mov 2[si],sp
+!
+! load kernel stack pointer
+!
+ mov sp,[si]
+ sub sp,#2
!
! Finish switching to the right things
!
- mov ax,[bx] ! kernel stack pointer
- mov sp,ax
- mov ax,ds ! ds=es=ss
- mov es,ax
- mov ss,ax
+ mov si,ds ! ds=es=ss
+ mov es,si
+ mov ss,si
cld
!
! Stack is now right, we can take interrupts OK
!
- sti
-#ifdef CONFIG_ROMCODE
- mov ax,#CONFIG_ROM_IRQ_DATA
-#else
- mov ax,cs
-#endif
- mov ds,ax
-
- mov ax, stashed_si
- push ax ! push si
+ sti ! SI already on top of stack
push di
push dx
push cx
- push si ! saved bx
- mov ax,sc_tmp ! restore ax
- push es
- pop ds ;orig kernel ds
+ push bx
#ifdef CONFIG_STRACE
!
diff -Nurb elks.orig/arch/i86/sibo/irqtab.c elks/arch/i86/sibo/irqtab.c
--- elks.orig/arch/i86/sibo/irqtab.c 2012-05-24 16:58:24.000000000 -0500
+++ elks/arch/i86/sibo/irqtab.c 2012-05-24 17:41:57.000000000 -0500
@@ -36,21 +36,12 @@
#ifndef CONFIG_ROMCODE
.globl cseg_stashed_ds
- .globl cseg_stashed_si
- .globl cseg_sc_tmp
.even
cseg_stashed_ds:
.word 0
-;from process.c
-
-cseg_stashed_si:
- .word 0
-cseg_sc_tmp:
- .word 0
-
#endif
#endasm
reply other threads:[~2012-05-29 20:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAD6VGuY5ppAxi=Lu9wb6ijvuRTjHrXN4NOhV6vRpdCES7UV1wQ@mail.gmail.com' \
--to=lithoxs@gmail.com \
--cc=linux-8086@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).