public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tom Lyon <pugs@cisco.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org
Subject: Re: [PATCH] vfio: fix config virtualization, esp command byte
Date: Tue, 16 Nov 2010 21:14:50 -0800	[thread overview]
Message-ID: <201011162114.50954.pugs@cisco.com> (raw)
In-Reply-To: <1289933847.3069.8.camel@x201>

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

      reply	other threads:[~2010-11-17  5:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-10  1:09 [PATCH] vfio: fix config virtualization, esp command byte Tom Lyon
2010-11-16 17:54 ` Alex Williamson
2010-11-16 18:57   ` Alex Williamson
2010-11-17  5:14     ` Tom Lyon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201011162114.50954.pugs@cisco.com \
    --to=pugs@cisco.com \
    --cc=alex.williamson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox