All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keir Fraser <keir.xen@gmail.com>
To: Yang Zhang <yang.z.zhang@intel.com>, xen-devel@lists.xen.org
Cc: xiantao.zhang@intel.com, JBeulich@suse.com
Subject: Re: [PATCH 4/4] VMX: Use posted interrupt to deliver virutal interrupt
Date: Tue, 09 Apr 2013 08:40:46 +0100	[thread overview]
Message-ID: <CD89848E.4F1B7%keir.xen@gmail.com> (raw)
In-Reply-To: <1365487291-2283-5-git-send-email-yang.z.zhang@intel.com>

On 09/04/2013 07:01, "Yang Zhang" <yang.z.zhang@intel.com> wrote:

> From: Yang Zhang <yang.z.zhang@Intel.com>
> 
> Deliver virtual interrupt through posted way if posted interrupt
> is enabled.
> 
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> Reviewed-by: Jun Nakajima <jun.nakajima@intel.com>

You modify many but not all callers of vlapic_set_irq() -- is that
intentional? Would it be better to modify vlapic_set_irq(), or add a new
wrapper function for most/all current callers of vlapic_set_irq()?

Just seems that the method presented here is a bit uglier and more fragile
than perhaps it needs to be.

 -- Keir

> ---
>  xen/arch/x86/hvm/vioapic.c        |    4 +++-
>  xen/arch/x86/hvm/vlapic.c         |   13 ++++++++++---
>  xen/arch/x86/hvm/vmsi.c           |    5 ++++-
>  xen/arch/x86/hvm/vmx/vpmu_core2.c |    5 ++++-
>  xen/arch/x86/hvm/vpt.c            |   10 +++++++---
>  5 files changed, 28 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
> index d3de695..b543e55 100644
> --- a/xen/arch/x86/hvm/vioapic.c
> +++ b/xen/arch/x86/hvm/vioapic.c
> @@ -263,7 +263,9 @@ static void ioapic_inj_irq(
>      ASSERT((delivery_mode == dest_Fixed) ||
>             (delivery_mode == dest_LowestPrio));
>  
> -    if ( vlapic_set_irq(target, vector, trig_mode) )
> +    if ( hvm_funcs.deliver_posted_intr )
> +        hvm_funcs.deliver_posted_intr(vlapic_vcpu(target), vector,
> trig_mode);
> +    else if ( vlapic_set_irq(target, vector, trig_mode) )
>          vcpu_kick(vlapic_vcpu(target));
>  }
>  
> diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
> index 128745c..a8af47a 100644
> --- a/xen/arch/x86/hvm/vlapic.c
> +++ b/xen/arch/x86/hvm/vlapic.c
> @@ -137,6 +137,9 @@ static void vlapic_clear_irr(int vector, struct vlapic
> *vlapic)
>  
>  static int vlapic_find_highest_irr(struct vlapic *vlapic)
>  {
> +    if ( hvm_funcs.sync_pir_to_irr )
> +        hvm_funcs.sync_pir_to_irr(vlapic_vcpu(vlapic));
> +
>      return vlapic_find_highest_vector(&vlapic->regs->data[APIC_IRR]);
>  }
>  
> @@ -315,9 +318,13 @@ static void vlapic_accept_irq(struct vcpu *v, uint32_t
> icr_low)
>      {
>      case APIC_DM_FIXED:
>      case APIC_DM_LOWEST:
> -        if ( vlapic_enabled(vlapic) &&
> -             !vlapic_test_and_set_irr(vector, vlapic) )
> -            vcpu_kick(v);
> +        if ( vlapic_enabled(vlapic) )
> +        {
> +            if ( hvm_funcs.deliver_posted_intr )
> +                hvm_funcs.deliver_posted_intr(v, vector, 0);
> +            else if ( !vlapic_test_and_set_irr(vector, vlapic) )
> +                vcpu_kick(v);
> +        }
>          break;
>  
>      case APIC_DM_REMRD:
> diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
> index cfc7c80..0ac14d1 100644
> --- a/xen/arch/x86/hvm/vmsi.c
> +++ b/xen/arch/x86/hvm/vmsi.c
> @@ -57,7 +57,10 @@ static void vmsi_inj_irq(
>      {
>      case dest_Fixed:
>      case dest_LowestPrio:
> -        if ( vlapic_set_irq(target, vector, trig_mode) )
> +        if ( hvm_funcs.deliver_posted_intr )
> +            hvm_funcs.deliver_posted_intr(vlapic_vcpu(target), vector,
> +                                        trig_mode);
> +        else if ( vlapic_set_irq(target, vector, trig_mode) )
>              vcpu_kick(vlapic_vcpu(target));
>          break;
>      default:
> diff --git a/xen/arch/x86/hvm/vmx/vpmu_core2.c
> b/xen/arch/x86/hvm/vmx/vpmu_core2.c
> index 2313e39..dc152f7 100644
> --- a/xen/arch/x86/hvm/vmx/vpmu_core2.c
> +++ b/xen/arch/x86/hvm/vmx/vpmu_core2.c
> @@ -737,7 +737,10 @@ static int core2_vpmu_do_interrupt(struct cpu_user_regs
> *regs)
>      int_vec = vlapic_lvtpc & APIC_VECTOR_MASK;
>      vlapic_set_reg(vlapic, APIC_LVTPC, vlapic_lvtpc | APIC_LVT_MASKED);
>      if ( GET_APIC_DELIVERY_MODE(vlapic_lvtpc) == APIC_MODE_FIXED )
> -        vlapic_set_irq(vcpu_vlapic(v), int_vec, 0);
> +        if ( hvm_funcs.deliver_posted_intr )
> +            hvm_funcs.deliver_posted_intr(v, int_vec, 0);
> +        else 
> +            vlapic_set_irq(vcpu_vlapic(v), int_vec, 0);
>      else
>          v->nmi_pending = 1;
>      return 1;
> diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c
> index 46d3ec6..7c3f2ba 100644
> --- a/xen/arch/x86/hvm/vpt.c
> +++ b/xen/arch/x86/hvm/vpt.c
> @@ -257,9 +257,13 @@ int pt_update_irq(struct vcpu *v)
>  
>      spin_unlock(&v->arch.hvm_vcpu.tm_lock);
>  
> -    if ( is_lapic )
> -        vlapic_set_irq(vcpu_vlapic(v), irq, 0);
> -    else if ( irq == RTC_IRQ && pt_priv )
> +    if ( is_lapic )
> +    {
> +        if ( hvm_funcs.deliver_posted_intr )
> +            hvm_funcs.deliver_posted_intr(v, irq, 0);
> +        else
> +            vlapic_set_irq(vcpu_vlapic(v), irq, 0);
> +    } else if ( irq == RTC_IRQ && pt_priv )
>          rtc_periodic_interrupt(pt_priv);
>      else
>      {

  reply	other threads:[~2013-04-09  7:40 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09  6:01 [PATCH 0/4] Add posted interrupt supporting Yang Zhang
2013-04-09  6:01 ` [PATCH 1/4] VMX: Detect posted interrupt capability Yang Zhang
2013-04-09  6:01 ` [PATCH 2/4] VMX: Turn on posted interrupt bit in vmcs Yang Zhang
2013-04-09  8:04   ` Jan Beulich
2013-04-09  8:30     ` Zhang, Yang Z
2013-04-09  8:55       ` Jan Beulich
2013-04-09  9:53         ` Zhang, Yang Z
2013-04-09  8:23   ` Jan Beulich
2013-04-09  8:38     ` Keir Fraser
2013-04-09  8:48       ` Zhang, Yang Z
2013-04-09  6:01 ` [PATCH 3/4] VMX: Add posted interrupt supporting Yang Zhang
2013-04-09  7:39   ` Keir Fraser
2013-04-09  7:58     ` Zhang, Yang Z
2013-04-09  8:14       ` Keir Fraser
2013-04-09  8:23         ` Zhang, Yang Z
2013-04-09  8:40           ` Keir Fraser
2013-04-09  8:17   ` Jan Beulich
2013-04-09  8:40     ` Zhang, Yang Z
2013-04-09  8:59       ` Keir Fraser
2013-04-09  8:53     ` Zhang, Yang Z
2013-04-09  9:00       ` Jan Beulich
2013-04-09  9:18         ` Keir Fraser
2013-04-09  6:01 ` [PATCH 4/4] VMX: Use posted interrupt to deliver virutal interrupt Yang Zhang
2013-04-09  7:40   ` Keir Fraser [this message]
2013-04-09  8:25     ` Zhang, Yang Z
2013-04-09 20:26 ` [PATCH 0/4] Add posted interrupt supporting Konrad Rzeszutek Wilk
2013-04-10  2:51   ` Zhang, Yang Z
2013-04-10 13:22     ` Konrad Rzeszutek Wilk
2013-04-10 13:32       ` Zhang, Yang Z
2013-04-10 13:42         ` Konrad Rzeszutek Wilk
2013-04-19 11:49           ` Stefano Stabellini
2013-04-19 13:10             ` Jan Beulich
2013-04-19 14:16               ` Stefano Stabellini
2013-04-19 14:23                 ` Jan Beulich
2013-04-20  7:26               ` Zhang, Yang Z
2013-04-20 13:33                 ` Stefano Stabellini
2013-04-10 13:58 ` Zhang, Yang Z
2013-04-10 14:34   ` Jan Beulich
2013-04-10 16:18     ` Keir Fraser
2013-04-11  1:04       ` Zhang, Yang Z

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=CD89848E.4F1B7%keir.xen@gmail.com \
    --to=keir.xen@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xiantao.zhang@intel.com \
    --cc=yang.z.zhang@intel.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.