From patchwork Tue Dec 10 17:36:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22227 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 98FAF23908 for ; Tue, 10 Dec 2013 17:36:34 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rq2sf25415977pbb.1 for ; Tue, 10 Dec 2013 09:36:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=UTM2QdPGZ+c4SXJTMG2QSIo6SmDK3ZBWumSkVtlJCOc=; b=iufSihsGgIchOcWZDlGzk4fpmT5Cx+DIkMGeOTTAoBgSGatyYSofwqM/xvG2UCrkvg OqhuiiOnRWld4Ql2jPCtwNlIf4/be4M6QrS6Rrd3NzF7PjN3kwgbDKwGbp+b8v4N7g7C FEGYTv1gWb9uqrNbI8QhSmRs63q+h6CIswwLlDlhRqLVgNwutkmD4IfZxkc0svmDR0hy jBj2QWc6neQ4Xkac5/9TwFBkV8xziM2Fy9Co2axz5L2n9kkxqSUYEo0jMz38QbcBMw0s JVsKhrWju0xXcHVxY1wtuDlpYbXLdjqbI5mz9xIbMFGgurwZFHUo6bsoRlCBK7EUmyGg Z4Uw== X-Gm-Message-State: ALoCoQmwIEyaL+EvZmazn9K00KmZ25XOXVjDd3x+TwFz6agG+htATAU0S8He6NylqghS8Ot6yiCM X-Received: by 10.68.202.69 with SMTP id kg5mr2062676pbc.2.1386696993711; Tue, 10 Dec 2013 09:36:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.16.35 with SMTP id c3ls2486204qed.83.gmail; Tue, 10 Dec 2013 09:36:33 -0800 (PST) X-Received: by 10.58.54.69 with SMTP id h5mr1398502vep.25.1386696993570; Tue, 10 Dec 2013 09:36:33 -0800 (PST) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id fc4si5354129vcb.11.2013.12.10.09.36.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Dec 2013 09:36:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ia6so4758387vcb.4 for ; Tue, 10 Dec 2013 09:36:33 -0800 (PST) X-Received: by 10.220.95.201 with SMTP id e9mr307961vcn.71.1386696993438; Tue, 10 Dec 2013 09:36:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp206369vcz; Tue, 10 Dec 2013 09:36:33 -0800 (PST) X-Received: by 10.180.11.169 with SMTP id r9mr20283457wib.26.1386696992447; Tue, 10 Dec 2013 09:36:32 -0800 (PST) Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by mx.google.com with ESMTPS id z3si1348387wia.7.2013.12.10.09.36.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Dec 2013 09:36:32 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.46 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.46; Received: by mail-wg0-f46.google.com with SMTP id m15so5168459wgh.1 for ; Tue, 10 Dec 2013 09:36:32 -0800 (PST) X-Received: by 10.180.90.114 with SMTP id bv18mr20513169wib.16.1386696991953; Tue, 10 Dec 2013 09:36:31 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id b7sm6984833wiz.8.2013.12.10.09.36.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2013 09:36:31 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, stefano.stabellini@citrix.com, Julien Grall Subject: [PATCH] libxc/arm: Correctly handle the difference between virtual and physical address Date: Tue, 10 Dec 2013 17:36:21 +0000 Message-Id: <1386696982-23129-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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;