From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert de Bath Subject: Re: ELKS memcpy_fromfs() failing. Wrong variable offsets Date: Wed, 2 Jun 2004 09:47:25 +0100 (BST) Sender: linux-8086-owner@vger.kernel.org Message-ID: <609c173af82cc283@mayday.cix.co.uk> References: <20040601222140.GV21172@duckman.distro.conectiva> Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463811701-585644062-1086166045=:20748" Return-path: In-Reply-To: <20040601222140.GV21172@duckman.distro.conectiva> List-Id: To: Eduardo Pereira Habkost Cc: Linux-8086 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---1463811701-585644062-1086166045=:20748 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 1 Jun 2004, Eduardo Pereira Habkost wrote: > I am forwarding these messages to you, to check if you have any clue on > why this happened, and why the function worked on older versions. > > I've changed the function to use [bp-2] for the 'ds' variable, and now > the kernel works flawlessly. > > Do you have an explanation on how this function.off stuff works, and if > this have changed on older versions? Oh my, confusion reigns. Okay first the si and di variables are usually defined as callee saves unless you're compiling with the '-Mc' option. The "memcpy_fromfs.off" stuff is generated for optimising the push/pop of the si and di variables. It's a reasonably recent addition so all accesses of si and si can be eliminated if they are unused. However, it's only turned on if you use '-O'. Ie: this is working as it should. You have highlighted a bug though, the definition some of the 'set' variables is actually wrong, they should have memcpy_fromfs.off added when it might be non-zero. BTW: You should really be using those variables to access C arguments and locals, the '_memcpy_fromfs.ds' is for stack pointer relative the '.memcpy_fromfs.ds' is for 'bp' relative. I can fix the bug in one of two ways; either actually add the 'memcpy_fromfs.off' variable to the 'set' variables or simply have the compiler assume that any '#asm' will use si and di. (The asm("...") function will not however.) Actually I think assuming that #asm uses si/di is best because as this example has shown it is quite likely to be true, plus, it's the failsafe option. (PS: It's also very easy to do :-) see attached. ) So do you want me to make it like it was before? :-) -- Rob. (Robert de Bath ) ---1463811701-585644062-1086166045=:20748 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="fix.patch" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="fix.patch" ZGlmZiAtTnVyZCBsaW51eDg2Lm9sZC9iY2MvdGFibGUuYyBsaW51eDg2L2Jj Yy90YWJsZS5jDQotLS0gbGludXg4Ni5vbGQvYmNjL3RhYmxlLmMJU3VuIEp1 bCAyOCAwODo0MzoxMyAyMDAyDQorKysgbGludXg4Ni9iY2MvdGFibGUuYwlX ZWQgSnVuICAyIDA5OjM3OjU2IDIwMDQNCkBAIC00MDAsNiArNDAwLDExIEBA DQogICAgIHJlZ2lzdGVyIHN0cnVjdCBzeW1zdHJ1Y3QgKnN5bXB0cjsNCiAg ICAgaW50IGk7DQogDQorICAgIGlmIChmcmFtZXAgJiYgb3B0aW1pc2UgJiYg IWNhbGxlcnNhdmVzKSB7DQorICAgICAgIHJlZ2Z1c2UgfD0gY2FsbGVlMW1h c2s7DQorICAgICAgIG91dG5zdHIoIiEgQXNzdW1pbmcgI2FzbSB1c2VzIGFs bCBjYWxsZWUgc2F2ZXMgcmVnaXN0ZXJzIik7DQorICAgIH0NCisNCiAgICAg Zm9yIChpID0gMDsgaSA8IEhBU0hUQUJTSVpFOyArK2kpDQogCWZvciAoc3lt cHRyID0gaGFzaHRhYltpXTsgc3ltcHRyICE9IE5VTEw7IHN5bXB0ciA9IHN5 bXB0ci0+bmV4dCkNCiAJICAgIGlmIChzeW1wdHItPnN0b3JhZ2UgPT0gTE9D QUwpDQo= ---1463811701-585644062-1086166045=:20748--