All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Yang Zhang <yang.z.zhang@intel.com>
Cc: xen-devel@lists.xensource.com, keir.xen@gmail.com, JBeulich@suse.com
Subject: Re: [PATCH 6/7] Nested VMX: Update APIC-v(RVI/SVI) when vmexit to L1
Date: Fri, 9 Aug 2013 11:49:53 +0100	[thread overview]
Message-ID: <5204C951.2040906@citrix.com> (raw)
In-Reply-To: <1376038175-18571-7-git-send-email-yang.z.zhang@intel.com>

On 09/08/13 09:49, Yang Zhang wrote:
> From: Yang Zhang <yang.z.zhang@Intel.com>
>
> If enabling APIC-v, all interrupts to L1 is delivered through APIC-v.
> But when L2 is running, external interrupt will casue L1 vmexit with
> reason external interrupt. Then L1 will pick up the interrupt through
> vmcs. So we need to update APIC-v related structure accordingly;
>
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> ---
>  xen/arch/x86/hvm/vmx/vvmx.c |   37 +++++++++++++++++++++++++++++++++++++
>  1 files changed, 37 insertions(+), 0 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
> index 5dfbc54..9ba169d 100644
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -1283,6 +1283,41 @@ static void sync_exception_state(struct vcpu *v)
>      }
>  }
>  
> +static void nvmx_update_apicv(struct vcpu *v)
> +{
> +    struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
> +    struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
> +    unsigned long reason = __get_vvmcs(nvcpu->nv_vvmcx, VM_EXIT_REASON);
> +    uint32_t intr_info = __get_vvmcs(nvcpu->nv_vvmcx, VM_EXIT_INTR_INFO);
> +
> +    if ( !cpu_has_vmx_virtual_intr_delivery )
> +        return;

Is it worth hoisting this check outside of the function, to avoid
needless __get_vvmcs() calls on some hardware?

> +
> +    if ( reason == EXIT_REASON_EXTERNAL_INTERRUPT &&
> +            nvmx->intr.source == hvm_intsrc_lapic &&
> +            (intr_info & INTR_INFO_VALID_MASK) )
> +    {
> +        unsigned long status;
> +        uint32_t rvi, ppr;
> +        uint32_t vector = intr_info & 0xff;
> +        struct vlapic *vlapic = vcpu_vlapic(v);
> +
> +        WARN_ON(vector <= 0);
> +
> +        vlapic_ack_pending_irq(v, vector, 1);
> +
> +        ppr = vlapic_set_ppr(vlapic);
> +        BUG_ON( (ppr & 0xf0) != (vector & 0xf0) );
> +
> +        status = (vector << 8) & 0xff00;

Given "vector = intr_info & 0xff;" above, this "& 0xff00" looks useless.

~Andrew

> +        rvi = vlapic_has_pending_irq(v);
> +        if ( rvi != -1 )
> +            status |= rvi & 0xff;
> +
> +        __vmwrite(GUEST_INTR_STATUS, status);
> +    }
> +}
> +
>  static void virtual_vmexit(struct cpu_user_regs *regs)
>  {
>      struct vcpu *v = current;
> @@ -1328,6 +1363,8 @@ static void virtual_vmexit(struct cpu_user_regs *regs)
>      /* updating host cr0 to sync TS bit */
>      __vmwrite(HOST_CR0, v->arch.hvm_vmx.host_cr0);
>  
> +    nvmx_update_apicv(v);
> +
>      vmreturn(regs, VMSUCCEED);
>  }
>  

  reply	other threads:[~2013-08-09 10:49 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09  8:49 [PATCH 0/7] Nested VMX: APIC-v related bug fixing Yang Zhang
2013-08-09  8:49 ` [PATCH 1/7] Nested VMX: Introduce interrupt source supporting Yang Zhang
2013-08-09 10:14   ` Andrew Cooper
2013-08-09 12:03   ` Jan Beulich
2013-08-11  2:30     ` Zhang, Yang Z
2013-08-09  8:49 ` [PATCH 2/7] Nested VMX: Allow to ack irq even virtual intr delivery is enabled Yang Zhang
2013-08-09 10:28   ` Andrew Cooper
2013-08-09 10:32     ` Zhang, Yang Z
2013-08-09 12:04       ` Jan Beulich
2013-08-11  2:30         ` Zhang, Yang Z
2013-08-09 12:06   ` Jan Beulich
2013-08-11  2:43     ` Zhang, Yang Z
2013-08-12  6:47       ` Jan Beulich
2013-08-13  1:10         ` Zhang, Yang Z
2013-08-13 10:30           ` Jan Beulich
2013-08-09  8:49 ` [PATCH 3/7] Nested VMX: Force check ISR when L2 is running Yang Zhang
2013-08-09 10:38   ` Andrew Cooper
2013-08-09 12:12   ` Jan Beulich
2013-08-11  2:49     ` Zhang, Yang Z
2013-08-12  6:47       ` Jan Beulich
2013-08-09  8:49 ` [PATCH 4/7] Nested VMX: Add interface to update vPPR Yang Zhang
2013-08-09 10:42   ` Andrew Cooper
2013-08-09 12:14   ` Jan Beulich
2013-08-11  2:50     ` Zhang, Yang Z
2013-08-09  8:49 ` [PATCH 5/7] Nested VMX: Check whether interrupt is blocked by TPR Yang Zhang
2013-08-09 10:43   ` Andrew Cooper
2013-08-09 12:16     ` Jan Beulich
2013-08-11  2:51       ` Zhang, Yang Z
2013-08-09  8:49 ` [PATCH 6/7] Nested VMX: Update APIC-v(RVI/SVI) when vmexit to L1 Yang Zhang
2013-08-09 10:49   ` Andrew Cooper [this message]
2013-08-09 12:31   ` Jan Beulich
2013-08-11  2:59     ` Zhang, Yang Z
2013-08-12  6:53       ` Jan Beulich
2013-08-13  1:08         ` Zhang, Yang Z
2013-08-15  1:41         ` Zhang, Yang Z
2013-08-15  6:26           ` Jan Beulich
2013-08-09  8:49 ` [PATCH 7/7] Nested VMX: Clear APIC-v control bit in vmcs02 Yang Zhang
2013-08-09 10:50   ` Andrew Cooper
2013-08-09 12:37   ` Jan Beulich
2013-08-11  3:04     ` Zhang, Yang Z
2013-08-09 12:00 ` [PATCH 0/7] Nested VMX: APIC-v related bug fixing Jan Beulich

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=5204C951.2040906@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir.xen@gmail.com \
    --cc=xen-devel@lists.xensource.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.