From: Mohammed Gamal <mgamal@redhat.com>
To: qemu-devel@nongnu.org
Cc: thuth@redhat.com, ehabkost@redhat.com, peterx@redhat.com,
pbonzini@redhat.com, mst@redhat.com, mjt@tls.msk.ru,
Mohammed Gamal <mgamal@redhat.com>
Subject: [Qemu-devel] [PATCH RESEND 2/2] x86_iommu: check if machine has PCI bus
Date: Mon, 16 Oct 2017 11:06:23 +0200 [thread overview]
Message-ID: <1508144783-18792-3-git-send-email-mgamal@redhat.com> (raw)
In-Reply-To: <1508144783-18792-1-git-send-email-mgamal@redhat.com>
Starting qemu with
qemu-system-x86_64 -S -M isapc -device {amd|intel}-iommu
leads to a segfault. The code assume PCI bus is present and
tries to access the bus structure without checking.
Since Intel VT-d and AMDVI should only work with PCI, add a
check for PCI bus and return error if not present.
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
---
hw/i386/x86-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
index 51de519..8a01a2d 100644
--- a/hw/i386/x86-iommu.c
+++ b/hw/i386/x86-iommu.c
@@ -88,7 +88,7 @@ static void x86_iommu_realize(DeviceState *dev, Error **errp)
PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE));
QLIST_INIT(&x86_iommu->iec_notifiers);
- if (!pcms) {
+ if (!pcms || !pcms->bus) {
error_setg(errp, "Machine-type '%s' not supported by IOMMU",
mc->name);
return;
--
1.8.3.1
next prev parent reply other threads:[~2017-10-16 9:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 9:06 [Qemu-devel] [PATCH RESEND 0/2] x86_iommu: Fix segfault when starting on non-PCI machines Mohammed Gamal
2017-10-16 9:06 ` [Qemu-devel] [PATCH RESEND 1/2] x86_iommu: Move machine check to x86_iommu_realize() Mohammed Gamal
2017-10-16 9:06 ` Mohammed Gamal [this message]
2017-10-16 9:31 ` [Qemu-devel] [PATCH RESEND 0/2] x86_iommu: Fix segfault when starting on non-PCI machines Peter Xu
2017-10-18 17:34 ` Michael S. Tsirkin
-- strict thread matches above, loose matches on Subject: below --
2017-11-29 12:33 Mohammed Gamal
2017-11-29 12:33 ` [Qemu-devel] [PATCH RESEND 2/2] x86_iommu: check if machine has PCI bus Mohammed Gamal
2017-11-29 15:26 ` Thomas Huth
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=1508144783-18792-3-git-send-email-mgamal@redhat.com \
--to=mgamal@redhat.com \
--cc=ehabkost@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.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;
as well as URLs for NNTP newsgroup(s).