per-domain passthrough/iommu options
Hi,
I sent a previous email [1] about enabling use of the IOMMU on a per-domain basis and am now a reasonable way into my patch series, which also allows for IOMMU option-setting (specifically shared EPT use) on a per-domain basis too. Before I post v1 I'd like to get some opinion on the what the xl.cfg options should look like. The simplest way for me to do things would be to have two new boolean options; something like:
'passthrough' - enable/disable pass-through support (i.e. use of the IOMMU)... can be implicitly enabled if there are pci or dt devices specified in the xl.cfg. 'no-sharept' - named to match the xen-cmdline option for turning off shared EPT. (EPT sharing currently defaults on globally).
I think the former is probably ok, but thinking forward to a time where we might have vIOMMU (PV or emulated) the latter is probably not the right thing to use. So, another way might be to have an IOMMU page-table option... something like:
'iommu-pt = shared|sync'
where 'shared' means use EPT mappings, and 'sync' means keep the P2M in sync. This could then be extended with 'viommu' later, meaning that there would be some form of vIOMMU exposed to the guest, be it emulated, PV or both. One drawback with this mechanism is that 'shared' is not always possible (e.g. on AMD h/w) so what should be done in that case? Should selecting that option be considered an error, or should there be a fall-back to 'sync'? The fall-back would be easier to deal with as then the option could just default to 'sync' if it was not specified.
Thoughts? Other ideas?
Cheers,
Paul
[1] https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg01090.html
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 11 lines · Paul Durrant
I sent a previous email [1] about enabling use of the IOMMU on a per-domain basis and am now a reasonable way into my patch series, which also allows for IOMMU option-setting (specifically shared EPT use) on a per-domain basis too. Before I post v1 I'd like to get some opinion on the what the xl.cfg options should look like. The simplest way for me to do things would be to have two new boolean options; something like:
'passthrough' - enable/disable pass-through support (i.e. use of the IOMMU)... can be implicitly enabled if there are pci or dt devices specified in the xl.cfg. 'no-sharept' - named to match the xen-cmdline option for turning off shared EPT. (EPT sharing currently defaults on globally).
I think the former is probably ok, but thinking forward to a time where we might have vIOMMU (PV or emulated) the latter is probably not the right thing to use. So, another way might be to have an IOMMU page-table option... something like:
'iommu-pt = shared|sync'
where 'shared' means use EPT mappings, and 'sync' means keep the P2M in sync. This could then be extended with 'viommu' later, meaning that there would be some form of vIOMMU exposed to the guest, be it emulated, PV or both. One drawback with this mechanism is that 'shared' is not always possible (e.g. on AMD h/w) so what should be done in that case? Should selecting that option be considered an error, or should there be a fall-back to 'sync'? The fall-back would be easier to deal with as then the option could just default to 'sync' if it was not specified.
The fall-back sounds reasonable to me (as long as that's properly described in documentation). What I'm less happy with is the idea of having two options instead of just one. But of course this may be a result of how libxl wants to organize options. If there's no restriction at that end, then how about
passthrough = off|sync|share-pt|viommu
? It would default to off when there are no devices listed in the config, and to share-pt (with the fall-back to sync) when there is at least one.
As to "sync" - how did you come to use this as the "opposite" of "share-pt"? There's nothing asynchronous with shared page tables, is there? Maybe "private-pt" or "separate-pt"? The option wouldn't be used typically anyway, especially if alongside "off" there was also an "on" variant, meaning the same as "share-pt".
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 38 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 13:57
To: Paul Durrant <[email protected]>
Cc: xen-devel ([email protected]) <[email protected]>
Subject: Re: [Xen-devel] per-domain passthrough/iommu optionsQuoted 1 line · Paul Durrant
I sent a previous email [1] about enabling use of the IOMMU on a per-domain basis and am now a
reasonable way into my patch series, which also allows for IOMMU option-setting (specifically shared EPT use) on a per-domain basis too. Before I post v1 I'd like to get some opinion on the what the xl.cfg options should look like.
Quoted 3 lines
The simplest way for me to do things would be to have two new boolean options; something like:
'passthrough' - enable/disable pass-through support (i.e. use of the IOMMU)... can be implicitly
enabled if there are pci or dt devices specified in the xl.cfg.
Quoted 1 line
'no-sharept' - named to match the xen-cmdline option for turning off shared EPT. (EPT sharing
currently defaults on globally).
Quoted 2 lines
I think the former is probably ok, but thinking forward to a time where we might have vIOMMU (PV
or emulated) the latter is probably not the right thing to use. So, another way might be to have an IOMMU page-table option... something like:
Quoted 4 lines
'iommu-pt = shared|sync'
where 'shared' means use EPT mappings, and 'sync' means keep the P2M in sync. This could then be
extended with 'viommu' later, meaning that there would be some form of vIOMMU exposed to the guest, be it emulated, PV or both. One drawback with this mechanism is that 'shared' is not always possible (e.g. on AMD h/w) so what should be done in that case? Should selecting that option be considered an error, or should there be a fall-back to 'sync'? The fall-back would be easier to deal with as then the option could just default to 'sync' if it was not specified.
The fall-back sounds reasonable to me (as long as that's properly described in documentation). What I'm less happy with is the idea of having two options instead of just one. But of course this may be a result of how libxl wants to organize options. If there's no restriction at that end, then how about
Quoted 5 lines
passthrough = off|sync|share-pt|viommu
? It would default to off when there are no devices listed in the config, and to share-pt (with the fall-back to sync) when there is at least one.
Yes, that sounds like it would work.
Quoted 3 lines
As to "sync" - how did you come to use this as the "opposite" of "share-pt"?
Oh, that's just adopting the general naming used in Xen. For a domU it is either going to have 'need_sync' set in its domain_iommu structure, or EPT sharing will be active.
Quoted 4 lines
There's nothing asynchronous with shared page tables, is there? Maybe "private-pt" or "separate-pt"? The option wouldn't be used typically anyway, especially if alongside "off" there was also an "on" variant, meaning the same as "share-pt".
Not sure how 'on' would co-exist with 'viommu'... the crucial difference is whether the p2m is shared or not and the currently the only option in the non-shared case, because we lack a viommu, is to keep the IOMMU mappings in sync with the P2M whenever the latter is updated. So, how about:
passthrough = off|sync-pt|share-pt|viommu
? I don't think 'private-pt' or 'separate-pt' really capture the fact that the page tables match the P2M. They could just as easily be taken to mean that they are populated using some other policy.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines · Paul Durrant
Not sure how 'on' would co-exist with 'viommu'... the crucial difference is whether the p2m is shared or not and the currently the only option in the non-shared case, because we lack a viommu, is to keep the IOMMU mappings in sync with the P2M whenever the latter is updated. So, how about:
passthrough = off|sync-pt|share-pt|viommu
? I don't think 'private-pt' or 'separate-pt' really capture the fact that the page tables match the P2M. They could just as easily be taken to mean that they are populated using some other policy.
But haven't we recently seen that this fully lock-step population of page tables isn't always correct (or at least desirable)? I vaguely recall other comments to that effect too, from long ago. I'd specifically want to avoid encoding into the interface here that the two are exact mirrors of one another, now and forever.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 14 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:02
To: Paul Durrant <[email protected]>
Cc: xen-devel ([email protected]) <[email protected]>
Subject: Re: [Xen-devel] per-domain passthrough/iommu optionsQuoted 1 line · Paul Durrant
Not sure how 'on' would co-exist with 'viommu'... the crucial difference is whether the p2m is
shared or not and the currently the only option in the non-shared case, because we lack a viommu, is to keep the IOMMU mappings in sync with the P2M whenever the latter is updated. So, how about:
Quoted 3 lines
passthrough = off|sync-pt|share-pt|viommu
Quoted 8 lines
Quoted 1 line
? I don't think 'private-pt' or 'separate-pt' really capture the fact that the page tables match the
P2M. They could just as easily be taken to mean that they are populated using some other policy.
But haven't we recently seen that this fully lock-step population of page tables isn't always correct (or at least desirable)? I vaguely recall other comments to that effect too, from long ago. I'd specifically want to avoid encoding into the interface here that the two are exact mirrors of one another, now and forever.
How do you think we should express it. I agree that it's a bit awkward because of the difference between HVM and PV domains, but all we can do there really is document it I think, so perhaps the manpage could have something like:
'off'
IOMMU mappings are disabled for the domain and so hardware may not be passed through.
'sync-pt'
For a PV domain, all writable pages assigned to the domain are identity mapped by MFN in the IOMMU page tables. Thus a device driver running in the domain may program passthrough hardware for DMA using MFN values (i.e. host/machine frame numbers) looked up in its P2M. For an HVM domain, all non-foreign RAM pages present in the P2M will be identity mapped by GFN in the IOMMU page tables. Thus a device driver running in the domain may program passthrough hardware using GFN values (i.e. guest physical frame numbers) without any further translation.
'share-pt'
This is unavailable for a PV domain. For an HVM domain, this option means that the IOMMU will be programmed to directly reference the P2M as its page tables. This availability of this option is hardware specific and thus, if it is specified for a domain running on hardware that does not allow it, 'sync-pt' will be used instead.
?
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Paul Durrant
Quoted 7 lines
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:02Quoted 1 line · Paul Durrant
? I don't think 'private-pt' or 'separate-pt' really capture the fact that the page tables match the
P2M. They could just as easily be taken to mean that they are populated using some other policy.
Quoted 7 lines
Quoted 5 lines
But haven't we recently seen that this fully lock-step population of page tables isn't always correct (or at least desirable)? I vaguely recall other comments to that effect too, from long ago. I'd specifically want to avoid encoding into the interface here that the two are exact mirrors of one another, now and forever.
How do you think we should express it. I agree that it's a bit awkward because of the difference between HVM and PV domains, but all we can do there really is document it I think, so perhaps the manpage could have something like:
Sounds reasonable - it at least avoids making the behavior too much spelled out with regard to the similarity of mappings between IOMMU page tables and P2M. There's one issue though:
Quoted 8 lines
'off'
IOMMU mappings are disabled for the domain and so hardware may not be passed through.
'sync-pt'
For a PV domain, all writable pages assigned to the domain are identity mapped by MFN in the IOMMU page tables. Thus a device driver running in the domain may program passthrough hardware for DMA using MFN values (i.e. host/machine frame numbers) looked up in its P2M. For an HVM domain, all non-foreign RAM pages present in the P2M will be identity mapped by GFN
Why "identity mapped" here? It's a GFN -> MFN mappingm, isn't it?
Jan
Quoted 12 lines
in the IOMMU page tables. Thus a device driver running in the domain may program passthrough hardware using GFN values (i.e. guest physical frame numbers) without any further translation.
'share-pt'
This is unavailable for a PV domain. For an HVM domain, this option means that the IOMMU will be programmed to directly reference the P2M as its page tables. This availability of this option is hardware specific and thus, if it is specified for a domain running on hardware that does not allow it, 'sync-pt' will be used instead.
?
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 34 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:34
To: Paul Durrant <[email protected]>
Cc: xen-devel ([email protected]) <[email protected]>
Subject: Re: [Xen-devel] per-domain passthrough/iommu optionsQuoted 5 lines · Paul Durrant
Quoted 5 lines
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:02Quoted 1 line · Paul Durrant
? I don't think 'private-pt' or 'separate-pt' really capture the fact that the page tables match
the
Quoted 9 lines
Quoted 7 lines
P2M. They could just as easily be taken to mean that they are populated using some other policy.
But haven't we recently seen that this fully lock-step population of page tables isn't always correct (or at least desirable)? I vaguely recall other comments to that effect too, from long ago. I'd specifically want to avoid encoding into the interface here that the two are exact mirrors of one another, now and forever.
How do you think we should express it. I agree that it's a bit awkward because of the difference
between HVM and PV domains, but all we can do there really is document it I think, so perhaps the manpage could have something like:
Sounds reasonable - it at least avoids making the behavior too much spelled out with regard to the similarity of mappings between IOMMU page tables and P2M. There's one issue though:
Quoted 4 lines
'off'
IOMMU mappings are disabled for the domain and so hardware may not be passed through.
Quoted 8 lines
Quoted 3 lines
'sync-pt'
For a PV domain, all writable pages assigned to the domain are identity mapped by MFN in the IOMMU
page tables. Thus a device driver running in the domain may program passthrough hardware for DMA using MFN values (i.e. host/machine frame numbers) looked up in its P2M.
Quoted 1 line
For an HVM domain, all non-foreign RAM pages present in the P2M will be identity mapped by GFN
Why "identity mapped" here? It's a GFN -> MFN mappingm, isn't it?
Yes... it's hard to express. What I want to say, of course, is that device drivers can use GFNs. Can you think of any other form of words that might be better?
Paul
Quoted 4 lines
Jan
Quoted 1 line
in the IOMMU page tables. Thus a device driver running in the domain may program passthrough
Quoted 15 lines
hardware using GFN values (i.e. guest physical frame numbers) without any further translation.
Quoted 4 lines
'share-pt'
This is unavailable for a PV domain. For an HVM domain, this option means that the IOMMU will be
programmed to directly reference the P2M as its page tables. This availability of this option is hardware specific and thus, if it is specified for a domain running on hardware that does not allow it, 'sync-pt' will be used instead.
Quoted 7 lines
?
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 36 lines · Paul Durrant
Quoted 36 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:34
To: Paul Durrant <[email protected]>
Cc: xen-devel ([email protected]) <[email protected]>
Subject: Re: [Xen-devel] per-domain passthrough/iommu optionsQuoted 5 lines · Paul Durrant
Quoted 5 lines
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:02Quoted 1 line · Paul Durrant
? I don't think 'private-pt' or 'separate-pt' really capture the fact that the page tables match
the
Quoted 9 lines
Quoted 7 lines
P2M. They could just as easily be taken to mean that they are populated using some other policy.
But haven't we recently seen that this fully lock-step population of page tables isn't always correct (or at least desirable)? I vaguely recall other comments to that effect too, from long ago. I'd specifically want to avoid encoding into the interface here that the two are exact mirrors of one another, now and forever.
How do you think we should express it. I agree that it's a bit awkward because of the difference
between HVM and PV domains, but all we can do there really is document it I think, so perhaps the manpage could have something like:
Sounds reasonable - it at least avoids making the behavior too much spelled out with regard to the similarity of mappings between IOMMU page tables and P2M. There's one issue though:
Quoted 6 lines
'off'
IOMMU mappings are disabled for the domain and so hardware may not be passed through.
'sync-pt'
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
For a PV domain, all writable pages assigned to the domain are identity mapped by MFN in the IOMMU
page tables. Thus a device driver running in the domain may program passthrough hardware for DMA using MFN values (i.e. host/machine frame numbers) looked up in its P2M.
Quoted 1 line
For an HVM domain, all non-foreign RAM pages present in the P2M will be identity mapped by GFN
Why "identity mapped" here? It's a GFN -> MFN mappingm, isn't it?
Yes... it's hard to express. What I want to say, of course, is that device drivers can use GFNs. Can you think of any other form of words that might be better?
Just omit "identity" in the HVM related sentence?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 48 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 29 July 2019 12:11
To: Paul Durrant <[email protected]>
Cc: xen-devel ([email protected]) <[email protected]>
Subject: Re: [Xen-devel] per-domain passthrough/iommu optionsQuoted 30 lines · Paul Durrant
Quoted 30 lines
-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:34
To: Paul Durrant <[email protected]>
Cc: xen-devel ([email protected]) <[email protected]>
Subject: Re: [Xen-devel] per-domain passthrough/iommu optionsQuoted 5 lines · Paul Durrant
Quoted 5 lines
From: Jan Beulich <[email protected]>
Sent: 26 July 2019 15:02Quoted 1 line · Paul Durrant
? I don't think 'private-pt' or 'separate-pt' really capture the fact that the page tables match
the
Quoted 9 lines
Quoted 7 lines
P2M. They could just as easily be taken to mean that they are populated using some other policy.
But haven't we recently seen that this fully lock-step population of page tables isn't always correct (or at least desirable)? I vaguely recall other comments to that effect too, from long ago. I'd specifically want to avoid encoding into the interface here that the two are exact mirrors of one another, now and forever.
How do you think we should express it. I agree that it's a bit awkward because of the difference
between HVM and PV domains, but all we can do there really is document it I think, so perhaps the manpage could have something like:
Sounds reasonable - it at least avoids making the behavior too much spelled out with regard to the similarity of mappings between IOMMU page tables and P2M. There's one issue though:
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
'off'
IOMMU mappings are disabled for the domain and so hardware may not be passed through.
'sync-pt'
For a PV domain, all writable pages assigned to the domain are identity mapped by MFN in the IOMMU
page tables. Thus a device driver running in the domain may program passthrough hardware for DMA
using
Quoted 1 line
Quoted 1 line
MFN values (i.e. host/machine frame numbers) looked up in its P2M.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
For an HVM domain, all non-foreign RAM pages present in the P2M will be identity mapped by GFN
Why "identity mapped" here? It's a GFN -> MFN mappingm, isn't it?
Yes... it's hard to express. What I want to say, of course, is that device drivers can use GFNs. Can
you think of any other form of words that might be better?
Just omit "identity" in the HVM related sentence?
Ok, I guess that sounds ok. I'll do that.
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel