Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1543363 > unrolled thread

[PATCH 04/13] vfio-pci: use 32-bit comparisons for register address for gcc-4.5

Started byArnd Bergmann <arnd@arndb.de>
First post2016-12-16 12:00 +0100
Last post2016-12-16 21:00 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 04/13] vfio-pci: use 32-bit comparisons for register address for gcc-4.5 Arnd Bergmann <arnd@arndb.de> - 2016-12-16 12:00 +0100
    Re: [PATCH 04/13] vfio-pci: use 32-bit comparisons for register  address for gcc-4.5 Alex Williamson <alex.williamson@redhat.com> - 2016-12-16 16:40 +0100
      Re: [PATCH 04/13] vfio-pci: use 32-bit comparisons for register address for gcc-4.5 Arnd Bergmann <arnd@arndb.de> - 2016-12-16 21:00 +0100

#1543363 — [PATCH 04/13] vfio-pci: use 32-bit comparisons for register address for gcc-4.5

FromArnd Bergmann <arnd@arndb.de>
Date2016-12-16 12:00 +0100
Subject[PATCH 04/13] vfio-pci: use 32-bit comparisons for register address for gcc-4.5
Message-ID<sOYp4-2rU-25@gated-at.bofh.it>
Using ancient compilers (gcc-4.5 or older) on ARM, we get a link
failure with the vfio-pci driver:

ERROR: "__aeabi_lcmp" [drivers/vfio/pci/vfio-pci.ko] undefined!

The reason is that the compiler tries to do a comparison of
a 64-bit range. This changes it to convert to a 32-bit number
explicitly first, as newer compilers do for themselves.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/vfio/pci/vfio_pci_rdwr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
index 5ffd1d9ad4bd..357243d76f10 100644
--- a/drivers/vfio/pci/vfio_pci_rdwr.c
+++ b/drivers/vfio/pci/vfio_pci_rdwr.c
@@ -193,7 +193,10 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf,
 	if (!vdev->has_vga)
 		return -EINVAL;
 
-	switch (pos) {
+	if (pos > 0xbfffful)
+		return -EINVAL;
+
+	switch ((u32)pos) {
 	case 0xa0000 ... 0xbffff:
 		count = min(count, (size_t)(0xc0000 - pos));
 		iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1);
-- 
2.9.0

[toc] | [next] | [standalone]


#1543528 — Re: [PATCH 04/13] vfio-pci: use 32-bit comparisons for register address for gcc-4.5

FromAlex Williamson <alex.williamson@redhat.com>
Date2016-12-16 16:40 +0100
SubjectRe: [PATCH 04/13] vfio-pci: use 32-bit comparisons for register address for gcc-4.5
Message-ID<sP2M1-5uf-9@gated-at.bofh.it>
In reply to#1543363
On Fri, 16 Dec 2016 11:56:25 +0100
Arnd Bergmann <arnd@arndb.de> wrote:

> Using ancient compilers (gcc-4.5 or older) on ARM, we get a link
> failure with the vfio-pci driver:
> 
> ERROR: "__aeabi_lcmp" [drivers/vfio/pci/vfio-pci.ko] undefined!
> 
> The reason is that the compiler tries to do a comparison of
> a 64-bit range. This changes it to convert to a 32-bit number
> explicitly first, as newer compilers do for themselves.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/vfio/pci/vfio_pci_rdwr.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
> index 5ffd1d9ad4bd..357243d76f10 100644
> --- a/drivers/vfio/pci/vfio_pci_rdwr.c
> +++ b/drivers/vfio/pci/vfio_pci_rdwr.c
> @@ -193,7 +193,10 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf,
>  	if (!vdev->has_vga)
>  		return -EINVAL;
>  
> -	switch (pos) {
> +	if (pos > 0xbfffful)
> +		return -EINVAL;
> +
> +	switch ((u32)pos) {
>  	case 0xa0000 ... 0xbffff:
>  		count = min(count, (size_t)(0xc0000 - pos));
>  		iomem = ioremap_nocache(0xa0000, 0xbffff - 0xa0000 + 1);

Acked-by: Alex Williamson <alex.williamson@redhat.com>

Would you like me to pull this one patch in through the vfio tree?
Thanks,

Alex

[toc] | [prev] | [next] | [standalone]


#1543721

FromArnd Bergmann <arnd@arndb.de>
Date2016-12-16 21:00 +0100
Message-ID<sP6PE-7WR-3@gated-at.bofh.it>
In reply to#1543528
On Friday, December 16, 2016 8:30:56 AM CET Alex Williamson wrote:
> 
> Acked-by: Alex Williamson <alex.williamson@redhat.com>
> 
> Would you like me to pull this one patch in through the vfio tree?
> Thanks,

If you think the patch is appropriate, please merge it.

I originally just posted this as illustration to raise the
question of whether we actually want to support gcc-4.5,
from the feedback so far it does seem like the answer is yes,
and we will need it.

	Arnd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web