All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: Fix handling of pci use accessor return codes
@ 2021-01-24 15:35 Heiner Kallweit
  2021-01-25 18:11 ` Cornelia Huck
  2021-02-02 17:22 ` Alex Williamson
  0 siblings, 2 replies; 4+ messages in thread
From: Heiner Kallweit @ 2021-01-24 15:35 UTC (permalink / raw)
  To: Cornelia Huck, Alex Williamson; +Cc: kvm

The pci user accessors return negative errno's on error.

Fixes: f572a960a15e ("vfio/pci: Intel IGD host and LCP bridge config space access")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/vfio/pci/vfio_pci_igd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
index 53d97f459..e66dfb017 100644
--- a/drivers/vfio/pci/vfio_pci_igd.c
+++ b/drivers/vfio/pci/vfio_pci_igd.c
@@ -127,7 +127,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
 
 		ret = pci_user_read_config_byte(pdev, pos, &val);
 		if (ret)
-			return pcibios_err_to_errno(ret);
+			return ret;
 
 		if (copy_to_user(buf + count - size, &val, 1))
 			return -EFAULT;
@@ -141,7 +141,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
 
 		ret = pci_user_read_config_word(pdev, pos, &val);
 		if (ret)
-			return pcibios_err_to_errno(ret);
+			return ret;
 
 		val = cpu_to_le16(val);
 		if (copy_to_user(buf + count - size, &val, 2))
@@ -156,7 +156,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
 
 		ret = pci_user_read_config_dword(pdev, pos, &val);
 		if (ret)
-			return pcibios_err_to_errno(ret);
+			return ret;
 
 		val = cpu_to_le32(val);
 		if (copy_to_user(buf + count - size, &val, 4))
@@ -171,7 +171,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
 
 		ret = pci_user_read_config_word(pdev, pos, &val);
 		if (ret)
-			return pcibios_err_to_errno(ret);
+			return ret;
 
 		val = cpu_to_le16(val);
 		if (copy_to_user(buf + count - size, &val, 2))
@@ -186,7 +186,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
 
 		ret = pci_user_read_config_byte(pdev, pos, &val);
 		if (ret)
-			return pcibios_err_to_errno(ret);
+			return ret;
 
 		if (copy_to_user(buf + count - size, &val, 1))
 			return -EFAULT;
-- 
2.30.0


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

* Re: [PATCH] vfio/pci: Fix handling of pci use accessor return codes
  2021-01-24 15:35 [PATCH] vfio/pci: Fix handling of pci use accessor return codes Heiner Kallweit
@ 2021-01-25 18:11 ` Cornelia Huck
  2021-01-25 20:06   ` Heiner Kallweit
  2021-02-02 17:22 ` Alex Williamson
  1 sibling, 1 reply; 4+ messages in thread
From: Cornelia Huck @ 2021-01-25 18:11 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: Alex Williamson, kvm

On Sun, 24 Jan 2021 16:35:41 +0100
Heiner Kallweit <hkallweit1@gmail.com> wrote:

> The pci user accessors return negative errno's on error.
> 
> Fixes: f572a960a15e ("vfio/pci: Intel IGD host and LCP bridge config space access")
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/vfio/pci/vfio_pci_igd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
> index 53d97f459..e66dfb017 100644
> --- a/drivers/vfio/pci/vfio_pci_igd.c
> +++ b/drivers/vfio/pci/vfio_pci_igd.c
> @@ -127,7 +127,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
>  
>  		ret = pci_user_read_config_byte(pdev, pos, &val);
>  		if (ret)
> -			return pcibios_err_to_errno(ret);
> +			return ret;

This is actually not strictly needed, as pcibios_err_to_errno() already
keeps errors <= 0 unchanged, so more a cleanup than a fix?

Anyway,

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

>  
>  		if (copy_to_user(buf + count - size, &val, 1))
>  			return -EFAULT;


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

* Re: [PATCH] vfio/pci: Fix handling of pci use accessor return codes
  2021-01-25 18:11 ` Cornelia Huck
