Skip to contentSkip to conversation

x86/io: rename dpci_ IO port handlers

PATCH Superseded Roger Pau Monne 4 participants 14 messages Mar 28, 2017 – Apr 4, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover x86/io: rename dpci_ IO port handlers

Hello,

The following series contain two cosmetic fixes for the g2m IO port handlers. The first one renames them to use the g2m_ prefix instead of the dpci_ one, since those handlers are not trapping the PCI config space in any way. The second fix moves the list of ports from the domain_iommu struct to the hvm_struct, where it fits more naturally.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

PATCH v2 1/2 x86/io: rename misleading dpci_ prefixed functions to g2m_

The dpci_ prefix used on those IO handlers is misleading, there's nothing PCI specific in them, they simply map a guest IO port into a machine (physical) IO port. They don't specifically trap the PCI IO port range in any way (0xcf8/0xcfc).

Rename them to use the g2m_ prefix in order to avoid this confusion.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/hvm/hvm.c       |  2 +-
 xen/arch/x86/hvm/io.c        | 28 ++++++++++++----------------
 xen/include/asm-x86/hvm/io.h |  6 +++++-
 3 files changed, 18 insertions(+), 18 deletions(-)
xen/arch/x86/hvm/hvm.c +1 -1
index 0282986..3a2d001 100644
@@ -641,7 +641,7 @@ int hvm_domain_initialise(struct domain *d)
     else
         d->arch.hvm_domain.io_bitmap = hvm_io_bitmap;
 
-    register_dpci_portio_handler(d);
+    register_g2m_portio_handler(d);
 
     hvm_ioreq_init(d);
 
xen/arch/x86/hvm/io.c +12 -16
index 2770ff4..3b3a600 100644
@@ -167,8 +167,8 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
     return true;
 }
 
-static bool_t dpci_portio_accept(const struct hvm_io_handler *handler,
-                                 const ioreq_t *p)
+static bool_t g2m_portio_accept(const struct hvm_io_handler *handler,
+                                const ioreq_t *p)
 {
     struct vcpu *curr = current;
     const struct domain_iommu *dio = dom_iommu(curr->domain);
@@ -190,10 +190,8 @@ static bool_t dpci_portio_accept(const struct hvm_io_handler *handler,
     return 0;
 }
 
-static int dpci_portio_read(const struct hvm_io_handler *handler,
-                            uint64_t addr,
-                            uint32_t size,
-                            uint64_t *data)
+static int g2m_portio_read(const struct hvm_io_handler *handler,
+                           uint64_t addr, uint32_t size, uint64_t *data)
 {
     struct hvm_vcpu_io *vio = &current->arch.hvm_vcpu.hvm_io;
     const struct g2m_ioport *g2m_ioport = vio->g2m_ioport;
@@ -217,10 +215,8 @@ static int dpci_portio_read(const struct hvm_io_handler *handler,
     return X86EMUL_OKAY;
 }
 
-static int dpci_portio_write(const struct hvm_io_handler *handler,
-                             uint64_t addr,
-                             uint32_t size,
-                             uint64_t data)
+static int g2m_portio_write(const struct hvm_io_handler *handler,
+                            uint64_t addr, uint32_t size, uint64_t data)
 {
     struct hvm_vcpu_io *vio = &current->arch.hvm_vcpu.hvm_io;
     const struct g2m_ioport *g2m_ioport = vio->g2m_ioport;
@@ -244,13 +240,13 @@ static int dpci_portio_write(const struct hvm_io_handler *handler,
     return X86EMUL_OKAY;
 }
 
-static const struct hvm_io_ops dpci_portio_ops = {
-    .accept = dpci_portio_accept,
-    .read = dpci_portio_read,
-    .write = dpci_portio_write
+static const struct hvm_io_ops g2m_portio_ops = {
+    .accept = g2m_portio_accept,
+    .read = g2m_portio_read,
+    .write = g2m_portio_write
 };
 
-void register_dpci_portio_handler(struct domain *d)
+void register_g2m_portio_handler(struct domain *d)
 {
     struct hvm_io_handler *handler = hvm_next_io_handler(d);
 
@@ -258,7 +254,7 @@ void register_dpci_portio_handler(struct domain *d)
         return;
 
     handler->type = IOREQ_TYPE_PIO;
-    handler->ops = &dpci_portio_ops;
+    handler->ops = &g2m_portio_ops;
 }
 
 /*
xen/include/asm-x86/hvm/io.h +5 -1
index d6801c1..5ae9225 100644
@@ -148,7 +148,11 @@ void stdvga_deinit(struct domain *d);
 
 extern void hvm_dpci_msi_eoi(struct domain *d, int vector);
 
-void register_dpci_portio_handler(struct domain *d);
+/*
+ * HVM port IO handler that performs forwarding of guest IO ports into machine
+ * IO ports.
+ */
+void register_g2m_portio_handler(struct domain *d);
 
 #endif /* __ASM_X86_HVM_IO_H__ */
 
Signature · 7 lines
2.10.1 (Apple Git-78)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] x86/io: rename misleading dpci_ prefixed functions to g2m_

Quoted 10 lines

-----Original Message-----
From: Roger Pau Monne
Sent: 28 March 2017 14:12
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH v2 1/2] x86/io: rename misleading dpci_ prefixed functions to g2m_

Quoted 8 lines

The dpci_ prefix used on those IO handlers is misleading, there's nothing PCI specific in them, they simply map a guest IO port into a machine (physical) IO port. They don't specifically trap the PCI IO port range in any way (0xcf8/0xcfc).

Rename them to use the g2m_ prefix in order to avoid this confusion.

Quoted 112 lines

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/hvm/hvm.c       |  2 +-
 xen/arch/x86/hvm/io.c        | 28 ++++++++++++----------------
 xen/include/asm-x86/hvm/io.h |  6 +++++-
 3 files changed, 18 insertions(+), 18 deletions(-)
xen/arch/x86/hvm/hvm.c +1 -1
index 0282986..3a2d001 100644
@@ -641,7 +641,7 @@ int hvm_domain_initialise(struct domain *d)
     else
         d->arch.hvm_domain.io_bitmap = hvm_io_bitmap;
 
-    register_dpci_portio_handler(d);
+    register_g2m_portio_handler(d);
 
     hvm_ioreq_init(d);
 
xen/arch/x86/hvm/io.c +2 -2
index 2770ff4..3b3a600 100644
@@ -167,8 +167,8 @@ bool handle_pio(uint16_t port, unsigned int size, int
 dir)
     return true;
 }
 
-static bool_t dpci_portio_accept(const struct hvm_io_handler *handler,
-                                 const ioreq_t *p)
+static bool_t g2m_portio_accept(const struct hvm_io_handler *handler,
+                                const ioreq_t *p)
 {
     struct vcpu *curr = current;
     const struct domain_iommu *dio = dom_iommu(curr->domain);
xen/arch/x86/hvm/io.c +2 -4
@@ -190,10 +190,8 @@ static bool_t dpci_portio_accept(const struct
 hvm_io_handler *handler,
     return 0;
 }
 
-static int dpci_portio_read(const struct hvm_io_handler *handler,
-                            uint64_t addr,
-                            uint32_t size,
-                            uint64_t *data)
+static int g2m_portio_read(const struct hvm_io_handler *handler,
+                           uint64_t addr, uint32_t size, uint64_t *data)
 {
     struct hvm_vcpu_io *vio = &current->arch.hvm_vcpu.hvm_io;
     const struct g2m_ioport *g2m_ioport = vio->g2m_ioport;
xen/arch/x86/hvm/io.c +2 -4
@@ -217,10 +215,8 @@ static int dpci_portio_read(const struct
 hvm_io_handler *handler,
     return X86EMUL_OKAY;
 }
 
-static int dpci_portio_write(const struct hvm_io_handler *handler,
-                             uint64_t addr,
-                             uint32_t size,
-                             uint64_t data)
+static int g2m_portio_write(const struct hvm_io_handler *handler,
+                            uint64_t addr, uint32_t size, uint64_t data)
 {
     struct hvm_vcpu_io *vio = &current->arch.hvm_vcpu.hvm_io;
     const struct g2m_ioport *g2m_ioport = vio->g2m_ioport;
xen/arch/x86/hvm/io.c +6 -6
@@ -244,13 +240,13 @@ static int dpci_portio_write(const struct
 hvm_io_handler *handler,
     return X86EMUL_OKAY;
 }
 
-static const struct hvm_io_ops dpci_portio_ops = {
-    .accept = dpci_portio_accept,
-    .read = dpci_portio_read,
-    .write = dpci_portio_write
+static const struct hvm_io_ops g2m_portio_ops = {
+    .accept = g2m_portio_accept,
+    .read = g2m_portio_read,
+    .write = g2m_portio_write
 };
 
-void register_dpci_portio_handler(struct domain *d)
+void register_g2m_portio_handler(struct domain *d)
 {
     struct hvm_io_handler *handler = hvm_next_io_handler(d);
@@ -258,7 +254,7 @@ void register_dpci_portio_handler(struct domain *d)
         return;
 
     handler->type = IOREQ_TYPE_PIO;
-    handler->ops = &dpci_portio_ops;
+    handler->ops = &g2m_portio_ops;
 }
 
 /*
xen/include/asm-x86/hvm/io.h +2 -1
index d6801c1..5ae9225 100644
@@ -148,7 +148,11 @@ void stdvga_deinit(struct domain *d);
 
 extern void hvm_dpci_msi_eoi(struct domain *d, int vector);
 
-void register_dpci_portio_handler(struct domain *d);
+/*
+ * HVM port IO handler that performs forwarding of guest IO ports into

machine
+ * IO ports.
+ */
+void register_g2m_portio_handler(struct domain *d);

Quoted 4 lines

#endif /* __ASM_X86_HVM_IO_H__ */

--
2.10.1 (Apple Git-78)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

PATCH v2 2/2 x86/io: move the list of guest to machine IO ports out of domain_iommu

In reply to Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the presence of an IOMMU.

Move it inside of the hvm_domain struct instead.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/domctl.c               | 10 +++++-----
 xen/arch/x86/hvm/hvm.c              | 12 ++++++++++++
 xen/arch/x86/hvm/io.c               |  4 ++--
 xen/drivers/passthrough/x86/iommu.c | 11 -----------
 xen/include/asm-x86/hvm/domain.h    |  3 +++
 xen/include/asm-x86/iommu.h         |  1 -
 6 files changed, 22 insertions(+), 19 deletions(-)
xen/arch/x86/domctl.c +5 -5
index 1220224..b7b8748 100644
@@ -721,11 +721,11 @@ long arch_do_domctl(
 
     case XEN_DOMCTL_ioport_mapping:
     {
-        struct domain_iommu *hd;
         unsigned int fgp = domctl->u.ioport_mapping.first_gport;
         unsigned int fmp = domctl->u.ioport_mapping.first_mport;
         unsigned int np = domctl->u.ioport_mapping.nr_ports;
         unsigned int add = domctl->u.ioport_mapping.add_mapping;
+        struct hvm_domain *hvm_domain;
         struct g2m_ioport *g2m_ioport;
         int found = 0;
 
@@ -747,14 +747,14 @@ long arch_do_domctl(
         if ( ret )
             break;
 
-        hd = dom_iommu(d);
+        hvm_domain = &d->arch.hvm_domain;
         if ( add )
         {
             printk(XENLOG_G_INFO
                    "ioport_map:add: dom%d gport=%x mport=%x nr=%x\n",
                    d->domain_id, fgp, fmp, np);
 
-            list_for_each_entry(g2m_ioport, &hd->arch.g2m_ioport_list, list)
+            list_for_each_entry(g2m_ioport, &hvm_domain->g2m_ioport_list, list)
                 if (g2m_ioport->mport == fmp )
                 {
                     g2m_ioport->gport = fgp;
@@ -773,7 +773,7 @@ long arch_do_domctl(
                 g2m_ioport->gport = fgp;
                 g2m_ioport->mport = fmp;
                 g2m_ioport->np = np;
-                list_add_tail(&g2m_ioport->list, &hd->arch.g2m_ioport_list);
+                list_add_tail(&g2m_ioport->list, &hvm_domain->g2m_ioport_list);
             }
             if ( !ret )
                 ret = ioports_permit_access(d, fmp, fmp + np - 1);
@@ -788,7 +788,7 @@ long arch_do_domctl(
             printk(XENLOG_G_INFO
                    "ioport_map:remove: dom%d gport=%x mport=%x nr=%x\n",
                    d->domain_id, fgp, fmp, np);
-            list_for_each_entry(g2m_ioport, &hd->arch.g2m_ioport_list, list)
+            list_for_each_entry(g2m_ioport, &hvm_domain->g2m_ioport_list, list)
                 if ( g2m_ioport->mport == fmp )
                 {
                     list_del(&g2m_ioport->list);
xen/arch/x86/hvm/hvm.c +12 -0
index 3a2d001..b6c5c9b 100644
@@ -608,6 +608,7 @@ int hvm_domain_initialise(struct domain *d)
     spin_lock_init(&d->arch.hvm_domain.uc_lock);
     spin_lock_init(&d->arch.hvm_domain.write_map.lock);
     INIT_LIST_HEAD(&d->arch.hvm_domain.write_map.list);
+    INIT_LIST_HEAD(&d->arch.hvm_domain.g2m_ioport_list);
 
     hvm_init_cacheattr_region_list(d);
 
@@ -707,6 +708,9 @@ void hvm_domain_relinquish_resources(struct domain *d)
 
 void hvm_domain_destroy(struct domain *d)
 {
+    struct list_head *ioport_list, *tmp;
+    struct g2m_ioport *ioport;
+
     xfree(d->arch.hvm_domain.io_handler);
     d->arch.hvm_domain.io_handler = NULL;
 
@@ -722,6 +726,14 @@ void hvm_domain_destroy(struct domain *d)
 
     xfree(d->arch.hvm_domain.pl_time);
     d->arch.hvm_domain.pl_time = NULL;
+
+    list_for_each_safe ( ioport_list, tmp,
+                         &d->arch.hvm_domain.g2m_ioport_list )
+    {
+        ioport = list_entry(ioport_list, struct g2m_ioport, list);
+        list_del(&ioport->list);
+        xfree(ioport);
+    }
 }
 
 static int hvm_save_tsc_adjust(struct domain *d, hvm_domain_context_t *h)
xen/arch/x86/hvm/io.c +2 -2
index 3b3a600..9e00409 100644
@@ -171,12 +171,12 @@ static bool_t g2m_portio_accept(const struct hvm_io_handler *handler,
                                 const ioreq_t *p)
 {
     struct vcpu *curr = current;
-    const struct domain_iommu *dio = dom_iommu(curr->domain);
+    const struct hvm_domain *hvm_domain = &curr->domain->arch.hvm_domain;
     struct hvm_vcpu_io *vio = &curr->arch.hvm_vcpu.hvm_io;
     struct g2m_ioport *g2m_ioport;
     unsigned int start, end;
 
-    list_for_each_entry( g2m_ioport, &dio->arch.g2m_ioport_list, list )
+    list_for_each_entry( g2m_ioport, &hvm_domain->g2m_ioport_list, list )
     {
         start = g2m_ioport->gport;
         end = start + g2m_ioport->np;
xen/drivers/passthrough/x86/iommu.c +0 -11
index 750c663..0253823 100644
@@ -123,7 +123,6 @@ int arch_iommu_domain_init(struct domain *d)
     struct domain_iommu *hd = dom_iommu(d);
 
     spin_lock_init(&hd->arch.mapping_lock);
-    INIT_LIST_HEAD(&hd->arch.g2m_ioport_list);
     INIT_LIST_HEAD(&hd->arch.mapped_rmrrs);
 
     return 0;
@@ -131,16 +130,6 @@ int arch_iommu_domain_init(struct domain *d)
 
 void arch_iommu_domain_destroy(struct domain *d)
 {
-    const struct domain_iommu *hd = dom_iommu(d);
-    struct list_head *ioport_list, *tmp;
-    struct g2m_ioport *ioport;
-
-    list_for_each_safe ( ioport_list, tmp, &hd->arch.g2m_ioport_list )
-    {
-        ioport = list_entry(ioport_list, struct g2m_ioport, list);
-        list_del(&ioport->list);
-        xfree(ioport);
-    }
 }
 
 /*
xen/include/asm-x86/hvm/domain.h +3 -0
index 420cbdc..bdfc082 100644
@@ -180,6 +180,9 @@ struct hvm_domain {
 
     unsigned long *io_bitmap;
 
+    /* List of guest to machine IO ports mapping. */
+    struct list_head g2m_ioport_list;
+
     /* List of permanently write-mapped pages. */
     struct {
         spinlock_t lock;
xen/include/asm-x86/iommu.h +0 -1
index be95106..0008505 100644
@@ -34,7 +34,6 @@ struct arch_iommu
     u64 pgd_maddr;                 /* io page directory machine address */
     spinlock_t mapping_lock;            /* io page table lock */
     int agaw;     /* adjusted guest address width, 0 is level 2 30-bit */
-    struct list_head g2m_ioport_list;   /* guest to machine ioport mapping */
     u64 iommu_bitmap;              /* bitmap of iommu(s) that the domain uses */
     struct list_head mapped_rmrrs;
 
Signature · 7 lines
2.10.1 (Apple Git-78)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 10 lines

-----Original Message-----
From: Roger Pau Monne
Sent: 28 March 2017 14:12
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 7 lines

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the presence of an IOMMU.

Move it inside of the hvm_domain struct instead.

Quoted 185 lines

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/domctl.c               | 10 +++++-----
 xen/arch/x86/hvm/hvm.c              | 12 ++++++++++++
 xen/arch/x86/hvm/io.c               |  4 ++--
 xen/drivers/passthrough/x86/iommu.c | 11 -----------
 xen/include/asm-x86/hvm/domain.h    |  3 +++
 xen/include/asm-x86/iommu.h         |  1 -
 6 files changed, 22 insertions(+), 19 deletions(-)
xen/arch/x86/domctl.c +3 -3
index 1220224..b7b8748 100644
@@ -721,11 +721,11 @@ long arch_do_domctl(
 
     case XEN_DOMCTL_ioport_mapping:
     {
-        struct domain_iommu *hd;
         unsigned int fgp = domctl->u.ioport_mapping.first_gport;
         unsigned int fmp = domctl->u.ioport_mapping.first_mport;
         unsigned int np = domctl->u.ioport_mapping.nr_ports;
         unsigned int add = domctl->u.ioport_mapping.add_mapping;
+        struct hvm_domain *hvm_domain;
         struct g2m_ioport *g2m_ioport;
         int found = 0;
 
@@ -747,14 +747,14 @@ long arch_do_domctl(
         if ( ret )
             break;
 
-        hd = dom_iommu(d);
+        hvm_domain = &d->arch.hvm_domain;
         if ( add )
         {
             printk(XENLOG_G_INFO
                    "ioport_map:add: dom%d gport=%x mport=%x nr=%x\n",
                    d->domain_id, fgp, fmp, np);
 
-            list_for_each_entry(g2m_ioport, &hd->arch.g2m_ioport_list, list)
+            list_for_each_entry(g2m_ioport, &hvm_domain->g2m_ioport_list,
 list)
                 if (g2m_ioport->mport == fmp )
                 {
                     g2m_ioport->gport = fgp;
xen/arch/x86/domctl.c +2 -2
@@ -773,7 +773,7 @@ long arch_do_domctl(
                 g2m_ioport->gport = fgp;
                 g2m_ioport->mport = fmp;
                 g2m_ioport->np = np;
-                list_add_tail(&g2m_ioport->list, &hd->arch.g2m_ioport_list);
+                list_add_tail(&g2m_ioport->list, &hvm_domain->g2m_ioport_list);
             }
             if ( !ret )
                 ret = ioports_permit_access(d, fmp, fmp + np - 1);
@@ -788,7 +788,7 @@ long arch_do_domctl(
             printk(XENLOG_G_INFO
                    "ioport_map:remove: dom%d gport=%x mport=%x nr=%x\n",
                    d->domain_id, fgp, fmp, np);
-            list_for_each_entry(g2m_ioport, &hd->arch.g2m_ioport_list, list)
+            list_for_each_entry(g2m_ioport, &hvm_domain->g2m_ioport_list,
 list)
                 if ( g2m_ioport->mport == fmp )
                 {
                     list_del(&g2m_ioport->list);
xen/arch/x86/hvm/hvm.c +12 -0
index 3a2d001..b6c5c9b 100644
@@ -608,6 +608,7 @@ int hvm_domain_initialise(struct domain *d)
     spin_lock_init(&d->arch.hvm_domain.uc_lock);
     spin_lock_init(&d->arch.hvm_domain.write_map.lock);
     INIT_LIST_HEAD(&d->arch.hvm_domain.write_map.list);
+    INIT_LIST_HEAD(&d->arch.hvm_domain.g2m_ioport_list);
 
     hvm_init_cacheattr_region_list(d);
 
@@ -707,6 +708,9 @@ void hvm_domain_relinquish_resources(struct
 domain *d)
 
 void hvm_domain_destroy(struct domain *d)
 {
+    struct list_head *ioport_list, *tmp;
+    struct g2m_ioport *ioport;
+
     xfree(d->arch.hvm_domain.io_handler);
     d->arch.hvm_domain.io_handler = NULL;
@@ -722,6 +726,14 @@ void hvm_domain_destroy(struct domain *d)
 
     xfree(d->arch.hvm_domain.pl_time);
     d->arch.hvm_domain.pl_time = NULL;
+
+    list_for_each_safe ( ioport_list, tmp,
+                         &d->arch.hvm_domain.g2m_ioport_list )
+    {
+        ioport = list_entry(ioport_list, struct g2m_ioport, list);
+        list_del(&ioport->list);
+        xfree(ioport);
+    }
 }
 
 static int hvm_save_tsc_adjust(struct domain *d, hvm_domain_context_t

*h)

xen/arch/x86/hvm/io.c +2 -2
index 3b3a600..9e00409 100644
@@ -171,12 +171,12 @@ static bool_t g2m_portio_accept(const struct
 hvm_io_handler *handler,
                                 const ioreq_t *p)
 {
     struct vcpu *curr = current;
-    const struct domain_iommu *dio = dom_iommu(curr->domain);
+    const struct hvm_domain *hvm_domain = &curr->domain-
 >arch.hvm_domain;
     struct hvm_vcpu_io *vio = &curr->arch.hvm_vcpu.hvm_io;
     struct g2m_ioport *g2m_ioport;
     unsigned int start, end;
 
-    list_for_each_entry( g2m_ioport, &dio->arch.g2m_ioport_list, list )
+    list_for_each_entry( g2m_ioport, &hvm_domain->g2m_ioport_list, list )
     {
         start = g2m_ioport->gport;
         end = start + g2m_ioport->np;
xen/drivers/passthrough/x86/iommu.c +0 -11
index 750c663..0253823 100644
@@ -123,7 +123,6 @@ int arch_iommu_domain_init(struct domain *d)
     struct domain_iommu *hd = dom_iommu(d);
 
     spin_lock_init(&hd->arch.mapping_lock);
-    INIT_LIST_HEAD(&hd->arch.g2m_ioport_list);
     INIT_LIST_HEAD(&hd->arch.mapped_rmrrs);
 
     return 0;
@@ -131,16 +130,6 @@ int arch_iommu_domain_init(struct domain *d)
 
 void arch_iommu_domain_destroy(struct domain *d)
 {
-    const struct domain_iommu *hd = dom_iommu(d);
-    struct list_head *ioport_list, *tmp;
-    struct g2m_ioport *ioport;
-
-    list_for_each_safe ( ioport_list, tmp, &hd->arch.g2m_ioport_list )
-    {
-        ioport = list_entry(ioport_list, struct g2m_ioport, list);
-        list_del(&ioport->list);
-        xfree(ioport);
-    }
 }
 
 /*
xen/include/asm- renamed from xen/include/asm-x86/hvm/domain.h +0 -0

x86/hvm/domain.h
index 420cbdc..bdfc082 100644

xen/include/asm-x86/hvm/domain.h +3 -0
@@ -180,6 +180,9 @@ struct hvm_domain {
 
     unsigned long *io_bitmap;
 
+    /* List of guest to machine IO ports mapping. */
+    struct list_head g2m_ioport_list;
+
     /* List of permanently write-mapped pages. */
     struct {
         spinlock_t lock;
xen/include/asm-x86/iommu.h +0 -2
index be95106..0008505 100644
@@ -34,7 +34,6 @@ struct arch_iommu
     u64 pgd_maddr;                 /* io page directory machine address */
     spinlock_t mapping_lock;            /* io page table lock */
     int agaw;     /* adjusted guest address width, 0 is level 2 30-bit */
-    struct list_head g2m_ioport_list;   /* guest to machine ioport mapping */
     u64 iommu_bitmap;              /* bitmap of iommu(s) that the domain uses */
     struct list_head mapped_rmrrs;
 
--
Quoted 1 line

2.10.1 (Apple Git-78)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

In reply to Roger Pau Monne
Quoted 7 lines · Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the presence of an IOMMU.

Move it inside of the hvm_domain struct instead.

Actually, on second thoughts, I rescind my R-by.

This breaks PV guests, which must not use state in the hvm half of the union.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the presence of an IOMMU.

Quoted 8 lines
Quoted 3 lines

Move it inside of the hvm_domain struct instead.

Actually, on second thoughts, I rescind my R-by.

This breaks PV guests, which must not use state in the hvm half of the union.

I'm extremely confused now, AFAICT the g2m_ioport_list list is only used by the g2m_portio_* handlers, and those handlers already make use of HVM only fields (ie: hvm_vcpu_io).

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 10 lines · Roger Pau Monne
Quoted 9 lines · Andrew Cooper
Quoted 7 lines · Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the presence of an IOMMU.

Move it inside of the hvm_domain struct instead.

Quoted 8 lines
Quoted 4 lines

Actually, on second thoughts, I rescind my R-by.

This breaks PV guests, which must not use state in the hvm half of the union.

I'm extremely confused now, AFAICT the g2m_ioport_list list is only used by the g2m_portio_* handlers, and those handlers already make use of HVM only fields (ie: hvm_vcpu_io).

Can this be committed? I understand there's a previous regression here, but this patches don't make it any worse AFAICT, and they clarify the nomenclature.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 04.04.17 at 13:06, <[email protected]> wrote:
Quoted 12 lines · Roger Pau Monne
Quoted 11 lines · Andrew Cooper
Quoted 7 lines · Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the presence of an IOMMU.

Move it inside of the hvm_domain struct instead.

Actually, on second thoughts, I rescind my R-by.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

This breaks PV guests, which must not use state in the hvm half of the union.

I'm extremely confused now, AFAICT the g2m_ioport_list list is only used by the g2m_portio_* handlers, and those handlers already make use of HVM only fields (ie: hvm_vcpu_io).

Can this be committed?

As said on irc, I think was posted after the last posting date, so you'd need to obtain an ack from Julien.

Quoted 3 lines

I understand there's a previous regression here, but this patches don't make it any worse AFAICT, and they clarify the nomenclature.

I don't see the "previous regression": The handlers can be invoked only for HVM guests. What is not HVM-specific is the domctl, and there is where you introduce a regression.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 22 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 04.04.17 at 13:06, <[email protected]> wrote:
Quoted 9 lines · Roger Pau Monne
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the presence of an IOMMU.

Move it inside of the hvm_domain struct instead.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Actually, on second thoughts, I rescind my R-by.

This breaks PV guests, which must not use state in the hvm half of the union.

I'm extremely confused now, AFAICT the g2m_ioport_list list is only used by the g2m_portio_* handlers, and those handlers already make use of HVM only fields (ie: hvm_vcpu_io).

Can this be committed?

As said on irc, I think was posted after the last posting date, so you'd need to obtain an ack from Julien.

Quoted 6 lines
Quoted 3 lines

I understand there's a previous regression here, but this patches don't make it any worse AFAICT, and they clarify the nomenclature.

I don't see the "previous regression": The handlers can be invoked only for HVM guests. What is not HVM-specific is the domctl, and there is where you introduce a regression.

It is certainly the case that in the past, you could use this domctl to pass ISA ports through to PV guests, and that definitely regressed as some point in the past. ISTR Ian (cc'd) fielded a question to this effect from Debian.

This change definitely puts an HVM-only restriction in place, which is wrong IMO.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 04.04.17 at 15:23, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 04.04.17 at 13:06, <[email protected]> wrote:
Quoted 4 lines · Roger Pau Monne
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the

presence

Quoted 19 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

of an IOMMU.

Move it inside of the hvm_domain struct instead.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Actually, on second thoughts, I rescind my R-by.

This breaks PV guests, which must not use state in the hvm half of the union.

I'm extremely confused now, AFAICT the g2m_ioport_list list is only used by the g2m_portio_* handlers, and those handlers already make use of HVM only fields (ie: hvm_vcpu_io).

Can this be committed?

As said on irc, I think was posted after the last posting date, so you'd need to obtain an ack from Julien.

Quoted 3 lines

I understand there's a previous regression here, but this patches don't make it any worse AFAICT, and they clarify the nomenclature.

Quoted 8 lines
Quoted 3 lines

I don't see the "previous regression": The handlers can be invoked only for HVM guests. What is not HVM-specific is the domctl, and there is where you introduce a regression.

It is certainly the case that in the past, you could use this domctl to pass ISA ports through to PV guests, and that definitely regressed as some point in the past. ISTR Ian (cc'd) fielded a question to this effect from Debian.

How would that have worked? Making ports (in)accessible is done via XEN_DOMCTL_ioport_permission. Going back to 3.2.3 I actually find that what is now named dom_iommu() was domain_hvm_iommu() back then, and it wasn't entirely mis-named (i.e. the field was in arch.hvm_domain). So I think all that's needed is adding an is_hvm_domain() to the domctl handling.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw

Re: [PATCH v2 2/2] x86/io: move the list of guest to machine IO ports out of domain_iommu

Quoted 37 lines · Jan Beulich
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 04.04.17 at 15:23, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 04.04.17 at 13:06, <[email protected]> wrote:
Quoted 4 lines · Roger Pau Monne
Quoted 3 lines · Andrew Cooper
Quoted 2 lines · Roger Pau Monne

There's no reason to store that list inside of the domain_iommu struct, the forwarding of guest IO ports into machine IO ports is not tied to the

presence

Quoted 19 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

of an IOMMU.

Move it inside of the hvm_domain struct instead.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Actually, on second thoughts, I rescind my R-by.

This breaks PV guests, which must not use state in the hvm half of the union.

I'm extremely confused now, AFAICT the g2m_ioport_list list is only used by the g2m_portio_* handlers, and those handlers already make use of HVM only fields (ie: hvm_vcpu_io).

Can this be committed?

As said on irc, I think was posted after the last posting date, so you'd need to obtain an ack from Julien.

Quoted 3 lines

I understand there's a previous regression here, but this patches don't make it any worse AFAICT, and they clarify the nomenclature.

Quoted 8 lines
Quoted 3 lines

I don't see the "previous regression": The handlers can be invoked only for HVM guests. What is not HVM-specific is the domctl, and there is where you introduce a regression.

It is certainly the case that in the past, you could use this domctl to pass ISA ports through to PV guests, and that definitely regressed as some point in the past. ISTR Ian (cc'd) fielded a question to this effect from Debian.

Quoted 6 lines

How would that have worked? Making ports (in)accessible is done via XEN_DOMCTL_ioport_permission. Going back to 3.2.3 I actually find that what is now named dom_iommu() was domain_hvm_iommu() back then, and it wasn't entirely mis-named (i.e. the field was in arch.hvm_domain). So I think all that's needed is adding an is_hvm_domain() to the domctl handling.

I can either do that, or move the list to arch_domain instead of hvm_domain. Either way it's not going to make it work for PV guests, but it's going to prevent PV guests from writing to hvm_domain.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw
In reply to Roger Pau Monne
Quoted 7 lines · Roger Pau Monne

Hello,

The following series contain two cosmetic fixes for the g2m IO port handlers. The first one renames them to use the g2m_ prefix instead of the dpci_ one, since those handlers are not trapping the PCI config space in any way. The second fix moves the list of ports from the domain_iommu struct to the hvm_struct, where it fits more naturally.

Both Reviewed-by: Andrew Cooper <[email protected]>, although it would be good to take the opportunity to s/bool_t/bool/ while committing.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw
Quoted 11 lines · Andrew Cooper
Quoted 7 lines · Roger Pau Monne

Hello,

The following series contain two cosmetic fixes for the g2m IO port handlers. The first one renames them to use the g2m_ prefix instead of the dpci_ one, since those handlers are not trapping the PCI config space in any way. The second fix moves the list of ports from the domain_iommu struct to the hvm_struct, where it fits more naturally.

Both Reviewed-by: Andrew Cooper <[email protected]>, although it would be good to take the opportunity to s/bool_t/bool/ while committing.

The accept handler (hvm_io_accept_t) expects a bool_t as return type. This can be fixed also, but seems out of the scope of this patch.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel