linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/type1: Initialize resv_msi_base
@ 2019-10-15 15:16 Joerg Roedel
  2019-10-15 15:49 ` Auger Eric
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joerg Roedel @ 2019-10-15 15:16 UTC (permalink / raw)
  To: Alex Williamson; +Cc: Cornelia Huck, kvm, linux-kernel, Joerg Roedel

From: Joerg Roedel <jroedel@suse.de>

After enabling CONFIG_IOMMU_DMA on X86 a new warning appears when
compiling vfio:

drivers/vfio/vfio_iommu_type1.c: In function ‘vfio_iommu_type1_attach_group’:
drivers/vfio/vfio_iommu_type1.c:1827:7: warning: ‘resv_msi_base’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   ret = iommu_get_msi_cookie(domain->domain, resv_msi_base);
   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The warning is a false positive, because the call to iommu_get_msi_cookie()
only happens when vfio_iommu_has_sw_msi() returned true. And that only
happens when it also set resv_msi_base.

But initialize the variable anyway to get rid of the warning.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/vfio/vfio_iommu_type1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 96fddc1dafc3..d864277ea16f 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1658,7 +1658,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
 	struct bus_type *bus = NULL;
 	int ret;
 	bool resv_msi, msi_remap;
-	phys_addr_t resv_msi_base;
+	phys_addr_t resv_msi_base = 0;
 	struct iommu_domain_geometry geo;
 	LIST_HEAD(iova_copy);
 	LIST_HEAD(group_resv_regions);
-- 
2.16.4


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

* Re: [PATCH] vfio/type1: Initialize resv_msi_base
  2019-10-15 15:16 [PATCH] vfio/type1: Initialize resv_msi_base Joerg Roedel
@ 2019-10-15 15:49 ` Auger Eric
  2019-10-15 16:03 ` Cornelia Huck
  2019-10-18 14:57 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Auger Eric @ 2019-10-15 15:49 UTC (permalink / raw)
  To: Joerg Roedel, Alex Williamson
  Cc: Cornelia Huck, kvm, linux-kernel, Joerg Roedel

Hi Joerg,

On 10/15/19 5:16 PM, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> After enabling CONFIG_IOMMU_DMA on X86 a new warning appears when
> compiling vfio:
> 
> drivers/vfio/vfio_iommu_type1.c: In function ‘vfio_iommu_type1_attach_group’:
> drivers/vfio/vfio_iommu_type1.c:1827:7: warning: ‘resv_msi_base’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    ret = iommu_get_msi_cookie(domain->domain, resv_msi_base);
>    ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> The warning is a false positive, because the call to iommu_get_msi_cookie()
> only happens when vfio_iommu_has_sw_msi() returned true. And that only
> happens when it also set resv_msi_base.
> 
> But initialize the variable anyway to get rid of the warning.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 96fddc1dafc3..d864277ea16f 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -1658,7 +1658,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
>  	struct bus_type *bus = NULL;
>  	int ret;
>  	bool resv_msi, msi_remap;
> -	phys_addr_t resv_msi_base;
> +	phys_addr_t resv_msi_base = 0;
>  	struct iommu_domain_geometry geo;
>  	LIST_HEAD(iova_copy);
>  	LIST_HEAD(group_resv_regions);
> 
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric

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

* Re: [PATCH] vfio/type1: Initialize resv_msi_base
  2019-10-15 15:16 [PATCH] vfio/type1: Initialize resv_msi_base Joerg Roedel
  2019-10-15 15:49 ` Auger Eric
@ 2019-10-15 16:03 ` Cornelia Huck
  2019-10-18 14:57 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2019-10-15 16:03 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Alex Williamson, kvm, linux-kernel, Joerg Roedel

On Tue, 15 Oct 2019 17:16:50 +0200
Joerg Roedel <joro@8bytes.org> wrote:

> From: Joerg Roedel <jroedel@suse.de>
> 
> After enabling CONFIG_IOMMU_DMA on X86 a new warning appears when
> compiling vfio:
> 
> drivers/vfio/vfio_iommu_type1.c: In function ‘vfio_iommu_type1_attach_group’:
> drivers/vfio/vfio_iommu_type1.c:1827:7: warning: ‘resv_msi_base’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    ret = iommu_get_msi_cookie(domain->domain, resv_msi_base);
>    ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> The warning is a false positive, because the call to iommu_get_msi_cookie()
> only happens when vfio_iommu_has_sw_msi() returned true. And that only
> happens when it also set resv_msi_base.
> 
> But initialize the variable anyway to get rid of the warning.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 96fddc1dafc3..d864277ea16f 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -1658,7 +1658,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
>  	struct bus_type *bus = NULL;
>  	int ret;
>  	bool resv_msi, msi_remap;
> -	phys_addr_t resv_msi_base;
> +	phys_addr_t resv_msi_base = 0;
>  	struct iommu_domain_geometry geo;
>  	LIST_HEAD(iova_copy);
>  	LIST_HEAD(group_resv_regions);

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

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

* Re: [PATCH] vfio/type1: Initialize resv_msi_base
  2019-10-15 15:16 [PATCH] vfio/type1: Initialize resv_msi_base Joerg Roedel
  2019-10-15 15:49 ` Auger Eric
  2019-10-15 16:03 ` Cornelia Huck
@ 2019-10-18 14:57 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Williamson @ 2019-10-18 14:57 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Cornelia Huck, kvm, linux-kernel, Joerg Roedel

On Tue, 15 Oct 2019 17:16:50 +0200
Joerg Roedel <joro@8bytes.org> wrote:

> From: Joerg Roedel <jroedel@suse.de>
> 
> After enabling CONFIG_IOMMU_DMA on X86 a new warning appears when
> compiling vfio:
> 
> drivers/vfio/vfio_iommu_type1.c: In function ‘vfio_iommu_type1_attach_group’:
> drivers/vfio/vfio_iommu_type1.c:1827:7: warning: ‘resv_msi_base’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    ret = iommu_get_msi_cookie(domain->domain, resv_msi_base);
>    ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> The warning is a false positive, because the call to iommu_get_msi_cookie()
> only happens when vfio_iommu_has_sw_msi() returned true. And that only
> happens when it also set resv_msi_base.
> 
> But initialize the variable anyway to get rid of the warning.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 96fddc1dafc3..d864277ea16f 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -1658,7 +1658,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
>  	struct bus_type *bus = NULL;
>  	int ret;
>  	bool resv_msi, msi_remap;
> -	phys_addr_t resv_msi_base;
> +	phys_addr_t resv_msi_base = 0;
>  	struct iommu_domain_geometry geo;
>  	LIST_HEAD(iova_copy);
>  	LIST_HEAD(group_resv_regions);

Thanks Joerg!  Added to vfio for-linus branch with Connie and Eric's
reviews for v5.4.  Thanks,

Alex

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

end of thread, other threads:[~2019-10-18 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 15:16 [PATCH] vfio/type1: Initialize resv_msi_base Joerg Roedel
2019-10-15 15:49 ` Auger Eric
2019-10-15 16:03 ` Cornelia Huck
2019-10-18 14:57 ` Alex Williamson

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).