@ 2021-01-25 20:06   ` Heiner Kallweit
  0 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2021-01-25 20:06 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: Alex Williamson, kvm

On 25.01.2021 19:11, Cornelia Huck wrote:
> On Sun, 24 Jan 2021 16:35:41 +0100
> Heiner Kallweit <hkallweit1@gmail.com> wrote:
> 
>> The pci user accessors return negative errno's on error.
>>
>> Fixes: f572a960a15e ("vfio/pci: Intel IGD host and LCP bridge config space access")
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>>  drivers/vfio/pci/vfio_pci_igd.c | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
>> index 53d97f459..e66dfb017 100644
>> --- a/drivers/vfio/pci/vfio_pci_igd.c
>> +++ b/drivers/vfio/pci/vfio_pci_igd.c
>> @@ -127,7 +127,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
>>  
>>  		ret = pci_user_read_config_byte(pdev, pos, &val);
>>  		if (ret)
>> -			return pcibios_err_to_errno(ret);
>> +			return ret;
> 
> This is actually not strictly needed, as pcibios_err_to_errno() already
> keeps errors <= 0 unchanged, so more a cleanup than a fix?
> 
I agree. Although I'd argue that the author of the original commit missed
the fact the the user accessors return errno's, and the code just works
by chance, because of the "good will" of pcibios_err_to_errno().
So up to you whether it's worth it to apply this change also to stable.

> Anyway,
> 
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> 
>>  
>>  		if (copy_to_user(buf + count - size, &val, 1))
>>  			return -EFAULT;
> 


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

* Re: [PATCH] vfio/pci: Fix handling of pci use accessor return codes
  2021-01-24 15:35 [PATCH] vfio/pci: Fix handling of pci use accessor return codes Heiner Kallweit
  2021-01-25 18:11 ` Cornelia Huck
@ 2021-02-02 17:22 ` Alex Williamson
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Williamson @ 2021-02-02 17:22 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: Cornelia Huck, kvm

On Sun, 24 Jan 2021 16:35:41 +0100
Heiner Kallweit <hkallweit1@gmail.com> wrote:

> The pci user accessors return negative errno's on error.
> 
> Fixes: f572a960a15e ("vfio/pci: Intel IGD host and LCP bridge config space access")
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/vfio/pci/vfio_pci_igd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Applied to vfio next branch for v5.12 w/ Connie's R-b.  I did drop the
fixes tag since pcibios_err_to_errno() has always handled -errno
correctly to avoid the unnecessary churn.  Thanks,

Alex

> 
> diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
> index 53d97f459..e66dfb017 100644
> --- a/drivers/vfio/pci/vfio_pci_igd.c
> +++ b/drivers/vfio/pci/vfio_pci_igd.c
> @@ -127,7 +127,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
>  
>  		ret = pci_user_read_config_byte(pdev, pos, &val);
>  		if (ret)
> -			return pcibios_err_to_errno(ret);
> +			return ret;
>  
>  		if (copy_to_user(buf + count - size, &val, 1))
>  			return -EFAULT;
> @@ -141,7 +141,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
>  
>  		ret = pci_user_read_config_word(pdev, pos, &val);
>  		if (ret)
> -			return pcibios_err_to_errno(ret);
> +			return ret;
>  
>  		val = cpu_to_le16(val);
>  		if (copy_to_user(buf + count - size, &val, 2))
> @@ -156,7 +156,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
>  
>  		ret = pci_user_read_config_dword(pdev, pos, &val);
>  		if (ret)
> -			return pcibios_err_to_errno(ret);
> +			return ret;
>  
>  		val = cpu_to_le32(val);
>  		if (copy_to_user(buf + count - size, &val, 4))
> @@ -171,7 +171,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
>  
>  		ret = pci_user_read_config_word(pdev, pos, &val);
>  		if (ret)
> -			return pcibios_err_to_errno(ret);
> +			return ret;
>  
>  		val = cpu_to_le16(val);
>  		if (copy_to_user(buf + count - size, &val, 2))
> @@ -186,7 +186,7 @@ static size_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev,
>  
>  		ret = pci_user_read_config_byte(pdev, pos, &val);
>  		if (ret)
> -			return pcibios_err_to_errno(ret);
> +			return ret;
>  
>  		if (copy_to_user(buf + count - size, &val, 1))
>  			return -EFAULT;


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

end of thread, other threads:[~2021-02-02 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-24 15:35 [PATCH] vfio/pci: Fix handling of pci use accessor return codes Heiner Kallweit
2021-01-25 18:11 ` Cornelia Huck
2021-01-25 20:06   ` Heiner Kallweit
2021-02-02 17:22 ` Alex Williamson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.