From patchwork Mon Jan 28 11:50:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 156718 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3333320jaa; Mon, 28 Jan 2019 03:52:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN7GgGGcFrMKnAEW38tmnKWrndM3gzUVKeyK1axftt9ALC833mpJfECO5B+YD9YECvx/vh8U X-Received: by 2002:a25:bb04:: with SMTP id z4mr21424534ybg.38.1548676350519; Mon, 28 Jan 2019 03:52:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548676350; cv=none; d=google.com; s=arc-20160816; b=nfwcQmgOQFKPZrmacTRE2ljnk8DDF/idnKSFZehSs7f6HxcC81cMXfXHbu40lTdC2T xFNaDcE0numl9LoWX0Iw8gTCL3zBGlarFG1xrpUnBOHZYuTddzQ2xTC2pfX6yauf+whm 6UOZm4gr7IoSjES1TyKFmXZbfk06IqzZD5ZwjwbcL3h2hFm8AuQXd+TG9kEENjWSLevp icFBWQk8H6Fmz9qGBf7yFFoiu/dq1SsIEdInmZGBRJbKsvKoiAj+acZGFQ2Pi6mPibjt xoESUpThfnjZGTKFHBXPnYrGo9s/2a/fnnbNi+1HI7KvRItMxxRiaO/+hioNnqQdolpO UK5w== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=Jezc4ZpQIXVvCSSWLXK1GmXcXGUrDir6qdKiidFuw8g=; b=BZ7rD+ETYJOI+8GnBMOYJIbEs594bH86nKPwF26SpP+Et5mrGasi/hSqiO0CRMb8ZJ MJooZkwicOjtXHVSr3FvLQES8uq3y8FknSR+DIZn7+rTMMbk+9Rcfhbo/D1zUdnxJ1TH suv4k+wu+SBTq+ylLptgrro8ZDdSaMNpxeYNirigBpnbis9OuZQ/HTnSoRbhHHM1wPCr 3njwjS167jdlwkTPM03HtA8ro92MPAXuYdERwmOMlRkHDYMY/h6glDQfYz/qFHv7jDj9 nlNqnxcQ7BI1a+x6+iTbUcmrqb7vrTPKyM7YxkU6pcXWksLpfShWMZ6Y+y42WRdZskTM WMtg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i129si18659836yba.47.2019.01.28.03.52.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 03:52:30 -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; 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 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1go5R0-00035F-L7; Mon, 28 Jan 2019 11:50:38 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1go5Qy-00034p-M8 for xen-devel@lists.xenproject.org; Mon, 28 Jan 2019 11:50:36 +0000 X-Inumbo-ID: eca345ba-22f2-11e9-aeee-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id eca345ba-22f2-11e9-aeee-bc764e045a96; Mon, 28 Jan 2019 11:50:36 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AD83315AD; Mon, 28 Jan 2019 03:50:35 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C13013F59C; Mon, 28 Jan 2019 03:50:34 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 28 Jan 2019 11:50:22 +0000 Message-Id: <20190128115026.3336-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190128115026.3336-1-julien.grall@arm.com> References: <20190128115026.3336-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 v2 3/7] xen/arm: p2m: Introduce an helper to allocate the root page-table X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org, Andrii Anisov MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A follow-up patch will require to allocate the root page-table without having a domain in hand. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Andrii's and Stefano's reviewed-by --- xen/arch/arm/p2m.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 38bfa9964f..9844bfb936 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1353,21 +1353,29 @@ int guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn, return p2m_remove_mapping(d, gfn, (1 << page_order), mfn); } -static int p2m_alloc_table(struct domain *d) +static struct page_info *p2m_allocate_root(void) { - struct p2m_domain *p2m = p2m_get_hostp2m(d); struct page_info *page; unsigned int i; page = alloc_domheap_pages(NULL, P2M_ROOT_ORDER, 0); if ( page == NULL ) - return -ENOMEM; + return NULL; /* Clear both first level pages */ for ( i = 0; i < P2M_ROOT_PAGES; i++ ) clear_and_clean_page(page + i); - p2m->root = page; + return page; +} + +static int p2m_alloc_table(struct domain *d) +{ + struct p2m_domain *p2m = p2m_get_hostp2m(d); + + p2m->root = p2m_allocate_root(); + if ( !p2m->root ) + return -ENOMEM; p2m->vttbr = generate_vttbr(p2m->vmid, page_to_mfn(p2m->root));