From: Ben Johnson <ben@blarg.net>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: linear vs. logical addresses? how does cpu interpret kernel addrs?
Date: Tue, 16 Sep 2003 15:47:47 -0700 [thread overview]
Message-ID: <20030916154747.A22526@blarg.net> (raw)
short version:
1) When I am referencing a pointer in the kernel, is the value of that
pointer variable interpreted by the cpu as a logical or linear address?
2) if I have two overlapping data/stack segments presently selected,
each with a different base, how does the cpu know which segment/base
address to use to get the linear address?
longer version:
(please stop me if I'm just being stupid.)
As I understand it, logical addresses are interpreted as offsets from
the base address of some current segment descriptor. in at least the
2.0 kernel the base address of the data segment selected by the
"KERNEL_DS" segment selector is 0xc00000000. so, to get a linear
address I would do this...
int anything;
ulong linear_anything_addr = ((unsigned long) & anything) + 0xc00000000;
right?
and...
I'm messing with stack segments, trying to give each kernel stack it's
own segment. (just for kicks.) I have one data segment with a base
address of 0xc0000000 and a limit of 1GB(4GB?) that I think I use for
all data access. If I make a stack segment with a base address that
falls within the area governed by the data segment, say the base address
is 0xc00000ff, what happens when I do something like this?:
struct pt_regs * regs;
unsigned long * stack_pointer;
regs = ((struct pt_regs *) (current->kernel_stack_page + PAGE_SIZE))-1;
stack_pointer = (unsigned long *) regs->esp;
printk( "%ul", *stack_pointer ); /* what is this pointing to? */
So, what I'm thinking here is that the value of %%esp is treated as an
offset from the base address of the stack segment, 0xc00000ff, but when
I use it in a non-stack oriented context, it's possibly treated as an
offset from some other segment's base address. how does the cpu choose
which segment to use?
Thanks a lot.
- Ben
next reply other threads:[~2003-09-16 22:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-16 22:47 Ben Johnson [this message]
2003-09-17 0:48 ` linear vs. logical addresses? how does cpu interpret kernel addrs? 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
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=20030916154747.A22526@blarg.net \
--to=ben@blarg.net \
--cc=linux-kernel@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 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.