[RFC,v1,2/8] vfio-ccw: Don't inject an I/O interrupt if the subchannel is not enabled
diff mbox series

Message ID 20191115033437.37926-3-farman@linux.ibm.com
State New
Headers show
Series
  • s390x/vfio-ccw: Channel Path Handling
Related show

Commit Message

Eric Farman Nov. 15, 2019, 3:34 a.m. UTC
From: Farhan Ali <alifm@linux.ibm.com>

According to PoPs, when the SCHIB.PMCW bit 8 is 0 status presented by
the device is not made available to the program. So don't inject an
interrupt in the guest if the guest OS has not enabled the
subchannel.

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---

Notes:
    v0->v1: [EF]
     - Update commit message, as the bit in question is bit 8 not 15

 hw/vfio/ccw.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Cornelia Huck Nov. 18, 2019, 6:23 p.m. UTC | #1
On Fri, 15 Nov 2019 04:34:31 +0100
Eric Farman <farman@linux.ibm.com> wrote:

> From: Farhan Ali <alifm@linux.ibm.com>
> 
> According to PoPs, when the SCHIB.PMCW bit 8 is 0 status presented by
> the device is not made available to the program. So don't inject an
> interrupt in the guest if the guest OS has not enabled the
> subchannel.

Have you managed to trigger this state in real life?

> 
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> ---
> 
> Notes:
>     v0->v1: [EF]
>      - Update commit message, as the bit in question is bit 8 not 15
> 
>  hw/vfio/ccw.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index 0919ddbeb8..0590a6f512 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -230,6 +230,11 @@ static void vfio_ccw_io_notifier_handler(void *opaque)
>          return;
>      }
>  
> +    /* Virtual subchannel is not enabled */
> +    if (!(schib->pmcw.flags & PMCW_FLAGS_MASK_ENA)) {

How can that happen? We should not be able to disable the subchannel
while it is in active use, should we? I fear I'm missing something
here...

> +        return;
> +    }
> +
>      size = pread(vcdev->vdev.fd, region, vcdev->io_region_size,
>                   vcdev->io_region_offset);
>      if (size == -1) {
Eric Farman Nov. 19, 2019, 3:47 p.m. UTC | #2
On 11/18/19 1:23 PM, Cornelia Huck wrote:
> On Fri, 15 Nov 2019 04:34:31 +0100
> Eric Farman <farman@linux.ibm.com> wrote:
> 
>> From: Farhan Ali <alifm@linux.ibm.com>
>>
>> According to PoPs, when the SCHIB.PMCW bit 8 is 0 status presented by
>> the device is not made available to the program. So don't inject an
>> interrupt in the guest if the guest OS has not enabled the
>> subchannel.
> 
> Have you managed to trigger this state in real life?

No, and I have no notes on how this came to be.  I'll try running some
of the config tests with this reverted, and see if I can find any weirdness.

> 
>>
>> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
>> Signed-off-by: Eric Farman <farman@linux.ibm.com>
>> ---
>>
>> Notes:
>>     v0->v1: [EF]
>>      - Update commit message, as the bit in question is bit 8 not 15
>>
>>  hw/vfio/ccw.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
>> index 0919ddbeb8..0590a6f512 100644
>> --- a/hw/vfio/ccw.c
>> +++ b/hw/vfio/ccw.c
>> @@ -230,6 +230,11 @@ static void vfio_ccw_io_notifier_handler(void *opaque)
>>          return;
>>      }
>>  
>> +    /* Virtual subchannel is not enabled */
>> +    if (!(schib->pmcw.flags & PMCW_FLAGS_MASK_ENA)) {
> 
> How can that happen? We should not be able to disable the subchannel
> while it is in active use, should we? I fear I'm missing something
> here...

Me too...  Hrm...

> 
>> +        return;
>> +    }
>> +
>>      size = pread(vcdev->vdev.fd, region, vcdev->io_region_size,
>>                   vcdev->io_region_offset);
>>      if (size == -1) {
>

Patch
diff mbox series

diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 0919ddbeb8..0590a6f512 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -230,6 +230,11 @@  static void vfio_ccw_io_notifier_handler(void *opaque)
         return;
     }
 
+    /* Virtual subchannel is not enabled */
+    if (!(schib->pmcw.flags & PMCW_FLAGS_MASK_ENA)) {
+        return;
+    }
+
     size = pread(vcdev->vdev.fd, region, vcdev->io_region_size,
                  vcdev->io_region_offset);
     if (size == -1) {