public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Yang Zhang <yang.z.zhang@intel.com>
Cc: kvm@vger.kernel.org, gleb@redhat.com, xiantao.zhang@intel.com
Subject: Re: [PATCH v5 4/6] KVM: Add reset/restore rtc_status support
Date: Fri, 22 Mar 2013 07:16:16 -0300	[thread overview]
Message-ID: <20130322101616.GA5924@amt.cnet> (raw)
In-Reply-To: <1363862964-25148-5-git-send-email-yang.z.zhang@intel.com>

On Thu, Mar 21, 2013 at 06:49:22PM +0800, Yang Zhang wrote:
> From: Yang Zhang <yang.z.zhang@Intel.com>
> 
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> ---
>  arch/x86/kvm/lapic.c |    8 ++++++++
>  arch/x86/kvm/lapic.h |    2 ++
>  virt/kvm/ioapic.c    |   35 +++++++++++++++++++++++++++++++++++
>  3 files changed, 45 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 5f6b1d0..158e0a3 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -94,6 +94,14 @@ static inline int apic_test_vector(int vec, void *bitmap)
>  	return test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
>  }
>  
> +bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector)
> +{
> +	struct kvm_lapic *apic = vcpu->arch.apic;
> +
> +	return apic_test_vector(vector, apic->regs + APIC_ISR) ||
> +		apic_test_vector(vector, apic->regs + APIC_IRR);
> +}
> +
>  static inline void apic_set_vector(int vec, void *bitmap)
>  {
>  	set_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
> diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
> index 967519c..004d2ad 100644
> --- a/arch/x86/kvm/lapic.h
> +++ b/arch/x86/kvm/lapic.h
> @@ -170,4 +170,6 @@ static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu)
>  	return vcpu->arch.apic->pending_events;
>  }
>  
> +bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector);
> +
>  #endif
> diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
> index 4767fa6..8f9c62b 100644
> --- a/virt/kvm/ioapic.c
> +++ b/virt/kvm/ioapic.c
> @@ -87,6 +87,39 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
>  	return result;
>  }
>  
> +#ifdef CONFIG_X86
> +static void rtc_irq_reset(struct kvm_ioapic *ioapic)
> +{
> +	ioapic->rtc_status.pending_eoi = 0;
> +	bitmap_zero(ioapic->rtc_status.dest_map, KVM_MAX_VCPUS);
> +}
> +
> +static void rtc_irq_restore(struct kvm_ioapic *ioapic)
> +{
> +	struct kvm_vcpu *vcpu;
> +	int vector, i, pending_eoi = 0, rtc_pin = 8;
> +
> +	vector = ioapic->redirtbl[rtc_pin].fields.vector;
> +	kvm_for_each_vcpu(i, vcpu, ioapic->kvm) {
> +		if (kvm_apic_pending_eoi(vcpu, vector)) {
> +			pending_eoi++;
> +			set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map);
> +		}
> +	}
> +	ioapic->rtc_status.pending_eoi = pending_eoi;
> +}

Userspace can load the IOAPIC before loading VCPUS LAPIC via
KVM_SET_LAPIC. So kvm_lapic_reset / kvm_apic_post_state_restore should
also update ioapic->rtc_status.dest_map (checking whether ioapic is
initialized, of course).

Please add a comment explaining why dest_map is necessary (or explain it
in the changelog).


  reply	other threads:[~2013-03-22 10:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21 10:49 [PATCH v5 0/6] Use eoi to track RTC interrupt delivery status Yang Zhang
2013-03-21 10:49 ` [PATCH v5 1/6] KVM: Add vcpu info to ioapic_update_eoi() Yang Zhang
2013-03-21 10:49 ` [PATCH v5 2/6] KVM: Introduce struct rtc_status Yang Zhang
2013-03-21 12:08   ` Gleb Natapov
2013-03-21 12:15     ` Zhang, Yang Z
2013-03-21 10:49 ` [PATCH v5 3/6] KVM : Calculate destination vcpu on interrupt injection Yang Zhang
2013-03-21 11:48   ` Gleb Natapov
2013-03-21 11:56     ` Zhang, Yang Z
2013-03-21 12:03       ` Gleb Natapov
2013-03-21 12:12         ` Zhang, Yang Z
2013-03-21 12:21           ` Gleb Natapov
2013-03-21 12:25             ` Zhang, Yang Z
2013-03-21 10:49 ` [PATCH v5 4/6] KVM: Add reset/restore rtc_status support Yang Zhang
2013-03-22 10:16   ` Marcelo Tosatti [this message]
2013-03-22 10:47     ` Zhang, Yang Z
2013-03-21 10:49 ` [PATCH v5 5/6] KVM: Force vmexit with virtual interrupt delivery Yang Zhang
2013-03-21 10:49 ` [PATCH v5 6/6] KVM: Use eoi to track RTC interrupt delivery status Yang Zhang

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=20130322101616.GA5924@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox