All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Johnson <ben@blarg.net>
To: "Richard B. Johnson" <root@chaos.analogic.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: linear vs. logical addresses?  how does cpu interpret kernel addrs?
Date: Wed, 17 Sep 2003 12:42:21 -0700	[thread overview]
Message-ID: <20030917124221.A3970@blarg.net> (raw)
In-Reply-To: <Pine.LNX.4.53.0309170734240.881@chaos>; from root@chaos.analogic.com on Wed, Sep 17, 2003 at 07:39:53AM -0400

On Wed, Sep 17, 2003 at 07:39:53AM -0400, Richard B. Johnson wrote:
> 
> All stack offsets are accessed relative to SS. No exceptions.
> However a compiler may calculate those offsets based upon
> something else.
> This is why DS must equal SS if 'C' is going to access both
> stack data variables and data segment variables. This is how
> the 'C' code converter is set up. It is not a CPU limitation.
> If you change the SS in the kernel, strange and wonderful
> things will occur.

Let me see if I understand you.  If SS and DS point to segments that
have different base addresses then code like this...  (I'm an assembly
newbie.  hope I get this right.)

# get whatever is at %ss:%esp + 4 and put it in eax
movl 4(%esp), %eax
movl %esp, %edx
# get whatever is at %ds:%edx + 4 and put it in eax
movl 4(%edx), %eax

# eax probably changed twice because while esp and edx have same value,
# if SS->baseaddr != DS->baseaddr, then (%esp) and (%edx) don't point to
# the same memory location.

I'm pretty sure I've seen plenty of code like this, which must mean,
like you just told me, that the C compiler assumes the base address of
DS and SS are the same.  So, if I want to change segment base addresses
then I'm up shit creek.

Thanks very much for the info!

- Ben


  reply	other threads:[~2003-09-17 19:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-16 22:47 linear vs. logical addresses? how does cpu interpret kernel addrs? Ben Johnson
2003-09-17  0:48 ` Martin J. Bligh
2003-09-17  0:54   ` William Lee Irwin III
2003-09-17  0:58     ` Martin J. Bligh
2003-09-17  1:44       ` Ben Johnson
2003-09-17  1:55         ` William Lee Irwin III
2003-09-17  2:07           ` Ben Johnson
2003-09-17  2:10             ` William Lee Irwin III
2003-09-17  2:32               ` Ben Johnson
2003-09-17  2:10         ` Felipe Alfaro Solana
2003-09-17 11:39 ` Richard B. Johnson
2003-09-17 19:42   ` Ben Johnson [this message]
2003-09-17 20:05     ` Richard B. Johnson
2003-09-17 20:44       ` 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=20030917124221.A3970@blarg.net \
    --to=ben@blarg.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.