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

Re: [PATCH 10/22] x86/mapcache: initialise the mapcache for the idle domain


  • To: Julien Grall <julien@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 22 Dec 2022 14:06:34 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=TDw3BjNQpD9JfYqN5BmhFNoyfMRTSqoCJgSTmCM6ATM=; b=drGVR2BQWGDUPiVzFjNe4Hk01OF62pZH0ASDSDoHGVAC78p1O1ethLQvpu9DehjkKkiJDNhxnP344SmTTdPIHWxcXSXWQbZckOpA76yRiOPPweLGkae/fAvAfTm2YiieWmXUhl9+QMGHgcI23vOEZTxNHwbNl/s0G40qYTNeplpA8HKlQV4Se7ZsMPDMIjOPfwI0kw1f6Hi2Rov5uAX9MswA+kSlAcIaM4N0TR0my4bSRWVIWkwWOPIkTN4oDz8Xa7MFiUIKiSFtLFaqmvyJEHJTbYElF52jKcWsxrcXUE8BF+Ubr/t8P8AGGCDKILybbHfUIgme5sNkCKkl2/yOwA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oYwzX+LcrF67ycYCwuuCTpTkEkzG+eehjG1FSn2n0U2OfGf5ECWGo1jF1mEEcdwQV+/u2uAm25pouGjAnHfUMQIjBzX6iTGxSnd8mnk21FCmSg1IRGa4+JQDMxlqN5aBgiiLqmsKDEI6UM9oPa92Iu3O8Pw4mBF4x+DYglOQcQjquoNmTqUO9A0sBimA2fppQsqKtbqCMJbY6WmOgSbhCkmful90AEWHEjWSFt+mvAoRJ9UDLuykd6dsONTMK25jw4MwSVZ9pickylgt6UYr0McYS6FVSjJf4FwEs8Ti82m+a1ncsGyzMj8eVVkG5vVXvsznWLpHXREE9iH33p3X7Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Hongyan Xia <hongyxia@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Wei Wang <wawei@xxxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 22 Dec 2022 13:06:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.12.2022 12:48, Julien Grall wrote:
> From: Hongyan Xia <hongyxia@xxxxxxxxxx>
> 
> In order to use the mapcache in the idle domain, we also have to
> populate its page tables in the PERDOMAIN region, and we need to move
> mapcache_domain_init() earlier in arch_domain_create().
> 
> Note, commit 'x86: lift mapcache variable to the arch level' has
> initialised the mapcache for HVM domains. With this patch, PV, HVM,
> idle domains now all initialise the mapcache.

But they can't use it yet, can they? This needs saying explicitly, or
else one is going to make wrong implications.

> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -732,6 +732,8 @@ int arch_domain_create(struct domain *d,
>  
>      spin_lock_init(&d->arch.e820_lock);
>  
> +    mapcache_domain_init(d);
> +
>      /* Minimal initialisation for the idle domain. */
>      if ( unlikely(is_idle_domain(d)) )
>      {
> @@ -829,8 +831,6 @@ int arch_domain_create(struct domain *d,
>  
>      psr_domain_init(d);
>  
> -    mapcache_domain_init(d);

You move this ahead of error paths taking the "goto out" route, so
adjustments to affected error paths are going to be needed to avoid
memory leaks.

> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -5963,6 +5963,9 @@ int create_perdomain_mapping(struct domain *d, unsigned 
> long va,
>          l3tab = __map_domain_page(pg);
>          clear_page(l3tab);
>          d->arch.perdomain_l3_pg = pg;
> +        if ( is_idle_domain(d) )
> +            idle_pg_table[l4_table_offset(PERDOMAIN_VIRT_START)] =
> +                l4e_from_page(pg, __PAGE_HYPERVISOR_RW);

Hmm, having an idle domain check here isn't very nice. I agree putting
it in arch_domain_create()'s respective conditional isn't very neat
either, but personally I'd consider this at least a little less bad.
And the layering violation aspect isn't much worse than that of setting
d->arch.ctxt_switch there as well.

Jan



 


Rackspace

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