public inbox for kvmarm@lists.cs.columbia.edu
 help / color / mirror / Atom feed
From: Christoffer Dall <christoffer.dall@linaro.org>
To: Pavel Fedin <p.fedin@samsung.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>,
	KVM-ARM mailing list <kvmarm@lists.cs.columbia.edu>
Subject: Re: [PATCH 1/2] Fix NULL pointer dereferences if KVM is used without in-kernel irqchip
Date: Thu, 9 Jul 2015 13:11:13 +0200	[thread overview]
Message-ID: <20150709111113.GI13530@cbox> (raw)
In-Reply-To: <46c62639f325ef935c4ca24c5fc9d5eb2b4a0979.1436264839.git.p.fedin@samsung.com>

On Tue, Jul 07, 2015 at 01:38:48PM +0300, Pavel Fedin wrote:
> Makes qemu working again with kernel-irqchip=off option
> 
> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
> ---
>  virt/kvm/arm/vgic.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index 78fb820..3420657 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -100,6 +100,9 @@ static bool queue_sgi(struct kvm_vcpu *vcpu, int irq)
>  
>  int kvm_vgic_map_resources(struct kvm *kvm)
>  {
> +	if (!kvm->arch.vgic.vm_ops.map_resources)
> +		return 0;
> +
>  	return kvm->arch.vgic.vm_ops.map_resources(kvm, vgic);
>  }
>  
> @@ -1637,7 +1640,7 @@ static int vgic_vcpu_init_maps(struct kvm_vcpu *vcpu, int nr_irqs)
>   */
>  int kvm_vgic_get_max_vcpus(void)
>  {
> -	return vgic->max_gic_vcpus;
> +	return vgic ? vgic->max_gic_vcpus : KVM_MAX_VCPUS;
>  }
>  
>  void kvm_vgic_destroy(struct kvm *kvm)
> -- 
> 2.4.4
> 

This feels like defensive programming and it's a bit weird to return
something from kvm_vgic_get_max_vcpus when there is no vgic...

I would probably guard the callers with irqchip_in_kernel instead.

-Christoffer

  reply	other threads:[~2015-07-09 10:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 10:38 [PATCH 0/2] Allow to use KVM without in-kernel irqchip Pavel Fedin
2015-07-07 10:38 ` [PATCH 1/2] Fix NULL pointer dereferences if KVM is used " Pavel Fedin
2015-07-09 11:11   ` Christoffer Dall [this message]
2015-07-07 10:38 ` [PATCH 2/2] Detect vGIC presence at runtime Pavel Fedin
2015-07-09 11:37   ` Christoffer Dall
2015-07-09 12:50     ` Pavel Fedin
2015-07-09 13:25       ` Christoffer Dall
2015-07-09 13:47         ` Pavel Fedin

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=20150709111113.GI13530@cbox \
    --to=christoffer.dall@linaro.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    --cc=p.fedin@samsung.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