From: "Parity Error" <bootup@mail.ru>
To: "Jamie Lokier" <lk@tantalophile.demon.co.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re[2]: switch_to()/doesnt %esp get replaced with %ebp on ret
Date: Tue, 20 Mar 2001 13:51:00 +0300 [thread overview]
Message-ID: <E14fJjA-000Pf0-00@f6.mail.ru> (raw)
In-Reply-To: <20010319150425.D19104@pcep-jamie.cern.ch>
I dont know if you understood my doubt, but your pointer
to bp accidentally or otherwise solved the mystery.
The problem was although switch_to changes esp to the
next processes stack, code emitted by the compiler, has
"cached" the 'prev' processes's esp via ebp, and uses this
at return to restore... So in effect, esp would again
get changed to prev's esp.
switch_to is a MACRO and saves ebp on stack and restores
it. The above ensures that the cached ebp is also changed
to the next's cached ebp, in some sense. I removed the
push %ebp , and pop %ebp from switch_to and ran and it
promptly crashed. But with -fomit-frame-pointer, all this
does not take place.
Still, could some one enlighten me on why esi and edi are
also similarly saved and restored ?
-----Original Message-----
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Parity Error <bootup@mail.ru>
Date: Mon, 19 Mar 2001 15:04:25 +0100
Subject: Re: switch_to()/doesnt %esp get replaced with %ebp on ret
=
=That's not nice code from the compiler (suboptimal), but it'll work.
=leal -24(%ebp),%esp is perfectly ok in the epilogue of a function.
=You're right that %esp is lost -- in this case, %ebp has effectively the
=same information.
=
=Think like this: a perfectly normal function (without switch_to) can
=have this:
=
=f: pushl %ebp
= movl %esp,%ebp
= pushl %ebx
= ... do stuff, decrement %esp a lot to call functions etc. etc. ...
= movl -4(%ebp),%esp
= popl %ebx
= popl %ebp
= ret
=
=Parity Error wrote:
=> in schedule(), switch_to() macro changes esp to
=> the new process's stack. But, on exit frm schedule,
=> how come it does not get overwritten with ebp-24,
=> as the dissasembled code shows. The code was compiled
=> without the -fomit-frame-pointer.
=>
=> pushl 508(%ecx)
=> jmp __switch_to
=> 1: popl %ebp
=> popl %edi
=> popl %esi
=>
=> jmp .L1180
=>
=> .L1180:
=> leal -24(%ebp),%esp
=> popl %ebx
=> popl %esi
=> popl %edi
=> movl %ebp,%esp
=> popl %ebp
=> ret
=
next prev parent reply other threads:[~2001-03-20 10:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-19 13:19 Parity Error
2001-03-19 14:04 ` Jamie Lokier
2001-03-20 10:51 ` Parity Error [this message]
2001-03-20 11:23 ` Jamie Lokier
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=E14fJjA-000Pf0-00@f6.mail.ru \
--to=bootup@mail.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=lk@tantalophile.demon.co.uk \
/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
all inboxes | Powered by JetHome®