From: Jared Rossi <jrossi@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
qemu-devel@nongnu.org, qemu-s390x@nongnu.org, mst@redhat.com
Cc: jjherne@linux.ibm.com, alifm@linux.ibm.com, farman@linux.ibm.com,
mjrosato@linux.ibm.com, zycai@linux.ibm.com
Subject: Re: [PATCH v4 12/15] pc-bios/s390-ccw: Add support for virtio-blk-pci IPL
Date: Wed, 4 Mar 2026 15:17:33 -0500 [thread overview]
Message-ID: <5126b04a-dd1f-40ad-a720-4d2c3a7cb1aa@linux.ibm.com> (raw)
In-Reply-To: <79fb74d7-4b42-4ffc-902f-2498e1de5a52@redhat.com>
On 3/4/26 9:39 AM, Thomas Huth wrote:
> On 04/03/2026 15.29, Jared Rossi wrote:
>>
>>
>> On 3/4/26 4:53 AM, Thomas Huth wrote:
>>> On 04/03/2026 03.59, jrossi@linux.ibm.com wrote:
>>>> From: Jared Rossi <jrossi@linux.ibm.com>
>>>>
>>>> Add little-endian virt-queue configuration and support for
>>>> virtio-blk-pci IPL
>>>> devices.
>>>>
>>>> Signed-off-by: Jared Rossi <jrossi@linux.ibm.com>
>>>> ---
>>> ...
>>>> +static int virtio_pci_get_blk_config(void)
>>>> +{
>>>> + VirtioBlkConfig *cfg = &virtio_get_device()->config.blk;
>>>> + int rc = vpci_read_flex(d_cap.off, d_cap.bar, cfg,
>>>> sizeof(VirtioBlkConfig));
>>>> +
>>>> + /* single byte fields are not touched */
>>>> + cfg->capacity = bswap64(cfg->capacity);
>>>> + cfg->size_max = bswap32(cfg->size_max);
>>>> + cfg->seg_max = bswap32(cfg->seg_max);
>>>> +
>>>> + cfg->geometry.cylinders = bswap16(cfg->geometry.cylinders);
>>>> +
>>>> + cfg->blk_size = bswap32(cfg->blk_size);
>>>> + cfg->min_io_size = bswap16(cfg->min_io_size);
>>>> + cfg->opt_io_size = bswap32(cfg->opt_io_size);
>>>
>>> So it looks like you read a bunch of optional config fields here ...
>>>
>>>> + return rc;
>>>> +}
>>> ...
>>>> +int virtio_pci_setup(VDev *vdev)
>>>> +{
>>>> + VRing *vr;
>>>> + int rc;
>>>> + uint8_t status;
>>>> + uint16_t vq_size;
>>>> + int i = 0;
>>>> +
>>>> + vdev->guessed_disk_nature = VIRTIO_GDN_NONE;
>>>> + vdev->cmd_vr_idx = 0;
>>>> +
>>>> + if (virtio_pci_read_pci_cap_config()) {
>>>> + puts("Invalid virtio PCI capabilities");
>>>> + return -EIO;
>>>> + }
>>>> +
>>>> + if (enable_pci_bus_master()) {
>>>> + return -EIO;
>>>> + }
>>>> +
>>>> + if (virtio_reset(vdev)) {
>>>> + return -EIO;
>>>> + }
>>>> +
>>>> + status = VIRTIO_CONFIG_S_ACKNOWLEDGE;
>>>> + if (virtio_pci_set_status(status)) {
>>>> + puts("Virtio-pci device Failed to ACKNOWLEDGE");
>>>> + return -EIO;
>>>> + }
>>>
>>> ... so I think you should enable the corresponding feature bits in
>>> vdev- >guest_features[0] here? QEMU might be very forgiving and
>>> provide you with the fields anyway, but let's better play safe.
>>> Something like:
>>>
>>> vdev->guest_features[0] = VIRTIO_BLK_F_SIZE_MAX |
>>> VIRTIO_BLK_F_SEG_MAX |
>>> VIRTIO_BLK_F_GEOMETRY |
>>> VIRTIO_BLK_F_BLK_SIZE;
>>>
>>> ?
>>
>> VIRTIO_BLK_F_GEOMETRY and VIRTIO_BLK_F_BLK_SIZE are already set
>> during the virtio-blk setup. I actually don't think the other two
>> fields are used, I jut swapped any fields larger than 1 byte. I
>> suppose the feature bits should be enabled though... otherwise we
>> could just just not touch the unused fields at all?
>
> Ah, right, I missed the initialization in virtio_blk_setup_device(),
> so we should be fine here, indeed!
>
>>>
>>>> + vdev->guest_features[1] = VIRTIO_F_VERSION_1;
>>>> + if (virtio_pci_negotiate()) {
>>>> + panic("Virtio feature negotation failed!");
>>>> + }
>>>
>>> Maybe double-check whether VIRTIO_F_VERSION_1 has really been
>>> negotiated? Otherwise, what happens if a user runs QEMU with
>>> "-device virtio-blk- pci,disable-modern=on" ?
>>
>> I haven't tried running it with "disable-modern=on" (I will test that
>> next) but the config is big endian if I don't negotiate that feature
>> bit, and little endian if I do, which I think is the expected
>> behavior when VIRTIO_F_VERSION_1 is set.
>>
>> Just for my understanding, do you see something that makes you
>> suspect the negotiation isn't actually happening? I will try running
>> with "disable- modern=on" and let you know the results.
>
> No, I think it's fine for the default case. I'm just wondering what
> happens when someone uses "disable-modern=on" ... I guess the code
> will currently behave in weird ways since the endianness is wrong ...
> thus I thought it might be better to check VIRTIO_F_VERSION_1 again
> and emit a proper error message in this case?
>
I tried running with "disable-moden=on" and it failed very early in the
virtio-pci setup when trying to read the PCI configuration space.
Failed to locate PCI common configuration
Invalid virtio PCI capabilities
ERROR: No suitable device for IPL. Halting...
Actually that happens before we even try to negotiate
VIRTIO_F_VERSION_1. From the virtio spec, it looks like the legacy
interface requires the common configuration to be in BAR0 (4.1.4.10),
while we normally expect BAR15 to specify the layout. Typically we need
to read the capabilities config in BAR15 to determine which BAR the
common config is in, then that location is used when negotiating the
features, etc. My guess is BAR15 isn't populated when
"disable-modern=on" so it bails out when there is no capabilities
configuration.
But as far as I can tell it isn't an endianness issue since we are
trying to read single byte fields at this point anyway. What are your
thoughts?
Regards,
Jared Rossi
next prev parent reply other threads:[~2026-03-04 20:18 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 2:59 [PATCH v4 00/15] s390x: Add support for virtio-blk-pci IPL device jrossi
2026-03-04 2:59 ` [PATCH v4 01/15] pc-bios/s390-ccw: Fix misattributed function prototypes jrossi
2026-03-04 2:59 ` [PATCH v4 02/15] pc-bios/s390-ccw: Remove redundant vring schid attribute jrossi
2026-03-04 2:59 ` [PATCH v4 03/15] pc-bios/s390-ccw: Always reset virtio device on failed boot attempt jrossi
2026-03-04 8:23 ` Thomas Huth
2026-03-04 13:39 ` Eric Farman
2026-03-04 2:59 ` [PATCH v4 04/15] s390x: Remove duplicate definitions of IPL types jrossi
2026-03-04 8:34 ` Thomas Huth
2026-03-04 2:59 ` [PATCH v4 05/15] pc-bios/s390-ccw: Store device type independent of sense data jrossi
2026-03-04 2:59 ` [PATCH v4 06/15] pc-bios/s390-ccw: Split virtio-ccw and generic virtio jrossi
2026-03-04 8:42 ` Thomas Huth
2026-03-05 15:43 ` Eric Farman
2026-03-04 2:59 ` [PATCH v4 07/15] include/hw/s390x: Move CLP definitions for easier BIOS access jrossi
2026-03-04 2:59 ` [PATCH v4 08/15] pc-bios/s390-ccw: Introduce CLP Architecture jrossi
2026-03-04 14:05 ` Eric Farman
2026-03-04 2:59 ` [PATCH v4 09/15] s390x: Add definitions for PCI IPL type jrossi
2026-03-04 2:59 ` [PATCH v4 10/15] pc-bios/s390-ccw: Introduce PCI device jrossi
2026-03-04 9:10 ` Thomas Huth
2026-03-04 14:35 ` Jared Rossi
2026-03-04 2:59 ` [PATCH v4 11/15] pc-bios/s390-ccw: Introduce virtio-pci functions jrossi
2026-03-04 9:18 ` Thomas Huth
2026-03-04 14:38 ` Jared Rossi
2026-03-05 18:37 ` Eric Farman
2026-03-04 2:59 ` [PATCH v4 12/15] pc-bios/s390-ccw: Add support for virtio-blk-pci IPL jrossi
2026-03-04 9:53 ` Thomas Huth
2026-03-04 14:29 ` Jared Rossi
2026-03-04 14:39 ` Thomas Huth
2026-03-04 20:17 ` Jared Rossi [this message]
2026-03-05 6:16 ` Thomas Huth
2026-03-05 22:25 ` Eric Farman
2026-03-04 2:59 ` [PATCH v4 13/15] s390x: Build IPLB for virtio-pci devices jrossi
2026-03-05 22:30 ` Eric Farman
2026-03-04 2:59 ` [PATCH v4 14/15] hw: Add "loadparm" property to virtio block PCI devices booting on s390x jrossi
2026-03-04 9:59 ` Thomas Huth
2026-03-04 2:59 ` [PATCH v4 15/15] tests/qtest: Add s390x PCI boot test to cdrom-test.c jrossi
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=5126b04a-dd1f-40ad-a720-4d2c3a7cb1aa@linux.ibm.com \
--to=jrossi@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=farman@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=thuth@redhat.com \
--cc=zycai@linux.ibm.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 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.