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

RE: [PATCH v3 6/6] xen: retrieve reserved pages on populate_physmap


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Thu, 5 May 2022 06:24:17 +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=gzQe7Cb12yxjblIaJlPcI092brMvHMWkPmc6L4PYCqA=; b=HQHHwdKkPYWGuhMzY9ZEpLpOzMT5jQ5pukvpUFD7hkfoZ6jtc3YFzphTTXPd82awA4Zj43tBbalG9qx4seDtjZkGao3GQvA2HXRYYGEtS9bTvz3y3cvK7pGG8JbPumE2tdZeoLdTd+w04uh4OBmh111JAaG+c7t12z53WcI8ngpuhDUZBZhWUO/M2/ssnMrdupv6Adhl9x9iZVbm6EbtuqgjxiRRYJUG8BKN1x1FmXnPwDxr81iX6dvqIsOhW9UUQG7Vs+TLJ7YKTcI9Am+/XpBsJeuAKUxhwniMcHi6nZmtWWPLAThIxWrD4Hx/TWgMb6AGMmyEg3mkfAbvouy3vQ==
  • 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=gzQe7Cb12yxjblIaJlPcI092brMvHMWkPmc6L4PYCqA=; b=nFdU0XquqbpHOfjPE3Gpdsz5dyDWhhaiz9FA11WppZD5xXe1qMvUh0IOBWtm2Or9sThSM62s+RCM1YIV0MWbJf04Dhzu1vgusUBLao0+YEukLjM8EkZae4wRX330Z2uZYL19a3WJiYRDUYd94pBEHLnnDUX+jOWeYA+ELcozC+RUt3TlRd/dYbXsj1RHwArXPEMacq2EIOilXljBodBxwhZw3PyZ5fowQymSXeU9bMwvjAkOyHco4dBlFF4X3LodVjXjH4PCGJSuVWA8GHH001nR/3TEHLkJOz22JRCC1CUGWuf/TBFQei34j5Uadk5vpyWOUFOnTk2+DL/rf5G/DQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=d3Y684bcOr79PPdtZ8HSiseYGEWdV+V8hRpOIJSeLwQiBoDfTiwyB0v3PPSQBXceWuWxGgAW0kHZX/+sHUFzrolpkJhZbIjRqHRh7Unus107ngZz+scVb24sdrNvB7oj9hopMZV5J038eoj/WUoTWKYjqa/g5jLSxrlHNuf8cpql4k6QxpHPzdv0n7AdetznEC0e/6xlu+RXHrATXpn0iKZKJ9+AgePmuw5SVHq4g/4ZC65GWQDZARC6lGkBp0ZN01fCCrDoFyviQFN26BeD8SNAl9WlS7yqHrJqkmT3plzUvo9ylRoSZ4MBnl4qX6tFhnJ1TjlFQLsiNmAQYWa+0w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ly14b8uW25XyRSsh/KnxrGFpNrGunA3n87uhYBCikSEwkHq6GVVNEo/HNz77lcmV1Pv6ORHbwRmmn5A41lHPQvPB/jdMjHFchTk3qpvu+ZVXskZ/VkAyMEUKyb6r2zeCrSbRA3Xu4hAHKjgD30KWQFc7+zqflRlAnkN1+Jdg68H97UbBpAprKtZVTQq2VFUTDTuQdYYgVK6nCTMecUxqTRdsj9sDhaonu881ITbZlGp8Dah0kGVaQZ2ApF35ke12n6F0cBcTmTkt7cJ12UfjTnlaKGSFg4NIC1ZqWS4vuh1xCT4WYKqZS0lXjyyGsfKDMnP3aQI6WxcFqsqh4cfWAg==
  • 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>, Henry Wang <Henry.Wang@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 05 May 2022 06:24:54 +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: AQHYWhlFOdBlNRd7J0aYNs5h64D4UK0OxgEAgAEVjwA=
  • Thread-topic: [PATCH v3 6/6] xen: retrieve reserved pages on populate_physmap

