xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>
Subject: [PATCH v4 10/12] IOMMU: introduce IOMMU_MIXED config option
Date: Tue, 02 Oct 2018 04:18:05 -0600	[thread overview]
Message-ID: <5BB345DD02000078001EDA5A@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <5BB343D802000078001ED9F6@prv1-mh.provo.novell.com>

ARM is intended to gain support for heterogeneous IOMMUs on a single
system. This not only disallows boot time replacement of respective
indirect calls (handling of which is the main goal of the introduction
here), but more generally disallows calls using the iommu_ops() return
value directly - all such calls need to have means (commonly a domain
pointer) to know the targeted IOMMU.

Disallow all hooks lacking such context for the time being, which in
effect is some dead code elimination for ARM. Once extended suitably,
individual of these hooks can be moved out of their guards again in the
future.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v4: New.

--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -19,6 +19,7 @@ config ARM
 	select HAS_DEVICE_TREE
 	select HAS_PASSTHROUGH
 	select HAS_PDX
+	select IOMMU_MIXED
 
 config ARCH_DEFCONFIG
 	string
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -938,7 +938,7 @@ static int construct_memop_from_reservat
     return 0;
 }
 
-#ifdef CONFIG_HAS_PASSTHROUGH
+#if defined(CONFIG_HAS_PASSTHROUGH) && !defined(CONFIG_IOMMU_MIXED)
 struct get_reserved_device_memory {
     struct xen_reserved_device_memory_map map;
     unsigned int used_entries;
@@ -1550,7 +1550,7 @@ long do_memory_op(unsigned long cmd, XEN
         break;
     }
 
-#ifdef CONFIG_HAS_PASSTHROUGH
+#if defined(CONFIG_HAS_PASSTHROUGH) && !defined(CONFIG_IOMMU_MIXED)
     case XENMEM_reserved_device_memory_map:
     {
         struct get_reserved_device_memory grdm;
--- a/xen/drivers/passthrough/Kconfig
+++ b/xen/drivers/passthrough/Kconfig
@@ -2,6 +2,9 @@
 config HAS_PASSTHROUGH
 	bool
 
+config IOMMU_MIXED
+	bool
+
 if ARM
 config ARM_SMMU
 	bool "ARM SMMUv1 and v2 driver"
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -77,9 +77,11 @@ bool_t __read_mostly amd_iommu_perdev_in
 
 DEFINE_PER_CPU(bool_t, iommu_dont_flush_iotlb);
 
+#ifndef CONFIG_IOMMU_MIXED
 DEFINE_SPINLOCK(iommu_pt_cleanup_lock);
 PAGE_LIST_HEAD(iommu_pt_cleanup_list);
 static struct tasklet iommu_pt_cleanup_tasklet;
+#endif
 
 static int __init parse_iommu_param(const char *s)
 {
@@ -246,7 +248,9 @@ void iommu_teardown(struct domain *d)
 
     d->need_iommu = 0;
     hd->platform_ops->teardown(d);
+#ifndef CONFIG_IOMMU_MIXED
     tasklet_schedule(&iommu_pt_cleanup_tasklet);
+#endif
 }
 
 int iommu_construct(struct domain *d)
@@ -332,6 +336,7 @@ int iommu_unmap_page(struct domain *d, u
     return rc;
 }
 
+#ifndef CONFIG_IOMMU_MIXED
 static void iommu_free_pagetables(unsigned long unused)
 {
     do {
@@ -348,6 +353,7 @@ static void iommu_free_pagetables(unsign
     tasklet_schedule_on_cpu(&iommu_pt_cleanup_tasklet,
                             cpumask_cycle(smp_processor_id(), &cpu_online_map));
 }
+#endif
 
 int iommu_iotlb_flush(struct domain *d, unsigned long gfn,
                       unsigned int page_count)
@@ -433,12 +439,15 @@ int __init iommu_setup(void)
                iommu_hwdom_passthrough ? "Passthrough" :
                iommu_hwdom_strict ? "Strict" : "Relaxed");
         printk("Interrupt remapping %sabled\n", iommu_intremap ? "en" : "dis");
+#ifndef CONFIG_IOMMU_MIXED
         tasklet_init(&iommu_pt_cleanup_tasklet, iommu_free_pagetables, 0);
+#endif
     }
 
     return rc;
 }
 
+#ifndef CONFIG_IOMMU_MIXED
 int iommu_suspend()
 {
     if ( iommu_enabled )
@@ -453,27 +462,6 @@ void iommu_resume()
         iommu_get_ops()->resume();
 }
 
-int iommu_do_domctl(
-    struct xen_domctl *domctl, struct domain *d,
-    XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
-{
-    int ret = -ENODEV;
-
-    if ( !iommu_enabled )
-        return -ENOSYS;
-
-#ifdef CONFIG_HAS_PCI
-    ret = iommu_do_pci_domctl(domctl, d, u_domctl);
-#endif
-
-#ifdef CONFIG_HAS_DEVICE_TREE
-    if ( ret == -ENODEV )
-        ret = iommu_do_dt_domctl(domctl, d, u_domctl);
-#endif
-
-    return ret;
-}
-
 void iommu_share_p2m_table(struct domain* d)
 {
     if ( iommu_enabled && iommu_use_hap_pt(d) )
@@ -500,6 +488,28 @@ int iommu_get_reserved_device_memory(iom
 
     return ops->get_reserved_device_memory(func, ctxt);
 }
+#endif
+
+int iommu_do_domctl(
+    struct xen_domctl *domctl, struct domain *d,
+    XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
+{
+    int ret = -ENODEV;
+
+    if ( !iommu_enabled )
+        return -ENOSYS;
+
+#ifdef CONFIG_HAS_PCI
+    ret = iommu_do_pci_domctl(domctl, d, u_domctl);
+#endif
+
+#ifdef CONFIG_HAS_DEVICE_TREE
+    if ( ret == -ENODEV )
+        ret = iommu_do_dt_domctl(domctl, d, u_domctl);
+#endif
+
+    return ret;
+}
 
 bool_t iommu_has_feature(struct domain *d, enum iommu_feature feature)
 {
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -147,7 +147,7 @@ struct iommu_ops {
     int (*assign_device)(struct domain *, u8 devfn, device_t *dev, u32 flag);
     int (*reassign_device)(struct domain *s, struct domain *t,
                            u8 devfn, device_t *dev);
-#ifdef CONFIG_HAS_PCI
+#if defined(CONFIG_HAS_PCI) && !defined(CONFIG_IOMMU_MIXED)
     int (*get_device_group_id)(u16 seg, u8 bus, u8 devfn);
     int (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg);
     void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg);
@@ -157,6 +157,7 @@ struct iommu_ops {
     int __must_check (*map_page)(struct domain *d, unsigned long gfn,
                                  unsigned long mfn, unsigned int flags);
     int __must_check (*unmap_page)(struct domain *d, unsigned long gfn);
+#ifndef CONFIG_IOMMU_MIXED
     void (*free_page_table)(struct page_info *);
 #ifdef CONFIG_X86
     void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);
@@ -167,10 +168,11 @@ struct iommu_ops {
     void (*resume)(void);
     void (*share_p2m)(struct domain *d);
     void (*crash_shutdown)(void);
+    int (*get_reserved_device_memory)(iommu_grdm_t *, void *);
+#endif
     int __must_check (*iotlb_flush)(struct domain *d, unsigned long gfn,
                                     unsigned int page_count);
     int __must_check (*iotlb_flush_all)(struct domain *d);
-    int (*get_reserved_device_memory)(iommu_grdm_t *, void *);
     void (*dump_p2m_table)(struct domain *d);
 };
 




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-10-02 10:18 UTC|newest]

Thread overview: 119+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11 13:26 [PATCH v3 0/9] x86: indirect call overhead reduction Jan Beulich
2018-09-11 13:32 ` [PATCH v3 1/9] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-09-21 10:49   ` Wei Liu
2018-09-21 11:47     ` Jan Beulich
2018-09-21 13:48       ` Wei Liu
2018-09-21 15:26         ` Jan Beulich
2018-09-26 11:06           ` Wei Liu
2018-09-11 13:32 ` [PATCH v3 2/9] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-09-21 10:50   ` Wei Liu
2018-09-11 13:33 ` [PATCH v3 3/9] x86/HVM: patch vINTR " Jan Beulich
2018-09-21 10:50   ` Wei Liu
2018-09-11 13:34 ` [PATCH v3 4/9] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-09-21 10:51   ` Wei Liu
2018-09-11 13:35 ` [PATCH v3 5/9] x86/genapic: remove indirection from genapic hook accesses Jan Beulich
2018-09-21 10:53   ` Wei Liu
2018-09-11 13:35 ` [PATCH v3 6/9] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-09-21 11:03   ` Wei Liu
2018-09-21 11:53     ` Jan Beulich
2018-09-21 13:55   ` Wei Liu
2018-09-11 13:35 ` [PATCH v3 7/9] x86/cpuidle: patch some " Jan Beulich
2018-09-21 14:01   ` Wei Liu
2018-09-11 13:37 ` [PATCH v3 8/9] cpufreq: convert to a single post-init driver (hooks) instance Jan Beulich
2018-09-21 14:06   ` Wei Liu
2018-09-11 13:37 ` [PATCH v3 9/9] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-09-21 14:06   ` Wei Liu
2018-10-02 10:09 ` [PATCH v4 00/12] x86: indirect call overhead reduction Jan Beulich
2018-10-02 10:12   ` [PATCH v4 01/12] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-10-02 13:21     ` Andrew Cooper
2018-10-02 13:28       ` Julien Grall
2018-10-02 13:35         ` Andrew Cooper
2018-10-02 13:36           ` Julien Grall
2018-10-02 14:06       ` Jan Beulich
2018-10-02 14:23         ` Andrew Cooper
2018-10-02 14:43           ` Jan Beulich
2018-10-02 15:40             ` Andrew Cooper
2018-10-02 16:06               ` Jan Beulich
2018-10-02 13:55     ` Wei Liu
2018-10-02 14:08       ` Jan Beulich
2018-10-03 18:38     ` Andrew Cooper
2018-10-05 12:39       ` Andrew Cooper
2018-10-05 13:43         ` Jan Beulich
2018-10-05 14:49           ` Andrew Cooper
2018-10-05 15:05             ` Jan Beulich
2018-10-29 11:01       ` Jan Beulich
2018-10-02 10:12   ` [PATCH v4 02/12] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-10-02 13:18     ` Paul Durrant
2018-10-03 18:55     ` Andrew Cooper
2018-10-04 10:19       ` Jan Beulich
2018-10-02 10:13   ` [PATCH v4 03/12] x86/HVM: patch vINTR " Jan Beulich
2018-10-03 19:01     ` Andrew Cooper
2018-10-02 10:13   ` [PATCH v4 04/12] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-10-03 19:01     ` Andrew Cooper
2018-10-02 10:14   ` [PATCH v4 05/12] x86/genapic: remove indirection from genapic hook accesses Jan Beulich
2018-10-03 19:04     ` Andrew Cooper
2018-10-02 10:14   ` [PATCH v4 06/12] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-10-03 19:07     ` Andrew Cooper
2018-10-02 10:15   ` [PATCH v4 07/12] x86/cpuidle: patch some " Jan Beulich
2018-10-04 10:35     ` Andrew Cooper
2018-10-02 10:16   ` [PATCH v4 08/12] cpufreq: convert to a single post-init driver (hooks) instance Jan Beulich
2018-10-04 10:36     ` Andrew Cooper
2018-10-02 10:16   ` [PATCH v4 09/12] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-10-04 10:36     ` Andrew Cooper
2018-10-02 10:18   ` Jan Beulich [this message]
2018-10-02 10:38     ` [PATCH v4 10/12] IOMMU: introduce IOMMU_MIXED config option Julien Grall
2018-10-02 10:42       ` Jan Beulich
2018-10-02 11:00         ` Julien Grall
2018-10-02 11:58           ` Jan Beulich
2018-10-02 12:58             ` Julien Grall
2018-11-06 15:48       ` Jan Beulich
2018-11-07 18:01         ` Julien Grall
2018-10-02 10:18   ` [PATCH v4 11/12] IOMMU: remove indirection from certain IOMMU hook accesses Jan Beulich
2018-10-02 10:19   ` [PATCH v4 12/12] IOMMU: patch certain indirect calls to direct ones Jan Beulich
2018-11-08 15:56 ` [PATCH v5 00/13] x86: indirect call overhead reduction Jan Beulich
2018-11-08 16:05   ` [PATCH v5 01/13] x86: reduce general stack alignment to 8 Jan Beulich
2018-11-29 14:54     ` Wei Liu
2018-11-29 15:03       ` Jan Beulich
2018-11-29 17:44     ` Wei Liu
2018-11-30  9:03       ` Jan Beulich
2018-12-03 11:29         ` Wei Liu
2018-11-08 16:06   ` [PATCH v5 02/13] x86: clone Linux'es ASM_CALL_CONSTRAINT Jan Beulich
2018-11-29 17:13     ` Wei Liu
2018-11-08 16:08   ` [PATCH v5 03/13] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-11-12 10:36     ` Jan Beulich
2018-11-08 16:09   ` [PATCH v5 04/13] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-11-08 16:09   ` [PATCH v5 05/13] x86/HVM: patch vINTR " Jan Beulich
2018-11-08 16:10   ` [PATCH v5 06/13] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-11-08 16:11   ` [PATCH v5 07/13] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-11-08 16:11   ` [PATCH v5 08/13] x86/cpuidle: patch some " Jan Beulich
2018-11-08 16:12   ` [PATCH v5 09/13] cpufreq: convert to a single post-init driver (hooks) instance Jan Beulich
2018-11-08 16:13   ` [PATCH v5 10/13] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-11-08 16:14   ` [PATCH v5 11/13] IOMMU: move inclusion point of asm/iommu.h Jan Beulich
2018-11-12 11:55     ` Julien Grall
2018-11-08 16:16   ` [PATCH v5 12/13] IOMMU/x86: remove indirection from certain IOMMU hook accesses Jan Beulich
2018-11-14  3:25     ` Tian, Kevin
2018-11-14 17:16     ` Woods, Brian
2018-11-08 16:17   ` [PATCH v5 13/13] IOMMU: patch certain indirect calls to direct ones Jan Beulich
2018-11-29 14:49     ` Wei Liu
2018-12-05 15:54 ` [PATCH v6 00/10] x86: indirect call overhead reduction Jan Beulich
2018-12-05 16:02   ` [PATCH v6 01/10] x86: reduce general stack alignment to 8 Jan Beulich
2018-12-05 16:02   ` [PATCH v6 02/10] x86: clone Linux'es ASM_CALL_CONSTRAINT Jan Beulich
2018-12-05 16:03   ` [PATCH v6 03/10] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2018-12-05 16:04   ` [PATCH v6 04/10] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2018-12-05 16:05   ` [PATCH v6 05/10] x86/HVM: patch vINTR " Jan Beulich
2018-12-05 16:06   ` [PATCH v6 06/10] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2018-12-05 16:06   ` [PATCH v6 07/10] x86/genapic: patch indirect calls to direct ones Jan Beulich
2018-12-05 16:07   ` [PATCH v6 08/10] x86/cpuidle: patch some " Jan Beulich
2018-12-05 16:07   ` [PATCH v6 09/10] cpufreq: patch target() indirect call to direct one Jan Beulich
2018-12-05 16:08   ` [PATCH v6 10/10] IOMMU: patch certain indirect calls to direct ones Jan Beulich
     [not found] ` <5C07F49D0200000000101036@prv1-mh.provo.novell.com>
     [not found]   ` <5C07F49D020000780021DC1A@prv1-mh.provo.novell.com>
2019-03-12 13:59     ` [PATCH v7 00/10] x86: indirect call overhead reduction Jan Beulich
2019-03-12 14:03       ` [PATCH v7 01/10] x86: reduce general stack alignment to 8 Jan Beulich
2019-03-12 14:04       ` [PATCH v7 02/10] x86: clone Linux'es ASM_CALL_CONSTRAINT Jan Beulich
2019-03-12 14:05       ` [PATCH v7 03/10] x86: infrastructure to allow converting certain indirect calls to direct ones Jan Beulich
2019-03-12 14:06       ` [PATCH v7 04/10] x86/HVM: patch indirect calls through hvm_funcs " Jan Beulich
2019-03-12 14:06       ` [PATCH v7 05/10] x86/HVM: patch vINTR " Jan Beulich
2019-03-12 14:07       ` [PATCH v7 06/10] x86: patch ctxt_switch_masking() indirect call to direct one Jan Beulich
2019-03-12 14:07       ` [PATCH v7 07/10] x86/genapic: patch indirect calls to direct ones Jan Beulich
2019-03-12 14:08       ` [PATCH v7 08/10] x86/cpuidle: patch some " Jan Beulich
2019-03-12 14:08       ` [PATCH v7 09/10] cpufreq: patch target() indirect call to direct one Jan Beulich
2019-03-12 14:09       ` [PATCH v7 10/10] IOMMU: patch certain indirect calls to direct ones Jan Beulich

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=5BB345DD02000078001EDA5A@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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).