From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: stefano.stabellini@citrix.com,
Julien Grall <julien.grall@linaro.org>,
ian.jackson@eu.citrix.com, ian.campbell@citrix.com,
patches@linaro.org
Subject: [PATCH] libxc/arm: Correctly handle the difference between virtual and physical address
Date: Tue, 10 Dec 2013 17:36:21 +0000 [thread overview]
Message-ID: <1386696982-23129-1-git-send-email-julien.grall@linaro.org> (raw)
xc_dom_alloc_page deals with virtual address not physical address. When
an ELF is loaded, virtual address and physical address may be different.
Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
tools/libxc/xc_dom_arm.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index a40e04d..75a6f1c 100644
--- a/tools/libxc/xc_dom_arm.c
+++ b/tools/libxc/xc_dom_arm.c
@@ -108,13 +108,15 @@ static int shared_info_arm(struct xc_dom_image *dom, void *ptr)
static int vcpu_arm32(struct xc_dom_image *dom, void *ptr)
{
vcpu_guest_context_t *ctxt = ptr;
+ uint32_t rambase = dom->rambase_pfn << XC_PAGE_SHIFT;
+ uint32_t offset = dom->parms.virt_base - rambase;
DOMPRINTF_CALLED(dom->xch);
/* clear everything */
memset(ctxt, 0, sizeof(*ctxt));
- ctxt->user_regs.pc32 = dom->parms.virt_entry;
+ ctxt->user_regs.pc32 = dom->parms.virt_entry - offset;
/* Linux boot protocol. See linux.Documentation/arm/Booting. */
ctxt->user_regs.r0_usr = 0; /* SBZ */
@@ -125,7 +127,7 @@ static int vcpu_arm32(struct xc_dom_image *dom, void *ptr)
* like a valid pointer to a set of ATAGS or a DTB.
*/
ctxt->user_regs.r2_usr = dom->devicetree_blob ?
- dom->devicetree_seg.vstart : 0xffffffff;
+ (dom->devicetree_seg.vstart - offset) : 0xffffffff;
ctxt->sctlr = SCTLR_GUEST_INIT;
@@ -280,15 +282,15 @@ int arch_setup_meminit(struct xc_dom_image *dom)
if ( dom->devicetree_blob )
{
- const uint64_t rambase = dom->rambase_pfn << XC_PAGE_SHIFT;
- const uint64_t ramend = rambase + ( dom->total_pages << XC_PAGE_SHIFT );
+ const uint64_t virtbase = dom->parms.virt_base;
+ const uint64_t virtend = virtbase + ( dom->total_pages << XC_PAGE_SHIFT );
const uint64_t dtbsize = ROUNDUP(dom->devicetree_size, XC_PAGE_SHIFT);
/* Place at 128MB if there is sufficient RAM */
- if ( ramend >= rambase + 128*1024*1024 + dtbsize )
- dom->devicetree_seg.vstart = rambase + 128*1024*1024;
+ if ( virtend >= virtbase + 128*1024*1024 + dtbsize )
+ dom->devicetree_seg.vstart = virtbase + 128*1024*1024;
else /* otherwise at top of RAM */
- dom->devicetree_seg.vstart = ramend - dtbsize;
+ dom->devicetree_seg.vstart = virtend - dtbsize;
dom->devicetree_seg.vend =
dom->devicetree_seg.vstart + dom->devicetree_size;
--
1.7.10.4
next reply other threads:[~2013-12-10 17:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 17:36 Julien Grall [this message]
2013-12-10 17:44 ` [PATCH] libxc/arm: Correctly handle the difference between virtual and physical address Ian Campbell
2013-12-10 18:16 ` Julien Grall
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=1386696982-23129-1-git-send-email-julien.grall@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).