All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel@lists.xen.org, wei.liu2@citrix.com,
	ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH 1/2] libxl: Wait until QEMU removed the device before tearing it down
Date: Fri, 14 Nov 2014 10:30:12 -0500	[thread overview]
Message-ID: <54662004.6050702@oracle.com> (raw)
In-Reply-To: <21606.5282.659930.728522@mariner.uk.xensource.com>

On 11/14/2014 09:41 AM, Ian Jackson wrote:
> Boris Ostrovsky writes ("[PATCH 1/2] libxl: Wait until QEMU removed the device before tearing it down"):
>> When a device is hot-unplugged libxl sends QEMU a "device-del" message
>> (via QMP). This call returns after QEMU has initiated device removal by
>> sending an interrupt to the guest. At some point later QEMU is expected
>> to clean up after the device (such as unbind/unmap MSIs), which will
>> occur when the guest signals that the device has been ejected.
> I haven't repro'd this bug, but after looking at your patch, and
> staring at the code, I think you may have misdiagnosed the problem.
>
> I found this:
>
>      if (type == LIBXL_DOMAIN_TYPE_HVM) {
>         [stuff]
>      } else if (type != LIBXL_DOMAIN_TYPE_PV)
>          abort();
>      {
>
> This is, of course, very bizarre.  For a moment I put it down to
> coding style, but the subsequent block is the PV pci unplug path.  It
> would appear therefore that HVM PCI unplug executes first the HVM
> code, and then immediately afterwards the PV code.
>
> This strangeness was introduced in abfb006f
>   "tools/libxl: explicitly grant access to needed I/O-memory ranges"
> which seems to contain an entirely wrong hunk.
>
> Can you try the patch below and see if it helps your problem ?

It does help with the first half of the problem --- we don't do the 
unnecessary unmap anymore in what now becomes PV-only 'else if (type != 
LIBXL_DOMAIN_TYPE_PV)' clause.

But it doesn't help with the second part (the one that shows Linux 
WARNING), because we still may try to reset the device before guest 
kernel is done unloading the driver. Reproducing that problem is 
probably dependent on the guest/driver: in this particular case the igb 
driver does an IN instruction while unloading the driver and if that 
instruction fails (which may happen if the device is gone from the POV 
of toolstack) then it triggers the warning.

>
> AFAICT your other patch probably isn't needed in the light of all
> this.  If it is, then I have misunderstood (and perhaps the commit
> message could be more explicit about the bug that this is allegedly
> fixing - calling a patch `Simplify ....' makes it sound like the kind
> of cleanup we don't want to take during the freeze).

And I believe we still need part of the second patch --- the one that 
removes call to xc_domain_irq_permission() for PV guests (after your 
patch is applied): this call will fail because xc_physdev_unmap_pirq() 
above it will cause hypervisor to do unmap_domain_pirq()->irq_deny_access()

So I think we need:
1. Your patch
2. My first patch
3. Part of my second patch as described above. (and make commit 
message/subject more understandable)


Thanks.
-boris

>
> Thanks
> Ian.
>
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
>
> diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
> index 9f40100..bec25a9 100644
> --- a/tools/libxl/libxl_pci.c
> +++ b/tools/libxl/libxl_pci.c
> @@ -1255,9 +1255,9 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
>               rc = ERROR_FAIL;
>               goto out_fail;
>           }
> -    } else if (type != LIBXL_DOMAIN_TYPE_PV)
> -        abort();
> -    {
> +    } else {
> +        assert(type == LIBXL_DOMAIN_TYPE_PV);
> +
>           char *sysfs_path = libxl__sprintf(gc, SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->domain,
>                                            pcidev->bus, pcidev->dev, pcidev->func);
>           FILE *f = fopen(sysfs_path, "r");

  reply	other threads:[~2014-11-14 15:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-10 23:16 [PATCH 0/2] Two fixes for libxl's PCI detach operation Boris Ostrovsky
2014-11-10 23:16 ` [PATCH 1/2] libxl: Wait until QEMU removed the device before tearing it down Boris Ostrovsky
2014-11-14 14:41   ` Ian Jackson
2014-11-14 15:30     ` Boris Ostrovsky [this message]
2014-11-14 16:01       ` Ian Jackson
2014-11-14 16:24         ` Boris Ostrovsky
2014-11-14 16:31           ` Ian Jackson
2014-11-14 16:37             ` Boris Ostrovsky
2014-11-14 16:36               ` Ian Jackson
2014-11-14 16:58                 ` Boris Ostrovsky
2014-11-14 17:45             ` Sander Eikelenboom
2014-11-14 18:07               ` Ian Jackson
2014-11-14 19:24                 ` Sander Eikelenboom
2014-11-14 21:09                   ` Boris Ostrovsky
2014-11-14 21:20                     ` Sander Eikelenboom
2014-11-14 21:38                       ` Boris Ostrovsky
2014-11-14 21:50                         ` Sander Eikelenboom
2014-11-14 16:19   ` Ian Jackson
2014-11-14 17:09     ` Boris Ostrovsky
2014-11-14 17:33       ` Ian Jackson
2014-11-10 23:16 ` [PATCH 2/2] libxl: Simplify cleanup in do_pci_remove() Boris Ostrovsky

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=54662004.6050702@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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 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.