kernel, sf9: zero data buffer for empty slots
Now sf9 doesn't read uninitialized memory when called for an empty slot. Also, applications don't get stale data after sf9 anymore. git-svn-id: svn://kolibrios.org@9968 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7b51a89852
commit
bd4ac33731
@ -612,7 +612,7 @@ struct WDATA
|
|||||||
draw_bgr_x dd ?
|
draw_bgr_x dd ?
|
||||||
draw_bgr_y dd ?
|
draw_bgr_y dd ?
|
||||||
draw_data RECT
|
draw_data RECT
|
||||||
thread dd ? ; prt APPDATA
|
thread dd ? ; ptr APPDATA
|
||||||
rb 12
|
rb 12
|
||||||
ends
|
ends
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ B32:
|
|||||||
cld
|
cld
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
; CLEAR KERNEL UNDEFINED GLOBALS
|
; Clear kernel undefined globals and slots
|
||||||
mov edi, endofcode - OS_BASE
|
mov edi, endofcode - OS_BASE
|
||||||
mov ecx, 0x90000
|
mov ecx, VGABasePtr - endofcode ; why uglobals_size isn't enough?
|
||||||
sub ecx, edi
|
sub ecx, edi
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep stosd
|
rep stosd
|
||||||
@ -219,8 +219,8 @@ high_code:
|
|||||||
mov [pte_valid_mask], ebx
|
mov [pte_valid_mask], ebx
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov dword [sys_proc + PROC.pdt_0], eax
|
mov [sys_proc + PROC.pdt_0], eax
|
||||||
mov dword [sys_proc + PROC.pdt_0+4], eax
|
mov [sys_proc + PROC.pdt_0+4], eax
|
||||||
|
|
||||||
mov eax, cr3
|
mov eax, cr3
|
||||||
mov cr3, eax ; flush TLB
|
mov cr3, eax ; flush TLB
|
||||||
@ -524,6 +524,16 @@ high_code:
|
|||||||
|
|
||||||
mov [current_process], sys_proc
|
mov [current_process], sys_proc
|
||||||
|
|
||||||
|
; set all the threads state to free
|
||||||
|
mov edi, SLOT_BASE
|
||||||
|
movi eax, TSTATE_FREE
|
||||||
|
movi ecx, max_processes
|
||||||
|
@@:
|
||||||
|
mov [edi+APPDATA.state], TSTATE_FREE
|
||||||
|
add edi, sizeof.APPDATA
|
||||||
|
dec ecx
|
||||||
|
jns @b
|
||||||
|
|
||||||
mov edx, SLOT_BASE + sizeof.APPDATA*1
|
mov edx, SLOT_BASE + sizeof.APPDATA*1
|
||||||
mov ebx, [os_stack_seg]
|
mov ebx, [os_stack_seg]
|
||||||
add ebx, RING0_STACK_SIZE
|
add ebx, RING0_STACK_SIZE
|
||||||
@ -543,9 +553,9 @@ high_code:
|
|||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
call scheduler_add_thread
|
call scheduler_add_thread
|
||||||
|
|
||||||
mov dword [current_slot_idx], 2
|
mov [current_slot_idx], 2
|
||||||
mov [thread_count], 2
|
mov [thread_count], 2
|
||||||
mov dword [current_slot], SLOT_BASE + sizeof.APPDATA*2
|
mov [current_slot], SLOT_BASE + sizeof.APPDATA*2
|
||||||
|
|
||||||
; Move other CPUs to deep sleep, if it is useful
|
; Move other CPUs to deep sleep, if it is useful
|
||||||
uglobal
|
uglobal
|
||||||
@ -1071,12 +1081,12 @@ proc setup_os_slot
|
|||||||
inc eax
|
inc eax
|
||||||
mov [edx + APPDATA.io_map + 4], eax
|
mov [edx + APPDATA.io_map + 4], eax
|
||||||
|
|
||||||
mov dword [edx + APPDATA.pl0_stack], ebx
|
mov [edx + APPDATA.pl0_stack], ebx
|
||||||
lea edi, [ebx + RING0_STACK_SIZE]
|
lea edi, [ebx + RING0_STACK_SIZE]
|
||||||
mov dword [edx + APPDATA.fpu_state], edi
|
mov [edx + APPDATA.fpu_state], edi
|
||||||
mov dword [edx + APPDATA.saved_esp0], edi
|
mov [edx + APPDATA.saved_esp0], edi
|
||||||
mov dword [edx + APPDATA.saved_esp], edi
|
mov [edx + APPDATA.saved_esp], edi
|
||||||
mov dword [edx + APPDATA.terminate_protection], 1 ; make unkillable
|
mov [edx + APPDATA.terminate_protection], 1 ; make unkillable
|
||||||
|
|
||||||
mov esi, fpu_data
|
mov esi, fpu_data
|
||||||
mov ecx, [xsave_area_size]
|
mov ecx, [xsave_area_size]
|
||||||
@ -1085,14 +1095,14 @@ proc setup_os_slot
|
|||||||
rep movsd
|
rep movsd
|
||||||
|
|
||||||
lea eax, [edx + APP_EV_OFFSET]
|
lea eax, [edx + APP_EV_OFFSET]
|
||||||
mov dword [edx + APPDATA.fd_ev], eax
|
mov [edx + APPDATA.fd_ev], eax
|
||||||
mov dword [edx + APPDATA.bk_ev], eax
|
mov [edx + APPDATA.bk_ev], eax
|
||||||
|
|
||||||
lea eax, [edx + APP_OBJ_OFFSET]
|
lea eax, [edx + APP_OBJ_OFFSET]
|
||||||
mov dword [edx + APPDATA.fd_obj], eax
|
mov [edx + APPDATA.fd_obj], eax
|
||||||
mov dword [edx + APPDATA.bk_obj], eax
|
mov [edx + APPDATA.bk_obj], eax
|
||||||
|
|
||||||
mov dword [edx + APPDATA.cur_dir], sysdir_path-2
|
mov [edx + APPDATA.cur_dir], sysdir_path-2
|
||||||
|
|
||||||
mov [edx + APPDATA.process], sys_proc
|
mov [edx + APPDATA.process], sys_proc
|
||||||
|
|
||||||
@ -1514,7 +1524,7 @@ sys_setup:
|
|||||||
; 11 = enable lba read
|
; 11 = enable lba read
|
||||||
; 12 = enable pci access
|
; 12 = enable pci access
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
and [esp + SYSCALL_STACK.eax], dword 0
|
and [esp + SYSCALL_STACK.eax], 0
|
||||||
; F.21.1 - set MPU MIDI base port
|
; F.21.1 - set MPU MIDI base port
|
||||||
dec ebx
|
dec ebx
|
||||||
jnz @f
|
jnz @f
|
||||||
@ -1601,7 +1611,7 @@ sys_setup:
|
|||||||
ret
|
ret
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
.error:
|
.error:
|
||||||
or [esp + SYSCALL_STACK.eax], dword -1
|
or [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@ -1675,7 +1685,7 @@ sys_getsetup:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.addr_error: ; if given memory address is illegal
|
.addr_error: ; if given memory address is illegal
|
||||||
or dword [esp + SYSCALL_STACK.eax], -1
|
or [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
@@:
|
@@:
|
||||||
@ -1725,7 +1735,7 @@ sys_getsetup:
|
|||||||
ret
|
ret
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
.error:
|
.error:
|
||||||
or [esp + SYSCALL_STACK.eax], dword -1
|
or [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
get_timer_ticks:
|
get_timer_ticks:
|
||||||
@ -1930,7 +1940,7 @@ sysfn_shutdown: ; 18.9 = system shutdown
|
|||||||
mov [SYS_SHUTDOWN], al
|
mov [SYS_SHUTDOWN], al
|
||||||
mov [shutdown_processes], eax
|
mov [shutdown_processes], eax
|
||||||
call wakeup_osloop
|
call wakeup_osloop
|
||||||
and dword [esp + SYSCALL_STACK.eax], 0
|
and [esp + SYSCALL_STACK.eax], 0
|
||||||
.exit_for_anyone:
|
.exit_for_anyone:
|
||||||
ret
|
ret
|
||||||
uglobal
|
uglobal
|
||||||
@ -2013,11 +2023,11 @@ sysfn_terminate2:
|
|||||||
call sysfn_terminate
|
call sysfn_terminate
|
||||||
call unlock_application_table
|
call unlock_application_table
|
||||||
sti
|
sti
|
||||||
and dword [esp + SYSCALL_STACK.eax], 0
|
and [esp + SYSCALL_STACK.eax], 0
|
||||||
ret
|
ret
|
||||||
.not_found:
|
.not_found:
|
||||||
call unlock_application_table
|
call unlock_application_table
|
||||||
or dword [esp + SYSCALL_STACK.eax], -1
|
or [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW
|
sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW
|
||||||
@ -2213,7 +2223,7 @@ sysfn_getversion: ; 18.13 = get kernel ID and version
|
|||||||
rep movsb
|
rep movsb
|
||||||
ret
|
ret
|
||||||
.addr_error: ; if given memory address is illegal
|
.addr_error: ; if given memory address is illegal
|
||||||
mov dword [esp + SYSCALL_STACK.eax], -1
|
mov [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
sysfn_waitretrace: ; 18.14 = sys wait retrace
|
sysfn_waitretrace: ; 18.14 = sys wait retrace
|
||||||
@ -2223,7 +2233,7 @@ sysfn_waitretrace: ; 18.14 = sys wait retrace
|
|||||||
in al, dx
|
in al, dx
|
||||||
test al, 1000b
|
test al, 1000b
|
||||||
jz .loop
|
jz .loop
|
||||||
and [esp + SYSCALL_STACK.eax], dword 0
|
and [esp + SYSCALL_STACK.eax], 0
|
||||||
ret
|
ret
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@ -2406,7 +2416,7 @@ sys_cachetodiskette:
|
|||||||
mov [esp + SYSCALL_STACK.eax], eax
|
mov [esp + SYSCALL_STACK.eax], eax
|
||||||
ret
|
ret
|
||||||
.no_floppy_save:
|
.no_floppy_save:
|
||||||
mov [esp + SYSCALL_STACK.eax], dword 1
|
mov [esp + SYSCALL_STACK.eax], 1
|
||||||
ret
|
ret
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@ -2422,11 +2432,23 @@ sys_cpuusage:
|
|||||||
jne .no_who_am_i
|
jne .no_who_am_i
|
||||||
mov ecx, [current_slot_idx]
|
mov ecx, [current_slot_idx]
|
||||||
.no_who_am_i:
|
.no_who_am_i:
|
||||||
|
jecxz .empty_slot
|
||||||
cmp ecx, max_processes
|
cmp ecx, max_processes
|
||||||
ja .nofillbuf
|
ja .empty_slot
|
||||||
test ecx, ecx ; slot 0 is empty, kernel threads start from 1
|
mov edx, ecx
|
||||||
jz .nofillbuf
|
shl edx, BSF sizeof.APPDATA
|
||||||
|
cmp [SLOT_BASE+edx+APPDATA.state], TSTATE_FREE
|
||||||
|
jnz .thread_found
|
||||||
|
.empty_slot:
|
||||||
|
; zero buffer for an empty slot
|
||||||
|
push edi
|
||||||
|
xor eax, eax
|
||||||
|
mov edi, ebx
|
||||||
|
movi ecx, sizeof.process_information
|
||||||
|
rep stosb
|
||||||
|
pop edi
|
||||||
|
jmp .nofillbuf
|
||||||
|
.thread_found:
|
||||||
; +4: word: position of the window of thread in the window stack
|
; +4: word: position of the window of thread in the window stack
|
||||||
mov ax, [WIN_STACK + ecx * 2]
|
mov ax, [WIN_STACK + ecx * 2]
|
||||||
mov [ebx+process_information.window_stack_position], ax
|
mov [ebx+process_information.window_stack_position], ax
|
||||||
@ -2494,11 +2516,11 @@ sys_cpuusage:
|
|||||||
stosb
|
stosb
|
||||||
|
|
||||||
; Event mask (+71)
|
; Event mask (+71)
|
||||||
mov eax, dword [SLOT_BASE + ecx + APPDATA.event_mask]
|
mov eax, [SLOT_BASE + ecx + APPDATA.event_mask]
|
||||||
stosd
|
stosd
|
||||||
|
|
||||||
; Keyboard mode (+75)
|
; Keyboard mode (+75)
|
||||||
mov al, byte [SLOT_BASE + ecx + APPDATA.keyboard_mode]
|
mov al, [SLOT_BASE + ecx + APPDATA.keyboard_mode]
|
||||||
stosb
|
stosb
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
@ -2512,7 +2534,7 @@ sys_cpuusage:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.addr_error: ; if given memory address is illegal
|
.addr_error: ; if given memory address is illegal
|
||||||
mov dword [esp + SYSCALL_STACK.eax], -1
|
mov [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -3461,7 +3483,7 @@ r_f_port_area:
|
|||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
drawbackground:
|
drawbackground:
|
||||||
cmp [BgrDrawMode], dword 1
|
cmp [BgrDrawMode], 1
|
||||||
jne .bgrstr
|
jne .bgrstr
|
||||||
call vesa20_drawbackground_tiled
|
call vesa20_drawbackground_tiled
|
||||||
call __sys_draw_pointer
|
call __sys_draw_pointer
|
||||||
@ -4055,7 +4077,7 @@ sys_gs: ; direct screen access
|
|||||||
ja .not_support
|
ja .not_support
|
||||||
jmp dword [f61call + ebx*4]
|
jmp dword [f61call + ebx*4]
|
||||||
.not_support:
|
.not_support:
|
||||||
or [esp + SYSCALL_STACK.eax], dword -1
|
or [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -4380,7 +4402,8 @@ sys_apm:
|
|||||||
inc eax
|
inc eax
|
||||||
or dword [esp + 44], eax ; error
|
or dword [esp + 44], eax ; error
|
||||||
add eax, 7
|
add eax, 7
|
||||||
mov dword [esp + SYSCALL_STACK.eax], eax ; 32-bit protected-mode interface not supported
|
mov [esp + SYSCALL_STACK.eax], eax ; 32-bit protected-mode
|
||||||
|
; interface not supported
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
@ -4426,7 +4449,7 @@ sys_apm:
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
undefined_syscall: ; Undefined system call
|
undefined_syscall: ; Undefined system call
|
||||||
mov [esp + SYSCALL_STACK.eax], dword -1
|
mov [esp + SYSCALL_STACK.eax], -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
|
Loading…
Reference in New Issue
Block a user