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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,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 615E9C4338F for ; Fri, 13 Aug 2021 13:12:34 +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 20AAB6103A for ; Fri, 13 Aug 2021 13:12:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 20AAB6103A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.166802.304470 (Exim 4.92) (envelope-from ) id 1mEWyx-0003nf-5g; Fri, 13 Aug 2021 13:12:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 166802.304470; Fri, 13 Aug 2021 13:12:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mEWyx-0003nY-2S; Fri, 13 Aug 2021 13:12:19 +0000 Received: by outflank-mailman (input) for mailman id 166802; Fri, 13 Aug 2021 13:12:18 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mEWyw-0003nK-1B for xen-devel@lists.xenproject.org; Fri, 13 Aug 2021 13:12:18 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mEWyv-0006NM-QS; Fri, 13 Aug 2021 13:12:17 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mEWyv-0004DJ-Kr; Fri, 13 Aug 2021 13:12:17 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=YoBpmUY41pS4/1G2KQwInQItCFgrO9vEF5W2caDnQZI=; b=lMvewBwdBQUupL6qiWq93li+8a WtwS73v4aiSJYHR15JARuh6UjS1WXNCDB24JpAGtw/kwSraHgQMCfXz+YKaq0IWIsrOwbP8VMFitZ Fep5ubSEUIhbiC911AulUtNUupkdKRzVY816xFt9Kby7O3zbQBeAN/9ey+6cDABodIzw=; Subject: Re: [PATCH V4 09/10] xen/arm: check "xen,static-mem" property during domain construction To: Penny Zheng , xen-devel@lists.xenproject.org, sstabellini@kernel.org Cc: Bertrand.Marquis@arm.com, Wei.Chen@arm.com, nd@arm.com References: <20210728102758.3269446-1-penny.zheng@arm.com> <20210728102758.3269446-10-penny.zheng@arm.com> From: Julien Grall Message-ID: Date: Fri, 13 Aug 2021 14:12:15 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210728102758.3269446-10-penny.zheng@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Hi, On 28/07/2021 11:27, Penny Zheng wrote: > This commit checks "xen,static-mem" device tree property in /domUx node, > to determine whether domain is on Static Allocation, when constructing > domain during boot-up. > > Right now, the implementation of allocate_static_memory is missing, and > will be introduced later. It just BUG() out at the moment. I think the code is small enough to fold it in patch #10. In fact... > > Signed-off-by: Penny Zheng > --- > xen/arch/arm/domain_build.c | 37 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 36 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c > index 6c86d52781..cdb16f2086 100644 > --- a/xen/arch/arm/domain_build.c > +++ b/xen/arch/arm/domain_build.c > @@ -2425,6 +2425,37 @@ static int __init construct_domU(struct domain *d, > struct kernel_info kinfo = {}; > int rc; > u64 mem; > + const struct dt_property *static_mem_prop; > + u32 static_mem_addr_cells, static_mem_size_cells; > + bool static_mem = false; You don't need those information outside of allocate_static_memory(). So I think it would be best to move the code in that function. > + > + /* > + * Guest RAM could be static memory which will be specified through > + * "xen,static-mem" property. > + */ > + static_mem_prop = dt_find_property(node, "xen,static-mem", NULL); > + if ( static_mem_prop ) > + { > + static_mem = true; > + > + if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells", > + &static_mem_addr_cells) ) > + { > + printk("Error building DomU: cannot read " > + "\"#xen,static-mem-address-cells\" property\n"); We don't split comment over multi-line (even they are more than 80 characters). This is to help grep message in the code. Although for this one I would replaced "Error building Domu:" with simply with the domain ID (you can use %pd and 'd'). The caller will then print there was an error during building. > + return -EINVAL; > + } > + > + if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells", > + &static_mem_size_cells) ) > + { > + printk("Error building DomU: cannot read " > + "\"#xen,static-mem-size-cells\" property\n"); My remark applies here as well. > + return -EINVAL; > + } > + > + BUG_ON(static_mem_size_cells > 2 || static_mem_addr_cells > 2); Did we validate the DT before hand? If not, then I think > + } > > rc = dt_property_read_u64(node, "memory", &mem); > if ( !rc ) > @@ -2452,7 +2483,11 @@ static int __init construct_domU(struct domain *d, > /* type must be set before allocate memory */ > d->arch.type = kinfo.type; > #endif > - allocate_memory(d, &kinfo); > + if ( !static_mem ) With my suggestion above, the check can be replaced with: if ( !dt_find_property(node, "xen,static-mem", NULL) ) > + allocate_memory(d, &kinfo); > + else > + /* TODO: allocate_static_memory(...). */ > + BUG(); > > rc = prepare_dtb_domU(d, &kinfo); > if ( rc < 0 ) > Cheers, -- Julien Grall