From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EF68C433ED for ; Thu, 13 May 2021 22:58:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB4A2613F2 for ; Thu, 13 May 2021 22:58:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB4A2613F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.127102.238798 (Exim 4.92) (envelope-from ) id 1lhKHa-00015O-Qt; Thu, 13 May 2021 22:58:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 127102.238798; Thu, 13 May 2021 22:58:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lhKHa-00015H-Nt; Thu, 13 May 2021 22:58:18 +0000 Received: by outflank-mailman (input) for mailman id 127102; Thu, 13 May 2021 22:58:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lhKHZ-000159-4N for xen-devel@lists.xenproject.org; Thu, 13 May 2021 22:58:17 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 038240cf-730e-4e95-ba80-0b82c1316b3d; Thu, 13 May 2021 22:58:16 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 856FC613F2; Thu, 13 May 2021 22:58:15 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 038240cf-730e-4e95-ba80-0b82c1316b3d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620946695; bh=mJyZjD0j0jh/C9sjuzveh3hfW5aCZqoqnRKmjNZsgW8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=HocVW8WT1IhE6KWJGiBxD0c6F67fjN/+vtS+z8pA/p6izSawad3smgymhX7QUd7/l UdxQrjKzewHiCaSmwvjlB9arf3Do67S+youUOGslNjpWtbrrLdxWn/HGB5QGr1HzCV SlobJcf4rxZOGdo2KFTy80kpWYum/BpDi2+lzrxDBxX7h9PrUaDAoD6ePB8jFXNyl1 5loG41loVuce3jDzlXC5KXxP7YJK+aQxbVQF4S0kmIQkl1a0jfmVkFRtJe8wVhgYFH M/riNtAGx4tVMWWToRAydOxgBao0Aan3Dg5t/XL74FFYYut+ED9qrUZlq4VVUhM23s T5sABUu+8KHUA== Date: Thu, 13 May 2021 15:58:14 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Julien Grall cc: xen-devel@lists.xenproject.org, Wei.Chen@arm.com, Henry.Wang@arm.com, Penny.Zheng@arm.com, Bertrand.Marquis@arm.com, Julien Grall , Stefano Stabellini , Volodymyr Babchuk , Julien Grall Subject: Re: [PATCH RFCv2 11/15] xen/arm: mm: Allow page-table allocation from the boot allocator In-Reply-To: <20210425201318.15447-12-julien@xen.org> Message-ID: References: <20210425201318.15447-1-julien@xen.org> <20210425201318.15447-12-julien@xen.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Sun, 25 Apr 2021, Julien Grall wrote: > From: Julien Grall > > At the moment, page-table can only be allocated from domheap. This means > it is not possible to create mapping in the page-tables via > map_pages_to_xen() if page-table needs to be allocated. > > In order to avoid open-coding page-tables update in early boot, we need > to be able to allocate page-tables much earlier. Thankfully, we have the > boot allocator for those cases. > > create_xen_table() is updated to cater early boot allocation by using > alloc_boot_pages(). > > Note, this is not sufficient to bootstrap the page-tables (i.e mapping > before any memory is actually mapped). This will be addressed > separately. > > Signed-off-by: Julien Grall > Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini > --- > Changes in v2: > - New patch > --- > xen/arch/arm/mm.c | 20 ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) > > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c > index ae5a07ea956b..d090fdfd5994 100644 > --- a/xen/arch/arm/mm.c > +++ b/xen/arch/arm/mm.c > @@ -1011,19 +1011,27 @@ static void xen_unmap_table(const lpae_t *table) > > static int create_xen_table(lpae_t *entry) > { > - struct page_info *pg; > + mfn_t mfn; > void *p; > lpae_t pte; > > - pg = alloc_domheap_page(NULL, 0); > - if ( pg == NULL ) > - return -ENOMEM; > + if ( system_state != SYS_STATE_early_boot ) > + { > + struct page_info *pg = alloc_domheap_page(NULL, 0); > + > + if ( pg == NULL ) > + return -ENOMEM; > + > + mfn = page_to_mfn(pg); > + } > + else > + mfn = alloc_boot_pages(1, 1); > > - p = xen_map_table(page_to_mfn(pg)); > + p = xen_map_table(mfn); > clear_page(p); > xen_unmap_table(p); > > - pte = mfn_to_xen_entry(page_to_mfn(pg), MT_NORMAL); > + pte = mfn_to_xen_entry(mfn, MT_NORMAL); > pte.pt.table = 1; > write_pte(entry, pte); > > -- > 2.17.1 >