[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH 09/10] xen/arm: parse `xen,static-mem` info during domain construction


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Wed, 19 May 2021 07:58:08 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xnlDh86C58JYNQlFKUuNIswqitz6f1t8JwsKTbmEjoo=; b=aRxj5GyFLrc6pCw8g1dMZybUPIww5gPDSyi/7EGQOE4KIFL9p1JZEmzoEq6rn21jQ6/tm3v9c9ly6YpdLSy2DyBdZ3xPgJTnVIjqcLAtlL3+Nx+MyDxsrO6f2/1urHqEENOa3wn9MSOtJI9NquLr7ge1vmKnu2QuQApbR0b4DZOVQ4rzaEtcP0PTf0Kjn2c8wZ0+1YO33conOFBINPexkyjTRGSo+ejkH1DODIcNCQoHA+hIyb+MYOI2orMfz6UXZHexOt/dufQrYdHyU8bIxSEqpwuqlBnw0Wo/3DK8VZwR5waXD1t9xhCCBerNFw1VTOVpkKl3xlrh1QCS5R3G/Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eqm2VeoSASeFTA+bilaifRcRtpOns5oqVdaq2Esp1qwfucI6TEqCpknV8u88qmWc7KWFfRVT1qDA+xACodeZMDsdKv8l+uvsxZj3MDqr0Npg92qX6tuIIZvIgZuKd8uds/I6nmqyx5zb2XrLIZE8c1SAVp24/M4hj0DLN8VQ7r25/9GLIJLPpMKg8xT0c3UgBNHIGRA04PJlMFgCWZS2teC7kNabV/lM+3SV+UkYaLs+VZXobLQ3opzC/UweWk1GHTnZC4cv/gaCNn6MCce6zhRBjRPBhBq99Ggo4oMmRcZ1iXQ5YkstYiKPgWTQCu6RcDSj5yc2gOsO96dPzWm0pw==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, nd <nd@xxxxxxx>
  • Delivery-date: Wed, 19 May 2021 07:58:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXS6XDy5MrKETGVUijoDUAUijwiqrpJf6AgAFKs2A=
  • Thread-topic: [PATCH 09/10] xen/arm: parse `xen,static-mem` info during domain construction

Hi Julien

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: Tuesday, May 18, 2021 8:09 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx;
> sstabellini@xxxxxxxxxx
> Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>; Wei Chen
> <Wei.Chen@xxxxxxx>; nd <nd@xxxxxxx>
> Subject: Re: [PATCH 09/10] xen/arm: parse `xen,static-mem` info during
> domain construction
> 
> Hi Penny,
> 
> On 18/05/2021 06:21, Penny Zheng wrote:
> > This commit parses `xen,static-mem` device tree property, to acquire
> > static memory info reserved for this domain, when constructing domain
> > during boot-up.
> >
> > Related info shall be stored in new static_mem value under per domain
> > struct arch_domain.
> 
> So far, this seems to only be used during boot. So can't this be kept in the
> kinfo structure?
> 

Sure, I'll store it in kinfo

> >
> > Right now, the implementation of allocate_static_memory is missing,
> > and will be introduced later. It just BUG() out at the moment.
> >
> > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> > ---
> >   xen/arch/arm/domain_build.c  | 58
> ++++++++++++++++++++++++++++++++----
> >   xen/include/asm-arm/domain.h |  3 ++
> >   2 files changed, 56 insertions(+), 5 deletions(-)
> >
> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> > index 282416e74d..30b55588b7 100644
> > --- a/xen/arch/arm/domain_build.c
> > +++ b/xen/arch/arm/domain_build.c
> > @@ -2424,17 +2424,61 @@ static int __init construct_domU(struct domain
> *d,
> >   {
> >       struct kernel_info kinfo = {};
> >       int rc;
> > -    u64 mem;
> > +    u64 mem, static_mem_size = 0;
> > +    const struct dt_property *prop;
> > +    u32 static_mem_len;
> > +    bool static_mem = false;
> > +
> > +    /*
> > +     * Guest RAM could be of static memory from static allocation,
> > +     * which will be specified through "xen,static-mem" property.
> > +     */
> > +    prop = dt_find_property(node, "xen,static-mem", &static_mem_len);
> > +    if ( prop )
> > +    {
> > +        const __be32 *cell;
> > +        u32 addr_cells = 2, size_cells = 2, reg_cells;
> > +        u64 start, size;
> > +        int i, banks;
> > +        static_mem = true;
> > +
> > +        dt_property_read_u32(node, "#address-cells", &addr_cells);
> > +        dt_property_read_u32(node, "#size-cells", &size_cells);
> > +        BUG_ON(size_cells > 2 || addr_cells > 2);
> > +        reg_cells = addr_cells + size_cells;
> > +
> > +        cell = (const __be32 *)prop->value;
> > +        banks = static_mem_len / (reg_cells * sizeof (u32));
> > +        BUG_ON(banks > NR_MEM_BANKS);
> > +
> > +        for ( i = 0; i < banks; i++ )
> > +        {
> > +            device_tree_get_reg(&cell, addr_cells, size_cells, &start, 
> > &size);
> > +            d->arch.static_mem.bank[i].start = start;
> > +            d->arch.static_mem.bank[i].size = size;
> > +            static_mem_size += size;
> > +
> > +            printk(XENLOG_INFO
> > +                    "Static Memory Bank[%d] for Domain %pd:"
> > +                    "0x%"PRIx64"-0x%"PRIx64"\n",
> > +                    i, d,
> > +                    d->arch.static_mem.bank[i].start,
> > +                    d->arch.static_mem.bank[i].start +
> > +                    d->arch.static_mem.bank[i].size);
> > +        }
> > +        d->arch.static_mem.nr_banks = banks;
> > +    }
> 
> Could we allocate the memory as we parse?
> 

Ok. I'll try.

> >
> >       rc = dt_property_read_u64(node, "memory", &mem);
> > -    if ( !rc )
> > +    if ( !static_mem && !rc )
> >       {
> >           printk("Error building DomU: cannot read \"memory\" property\n");
> >           return -EINVAL;
> >       }
> > -    kinfo.unassigned_mem = (paddr_t)mem * SZ_1K;
> > +    kinfo.unassigned_mem = static_mem ? static_mem_size :
> > + (paddr_t)mem * SZ_1K;
> >
> > -    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d-
> >max_vcpus, mem);
> > +    printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n",
> > +            d->max_vcpus, (kinfo.unassigned_mem) >> 10);
> >
> >       kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
> >
> > @@ -2452,7 +2496,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 )
> > +        /* allocate_static_memory(d, &kinfo); */
> > +        BUG();
> > +    else
> > +        allocate_memory(d, &kinfo);
> >
> >       rc = prepare_dtb_domU(d, &kinfo);
> >       if ( rc < 0 )
> > diff --git a/xen/include/asm-arm/domain.h
> > b/xen/include/asm-arm/domain.h index c9277b5c6d..81b8eb453c 100644
> > --- a/xen/include/asm-arm/domain.h
> > +++ b/xen/include/asm-arm/domain.h
> > @@ -10,6 +10,7 @@
> >   #include <asm/gic.h>
> >   #include <asm/vgic.h>
> >   #include <asm/vpl011.h>
> > +#include <asm/setup.h>
> >   #include <public/hvm/params.h>
> >
> >   struct hvm_domain
> > @@ -89,6 +90,8 @@ struct arch_domain
> >   #ifdef CONFIG_TEE
> >       void *tee;
> >   #endif
> > +
> > +    struct meminfo static_mem;
> >   }  __cacheline_aligned;
> >
> >   struct arch_vcpu
> >
> 
> Cheers,
> 
> --
> Julien Grall

Cheers

Penny


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.