xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Paul Durrant <paul.durrant@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>, KeirFraser <keir@xen.org>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v5 2/2] x86/hvm/viridian: Enable APIC assist enlightenment
Date: Thu, 17 Mar 2016 10:43:08 -0600	[thread overview]
Message-ID: <56EAECAC02000078000DDFD5@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1458216832-18378-3-git-send-email-paul.durrant@citrix.com>

>>> On 17.03.16 at 13:13, <paul.durrant@citrix.com> 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@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-03-17 16:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 12:13 [PATCH v4 0/2] x86/hvm/viridian: APIC assist Paul Durrant
2016-03-17 12:13 ` [PATCH v5 1/2] x86/hvm/viridian: keep APIC assist page mapped Paul Durrant
2016-03-17 12:13 ` [PATCH v5 2/2] x86/hvm/viridian: Enable APIC assist enlightenment Paul Durrant
2016-03-17 16:43   ` Jan Beulich [this message]
2016-03-18 10:06     ` Paul Durrant
2016-03-18 10:24       ` Jan Beulich
2016-03-18 10:30         ` Paul Durrant
2016-03-18 10:58           ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56EAECAC02000078000DDFD5@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=keir@xen.org \
    --cc=paul.durrant@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    --subject='Re: [PATCH v5 2/2] x86/hvm/viridian: Enable APIC assist enlightenment' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).