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

Re: [PATCH 1/2] arm/p2m: Rework p2m_init()


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 18 Oct 2022 11:52:03 +0000
  • Accept-language: en-GB, 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=EsfXy0BKQDopchh9sqTepaGzECim6z7Urd9YPkG1nM4=; b=JBi6cjdMgYcbZ86pUQMhzwraU2TtO9aGzFDGBUqcjI/fbSB4JYbYe446SkCBimLLsJc0ungxW2OVQdcSXVwxwTT0/obwrlA8lC62dk2qWBvr84eGhQvnokccMyE0A+IvvW3QDuKU1w0jBQi+W/uoexZFjNIevCqC57xwSOfkt0V3EDfCtkx/aDtcqUvN4XSXzXyialxeEW02PmLNgbqqz+eWzMMwdWiKujEULw7r0h4S/y2LhZ81jmgU4gUBn+iqZW3xhEYA1c/nQrSC8lDHncUjOJpJAEM1qQTN5wi6GwffjsAH7CMiMVX6s4AsqwKCeA6b/NMqlgihj7qmxcNdyA==
  • 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=EsfXy0BKQDopchh9sqTepaGzECim6z7Urd9YPkG1nM4=; b=IXH3ZNkz3DUKnvMo7UGeB0I/3slMsBMWLplJh3w3H9Yy7qbx9SEqGcNtFmRTmLUtz4uJKZwVm2dyGZ90Xbhv/WDA3ktiXs1Vvt8kbGirZe5oRHZKFDvt7WIMnW1rM3oRJ9aN3sVIx8OfSYoF76DvgOVvQ6e2n1iDOXc880NmV/U2493PbO2RMAIdVH60OptW9hlZnulyIHsmWuEeZGOzwkeaOuNY97pOUXDhZv0t+uEU8xrFvOpIze5TtBJhxRM7ckrudWISoGYPDnhtxDy1oEUkxhX1IbMw/FK3twD0kzAYMd98VYXK88xh1eHvLWIQiD24wPdSYd2gW30Gcb9VNg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=LiiMFszQjL0A/X4bVjNLIZx2fPIpPjySLre0OIWsYFqcnoKl+zJdXT2cbPDGUQMR4pS+c3QPY7UOE2dZXoED798WyhYt6TFFVu7WQWkSxpAUCwQCpJ8/1OkSHstJXBBY8y/uR3PlgGprLMafqJgp+08EbN9FFYYIoI+Re7swxS/UNfgQpgzTRfuKAYQpj7FUXSk4Jg1iS41Ti3740DkiaGIx0D8uHjRidIiEwYf9ha0M7QuwdXGzCgzq38EmySSIkijHNjFqrjX/watOxupPioXYaJ7JYIQ5J70KSw2AIJWg6+bUaW/cM/v7GXb+0nKIILnR1obV+g7YO3YtBnhtMQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PDlJHqKcM1x0/RGowbmw/I3bKzQ4jBGpRGfFYxSEYrby1yYvPiMMOgcRWkFdCADtfEA8Mw0vPqfkw0uOn2RVGma3RLVBl/nuKFUfyuJnvmmCkRLcuWTWE2+WTxiwmDjkuuseqh/cSXYouguoSM5PrvTq6LZgTve1pY7plBgrDZCK1lEcyR3Nd2A8avUbU/4Hkun05YazOGHOQ8reWA/OFTVhQ4mtLyWL9WTrvjBQgANDOjWXEO4i7DdzB6AmmAHAy7GgOe0P2TPNWN5vp1BXA6hjKKaJul0JzVG9WKKqsBsDwpCo/HFSPADWQD34CF15yZDhhWrHux/Wj6sr3T363A==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Tue, 18 Oct 2022 11:52:19 +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: AQHY4lx8NcMOBRjDdEuRGdu/FdZOvq4UC1kA
  • Thread-topic: [PATCH 1/2] arm/p2m: Rework p2m_init()

Hi Andrew,

> On 17 Oct 2022, at 20:12, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx> wrote:
> 
> p2m_init() is mostly trivial initialisation, but has two failable operations

Maybe say “two operations that can fail” as the failable does seem fully right 
:-)
But I am not a native speaker so I will let that to you.

> which are on either side of the backpointer trigger for teardown to take
> actions.
> 
> p2m_free_vmid() is idempotent with a failed p2m_alloc_vmid(), so rearrange
> p2m_init() to perform all trivial setup, then set the backpointer, then
> perform all failable setup.
> 
> This will simplify a future bugfix which needs to add a third failabile
> operation.
> 
> No practical change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> CC: Julien Grall <julien@xxxxxxx>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
> CC: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> CC: Henry Wang <Henry.Wang@xxxxxxx>
> ---
> xen/arch/arm/p2m.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index f17500ddf3a3..6826f6315080 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -1754,7 +1754,7 @@ void p2m_final_teardown(struct domain *d)
> int p2m_init(struct domain *d)
> {
>     struct p2m_domain *p2m = p2m_get_hostp2m(d);
> -    int rc = 0;
> +    int rc;
>     unsigned int cpu;
> 
>     rwlock_init(&p2m->lock);
> @@ -1763,11 +1763,6 @@ int p2m_init(struct domain *d)
>     INIT_PAGE_LIST_HEAD(&d->arch.paging.p2m_freelist);
> 
>     p2m->vmid = INVALID_VMID;
> -
> -    rc = p2m_alloc_vmid(d);
> -    if ( rc != 0 )
> -        return rc;
> -
>     p2m->max_mapped_gfn = _gfn(0);
>     p2m->lowest_mapped_gfn = _gfn(ULONG_MAX);
> 
> @@ -1783,8 +1778,6 @@ int p2m_init(struct domain *d)
>     p2m->clean_pte = is_iommu_enabled(d) &&
>         !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK);
> 
> -    rc = p2m_alloc_table(d);
> -
>     /*
>      * Make sure that the type chosen to is able to store the an vCPU ID
>      * between 0 and the maximum of virtual CPUS supported as long as
> @@ -1797,13 +1790,20 @@ int p2m_init(struct domain *d)
>        p2m->last_vcpu_ran[cpu] = INVALID_VCPU_ID;
> 
>     /*
> -     * Besides getting a domain when we only have the p2m in hand,
> -     * the back pointer to domain is also used in p2m_teardown()
> -     * as an end-of-initialization indicator.
> +     * "Trivial" initialisation is now complete.  Set the backpointer so
> +     * p2m_teardown() and friends know to do something.
>      */
>     p2m->domain = d;
> 
> -    return rc;
> +    rc = p2m_alloc_vmid(d);
> +    if ( rc )
> +        return rc;
> +
> +    rc = p2m_alloc_table(d);
> +    if ( rc )
> +        return rc;
> +
> +    return 0;
> }
> 
> /*
> -- 
> 2.11.0
> 


 


Rackspace

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