[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH v9 2/8] xen: do not free reserved memory into heap
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Penny Zheng <Penny.Zheng@xxxxxxx>
- Date: Tue, 26 Jul 2022 03:15:50 +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=+EUfJweFe5RBt67MncQk4V6z7mqKjpeCFTB5GPYH/YE=; b=TC+DD3KJYaO6lCL6FQLWycm2bGHpQmn4+7q43lsfhtomGKeGyCUFLu1GpuZPQk2xIqNK/kKM4bDZ+0L6ClhSXIcvoAbUYi7JdppsJL34RjWzWwSpq+7B40nmHcrip7tiBU2RKRSwDzj/YOg3eZvn6tKlwqKnx7ItYuOLRJNC7vfx8LEMBtHZSrZJqnwairtqq+tB98sOhEPNP38tZPFGxSPtvU4rV/zy2Rk6Um/sEQAZ1FYaysAIVoCazTa2bINuQksKoeoCmUwODzy6NKunrXafTZReqtWigXi/xQsCjyR3BIPdqPFLizkKwCiV7rjVSd1d9kiNIoof5ATcrCnCwQ==
- 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=+EUfJweFe5RBt67MncQk4V6z7mqKjpeCFTB5GPYH/YE=; b=E3iNlYtB4YYtdpKP96TcCC413IqtsPjvGIbr8Jn/NnPqrdLB/ikKQuNfgBQG3q2jl3oMMcJRCcBJb1fSgkmAthpEMQhO+VEy4aN1M74bgbJXBDjJSJeI4pGV3w7/5f2UySml9jvJ31IHBpEH4bkvQEoRErfNVKDJG6DabLIPhpnFiG+Kzoq0ZtZYqgx4MJuL0xZpSHpFWfjMKft57HkAJwb7c/FUM6WgrZUEajMn+dCy3uqNXyNhJOFjH2/M0DyNPgXHRGeLcsi2qYOCUUS+qzXHZ7zOkBYLFM/H2noXsJ/RDbetnsaXVf0IDVwHK88rtbDXej65n1E9cUpL8TG3pQ==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=PtivYfqHfRTq4dMhixuUNngkkRA1cFt6c/0Mn0w8Gt227f/YPq922YtfUbgIY1Dad9+T7C5nga94mbRPrqjHpMJCUW1xcgjk1Weskpa75MTfyuk01z0yqw0c4Oi6mBobmhJrWbPnxCMCj8Gs6D8oKsznlexDC2vsvvSZyPDs8bbDHjzhsSytNItdJVZ1eFAFK5gFnSk51ldA1Mf/xNRQacdgWCdPlxVDztPrRkgLrMCmWKRGrJcXbiyP13E61FiTtkwo4DX/Nmc2Bvey9+W6s6oWoS5A3xBjVTBo4UTaB1cSroevp5a4Oky1aVMjr8sxAX8y+AUZNgnY8f35KjyaiQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NW5ufMjq0ejkwB/Tec+6wC+D3K5atEwfqksRbgKQdV+IB9lZ1G0pxa4FJssTBjn0xWhXL9+H6wGN6W/8tTq6kMGPxhh37qZ8rl59NK0TyS/ibLCas5tCDTWk45rZHlyKaH+oX5PNj3lK1Rtsyf9zSVWx2Z4fUI2ax7ZErheaRa4TDjmfPyJsNaIrVpbHwyYJRUmkTl8aXMP9GIdA7zJ837EMIHFy9iNOqCIKoo9cTCmkwRtvVr7awRh+gqXkktPlA1w3SPHNCAAC5B3KohPDvQ5Cb4l6YjHL1t1EeXvnIfZzW/mYEHBFb+UIpb4huC1bHj+7LbshOT4bwP2R5lxNbw==
- 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>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Tue, 26 Jul 2022 03:16:21 +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: AQHYm/wkzpoqdfP5/kKS0Y1Fu7qjpq2PPrOAgADESLA=
- Thread-topic: [PATCH v9 2/8] xen: do not free reserved memory into heap
Hi Jan
> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Monday, July 25, 2022 11:30 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Stefano Stabellini
> <sstabellini@xxxxxxxxxx>; Julien Grall <julien@xxxxxxx>; Bertrand Marquis
> <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> <Volodymyr_Babchuk@xxxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; George Dunlap <george.dunlap@xxxxxxxxxx>;
> Wei Liu <wl@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v9 2/8] xen: do not free reserved memory into heap
>
> On 20.07.2022 07:46, Penny Zheng wrote:
> > Pages used as guest RAM for static domain, shall be reserved to this
> > domain only.
> > So in case reserved pages being used for other purpose, users shall
> > not free them back to heap, even when last ref gets dropped.
> >
> > This commit introduces a new helper free_domstatic_page to free static
> > page in runtime, and free_staticmem_pages will be called by it in
> > runtime, so let's drop the __init flag.
> >
> > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
>
> Technically
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> Nevertheless two remarks:
>
> > +void free_domstatic_page(struct page_info *page) {
> > + struct domain *d = page_get_owner(page);
> > + bool drop_dom_ref;
> > +
> > + ASSERT(d);
>
> I wonder whether
>
> if ( unlikely(!d) )
> {
> ASSERT_UNREACHABLE();
> return;
> }
>
> wouldn't be more robust looking forward.
>
> > --- a/xen/include/xen/mm.h
> > +++ b/xen/include/xen/mm.h
> > @@ -85,13 +85,12 @@ bool scrub_free_pages(void); } while ( false )
> > #define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0)
> >
> > -#ifdef CONFIG_STATIC_MEMORY
> > /* These functions are for static memory */ void
> > free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns,
> > bool need_scrub);
> > +void free_domstatic_page(struct page_info *page);
> > int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned int
> nr_mfns,
> > unsigned int memflags); -#endif
> >
> > /* Map machine page range in Xen virtual address space. */ int
> > map_pages_to_xen( @@ -212,6 +211,10 @@ extern struct domain
> *dom_cow;
> >
> > #include <asm/mm.h>
> >
> > +#ifndef PGC_static
> > +#define PGC_static 0
> > +#endif
>
> This disconnect from all other PGC_* values isn't very nice. I wonder as how
> bad it would be seen if Arm kept its #define to 0 private, with the generic
> fallback remaining in page_alloc.c.
>
It, right now, is only used in xen/arch/arm/mm.c and xen/common/page_alloc.c.
It is ok to let Arm keep its #define to 0 private, with the generic
fallback remaining in page_alloc.c.
> Jan
|