public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Baron <jbaron@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	kvm@vger.kernel.org, Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	jan.kiszka@siemens.com
Subject: Re: [PATCH v2] kvm: Disable MSI/MSI-X in assigned device reset path
Date: Mon, 16 Apr 2012 12:12:52 -0400	[thread overview]
Message-ID: <20120416161252.GC2345@redhat.com> (raw)
In-Reply-To: <20120416150640.GB13713@redhat.com>

On Mon, Apr 16, 2012 at 06:06:40PM +0300, Michael S. Tsirkin wrote:
> On Mon, Apr 16, 2012 at 08:03:17AM -0600, Alex Williamson wrote:
> > The discussion on this patch seems to have fizzled, with no clear short
> > term solution.
> 
> I think we are in concensus, it's just that there are
> multiple bugs still left to fix.
> 
> First, we need to prevent guest from touching command
> register except for the bus master bit. Something like
> the below? Compiled only.
> 
> device-assignment: don't touch pci command register
> 
> Real command register is under kernel control:
> it includes bits for triggering SERR, marking
> BARs as invalid and such which are under host
> kernel control. Don't touch any except bus master
> which is ok to put under guest control.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> ---
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 89823f1..9ebce49 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -501,7 +501,6 @@ static int get_real_device(AssignedDevice *pci_dev, uint16_t r_seg,
>      FILE *f;
>      unsigned long long start, end, size, flags;
>      uint16_t id;
> -    struct stat statbuf;
>      PCIRegion *rp;
>      PCIDevRegions *dev = &pci_dev->real_device;
>  
> @@ -610,12 +609,8 @@ again:
>      pci_dev->dev.config[2] = id & 0xff;
>      pci_dev->dev.config[3] = (id & 0xff00) >> 8;
>  
> -    /* dealing with virtual function device */
> -    snprintf(name, sizeof(name), "%sphysfn/", dir);
> -    if (!stat(name, &statbuf)) {
> -        /* always provide the written value on readout */
> -        assigned_dev_emulate_config_read(pci_dev, PCI_COMMAND, 2);
> -    }
> +    /* Pass bus master writes to device. */
> +    pci_dev->emulate_config_write[PCI_COMMAND] &= ~PCI_COMMAND_MASTER;
>  
>      dev->region_number = r;
>      return 0;
> @@ -782,14 +777,6 @@ static int assign_device(AssignedDevice *dev)
>                  "cause host memory corruption if the device issues DMA write "
>                  "requests!\n");
>      }
> -    if (dev->features & ASSIGNED_DEVICE_SHARE_INTX_MASK &&
> -        kvm_has_intx_set_mask()) {
> -        assigned_dev_data.flags |= KVM_DEV_ASSIGN_PCI_2_3;
> -
> -        /* hide host-side INTx masking from the guest */
> -        dev->emulate_config_read[PCI_COMMAND + 1] |=
> -            PCI_COMMAND_INTX_DISABLE >> 8;
> -    }
>  
>      r = kvm_assign_pci_device(kvm_state, &assigned_dev_data);
>      if (r < 0) {
> @@ -1631,10 +1618,10 @@ static void reset_assigned_device(DeviceState *dev)
>      }
>  
>      /*
> -     * When a 0 is written to the command register, the device is logically
> +     * When a 0 is written to the bus master register, the device is logically
>       * disconnected from the PCI bus. This avoids further DMA transfers.
>       */
> -    assigned_dev_pci_write_config(pci_dev, PCI_COMMAND, 0, 2);
> +    assigned_dev_pci_write_config(pci_dev, PCI_COMMAND, 0, 1);
>  }

This is still going to disable mmio, is the intent to just clear the bus
master bit, ie bit 2? Or is this patch meant to be in addition to the
one Alex posted?

Thanks,

-Jason

  parent reply	other threads:[~2012-04-16 16:12 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05  3:42 [PATCH v2] kvm: Disable MSI/MSI-X in assigned device reset path Alex Williamson
2012-04-05  7:28 ` Jan Kiszka
2012-04-05  9:34 ` Michael S. Tsirkin
2012-04-05 14:42   ` Alex Williamson
2012-04-05 15:04     ` Michael S. Tsirkin
2012-04-08 13:14 ` Avi Kivity
2012-04-08 13:17   ` Michael S. Tsirkin
2012-04-08 13:18     ` Avi Kivity
2012-04-08 13:21       ` Michael S. Tsirkin
2012-04-08 13:24         ` Avi Kivity
2012-04-08 13:30           ` Michael S. Tsirkin
2012-04-08 13:41             ` Avi Kivity
2012-04-08 13:53               ` Michael S. Tsirkin
2012-04-08 14:01                 ` Avi Kivity
2012-04-08 14:42                   ` Michael S. Tsirkin
2012-04-08 15:26                     ` Avi Kivity
2012-04-08 15:46                       ` Michael S. Tsirkin
2012-04-08 15:50                         ` Avi Kivity
2012-04-08 16:04                           ` Michael S. Tsirkin
2012-04-08 16:08                             ` Avi Kivity
2012-04-08 17:37                               ` Jan Kiszka
2012-04-08 18:18                                 ` Michael S. Tsirkin
2012-04-08 18:39                                   ` Jan Kiszka
2012-04-08 20:35                                     ` Michael S. Tsirkin
2012-04-09  8:35                                 ` Avi Kivity
2012-04-10 16:55                                   ` Alex Williamson
2012-04-16 14:03 ` Alex Williamson
2012-04-16 14:31   ` Avi Kivity
2012-04-16 15:06   ` Michael S. Tsirkin
2012-04-16 15:10     ` Jan Kiszka
2012-04-16 16:08       ` Michael S. Tsirkin
2012-04-16 16:13         ` Jan Kiszka
2012-04-16 16:36           ` Michael S. Tsirkin
2012-04-16 16:38             ` Jan Kiszka
2012-04-16 17:12               ` Michael S. Tsirkin
2012-04-16 18:47                 ` Jan Kiszka
2012-04-16 16:12     ` Jason Baron [this message]
2012-04-16 16:34       ` Michael S. Tsirkin
2012-04-16 19:07     ` Alex Williamson
2012-04-16 19:47       ` Michael S. Tsirkin
2012-04-17  0:55 ` Marcelo Tosatti

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=20120416161252.GC2345@redhat.com \
    --to=jbaron@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    /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