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

Re: [Xen-devel] [PATCH 5/7] x86/domain: Optimise the order of actions in arch_domain_create()



>>> On 15.03.18 at 21:15, <andrew.cooper3@xxxxxxxxxx> wrote:
> On 09/03/18 16:54, Jan Beulich wrote:
>>>>> On 09.03.18 at 14:18, <andrew.cooper3@xxxxxxxxxx> wrote:
>>> --- a/xen/arch/x86/domain.c
>>> +++ b/xen/arch/x86/domain.c
>>> @@ -430,20 +430,37 @@ int arch_domain_create(struct domain *d, unsigned int 
>>> domcr_flags,
>>>                         struct xen_arch_domainconfig *config)
>>>  {
>>>      bool paging_initialised = false;
>>> +    uint32_t emflags;
>>>      int rc;
>>>  
>>> -    if ( config == NULL && !is_idle_domain(d) )
>>> -        return -EINVAL;
>>> -
>>> -    d->arch.s3_integrity = domcr_flags & XEN_DOMCTL_CDF_s3_integrity;
>>> -
>>>      INIT_LIST_HEAD(&d->arch.pdev_list);
>>>  
>>>      d->arch.relmem = RELMEM_not_started;
>>>      INIT_PAGE_LIST_HEAD(&d->arch.relmem_list);
>>>  
>>> -    if ( d->domain_id && !is_idle_domain(d) &&
>>> -         cpu_has_amd_erratum(&boot_cpu_data, AMD_ERRATUM_121) )
>>> +    spin_lock_init(&d->arch.e820_lock);
>>> +    spin_lock_init(&d->arch.vtsc_lock);
>>> +
>>> +    /* Minimal initialisation for the idle domain. */
>>> +    if ( unlikely(is_idle_domain(d)) )
>>> +    {
>>> +        static const struct arch_csw idle_csw = {
>>> +            .from = paravirt_ctxt_switch_from,
>>> +            .to   = paravirt_ctxt_switch_to,
>>> +            .tail = continue_idle_domain,
>>> +        };
>>> +
>>> +        d->arch.ctxt_switch = &idle_csw;
>>> +
>>> +        d->arch.cpuid = ZERO_BLOCK_PTR; /* Catch stray misuses. */
>>> +        d->arch.msr = ZERO_BLOCK_PTR;
>>> +
>>> +        return 0;
>>> +    }
>>> +    else if ( !config )
>> May I suggest to avoid the "else" here?
> 
> I've gone with
> 
> ...
>         return 0;
>     }
> 
>     if ( !config )
>     {
>         /* Only IDLE is allowed with no config. */
>         ASSERT_UNREACHABLE();
>         return -EINVAL;
>     }
> ...
> 
> For runtime safety and debug sanity.

Ah, yes, that's even better.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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