From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com,
stefano.stabellini@citrix.com, patches@linaro.org
Subject: Re: [PATCH] libxc/arm: Correctly handle the difference between virtual and physical address
Date: Tue, 10 Dec 2013 18:16:23 +0000 [thread overview]
Message-ID: <52A75A77.7000708@linaro.org> (raw)
In-Reply-To: <1386697480.30568.64.camel@kazak.uk.xensource.com>
On 12/10/2013 05:44 PM, Ian Campbell wrote:
> On Tue, 2013-12-10 at 17:36 +0000, Julien Grall wrote:
>> xc_dom_alloc_page deals with virtual address not physical address. When
>> an ELF is loaded, virtual address and physical address may be different.
>
> Can you give an example of the program headers of an ELF file (readelf
> -l) which causes this? How was it constructed?
This is the beginning of readelf -l for a FreeBSD ARM binary:
Elf file type is EXEC (Executable file)
Entry point 0xc0100100
There are 5 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
EXIDX 0x2f6e54 0xc03f6e54 0xc03f6e54 0x0df90 0x0df90 R 0x4
PHDR 0x000034 0xc0100034 0xc0100034 0x000a0 0x000a0 R E 0x4
INTERP 0x2b67f0 0xc03b67f0 0xc03b67f0 0x0000d 0x0000d R 0x1
[Requesting program interpreter: /red/herring]
LOAD 0x000000 0xc0100000 0xc0100000 0x32dadc 0x3538d8 RWE 0x8000
DYNAMIC 0x32da74 0xc042da74 0xc042da74 0x00068 0x00068 RW 0x4
FreeBSD will build the kernel with:
- kernel physical address: 0x80100000
- kernel virtual address: 0xC0100000
And the ELF will be linked with the virtual address.
> When we are building the guest the MMU is disabled so virt == phys.
Right, but ELF loader is based on virtual address not physical address.
Guest creation will fail when libxc is trying to allocate segment for the device
tree (see xc_dom_alloc_segment).
As it's allocate after the kernel, virt_alloc_end will contains a virtual address.
But device tree address is generated with a physical address...
Therefore, the function will fail with "segment start too low ...".
> If the ELF has virt != phys then how do we know whether it expects to be
> launched with the MMU on or off? We can only really launch with the MMU
> off, so do we require that the initial ELF entry point be PIC and know
> how to enable the MMU?
This issue is when as virt == phys, build ELF with virt != phys is very difficult.
I took a couple of hours without any success.
In any case, FreeBSD is building its ELF with virt = phys.
When the guest is creating, the ELF should loaded like zImage at the specific
physical address. Then the guest will start will MMU turn off, and during the
first instructions it will use fixup to get the right address.
--
Julien Grall
next prev parent reply other threads:[~2013-12-10 18:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 17:36 [PATCH] libxc/arm: Correctly handle the difference between virtual and physical address Julien Grall
2013-12-10 17:44 ` Ian Campbell
2013-12-10 18:16 ` Julien Grall [this message]
2013-12-11 10:02 ` Ian Campbell
2013-12-11 19:26 ` Julien Grall
2013-12-12 10:35 ` Ian Campbell
2013-12-12 13:55 ` Julien Grall
2013-12-12 14:36 ` Ian Campbell
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=52A75A77.7000708@linaro.org \
--to=julien.grall@linaro.org \
--cc=Ian.Campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=patches@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).