* [Qemu-devel] [PATCH] vfio-pci: Add missing kvm_enabled() checks
@ 2012-12-20 21:14 Stefan Hajnoczi
2012-12-20 22:35 ` Alex Williamson
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-12-20 21:14 UTC (permalink / raw)
To: qemu-devel; +Cc: Alex Williamson, Stefan Hajnoczi
It's necessary to check kvm_enabled() since a QEMU binary can be
compiled with KVM support but TCG can be used at run-time.
kvm_check_extension() segfaults if kvm_state is NULL.
Reported-by: Joe Terranova <joeterranova@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/vfio_pci.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
index fbfe670..677dc48 100644
--- a/hw/vfio_pci.c
+++ b/hw/vfio_pci.c
@@ -275,7 +275,8 @@ static void vfio_enable_intx_kvm(VFIODevice *vdev)
int ret, argsz;
int32_t *pfd;
- if (!kvm_irqfds_enabled() ||
+ if (!kvm_enabled() ||
+ !kvm_irqfds_enabled() ||
vdev->intx.route.mode != PCI_INTX_ENABLED ||
!kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
return;
@@ -438,7 +439,8 @@ static int vfio_enable_intx(VFIODevice *vdev)
* Only conditional to avoid generating error messages on platforms
* where we won't actually use the result anyway.
*/
- if (kvm_irqfds_enabled() &&
+ if (kvm_enabled() &&
+ kvm_irqfds_enabled() &&
kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev,
vdev->intx.pin);
--
1.8.0.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vfio-pci: Add missing kvm_enabled() checks
2012-12-20 21:14 [Qemu-devel] [PATCH] vfio-pci: Add missing kvm_enabled() checks Stefan Hajnoczi
@ 2012-12-20 22:35 ` Alex Williamson
2012-12-21 7:11 ` Stefan Hajnoczi
0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2012-12-20 22:35 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel
On Thu, 2012-12-20 at 22:14 +0100, Stefan Hajnoczi wrote:
> It's necessary to check kvm_enabled() since a QEMU binary can be
> compiled with KVM support but TCG can be used at run-time.
> kvm_check_extension() segfaults if kvm_state is NULL.
Ugh, this is exactly why we added kvm_irqfds_enabled() which doesn't
call kvm_check_extension(). How is it possible to fall through to a
kvm_check_extension() with that in place? Thanks,
Alex
> Reported-by: Joe Terranova <joeterranova@gmail.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> hw/vfio_pci.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
> index fbfe670..677dc48 100644
> --- a/hw/vfio_pci.c
> +++ b/hw/vfio_pci.c
> @@ -275,7 +275,8 @@ static void vfio_enable_intx_kvm(VFIODevice *vdev)
> int ret, argsz;
> int32_t *pfd;
>
> - if (!kvm_irqfds_enabled() ||
> + if (!kvm_enabled() ||
> + !kvm_irqfds_enabled() ||
> vdev->intx.route.mode != PCI_INTX_ENABLED ||
> !kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
> return;
> @@ -438,7 +439,8 @@ static int vfio_enable_intx(VFIODevice *vdev)
> * Only conditional to avoid generating error messages on platforms
> * where we won't actually use the result anyway.
> */
> - if (kvm_irqfds_enabled() &&
> + if (kvm_enabled() &&
> + kvm_irqfds_enabled() &&
> kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) {
> vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev,
> vdev->intx.pin);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vfio-pci: Add missing kvm_enabled() checks
2012-12-20 22:35 ` Alex Williamson
@ 2012-12-21 7:11 ` Stefan Hajnoczi
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-12-21 7:11 UTC (permalink / raw)
To: Alex Williamson; +Cc: qemu-devel, Stefan Hajnoczi
On Thu, Dec 20, 2012 at 11:35 PM, Alex Williamson
<alex.williamson@redhat.com> wrote:
> On Thu, 2012-12-20 at 22:14 +0100, Stefan Hajnoczi wrote:
>> It's necessary to check kvm_enabled() since a QEMU binary can be
>> compiled with KVM support but TCG can be used at run-time.
>> kvm_check_extension() segfaults if kvm_state is NULL.
>
> Ugh, this is exactly why we added kvm_irqfds_enabled() which doesn't
> call kvm_check_extension(). How is it possible to fall through to a
> kvm_check_extension() with that in place? Thanks,
Ah, this explains it: Joe was using QEMU 1.3.0 which does not contain
the kvm_irqfds_enabled() fix.
My patch is unnecessary and can be dropped.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-21 7:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-20 21:14 [Qemu-devel] [PATCH] vfio-pci: Add missing kvm_enabled() checks Stefan Hajnoczi
2012-12-20 22:35 ` Alex Williamson
2012-12-21 7:11 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).