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

Alexandra Winter posted 1 patch 2 weeks, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260511134909.43802-1-wintera@linux.ibm.com
Maintainers: Gautam Gala <ggala@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>
target/s390x/kvm/stsi-topology.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
[PATCH] target/s390x: Make container ids in SysIB_15x 1-based
Posted by Alexandra Winter 2 weeks, 5 days ago
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>
---
 target/s390x/kvm/stsi-topology.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/target/s390x/kvm/stsi-topology.c b/target/s390x/kvm/stsi-topology.c
index 301d41b68d..afd00da0e6 100644
--- a/target/s390x/kvm/stsi-topology.c
+++ b/target/s390x/kvm/stsi-topology.c
@@ -90,9 +90,9 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
     int last_drawer = -1;
     int last_book = -1;
     int last_socket = -1;
-    int drawer_id = 0;
-    int book_id = 0;
-    int socket_id = 0;
+    int drawer_id = 1;
+    int book_id = 1;
+    int socket_id = 1;
     int n = sizeof(SysIB_151x);
 
     QTAILQ_FOREACH(entry, topology_list, next) {
@@ -103,12 +103,12 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
         if (level > 3 && drawer_change) {
             SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
             p = fill_container(p, 3, drawer_id++);
-            book_id = 0;
+            book_id = 1;
         }
         if (level > 2 && book_change) {
             SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
             p = fill_container(p, 2, book_id++);
-            socket_id = 0;
+            socket_id = 1;
         }
         if (socket_change) {
             SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
-- 
2.39.5 (Apple Git-154)
Re: [PATCH] target/s390x: Make container ids in SysIB_15x 1-based
Posted by Cornelia Huck 1 day, 2 hours ago
On Mon, May 11 2026, Alexandra Winter <wintera@linux.ibm.com> wrote:

> 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>
> ---
>  target/s390x/kvm/stsi-topology.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Thanks, queued to s390-next.
Re: [PATCH] target/s390x: Make container ids in SysIB_15x 1-based
Posted by Hendrik Brueckner 2 weeks, 4 days ago
On Mon, May 11, 2026 at 03:49:09PM +0200, Alexandra Winter wrote:
> 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>
Re: [PATCH] target/s390x: Make container ids in SysIB_15x 1-based
Posted by Christian Borntraeger 2 weeks, 4 days ago
Am 11.05.26 um 15:49 schrieb Alexandra Winter:
> 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: Christian Borntraeger <borntraeger@linux.ibm.com>

I guess this should go via Connys s390 tree.


> ---
>   target/s390x/kvm/stsi-topology.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/target/s390x/kvm/stsi-topology.c b/target/s390x/kvm/stsi-topology.c
> index 301d41b68d..afd00da0e6 100644
> --- a/target/s390x/kvm/stsi-topology.c
> +++ b/target/s390x/kvm/stsi-topology.c
> @@ -90,9 +90,9 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
>       int last_drawer = -1;
>       int last_book = -1;
>       int last_socket = -1;
> -    int drawer_id = 0;
> -    int book_id = 0;
> -    int socket_id = 0;
> +    int drawer_id = 1;
> +    int book_id = 1;
> +    int socket_id = 1;
>       int n = sizeof(SysIB_151x);
>   
>       QTAILQ_FOREACH(entry, topology_list, next) {
> @@ -103,12 +103,12 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
>           if (level > 3 && drawer_change) {
>               SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
>               p = fill_container(p, 3, drawer_id++);
> -            book_id = 0;
> +            book_id = 1;
>           }
>           if (level > 2 && book_change) {
>               SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
>               p = fill_container(p, 2, book_id++);
> -            socket_id = 0;
> +            socket_id = 1;
>           }
>           if (socket_change) {
>               SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
Re: [PATCH] target/s390x: Make container ids in SysIB_15x 1-based
Posted by Cornelia Huck 2 days, 1 hour ago
On Tue, May 12 2026, Christian Borntraeger <borntraeger@linux.ibm.com> wrote:

> Am 11.05.26 um 15:49 schrieb Alexandra Winter:
>> 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: Christian Borntraeger <borntraeger@linux.ibm.com>
>
> I guess this should go via Connys s390 tree.

Yep, that makes sense.
Re: [PATCH] target/s390x: Make container ids in SysIB_15x 1-based
Posted by Gautam Gala 2 weeks, 4 days ago
On Mon, May 11, 2026 at 03:49:09PM +0200, Alexandra Winter wrote:
> 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>
> ---
>  target/s390x/kvm/stsi-topology.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/target/s390x/kvm/stsi-topology.c b/target/s390x/kvm/stsi-topology.c
> index 301d41b68d..afd00da0e6 100644
> --- a/target/s390x/kvm/stsi-topology.c
> +++ b/target/s390x/kvm/stsi-topology.c
> @@ -90,9 +90,9 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
>      int last_drawer = -1;
>      int last_book = -1;
>      int last_socket = -1;
> -    int drawer_id = 0;
> -    int book_id = 0;
> -    int socket_id = 0;
> +    int drawer_id = 1;
> +    int book_id = 1;
> +    int socket_id = 1;
>      int n = sizeof(SysIB_151x);
>  
>      QTAILQ_FOREACH(entry, topology_list, next) {
> @@ -103,12 +103,12 @@ static int stsi_topology_fill_sysib(S390TopologyList *topology_list,
>          if (level > 3 && drawer_change) {
>              SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
>              p = fill_container(p, 3, drawer_id++);
> -            book_id = 0;
> +            book_id = 1;
>          }
>          if (level > 2 && book_change) {
>              SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
>              p = fill_container(p, 2, book_id++);
> -            socket_id = 0;
> +            socket_id = 1;
>          }
>          if (socket_change) {
>              SYSIB_GUARD(n, sizeof(SYSIBContainerListEntry));
> -- 
> 2.39.5 (Apple Git-154)
>
Thanks, this looks correct.

Reviewed-by: Gautam Gala <ggala@linux.ibm.com>