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

RE: [PATCH v5 3/8] xen/arm: allocate static shared memory to a specific owner domain


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Wed, 29 Jun 2022 07:49:54 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • 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=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zag62M8tH5+CJv1vPt7L0sAa1qAxkF/R0nqvxTkVhss=; b=hjGhXvQa+X7nPM7Ul7KFIoATcGyxUipE0pQ12DBfWvhOt8loN8PHPRY+5Yuz6FWFphvOtUH5AFklWcopz+C/j9PO154+oEqjWgDlS/FYmoZi4/S2rqxt8ETElJCpQMtD4+PAxXsdT5W86HF4J1msGnwoQIah3U6drbRgb1lNerE70XSBgednvpokhztHSj0mN9J83t0OqOD8v/FkVXpXjMxvpGfz3ggbyrmZTpG6yN9jDpK0krijiZZ+9F5hPbhMiC65/nZLYIAt56W12neFTqpMLRRxczADkBhx4r1n+VWeZ7bnQg/Qj/E1fcIthOZzbPrZPR/pU9/qzyTZpLDSaw==
  • 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zag62M8tH5+CJv1vPt7L0sAa1qAxkF/R0nqvxTkVhss=; b=bYTg3ThAknuCpXc1WhYzhVUM2mfq0FbAU+AZ2i29ocAx8oSDMo5oOusLWfbVlu7i8x1pstNUMvHixvHQQcYGxYdQvqxeXKtb0r2Jtrd+U4lssVl1c6OYZCZiFo6+coicT7vQGp8ua3Lt0Tmih/OTT0Quzm70D+6JnDcd0oGgxUJjuDzsbdQQx9j7Ya6lX/GE4Oj8AQC7SrZlIo/4tQe+LjiecRRYvIv1kFg2wvLJfe61T3icGEyjpecbKK04+cdwt00S4V2XLmkqRf/DKjVkll9K1CuJHfL6UlPJ08ccuGt3hACsTHJF7Q7TUXm8E7fM/5ThksnblqVhgJ6b1Eqoag==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=T5VCm9R5vCuBtUPeNG+XyONOMGS67zs7KSUUosDB8vavHp+gw6tRfILuACfZGHnohCAJAOThRru5loUoJbOTqYWalAUn9lrsqZ/H0tdBcJ01IxxngGzyr3nXhRvEXW5ra9U0sHmI+j/d1YUKq9cERle22YNQPVaFlpdz7CJONs+6uhBB1Z6CTUHWtO9OxfdiIojF+NhshPkBPPeTNdeIYStnYqKlcTOdawygxx0HjwegKz4FnqwXK9AfidafUExl2LDhUfXe5FMLNsDYVQklWl6+du45z77o0zPE8j+gYAaH7jvcnLzbfVBkuxAGXInAlBAPoztW0okhXgWWy5hVig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QLzFw7K/GlOYLe8e0i9iq2JiZVjk/qjKtWvNPtMcJBlYVgJIdaCFRxvMAXavnhk116AZO9Yw+ZeJdi2nPWonSz3V5JD4FhDtx4NuI0HgoGWlxJfSbOE3T2XvqXeVk4mlGki72VgnNcErE3MaphaxW6tM/g+VuoRAeD2l98Hekgr92PbfKYEQwQphmflK2dgRzKj4+SKWx4YPO+EfLZ6B4qBSi5f6IeMgsn1GDQOBLUAvBIjCo4GbsQMpT0MlG/f6DXTZNXXiHAtLurBFSYqRlFGf1zA5dmCOMIQRzptiK5GBdLWj3rBB0LF0t6/bT/HOSz9vU3gwo+kCJarAG5LElA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Wei Chen <Wei.Chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 29 Jun 2022 07:50:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYhGQ+VQS5G+xrzUihN2YrNBvaxq1e8m8AgAcdTKA=
  • Thread-topic: [PATCH v5 3/8] xen/arm: allocate static shared memory to a specific owner domain

