* [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
@ 2023-04-26 20:32 Jon Pan-Doh
2023-04-26 21:04 ` Nadav Amit
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Jon Pan-Doh @ 2023-04-26 20:32 UTC (permalink / raw)
To: Joerg Roedel, Suravee Suthikulpanit
Cc: Will Deacon, Robin Murphy, Nadav Amit, iommu, linux-kernel,
Jon Pan-Doh, Sudheer Dantuluri, Gary Zibrat
When running on an AMD vIOMMU, we observed multiple invalidations (of
decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However,
gather->end is defined as the last inclusive address (start + size - 1).
This leads to an off by 1 error.
With this patch, verified that 1 invalidation occurs when unmapping a
single page.
Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")
Signed-off-by: Jon Pan-Doh <pandoh@google.com>
Tested-by: Sudheer Dantuluri <dantuluris@google.com>
Suggested-by: Gary Zibrat <gzibrat@google.com>
---
drivers/iommu/amd/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 5a505ba5467e..da45b1ab042d 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2378,7 +2378,7 @@ static void amd_iommu_iotlb_sync(struct iommu_domain *domain,
unsigned long flags;
spin_lock_irqsave(&dom->lock, flags);
- domain_flush_pages(dom, gather->start, gather->end - gather->start, 1);
+ domain_flush_pages(dom, gather->start, gather->end - gather->start + 1, 1);
amd_iommu_domain_flush_complete(dom);
spin_unlock_irqrestore(&dom->lock, flags);
}
--
2.40.0.634.g4ca3ef3211-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-04-26 20:32 [PATCH] iommu/amd: Fix domain flush size when syncing iotlb Jon Pan-Doh
@ 2023-04-26 21:04 ` Nadav Amit
2023-04-26 21:22 ` Nadav Amit
2023-04-28 5:20 ` Vasant Hegde
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Nadav Amit @ 2023-04-26 21:04 UTC (permalink / raw)
To: Jon Pan-Doh
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Sudheer Dantuluri, Gary Zibrat
> On Apr 26, 2023, at 1:32 PM, Jon Pan-Doh <pandoh@google.com> wrote:
>
> When running on an AMD vIOMMU, we observed multiple invalidations (of
> decreasing power of 2 aligned sizes) when unmapping a single page.
>
> Domain flush takes gather bounds (end-start) as size param. However,
> gather->end is defined as the last inclusive address (start + size - 1).
> This leads to an off by 1 error.
>
> With this patch, verified that 1 invalidation occurs when unmapping a
> single page.
>
> Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")
> Signed-off-by: Jon Pan-Doh <pandoh@google.com>
> Tested-by: Sudheer Dantuluri <dantuluris@google.com>
> Suggested-by: Gary Zibrat <gzibrat@google.com>
>
Sorry for that.
Acked-by: Nadav Amit <namit@vmware.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-04-26 21:04 ` Nadav Amit
@ 2023-04-26 21:22 ` Nadav Amit
0 siblings, 0 replies; 12+ messages in thread
From: Nadav Amit @ 2023-04-26 21:22 UTC (permalink / raw)
To: Jon Pan-Doh
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Sudheer Dantuluri, Gary Zibrat
> On Apr 26, 2023, at 2:04 PM, Nadav Amit <namit@vmware.com> wrote:
>
>
>
>> On Apr 26, 2023, at 1:32 PM, Jon Pan-Doh <pandoh@google.com> wrote:
>>
>> When running on an AMD vIOMMU, we observed multiple invalidations (of
>> decreasing power of 2 aligned sizes) when unmapping a single page.
>>
>> Domain flush takes gather bounds (end-start) as size param. However,
>> gather->end is defined as the last inclusive address (start + size - 1).
>> This leads to an off by 1 error.
>>
>> With this patch, verified that 1 invalidation occurs when unmapping a
>> single page.
>>
>> Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")
>> Signed-off-by: Jon Pan-Doh <pandoh@google.com>
>> Tested-by: Sudheer Dantuluri <dantuluris@google.com>
>> Suggested-by: Gary Zibrat <gzibrat@google.com>
>>
>
> Sorry for that.
>
> Acked-by: Nadav Amit <namit@vmware.com>
P.S. I think it is stable-worthy.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-04-26 20:32 [PATCH] iommu/amd: Fix domain flush size when syncing iotlb Jon Pan-Doh
2023-04-26 21:04 ` Nadav Amit
@ 2023-04-28 5:20 ` Vasant Hegde
2023-05-16 20:59 ` Jon Pan-Doh
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Vasant Hegde @ 2023-04-28 5:20 UTC (permalink / raw)
To: Jon Pan-Doh, Joerg Roedel, Suravee Suthikulpanit
Cc: Will Deacon, Robin Murphy, Nadav Amit, iommu, linux-kernel,
Sudheer Dantuluri, Gary Zibrat
On 4/27/2023 2:02 AM, Jon Pan-Doh wrote:
> When running on an AMD vIOMMU, we observed multiple invalidations (of
> decreasing power of 2 aligned sizes) when unmapping a single page.
>
> Domain flush takes gather bounds (end-start) as size param. However,
> gather->end is defined as the last inclusive address (start + size - 1).
> This leads to an off by 1 error.
>
> With this patch, verified that 1 invalidation occurs when unmapping a
> single page.
>
> Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")
> Signed-off-by: Jon Pan-Doh <pandoh@google.com>
> Tested-by: Sudheer Dantuluri <dantuluris@google.com>
> Suggested-by: Gary Zibrat <gzibrat@google.com>
Thanks!
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
> ---
> drivers/iommu/amd/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 5a505ba5467e..da45b1ab042d 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2378,7 +2378,7 @@ static void amd_iommu_iotlb_sync(struct iommu_domain *domain,
> unsigned long flags;
>
> spin_lock_irqsave(&dom->lock, flags);
> - domain_flush_pages(dom, gather->start, gather->end - gather->start, 1);
> + domain_flush_pages(dom, gather->start, gather->end - gather->start + 1, 1);
> amd_iommu_domain_flush_complete(dom);
> spin_unlock_irqrestore(&dom->lock, flags);
> }
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
@ 2023-05-05 1:43 Jon Pan-Doh
0 siblings, 0 replies; 12+ messages in thread
From: Jon Pan-Doh @ 2023-05-05 1:43 UTC (permalink / raw)
To: Jon Pan-Doh
Cc: Sudheer Dantuluri, Gary Zibrat, iommu, joro, linux-kernel, namit,
robin.murphy, Suthikulpanit, Suravee, will, stable
Cc'ing stable@vger.kernel.org per Nadav's suggestion.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-04-26 20:32 [PATCH] iommu/amd: Fix domain flush size when syncing iotlb Jon Pan-Doh
2023-04-26 21:04 ` Nadav Amit
2023-04-28 5:20 ` Vasant Hegde
@ 2023-05-16 20:59 ` Jon Pan-Doh
2023-05-17 4:38 ` Greg KH
2023-05-17 5:49 ` Jon Pan-Doh
2023-05-22 15:34 ` Joerg Roedel
4 siblings, 1 reply; 12+ messages in thread
From: Jon Pan-Doh @ 2023-05-16 20:59 UTC (permalink / raw)
To: Joerg Roedel
Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, Nadav Amit,
iommu, linux-kernel, Sudheer Dantuluri, Gary Zibrat, stable
Hi Joerg,
[Cc'ing stable@vger.kernel.org per Nadav's suggestion]
This bug fix seems to have gotten the necessary reviews (AMD and
previous commit author). Is it eligible to be applied?
Thanks,
Jon
On Wed, Apr 26, 2023 at 1:32 PM Jon Pan-Doh <pandoh@google.com> wrote:
>
> When running on an AMD vIOMMU, we observed multiple invalidations (of
> decreasing power of 2 aligned sizes) when unmapping a single page.
>
> Domain flush takes gather bounds (end-start) as size param. However,
> gather->end is defined as the last inclusive address (start + size - 1).
> This leads to an off by 1 error.
>
> With this patch, verified that 1 invalidation occurs when unmapping a
> single page.
>
> Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")
> Signed-off-by: Jon Pan-Doh <pandoh@google.com>
> Tested-by: Sudheer Dantuluri <dantuluris@google.com>
> Suggested-by: Gary Zibrat <gzibrat@google.com>
> ---
> drivers/iommu/amd/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 5a505ba5467e..da45b1ab042d 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2378,7 +2378,7 @@ static void amd_iommu_iotlb_sync(struct iommu_domain *domain,
> unsigned long flags;
>
> spin_lock_irqsave(&dom->lock, flags);
> - domain_flush_pages(dom, gather->start, gather->end - gather->start, 1);
> + domain_flush_pages(dom, gather->start, gather->end - gather->start + 1, 1);
> amd_iommu_domain_flush_complete(dom);
> spin_unlock_irqrestore(&dom->lock, flags);
> }
> --
> 2.40.0.634.g4ca3ef3211-goog
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-05-16 20:59 ` Jon Pan-Doh
@ 2023-05-17 4:38 ` Greg KH
2023-05-17 5:54 ` Jon Pan-Doh
0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2023-05-17 4:38 UTC (permalink / raw)
To: Jon Pan-Doh
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
Nadav Amit, iommu, linux-kernel, Sudheer Dantuluri, Gary Zibrat,
stable
On Tue, May 16, 2023 at 01:59:16PM -0700, Jon Pan-Doh wrote:
> Hi Joerg,
>
> [Cc'ing stable@vger.kernel.org per Nadav's suggestion]
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-04-26 20:32 [PATCH] iommu/amd: Fix domain flush size when syncing iotlb Jon Pan-Doh
` (2 preceding siblings ...)
2023-05-16 20:59 ` Jon Pan-Doh
@ 2023-05-17 5:49 ` Jon Pan-Doh
2023-05-17 5:58 ` Nadav Amit
2023-05-22 15:34 ` Joerg Roedel
4 siblings, 1 reply; 12+ messages in thread
From: Jon Pan-Doh @ 2023-05-17 5:49 UTC (permalink / raw)
To: Joerg Roedel, Suravee Suthikulpanit
Cc: Will Deacon, Robin Murphy, Nadav Amit, iommu, linux-kernel,
Sudheer Dantuluri, Gary Zibrat
On Wed, Apr 26, 2023 at 1:32 PM Jon Pan-Doh <pandoh@google.com> wrote:
>
> When running on an AMD vIOMMU, we observed multiple invalidations (of
> decreasing power of 2 aligned sizes) when unmapping a single page.
>
> Domain flush takes gather bounds (end-start) as size param. However,
> gather->end is defined as the last inclusive address (start + size - 1).
> This leads to an off by 1 error.
>
> With this patch, verified that 1 invalidation occurs when unmapping a
> single page.
>
> Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")
> Signed-off-by: Jon Pan-Doh <pandoh@google.com>
> Tested-by: Sudheer Dantuluri <dantuluris@google.com>
> Suggested-by: Gary Zibrat <gzibrat@google.com>
Cc: stable@vger.kernel.org
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-05-17 4:38 ` Greg KH
@ 2023-05-17 5:54 ` Jon Pan-Doh
0 siblings, 0 replies; 12+ messages in thread
From: Jon Pan-Doh @ 2023-05-17 5:54 UTC (permalink / raw)
To: Greg KH
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
Nadav Amit, iommu, linux-kernel, Sudheer Dantuluri, Gary Zibrat
On Tue, May 16, 2023 at 9:38 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, May 16, 2023 at 01:59:16PM -0700, Jon Pan-Doh wrote:
> > Hi Joerg,
> >
> > [Cc'ing stable@vger.kernel.org per Nadav's suggestion]
>
> <formletter>
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read:
> https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
>
> </formletter>
Thanks for the link. Added the Cc tag as a reply to the patch.
Apologies for top-posting previously.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-05-17 5:49 ` Jon Pan-Doh
@ 2023-05-17 5:58 ` Nadav Amit
2023-05-18 2:05 ` Jon Pan-Doh
0 siblings, 1 reply; 12+ messages in thread
From: Nadav Amit @ 2023-05-17 5:58 UTC (permalink / raw)
To: Jon Pan-Doh
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Sudheer Dantuluri, Gary Zibrat
> On May 16, 2023, at 10:49 PM, Jon Pan-Doh <pandoh@google.com> wrote:
>
> !! External Email
>
> On Wed, Apr 26, 2023 at 1:32 PM Jon Pan-Doh <pandoh@google.com> wrote:
>>
>> When running on an AMD vIOMMU, we observed multiple invalidations (of
>> decreasing power of 2 aligned sizes) when unmapping a single page.
>>
>> Domain flush takes gather bounds (end-start) as size param. However,
>> gather->end is defined as the last inclusive address (start + size - 1).
>> This leads to an off by 1 error.
>>
>> With this patch, verified that 1 invalidation occurs when unmapping a
>> single page.
>>
>> Fixes: a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")
>> Signed-off-by: Jon Pan-Doh <pandoh@google.com>
>> Tested-by: Sudheer Dantuluri <dantuluris@google.com>
>> Suggested-by: Gary Zibrat <gzibrat@google.com>
>
> Cc: stable@vger.kernel.org
Assuming the patch was still not applied, I think that Greg KH would
prefer that you send v2 that includes the “Cc: <stable@vger.kernel.org>”
(notice the “<“ and “>" signs) and ideally the version in which I added
the buggy code (sorry for that again) after a “#” sign.
I think it is version 5.15.
IOW: If the patch was still not applied by Joerg, please send v2 with:
Cc: <stable@vger.kernel.org <mailto:stable@vger.kernel.org>> # 5.15.x
In the commit log.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-05-17 5:58 ` Nadav Amit
@ 2023-05-18 2:05 ` Jon Pan-Doh
0 siblings, 0 replies; 12+ messages in thread
From: Jon Pan-Doh @ 2023-05-18 2:05 UTC (permalink / raw)
To: Nadav Amit
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
Sudheer Dantuluri, Gary Zibrat
On Tue, May 16, 2023 at 10:58 PM Nadav Amit <namit@vmware.com> wrote:
> IOW: If the patch was still not applied by Joerg, please send v2 with:
>
> Cc: <stable@vger.kernel.org <mailto:stable@vger.kernel.org>> # 5.15.x
>
> In the commit log.
>
Thanks for the clarification/guidance. I've resent the patch for
review with added tags (Acked-by, Reviewed-by). Will re-read the patch
submission doc and try to avoid formatting issues in the future.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] iommu/amd: Fix domain flush size when syncing iotlb
2023-04-26 20:32 [PATCH] iommu/amd: Fix domain flush size when syncing iotlb Jon Pan-Doh
` (3 preceding siblings ...)
2023-05-17 5:49 ` Jon Pan-Doh
@ 2023-05-22 15:34 ` Joerg Roedel
4 siblings, 0 replies; 12+ messages in thread
From: Joerg Roedel @ 2023-05-22 15:34 UTC (permalink / raw)
To: Jon Pan-Doh
Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, Nadav Amit,
iommu, linux-kernel, Sudheer Dantuluri, Gary Zibrat
On Wed, Apr 26, 2023 at 01:32:56PM -0700, Jon Pan-Doh wrote:
> drivers/iommu/amd/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied for 6.4, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-05-22 15:34 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-26 20:32 [PATCH] iommu/amd: Fix domain flush size when syncing iotlb Jon Pan-Doh
2023-04-26 21:04 ` Nadav Amit
2023-04-26 21:22 ` Nadav Amit
2023-04-28 5:20 ` Vasant Hegde
2023-05-16 20:59 ` Jon Pan-Doh
2023-05-17 4:38 ` Greg KH
2023-05-17 5:54 ` Jon Pan-Doh
2023-05-17 5:49 ` Jon Pan-Doh
2023-05-17 5:58 ` Nadav Amit
2023-05-18 2:05 ` Jon Pan-Doh
2023-05-22 15:34 ` Joerg Roedel
-- strict thread matches above, loose matches on Subject: below --
2023-05-05 1:43 Jon Pan-Doh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox