From patchwork Tue Dec 12 19:02:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 121634 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4508506qgn; Tue, 12 Dec 2017 11:04:35 -0800 (PST) X-Google-Smtp-Source: ACJfBouNtL0M0mCGC56CP2fNqTswrEvJH0en52FxeHPGblkAQkzFZF+rEWQF95/WD8aznLh89uZ7 X-Received: by 10.107.169.152 with SMTP id f24mr6361702ioj.219.1513105475329; Tue, 12 Dec 2017 11:04:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513105475; cv=none; d=google.com; s=arc-20160816; b=RdLXi1eucMnsddX67wlui/AhFOsHrL8zL4W/ggRFtnPWyTUdwnMq4kfn2yWGWXk7A8 kPxmi13BEDQ8u1TGo5NY+mnUjh/MkBSA8aal6qUnzG9rC03FL/PDSliQFA5hzWwnjKoq FOasyBRtHL2QcQuKLSdEp7xh58gObVGKJ2vQngWrTiEbZsbgVmM571PZKfmKtSrBLoZc hNpcLvBJidLgLd+BNhS0KRjUNqZjUWIVv1Ju04vsRyPut6ftZo/InRtL7nAzz5Hi5jLH 0cU3YrA/90V3rhyjXVDycX8NI79vkYTIhb3A5LPsB9GnGjK6UB4eAgFCR0kuXGetis0H Em4Q== 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=pbU/cNVw3C3eZcDyk7Pcqz8KcQMQI8s3FmJayqUL1Vg=; b=GcszxU1krqdlaNGsLQBEJeZtloVfKCQHj7WrlQpePwFae3FMPgc2t4a4RkspnZwZhB fVOCPDAg4/xs8xx+elIB2ia2N3vLee5HLb6yI+/gS7GNM293QEG/4NqSMk5hS62lKV2W NcjWV/+FUaqfo9jBXceoY57a/m2ycYXfczBRh5bVWaBUWqpxBF2kUc4ST2QXh1Mf6HN/ xqnwOZi9Adt1pFs33R0lU+l50leWe9MiRF45mYkW9DwKZnCJfzNv8ogjIVXO/t+Ao9Jr ocEdll2xOqpuzTK+Iacryi7ReGzYS/jy9IrqmsEilYN1Rs9yTdq0qmkDW7WUkjDy3I47 hVuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UyDnKcNh; 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 y62si191725itg.38.2017.12.12.11.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:04:35 -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=UyDnKcNh; 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 1eOpp7-0002b2-0z; Tue, 12 Dec 2017 19:02:37 +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 1eOpp5-0002ZM-EW for xen-devel@lists.xen.org; Tue, 12 Dec 2017 19:02:35 +0000 X-Inumbo-ID: ef46245b-df6e-11e7-b4a6-bc764e045a96 Received: from mail-wr0-x241.google.com (unknown [2a00:1450:400c:c0c::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ef46245b-df6e-11e7-b4a6-bc764e045a96; Tue, 12 Dec 2017 20:02:01 +0100 (CET) Received: by mail-wr0-x241.google.com with SMTP id l22so22203747wrc.11 for ; Tue, 12 Dec 2017 11:02:33 -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=Qd4oZes4m/rpQ0NKa8VAFcomBS8OlY6pRMzFwuSfxb0=; b=UyDnKcNhiyXEPinaoQEc4Pio4410BrGM4nEBTga65np8DMPvpt08IbKYumNy7r0Rzu 57M7U3AfXNtCTSSKNb+Yks67u1X6VC3y3us+WXEtK/Q2zPk1c/NnD2UxdX8MFEopSAPz 1NdkOUsMk/0wX+B81n1yganfghMe3sKgwbmsU= 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=Qd4oZes4m/rpQ0NKa8VAFcomBS8OlY6pRMzFwuSfxb0=; b=sbEve4bxhbByTvpWtdF+omgJZr8pWj7SdfCISqbklPHMi1bzKX9b1pD7nXpqqdxTFL jidKf2Vw5rOGz4YSxrsRGaMF1jm09HOcbeO5tCjQmYAp2oChzKq0Ij9eN9rqOVkpWdW5 gTADCIDdqNDoH0ibxbYiGDzbHphEtBUnOACabzedEd3YMKiUFU2mWNs2442XtpCzrUXj 43gqo3153p1cD3bIQEH5MmamFDiQQFY4NGA6fTM0HWqov9/Nyi46SCl3Yj0ut3oz6HvF Z5U6s++zWbUbA5u2uXxiSzwVw98vKLmvTLrkkMnsIL8QBjsF3jsDTMZrLvI1JIPPNCws tCSQ== X-Gm-Message-State: AKGB3mIV9CQfg8vxWuwl1L7C2Q2J/dfEy+RUjPYxPoa7USVb8h18ny0P QphMIccIAw1bdlQmwliXSmrlFkE6VOk= X-Received: by 10.223.185.79 with SMTP id b15mr4964208wrg.58.1513105352490; Tue, 12 Dec 2017 11:02:32 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:02:31 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Dec 2017 19:02:05 +0000 Message-Id: <20171212190212.5535-10-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 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 --- Changes in v2: - Add Stefano's reviewed-by --- 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 aa6ff8d456..66fd77def6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1968,11 +1968,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; @@ -2002,29 +2002,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)