Hi Soramichi,

If you're in SE mode, you can call the function "map(Addr vaddr, Addr
paddr, int sz, bool cacheable=true);" on the process object from Python.
For instance:

```
# Default to running 'hello', use the compiled ISA to find the binary
# grab the specific path to the binary
thispath = os.path.dirname(os.path.realpath(__file__))
binary = os.path.join(thispath, '../../../',
                      'tests/test-progs/hello/bin/', isa, 'linux/hello')
# Create a process for a simple "Hello World" application
process = Process()
# Set the command
# cmd is a list which begins with the executable (like argv)
process.cmd = [binary]
...
m5.instantiate()
process.map(0, 0x10000, 0x1000)
```

You have to call the function *after* instantiate, though.

The above will map the virtual addresses 0-4k to 64k-68k physical addresses
(if I've done my hex conversions correctly).

If you're in FS mode, you should be able to use the mmap system call just
like you would on a native system.

Cheers,
Jason

On Tue, Jun 23, 2020 at 8:10 AM Soramichi Akiyama via gem5-users <
gem5-users@gem5.org> wrote:

> Hi Eliot,
>
> thanks for the advice. The component (class) I'm looking for is the one
> that uses
> the page table walker (which uses TLB inside) to convert a vaddr to a
> paddr.
>
> What I want to do is to modify a given virtual address to a different
> address if it is in
> a specific range, to mimic memory region remapping without changing the
> application
> binary and/or the source code. I need to insert code to do this address
> modification
> where vaddr is about to be passed to the page table walker.
>
> Best regrads,
>
> Soramichi
>
> On Tue, 23 Jun 2020 08:51:04 -0400
> Eliot Moss via gem5-users <gem5-users@gem5.org> wrote:
>
> > I don't use the latest version of Gem5, and have focused on an ARM
> simulator, but I see no reason
> > why the operation would not be generally the same as the version I am
> using.
> >
> > In src/sim there is a base TLB class in tlb.{hh,cc}, and
> src/arch/x86/tlb.{hh,cc} extend
> > this.  There is also a table Walker class.  I believe this is where
> translation happens.
> >
> > If you look at your config.dot svg or pdf file, you should see the
> components and how
> > they're connected together.
> >
> > Hope this helps ...  EM
> > _______________________________________________
> > gem5-users mailing list -- gem5-users@gem5.org
> > To unsubscribe send an email to gem5-users-le...@gem5.org
> > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
>
>
> --
> Soramichi Akiyama <akiy...@ci.i.u-tokyo.ac.jp>
> Department of Creative Informatics,
> Graduate School of Information Science and Technology,
> The University of Tokyo, Japan
> _______________________________________________
> gem5-users mailing list -- gem5-users@gem5.org
> To unsubscribe send an email to gem5-users-le...@gem5.org
> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
>
_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to