diff mbox series

[v2,8/8] pc: stubify x86 iommu

Message ID 1576171754-45138-9-git-send-email-pbonzini@redhat.com
State New
Headers show
Series x86: allow building without PC machine types | expand

Commit Message

Paolo Bonzini Dec. 12, 2019, 5:29 p.m. UTC
Allow building microvm without x86-iommu.c and in turn hw/i386/pc.h.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/Kconfig          |  6 ++++++
 hw/i386/Makefile.objs    |  3 ++-
 hw/i386/x86-iommu-stub.c | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletions(-)
 create mode 100644 hw/i386/x86-iommu-stub.c

Comments

Thomas Huth Jan. 7, 2020, 2:26 p.m. UTC | #1
On 12/12/2019 18.29, Paolo Bonzini wrote:
> Allow building microvm without x86-iommu.c and in turn hw/i386/pc.h.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/i386/Kconfig          |  6 ++++++
>  hw/i386/Makefile.objs    |  3 ++-
>  hw/i386/x86-iommu-stub.c | 34 ++++++++++++++++++++++++++++++++++
>  3 files changed, 42 insertions(+), 1 deletions(-)
>  create mode 100644 hw/i386/x86-iommu-stub.c

I just ran into this strange Travis build issue:

 https://travis-ci.com/huth/qemu/jobs/273007378#L3509

... I think it might be related to this patch?

CONFIG_Q35 only does "imply AMD_IOMMU", so when compiling with
"--without-default-devices", x86-iommu.c is not used... Do
x86_iommu_ir_supported() and x86_iommu_get_type() need to be added to
the x86-iommu-stub.c file?

 Thomas
Thomas Huth Jan. 7, 2020, 2:59 p.m. UTC | #2
On 07/01/2020 15.26, Thomas Huth wrote:
> On 12/12/2019 18.29, Paolo Bonzini wrote:
>> Allow building microvm without x86-iommu.c and in turn hw/i386/pc.h.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  hw/i386/Kconfig          |  6 ++++++
>>  hw/i386/Makefile.objs    |  3 ++-
>>  hw/i386/x86-iommu-stub.c | 34 ++++++++++++++++++++++++++++++++++
>>  3 files changed, 42 insertions(+), 1 deletions(-)
>>  create mode 100644 hw/i386/x86-iommu-stub.c
> 
> I just ran into this strange Travis build issue:
> 
>  https://travis-ci.com/huth/qemu/jobs/273007378#L3509
> 
> ... I think it might be related to this patch?
> 
> CONFIG_Q35 only does "imply AMD_IOMMU", so when compiling with
> "--without-default-devices", x86-iommu.c is not used... Do
> x86_iommu_ir_supported() and x86_iommu_get_type() need to be added to
> the x86-iommu-stub.c file?

FWIW, I just found Phil's patch which should fix this issue:

https://lists.gnu.org/archive/html/qemu-devel/2020-01/msg00959.html

 Thomas
diff mbox series

Patch

diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index 5a49434..91cf584 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -103,11 +103,17 @@  config MICROVM
     select MC146818RTC
     select VIRTIO_MMIO
 
+config X86_IOMMU
+    bool
+    depends on PC
+
 config VTD
     bool
+    select X86_IOMMU
 
 config AMD_IOMMU
     bool
+    select X86_IOMMU
 
 config VMPORT
     bool
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 01ae202..1236c3b 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -6,7 +6,8 @@  obj-$(CONFIG_I440FX) += pc_piix.o
 obj-$(CONFIG_Q35) += pc_q35.o
 obj-$(CONFIG_MICROVM) += microvm.o
 obj-y += fw_cfg.o
-obj-y += x86-iommu.o
+obj-$(CONFIG_X86_IOMMU) += x86-iommu.o
+obj-$(call lnot,$(CONFIG_X86_IOMMU)) += x86-iommu-stub.o
 obj-$(CONFIG_VTD) += intel_iommu.o
 obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o
 obj-$(CONFIG_XEN) += ../xenpv/ xen/
diff --git a/hw/i386/x86-iommu-stub.c b/hw/i386/x86-iommu-stub.c
new file mode 100644
index 0000000..03576cd
--- /dev/null
+++ b/hw/i386/x86-iommu-stub.c
@@ -0,0 +1,34 @@ 
+/*
+ * Stubs for X86 IOMMU emulation
+ *
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * Author: Paolo Bonzini <pbonzini@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/i386/x86-iommu.h"
+
+void x86_iommu_iec_register_notifier(X86IOMMUState *iommu,
+                                     iec_notify_fn fn, void *data)
+{
+}
+
+X86IOMMUState *x86_iommu_get_default(void)
+{
+    return NULL;
+}
+