From patchwork Wed Nov 28 16:49:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 152311 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1321025ljp; Wed, 28 Nov 2018 08:51:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vnz9eblg8UNzalJWYSQUvp4cED2xXKsAzLzA7OmeTiq7AXAs2gOZgGZSPfb5Phg15Ao24d X-Received: by 2002:a25:7a43:: with SMTP id v64-v6mr13135518ybc.187.1543423919575; Wed, 28 Nov 2018 08:51:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543423919; cv=none; d=google.com; s=arc-20160816; b=FlO/aFtTVeFnaDXyfn5P+lzgL861iCiiop1vmab5EEvKYIByxFTT/0axD3Sr2KLwGl LPqTLJO1WZfL1HjZZ7Ekfu48QTLiogmacQ1xfJh3ML8Kewz9vY6BzrJ5WZAVbC4E8sZa 1fDVsNL8bOe3cKpZ96tC0Ni5oiRgW/PR7Qj24JuY0iFtvhfkRgj8YygHfcZi8tXBeS4F OTPjOze5c0Ej7S5C4teUNhUGY5xZDwECvOGdqwZfQdmMSRlHrOqIZ0KxiQ0fPlVsgEUa K+O91hiXx2kgY8KRHpaUBsX/m6w72JFV36mHwwoEjmfv/Bfc1+HFHgmLEqEzPmxJXy3p Gg2A== 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=+An0hepsK1qfjfb199zOVOemDCma7pWftIPg5FiQhBU=; b=dioXMf5/SCwRtlB3T3G/iUbNK4H2BTJV8g4Tcxu/jm3i+f7uzCRN2xgOACmecd43ho V3JGIpbFvwE7XN7xpkV1ShTTyxxvz8xICFU1iFkDPJGFP5AmffLJ00o/W+V0DZ5BgWHp TJcnoIFCA0Stzg7Y5HPYoVhoy+WH0NP2gIJuna0xs12/wJZdPxzNNEDYpSndrR0i5om0 XsFqVwapbO4QpH8dTVi3Sm4Mc6y4JDPr2A0k8qdBZ/TAXKfAvSIHBtWee1U0Rww1o0Dp sjhalgJyFHcrvWfeGI3megL1zUrUrr9LCZta92jXGCJYKZYn6tU7GQfIW3MS/6z6U4MT skPA== 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 k84si3013349ywb.147.2018.11.28.08.51.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Nov 2018 08:51:59 -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 1gS328-0000rA-MS; Wed, 28 Nov 2018 16:49:52 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gS328-0000qv-6G for xen-devel@lists.xenproject.org; Wed, 28 Nov 2018 16:49:52 +0000 X-Inumbo-ID: 9f996d6b-f32d-11e8-9a16-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 9f996d6b-f32d-11e8-9a16-bc764e045a96; Wed, 28 Nov 2018 16:49:51 +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 D2768382E; Wed, 28 Nov 2018 08:49:50 -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 E63063F575; Wed, 28 Nov 2018 08:49:49 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 28 Nov 2018 16:49:34 +0000 Message-Id: <20181128164939.8329-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181128164939.8329-1-julien.grall@arm.com> References: <20181128164939.8329-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 3/8] 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: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org 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 --- 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 8ebf1e8dba..e8bacab9d2 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1136,21 +1136,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));