@samitouri / QOSamiQemu / commits / 1f1ccb6f3c

target/s390x: Make container ids in SysIB_15x 1-based

The Container Id in a container-type TLE of SysIB_15x is defined as 8-bit unsigned nonzero integer. Make stsi fc 15 emulation architecture compliant, by starting the container ids at 1 for the lowest numbered container. The qemu misbehaviour without this patch becomes obvious due to a recently proposed kernel fix. Older linux kernels pass the container ids from stsi fc15 unchanged to sysfs, i.e. starting at 1 on s390 hardware. This resulted in off-by-one values when compared to the values from HMC. A Linux kernel fix is being proposed to correct the sysfs topology ids by -1, so they start at 0, e.g. when displayed by 'lscpu -ye'. In case a KVM guest with a fixed kernel runs on a host with a qemu without this fix, this can result in container ids erroneously being shown as 255. Example (Fixed guest on unfixed qemu): $ lscpu -ye CPU NODE DRAWER BOOK SOCKET CORE L1d:L1i:L2 ONLINE CONFIGURED POLARIZATION ADDRESS 0 0 255 255 255 0 0:0:0 yes yes vert-medium 0 1 0 255 255 0 1 1:1:1 yes yes vert-medium 1 After this fix: $ lscpu -ye CPU NODE DRAWER BOOK SOCKET CORE L1d:L1i:L2 ONLINE CONFIGURED POLARIZATION ADDRESS 0 0 0 0 0 0 0:0:0 yes yes vert-medium 0 1 0 0 0 1 1 1:1:1 yes yes vert-medium 1 Fixes: f4f54b582f ("target/s390x/cpu topology: handle STSI(15) and build the SYSIB") Signed-off-by: Alexandra Winter <wintera@linux.ibm.com> Acked-by: Hendrik Brueckner <brueckner@linux.ibm.com> Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com> Reviewed-by: Gautam Gala <ggala@linux.ibm.com> Message-ID: <20260511134909.43802-1-wintera@linux.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>

Alexandra Winter committed May 11, 2026 at 15:49 UTC 1f1ccb6f3c48a2cd80e874d66afeef2dc28a65f3
1 file changed +5 -5
target/s390x/kvm/stsi-topology.c
+5 -5
@@ -90,9 +90,9 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
90 int last_drawer = -1;
91 int last_book = -1;
92 int last_socket = -1;
93 - int drawer_id = 0;
94 - int book_id = 0;
95 - int socket_id = 0;
93 + int drawer_id = 1;
94 + int book_id = 1;
95 + int socket_id = 1;
96 int n = sizeof(SysIB_151x);
97
98 QTAILQ_FOREACH(entry, topology_list, next) {
@@ -103,12 +103,12 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
103 if (level > 3 && drawer_change) {
104 SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
105 p = fill_container(p, 3, drawer_id++);
106 - book_id = 0;
106 + book_id = 1;
107 }
108 if (level > 2 && book_change) {
109 SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
110 p = fill_container(p, 2, book_id++);
111 - socket_id = 0;
111 + socket_id = 1;
112 }
113 if (socket_change) {
114 SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));