tests for CCW IDA
cover tests for CCW IDA
Because there is not matching (emulated) QEMU device for the Linux drivers using IDA, testing IDA requires extra effort.
The last patch of this series is a QEMU patch which introduces an emulated CCW device, which does support IDA. This patch depends on my IDA work and is intended to be used with the following patch set:
https://lists.nongnu.org/archive/html/qemu-devel/2017-09/msg03434.html
The second patch is an out-of-tree Linux kernel module, meant to exercise the QEMU device introduced by the first patch. The idea is to apply this patch to an empty git repository.
Both of the patches used to be included in my IDA series, but I've split them out on maintainer request.
Halil Pasic (1):
s390x/ccs: add ccw-tester emulated device
hw/s390x/Makefile.objs | 1 + hw/s390x/ccw-tester.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 hw/s390x/ccw-tester.c
Signature · 1 line
2.13.5
PATCH 1/2 s390x/ccs: add ccw-tester emulated device
Add a fake device meant for testing the correctness of our css emulation.
What we currently have is writing a Fibonacci sequence of uint32_t to the device via ccw write. The write is going to fail if it ain't a Fibonacci and indicate a device exception in scsw together with the proper residual count.
Of course lot's of invalid inputs (besides basic data processing) can be tested with that as well.
Usage:
1) fire up a qemu with something like -device ccw-tester,devno=fe.0.0001 on the command line
2) exercise the device from the guest
---
Depends on the series 'add CCW indirect data access support'
--- hw/s390x/Makefile.objs | 1 + hw/s390x/ccw-tester.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 hw/s390x/ccw-tester.c
hw/s390x/Makefile.objs +1 -0
@@ -18,3 +18,4 @@ obj-y += s390-stattrib.o obj-$(CONFIG_KVM) += s390-skeys-kvm.o obj-$(CONFIG_KVM) += s390-stattrib-kvm.o obj-y += s390-ccw.o +obj-y += ccw-tester.o
hw/s390x/ccw-tester.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.13.5
PATCH 2/2 a tester device for ccw I/O
In reply to Halil PasicLet's introduce a device driver for doing ccw I/O tests. The initial focus is on indirect data access.
The driver is impemented as an out-of-tree Linux kernel module. A module parameter cu_type is used for matching ccw devices. The parameter defaults to 0x3831 which is the default cu_type for the qemu counterpart of this (a fully emulated ccw device just for test).
The current status of the module is means to an end where the end is testing my IDA implementation.
Usage:
You load the module. The driver is supposed to auto detect and auto online the device and provide sysfs atributes for the tests available. Tests are triggered by writing to the attributes. Reoprting is done via printk in almost TAP format (could use improvement if more ambitious). We run one test at a time and do that async to the write. If you try to start more in parallel you will get -EBUSY.
Currently all you can do something like:
* echo 1 > /sys/bus/ccw/devices/<devno>/w_fib To test good old ccw.
* echo 1 > /sys/bus/ccw/devices/<devno>/w_fib_idal To test IDA ccw.
These tests are designed to wrok together with the qemu device mentioned before. The basic idea is that a device is expecting a stream of words such that the sequence words interpreted as uint32_t is a Fibonacci sequence (that is for n > 2 a_{n} = a_{n-1} + a{n-2}).
Using his simple scheme one can check that the right bytes are transferred (with reasonable confidence). If the device detects an element violating the Fibonacci property the driver expects the device posts a device exception indicating that element.
---
Do not try to apply this to a QEMU tree. Use an empty repo.
--- .gitignore | 8 ++ Makefile | 10 ++ ccw_tester.c | 420 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 438 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 ccw_tester.c
.gitignore new file +8 -0
@@ -0,0 +1,8 @@ +#ignore these +*.o +*.cmd +*.ko +*.mod.c +Module.symvers +modules.order +.tmp_versions/
Makefile new file +10 -0
@@ -0,0 +1,10 @@ +ifneq ($(KERNELRELEASE),) +obj-m := ccw_tester.o +else +# normal makefile +KDIR ?= /lib/modules/`uname -r`/build + +default: + $(MAKE) -C $(KDIR) M=$$PWD + +endif
ccw_tester.c new file +420 -0
420 lines not on this page · raw message
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
In reply to Halil PasicQuoted 37 lines · On Wed, 13 Sep 2017 15:27:51 +0200 Halil Pasic <[email protected]> wrote:
Add a fake device meant for testing the correctness of our css emulation.
What we currently have is writing a Fibonacci sequence of
uint32_tto the device via ccw write. The write is going to fail if it ain't a Fibonacci and indicate a device exception in scsw together with the proper residual count.Of course lot's of invalid inputs (besides basic data processing) can be tested with that as well.
Usage:
1) fire up a qemu with something like -device ccw-tester,devno=fe.0.0001 on the command line
2) exercise the device from the guestSigned-off-by Halil Pasic <[email protected]>---
Depends on the series 'add CCW indirect data access support'
--- hw/s390x/Makefile.objs | 1 + hw/s390x/ccw-tester.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 hw/s390x/ccw-tester.c(quoted diff) +10
-0+static int ccw_tester_write_fib(SubchDev *sch, CCW1 ccw) +{ + CcwTesterDevice *d = sch->driver_data; + bool is_fib = true; + uint32_t sum; + int ret = 0; + + ccw_dstream_init(&sch->cds, &ccw, &sch->orb); + d->fib.next = 0; + while (ccw_dstream_avail(&sch->cds) > 0) {
Review
Quoted 10 lines
(quoted diff) +10
-0+ ret = ccw_dstream_read(&sch->cds, + d->fib.ring[abs_to_ring(d->fib.next)]); + if (ret) { + error(0, -ret, "fib"); + break; + } + if (d->fib.next > 2) { + sum = (d->fib.ring[abs_to_ring(d->fib.next - 1)] + + d->fib.ring[abs_to_ring(d->fib.next - 2)]); + is_fib = sum == d->fib.ring[abs_to_ring(d->fib.next)];
This is not endian-safe (noticed while testing on my laptop). Trivial to fix:
hw/s390x/ccw-tester.c +3 -3
@@ -58,9 +58,9 @@ static int ccw_tester_write_fib(SubchDev *sch, CCW1 ccw)break ; }if (d->fib.next >2 ) { - sum = (d->fib.ring[abs_to_ring (d->fib.next -1 )] - + d->fib.ring[abs_to_ring (d->fib.next -2 )]); - is_fib = sum == d->fib.ring[abs_to_ring (d->fib.next)]; + sum =be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next -1 )]) + +be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next -2 )]); + is_fib = sum ==be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next)]);if (!is_fib) {break ; }
Quoted 20 lines
(quoted diff) +20
-0+ if (!is_fib) { + break; + } + } + ++(d->fib.next); + } + if (!is_fib) { + sch->curr_status.scsw.ctrl &= ~SCSW_ACTL_START_PEND; + sch->curr_status.scsw.ctrl |= SCSW_STCTL_PRIMARY | + SCSW_STCTL_SECONDARY | + SCSW_STCTL_ALERT | + SCSW_STCTL_STATUS_PEND; + sch->curr_status.scsw.count = ccw_dstream_residual_count(&sch->cds); + sch->curr_status.scsw.cpa = sch->channel_prog + 8; + sch->curr_status.scsw.dstat = SCSW_DSTAT_UNIT_EXCEP; + return -EIO; + } + return ret; +} +
(...)
Review
Quoted 3 lines
(quoted diff) +3
-0+static Property ccw_tester_properties[] = { + DEFINE_PROP_UINT16("cu_type", CcwTesterDevice, cu_type, + 0x3831),
0x4711 would be nice :)
If we want to follow up on that testdev idea (and I think we should), it might make sense to have a proper type reserve to prevent accidental clashes.
(Or is there already something reserved for "hypervisor use" or whatever?)
Review
Quoted 4 lines
(quoted diff) +4
-0+ DEFINE_PROP_UINT8("chpid_type", CcwTesterDevice, chpid_type, + 0x98), + DEFINE_PROP_END_OF_LIST(), +};
IIUC, pci-testdev provides some unit tests to testers (like kvm-tests) itself. This might be an idea to follow up on for ccw as well.
There's quite some potential in this. We may want to make this a permanent addition.
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 62 lines · Cornelia Huck
Quoted 37 lines · On Wed, 13 Sep 2017 15:27:51 +0200 Halil Pasic <[email protected]> wrote:
Add a fake device meant for testing the correctness of our css emulation.
What we currently have is writing a Fibonacci sequence of
uint32_tto the device via ccw write. The write is going to fail if it ain't a Fibonacci and indicate a device exception in scsw together with the proper residual count.Of course lot's of invalid inputs (besides basic data processing) can be tested with that as well.
Usage:
1) fire up a qemu with something like -device ccw-tester,devno=fe.0.0001 on the command line
2) exercise the device from the guestSigned-off-by Halil Pasic <[email protected]>---
Depends on the series 'add CCW indirect data access support'
--- hw/s390x/Makefile.objs | 1 + hw/s390x/ccw-tester.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 hw/s390x/ccw-tester.c(quoted diff) +10
-0+static int ccw_tester_write_fib(SubchDev *sch, CCW1 ccw) +{ + CcwTesterDevice *d = sch->driver_data; + bool is_fib = true; + uint32_t sum; + int ret = 0; + + ccw_dstream_init(&sch->cds, &ccw, &sch->orb); + d->fib.next = 0; + while (ccw_dstream_avail(&sch->cds) > 0) {Review
Quoted 10 lines
(quoted diff) +10
-0+ ret = ccw_dstream_read(&sch->cds, + d->fib.ring[abs_to_ring(d->fib.next)]); + if (ret) { + error(0, -ret, "fib"); + break; + } + if (d->fib.next > 2) { + sum = (d->fib.ring[abs_to_ring(d->fib.next - 1)] + + d->fib.ring[abs_to_ring(d->fib.next - 2)]); + is_fib = sum == d->fib.ring[abs_to_ring(d->fib.next)];This is not endian-safe (noticed while testing on my laptop). Trivial to fix:
hw/s390x/ccw-tester.c +0
-0@@ -58,9 +58,9 @@ static int ccw_tester_write_fib(SubchDev *sch, CCW1 ccw)break ; }
hw/s390x/ccw-tester.c static int ccw_tester_write_fib(SubchDev *sch, CCW1 ccw) · line 66
Quoted 10 lines
hw/s390x/ccw-tester.c +3
-3if (d->fib.next >2 ) { - sum = (d->fib.ring[abs_to_ring (d->fib.next -1 )] - + d->fib.ring[abs_to_ring (d->fib.next -2 )]); - is_fib = sum == d->fib.ring[abs_to_ring (d->fib.next)]; + sum =be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next -1 )]) + +be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next -2 )]); + is_fib = sum ==be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next)]);if (!is_fib) {break ; }
Nod.
Quoted 21 lines
Quoted 20 lines
(quoted diff) +20
-0+ if (!is_fib) { + break; + } + } + ++(d->fib.next); + } + if (!is_fib) { + sch->curr_status.scsw.ctrl &= ~SCSW_ACTL_START_PEND; + sch->curr_status.scsw.ctrl |= SCSW_STCTL_PRIMARY | + SCSW_STCTL_SECONDARY | + SCSW_STCTL_ALERT | + SCSW_STCTL_STATUS_PEND; + sch->curr_status.scsw.count = ccw_dstream_residual_count(&sch->cds); + sch->curr_status.scsw.cpa = sch->channel_prog + 8; + sch->curr_status.scsw.dstat = SCSW_DSTAT_UNIT_EXCEP; + return -EIO; + } + return ret; +} +(...)
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+static Property ccw_tester_properties[] = { + DEFINE_PROP_UINT16("cu_type", CcwTesterDevice, cu_type, + 0x3831),
0x4711would be nice :)
I don't understand the joke/pun/whatever if there is one, but I'm fine with changing this too.
Quoted 4 lines
If we want to follow up on that testdev idea (and I think we should), it might make sense to have a proper type reserve to prevent accidental clashes.
I agree. Although I would still keep the cu_type configurable, because it might make sense to test a particular 'real' driver (and not a test driver like here). I haven't really thought this through, but it was an idea I had while agonizing over not having a proper type reserved.
I suppose you did something like that for virtio, or? I'm in dark when it comes to the question what process do we/I have to go to get a type,for example 0x4711, reserved.
Quoted 3 lines
(Or is there already something reserved for "hypervisor use" or whatever?)
Not that I know. I can't recall encountering a list of reserved types. Honestly I've hoped to leverage your experience (again because of virtio-ccw).
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+ DEFINE_PROP_UINT8("chpid_type", CcwTesterDevice, chpid_type, + 0x98), + DEFINE_PROP_END_OF_LIST(), +};IIUC, pci-testdev provides some unit tests to testers (like kvm-tests) itself. This might be an idea to follow up on for ccw as well.
I've just had a first look at pci-testdev, and it does appear to be a similar concept.
Quoted 3 lines
There's quite some potential in this. We may want to make this a permanent addition.
I'm happy to contribute! I'm not sure how shall we proceed though. Maybe with making a todo list?
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 4 lines · On Thu, 14 Sep 2017 18:50:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 2 lines · Cornelia Huck
On Wed, 13 Sep 2017 15:27:51 +0200
Halil Pasic <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+static Property ccw_tester_properties[] = { + DEFINE_PROP_UINT16("cu_type", CcwTesterDevice, cu_type, + 0x3831),
0x4711would be nice :)I don't understand the joke/pun/whatever if there is one, but I'm fine with changing this too.
https://en.wikipedia.org/wiki/4711
That's my default if I need a four-digit number :)
Quoted 12 lines
Quoted 5 lines
If we want to follow up on that testdev idea (and I think we should), it might make sense to have a proper type reserve to prevent accidental clashes.
I agree. Although I would still keep the
cu_typeconfigurable, because it might make sense to test a particular 'real' driver (and not a test driver like here). I haven't really thought this through, but it was an idea I had while agonizing over not having a proper type reserved.
Quoted 3 lines
I suppose you did something like that for virtio, or? I'm in dark when it comes to the question what process do we/I have to go to get a type,for example
0x4711, reserved.
4711 is more a joke :) It might be worth trying the same channels as for virtio-ccw.
Christian should know more about that.
Quoted 8 lines
Quoted 4 lines
(Or is there already something reserved for "hypervisor use" or whatever?)
Not that I know. I can't recall encountering a list of reserved types. Honestly I've hoped to leverage your experience (again because of virtio-ccw).
My thought was that the z/VM folks already might have something (type-wise) that we could use as well. There's a surprising amount of values that are reserved for one use or the other. But obviously, I can't find out about that.
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+ DEFINE_PROP_UINT8("chpid_type", CcwTesterDevice, chpid_type, + 0x98),
This might also need re-evaluation - we should not really need a new chpid type.
Quoted 10 lines
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ DEFINE_PROP_END_OF_LIST(), +};IIUC, pci-testdev provides some unit tests to testers (like kvm-tests) itself. This might be an idea to follow up on for ccw as well.
I've just had a first look at pci-testdev, and it does appear to be a similar concept.
Quoted 6 lines
Quoted 3 lines
There's quite some potential in this. We may want to make this a permanent addition.
I'm happy to contribute! I'm not sure how shall we proceed though. Maybe with making a todo list?
I think the first step would be to figure out the ids so we don't step on anyone's toes. Then maybe refactor a bit so that other testers can be added easily.
For ideas about things to be tested, maybe put a list into the wiki?
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 9 lines · On Fri, 15 Sep 2017 09:27:58 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 6 lines · On Thu, 14 Sep 2017 18:50:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 3 lines · Cornelia Huck
There's quite some potential in this. We may want to make this a permanent addition.
Quoted 8 lines
Quoted 2 lines
I'm happy to contribute! I'm not sure how shall we proceed though. Maybe with making a todo list?
I think the first step would be to figure out the ids so we don't step on anyone's toes. Then maybe refactor a bit so that other testers can be added easily.
For ideas about things to be tested, maybe put a list into the wiki?
OK, I've created https://wiki.qemu.org/Testing/CCWTestDevice - let me know if you need an account.
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
In reply to Cornelia HuckQuoted 32 lines · Cornelia Huck
Quoted 4 lines · On Thu, 14 Sep 2017 18:50:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 2 lines · Cornelia Huck
On Wed, 13 Sep 2017 15:27:51 +0200
Halil Pasic <[email protected]> wrote:Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+static Property ccw_tester_properties[] = { + DEFINE_PROP_UINT16("cu_type", CcwTesterDevice, cu_type, + 0x3831),
0x4711would be nice :)I don't understand the joke/pun/whatever if there is one, but I'm fine with changing this too.
https://en.wikipedia.org/wiki/4711
That's my default if I need a four-digit number :)
Quoted 12 lines
Quoted 5 lines
If we want to follow up on that testdev idea (and I think we should), it might make sense to have a proper type reserve to prevent accidental clashes.
I agree. Although I would still keep the
cu_typeconfigurable, because it might make sense to test a particular 'real' driver (and not a test driver like here). I haven't really thought this through, but it was an idea I had while agonizing over not having a proper type reserved.
Quoted 8 lines
Quoted 3 lines
I suppose you did something like that for virtio, or? I'm in dark when it comes to the question what process do we/I have to go to get a type,for example
0x4711, reserved.4711 is more a joke :) It might be worth trying the same channels as for virtio-ccw.
Christian should know more about that.
Getting a new number was very easy (because it is attached to a machine type number). I I remember correctly, only numerical values are uses, so maybe we can use ffff as there will never be such a real value?
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 37 lines · On Mon, 18 Sep 2017 10:30:32 +0200 Christian Borntraeger…
Quoted 36 lines · Cornelia Huck
Quoted 4 lines · On Thu, 14 Sep 2017 18:50:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 2 lines · Cornelia Huck
On Wed, 13 Sep 2017 15:27:51 +0200
Halil Pasic <[email protected]> wrote:Quoted 8 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+static Property ccw_tester_properties[] = { + DEFINE_PROP_UINT16("cu_type", CcwTesterDevice, cu_type, + 0x3831),
0x4711would be nice :)I don't understand the joke/pun/whatever if there is one, but I'm fine with changing this too.
https://en.wikipedia.org/wiki/4711
That's my default if I need a four-digit number :)
Quoted 15 lines
Quoted 5 lines
If we want to follow up on that testdev idea (and I think we should), it might make sense to have a proper type reserve to prevent accidental clashes.
I agree. Although I would still keep the
cu_typeconfigurable, because it might make sense to test a particular 'real' driver (and not a test driver like here). I haven't really thought this through, but it was an idea I had while agonizing over not having a proper type reserved.I suppose you did something like that for virtio, or? I'm in dark when it comes to the question what process do we/I have to go to get a type,for example
0x4711, reserved.
Quoted 9 lines
Quoted 4 lines
4711 is more a joke :) It might be worth trying the same channels as for virtio-ccw.
Christian should know more about that.
Getting a new number was very easy (because it is attached to a machine type number). I I remember correctly, only numerical values are uses, so maybe we can use ffff as there will never be such a real value?
Yes, that sounds like the easiest way to do that.
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
In reply to Cornelia HuckQuoted 15 lines · Cornelia Huck
Quoted 12 lines · On Fri, 15 Sep 2017 09:27:58 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 8 lines · On Thu, 14 Sep 2017 18:50:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 3 lines · Cornelia Huck
There's quite some potential in this. We may want to make this a permanent addition.
I'm happy to contribute! I'm not sure how shall we proceed though. Maybe with making a todo list?
Quoted 9 lines
Quoted 5 lines
I think the first step would be to figure out the ids so we don't step on anyone's toes. Then maybe refactor a bit so that other testers can be added easily.
For ideas about things to be tested, maybe put a list into the wiki?
OK, I've created https://wiki.qemu.org/Testing/CCWTestDevice - let me know if you need an account.
Great!
I just saw your email, it was waiting in my inbox. strange things happens some time. A good serie. strange things. neverless...
Seriously.
Yes, I definitively need an account!
Pierre
Signature · 2 lines
Pierre Morel Linux/KVM/QEMU in Böblingen - Germany
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
In reply to Cornelia HuckQuoted 93 lines · Cornelia Huck
Quoted 37 lines · On Wed, 13 Sep 2017 15:27:51 +0200 Halil Pasic <[email protected]> wrote:
Add a fake device meant for testing the correctness of our css emulation.
What we currently have is writing a Fibonacci sequence of
uint32_tto the device via ccw write. The write is going to fail if it ain't a Fibonacci and indicate a device exception in scsw together with the proper residual count.Of course lot's of invalid inputs (besides basic data processing) can be tested with that as well.
Usage:
1) fire up a qemu with something like -device ccw-tester,devno=fe.0.0001 on the command line
2) exercise the device from the guestSigned-off-by Halil Pasic <[email protected]>---
Depends on the series 'add CCW indirect data access support'
--- hw/s390x/Makefile.objs | 1 + hw/s390x/ccw-tester.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+)create mode 100644
hw/s390x/ccw-tester.c(quoted diff) +10
-0+static int ccw_tester_write_fib(SubchDev *sch, CCW1 ccw) +{ + CcwTesterDevice *d = sch->driver_data; + bool is_fib = true; + uint32_t sum; + int ret = 0; + + ccw_dstream_init(&sch->cds, &ccw, &sch->orb); + d->fib.next = 0; + while (ccw_dstream_avail(&sch->cds) > 0) {Review
Quoted 10 lines
(quoted diff) +10
-0+ ret = ccw_dstream_read(&sch->cds, + d->fib.ring[abs_to_ring(d->fib.next)]); + if (ret) { + error(0, -ret, "fib"); + break; + } + if (d->fib.next > 2) { + sum = (d->fib.ring[abs_to_ring(d->fib.next - 1)] + + d->fib.ring[abs_to_ring(d->fib.next - 2)]); + is_fib = sum == d->fib.ring[abs_to_ring(d->fib.next)];This is not endian-safe (noticed while testing on my laptop). Trivial to fix:
hw/s390x/ccw-tester.c +3
-3@@ -58,9 +58,9 @@ static int ccw_tester_write_fib(SubchDev *sch, CCW1 ccw)break ; }if (d->fib.next >2 ) { - sum = (d->fib.ring[abs_to_ring (d->fib.next -1 )] - + d->fib.ring[abs_to_ring (d->fib.next -2 )]); - is_fib = sum == d->fib.ring[abs_to_ring (d->fib.next)]; + sum =be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next -1 )]) + +be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next -2 )]); + is_fib = sum ==be32_to_cpu (d->fib.ring[abs_to_ring (d->fib.next)]);if (!is_fib) {break ; }Quoted 21 lines
(quoted diff) +20
-0+ if (!is_fib) { + break; + } + } + ++(d->fib.next); + } + if (!is_fib) { + sch->curr_status.scsw.ctrl &= ~SCSW_ACTL_START_PEND; + sch->curr_status.scsw.ctrl |= SCSW_STCTL_PRIMARY | + SCSW_STCTL_SECONDARY | + SCSW_STCTL_ALERT | + SCSW_STCTL_STATUS_PEND; + sch->curr_status.scsw.count = ccw_dstream_residual_count(&sch->cds); + sch->curr_status.scsw.cpa = sch->channel_prog + 8; + sch->curr_status.scsw.dstat = SCSW_DSTAT_UNIT_EXCEP; + return -EIO; + } + return ret; +} +(...)
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+static Property ccw_tester_properties[] = { + DEFINE_PROP_UINT16("cu_type", CcwTesterDevice, cu_type, + 0x3831),
0x4711would be nice :)
The C0C0 channel would be nice too.
Sorry.
Quoted 19 lines
If we want to follow up on that testdev idea (and I think we should), it might make sense to have a proper type reserve to prevent accidental clashes.
(Or is there already something reserved for "hypervisor use" or whatever?)
Review
Quoted 4 lines
(quoted diff) +4
-0+ DEFINE_PROP_UINT8("chpid_type", CcwTesterDevice, chpid_type, + 0x98), + DEFINE_PROP_END_OF_LIST(), +};IIUC, pci-testdev provides some unit tests to testers (like kvm-tests) itself. This might be an idea to follow up on for ccw as well.
There's quite some potential in this. We may want to make this a permanent addition.
Signature · 2 lines
Pierre Morel Linux/KVM/QEMU in Böblingen - Germany
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
In reply to Pierre MorelQuoted 31 lines · Pierre Morel
Quoted 15 lines · Cornelia Huck
Quoted 12 lines · On Fri, 15 Sep 2017 09:27:58 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 8 lines · On Thu, 14 Sep 2017 18:50:29 +0200 Halil Pasic <[email protected]> wrote:
Quoted 3 lines · Cornelia Huck
There's quite some potential in this. We may want to make this a permanent addition.
I'm happy to contribute! I'm not sure how shall we proceed though. Maybe with making a todo list?
Quoted 9 lines
Quoted 5 lines
I think the first step would be to figure out the ids so we don't step on anyone's toes. Then maybe refactor a bit so that other testers can be added easily.
For ideas about things to be tested, maybe put a list into the wiki?
OK, I've created https://wiki.qemu.org/Testing/CCWTestDevice - let me know if you need an account.
Great!
I just saw your email, it was waiting in my inbox. strange things happens some time. A good serie. strange things. neverless...
Quoted 6 lines
Seriously.
Yes, I definitively need an account!Pierre
@Connie
I would also like to have an account. I would also like to do a v2 of this somewhere in the not too distant future. I intend to address the issues pointed out by you here (chpid_type, cu_type). Another question is whether this should go under hw/misc/ like the pci-testdev? ccw-testdev would also probably be a better file name (that ccw-tester) regardless of in which folder does this belong. One more thing I am considering for v2 is this make it extensible argument. I had something like mode on my mind from the very beginning (fib would be one mode). The idea was to provide a control ccw for setting/getting the mode (something like virtio) as well as a device property for setting the initial mode (so that guest does not have to know about it).
Regards,
Halil
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 2 lines · On Mon, 25 Sep 2017 17:06:01 +0200 Halil Pasic <[email protected]> wrote:
@Connie
I would also like to have an account.
Done (for both of you).
Quoted 7 lines
I would also like to do a
v2 of this somewhere in the not too distant future. I intend to address the issues pointed out by you here (chpid_type,cu_type). Another question is whether this should go under hw/misc/ like the pci-testdev? ccw-testdev would also probably be a better file name (that ccw-tester) regardless of in which folder does this belong.
Probably not a bad idea to follow pci here.
Quoted 6 lines
One more thing I am considering for
v2 is this make it extensible argument. I had something like mode on my mind from the very beginning (fib would be one mode). The idea was to provide a control ccw for setting/getting the mode (something like virtio) as well as a device property for setting the initial mode (so that guest does not have to know about it).
Yes, a control ccw sounds nice, we should just make sure that it doesn't collide with future tests (e.g. if we want to do some channel program fuzzing). Alternatively, this could be controled by a diagnose, which would be out of band (we can use a high function code for diag 500 that is unlikely to collide with future extensions).
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
In reply to Cornelia HuckQuoted 6 lines · Cornelia Huck
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ DEFINE_PROP_UINT8("chpid_type", CcwTesterDevice, chpid_type, + 0x98),This might also need re-evaluation - we should not really need a new chpid type.
I'm back at ccw-tester again (for v2). I've realized we did not agree on what to use here (chpid_type). Shall I use 0x25 (Fibre Channel) or EMULATED_CCW_3270_CHPID_TYPE, or even 0x32 (virtio-ccw) as a default value? And should EMULATED_CCW_3270_CHPID_TYPE be called like that (is it really supposed to be specific to 3270?
Sorry I did not notice sooner.
Regards,
Halil
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 8 lines · On Thu, 19 Oct 2017 18:39:37 +0200 Halil Pasic <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ DEFINE_PROP_UINT8("chpid_type", CcwTesterDevice, chpid_type, + 0x98),This might also need re-evaluation - we should not really need a new chpid type.
Quoted 7 lines
I'm back at ccw-tester again (for v2). I've realized we did not agree on what to use here (
chpid_type). Shall I use0x25(Fibre Channel) orEMULATED_CCW_3270_CHPID_TYPE, or even0x32(virtio-ccw) as a default value? And shouldEMULATED_CCW_3270_CHPID_TYPEbe called like that (is it really supposed to be specific to 3270?Sorry I did not notice sooner.
It might make sense to pick whatever z/VM commonly uses for emulated devices. (Or ask them if they reserved something explicitly for testing -- that would be an even better match.)
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 17 lines · Cornelia Huck
Quoted 14 lines · On Thu, 19 Oct 2017 18:39:37 +0200 Halil Pasic <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ DEFINE_PROP_UINT8("chpid_type", CcwTesterDevice, chpid_type, + 0x98),This might also need re-evaluation - we should not really need a new chpid type.
I'm back at ccw-tester again (for v2). I've realized we did not agree on what to use here (
chpid_type). Shall I use0x25(Fibre Channel) orEMULATED_CCW_3270_CHPID_TYPE, or even0x32(virtio-ccw) as a default value? And shouldEMULATED_CCW_3270_CHPID_TYPEbe called like that (is it really supposed to be specific to 3270?
Quoted 6 lines
Quoted 1 line
Sorry I did not notice sooner.
It might make sense to pick whatever z/VM commonly uses for emulated devices. (Or ask them if they reserved something explicitly for testing -- that would be an even better match.)
OK, I will approach the z/VM guys. About EMULATED_CCW_3270_CHPID_TYPE, does it really make sense to have a separate chpid type for 3270? (You have missed that question, so I'm asking it again).
Halil
Re: [Qemu-devel] [PATCH 1/2] s390x/ccs: add ccw-tester emulated device
Quoted 3 lines · On Fri, 20 Oct 2017 16:33:47 +0200 Halil Pasic <[email protected]> wrote:
OK, I will approach the z/VM guys. About
EMULATED_CCW_3270_CHPID_TYPE, does it really make sense to have a separate chpid type for 3270? (You have missed that question, so I'm asking it again).
I had not. But my resources are depleted.