iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] iommu/vt-d: Fix pointer cast warnings on 32 bit
@ 2020-05-19  1:34 Lu Baolu
  2020-05-19 12:09 ` Joerg Roedel
  0 siblings, 1 reply; 3+ messages in thread
From: Lu Baolu @ 2020-05-19  1:34 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu

Pointers should be casted to unsigned long to avoid "cast from pointer
to integer of different size" warnings.

drivers/iommu/intel-pasid.c:818:6: warning:
    cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/iommu/intel-pasid.c:821:9: warning:
    cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/iommu/intel-pasid.c:824:23: warning:
    cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/iommu/intel-svm.c:343:45: warning:
    cast to pointer from integer of different size [-Wint-to-pointer-cast]

Fixes: d64d47f4f5678 ("iommu/vt-d: Add nested translation helper function")
Fixes: a3bea1a35c083 ("iommu/vt-d: Add bind guest PASID support")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/iommu/intel-pasid.c | 8 ++++----
 drivers/iommu/intel-svm.c   | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/intel-pasid.c b/drivers/iommu/intel-pasid.c
index 25d749830500..c81f0f17c6ba 100644
--- a/drivers/iommu/intel-pasid.c
+++ b/drivers/iommu/intel-pasid.c
@@ -815,13 +815,13 @@ int intel_pasid_setup_nested(struct intel_iommu *iommu, struct device *dev,
 	}
 
 	/* First level PGD is in GPA, must be supported by the second level */
-	if ((unsigned long long)gpgd > domain->max_addr) {
+	if ((uintptr_t)gpgd > domain->max_addr) {
 		dev_err_ratelimited(dev,
-				    "Guest PGD %llx not supported, max %llx\n",
-				    (unsigned long long)gpgd, domain->max_addr);
+				    "Guest PGD %lx not supported, max %llx\n",
+				    (uintptr_t)gpgd, domain->max_addr);
 		return -EINVAL;
 	}
-	pasid_set_flptr(pte, (u64)gpgd);
+	pasid_set_flptr(pte, (uintptr_t)gpgd);
 
 	ret = intel_pasid_setup_bind_data(iommu, pte, pasid_data);
 	if (ret)
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index 11366dc91971..acc7555b002d 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -340,7 +340,8 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
 	 * call the nested mode setup function here.
 	 */
 	spin_lock(&iommu->lock);
-	ret = intel_pasid_setup_nested(iommu, dev, (pgd_t *)data->gpgd,
+	ret = intel_pasid_setup_nested(iommu, dev,
+				       (pgd_t *)(uintptr_t)data->gpgd,
 				       data->hpasid, &data->vtd, dmar_domain,
 				       data->addr_width);
 	spin_unlock(&iommu->lock);
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iommu/vt-d: Fix pointer cast warnings on 32 bit
  2020-05-19  1:34 [PATCH 1/1] iommu/vt-d: Fix pointer cast warnings on 32 bit Lu Baolu
@ 2020-05-19 12:09 ` Joerg Roedel
  2020-05-19 12:41   ` Lu Baolu
  0 siblings, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2020-05-19 12:09 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu

On Tue, May 19, 2020 at 09:34:23AM +0800, Lu Baolu wrote:
> Pointers should be casted to unsigned long to avoid "cast from pointer
> to integer of different size" warnings.
> 
> drivers/iommu/intel-pasid.c:818:6: warning:
>     cast from pointer to integer of different size [-Wpointer-to-int-cast]
> drivers/iommu/intel-pasid.c:821:9: warning:
>     cast from pointer to integer of different size [-Wpointer-to-int-cast]
> drivers/iommu/intel-pasid.c:824:23: warning:
>     cast from pointer to integer of different size [-Wpointer-to-int-cast]
> drivers/iommu/intel-svm.c:343:45: warning:
>     cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 
> Fixes: d64d47f4f5678 ("iommu/vt-d: Add nested translation helper function")
> Fixes: a3bea1a35c083 ("iommu/vt-d: Add bind guest PASID support")
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>  drivers/iommu/intel-pasid.c | 8 ++++----
>  drivers/iommu/intel-svm.c   | 3 ++-
>  2 files changed, 6 insertions(+), 5 deletions(-)

Applied, thanks.

Btw, I think the PASID and Intel SVM code is pretty useless on 32 bit
anyway, no? It only supports 4 and 5 level page-tables, not the 2 and
3-level variants on 32-bit. Can you make it 64-bit only?


Regards,

	Joerg

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iommu/vt-d: Fix pointer cast warnings on 32 bit
  2020-05-19 12:09 ` Joerg Roedel
@ 2020-05-19 12:41   ` Lu Baolu
  0 siblings, 0 replies; 3+ messages in thread
From: Lu Baolu @ 2020-05-19 12:41 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu

On 2020/5/19 20:09, Joerg Roedel wrote:
> On Tue, May 19, 2020 at 09:34:23AM +0800, Lu Baolu wrote:
>> Pointers should be casted to unsigned long to avoid "cast from pointer
>> to integer of different size" warnings.
>>
>> drivers/iommu/intel-pasid.c:818:6: warning:
>>      cast from pointer to integer of different size [-Wpointer-to-int-cast]
>> drivers/iommu/intel-pasid.c:821:9: warning:
>>      cast from pointer to integer of different size [-Wpointer-to-int-cast]
>> drivers/iommu/intel-pasid.c:824:23: warning:
>>      cast from pointer to integer of different size [-Wpointer-to-int-cast]
>> drivers/iommu/intel-svm.c:343:45: warning:
>>      cast to pointer from integer of different size [-Wint-to-pointer-cast]
>>
>> Fixes: d64d47f4f5678 ("iommu/vt-d: Add nested translation helper function")
>> Fixes: a3bea1a35c083 ("iommu/vt-d: Add bind guest PASID support")
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> ---
>>   drivers/iommu/intel-pasid.c | 8 ++++----
>>   drivers/iommu/intel-svm.c   | 3 ++-
>>   2 files changed, 6 insertions(+), 5 deletions(-)
> 
> Applied, thanks.
> 
> Btw, I think the PASID and Intel SVM code is pretty useless on 32 bit
> anyway, no? It only supports 4 and 5 level page-tables, not the 2 and
> 3-level variants on 32-bit. Can you make it 64-bit only?

Sure. I will make it.

Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-19 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19  1:34 [PATCH 1/1] iommu/vt-d: Fix pointer cast warnings on 32 bit Lu Baolu
2020-05-19 12:09 ` Joerg Roedel
2020-05-19 12:41   ` Lu Baolu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).