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

RE: [PATCH v2] xen/arm: p2m: Populate pages for GICv2 mapping in arch_domain_create()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Fri, 14 Oct 2022 09:28:29 +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=LBWfPjwQmtuWDY3ksijI4H40WjzGzbvm6P9YpHb9phQ=; b=BJ5/g2Lgyj3u7byRDJ2jrCy2rgEYm2hwk7Fr2ngw9slDasXvwq5DS6VgieRWqxL2aRD9xaHaTnPLze06BNCLDISotRofSt8zOllB4mPg8Wz13yBBFihjAKeuG4inWo6zpoUQbjAWQ9eKerCuBe5pkWIG2O5eeQCs0EfSAFSUdWUwN8WEIG4S67uR1g+pzK9lsLN2xCMbcRJ2hLP1yoKO74RclrtiKIkNx8bEVrxW3iYlAlIux3s6RbgCOnAMBYIcaa21vKthyV/ix5KL/uL9wNZO118EzWasyQ7YzjuZ5fUOSawl6bWTOt71Tq2T1tCJ+8A/y5NI1Fzyeb/7vI9SxA==
  • 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=LBWfPjwQmtuWDY3ksijI4H40WjzGzbvm6P9YpHb9phQ=; b=b2ZGkGlvdvfqgs3W79KheFgPfio/JOc5u71Xyg2EDGs+mJGmaa9S2gJI/DDFPZlV3X03UMsceyDV5WtwAA2QeDmaOTxlb9u5vC6fIT1jgU6qvW/gRVIFMKVF8qYf5aPHj+Q9oEOWxAlDQCOiOavAKkUOfwWo6T2WgwCxZYEC/nsHdVYDkFzkDqEj41h8dibS940GQnnpm8/HlKHlINf0SxIHacGOgYCxrEsd9MODW11ix9rSc2XIF8JqfIGpk7qUug/aFilskNW3piHJ7zmMNUU+wpJdPhdatmHiwHwhgFf3TnEcFAXCA0c27zMGOsUKYCrdyePZpE+CWjc3bHi+1g==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=G12+kTDfzZpJ2BH9SWvJqwcVTgGfUtUGqHCZRRzwtwE51N0GvSmSkPDO3NFpCwn+0xZmSm6s2NJSewppUVb89mxDrwsbwwSaRfyIqIQNH6MyW1kyV58VYbxT2e+pahDNB7aIuIy0ELB0hq5c6O+OPtfuz7+B6J/KucNU2Wu/0G21E5RDBgUk1nTWcO6bBm13IQ9g52p1DhvqCa88SHiOjcyggn3aSHWTC4pfFLAEnDyY3sMiL7Gil9kzx8PGhCgi3UmRx6O3bdAZ1O9OnNJXSip6/LLQMd2GjT/zeZ14TVbWhEAQnc+EcvzE9A3nN8eRgMuYe0mujHkPtTdgNRo5xA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gURWTbtE4wQ4ZEeGzJfIkSwpIzoL56snikmSfl+vdHxRRhO8yzRi7WZydXPJ14ZhbxDqpzIUCDrNF0FakMdXd8E56MHDCzSB4g/QZyhTLOyxMUmrP7tR/EGg+7y6xU2wBBTdvUtyU5h1u4VKsUQTc3DYyMIrSNX+DluGgBzXtd/BeD4cQwrgp8kLxvTtz6xe0mj1fqG+E6g9U8/JDVOHREY98xwOmiUGxOkVbjnETSEb6aOqY7mUAk832z3ylZoHUG9sn09JIyVJ3Ht4Tw9hRp4mhTCwDWuQnyK+PSQU1cNRgb0fg1sVIrJPhC4g+AnZGqmh04kZQLN7MfSNaaguQg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 14 Oct 2022 09:28:56 +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: AQHY36RSrOIThkYtnEq9RrtWc+uYX64NnUwAgAAAd5A=
  • Thread-topic: [PATCH v2] xen/arm: p2m: Populate pages for GICv2 mapping in arch_domain_create()

Hi Jan,

Thanks for the review.

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Subject: Re: [PATCH v2] xen/arm: p2m: Populate pages for GICv2 mapping in
> arch_domain_create()
> 
> On 14.10.2022 10:09, Henry Wang wrote:
> > --- a/xen/arch/arm/domain.c
> > +++ b/xen/arch/arm/domain.c
> > @@ -740,6 +740,20 @@ int arch_domain_create(struct domain *d,
> >          BUG();
> >      }
> >
> > +    /*
> > +     * 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 )
> > +        goto fail;
> 
> Putting this level of knowledge here feels like a layering violation to
> me. My first suggestion would be to move this call somewhere under
> p2m_init().

That is definitely possible. If Julien or other Arm maintainers are not
against that I am happy to move this to p2m_init() in v3.

The reason why the above block is placed here is just I thought to use
d->arch.vgic.version to only populate the 16 pages for GICv2 in the
beginning, and d->arch.vgic.version is first assigned later after p2m_init(),
but later we decided to populated the pages unconditionally so actually
now we can move the part to p2m_init().

> If that's not possible for some reason, I'd like to suggest
> passing 1 here as the count and then adding a min-acceptable check to
> p2m_set_allocation() along the lines of x86'es shadow_set_allocation().
> That way you'd also guarantee the minimum number of pages in case a
> subsequent tiny allocation request came in via domctl.
> 
> > @@ -1736,6 +1736,17 @@ void p2m_final_teardown(struct domain *d)
> >      if ( !p2m->domain )
> >          return;
> >
> > +    if ( !page_list_empty(&p2m->pages) )
> > +        p2m_teardown(d, false);
> > +
> > +    if ( d->arch.paging.p2m_total_pages != 0 )
> > +    {
> > +        spin_lock(&d->arch.paging.lock);
> > +        p2m_set_allocation(d, 0, NULL);
> > +        spin_unlock(&d->arch.paging.lock);
> > +        ASSERT(d->arch.paging.p2m_total_pages == 0);
> > +    }
> 
> Is it intentional to largely open-code p2m_teardown_allocation() here?

Yes, AFAICT p2m_teardown_allocation() is preemptible and we don't want
any preemption here.

Kind regards,
Henry

> 
> Jan

 


Rackspace

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