From patchwork Thu Nov 23 18:32:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119533 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1172965edl; Thu, 23 Nov 2017 10:34:12 -0800 (PST) X-Google-Smtp-Source: AGs4zMZvn04LrEjKKi9xljTM1E1lpFGdja1eDsI4gO+t72x7EPHV+Kt55tmHTun/TgLIcHwnBkVQ X-Received: by 10.36.70.195 with SMTP id j186mr12717002itb.32.1511462052785; Thu, 23 Nov 2017 10:34:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462052; cv=none; d=google.com; s=arc-20160816; b=eDE7SEnsUFdPwLFlZ9ccTx6vtvXahFVv5/0kwL98iv5EJwrJvOlx+HT+ZMatBBlg89 dMSJwaUrbqoDJLjyBAZmmTPMgZ0sdtyyXJlChDkpKqvX5aIkMNafscCDI1UnUE5UQLml N99AoPTCgBJU6mpMRTt5sfV59zssmY2RQHDZqTHh1RzCFqozIRW6XD4lqfUswrykJSCs kOJ+Qnofb5iN6p/r94ikBqnYjOuIlaNZam8LUwkEMKdd9oplI2T/ue6B8eGMakmrs5cG 2n5NOd9TPz/0jipAUvwvlLsgVa8CYEbQeAlvW4BJiE54oOkrFPpmJhNJrUG/pfadRCSE PyFg== 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=/mJxN7HeKZnY1JDbX8ZqU9MTrUj4kFy1Oo42aVP3JSs=; b=1H8w1rMRxg/yHeCTflevPiaOk0h1UiKXtldGqq+qnojnmZqVuCHjFz4Jb1peIIuol+ 7ZDpwEy1asbrZY7QgkjdFyzG1zWzspKxPJ5AT3x9gA2m2jr2YGUND16j92a6IUgyTOrO MFfIRYHPYr6GewUskieIVswjYVYZlsId1hp9yEtcBQpfc5IJril5/SOUES9/x9LA0Ajq TKjTxtZG4Fgw/jODEt+WVOoGe2TnD5/JDPNZpUsb4M6pizHMuKEJ57y+lSbhq5KLIgjG FhsyHSCvarKiiQUWj/flZicgHSybZ05LnzbQ/p9zFRMstJFrq91VGvGd1BIuB2Av87EQ nRMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gVG8ij+B; 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 n66si6601853ith.136.2017.11.23.10.34.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:12 -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=gVG8ij+B; 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-0005HQ-9l; Thu, 23 Nov 2017 18:32:26 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIT-0005Fm-Ki for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:25 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 88/7D-20334-834171A5; Thu, 23 Nov 2017 18:32:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMbThoK6FiHi UQccedoslHxezODB6HN39mymAMYo1My8pvyKBNePEoZWMBa1CFRfvv2ZrYDzM28XIxSEkMJlR 4n5/BwuIwyIwj1libV8DE4gjIdDPKvF7whbGLkYOICdPoudQaBcjJ5CZJtH7Yyo7hF0tcf/YY yaQEiEBNYk1b6IghvYxSfx49IcNJM4moCOxbkYtSLmIgLTEtc+XGUFsZoF4icdTr4OVCAtkSE y9GQISZhFQlVjZMYcNxOYVsJVYfnEuC8QmeYldbRdZQWxOoPjRAx+YIbbaSHz+rDiBUXABI8M qRo3i1KKy1CJdIyO9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK95PzcTYzAUKtnYGDcwbin 3e8QoyQHk5Ior8wvsSghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErySwuJRQoJFqempFWmZOcCgh 0lLcPAoifCmgaR5iwsSc4sz0yFSpxjtOS7cufSHiePAnltA8tnM1w3MHNOutjYxC7Hk5eelSo nzeoK0CYC0ZZTmwQ2FReklRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8b4WApvBk5pXA7X4 FdBYT0Fk/jwuDnFWSiJCSamA8yDXvDIOIX2BLLQ8j+4IthXYR7+wYZ+/8djKgc8vf4huntvZ9 u76Qd6bcNMdNCkWJpo1eht2TIqxfVEzemROUb8tZYvt+1+Ybu2fkp5Tnefx6esLHUP1w4Kq0i ae+3lotmWUv6B/HcXKH+8KoNn1eHf2XaQYvK7myA+96tvHbLlw6j9lxxRIlluKMREMt5qLiRA BflyXNzQIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-206.messagelabs.com!1511461943!93057739!1 X-Originating-IP: [209.85.128.193] 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 10017 invoked from network); 23 Nov 2017 18:32:24 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:24 -0000 Received: by mail-wr0-f193.google.com with SMTP id l22so18298029wrc.11 for ; Thu, 23 Nov 2017 10:32:24 -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=ah/TxKQ67+b+C7qrGiEEvL3vmN2Qqd+Tgaa6bNltHpQ=; b=gVG8ij+BA5EVgsPjSFz1Ivg3N+rbyv3HCrIFvdLzCBBwO/3c2/XPHr/0wMx8wGipSM /5a3a63tU8fgx6w46kIzyOreLZHZ/tmCa98JhGMWjsifVP+EsR1AUA9p4htiRCpQXIcJ htR5idJTgdywH/XsMOmvH6yaSzXNP0I4v2YcM= 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=ah/TxKQ67+b+C7qrGiEEvL3vmN2Qqd+Tgaa6bNltHpQ=; b=JW4QQDUXZVhRXV4txMCLLf2Ndbti9B/Lcj8ysfg0xQWfZqJvuXAjo14yyiQF4YWtjW rbdWPtIdJivUsJGlOYmW1nSLZyM0UD5/q230Immuo2Ra3A4tAbw9W38gfUqlEY7k5jfb r1UMPEiYZTOpAKz3vn335rTNtbjXVNrDPGoemfxOLpxaNI6JeV0777xtvm7dRuh0DIEd kcEnDfgMAm6VimOtcWs5H5UiDLpxWcfQyHym4KU3TlRr2wKkunKuqr6F1rd8Mlt2vL5p aKmBCbApiiUlZ/WKKPNF+rQXkqZB6H1PNFUo/X5lgI49YB0KjPzsxKKOCf0JgF5QTEyX 8FEA== X-Gm-Message-State: AJaThX78ks7lwCM8Cv0pPGMbeAqad0A7U2DT6vyTa+fK9E3rtOUWFp6X d91MOAZYYHF81kT4z1fDP7AvpOCjKfk= X-Received: by 10.223.160.61 with SMTP id k58mr14048662wrk.252.1511461943550; Thu, 23 Nov 2017 10:32:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:23 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:03 +0000 Message-Id: <20171123183210.12045-10-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 09/16] xen/arm: domain_build: Rework initrd_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 initrd_load 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 initrd in the virtual space. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 3f87bf2051..42c2e16ef6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1966,11 +1966,11 @@ static void initrd_load(struct kernel_info *kinfo) const struct bootmodule *mod = kinfo->initrd_bootmodule; paddr_t load_addr = kinfo->initrd_paddr; paddr_t paddr, len; - unsigned long offs; int node; int res; __be32 val[2]; __be32 *cellp; + void __iomem *initrd; if ( !mod || !mod->size ) return; @@ -2000,29 +2000,14 @@ static void initrd_load(struct kernel_info *kinfo) if ( res ) panic("Cannot fix up \"linux,initrd-end\" property"); - 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 translate guest address"); - return; - } - - dst = map_domain_page(maddr_to_mfn(ma)); + initrd = ioremap_wc(paddr, len); + if ( !initrd ) + panic("Unable to map the hwdom initrd"); - copy_from_paddr(dst + s, paddr + offs, l); - - unmap_domain_page(dst); - offs += l; - } + res = copy_to_guest_phys_flush_dcache(kinfo->d, load_addr, + initrd, len); + if ( res != 0 ) + panic("Unable to copy the initrd in the hwdom memory"); } static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)