x86/vtd: fix IOMMU share PT destruction path
PATCH 1/1 x86/vtd: fix IOMMU share PT destruction path
Commit 2916951c1 ("mm / iommu: include need_iommu() test in iommu_use_hap_pt()") included need_iommu() in iommu_use_hap_pt and 91d4eca7add (" mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync()") made things finer grain by spliting need_iommu into three states.
The destruction path can't use iommu_use_hap_pt because at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.
--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
xen/drivers/passthrough/vtd/iommu.c +7 -1
@@ -1752,7 +1752,13 @@ static void iommu_domain_teardown(struct domain *d)xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (hap_enabled (d)); + +/* +* We can't use iommu_use_hap_pt here because the IOMMU state is already +* changed to IOMMU_STATUS_disabled at this point. +*/ +if ( iommu_hap_pt_share )return ;spin_lock (&hd->arch.mapping_lock);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 15 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 11:42
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.
Quoted 4 lines
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.
This is VT-d specific and the issue could affect AMD too. Can't you just switch round the call to teardown and setting IOMMU_status_disabled in xen/drivers/passthrough/iommu.c:iommu_teardown()?
Paul
Quoted 27 lines
Signed-off-by Wei Liu <[email protected]>--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/drivers/passthrough/vtd/iommu.c +4
-1@@ -1752,7 +1752,13 @@ static void iommu_domain_teardown(struct domain *d)xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (hap_enabled (d)); + +/* +* We can't use iommu_use_hap_pt here because the IOMMU state is already
xen/drivers/passthrough/vtd/iommu.c +3
-1+* changed to IOMMU_STATUS_disabled at this point. +*/ +if ( iommu_hap_pt_share )return ;spin_lock (&hd->arch.mapping_lock); --
Quoted 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 25 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 09 October 2018 12:23
To: Wei Liu <[email protected]>; [email protected]
Cc: Kevin Tian <[email protected]>; Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 15 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 11:42
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.
Quoted 6 lines
Quoted 4 lines
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.This is VT-d specific and the issue could affect AMD too.
Yes, it looks like deallocate_iommu_page_tables() will then try to deallocate page tables that would not have been allocated. This probably happens to be safe because the root table is allocated on demand, but that might change in future so I think it better to fix as I suggest below.
Paul
Quoted 38 lines
Can't you just
switch round the call to teardown and settingIOMMU_status_disabledin xen/drivers/passthrough/iommu.c:iommu_teardown()?Paul
xen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct domain
Quoted 11 lines
Signed-off-by Wei Liu <[email protected]>--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1752,7 +1752,13 @@ static void iommu_domain_teardown(struct domain*d)
Quoted 16 lines
xen/drivers/passthrough/vtd/iommu.c +4
-1xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (hap_enabled (d)); + +/* +* We can't use iommu_use_hap_pt here because the IOMMU state is already
xen/drivers/passthrough/vtd/iommu.c +3
-1+* changed to IOMMU_STATUS_disabled at this point. +*/ +if ( iommu_hap_pt_share )return ;spin_lock (&hd->arch.mapping_lock); --Quoted 1 line
2.11.0
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 15 lines · Paul Durrant
Quoted 15 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 11:42
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.
Quoted 6 lines
Quoted 4 lines
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.This is VT-d specific and the issue could affect AMD too. Can't you just switch round the call to teardown and setting
IOMMU_status_disabledin xen/drivers/passthrough/iommu.c:iommu_teardown()?
AMD doesn't support shared page tables so far, but in order to avoid having to debug this again if AMD ever gains support for shared page tables I think switching the order in iommu_teardown might be better.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 30 lines · Paul Durrant
Quoted 30 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 09 October 2018 12:23
To: Wei Liu <[email protected]>; [email protected]
Cc: Kevin Tian <[email protected]>; Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 19 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 11:42
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.
Quoted 9 lines
Quoted 1 line
This is VT-d specific and the issue could affect AMD too.
Yes, it looks like
deallocate_iommu_page_tables()will then try to deallocate page tables that would not have been allocated. This probably happens to be safe because the root table is allocated on demand, but that might change in future so I think it better to fix as I suggest below.Paul
Quoted 3 lines
Can't you just
switch round the call to teardown and settingIOMMU_status_disabledin xen/drivers/passthrough/iommu.c:iommu_teardown()?
OK. I will swap those lines instead.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 09.10.18 at 14:57, <[email protected]> wrote:
Quoted 20 lines · Paul Durrant
Quoted 19 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 11:42
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.
Quoted 7 lines
Quoted 1 line
This is VT-d specific and the issue could affect AMD too. Can't you just
switch round the call to teardown and setting
IOMMU_status_disabledin xen/drivers/passthrough/iommu.c:iommu_teardown()?AMD doesn't support shared page tables so far, but in order to avoid having to debug this again if AMD ever gains support for shared page tables I think switching the order in
iommu_teardownmight be better.
I think we've pretty much ruled out AMD ever re-gaining such sharing functionality. In fact I thought we had settled that the dead code relating to this functionality could be ripped out, if anyone could carve out the time needed for doing so.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 35 lines · Wei Liu
Quoted 34 lines · Paul Durrant
Quoted 25 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 09 October 2018 12:23
To: Wei Liu <[email protected]>; [email protected]
Cc: Kevin Tian <[email protected]>; Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 15 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 11:42
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.Quoted 6 lines
Quoted 4 lines
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.This is VT-d specific and the issue could affect AMD too.
Yes, it looks like
deallocate_iommu_page_tables()will then try to deallocate page tables that would not have been allocated. This probably happens to be safe because the root table is allocated on demand, but that might change in future so I think it better to fix as I suggest below.
Quoted 7 lines
Quoted 5 lines
Paul
Quoted 3 lines
Can't you just
switch round the call to teardown and settingIOMMU_status_disabledin xen/drivers/passthrough/iommu.c:iommu_teardown()?OK. I will swap those lines instead.
Unfortunately swapping those two lines won't work, because for a DomU that doesn't have passthrough device, IOMMU is always disabled during its life cycle. Yet mm/p2m.c invokes iommu_share_p2m_table based solely on if hap is enabled.
Do you have other suggestions? It seems that we'd better make the predicates for enabling and disabling match.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 20 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.Signed-off-by Wei Liu <[email protected]>--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/drivers/passthrough/vtd/iommu.c +0
-0
xen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct domain *d) · line 1755
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +1
-1@@ -1752,7 +1752,13 @@ static void iommu_domain_teardown(struct domain *d)xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (hap_enabled (d));
This needs to be moved into the predicate below because PV domain can enter this path too.
Quoted 12 lines
xen/drivers/passthrough/vtd/iommu.c +6
-0+ +/* +* We can't use iommu_use_hap_pt here because the IOMMU state is already +* changed to IOMMU_STATUS_disabled at this point. +*/ +if ( iommu_hap_pt_share )return ;spin_lock (&hd->arch.mapping_lock);Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 61 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 14:38
To: Paul Durrant <[email protected]>
Cc: Wei Liu <[email protected]>; [email protected]; Kevin Tian <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 3 lines · Wei Liu
Quoted 2 lines · Paul Durrant
Quoted 2 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] OnBehalf
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Of Paul Durrant
Sent: 09 October 2018 12:23
To: Wei Liu <[email protected]>; [email protected]
Cc: Kevin Tian <[email protected]>; Wei Liu<[email protected]>; Jan
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Beulich <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH] x86/vtd: fix IOMMU share PTdestruction
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
path
Quoted 6 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 11:42
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>;Wei Liu
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
<[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()and
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
need_iommu_pt_sync()") made things finer grain by spliting
need_iommuQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
into three states.
The destruction path can't use
iommu_use_hap_ptbecause at thepoint
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
platform op is called, IOMMU is already switched to disabled state
and
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
the shared PT test would always be false.
This is VT-d specific and the issue could affect AMD too.
Yes, it looks like
deallocate_iommu_page_tables()will then try todeallocate page tables that would not have been allocated. This probably happens to be safe because the root table is allocated on demand, but that might change in future so I think it better to fix as I suggest below.
Quoted 5 lines
Quoted 5 lines
Paul
Quoted 2 lines
Can't you just
switch round the call to teardown and settingIOMMU_status_disabledin
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
xen/drivers/passthrough/iommu.c:iommu_teardown()?
OK. I will swap those lines instead.
Unfortunately swapping those two lines won't work, because for a DomU that doesn't have passthrough device, IOMMU is always disabled during its life cycle. Yet
mm/p2m.cinvokesiommu_share_p2m_tablebased solely on if hap is enabled.
OK. This disparity between dom0 and domU set-up is annoying.
Quoted 4 lines
Do you have other suggestions? It seems that we'd better make the predicates for enabling and disabling match.
Since your patch to the VT-d code works, let's go with it then.
Paul
Quoted 1 line
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 38 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 15:26
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: Re: [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 10 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.Review
Quoted 6 lines
Signed-off-by Wei Liu <[email protected]>--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/xen/drivers/passthrough/vtd/iommu.cxen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct domain
Quoted 4 lines
index
f94b522c73..d66d9e8ad0100644xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1752,7 +1752,13 @@ static void iommu_domain_teardown(struct domain*d)
xen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct domain *d) · line 1755
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +1
-1xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (hap_enabled (d));
Quoted 11 lines
This needs to be moved into the predicate below because PV domain can enter this path too.
xen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct domain *d)
Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+ +/* +* We can't use iommu_use_hap_pt here because the IOMMU state is already
Quoted 4 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+* changed to IOMMU_STATUS_disabled at this point. +*/ +if ( iommu_hap_pt_share )return ;
I guess the other option is to track whether there is anything to tear down in the iommu struct and test that. We have status and need_sync now, but maybe that's too simplistic.
Paul
Quoted 5 lines
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +0
-1spin_lock (&hd->arch.mapping_lock); --2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 44 lines · Paul Durrant
Quoted 44 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 15:26
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: Re: [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 10 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled state and the shared PT test would always be false.Review
Quoted 6 lines
Signed-off-by Wei Liu <[email protected]>--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/xen/drivers/passthrough/vtd/iommu.cxen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct domain
Quoted 4 lines
index
f94b522c73..d66d9e8ad0100644xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1752,7 +1752,13 @@ static void iommu_domain_teardown(struct domain*d)
xen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct domain *d) · line 1755
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +1
-1xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (hap_enabled (d));This needs to be moved into the predicate below because PV domain can enter this path too.
Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+ +/* +* We can't use iommu_use_hap_pt here because the IOMMU state is
Quoted 7 lines
Quoted 5 lines
already
Quoted 4 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+* changed to IOMMU_STATUS_disabled at this point. +*/ +if ( iommu_hap_pt_share )return ;I guess the other option is to track whether there is anything to tear down in the iommu struct and test that. We have status and
need_syncnow, but maybe that's too simplistic.
Using hap_enabled(d) && iommu_hap_pt_share should be good enough to me. Unless you feel strongly about this I'm not going to introduce more code churn than necessary.
Wei.
Quoted 8 lines
Paul
Quoted 5 lines
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +0
-1spin_lock (&hd->arch.mapping_lock); --2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 66 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 15:41
To: Paul Durrant <[email protected]>
Cc: Wei Liu <[email protected]>; [email protected]; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Kevin Tian <[email protected]>
Subject: Re: [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 6 lines · Paul Durrant
Quoted 6 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 15:26
To: [email protected]
Cc: Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Paul Durrant <[email protected]>; WeiLiu
Quoted 7 lines
Quoted 7 lines
<[email protected]>; Kevin Tian <[email protected]>
Subject: Re: [PATCH] x86/vtd: fix IOMMU share PT destruction pathQuoted 3 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add(" mm / iommu: splitneed_iommu()intohas_iommu_pt()and
Quoted 1 line
Quoted 1 line
Quoted 1 line
need_iommu_pt_sync()") made things finer grain by spliting
need_iommuQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
into three states.
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is already switched to disabled stateand
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
the shared PT test would always be false.
Signed-off-by Wei Liu <[email protected]>--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)Quoted 6 lines
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/xen/drivers/passthrough/vtd/iommu.cxen/drivers/passthrough/vtd/iommu.c static void iommu_domain_teardown(struct
Quoted 4 lines
index
f94b522c73..d66d9e8ad0100644xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1752,7 +1752,13 @@ static void iommu_domain_teardown(structdomain
Quoted 7 lines
Quoted 7 lines
*d)
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +1
-1xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (hap_enabled (d));Quoted 6 lines
Quoted 6 lines
This needs to be moved into the predicate below because PV domain can enter this path too.
Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+ +/* +* We can't use iommu_use_hap_pt here because the IOMMU state is
Quoted 6 lines
Quoted 5 lines
already
Quoted 4 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+* changed to IOMMU_STATUS_disabled at this point. +*/ +if ( iommu_hap_pt_share )return ;
Quoted 8 lines
Quoted 1 line
I guess the other option is to track whether there is anything to tear
down in the iommu struct and test that. We have status and
need_syncnow, but maybe that's too simplistic.Using
hap_enabled(d)&&iommu_hap_pt_shareshould be good enough to me. Unless you feel strongly about this I'm not going to introduce more code churn than necessary.
Ok. Fair enough. Let's keep the patch small.
Paul
Quoted 10 lines
Wei.
Quoted 8 lines
Paul
Quoted 5 lines
Quoted 5 lines
xen/drivers/passthrough/vtd/iommu.c +0
-1spin_lock (&hd->arch.mapping_lock); --2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel