From: Eduardo Pereira Habkost <ehabkost@conectiva.com.br>
To: linux-8086@vger.kernel.org
Subject: memcpy_fromfs() failing. Wrong variable offsets
Date: Tue, 1 Jun 2004 18:32:31 -0300 [thread overview]
Message-ID: <20040601213231.GT21172@duckman.distro.conectiva> (raw)
[-- Attachment #1: Type: text/plain, Size: 2825 bytes --]
I was trying to boot ELKS CVS here and it was failing when trying to
run init. I've tracked the bug until I discovered that
memcpy_fromfs() is failing, and it is not copying the right data.
Here is the function, with my debug line:
===============
void memcpy_fromfs(void *daddr, void *saddr, size_t len)
{
/*@unused@*/ unsigned short int ds = current->t_regs.ds;
#ifndef S_SPLINT_S
#asm
mov dx,es
mov bx,ds
mov es,bx
mov ax,[bp-6] ! source segment (local variable)
mov ds,ax
mov di,[bp+4] ! destination address
mov si,[bp+6] ! source address
mov cx,[bp+8] ! number of bytes to copy
cld
rep
movsb
mov ds,bx
mov es,dx
#endasm
#endif
debug3("DS: 0x%04x, real: 0x%02x, copied: 0x%02x\n",
ds, *((unsigned char*)saddr), *((unsigned char*)daddr));
}
====================
Note that, as the DS for the init task, at the time of the error is the
same of the kernel's DS, *((unsigned char*)saddr) showed the right value.
What I got when the kernel tries to run init is:
DS: 0x1dc1, real: 0x64, copied: 0x00
That means: the data wasn't copied.
Looking at the generated assembly file, We get:
==================
! 32 void memcpy_fromfs(daddr,saddr,len)
! Register SI DI used in function verfy_area
verfy_area.off = 0
! 33 # 32 "user.c"
! 32 void *daddr;
export>·_memcpy_fromfs
_memcpy_fromfs:
!BCC_EOS
! 33 # 32 "user.c"
! 32 void *saddr;
!BCC_EOS
! 33 # 32 "user.c"
! 32 size_t len;
!BCC_EOS
! 33 {
! 34 unsigned short int ds = current->t_regs.ds;
push>···bp
mov>····bp,sp
if memcpy_fromfs.off=0
push>···di
push>···si
endif
dec>····sp
dec>····sp
mov>····bx,[_current]
! Debug: eq unsigned short = [bx+6] to unsigned short ds = [S+8-8] (used reg = )
mov>····bx,6[bx]
mov>····-6+memcpy_fromfs.off[bp],bx
[...]
! 53 }
inc>····sp
inc>····sp
if memcpy_fromfs.off=0
pop>····si
pop>····di
endif
pop>····bp
ret
! 54·
! 55 int verified_memcpy_fromfs(daddr,saddr,len)
memcpy_fromfs.off = 4
============
That means: if memcpy_fromfs.off were 0, the function would be ok. The
variable ds is supposed to be in [bp-6], but it is on [bp-2], because
memcpy_fromfs.off is being defined to 4. Probably someday the compiler
generated code in a way that memcpy_fromfs.off was always zero, and the
function assumes that.
Anyway, looking at the code of the compiler, it looks like that
it should know if SI or DI was modified by the function,
because it should save their values on the stack.
I am using dev86-0.16.15 to compile elks.
Someone have reproduced this problem, too? Does anyone had success
booting ELKS CVS?
--
Eduardo
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2004-06-01 21:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-01 21:32 Eduardo Pereira Habkost [this message]
2004-06-01 22:02 ` Experimental fix for my memcpy_{to,from}fs problem Eduardo Pereira Habkost
2004-06-01 22:30 ` Eduardo Pereira Habkost
2004-06-02 2:57 ` Miguel Bolanos
2004-06-02 16:25 ` Eduardo Pereira Habkost
2004-06-03 14:02 ` Miguel Bolanos
2004-06-03 14:14 ` Eduardo Pereira Habkost
2004-06-03 14:37 ` Paul Nasrat
2004-06-02 1:33 ` claudio
2004-06-02 20:53 ` Miguel Bolanos
2004-06-02 3:05 ` Miguel Bolanos
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=20040601213231.GT21172@duckman.distro.conectiva \
--to=ehabkost@conectiva.com.br \
--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