public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Yang Zhang <yang.z.zhang@intel.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com
Subject: Re: [PATCH] KVM: x86: check ISR and TMR to construct eoi exit bitmap
Date: Fri, 08 Aug 2014 13:16:23 -0600	[thread overview]
Message-ID: <1407525383.26210.19.camel@ul30vt.home> (raw)
In-Reply-To: <1407477745-15743-1-git-send-email-yang.z.zhang@intel.com>

On Fri, 2014-08-08 at 14:02 +0800, Yang Zhang wrote:
> From: Yang Zhang <yang.z.zhang@Intel.com>
> 
> Guest may mask the IOAPIC entry before issue EOI. In such case,
> EOI will not be intercepted by hypervisor due to the corrensponding
> bit in eoi exit bitmap is not setting.
> 
> The solution is to check ISR + TMR to construct the EOI exit bitmap.
> 
> This patch is a better fixing for the issue that commit "0f6c0a740b"
> tries to solve.
> 
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> ---
>  arch/x86/kvm/lapic.c |   22 ++++++++++++++++++++++
>  arch/x86/kvm/lapic.h |    2 ++
>  arch/x86/kvm/x86.c   |    9 +++++++++
>  virt/kvm/ioapic.c    |    7 ++++---
>  4 files changed, 37 insertions(+), 3 deletions(-)
> 
> hi, alex
> 
> This patch is not tested since i don't have the environment to do it. Can you
> help to test it? thanks.

Yes, this also fixes the problem.

> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 08e8a89..d2f9a6e 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
...
> @@ -515,6 +520,23 @@ static void pv_eoi_clr_pending(struct kvm_vcpu *vcpu)
>  	__clear_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention);
>  }
>  
> +void kvm_apic_zap_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap,
> +		u32 *tmr)
> +{
> +	u32 i, reg_off, intr_in_service[8];

There's no reason for intr_in_service to be an array here.  Thanks,

Alex

> +	struct kvm_lapic *apic = vcpu->arch.apic;
> +
> +	for (i = 0; i < 8; i++) {
> +		reg_off = 0x10 * i;
> +		intr_in_service[i] = apic_read_reg(apic, APIC_ISR + reg_off) &
> +			apic_read_reg(apic, APIC_TMR + reg_off);
> +		if (intr_in_service[i]) {
> +			*((u32 *)eoi_exit_bitmap + i) |= intr_in_service[i];
> +			tmr[i] |= intr_in_service[i];
> +		}
> +	}
> +}
> +



      parent reply	other threads:[~2014-08-08 19:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-08  6:02 [PATCH] KVM: x86: check ISR and TMR to construct eoi exit bitmap Yang Zhang
2014-08-08  6:24 ` Chen, Tiejun
2014-08-08 19:16 ` Alex Williamson [this message]

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=1407525383.26210.19.camel@ul30vt.home \
    --to=alex.williamson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox