From patchwork Thu Nov 23 18:32:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119529 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172901edl; Thu, 23 Nov 2017 10:34:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMazWxqwhnGtAleZIcxhq78XIHUwa7bhnCB+Y4qYJJDXfHM4NhT1Mraiu64lugP50Sp31ANh X-Received: by 10.36.146.215 with SMTP id l206mr10347084itd.25.1511462049562; Thu, 23 Nov 2017 10:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462049; cv=none; d=google.com; s=arc-20160816; b=c57BBDl3ugHCGYPtaR1O2x8WEVMiMWLGM5mJ8rYLWnoH1aLeDoOml/E2CC/oZoQ/A6 a1SDCaVkkItT6BfmF4+Hl8AkuFub8srFD5mBTsgDoFZ0wfZJNo8MAuH0SlFXdLWulVhd VMKbqvppD+57F7L9DibPQ1JcTmfCzvh/z2f4vWY84aOktHIUQH90SVCBbVNvx/uR0hxx kwipKYAi6gqf1uIbWpB1N/cNjPparbG6h0yqYM2FpP43olqYAuFuIgtBmi856/Pn9sqw AuuApmCGIjAG3yERdhdMPyzehm/W9wjwXqPafWjSMzhXpCMiHUDDT9HxG87rC9o7Snau hiUw== 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=2oFy9zK/eQpvJNZM+3ZWL8Mhy+K+NoiLOmaMbmBBlKw=; b=psUCxFNUeOhI6IAszl9yYeot+Co5KLdgEg8ZYEV6Shgakur/K29l4ip5DuHMUfhPzY cDLNMtjO6gTHHftX+k12H3YOEJeuqnGGqR0DSeIx15VqFTfiruGrNMR3urOIQjQQmVLg AsDwmeO90HNXhUiZM1W1jBV1JJz3AJbYxvzEyE7iRzp1LIvtFUUhwYlZQ4WRpYBRUngP hQgWmICuVHpT7bwVfq3YSxwHuLCyBUESElVMvcpkVJpqZYvBT+W5zhufgUc69RpnGTtm DnTvk2F5apZMkTc9tXUhmXwQUf7FQtxv6NLjnPHqitH6hXCoyN4iXCzc8VTqqe74/jpW Ytug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ELxIXEu0; 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 i8si13377362iob.204.2017.11.23.10.34.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:09 -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=ELxIXEu0; 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 1eHwIU-0005Go-1f; Thu, 23 Nov 2017 18:32:26 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIR-00059i-Vr for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:24 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id AD/CD-27709-734171A5; Thu, 23 Nov 2017 18:32:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsXiVRvkrGsuIh5 lMGESn8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFywTrmgj7JivctL9kbGJcJdzFycggJTGSU WNXv3cXIxcEiMI9ZYlHrSRYQR0Kgn1Vi5uvHbCBVEgJ5EhuvPGSEsNMkdt/oZIWwKyU2XdjE1 MXIATRJTWLNmyiQXiGBPiaJnV8OsYPE2QR0JNbNqAUpFxGQlrj2+TLYGGaBeInHU6+DjRcWyJ RYeOQKO4jNIqAqsWb2ATCbV8BG4vWG2VAnyEvsarsItpZTwFbi6IEPzBBrbSQ+f1acwCi4gJF hFaN6cWpRWWqRrpleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgqDEAwQ7GeSf8 DzFKcjApifLK/BKLEuJLyk+pzEgszogvKs1JLT7EKMPBoSTBe1NIPEpIsCg1PbUiLTMHGPQwa QkOHiUR3u0gad7igsTc4sx0iNQpRkuOfXtu/WHieDbzdQMzx7SrrU3MQix5+XmpUuK8m0EaBE AaMkrz4MbBIvMSo6yUMC8j0IFCPAWpRbmZJajyrxjFORiVhHnThIGm8GTmlcBtfQV0EBPQQT+ PC4McVJKIkJJqYEyN+CO7T3fmAQP5P1xtsj8MJMqdZ34VmBeaLelY276rW8t3z5Ho74uMtu54 YXPiq+GOBSenKD0/J+jxS1uQ6+eazTxs+50uTXM8eet6f3PAkX0z92f8+Kv2Q+y4B4P4p/XyC x/mJsj0LwldMMM75fn5vvbIY0qTf4Vfbj92TKLAcd2PAKkNV74rsRRnJBpqMRcVJwIAQrImlM cCAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1511461943!116436948!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31200 invoked from network); 23 Nov 2017 18:32:23 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:23 -0000 Received: by mail-wm0-f67.google.com with SMTP id 128so18309940wmo.3 for ; Thu, 23 Nov 2017 10:32:23 -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=EkEWKS3KD6BOY8J1/VZIM+kubCBL2zD7NpsdCjfJLpE=; b=ELxIXEu0JrVsPdbzMm1dphBgKPkBrH/XXkMp6KdPiBEhQsODptSo6bnBHuvrCLJ2KW W0srKZmhtM2tN5P+aQL6mTPoT1ygqeVN0i6JhBJQDdqOY4JRV9jKHjd1t3UndTqhNFej gfHaf0MbjfnrBDZKHTtXByXKmHDgZxlhr8wOQ= 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=EkEWKS3KD6BOY8J1/VZIM+kubCBL2zD7NpsdCjfJLpE=; b=IXtW0Cdqzlajr8CaksT5hZQKH/9Ofq58435iLuY5X776SKwN//s6Dhr8tGsEDJZ2Nb 4io+2WTGI7Qke6rkNyk9lewbqWdsKh1yQT8bS0Ymv+FR9Aq+uNwO7uCw7AaWS8sudwYe uT5uGdxrIHZyLAbgqmiBx8E5xlLyozFdq3htiuoEn6/nGRGcAG1baHhxni873k34PkLt T1I/rMO213FO2Wl/PCplW1BlHsueIj+s7B9nCWk2czzdaIxirr0rFVUoTOtWIVssjc05 FBUBhZ5LSlPGfeZAYpJr5sz3hPPK6fPY/+/mRBjViOwLwN0dqeZRiX7WIp7VbSEq7azH q+Eg== X-Gm-Message-State: AJaThX4mIcrCoZklr/C6TrL5grkiSiUXEQPgodKvQ9LWeVh5OmRuI04T x30fmfs06xDOA1AIzC9fFf0pVtocBoc= X-Received: by 10.28.229.19 with SMTP id c19mr6967478wmh.156.1511461942681; Thu, 23 Nov 2017 10:32:22 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:22 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:02 +0000 Message-Id: <20171123183210.12045-9-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 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 --- 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 c74f4dd69d..3f87bf2051 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2133,6 +2133,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;