Fix xen crash when starting HVM guest due to missing io handler
v3 cover Fix xen crash when starting HVM guest due to missing io handler
From: Suravee Suthikulpanit <[email protected]>
Hi All,
Changes from V2:
* Use assert instead of sanity check before count increment in the hvm_next_io_handler().
* Post-pone iommu_domain_init() and add proper error handling code to destroy hvm in case of failure.
* Split out sanity check in guest_iommu_init() into a separate patch.
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 fix for this issue.
Thanks,
Suravee
Suravee Suthikulpanit (3):
x86/hvm: Add check when register io handler
svm: iommu: Only call guest_iommu_init() after initialized HVM domain AMD IOMMU: Check io_handler before registering mmio handler
xen/arch/x86/domain.c | 9 ++++++--- xen/arch/x86/hvm/intercept.c | 2 ++ xen/drivers/passthrough/amd/iommu_guest.c | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 1/3 x86/hvm: Add check when register io handler
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
Re: [PATCH v3 1/3] x86/hvm: Add check when register io handler
Quoted 25 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: 22 May 2016 00:42
To: [email protected]; Paul Durrant; [email protected]; George Dunlap
Cc: Keir (Xen.org); Suravee Suthikulpanit; Suravee Suthikulpanit
Subject: [PATCH v3 1/3] x86/hvm: Add check when register io handlerFrom: 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.Signed-off-by Suravee Suthikulpanit <[email protected]>--- xen/arch/x86/hvm/intercept.c | 2 ++ 1 file changed, 2 insertions(+)xen/arch/x86/hvm/intercept.c +0
-0
xen/arch/x86/hvm/intercept.c struct hvm_io_handler *hvm_next_io_handler(struct · line 262
Quoted 5 lines
xen/arch/x86/hvm/intercept.c +1
-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 );
Needs fixing for style, but with that...
Quoted 6 lines
xen/arch/x86/hvm/intercept.c +1
-0+if ( i ==NR_IO_HANDLERS ) {domain_crash(d);--
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 1/3] x86/hvm: Add check when register io handler
In reply to [email protected]xen/arch/x86/hvm/intercept.c struct hvm_io_handler *hvm_next_io_handler(struct domain *d) · line 261
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 22.05.16 at 01:42, <[email protected]> wrote:
xen/arch/x86/hvm/intercept.c +1
-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 );
Am I wrong in understanding that without patch 2 this ASSERT() will actually trigger? In which case the patch order would be wrong (but that could be taken care of during commit).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 1/3] x86/hvm: Add check when register io handler
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 22.05.16 at 01:42, <[email protected]> wrote:
xen/arch/x86/hvm/intercept.c +0
-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++;
Quoted 8 lines
xen/arch/x86/hvm/intercept.c struct hvm_io_handler *hvm_next_io_handler(struct domain *d) · line 261
Quoted 1 line
xen/arch/x86/hvm/intercept.c +1
-0+ASSERT ( d->arch.hvm_domain.io_handler );Am I wrong in understanding that without patch 2 this
ASSERT()will actually trigger? In which case the patch order would be wrong (but that could be taken care of during commit).Jan
Right, I can fix this in V4 if we decide to change the iommu_domain_initialise() ordering.
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 2/3 svm: iommu: Only call guest_iommu_init() after initialized HVM domain
In reply to [email protected]From: Suravee Suthikulpanit <[email protected]>
The guest_iommu_init() 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 moves the iommu_domain_init() to a later point after the hvm_domain_intialise() instead.
--- xen/arch/x86/domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
xen/arch/x86/domain.c +6 -3
@@ -642,9 +642,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,if ( (rc =init_domain_irq_mapping (d)) !=0 ) goto fail; - -if ( (rc =iommu_domain_init (d)) !=0 ) - goto fail; }spin_lock_init (&d->arch.e820_lock);
@@ -660,6 +657,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,/* 64-bit PV guest by default. */ d->arch.is_32bit_pv = d->arch.has_32bit_shinfo =0 ; +if ( !is_idle_domain (d) && (rc =iommu_domain_init (d)) !=0 ) + goto fail_1; +/* initialize default tsc behavior in case tools don't */ tsc_set_info (d,TSC_MODE_DEFAULT ,0UL ,0 ,0 );spin_lock_init (&d->arch.vtsc_lock);
@@ -675,6 +675,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,return 0 ; + fail_1: +if (has_hvm_container_domain (d) ) +hvm_domain_destroy (d); fail: d->is_dying = DOMDYING_dead;psr_domain_free (d);
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v3 2/3] svm: iommu: Only call guest_iommu_init() after initialized HVM domain
Quoted 20 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: 22 May 2016 00:43
To: [email protected]; Paul Durrant; [email protected]; George Dunlap
Cc: Keir (Xen.org); Suravee Suthikulpanit
Subject: [PATCH v3 2/3] svm: iommu: Only callguest_iommu_init()after initialized HVM domainFrom: Suravee Suthikulpanit <[email protected]>
The
guest_iommu_init()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 6 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails. This patch moves theiommu_domain_init()to a later point after thehvm_domain_intialise()instead.Signed-off-by Suravee Suthikulpanit <[email protected]>
Quoted 41 lines
--- xen/arch/x86/domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)xen/arch/x86/domain.c +3
-3@@ -642,9 +642,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, if ( (rc = init_domain_irq_mapping(d)) != 0 ) goto fail; - -if ( (rc =iommu_domain_init (d)) !=0 ) - goto fail; }spin_lock_init (&d->arch.e820_lock);@@ -660,6 +657,9 @@ int arch_domain_create(struct domain *d, unsignedint domcr_flags,/* 64-bit PV guest by default. */ d->arch.is_32bit_pv = d->arch.has_32bit_shinfo = 0; +if ( !is_idle_domain (d) && (rc =iommu_domain_init (d)) !=0 ) + goto fail_1; +/* initialize default tsc behavior in case tools don't */ tsc_set_info (d,TSC_MODE_DEFAULT ,0UL ,0 ,0 );spin_lock_init(&d->arch.vtsc_lock);xen/arch/x86/domain.c +3
-0@@ -675,6 +675,9 @@ int arch_domain_create(struct domain *d, unsignedint domcr_flags, return 0; + fail_1: +if (has_hvm_container_domain (d) ) +hvm_domain_destroy (d); fail: d->is_dying = DOMDYING_dead;psr_domain_free(d);
Quoted 2 lines
--
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 2/3] svm: iommu: Only call guest_iommu_init() after initialized HVM domain
In reply to [email protected]Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 22.05.16 at 01:42, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The
guest_iommu_init()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 4 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails. This patch moves theiommu_domain_init()to a later point after thehvm_domain_intialise()instead.
That's one possible approach, which I continue to be not really happy with. guest_iommu_init() really is HVM-specific, so maybe no longer calling it from amd_iommu_domain_init() would be the better solution (instead calling it from hvm_domain_initialise() would then seem to be the better option). Thoughts?
In any event is the choice of ...
xen/arch/x86/domain.c int arch_domain_create(struct domain *d, unsigned int domcr_flags, · line 683
Quoted 10 lines
xen/arch/x86/domain.c +3
-0@@ -675,6 +675,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,return 0 ; + fail_1: +if (has_hvm_container_domain (d) ) +hvm_domain_destroy (d); fail: d->is_dying = DOMDYING_dead;psr_domain_free (d);
... the new label name sub-optimal. Please pick something more descriptive, e.g. "iommu_fail", if the current approach is to be retained.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 2/3] svm: iommu: Only call guest_iommu_init() after initialized HVM domain
Quoted 15 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 22.05.16 at 01:42, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The
guest_iommu_init()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 4 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails. This patch moves theiommu_domain_init()to a later point after thehvm_domain_intialise()instead.
Quoted 5 lines
That's one possible approach, which I continue to be not really happy with.
guest_iommu_init()really is HVM-specific, so maybe no longer calling it fromamd_iommu_domain_init()would be the better solution (instead calling it fromhvm_domain_initialise()would then seem to be the better option). Thoughts?
Then, this goes back to the approach I proposed in the v1 of this patch series, where I call guest_iommu_init/destroy() in the svm_domain_initialise/destroy().
However, I'm still not quite clear in why the iommu_domain_init() is needed before hvm_domain_initialise().
Quoted 18 lines
In any event is the choice of ...
xen/arch/x86/domain.c int arch_domain_create(struct domain *d, unsigned int domcr_flags, · line 683
Quoted 10 lines
xen/arch/x86/domain.c +3
-0@@ -675,6 +675,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,return 0 ; + fail_1: +if (has_hvm_container_domain (d) ) +hvm_domain_destroy (d); fail: d->is_dying = DOMDYING_dead;psr_domain_free (d);... the new label name sub-optimal. Please pick something more descriptive, e.g. "
iommu_fail", if the current approach is to be retained.
Quoted 2 lines
Jan
In case we are going with this approach, I will make this change.
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 2/3] svm: iommu: Only call guest_iommu_init() after initialized HVM domain
Quoted 23 lines
Quoted 1 line
Quoted 1 line
Suravee Suthikulanit <[email protected]> 05/25/16 9:01 PM >>>
Quoted 15 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 22.05.16 at 01:42, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The
guest_iommu_init()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 4 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails. This patch moves theiommu_domain_init()to a later point after thehvm_domain_intialise()instead.Quoted 5 lines
That's one possible approach, which I continue to be not really happy with.
guest_iommu_init()really is HVM-specific, so maybe no longer calling it fromamd_iommu_domain_init()would be the better solution (instead calling it fromhvm_domain_initialise()would then seem to be the better option). Thoughts?
Quoted 6 lines
Then, this goes back to the approach I proposed in the v1 of this patch series, where I call guest_iommu_init/destroy() in the svm_domain_initialise/destroy().
However, I'm still not quite clear in why the
iommu_domain_init()is needed beforehvm_domain_initialise().
I think the two things are only lightly related. Changing the order of calls is generally fine, but recognizing that guest_iommu_init() really would better be called elsewhere makes that re-ordering simply unnecessary.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 2/3] svm: iommu: Only call guest_iommu_init() after initialized HVM domain
Quoted 27 lines · Jan Beulich
Quoted 27 lines
Quoted 1 line
Quoted 1 line
Suravee Suthikulanit <[email protected]> 05/25/16 9:01 PM >>>
Quoted 15 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 22.05.16 at 01:42, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The
guest_iommu_init()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 4 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails. This patch moves theiommu_domain_init()to a later point after thehvm_domain_intialise()instead.Quoted 5 lines
That's one possible approach, which I continue to be not really happy with.
guest_iommu_init()really is HVM-specific, so maybe no longer calling it fromamd_iommu_domain_init()would be the better solution (instead calling it fromhvm_domain_initialise()would then seem to be the better option). Thoughts?Then, this goes back to the approach I proposed in the v1 of this patch series, where I call guest_iommu_init/destroy() in the svm_domain_initialise/destroy().
Quoted 8 lines
Quoted 2 lines
However, I'm still not quite clear in why the
iommu_domain_init()is needed beforehvm_domain_initialise().I think the two things are only lightly related. Changing the order of calls is generally fine, but recognizing that
guest_iommu_init()really would better be called elsewhere makes that re-ordering simply unnecessary.Jan
So, let discussing these two things separately. I would propose to:
1. Let's just remove the guest_iommu_init() for now since it's not functioning, and it seems to not being called at a proper place according to Jan. We will revisit this when we re-introduce and fully test out the feature.
2. As for the ordering of the iommu_domain_init() and hvm_domain_init() , let's continue to discuss to find proper ordering if it needs changing.
Let me know what you guys thinks.
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 2/3] svm: iommu: Only call guest_iommu_init() after initialized HVM domain
Quoted 38 lines
Quoted 1 line
Quoted 1 line · On 31.05.16 at 23:11, <[email protected]> wrote:
Quoted 23 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line
Suravee Suthikulanit <[email protected]> 05/25/16 9:01 PM >>>
Quoted 20 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 22.05.16 at 01:42, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The
guest_iommu_init()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 4 lines
At this point, the
hvm_domain_initialised()has not been called. Soregister_mmio_handler()inguest_iommu_init()silently fails. This patch moves theiommu_domain_init()to a later point after thehvm_domain_intialise()instead.That's one possible approach, which I continue to be not really happy with.
guest_iommu_init()really is HVM-specific, so maybe no longer calling it fromamd_iommu_domain_init()would be the better solution (instead calling it fromhvm_domain_initialise()would then seem to be the better option). Thoughts?Quoted 8 lines
Quoted 6 lines
Then, this goes back to the approach I proposed in the v1 of this patch series, where I call guest_iommu_init/destroy() in the svm_domain_initialise/destroy().
However, I'm still not quite clear in why the
iommu_domain_init()is needed beforehvm_domain_initialise().I think the two things are only lightly related. Changing the order of calls
is
Quoted 1 line
generally fine, but recognizing that
guest_iommu_init()really would betterbe
Quoted 2 lines
called elsewhere makes that re-ordering simply unnecessary.
Quoted 8 lines
Quoted 1 line
Jan
So, let discussing these two things separately. I would propose to:
1. Let's just remove the
guest_iommu_init()for now since it's not functioning, and it seems to not being called at a proper place according to Jan. We will revisit this when we re-introduce and fully test out the feature.
Fine with me.
Quoted 2 lines
2. As for the ordering of the
iommu_domain_init()andhvm_domain_init(), let's continue to discuss to find proper ordering if it needs changing.
Sure. The only thing I'd like to avoid is a change for the change's sake.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 3/3 AMD IOMMU: Check io_handler before registering mmio handler
In reply to [email protected]From: Suravee Suthikulpanit <[email protected]>
guest_iommu_init tries to register mmio handler before HVM domain is initialized. This cause registration to silently failing. This patch adds a sanitiy check and puts out error message.
--- xen/drivers/passthrough/amd/iommu_guest.c | 6 ++++++ 1 file changed, 6 insertions(+)
xen/drivers/passthrough/amd/iommu_guest.c +6 -0
@@ -890,6 +890,12 @@ int guest_iommu_init(struct domain* d) !has_viommu(d) )return 0 ; +if ( d->arch.hvm_domain.io_handler ==NULL ) + { +AMD_IOMMU_DEBUG ("Error: uninitalized hvm io handler\n" ); +return 1 ; + } + iommu = xzalloc(struct guest_iommu);if ( !iommu ) {
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v3 3/3] AMD IOMMU: Check io_handler before registering mmio handler
Quoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: 22 May 2016 00:43
To: [email protected]; Paul Durrant; [email protected]; George Dunlap
Cc: Keir (Xen.org); Suravee Suthikulpanit; Suravee Suthikulapanit
Subject: [PATCH v3 3/3] AMD IOMMU: Checkio_handlerbefore registering mmio handler
Quoted 7 lines
From: Suravee Suthikulpanit <[email protected]>
guest_iommu_inittries to register mmio handler before HVM domain is initialized. This cause registration to silently failing. This patch adds a sanitiy check and puts out error message.Signed-off-by Suravee Suthikulapanit <[email protected]>
This patch is now defunct isn't it?
Paul
Quoted 23 lines
--- xen/drivers/passthrough/amd/iommu_guest.c | 6 ++++++ 1 file changed, 6 insertions(+)xen/drivers/passthrough/amd/iommu_guest.c +6
-1@@ -890,6 +890,12 @@ int guest_iommu_init(struct domain* d) !has_viommu(d) )return 0 ; +if ( d->arch.hvm_domain.io_handler ==NULL ) + { +AMD_IOMMU_DEBUG ("Error: uninitalized hvm io handler\n" ); +return 1 ; + } + iommu = xzalloc(struct guest_iommu);if ( !iommu ) { --
Quoted 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 3/3] AMD IOMMU: Check io_handler before registering mmio handler
Quoted 12 lines · Paul Durrant
Quoted 12 lines
-----Original Message-----
Quoted 11 lines
From: [email protected] [mailto:[email protected]]
Sent: 22 May 2016 00:43
To: [email protected]; Paul Durrant; [email protected]; George Dunlap
Cc: Keir (Xen.org); Suravee Suthikulpanit; Suravee Suthikulapanit
Subject: [PATCH v3 3/3] AMD IOMMU: Checkio_handlerbefore registering mmio handlerFrom: Suravee Suthikulpanit <[email protected]>
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
guest_iommu_inittries to register mmio handler before HVM domain is initialized. This cause registration to silently failing. This patch adds a sanitiy check and puts out error message.Signed-off-by Suravee Suthikulapanit <[email protected]>This patch is now defunct isn't it?
Paul
It is no longer required, but I think this is a good sanity check in case something changes in the future and causing this to be called before the HVM I/O handler initialized.
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 3/3] AMD IOMMU: Check io_handler before registering mmio handler
Quoted 29 lines
-----Original Message-----
From: Suravee Suthikulanit [mailto:[email protected]]
Sent: 25 May 2016 19:52
To: Paul Durrant; [email protected]; [email protected]; George Dunlap
Cc: Keir (Xen.org)
Subject: Re: [PATCH v3 3/3] AMD IOMMU: Checkio_handlerbefore registering mmio handlerQuoted 8 lines · Paul Durrant
Quoted 8 lines
-----Original Message-----
Quoted 7 lines
From: [email protected] [mailto:[email protected]]
Sent: 22 May 2016 00:43
To: [email protected]; Paul Durrant; [email protected]; George Dunlap
Cc: Keir (Xen.org); Suravee Suthikulpanit; Suravee Suthikulapanit
Subject: [PATCH v3 3/3] AMD IOMMU: Checkio_handlerbeforeregistering
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
mmio handler
From: Suravee Suthikulpanit <[email protected]>
guest_iommu_inittries to register mmio handler before HVM domain is initialized. This cause registration to silently failing. This patch adds a sanitiy check and puts out error message.Signed-off-by Suravee Suthikulapanit
Quoted 8 lines
Quoted 4 lines
This patch is now defunct isn't it?
Paul
It is no longer required, but I think this is a good sanity check in case something changes in the future and causing this to be called before the HVM I/O handler initialized.
Maybe, but shouldn't it result in a domain_crash()?
Paul
Quoted 3 lines
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 3/3] AMD IOMMU: Check io_handler before registering mmio handler
In reply to Suravee SuthikulanitQuoted 8 lines
Quoted 1 line
Quoted 1 line
Suravee Suthikulanit <[email protected]> 05/25/16 8:52 PM >>>
Quoted 6 lines · Paul Durrant
Quoted 6 lines
From: [email protected]
Sent: 22 May 2016 00:43Quoted 4 lines
guest_iommu_inittries to register mmio handler before HVM domain is initialized. This cause registration to silently failing. This patch adds a sanitiy check and puts out error message.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Suravee Suthikulapanit <[email protected]>This patch is now defunct isn't it?
It is no longer required, but I think this is a good sanity check in case something changes in the future and causing this to be called before the HVM I/O handler initialized.
To be honest, in this case I'm not convinced, no matter that generally appreciate ASSERT()s getting added.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
+ Rüdiger
This patch series should help fixing the issue you are seeing.
Thanks,
Suravee
Quoted 36 lines · On 05/21/2016 06:42 PM, [email protected] wrote:
From: Suravee Suthikulpanit <[email protected]>
Hi All,
Changes from V2:
* Use assert instead of sanity check before count increment in thehvm_next_io_handler().
* Post-poneiommu_domain_init()and add proper error handling code to destroy hvm in case of failure.
* Split out sanity check inguest_iommu_init()into a separate patch.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 toregister_mmio_handler()causing thehvm_next_io_handler()to increment theio_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 fix for this issue.
Thanks,
SuraveeSuravee Suthikulpanit (3):
x86/hvm: Add check when register io handler
svm: iommu: Only callguest_iommu_init()after initialized HVM domain AMD IOMMU: Checkio_handlerbefore registering mmio handler
Quoted 5 lines
xen/arch/x86/domain.c | 9 ++++++--- xen/arch/x86/hvm/intercept.c | 2 ++ xen/drivers/passthrough/amd/iommu_guest.c | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel