From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, izumi.taku@jp.fujitsu.com,
Chen Fan <chen.fan.fnst@cn.fujitsu.com>,
Dou Liyang <douly.fnst@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH RFC v11 3/4] vfio-pci: pass the aer error to guest
Date: Fri, 20 Jan 2017 14:50:26 +0800 [thread overview]
Message-ID: <5881B332.5050508@cn.fujitsu.com> (raw)
In-Reply-To: <20170118153152.2869a1aa@t450s.home>
On 01/19/2017 06:31 AM, Alex Williamson wrote:
> On Sat, 31 Dec 2016 17:13:07 +0800
> Cao jin <caoj.fnst@cn.fujitsu.com> wrote:
>
>> From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
>>
>> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
>> index 76a8ac3..9861f72 100644
>> --- a/hw/vfio/pci.c
>> +++ b/hw/vfio/pci.c
>> @@ -2470,21 +2470,55 @@ static void vfio_put_device(VFIOPCIDevice *vdev)
>> static void vfio_err_notifier_handler(void *opaque)
>> {
>> VFIOPCIDevice *vdev = opaque;
>> + PCIDevice *dev = &vdev->pdev;
>> + PCIEAERMsg msg = {
>> + .severity = 0,
>> + .source_id = (pci_bus_num(dev->bus) << 8) | dev->devfn,
>> + };
>> + int len;
>> + uint64_t uncor_status;
>> +
>> + /* Read uncorrectable error status from driver */
>> + len = read(vdev->err_notifier.rfd, &uncor_status, sizeof(uncor_status));
>
> Whoa this seems bogus. In the kernel eventfd_signal() adds the value
> to the internal counter. We can't guarantee that the user is going to
> immediately respond to every signal, multiple signals might occur, each
> incrementing the counter. I don't think we can use the eventfd like
> this.
>
Ah, got your concern, make sense. Michael had the same comments as you,
I didn't got him at that time...
I explained the reason in v10 cover letter(5 of changelog): I find that
error status register reading in error handler sometime returns ALL F's.
I may want to take a look at v10, incorporate your comments, and test
to see if the issue still exists. Currently if we only handle non-fatal
error, we can still use eventfd like before.
--
Sincerely,
Cao jin
>> + if (len != sizeof(uncor_status)) {
>> + error_report("vfio-pci: uncor error status reading returns"
>> + " invalid number of bytes: %d", len);
>> + return; //Or goto stop?
>
> It's bogus use of the eventfd anyway afaict, but
> event_notifier_test_and_clear() certainly handles at least EINTR.
>
>> + }
>> +
>> + if (!(vdev->features & VFIO_FEATURE_ENABLE_AER)) {
>> + goto stop;
>> + }
>
> I'm not sure this should be user selected anymore.
>
>> +
>> + /* Populate the aer msg and send it to root port */
>> + if (dev->exp.aer_cap) {
>> + uint8_t *aer_cap = dev->config + dev->exp.aer_cap;
>> + bool isfatal = uncor_status &
>> + pci_get_long(aer_cap + PCI_ERR_UNCOR_SEVER);
>> +
>> + if (isfatal) {
>> + goto stop;
>> + }
>
> QEMU uses spaces not tabs.
>
>> +
>> + msg.severity = isfatal ? PCI_ERR_ROOT_CMD_FATAL_EN :
>> + PCI_ERR_ROOT_CMD_NONFATAL_EN;
>
> We don't get here if isfatal.
>
>>
>> - if (!event_notifier_test_and_clear(&vdev->err_notifier)) {
>> + error_report("vfio-pci device %d sending AER to root port. uncor"
>> + " status = 0x%"PRIx64, dev->devfn, uncor_status);
>> + pcie_aer_msg(dev, &msg);
>> return;
>> }
>>
>> +stop:
>> /*
>> - * TBD. Retrieve the error details and decide what action
>> - * needs to be taken. One of the actions could be to pass
>> - * the error to the guest and have the guest driver recover
>> - * from the error. This requires that PCIe capabilities be
>> - * exposed to the guest. For now, we just terminate the
>> - * guest to contain the error.
>> + * Terminate the guest in case of
>> + * 1. AER capability is not exposed to guest.
>> + * 2. AER capability is exposed, but error is fatal, only non-fatal
>> + * error is handled now.
>
> You're also currently requiring the user to enable aer per device.
>
>> */
>>
>> - error_report("%s(%s) Unrecoverable error detected. Please collect any data possible and then kill the guest", __func__, vdev->vbasedev.name);
>> + error_report("%s(%s) fatal error detected. Please collect any data"
>> + " possible and then kill the guest", __func__, vdev->vbasedev.name);
>>
>> vm_stop(RUN_STATE_INTERNAL_ERROR);
>> }
>
>
>
> .
>
next prev parent reply other threads:[~2017-01-20 6:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-31 9:13 [Qemu-devel] [PATCH RFC v11 0/4] vfio-pci: pass non-fatal error to guest Cao jin
2016-12-31 9:13 ` [Qemu-devel] [PATCH v11 1/4] pcie_aer: support configurable AER capa version Cao jin
2016-12-31 9:13 ` [Qemu-devel] [PATCH RFC v11 2/4] vfio: new function to init aer cap for vfio device Cao jin
2017-01-18 22:09 ` Alex Williamson
2017-01-20 6:03 ` Cao jin
2017-01-20 18:12 ` Alex Williamson
2016-12-31 9:13 ` [Qemu-devel] [PATCH RFC v11 3/4] vfio-pci: pass the aer error to guest Cao jin
2017-01-09 22:55 ` Michael S. Tsirkin
2017-01-18 22:31 ` Alex Williamson
2017-01-20 6:50 ` Cao jin [this message]
2017-01-20 6:57 ` Tian, Kevin
2017-01-20 18:21 ` Alex Williamson
2017-01-22 4:43 ` Tian, Kevin
2016-12-31 9:13 ` [Qemu-devel] [PATCH RFC v11 4/4] vfio: add 'aer' property to expose aercap Cao jin
2017-01-18 22:36 ` Alex Williamson
2017-01-20 6:04 ` Cao jin
2017-01-20 18:01 ` Alex Williamson
2016-12-31 9:17 ` [Qemu-devel] [PATCH RFC v11 0/4] vfio-pci: pass non-fatal error to guest no-reply
2017-01-18 21:43 ` Alex Williamson
2017-01-19 6:15 ` Cao jin
2017-01-19 6:25 ` Cao jin
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=5881B332.5050508@cn.fujitsu.com \
--to=caoj.fnst@cn.fujitsu.com \
--cc=alex.williamson@redhat.com \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=douly.fnst@cn.fujitsu.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.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.