arm/p2m: do not invalidate p2m root if it is shared with IOMMU
PATCH 1/1 arm/p2m: do not invalidate p2m root if it is shared with IOMMU
From: Andrii Anisov <[email protected]>
In case if the p2m table is shared to IOMMU, invalidating it turns IOMMU to translation faults that could be not repaired.
Fixed patch check for the corresponded condition and has a comment for one introduced p2m_invalidate_root() call, but miss them for another. So put the if and the comment in place.
--- xen/arch/arm/p2m.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
xen/arch/arm/p2m.c +6 -1
@@ -1708,8 +1708,13 @@ void p2m_flush_vm(struct vcpu *v)/* * Invalidate the p2m to track which page was modified by the guest * between call of p2m_flush_vm(). +* +* This is only turned when IOMMU is not used or the page-table are +* not shared because bit[0] (e.g valid bit) unset will result +* IOMMU fault that could be not fixed-up. */ -p2m_invalidate_root (p2m); +if ( !iommu_use_hap_pt (v->domain) ) +p2m_invalidate_root (p2m); v->arch.need_flush_to_ram = false; }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 8 lines · Andrii Anisov
From: Andrii Anisov <[email protected]>
In case if the p2m table is shared to IOMMU, invalidating it turns IOMMU to translation faults that could be not repaired.
Fixed patch check for the corresponded condition and has a comment for one introduced
p2m_invalidate_root()call, but miss them for another. So put theifand the comment in place.
This was missed on purpose. Let me explain why. The call to p2m_invalidate_root() arch_domain_creation_finished is called by *all* the domain at boot to try to optimize the set/way case.
The check iommu_use_hap_pt in that context is to prevent guest not using Set/Way to become unusable under the IOMMU use-case.
In your case, you seem to have a guest OS using set/way and yet sharing the P2M with the IOMMU. You have the choice between:
1) Crashing on IOMMU fault
2) Become very slow and potentially unusable because you now have to go
through the full P2M every time you do a Set/Way.
1) was my favored option because Set/Way should really not be used by the guest. It was implemented by courtesy to the guest OS and I would not rely on everything working.
Can you explain what is your use-case (OS used, IOMMU, platform...)?
Cheers,
Quoted 27 lines
Fixes 2148a12 ("xen/arm: Track page accessed between batch of Set/Way operations")Signed-off-by Andrii Anisov <[email protected]>--- xen/arch/arm/p2m.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)xen/arch/arm/p2m.c +6
-1@@ -1708,8 +1708,13 @@ void p2m_flush_vm(struct vcpu *v)/* * Invalidate the p2m to track which page was modified by the guest * between call of p2m_flush_vm(). +* +* This is only turned when IOMMU is not used or the page-table are +* not shared because bit[0] (e.g valid bit) unset will result +* IOMMU fault that could be not fixed-up. */ -p2m_invalidate_root (p2m); +if ( !iommu_use_hap_pt (v->domain) ) +p2m_invalidate_root (p2m); v->arch.need_flush_to_ram = false; }
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hello Julien,
Actually I was going to send this patch as RFC, but dropped it at the last moment.
Quoted 11 lines · Julien Grall
This was missed on purpose. Let me explain why. The call to
p2m_invalidate_root()arch_domain_creation_finishedis called by *all* the domain at boot to try to optimize the set/way case.The check
iommu_use_hap_ptin that context is to prevent guest not using Set/Way to become unusable under the IOMMU use-case.In your case, you seem to have a guest OS using set/way and yet sharing the P2M with the IOMMU. You have the choice between:
1) Crashing on IOMMU fault
2) Become very slow and potentially unusable because you now have to go through the full P2M every time you do a Set/Way.1) was my favored option because Set/Way should really not be used by the guest. It was implemented by courtesy to the guest OS and I would not rely on everything working.
Can you explain what is your use-case (OS used, IOMMU, platform...)
Yep, I'm nearly finished moving our development setup to XEN 4.12-rc.
The platform is R-Car Gen3 (CA57+CA53), Renesas'es IOMMU named IPMMU is utilized for all peripherals assigned to DomD and GPU shared between DomD and DomA.
Three OS'es are running on the HW: HW-less Dom0, driver domain DomD with GPU sharing, Android running on PV drivers and GPU sharing.
So on system start (DomD booting) I see few translation faults from DomD only assigned peripherals. But then Android starts and there are lot of translation faults from GPU trying access DomA memory. Then GPU FW dies.
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 13 lines · Andrii Anisov
Hello Julien,
Actually I was going to send this patch as RFC, but dropped it at the last moment.
Quoted 8 lines · Julien Grall
This was missed on purpose. Let me explain why. The call to
p2m_invalidate_root()arch_domain_creation_finishedis called by *all* the domain at boot to try to optimize the set/way case.The check
iommu_use_hap_ptin that context is to prevent guest not using Set/Way to become unusable under the IOMMU use-case.In your case, you seem to have a guest OS using set/way and yet sharing the P2M with the IOMMU. You have the choice between:
1) Crashing on IOMMU fault
2) Become very slow and potentially unusable because you now have to go through the full P2M every time you do a Set/Way.
Quoted 7 lines
Quoted 3 lines
1) was my favored option because Set/Way should really not be used by the guest. It was implemented by courtesy to the guest OS and I would not rely on everything working.
Can you explain what is your use-case (OS used, IOMMU, platform...)
Yep, I'm nearly finished moving our development setup to XEN 4.12-rc.
The platform is R-Car Gen3 (CA57+CA53), Renesas'es IOMMU named IPMMU is utilized for all peripherals assigned to DomD and GPU shared between DomD and DomA.
Three OS'es are running on the HW: HW-less Dom0, driver domain DomD with GPU sharing, Android running on PV drivers and GPU sharing.
So on system start (DomD booting) I see few translation faults from DomD only assigned peripherals. But then Android starts and there are lot of translation faults from GPU trying access DomA memory. Then GPU FW dies.
Hold on, CA57 and CA53 are ARMv8 cores. So are you using 32-bit or 64-bit guests?
64-bit guest should not have any Set/Way operations unless you are using a very very old Linux. So what is the version of each guest?
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 1 line · Julien Grall
Hold on, CA57 and CA53 are ARMv8 cores. So are you using 32-bit or 64-bit guests?
64-bit guests.
Quoted 1 line
64-bit guest should not have any Set/Way operations unless you are using a very very old Linux. So what is the version of each guest?
All of them derived from 4.14.35.
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Andrii Anisov
Quoted 1 line · Julien Grall
Hold on, CA57 and CA53 are ARMv8 cores. So are you using 32-bit or 64-bit guests?
64-bit guests.
Quoted 1 line
64-bit guest should not have any Set/Way operations unless you are using a very very old Linux. So what is the version of each guest?
All of them derived from 4.14.35.
There should be no Set/Way in Linux 4.14. So I am a bit confused how can even reach this code.
Can you look if there are a Set/Way executed in Linux? And where? You can add some code in arm64/vsysreg.c to track that down.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Julien Grall
Quoted 4 lines · Andrii Anisov
Quoted 1 line · Julien Grall
Hold on, CA57 and CA53 are ARMv8 cores. So are you using 32-bit or 64-bit guests?
Quoted 8 lines
Quoted 4 lines
64-bit guests.
Quoted 1 line
64-bit guest should not have any Set/Way operations unless you are using a very very old Linux. So what is the version of each guest?
All of them derived from 4.14.35.
There should be no Set/Way in Linux 4.14. So I am a bit confused how can even reach this code.
Can you look if there are a Set/Way executed in Linux? And where? You can add some code in
arm64/vsysreg.cto track that down.
Yep, I'm still looking into details of that stuff. Yet this patch makes the system functional.
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hello Julien,
Quoted 1 line · Julien Grall
There should be no Set/Way in Linux 4.14. So I am a bit confused how can even reach this code.
Well, that is a proprietary kernel driver doing cache maintenance using Set/Way operations. And I'm not sure if we can avoid that :(
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 1 line · Andrii Anisov
Hello Julien,
Hi,
Quoted 4 lines · Julien Grall
Quoted 1 line
There should be no Set/Way in Linux 4.14. So I am a bit confused how can even reach this code.
Well, that is a proprietary kernel driver doing cache maintenance using Set/Way operations. And I'm not sure if we can avoid that :(
Which proprietary kernel driver? And in which context are Set/Way operations used?
Using Set/Way is fundamentally broken partly because it does not deal with system caches. It also only applies to a given cache and the behavior will not be replicated to other CPUs. For more details, have a look at [1].
If you wonder, this worked by pure chance in older release. Running such software is a call for nasty behavior in your guest.
Cheers,
[1] https://www.youtube.com/watch?v=s07f82iiI-E
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 1 line · Julien Grall
Which proprietary kernel driver? And in which context are Set/Way operations used?
I would not name it, it is proprietary ;) But we can't live without it.
Quoted 1 line
Using Set/Way is fundamentally broken partly because it does not deal with system caches.
I already know it. I've looked at KVM presentation from 2015, your last year video from China, reading through ARM ARM.
Quoted 1 line
It also only applies to a given cache and the behavior will not be replicated to other CPUs.
In our case cpu cache flushing by Set/Way it is propagated to all cpus with on_each_cpu(). (Here should be a facepalm emoji)
Quoted 1 line
Running such software is a call for nasty behavior in your guest.
I do understand that.
But we have to handle that. And it is a question to us how to do that.
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Andrii,
Quoted 7 lines · Andrii Anisov
Quoted 1 line · Julien Grall
Using Set/Way is fundamentally broken partly because it does not deal with system caches.
I already know it. I've looked at KVM presentation from 2015, your last year video from China, reading through ARM ARM.
Quoted 1 line
It also only applies to a given cache and the behavior will not be replicated to other CPUs.
In our case cpu cache flushing by Set/Way it is propagated to all cpus with
on_each_cpu(). (Here should be a facepalm emoji)
:/
Quoted 4 lines
Quoted 2 lines
Running such software is a call for nasty behavior in your guest.
I do understand that.
But we have to handle that. And it is a question to us how to do that.
No we don't have to. They have been lucky to see this working even on baremetal.
Set/Way operations have been dropped from Linux for a long time, so I really can't see why a proprietary driver is still using them.
I think the policy for Set/Way operations is correct in Xen. This works to avoid breaking basic case but the most complex one are going to break.
You solution is only delaying the real fix (i.e removing Set/Way operation from the software). So here the best solution is to go to the vendor and ask them to fix their software.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 1 line · Julien Grall
No we don't have to.
I mean, EPAM systems as a XEN based virtualization solution provider have to handle that issue.
Quoted 2 lines
They have been lucky to see this working even on baremetal.
Set/Way operations have been dropped from Linux for a long time, so I really can't see why a proprietary driver is still using them.
I guess there were some performance concerns. And they are really lucky, so they did not face related issues on baremetal.
Quoted 1 line
I think the policy for Set/Way operations is correct in Xen. This works to avoid breaking basic case but the most complex one are going to break.
Maybe it worth to get a notification from XEN, i.e. WARN_ONCE, saying that Set/Way cache operations are undesirable in VM and will lead to the system performance drop, or even instability in case of IOMMU sharing p2m with CPU. This might save days of debugging to XEN on ARM users.
Quoted 1 line
You solution is only delaying the real fix
I would not say it is delaying the fix, but allows us to have a functional system until we get that fix.
Quoted 1 line
(i.e removing Set/Way operation from the software). So here the best solution is to go to the vendor and ask them to fix their software.
Actually escalation the issue to the vendor is one of our next steps here.
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Andrii,
Quoted 5 lines · Andrii Anisov
Quoted 2 lines · Julien Grall
They have been lucky to see this working even on baremetal.
Set/Way operations have been dropped from Linux for a long time, so I really can't see why a proprietary driver is still using them.I guess there were some performance concerns. And they are really lucky, so they did not face related issues on baremetal.
I am not entirely convinced this is related to performance. You have to flush all the cache level one by one and may miss some caches (i.e system caches).
I suspect this is a relic from early version of Linux and no-one have seen the issue and/or "difficult" to fix. Set/Way is quite convenient to use over going over virtual address.
Quoted 4 lines
Quoted 2 lines
I think the policy for Set/Way operations is correct in Xen. This works to avoid breaking basic case but the most complex one are going to break.
Maybe it worth to get a notification from XEN, i.e.
WARN_ONCE, saying that Set/Way cache operations are undesirable in VM and will lead to the system performance drop, or even instability in case of IOMMU sharing p2m with CPU. This might save days of debugging to XEN on ARM users.
I would be happy with a printk warning the user.
Quoted 3 lines
Quoted 2 lines
You solution is only delaying the real fix
I would not say it is delaying the fix, but allows us to have a functional system until we get that fix.
By experience, if you workaround something in the code then you have less incentive to fix the real issue. So I am not willing to merge any patch that could delay a vendor to fix their software.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Andrii Anisov
Quoted 1 line · Julien Grall
No we don't have to.
I mean, EPAM systems as a XEN based virtualization solution provider have to handle that issue.
Quoted 3 lines
They have been lucky to see this working even on baremetal. Set/Way operations have been dropped from Linux for a long time, so I really can't see why a proprietary driver is still using them.
I guess there were some performance concerns. And they are really lucky, so they did not face related issues on baremetal.
Quoted 6 lines
Quoted 2 lines
I think the policy for Set/Way operations is correct in Xen. This works to avoid breaking basic case but the most complex one are going to break.
Maybe it worth to get a notification from XEN, i.e.
WARN_ONCE, saying that Set/Way cache operations are undesirable in VM and will lead to the system performance drop, or even instability in case of IOMMU sharing p2m with CPU. This might save days of debugging to XEN on ARM users.
A WARN_ONCE would be nice. If you send a patch I would be happy to take in 4.12 (if the release manager agrees).
Quoted 7 lines
Quoted 1 line
You solution is only delaying the real fix
I would not say it is delaying the fix, but allows us to have a functional system until we get that fix.
Quoted 2 lines
(i.e removing Set/Way operation from the software). So here the best solution is to go to the vendor and ask them to fix their software.
Actually escalation the issue to the vendor is one of our next steps here.
You really want to fix this in the Linux driver if you can, because you'll get better performance and a more stable system. In the short term, I would suggest you keep the work-around in your private tree. However, do let us know how the escalation with the vendor proceeds and if you have any troubles with it. Julien and I would be happy to provide help in terms of information and docs on the reasons why this should be fixed in the driver. Julien might even be able to help further via his employer.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 2 lines · Stefano Stabellini
You really want to fix this in the Linux driver if you can, because you'll get better performance and a more stable system.
I also have an idea that it might improve performance. And it is what we need.
Quoted 2 lines
In the short
term, I would suggest you keep the work-around in your private tree.
As I do now.
Quoted 5 lines
However, do let us know how the escalation with the vendor proceeds and if you have any troubles with it. Julien and I would be happy to provide help in terms of information and docs on the reasons why this should be fixed in the driver. Julien might even be able to help further via his employer.
Thank you.
I already referred this thread in the email to the vendor as the first step. But have no answer yet :(
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hello Stefano,
Quoted 3 lines · Andrii Anisov
Thank you.
I already referred this thread in the email to the vendor as the first step. But have no answer yet :(
We've got an answer from the vendor. They agree with arguments and have provided a patch to eliminate Set/Way usage. We've checked and it does what is needed. So we do not need this WA any more.
Signature · 7 lines
Sincerely, Andrii Anisov. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 10 lines · Andrii Anisov
Hello Stefano,
Quoted 3 lines · Andrii Anisov
Thank you.
I already referred this thread in the email to the vendor as the first step. But have no answer yet :(We've got an answer from the vendor. They agree with arguments and have provided a patch to eliminate Set/Way usage.
We've checked and it does what is needed. So we do not need this WA any more.
Great, best for everybody!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel