[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH v3] xen/arm: p2m: Populate pages for GICv2 mapping in arch_domain_create()
- To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Henry Wang <Henry.Wang@xxxxxxx>
- Date: Mon, 17 Oct 2022 15:54:04 +0000
- Accept-language: zh-CN, 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=CFdxsbDalMzwVZO0L318eW7ifMyVW7uS8kLd+vdvrl4=; b=H4DAkZHvxBFdDjSdO97m5/ppHoMcw4+IJFDnwiioWCJ8In8oHf95pE4Us/OHbeFIGVj1v0VPPFEt3qhcC9rYenjYIV8wmE+9W24ODvlo2LblEzqP4f48av4Kr2nrrYnERgXa14Z1nbSz3GZVw85f2sKZGEMMnITH4Gxo3+yCLDVmustCbH4D+G7mRxsEooFHV/eyLFvpAK3fyA2llgKw5L8nHzLf9Pixoqz40Np68C6J+I6WzznDuUK0Kn11QEFzbXjTHBWP36e0VPmD9PeQZysb8YgpTgvnD7zytMCL5pwvhOdJWR98r0LBnWv3cXBOb43OZ+oEUs09cvlpEGujvA==
- 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=CFdxsbDalMzwVZO0L318eW7ifMyVW7uS8kLd+vdvrl4=; b=Saz9qO69JNiNoYcBm663qr5Go5SlPUHh9r4IZitK39y83WlmoHRMRMc+sk6xPsvHCITlPqHSI3S+z6fSDEkMotukUQvI+rjhqObER738r1DdpMkerepNZKVOtFcqeF1jbUH11WNuNn2H/97vKeMrKzJOKdMty5blXOhhHoIDR2u+Q8AREojNhsKRi1lQvCyIU/awKNR0vCClKmyubC54cXP6vBBZ6Q32Tmb1PXf8nojWxXlsQNWON+EBzqxLSCWozEBMbLLgkUnhYXLJs9ZaXxX21oTJ3/O7Sm9tKoMaoZd1KvNQQ/BXNFvkt5KYXcX1m1wdijjSQB0lMi/twT1OUg==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=XsQaHp1wAKtAbsjgDIbxubearosftaXWUWc1fT3HOOAqGeNyfHLkKatutRtYlDLCFgKc0vle+IHmJDF0b5rfwyAhNiw4tqTLDR1gN+WtkRlHf2ukNZ6vSmhrDnHT3jkrM5qEsvU8WGyNrkxYdazzU0Biv7r+cbNbIHJPY5doZZrLl6cd0IYfKhwSzAis0T3xlWDY5BuKRtNi7ChdGjgIZT3kacwBpCIWPpZ28FR2eKnuCJ6/Dq9rcIU/IU+7CLqBWPnM1sy8KKt3xLABg6VI4LxL5k6l+OXpq7MwGRBmACsT4w3UDquTxn+B/6lRNuG7imz94UuTGuiKAZs7vv3KrA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jkY9N/OJLiCnfETbHwecTAEO0ZdnPXTupz1ueKgRScBPrL/XM1MctzrlLuHsY3aNb9aRLctd+Kg7l4l4FfyFVUcC8Z/Z/8wI3hXUQk5PcVTQ8Wdxu+r4hyDLViwinTraA7vePRpvpbUa+8dDCyyupzaeAcJOzrflYLWRa71S/7x4j4A71Q/k2yfKgF5neJq41dIHAc55vE3h+3IYlyamfAbhK6sxc2EedvvYi7oWwBTzwFT/yzbKph0oH1mYh8IV9yLF99Bvn65YfGph5tLy3z/0oQ3O63Rsd/YLqFLqH3OMl3JqwLwHgvQvvXTS9kSA5tlr749mUV50eNYD8DDZxQ==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Mon, 17 Oct 2022 15:54:29 +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: AQHY4fyZYp3iu3IBsEeHODWajPdDU64SurkAgAABF9A=
- Thread-topic: [PATCH v3] xen/arm: p2m: Populate pages for GICv2 mapping in arch_domain_create()
Hi Julien,
> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Subject: Re: [PATCH v3] xen/arm: p2m: Populate pages for GICv2 mapping in
> arch_domain_create()
>
> Hi Henry,
>
> On 17/10/2022 08:46, Henry Wang wrote:
> > if ( p2m->root )
> > @@ -1762,6 +1778,20 @@ int p2m_init(struct domain *d)
> > INIT_PAGE_LIST_HEAD(&p2m->pages);
> > INIT_PAGE_LIST_HEAD(&d->arch.paging.p2m_freelist);
> >
> > + /*
> > + * Hardware using GICv2 needs to create a P2M mapping of 8KB GICv2
> area
> > + * when the domain is created. Considering the worst case for page
> > + * tables and keep a buffer, populate 16 pages to the P2M pages pool
> here.
> > + * For GICv3, the above-mentioned P2M mapping is not necessary, but
> since
> > + * the allocated 16 pages here would not be lost, hence populate these
> > + * pages unconditionally.
> > + */
> > + spin_lock(&d->arch.paging.lock);
> > + rc = p2m_set_allocation(d, 16, NULL);
> > + spin_unlock(&d->arch.paging.lock);
> > + if ( rc != 0 )
> > + return rc;
>
>
> p2m_set_allocation() wants to be called after 'p->domain' is set. So
> p2m_teardown_final() will not return early and leak memory (as Andrew
> pointed out).
Yes this is a really silly mistake that I made, and I am really sorry for that.
>
> For simplicity I would move the code right at the end of the function.
Definitely.
> But if you want to keep it here then...
>
> > +
> > p2m->vmid = INVALID_VMID;
>
> ... this needs to be done first as well.
I agree moving that part to the end would be a better solution.
>
> >
> > rc = p2m_alloc_vmid(d);
>
> Note that if you move the code at the end. Then you will need to add:
>
> if ( rc )
> return rc;
>
> after the call to p2m_alloc_table();
Yes, thanks very much for the reminder.
>
> Other than that the code looks good to me.
As Andrew stated in his email that he will draft a patch, TBH I am not
sure if my patch would be superseded by his, but I will try to see if it
is possible for me to send a v4 today.
Kind regards,
Henry
>
> Cheers,
>
> --
> Julien Grall
|