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

Re: [Xen-devel] [PATCH v5 2/2] x86/hvm/viridian: Enable APIC assist enlightenment



>>> On 17.03.16 at 13:13, <paul.durrant@xxxxxxxxxx> wrote:
> @@ -262,6 +258,59 @@ static void initialize_apic_assist(struct vcpu *v)
>               page ? page_to_mfn(page) : INVALID_MFN);
>  }
>  
> +static uint32_t *get_apic_assist_word(struct vcpu *v)
> +{
> +    if ( !(viridian_feature_mask(v->domain) & HVMPV_apic_assist) )
> +        return NULL;
> +
> +    return v->arch.hvm_vcpu.viridian.apic_assist.va;

Does this need to be conditional, i.e. isn't the field NULL anyway
when the flag is not set?

> +void viridian_start_apic_assist(struct vcpu *v, int vector)
> +{
> +    uint32_t *va = get_apic_assist_word(v);
> +
> +    if ( !va )
> +        return;
> +
> +    /*
> +     * If there is already an assist pending then something has gone
> +     * wrong and the VM will most likely hang so force a crash now
> +     * to make the problem clear.
> +     */
> +    if ( v->arch.hvm_vcpu.viridian.apic_assist.vector >= 0 )
> +        domain_crash(v->domain);
> +
> +    v->arch.hvm_vcpu.viridian.apic_assist.vector = vector;
> +    *va |= 1u;

Are the u suffixes here really good for anything?

> +bool_t viridian_complete_apic_assist(struct vcpu *v, int *vector)
> +{
> +    uint32_t *va = get_apic_assist_word(v);
> +
> +    if ( !va )
> +        return 0;
> +
> +    if ( *va & 1u )
> +        return 0; /* Interrupt not yet processed by the guest */

Missing full stop.

> @@ -1170,10 +1183,27 @@ int vlapic_has_pending_irq(struct vcpu *v)
>           !nestedhvm_vcpu_in_guestmode(v) )
>          return irr;
>  
> +    /*
> +     * If APIC assist was used then there may have been no EOI so
> +     * we need to clear the requisite bit from the ISR here, before
> +     * comparing with the IRR.
> +     */
> +    if ( viridian_complete_apic_assist(v, &vector) &&
> +         vector != -1 )

Afaict "vector" is uninitialized here when initialize_apic_assist()
didn't run for that vCPU yet (which includes the case where no
Viridian emulation is active at all).

> @@ -1181,13 +1211,29 @@ int vlapic_has_pending_irq(struct vcpu *v)
>  int vlapic_ack_pending_irq(struct vcpu *v, int vector, bool_t force_ack)
>  {
>      struct vlapic *vlapic = vcpu_vlapic(v);
> +    int isr;
>  
> -    if ( force_ack || !vlapic_virtual_intr_delivery_enabled() )
> -    {
> -        vlapic_set_vector(vector, &vlapic->regs->data[APIC_ISR]);
> -        vlapic_clear_irr(vector, vlapic);
> -    }
> +    if ( !force_ack &&
> +         vlapic_virtual_intr_delivery_enabled() )
> +        return 1;
> +
> +    if ( vlapic_test_vector(vector, &vlapic->regs->data[APIC_TMR]) )
> +        goto done;
> +
> +    isr = vlapic_find_lowest_vector(&vlapic->regs->data[APIC_ISR]);
> +    if ( isr >= 0 && isr < vector )
> +        goto done;

These two new extra operations aren't exactly expensive, but
they also aren't for free. Would it make sense to at least avoid
the second one if the respective Viridian feature bit is clear?

> +    /*
> +     * This vector is edge triggered and there are no lower priority
> +     * vectors pending, so we can use APIC assist to avoid exiting
> +     * for EOI.
> +     */
> +    viridian_start_apic_assist(v, vector);
>  
> +done:

Labels indented by at least one space please.

> +    vlapic_set_vector(vector, &vlapic->regs->data[APIC_ISR]);
> +    vlapic_clear_irr(vector, vlapic);
>      return 1;
>  }




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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