Hi jan

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Wednesday, May 4, 2022 9:45 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Henry Wang <Henry.Wang@xxxxxxx>;
> Andrew Cooper <andrew.cooper3@xxxxxxxxxx>; George Dunlap
> <george.dunlap@xxxxxxxxxx>; Julien Grall <julien@xxxxxxx>; Stefano
> Stabellini <sstabellini@xxxxxxxxxx>; Wei Liu <wl@xxxxxxx>; xen-
> devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v3 6/6] xen: retrieve reserved pages on
> populate_physmap
> 
> On 27.04.2022 11:27, Penny Zheng wrote:
> > --- a/xen/common/memory.c
> > +++ b/xen/common/memory.c
> > @@ -245,6 +245,29 @@ static void populate_physmap(struct memop_args
> > *a)
> >
> >                  mfn = _mfn(gpfn);
> >              }
> > +            else if ( is_domain_using_staticmem(d) )
> > +            {
> > +                /*
> > +                 * No easy way to guarantee the retreived pages are
> > + contiguous,
> 
> Nit: retrieved
> 
> > +                 * so forbid non-zero-order requests here.
> > +                 */
> > +                if ( a->extent_order != 0 )
> > +                {
> > +                    gdprintk(XENLOG_INFO,
> > +                             "Could not allocate non-zero-order pages
> > + for static %pd.\n.",
> 
> Nit: "Could not" reads as if an attempt was made, so maybe better "Cannot"?
> I'd also pull "static" ahead of "non-zero-order" and, to help observers of the
> message associate it with a call site, actually log the order (i.e.
> "order-%u" instead of "non-zero-order").
> 
> Also please omit full stops in log messages. They serve no purpose but
> consume space.
> 
> Finally, here as well as below: Is "info" log level really appropriate?
> You're logging error conditions after all, so imo these want to be at least
> "warn" level. An alternative would be to omit logging of messages here
> altogether.
> 
> > --- a/xen/common/page_alloc.c
> > +++ b/xen/common/page_alloc.c
> > @@ -2769,12 +2769,50 @@ int __init acquire_domstatic_pages(struct
> > domain *d, mfn_t smfn,
> >
> >      return 0;
> >  }
> > +
> > +/*
> > + * Acquire a page from reserved page list(resv_page_list), when
> > +populating
> > + * memory for static domain on runtime.
> > + */
> > +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags)
> > +{
> > +    struct page_info *page;
> > +    mfn_t smfn;
> > +
> > +    /* Acquire a page from reserved page list(resv_page_list). */
> > +    page = page_list_remove_head(&d->resv_page_list);
> > +    if ( unlikely(!page) )
> > +    {
> > +        printk(XENLOG_ERR
> > +               "%pd: failed to acquire a reserved page from 
> > resv_page_list.\n",
> > +               d);
> 
> A gdprintk() in the caller is acceptable. Two log messages isn't imo, and a
> XENLOG_ERR message which a guest can trigger is a security concern (log
> spam) anyway.
> 
> > +        return INVALID_MFN;
> > +    }
> > +
> > +    smfn = page_to_mfn(page);
> > +
> > +    if ( acquire_domstatic_pages(d, smfn, 1, memflags) )
> > +        return INVALID_MFN;
> 
> Don't you want to add the page back to the reserved list in case of error?
> 

Oh, thanks for pointing that out.

> > +    return smfn;
> > +}
> >  #else
> >  void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns,
> >                            bool need_scrub)  {
> >      ASSERT_UNREACHABLE();
> >  }
> > +
> > +int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn,
> > +                                   unsigned int nr_mfns, unsigned int
> > +memflags) {
> > +    ASSERT_UNREACHABLE();
> > +}
> 
> I can't spot a caller of this one outside of suitable #ifdef. Also the __init 
> here
> looks wrong and you look to have missed dropping it from the real function.
> 
> > +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags)
> > +{
> > +    ASSERT_UNREACHABLE();
> > +}
> >  #endif
> 
> For this one I'd again expect CSE to leave no callers, just like in the 
> earlier
> patch. Or am I overlooking anything?
> 

In acquire_reserved_page, I've use a few CONFIG_STATIC_MEMORY-only variables, 
like
d->resv_page_list, so I'd expect to let acquire_reserved_page guarded by 
CONFIG_STATIC_MEMORY
too and provide the stub function here to avoid compilation error when 
!CONFIG_STATIC_MEMORY.


> Jan


 


Rackspace

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