[comp.os.minix] Urgent bug fix for protected mode

evans@ditsyda.oz (Bruce Evans) (07/25/89)

The function get_phys_byte() was not suitably reentrant, so printer
and rs232 (old driver) interrupts might corrupt the segments used by
other special protected mode functions, notably phys_copy() :-(.

CRCs:
08846   8017 klib286.x
36319   1576 klib286.x.cdif
12547   7691 klib286.x~

#! /bin/sh
# Contents:  klib286.x.cdif
# Wrapped by evans@ditsyda on Tue Jul 25 06:37:16 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'klib286.x.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'klib286.x.cdif'\"
else
echo shar: Extracting \"'klib286.x.cdif'\" \(1576 characters\)
sed "s/^X//" >'klib286.x.cdif' <<'END_OF_FILE'
X*** /local/sys/kernel/klib286.x	Mon Mar 13 04:51:55 1989
X--- klib286.x	Tue Jul 25 01:13:05 1989
X***************
X*** 147,166 ****
X  
X  p_get_phys_byte:
X! 	pop	dx
X! 	pop	_gdt+DS_286_OFFSET+DESC_BASE
X! 	pop	ax		| pop source into base of source descriptor
X  	movb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,al
X- 	sub	sp,#4
X  	mov	cx,ds
X  	mov	ax,#DS_286_SELECTOR
X- 	pushf			| lock may be necessary since this is (only)
X- 	cli			| called by the badly behaved printer task
X  	mov	ds,ax
X  	movb	al,0		| get the byte from the start of the segment
X- 	mov	ds,cx
X- 	popf
X  	subb	ah,ah
X! 	jmpreg	(dx)
X  
X  
X  |*===========================================================================*
X--- 184,215 ----
X  
X  p_get_phys_byte:
X! 	push	bp
X! 	mov	bp,sp
X! 
X! | Save the part of the DS_286 segment descriptor which is going to be
X! | modified, so badly behaved interrupt handlers (printer and old tty)
X! | can use this routine.
X! | This is cheaper than locking all the other descriptor-fiddling routines
X! | in this file.
X! 
X! 	push	_gdt+DS_286_OFFSET+DESC_BASE
X! 	push	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE
X! 
X! 	mov	ax,4(bp)	| move source into base of source descriptor
X! 	mov	_gdt+DS_286_OFFSET+DESC_BASE,ax
X! 	mov	al,4+2(bp)
X  	movb	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE,al
X  	mov	cx,ds
X  	mov	ax,#DS_286_SELECTOR
X  	mov	ds,ax
X  	movb	al,0		| get the byte from the start of the segment
X  	subb	ah,ah
X! 	mov	ds,cx
X  
X+ 	pop	_gdt+DS_286_OFFSET+DESC_BASE_MIDDLE
X+ 	pop	_gdt+DS_286_OFFSET+DESC_BASE
X+ 	pop	bp
X+ 	ret
X+ 
X  
X  |*===========================================================================*
END_OF_FILE
if test 1576 -ne `wc -c <'klib286.x.cdif'`; then
    echo shar: \"'klib286.x.cdif'\" unpacked with wrong size!
fi
# end of 'klib286.x.cdif'
fi
echo shar: End of shell archive.
exit 0
---
Bruce Evans		evans@ditsyda.oz.au
-- 
Bruce Evans		evans@ditsyda.oz.au

rbthomas@athos.rutgers.edu (Rick Thomas) (07/31/89)

I tried installing this bug fix and got the message 
	
	klib286.s 804: register error

when I ran make.

Until I find out if this is expected behavior, I am leaving the bugfix
out.

Bruce?  Any wisdom?

Rick
-- 

Rick Thomas
uucp: {ames, att, harvard}!rutgers!jove.rutgers.edu!rbthomas
internet: rbthomas@JOVE.RUTGERS.EDU
bitnet: rbthomas@zodiac.bitnet
Phone: (201) 932-4301

evans@ditsyda.oz (Bruce Evans) (08/02/89)

In article <Jul.30.17.53.09.1989.21520@athos.rutgers.edu> rbthomas@athos.rutgers.edu (Rick Thomas) writes:
>I tried installing this bug fix and got the message 
>	
>	klib286.s 804: register error
>
>when I ran make.

Oops.

	mov	al,4+2(bp)

should be

	movb	al,4+2(bp)

Asld needs to have the size-specifier 'b' on instructions dealing with byte
quantities, even when the size is determined by a byte register as here :-(.
I do not normally use asld...
-- 
Bruce Evans		evans@ditsyda.oz.au