mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: lya755@ece.northwestern.edu
To: root@chaos.analogic.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: question about ramdisk
Date: Wed, 14 Jul 2004 11:30:21 -0500	[thread overview]
Message-ID: <1089822621.40f55f9dd4278@core.ece.northwestern.edu> (raw)
In-Reply-To: <Pine.LNX.4.53.0407141154120.16363@chaos>

Thanks so much for the hint! Really appreciate it. I'll try out your 
suggestions.

I am still a bit confused, though. If the code is in ramdisk, then it will be 
mapped to the process address space, which as I understand, does not involve 
any actual data copy and transfer. This sounds very reasonable. But what if 
the code is in hard disk? Would the kernel copy it to memory (somewhere 
allocated) then map this region as the text section for the address space, and 
then run the instructions from ram? That's the way I understand it, but I 
don't know whether that is correct.

Thanks!
Lei

Quoting "Richard B. Johnson" <root@chaos.analogic.com>:

> On Wed, 14 Jul 2004 lya755@ece.northwestern.edu wrote:
> 
> > Hello,
> >
> > I am now thinking of a way to verify what H. Peter Anvin says about the
> > ramdisk, so that I can watch what is going on when the executable is
> running.
> > Is there any way to achieve that besides kernel debugging? I don't really
> want
> > to debug the kernel for now.
> >
> > Can I get the physical address of the text section with it's virtual
> address?
> > If I can know the physical address of the code in ramdisk and can know the
> > physical address of the text section of process address space, maybe this
> can
> > be done.
> >
> > Any suggestions?
> >
> > Lei
> >
> 
> The physical address will do you no good because your process
> uses the virtual address to access everything.
> 
> Do `cat /proc/PID/maps` where PID is a process ID number. You
> will see the virtual address of the executable and runtime
> shared libraries that the task is using. These are memory-mapped
> into the tasks address-space.
> 
> If your code is ANYWHERE, including on a RAM-Disk, it will
> be memory-mapped into your address-space just like what you
> see. This allows everybody to share all the executables and
> all the run-time libraries so they don't need separate copies.
> 
> For instance, here's somebody running the `bash` shell:
> 
> 08048000-0808c000 r-xp 00000000 08:11 1440929    /usr/bin/bash
> 0808c000-08092000 rw-p 00043000 08:11 1440929    /usr/bin/bash
> 08092000-080a2000 rwxp 00000000 00:00 0
> 40000000-4000a000 r-xp 00000000 08:11 475506     /usr/lib/ld-2.0.5.so
> 4000a000-4000b000 rw-p 00009000 08:11 475506     /usr/lib/ld-2.0.5.so
> 4000b000-4000c000 rwxp 00000000 00:00 0
> 4000c000-40010000 r--p 00000000 08:11 163651     /etc/ld.so.cache
> 40010000-40012000 rwxp 00000000 08:11 1030227    /lib/libtermcap.so.2.0.8
> 40012000-40014000 rw-p 00001000 08:11 1030227    /lib/libtermcap.so.2.0.8
> 40014000-4009f000 r-xp 00000000 08:11 475508     /usr/lib/libc-2.0.6.so
> 4009f000-400a5000 rw-p 0008b000 08:11 475508     /usr/lib/libc-2.0.6.so
> [SNIPPED...]
> 
> You can see the virtual address of your own stuff by compiling
> and executing this:
> 
> #include <stdio.h>
> extern char _start;
> extern char _end;
> char dat;
> const char x[]="x";
> 
> int main()
> {
>     char foo;
>     printf("start = %p\n", &_start);
>     printf(" main = %p\n", main);
>     printf(" data = %p\n", &dat);
>     printf("const = %p\n", x);
>     printf("stack = %p\n", &foo);
>     printf("  end = %p\n", &_end);
>     return 0;
> }
> 
> The physical address in RAM could be anywhere. The kernel takes
> pages of RAM from anywhere and makes them look contiguous for
> each task. So what looks like linear address-space is made up
> of (on ix86 0x1000 byte) pages of RAM.
> 
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
>             Note 96.31% of all statistics are fiction.
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 



_________________________________________________________
This message was sent through the NU ECE webmail gateway.

  reply	other threads:[~2004-07-14 16:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-12 16:57 lya755
2004-07-12 17:13 ` H. Peter Anvin
2004-07-13 14:01   ` lya755
2004-07-13 20:06     ` Lee Revell
2004-07-13 21:27       ` Lee Revell
     [not found]       ` <1089753034.40f44fca074c2@core.ece.northwestern.edu>
     [not found]         ` <1089753955.22175.8.camel@mindpipe>
2004-07-14 14:59           ` lya755
2004-07-14 16:07             ` Richard B. Johnson
2004-07-14 16:30               ` lya755 [this message]
2004-07-14 16:57                 ` Richard B. Johnson

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=1089822621.40f55f9dd4278@core.ece.northwestern.edu \
    --to=lya755@ece.northwestern.edu \
    --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 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®