Hello Sergej, On 16/08/16 23:16, Sergej Proskurin wrote:
+static int altp2m_init_helper(struct domain *d, unsigned int idx) +{ + int rc; + struct p2m_domain *p2m = d->arch.altp2m_p2m[idx]; + + ASSERT(p2m == NULL); + + /* Allocate a new, zeroed altp2m view. */ + p2m = xzalloc(struct p2m_domain); + if ( p2m == NULL) + { + rc = -ENOMEM; + goto err; + }
This could be simplified with just return -ENOMEM.
+ + p2m->p2m_class = p2m_alternate; + + /* Initialize the new altp2m view. */ + rc = p2m_init_one(d, p2m); + if ( rc ) + goto err; + + p2m->access_required = false; + _atomic_set(&p2m->active_vcpus, 0);
the p2m is initialized to 0, so both access_required and active_vcpus initialization is not necessary.
+ + d->arch.altp2m_p2m[idx] = p2m; + + return rc; + +err: + if ( p2m ) + xfree(p2m);
xfree is able to handle NULL pointer.
+ + d->arch.altp2m_p2m[idx] = NULL; + + return rc; +} + +int altp2m_init_by_id(struct domain *d, unsigned int idx) +{ + int rc = -EINVAL; + + if ( idx >= MAX_ALTP2M ) + return rc; + + altp2m_lock(d); + + if ( d->arch.altp2m_p2m[idx] == NULL ) + rc = altp2m_init_helper(d, idx); + + altp2m_unlock(d); + + return rc; +} +
Regards, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel