Fix xen crash when starting HVM guest due to missing io handler
v4 cover Fix xen crash when starting HVM guest due to missing io handler
From: Suravee Suthikulpanit <[email protected]>
Hi All,
Changes from V3:
* Remove calls to guest_iommu_init()/destroy() for now since the guest iommu feature is not functing and causing breakage.
* Do not change the ordering of the iommu_domain_init() and hvm_domain_init() for now until we agree on proper ordering.
OVERVIEW:
On systems with iommu v2 enabled, the hypervisor crashes when trying to start up an HVM guest.
Investigating shows that the guest_iommu_init() is called before the HVM domain is initialized. It then tries to register_mmio_handler() causing the hvm_next_io_handler() to increment the io_handler_count. However, the registration fails silently and left the I/O handler uninitialized.
At later time, hvm_find_io_handler() is called and iterate through the registered handlered, but then resulting in referencing NULL pointers.
This patch series proposes workaround for this issue.
Thanks,
Suravee
Suravee Suthikulpanit (2):
AMD IOMMU: Removing currently non-functioning guest iommu feature x86/hvm: Add check when register io handler
xen/arch/x86/hvm/intercept.c | 2 ++ xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-)
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v4 1/2 AMD IOMMU: Removing currently non-functioning guest iommu feature
From: Suravee Suthikulpanit <[email protected]>
The guest IOMMU feature is currently not functioning. However, the current guest_iommu_init() is causing issue when it tries to register mmio handler because the it is currently called by the following code path:
arch/x86/domain.c: arch_domain_create()
]- drivers/passthrough/iommu.c: iommu_domain_init()
|- drivers/passthrough/amd/pci_amd_iommu.c: amd_iommu_domain_init();
|- drivers/passthrough/amd/iommu_guest.c: guest_iommu_init()At this point, the hvm_domain_initialised() has not been called. So register_mmio_handler() in guest_iommu_init() silently fails.
This patch removes the guest IOMMU feature for now until we can properly support it.
--- xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 ---- 1 file changed, 4 deletions(-)
xen/drivers/passthrough/amd/pci_amd_iommu.c +0 -4
@@ -272,9 +272,6 @@ static int amd_iommu_domain_init(struct domain *d) hd->arch.paging_mode =is_hvm_domain (d) ?IOMMU_PAGING_MODE_LEVEL_2 :get_paging_mode (max_page); - -guest_iommu_init (d); -return 0 ; }
@@ -474,7 +471,6 @@ static void deallocate_iommu_page_tables(struct domain *d)static void amd_iommu_domain_destroy (struct domain *d) { -guest_iommu_destroy (d);deallocate_iommu_page_tables (d);amd_iommu_flush_all_pages (d); }
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v4 1/2] AMD IOMMU: Removing currently non-functioning guest iommu feature
Quoted 23 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: 01 June 2016 20:53
To: [email protected]; Paul Durrant; [email protected]; George Dunlap
Cc: Keir (Xen.org); Suravee Suthikulpanit; Suravee Suthikulpanit
Subject: [PATCH v4 1/2] AMD IOMMU: Removing currently non-functioning guest iommu featureFrom: Suravee Suthikulpanit <[email protected]>
The guest IOMMU feature is currently not functioning. However, the current
guest_iommu_init()is causing issue when it tries to register mmio handler because the it is currently called by the following code path:
arch/x86/domain.c:arch_domain_create()
]-drivers/passthrough/iommu.c:iommu_domain_init()
|-drivers/passthrough/amd/pci_amd_iommu.c:amd_iommu_domain_init();
|-drivers/passthrough/amd/iommu_guest.c:guest_iommu_init()
Quoted 7 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails.This patch removes the guest IOMMU feature for now until we can properly support it.
Signed-off-by Suravee Suthikulpanit <[email protected]>
Quoted 27 lines
--- xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 ---- 1 file changed, 4 deletions(-)xen/drivers/passthrough/amd/pci_amd_iommu.c +0
-4@@ -272,9 +272,6 @@ static int amd_iommu_domain_init(struct domain *d) hd->arch.paging_mode =is_hvm_domain (d) ?IOMMU_PAGING_MODE_LEVEL_2 :get_paging_mode (max_page); - -guest_iommu_init (d); -return 0 ; }@@ -474,7 +471,6 @@ static void deallocate_iommu_page_tables(struct domain *d)static void amd_iommu_domain_destroy (struct domain *d) { -guest_iommu_destroy (d);deallocate_iommu_page_tables (d);amd_iommu_flush_all_pages (d);
Quoted 3 lines
}
--
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 1/2] AMD IOMMU: Removing currently non-functioning guest iommu feature
In reply to [email protected]Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 01.06.16 at 21:52, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The guest IOMMU feature is currently not functioning. However, the current
guest_iommu_init()is causing issue when it tries to register mmio handler because the it is currently called by the following code path:arch/x86/domain.c: arch_domain_create() ]- drivers/passthrough/iommu.c: iommu_domain_init() |- drivers/passthrough/amd/pci_amd_iommu.c: amd_iommu_domain_init(); |- drivers/passthrough/amd/iommu_guest.c: guest_iommu_init()
Quoted 7 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails.This patch removes the guest IOMMU feature for now until we can properly support it.
Signed-off-by Suravee Suthikulpanit <[email protected]>
Thanks, quite reasonable. And imo actually a 4.7 candidate. Wei?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 1/2] AMD IOMMU: Removing currently non-functioning guest iommu feature
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 01.06.16 at 21:52, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The guest IOMMU feature is currently not functioning. However, the current
guest_iommu_init()is causing issue when it tries to register mmio handler because the it is currently called by the following code path:arch/x86/domain.c: arch_domain_create() ]- drivers/passthrough/iommu.c: iommu_domain_init() |- drivers/passthrough/amd/pci_amd_iommu.c: amd_iommu_domain_init(); |- drivers/passthrough/amd/iommu_guest.c: guest_iommu_init()At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails.
Quoted 7 lines
Quoted 4 lines
This patch removes the guest IOMMU feature for now until we can properly support it.
Signed-off-by Suravee Suthikulpanit <[email protected]>Thanks, quite reasonable. And imo actually a 4.7 candidate. Wei?
Please apply this series within this week.
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 1/2] AMD IOMMU: Removing currently non-functioning guest iommu feature
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 02.06.16 at 12:26, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 01.06.16 at 21:52, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The guest IOMMU feature is currently not functioning. However, the current
guest_iommu_init()is causing issue when it tries to register mmio handler because the it is currently called by the following code path:arch/x86/domain.c: arch_domain_create() ]- drivers/passthrough/iommu.c: iommu_domain_init() |- drivers/passthrough/amd/pci_amd_iommu.c: amd_iommu_domain_init(); |- drivers/passthrough/amd/iommu_guest.c: guest_iommu_init()At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails.This patch removes the guest IOMMU feature for now until we can properly support it.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Suravee Suthikulpanit <[email protected]>Thanks, quite reasonable. And imo actually a 4.7 candidate. Wei?
Release-acked-by Wei Liu <[email protected]>Please apply this series within this week.
Series? Also the other one, which is pretty benign imo?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 1/2] AMD IOMMU: Removing currently non-functioning guest iommu feature
Quoted 23 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 02.06.16 at 12:26, <[email protected]> wrote:
Quoted 21 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 01.06.16 at 21:52, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The guest IOMMU feature is currently not functioning. However, the current
guest_iommu_init()is causing issue when it tries to register mmio handler because the it is currently called by the following code path:arch/x86/domain.c: arch_domain_create() ]- drivers/passthrough/iommu.c: iommu_domain_init() |- drivers/passthrough/amd/pci_amd_iommu.c: amd_iommu_domain_init(); |- drivers/passthrough/amd/iommu_guest.c: guest_iommu_init()At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails.This patch removes the guest IOMMU feature for now until we can properly support it.
Signed-off-by Suravee Suthikulpanit <[email protected]>
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Thanks, quite reasonable. And imo actually a 4.7 candidate. Wei?
Release-acked-by Wei Liu <[email protected]>Please apply this series within this week.
Series? Also the other one, which is pretty benign imo?
Yes, the other one as well. I thought it you wanted this whole series in.
But if you only want this one in, that's of course fine by me.
Wei.
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 2/2 x86/hvm: Add check when register io handler
In reply to [email protected]From: Suravee Suthikulpanit <[email protected]>
At the time of registering HVM I/O handler, the HVM domain might not have been initialized, which means the hvm_domain.io_handler would be NULL. In the hvm_next_io_handler(), this should be asserted.
--- xen/arch/x86/hvm/intercept.c | 2 ++ 1 file changed, 2 insertions(+)
xen/arch/x86/hvm/intercept.c +2 -0
@@ -258,6 +258,8 @@ struct hvm_io_handler *hvm_next_io_handler(struct domain *d) {unsigned int i = d->arch.hvm_domain.io_handler_count++; +ASSERT (d->arch.hvm_domain.io_handler); +if ( i ==NR_IO_HANDLERS ) {domain_crash (d);
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel