lkml.org 
[lkml]   [2010]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] vfio: fix config virtualization, esp command byte
Date
Applied.

On Tuesday, November 16, 2010 10:57:27 am Alex Williamson wrote:
> On Tue, 2010-11-16 at 10:54 -0700, Alex Williamson wrote:
> > On Tue, 2010-11-09 at 17:09 -0800, Tom Lyon wrote:
> > > Cleans up config space virtualization, especialy handling of bytes
> > > which have some virtual and some real bits, like PCI_COMMAND.
> > >
> > > Alex, I hope you can test this with your setups.
> >
> > Sorry for the delay. FWIW, I'm not having much luck with this, I'll try
> > to debug the problem. Thanks,
>
> This seems to be the bug. Thanks,
>
> Alex
>
> vfio: Don't write random bits on read
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>
> diff --git a/drivers/vfio/vfio_pci_config.c
> b/drivers/vfio/vfio_pci_config.c index 7132ac4..422d7b1 100644
> --- a/drivers/vfio/vfio_pci_config.c
> +++ b/drivers/vfio/vfio_pci_config.c
> @@ -964,11 +964,6 @@ static int vfio_config_rwbyte(int write,
> return 0;
> }
>
> - if (write) {
> - if (copy_from_user(&newval, buf, 1))
> - return -EFAULT;
> - }
> -
> if (~virt) { /* mix of real and virt bits */
> /* update vconfig with latest hw bits */
> ret = vfio_read_config_byte(vdev, pos, &realbits);
> @@ -978,9 +973,14 @@ static int vfio_config_rwbyte(int write,
> (vdev->vconfig[pos] & virt) | (realbits & ~virt);
> }
>
> - /* update vconfig with writeable bits */
> - vdev->vconfig[pos] =
> - (vdev->vconfig[pos] & ~wr) | (newval & wr);
> + if (write) {
> + if (copy_from_user(&newval, buf, 1))
> + return -EFAULT;
> +
> + /* update vconfig with writeable bits */
> + vdev->vconfig[pos] =
> + (vdev->vconfig[pos] & ~wr) | (newval & wr);
> + }
>
> /*
> * Now massage virtual fields


\
 
 \ /
  Last update: 2010-11-17 06:17    [W:0.041 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site