[Android-virt] [PATCH 06/10] ARM: KVM: VGIC: Implement kvm_vgic_get_current_vcpu()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 14, 2012 at 9:07 AM, Marc Zyngier <marc.zyngier at arm.com> wrote:
> When a timer interrupt occurs for the guest, it is necessary
> to find out which VCPU was running at that point.
>
> Thankfully, the VGIC code already keeps track of this, so it is
> only a matter of exposing the information. The returned pointer
> is only valid in the interrupt handler.
>
> Signed-off-by: Marc Zyngier <marc.zyngier at arm.com>
> ---
> ?arch/arm/include/asm/kvm_vgic.h | ? ?6 ++++++
> ?arch/arm/kvm/vgic.c ? ? ? ? ? ? | ? ?5 +++++
> ?2 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/include/asm/kvm_vgic.h b/arch/arm/include/asm/kvm_vgic.h
> index 4e7f6c3..1690c6d 100644
> --- a/arch/arm/include/asm/kvm_vgic.h
> +++ b/arch/arm/include/asm/kvm_vgic.h
> @@ -148,6 +148,7 @@ void kvm_vgic_sync_from_cpu(struct kvm_vcpu *vcpu);
> ?int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, const struct kvm_irq_level *irq);
> ?int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu);
> ?int vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run);
> +struct kvm_vcpu *kvm_vgic_get_current_vcpu(void);
>
> ?#define irqchip_in_kernel(k) ? (!!((k)->arch.vgic.vctrl_base))
> ?#else
> @@ -175,6 +176,11 @@ static inline int vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run)
> ? ? ? ?return KVM_EXIT_MMIO;
> ?}
>
> +static inline struct kvm_vcpu *kvm_vgic_get_current_vcpu(void)
> +{
> + ? ? ? return NULL;
> +}
> +
> ?static inline int irqchip_in_kernel(struct kvm *kvm)
> ?{
> ? ? ? ?return 0;
> diff --git a/arch/arm/kvm/vgic.c b/arch/arm/kvm/vgic.c
> index 1b4f6b7..c8bcc9e 100644
> --- a/arch/arm/kvm/vgic.c
> +++ b/arch/arm/kvm/vgic.c
> @@ -687,6 +687,11 @@ void kvm_vgic_sync_from_cpu(struct kvm_vcpu *vcpu)
> ? ? ? ?*__this_cpu_ptr(vgic_vcpus) = NULL;
> ?}
>
> +struct kvm_vcpu *kvm_vgic_get_current_vcpu(void)
> +{
> + ? ? ? return *__this_cpu_ptr(vgic_vcpus);
> +}
> +
> ?int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu)
> ?{
> ? ? ? ?struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
> --
> 1.7.7.1
>
I think this should be factored out to generic code instead. It's not
vgic-specific is it?


-Christoffer



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux