Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-08-11 Thread Eugenio Perez Martin
On Tue, Aug 11, 2020 at 7:01 PM Eugenio Perez Martin wrote: > > On Fri, Jun 26, 2020 at 11:29 PM Peter Xu wrote: > > > > Hi, Eugenio, > > > > (CCing Eric, Yan and Michael too) > > > > On Fri, Jun 26, 2020 at 08:41:22AM +0200, Eugenio Pérez wrote: > > > diff --git a/memory.c b/memory.c > > >

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-08-11 Thread Eugenio Perez Martin
On Fri, Jun 26, 2020 at 11:29 PM Peter Xu wrote: > > Hi, Eugenio, > > (CCing Eric, Yan and Michael too) > > On Fri, Jun 26, 2020 at 08:41:22AM +0200, Eugenio Pérez wrote: > > diff --git a/memory.c b/memory.c > > index 2f15a4b250..7f789710d2 100644 > > --- a/memory.c > > +++ b/memory.c > > @@

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-08-04 Thread Jason Wang
On 2020/8/5 上午4:30, Peter Xu wrote: On Mon, Aug 03, 2020 at 06:00:34PM +0200, Eugenio Pérez wrote: On Fri, 2020-07-03 at 15:24 +0800, Jason Wang wrote: On 2020/7/2 下午11:45, Peter Xu wrote: On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: So I think we agree that a new notifier

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-08-04 Thread Peter Xu
On Mon, Aug 03, 2020 at 06:00:34PM +0200, Eugenio Pérez wrote: > On Fri, 2020-07-03 at 15:24 +0800, Jason Wang wrote: > > On 2020/7/2 下午11:45, Peter Xu wrote: > > > On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: > > > > So I think we agree that a new notifier is needed? > > > Good to

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-08-03 Thread Eugenio Pérez
On Fri, 2020-07-03 at 15:24 +0800, Jason Wang wrote: > On 2020/7/2 下午11:45, Peter Xu wrote: > > On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: > > > So I think we agree that a new notifier is needed? > > Good to me, or a new flag should be easier (IOMMU_NOTIFIER_DEV_IOTLB)? > > That

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-21 Thread Peter Xu
On Tue, Jul 21, 2020 at 02:20:01PM +0800, Jason Wang wrote: > > On 2020/7/20 下午9:03, Peter Xu wrote: > > On Mon, Jul 20, 2020 at 12:02:06PM +0800, Jason Wang wrote: > > > Right, so there's no need to deal with unmap in vtd's replay > > > implementation > > > (as what generic one did). > > We

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-21 Thread Jason Wang
On 2020/7/20 下午9:03, Peter Xu wrote: On Mon, Jul 20, 2020 at 12:02:06PM +0800, Jason Wang wrote: Right, so there's no need to deal with unmap in vtd's replay implementation (as what generic one did). We don't even for now; see vtd_page_walk_info.notify_unmap. Thanks, Right, but I meant

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-20 Thread Peter Xu
On Mon, Jul 20, 2020 at 12:02:06PM +0800, Jason Wang wrote: > Right, so there's no need to deal with unmap in vtd's replay implementation > (as what generic one did). We don't even for now; see vtd_page_walk_info.notify_unmap. Thanks, -- Peter Xu

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-19 Thread Jason Wang
On 2020/7/17 下午10:18, Peter Xu wrote: On Thu, Jul 16, 2020 at 10:54:31AM +0800, Jason Wang wrote: On 2020/7/16 上午9:00, Peter Xu wrote: On Mon, Jul 13, 2020 at 12:04:16PM +0800, Jason Wang wrote: On 2020/7/10 下午9:30, Peter Xu wrote: On Fri, Jul 10, 2020 at 02:34:11PM +0800, Jason Wang

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-17 Thread Peter Xu
On Thu, Jul 16, 2020 at 10:54:31AM +0800, Jason Wang wrote: > > On 2020/7/16 上午9:00, Peter Xu wrote: > > On Mon, Jul 13, 2020 at 12:04:16PM +0800, Jason Wang wrote: > > > On 2020/7/10 下午9:30, Peter Xu wrote: > > > > On Fri, Jul 10, 2020 at 02:34:11PM +0800, Jason Wang wrote: > > > > > On 2020/7/9

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-15 Thread Jason Wang
On 2020/7/16 上午9:00, Peter Xu wrote: On Mon, Jul 13, 2020 at 12:04:16PM +0800, Jason Wang wrote: On 2020/7/10 下午9:30, Peter Xu wrote: On Fri, Jul 10, 2020 at 02:34:11PM +0800, Jason Wang wrote: On 2020/7/9 下午10:10, Peter Xu wrote: On Thu, Jul 09, 2020 at 01:58:33PM +0800, Jason Wang wrote:

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-15 Thread Peter Xu
On Mon, Jul 13, 2020 at 12:04:16PM +0800, Jason Wang wrote: > > On 2020/7/10 下午9:30, Peter Xu wrote: > > On Fri, Jul 10, 2020 at 02:34:11PM +0800, Jason Wang wrote: > > > On 2020/7/9 下午10:10, Peter Xu wrote: > > > > On Thu, Jul 09, 2020 at 01:58:33PM +0800, Jason Wang wrote: > > > > > > > - If we

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-12 Thread Jason Wang
On 2020/7/10 下午9:30, Peter Xu wrote: On Fri, Jul 10, 2020 at 02:34:11PM +0800, Jason Wang wrote: On 2020/7/9 下午10:10, Peter Xu wrote: On Thu, Jul 09, 2020 at 01:58:33PM +0800, Jason Wang wrote: - If we care the performance, it's better to implement the MAP event for vhost, otherwise it

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-10 Thread Peter Xu
On Fri, Jul 10, 2020 at 02:34:11PM +0800, Jason Wang wrote: > > On 2020/7/9 下午10:10, Peter Xu wrote: > > On Thu, Jul 09, 2020 at 01:58:33PM +0800, Jason Wang wrote: > > > > > - If we care the performance, it's better to implement the MAP event > > > > > for > > > > > vhost, otherwise it could be

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-10 Thread Jason Wang
On 2020/7/9 下午10:10, Peter Xu wrote: On Thu, Jul 09, 2020 at 01:58:33PM +0800, Jason Wang wrote: - If we care the performance, it's better to implement the MAP event for vhost, otherwise it could be a lot of IOTLB miss I feel like these are two things. So far what we are talking about is

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-09 Thread Peter Xu
On Thu, Jul 09, 2020 at 01:58:33PM +0800, Jason Wang wrote: > > > - If we care the performance, it's better to implement the MAP event for > > > vhost, otherwise it could be a lot of IOTLB miss > > I feel like these are two things. > > > > So far what we are talking about is whether vt-d should

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-08 Thread Jason Wang
On 2020/7/8 下午10:16, Peter Xu wrote: On Wed, Jul 08, 2020 at 01:42:30PM +0800, Jason Wang wrote: So it should be functional equivalent to vtd_as_has_notifier(). For example: in vtd_iommu_replay() we'll skip the replay if vhost has registered the iommu notifier because

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-08 Thread Peter Xu
On Wed, Jul 08, 2020 at 01:42:30PM +0800, Jason Wang wrote: > > > So it should be functional equivalent to vtd_as_has_notifier(). > > For example: in vtd_iommu_replay() we'll skip the replay if vhost has > > registered the iommu notifier because vtd_as_has_map_notifier() will return > > false. >

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-08 Thread Jason Wang
On 2020/7/8 上午3:54, Peter Xu wrote: On Tue, Jul 07, 2020 at 04:03:10PM +0800, Jason Wang wrote: On 2020/7/3 下午9:03, Peter Xu wrote: On Fri, Jul 03, 2020 at 03:24:19PM +0800, Jason Wang wrote: On 2020/7/2 下午11:45, Peter Xu wrote: On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote:

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-07 Thread Peter Xu
On Tue, Jul 07, 2020 at 04:03:10PM +0800, Jason Wang wrote: > > On 2020/7/3 下午9:03, Peter Xu wrote: > > On Fri, Jul 03, 2020 at 03:24:19PM +0800, Jason Wang wrote: > > > On 2020/7/2 下午11:45, Peter Xu wrote: > > > > On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: > > > > > So I think

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-07 Thread Jason Wang
On 2020/7/3 下午9:03, Peter Xu wrote: On Fri, Jul 03, 2020 at 03:24:19PM +0800, Jason Wang wrote: On 2020/7/2 下午11:45, Peter Xu wrote: On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: So I think we agree that a new notifier is needed? Good to me, or a new flag should be easier

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-03 Thread Peter Xu
On Fri, Jul 03, 2020 at 03:24:19PM +0800, Jason Wang wrote: > > On 2020/7/2 下午11:45, Peter Xu wrote: > > On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: > > > So I think we agree that a new notifier is needed? > > Good to me, or a new flag should be easier (IOMMU_NOTIFIER_DEV_IOTLB)?

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-03 Thread Jason Wang
On 2020/7/2 下午11:45, Peter Xu wrote: On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: So I think we agree that a new notifier is needed? Good to me, or a new flag should be easier (IOMMU_NOTIFIER_DEV_IOTLB)? That should work but I wonder something as following is better.

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-02 Thread Peter Xu
On Thu, Jul 02, 2020 at 11:01:54AM +0800, Jason Wang wrote: > So I think we agree that a new notifier is needed? Good to me, or a new flag should be easier (IOMMU_NOTIFIER_DEV_IOTLB)? -- Peter Xu

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-01 Thread Jason Wang
On 2020/7/1 下午4:09, Jason Wang wrote: On 2020/6/30 下午11:39, Peter Xu wrote: On Tue, Jun 30, 2020 at 10:41:10AM +0800, Jason Wang wrote:   /* According to ATS spec table 2.4:    * S = 0, bits 15:12 = range size: 4K    * S = 1, bits 15:12 = xxx0 range size: 8K   

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-01 Thread Jason Wang
On 2020/7/1 下午8:41, Peter Xu wrote: On Wed, Jul 01, 2020 at 08:30:07PM +0800, Jason Wang wrote: I overlooked myself that the IR region will be there even if ir=off. Yes, but the point stands still but the issue is still if ir=off. So I think the assert should stand. Do you mean

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-01 Thread Peter Xu
On Wed, Jul 01, 2020 at 08:30:07PM +0800, Jason Wang wrote: > > I overlooked myself that the IR region will be there even if ir=off. > > > Yes, but the point stands still but the issue is still if ir=off. > > > >So I > > think the assert should stand. > > > Do you mean vhost can't

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-01 Thread Jason Wang
On 2020/7/1 下午8:16, Peter Xu wrote: On Wed, Jul 01, 2020 at 04:11:49PM +0800, Jason Wang wrote: On 2020/6/30 下午11:20, Peter Xu wrote: On Tue, Jun 30, 2020 at 05:23:31PM +0800, Jason Wang wrote: Ok, we had a dedicated mr for interrupt:

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-01 Thread Peter Xu
On Wed, Jul 01, 2020 at 04:11:49PM +0800, Jason Wang wrote: > > On 2020/6/30 下午11:20, Peter Xu wrote: > > On Tue, Jun 30, 2020 at 05:23:31PM +0800, Jason Wang wrote: > > > > > Ok, we had a dedicated mr for interrupt: > > > > > > > > > >

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-01 Thread Jason Wang
On 2020/6/30 下午11:20, Peter Xu wrote: On Tue, Jun 30, 2020 at 05:23:31PM +0800, Jason Wang wrote: Ok, we had a dedicated mr for interrupt: memory_region_add_subregion_overlap(MEMORY_REGION(_dev_as->iommu), VTD_INTERRUPT_ADDR_FIRST, _dev_as->iommu_ir, 1); So it should be fine. I guess the

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-07-01 Thread Jason Wang
On 2020/6/30 下午11:39, Peter Xu wrote: On Tue, Jun 30, 2020 at 10:41:10AM +0800, Jason Wang wrote: /* According to ATS spec table 2.4: * S = 0, bits 15:12 = range size: 4K * S = 1, bits 15:12 = xxx0 range size: 8K * S = 1, bits 15:12 = xx01 range

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-30 Thread Peter Xu
On Tue, Jun 30, 2020 at 10:41:10AM +0800, Jason Wang wrote: > > /* According to ATS spec table 2.4: > > * S = 0, bits 15:12 = range size: 4K > > * S = 1, bits 15:12 = xxx0 range size: 8K > > * S = 1, bits 15:12 = xx01 range size: 16K > > * S = 1, bits

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-30 Thread Peter Xu
On Tue, Jun 30, 2020 at 05:23:31PM +0800, Jason Wang wrote: > > > Ok, we had a dedicated mr for interrupt: > > > > > > memory_region_add_subregion_overlap(MEMORY_REGION(_dev_as->iommu), > > > VTD_INTERRUPT_ADDR_FIRST, > > > _dev_as->iommu_ir, 1); > > > > > > So it should be fine. I guess the

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-30 Thread Michael S. Tsirkin
On Tue, Jun 30, 2020 at 04:29:19PM +0800, Jason Wang wrote: > > On 2020/6/30 上午10:41, Jason Wang wrote: > > > > On 2020/6/29 下午9:34, Peter Xu wrote: > > > On Mon, Jun 29, 2020 at 01:51:47PM +0800, Jason Wang wrote: > > > > On 2020/6/28 下午10:47, Peter Xu wrote: > > > > > On Sun, Jun 28, 2020 at

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-30 Thread Jason Wang
On 2020/6/30 下午5:21, Michael S. Tsirkin wrote: On Tue, Jun 30, 2020 at 04:29:19PM +0800, Jason Wang wrote: On 2020/6/30 上午10:41, Jason Wang wrote: On 2020/6/29 下午9:34, Peter Xu wrote: On Mon, Jun 29, 2020 at 01:51:47PM +0800, Jason Wang wrote: On 2020/6/28 下午10:47, Peter Xu wrote: On Sun,

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-30 Thread Jason Wang
On 2020/6/30 上午10:41, Jason Wang wrote: On 2020/6/29 下午9:34, Peter Xu wrote: On Mon, Jun 29, 2020 at 01:51:47PM +0800, Jason Wang wrote: On 2020/6/28 下午10:47, Peter Xu wrote: On Sun, Jun 28, 2020 at 03:03:41PM +0800, Jason Wang wrote: On 2020/6/27 上午5:29, Peter Xu wrote: Hi, Eugenio,

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-29 Thread Jason Wang
On 2020/6/29 下午9:34, Peter Xu wrote: On Mon, Jun 29, 2020 at 01:51:47PM +0800, Jason Wang wrote: On 2020/6/28 下午10:47, Peter Xu wrote: On Sun, Jun 28, 2020 at 03:03:41PM +0800, Jason Wang wrote: On 2020/6/27 上午5:29, Peter Xu wrote: Hi, Eugenio, (CCing Eric, Yan and Michael too) On Fri,

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-29 Thread Peter Xu
On Mon, Jun 29, 2020 at 01:51:47PM +0800, Jason Wang wrote: > > On 2020/6/28 下午10:47, Peter Xu wrote: > > On Sun, Jun 28, 2020 at 03:03:41PM +0800, Jason Wang wrote: > > > On 2020/6/27 上午5:29, Peter Xu wrote: > > > > Hi, Eugenio, > > > > > > > > (CCing Eric, Yan and Michael too) > > > > > > > >

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-28 Thread Jason Wang
On 2020/6/28 下午10:47, Peter Xu wrote: On Sun, Jun 28, 2020 at 03:03:41PM +0800, Jason Wang wrote: On 2020/6/27 上午5:29, Peter Xu wrote: Hi, Eugenio, (CCing Eric, Yan and Michael too) On Fri, Jun 26, 2020 at 08:41:22AM +0200, Eugenio Pérez wrote: diff --git a/memory.c b/memory.c index

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-28 Thread Peter Xu
On Sun, Jun 28, 2020 at 03:03:41PM +0800, Jason Wang wrote: > > On 2020/6/27 上午5:29, Peter Xu wrote: > > Hi, Eugenio, > > > > (CCing Eric, Yan and Michael too) > > > > On Fri, Jun 26, 2020 at 08:41:22AM +0200, Eugenio Pérez wrote: > > > diff --git a/memory.c b/memory.c > > > index

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-28 Thread Jason Wang
On 2020/6/27 上午5:29, Peter Xu wrote: Hi, Eugenio, (CCing Eric, Yan and Michael too) On Fri, Jun 26, 2020 at 08:41:22AM +0200, Eugenio Pérez wrote: diff --git a/memory.c b/memory.c index 2f15a4b250..7f789710d2 100644 --- a/memory.c +++ b/memory.c @@ -1915,8 +1915,6 @@ void

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-27 Thread Yan Zhao
On Sat, Jun 27, 2020 at 08:57:14AM -0400, Peter Xu wrote: > On Sat, Jun 27, 2020 at 03:26:45AM -0400, Yan Zhao wrote: > > > -assert(entry->iova >= notifier->start && entry_end <= notifier->end); > > > +if (notifier->notifier_flags & IOMMU_NOTIFIER_ARBITRARY_MASK) { > > > +tmp.iova

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-27 Thread Peter Xu
On Sat, Jun 27, 2020 at 03:26:45AM -0400, Yan Zhao wrote: > > -assert(entry->iova >= notifier->start && entry_end <= notifier->end); > > +if (notifier->notifier_flags & IOMMU_NOTIFIER_ARBITRARY_MASK) { > > +tmp.iova = MAX(tmp.iova, notifier->start); > > +tmp.addr_mask =

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-27 Thread Yan Zhao
On Fri, Jun 26, 2020 at 05:29:17PM -0400, Peter Xu wrote: > Hi, Eugenio, > > (CCing Eric, Yan and Michael too) > On Fri, Jun 26, 2020 at 08:41:22AM +0200, Eugenio Pérez wrote: > > diff --git a/memory.c b/memory.c > > index 2f15a4b250..7f789710d2 100644 > > --- a/memory.c > > +++ b/memory.c > >

Re: [RFC v2 1/1] memory: Delete assertion in memory_region_unregister_iommu_notifier

2020-06-26 Thread Peter Xu
Hi, Eugenio, (CCing Eric, Yan and Michael too) On Fri, Jun 26, 2020 at 08:41:22AM +0200, Eugenio Pérez wrote: > diff --git a/memory.c b/memory.c > index 2f15a4b250..7f789710d2 100644 > --- a/memory.c > +++ b/memory.c > @@ -1915,8 +1915,6 @@ void memory_region_notify_one(IOMMUNotifier *notifier,