Hi Julien

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: Saturday, June 25, 2022 3:07 AM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Stefano Stabellini
> <sstabellini@xxxxxxxxxx>; Bertrand Marquis <Bertrand.Marquis@xxxxxxx>;
> Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
> Subject: Re: [PATCH v5 3/8] xen/arm: allocate static shared memory to a
> specific owner domain
> 
> Hi Penny,
> 
> On 20/06/2022 06:11, Penny Zheng wrote:
> > If owner property is defined, then owner domain of a static shared
> > memory region is not the default dom_io anymore, but a specific domain.
> >
> > This commit implements allocating static shared memory to a specific
> > domain when owner property is defined.
> >
> > Coding flow for dealing borrower domain will be introduced later in
> > the following commits.
> >
> > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> > Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> > ---
> > v5 change:
> > - no change
> > ---
> > v4 change:
> > - no changes
> > ---
> > v3 change:
> > - simplify the code since o_gbase is not used if the domain is dom_io
> > ---
> > v2 change:
> > - P2M mapping is restricted to normal domain
> > - in-code comment fix
> > ---
> >   xen/arch/arm/domain_build.c | 44 +++++++++++++++++++++++++++--------
> --
> >   1 file changed, 33 insertions(+), 11 deletions(-)
> >
> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> > index 91a5ace851..d4fd64e2bd 100644
> > --- a/xen/arch/arm/domain_build.c
> > +++ b/xen/arch/arm/domain_build.c
> > @@ -805,9 +805,11 @@ static mfn_t __init
> acquire_shared_memory_bank(struct domain *d,
> >    */
> >   static int __init allocate_shared_memory(struct domain *d,
> >                                            u32 addr_cells, u32 size_cells,
> > -                                         paddr_t pbase, paddr_t psize)
> > +                                         paddr_t pbase, paddr_t psize,
> > +                                         paddr_t gbase)
> >   {
> >       mfn_t smfn;
> > +    int ret = 0;
> >
> >       dprintk(XENLOG_INFO,
> >               "Allocate static shared memory BANK
> > %#"PRIpaddr"-%#"PRIpaddr".\n", @@ -822,8 +824,18 @@ static int __init
> allocate_shared_memory(struct domain *d,
> >        * DOMID_IO is the domain, like DOMID_XEN, that is not auto-
> translated.
> >        * It sees RAM 1:1 and we do not need to create P2M mapping for it
> >        */
> > -    ASSERT(d == dom_io);
> > -    return 0;
> > +    if ( d != dom_io )
> > +    {
> > +        ret = guest_physmap_add_pages(d, gaddr_to_gfn(gbase), smfn,
> > + PFN_DOWN(psize));
> 
> Coding style: this line is over 80 characters. And...
> 
> > +        if ( ret )
> > +        {
> > +            printk(XENLOG_ERR
> > +                   "Failed to map shared memory to %pd.\n", d);
> 
> ... this line could be merged with the previous one.
> 
> > +            return ret;
> > +        }
> > +    }
> > +
> > +    return ret;
> >   }
> >
> >   static int __init process_shm(struct domain *d, @@ -836,6 +848,8 @@
> > static int __init process_shm(struct domain *d,
> >       u32 shm_id;
> >       u32 addr_cells, size_cells;
> >       paddr_t gbase, pbase, psize;
> > +    const char *role_str;
> > +    bool owner_dom_io = true;
> 
> I think it would be best if role_str and owner_dom_io are defined within the
> loop. Same goes for all the other declarations.
> 
> >
> >       dt_for_each_child_node(node, shm_node)
> >       {
> > @@ -862,19 +876,27 @@ static int __init process_shm(struct domain *d,
> >           ASSERT(IS_ALIGNED(pbase, PAGE_SIZE) && IS_ALIGNED(psize,
> PAGE_SIZE));
> >           gbase = dt_read_number(cells, addr_cells);
> >
> > -        /* TODO: Consider owner domain is not the default dom_io. */
> > +        /*
> > +         * "role" property is optional and if it is defined explicitly,
> > +         * then the owner domain is not the default "dom_io" domain.
> > +         */
> > +        if ( dt_property_read_string(shm_node, "role", &role_str) == 0 )
> > +            owner_dom_io = false
> IIUC, the role is per-region. However, owner_dom_io is first initialized to
> false outside the loop. Therefore, the variable may not be correct on the next
> region.
> 
> So I think you want to write:
> 
> owner_dom_io = !dt_property_read_string(...);
> 
> This can also be avoided if you reduce the scope of the variable (it is meant
> to only be used in the loop).
> 

Yes, it is a bug, thx!!! I'll reduce the scope.

> > +
> >           /*
> >            * Per static shared memory region could be shared between 
> > multiple
> >            * domains.
> > -         * In case re-allocating the same shared memory region, we check
> > -         * if it is already allocated to the default owner dom_io before
> > -         * the actual allocation.
> > +         * So when owner domain is the default dom_io, in case 
> > re-allocating
> > +         * the same shared memory region, we check if it is already 
> > allocated
> > +         * to the default owner dom_io before the actual allocation.
> >            */
> > -        if ( !is_shm_allocated_to_domio(pbase) )
> > +        if ( (owner_dom_io && !is_shm_allocated_to_domio(pbase)) ||
> > +             (!owner_dom_io && strcmp(role_str, "owner") == 0) )
> >           {
> > -            /* Allocate statically shared pages to the default owner 
> > dom_io. */
> > -            ret = allocate_shared_memory(dom_io, addr_cells, size_cells,
> > -                                         pbase, psize);
> > +            /* Allocate statically shared pages to the owner domain. */
> > +            ret = allocate_shared_memory(owner_dom_io ? dom_io : d,
> > +                                         addr_cells, size_cells,
> > +                                         pbase, psize, gbase);
> >               if ( ret )
> >                   return ret;
> >           }
> 
> Cheers,
> 
> --
> Julien Grall

 


Rackspace

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