From patchwork Tue Dec 12 19:02:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 121645 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4508731qgn; Tue, 12 Dec 2017 11:04:46 -0800 (PST) X-Google-Smtp-Source: ACJfBotCQPrPD7QjB3N9d0xI9gfPElZ7r1Nrw+BqEGLLq8o3lZsbGaRG1ItS26SoJ2Am6A4/EtuG X-Received: by 10.36.206.130 with SMTP id v124mr890217itg.81.1513105486386; Tue, 12 Dec 2017 11:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513105486; cv=none; d=google.com; s=arc-20160816; b=cb+4d0ob1HQPee43CYIv+Chk8p7eD0mB3hvxy0merfRNKpV8PoBJYvJDzoLRNYEvlu WPR512zkXe2XCI92s5M5DXFeBuki37n07borjnJE5ixlCe6o5Re7a34mg449N2p4EMPX KeSlPFL/H/Py3xiPTYrWkO8VV6An2WV2hHN7fZWet0/15xTRcdl1JrkCUuedejGddXqb q75rEr6EoOMBAoEvGCsXK1BE4tCG5ygss80Tywkg1WOwbofhyZ3Ks390oeKbX1rIBwJo HFB05tUDURhn2SElMZOvCPjYKNuuc+M5HfHrcnL4Ho5KetIkbP0UIHnrXHtiPzkgBFiU /V0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=SFURQjsaDIJV73GG8hckDyacMam/E+r9BD72hq7/xM8=; b=iye7D685bfg3hJzJQvSdwKt+FORzgBiXzS01MPhbB9rT+oWQ+7G6lsXLRznYC1URmF i0YMY3OqFFQQ5TSb4MAtpomIbYxw6vwEy7bt+XcHmOcqYgEBHX12xsbigRFgsA6pB6/A FpQTWu9O51BxQ5hhsqTTCIRmpguSZUVFobDxuneBPVeID6cWrDMP9UxDpg2Tfsi/lEqq YH0xwvk29b7ektqB0DpzqqUpwx5k+gZJnvB/JWB2HXt3Ea/o0w0Soa6uTtB3IKvqbuo0 Ib3gR8MJG24jnobCeNIcAE75u7n9nMqaDVPpkmFPy8H3sRja92URQbRskGrbnx9/8J6+ +QAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KLXv77Vc; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x189si164056itb.172.2017.12.12.11.04.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:04:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KLXv77Vc; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOpp4-0002Yi-Px; Tue, 12 Dec 2017 19:02:34 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOpp4-0002Xr-3d for xen-devel@lists.xen.org; Tue, 12 Dec 2017 19:02:34 +0000 X-Inumbo-ID: ee8c69cd-df6e-11e7-b4a6-bc764e045a96 Received: from mail-wr0-x242.google.com (unknown [2a00:1450:400c:c0c::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ee8c69cd-df6e-11e7-b4a6-bc764e045a96; Tue, 12 Dec 2017 20:02:00 +0100 (CET) Received: by mail-wr0-x242.google.com with SMTP id y21so22240729wrc.1 for ; Tue, 12 Dec 2017 11:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s8S0y1gqjP0wTdZqWWLUTW3a7kvHJ2Nn2FjfLMpDcZk=; b=KLXv77VclmstaoauiYN2eEEKVv3m4eAbZ3gxUxwJqbgTnWdoEzgxav011lX9yXDsDt 6fOVXHZtz27RwH6QEj4dSzBPHwRnYrt9gbCqzmM7ER7t7fe1v7dzjx8u3NZLkPOWLh1v jAKALqL9UogsBwC9yqbw7mkVq7Ns7M6qHR34E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s8S0y1gqjP0wTdZqWWLUTW3a7kvHJ2Nn2FjfLMpDcZk=; b=hVn57W0Xm+DV4IhVKO/Vez58RJlWRyToUY3S244ZirWZTIk5nePxd/FmYJAk23SCok qeNNdrAjbjFm2tuUhBfUOl7hhQNRLNUff+y9l5yCD+4D5AS8d7nFSkgwQSfjNzjE2fqW wXmSarw44kPzDFDPZL+c84/aNlM4VHQgyaJ+14f48NPle1edamu7+PKuEqBM8w6Sc3L6 /IalA+rK01nRuFDzgcz4998Rer25Gr/gVNPTLA5MC0vSn0D69428YqneDmncAkC2a9Wm c1cWS/yQ7GHx8n1ipWXNRFEqyxGxHEPhhTzrsseifCRL0r81QfsRIOr4ebfoCkA0HFDJ gzqg== X-Gm-Message-State: AKGB3mIlxtPe67yMXxqY56yj0VHZte/29SpDSy8W74m44atepvyO2KSx 5JE7d7CgTYkof2yZ1lkcoIx0049HP24= X-Received: by 10.223.193.135 with SMTP id x7mr5006561wre.211.1513105351243; Tue, 12 Dec 2017 11:02:31 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n14sm207508wmh.37.2017.12.12.11.02.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:02:30 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Dec 2017 19:02:04 +0000 Message-Id: <20171212190212.5535-9-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171212190212.5535-1-julien.grall@linaro.org> References: <20171212190212.5535-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [v2 08/16] xen/arm: kernel: Rework kernel_zimage_load to use the generic copy helper X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function kernel_zimage is dealing with IPA but uses gvirt_to_maddr to do the translation. This is currently working fine because the stage-1 MMU is disabled. Furthermore, the function is implementing its own copy to guest resulting in code duplication and making more difficult to update the logic in page-tables (such support for Populate On Demand). The new copy_to_guest_phys_flush_dcache could be used here by temporarily mapping the full kernel in the virtual space. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/domain_build.c | 1 + xen/arch/arm/kernel.c | 33 ++++++++++++--------------------- xen/arch/arm/kernel.h | 2 ++ 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d7b114ec23..aa6ff8d456 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2135,6 +2135,7 @@ int construct_dom0(struct domain *d) d->max_pages = ~0U; kinfo.unassigned_mem = dom0_mem; + kinfo.d = d; rc = kernel_probe(&kinfo); if ( rc < 0 ) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index a6c6413712..2fb0b9684d 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -15,6 +15,8 @@ #include #include +#include + #include "kernel.h" #define UIMAGE_MAGIC 0x27051956 @@ -157,7 +159,8 @@ static void kernel_zimage_load(struct kernel_info *info) paddr_t load_addr = kernel_zimage_place(info); paddr_t paddr = info->zimage.kernel_addr; paddr_t len = info->zimage.len; - unsigned long offs; + void *kernel; + int rc; info->entry = load_addr; @@ -165,29 +168,17 @@ static void kernel_zimage_load(struct kernel_info *info) printk("Loading zImage from %"PRIpaddr" to %"PRIpaddr"-%"PRIpaddr"\n", paddr, load_addr, load_addr + len); - for ( offs = 0; offs < len; ) - { - uint64_t par; - paddr_t s, l, ma = 0; - void *dst; - - s = offs & ~PAGE_MASK; - l = min(PAGE_SIZE - s, len); - - par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); - if ( par ) - { - panic("Unable to map translate guest address"); - return; - } - dst = map_domain_page(maddr_to_mfn(ma)); + kernel = ioremap_wc(paddr, len); + if ( !kernel ) + panic("Unable to map the hwdom kernel"); - copy_from_paddr(dst + s, paddr + offs, l); + rc = copy_to_guest_phys_flush_dcache(info->d, load_addr, + kernel, len); + if ( rc != 0 ) + panic("Unable to copy the kernel in the hwdom memory"); - unmap_domain_page(dst); - offs += l; - } + iounmap(kernel); } /* diff --git a/xen/arch/arm/kernel.h b/xen/arch/arm/kernel.h index c1b07d4f7b..6d695097b5 100644 --- a/xen/arch/arm/kernel.h +++ b/xen/arch/arm/kernel.h @@ -15,6 +15,8 @@ struct kernel_info { enum domain_type type; #endif + struct domain *d; + void *fdt; /* flat device tree */ paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */ struct meminfo mem;