From nobody Sun Feb 8 17:47:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631800557717219.2857532294189; Thu, 16 Sep 2021 06:55:57 -0700 (PDT) Received: from localhost ([::1]:48794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQrro-0002OL-NK for importer@patchew.org; Thu, 16 Sep 2021 09:55:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQrnD-0003W9-Ds; Thu, 16 Sep 2021 09:51:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36442 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQrnA-0006Fe-17; Thu, 16 Sep 2021 09:51:11 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 18GC8nTp017292; Thu, 16 Sep 2021 09:51:04 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3b45p02ncv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Sep 2021 09:51:04 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 18GCtw86016281; Thu, 16 Sep 2021 09:51:04 -0400 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com with ESMTP id 3b45p02ncb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Sep 2021 09:51:04 -0400 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18GDknco030178; Thu, 16 Sep 2021 13:51:02 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma01fra.de.ibm.com with ESMTP id 3b0m39scsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Sep 2021 13:51:02 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18GDowBp56033770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 13:50:58 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81F184204D; Thu, 16 Sep 2021 13:50:58 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A09342056; Thu, 16 Sep 2021 13:50:58 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.190.206]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 Sep 2021 13:50:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=DisdGJeiF7tyApeyADx3ejZllWenYnTbEiSf24GUUDE=; b=W2AVnpJBfSJYJCRHnbKLjBYN7kPBmV3JpSjvG81sGMoKNSxp0TuNPgiWsdHpAkTUIbmw gaHbS/XPGRc52NeZS0wAu7vdoMcBg2IkD4+iADjv06dqTygQmR8gJb2kFgDVZDyiVnx7 kyv5/GTrupJ+vxJ/e2gJgSULDfwkdAp8AYUCkUyt4g4ZKuG/ycubDUdFdKfx0CXifcHU YE4bME3z437rABZ/LAlepPV58rlGPQZHBsi40wsRnc8E5mVN0W4BesAcPyzdU++KSsJq 7pXDBry74+QA8nCENLMMJpEpUPNjWX3Jmw5xv58Rw+s4oeZS3xdwf0i/a7zSBTjypLzl mA== From: Pierre Morel To: qemu-s390x@nongnu.org Subject: [PATCH v3 4/4] s390x: topology: implementating Store Topology System Information Date: Thu, 16 Sep 2021 15:50:54 +0200 Message-Id: <1631800254-25762-5-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1631800254-25762-1-git-send-email-pmorel@linux.ibm.com> References: <1631800254-25762-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _YyisZWLzGX6OnKsRz5kDLfPCYdYlfV5 X-Proofpoint-GUID: Ie6zzupuSLHZVpbgjqZw4FpsDqQgQsUm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109160073 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631800558636100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The handling of STSI is enhanced with the interception of the function code 15 for storing CPU topology. Using the objects built during the pluging of CPU, we build the SYSIB 15_1_x structures. With this patch the maximum MNEST level is 2, this is also the only level allowed and only SYSIB 15_1_2 will be built. Signed-off-by: Pierre Morel --- target/s390x/kvm/kvm.c | 101 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index dd036961fe..0a5f2aced2 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -52,6 +52,7 @@ #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/s390-virtio-hcall.h" #include "hw/s390x/pv.h" +#include "hw/s390x/cpu-topology.h" =20 #ifndef DEBUG_KVM #define DEBUG_KVM 0 @@ -1908,6 +1909,102 @@ static void insert_stsi_3_2_2(S390CPU *cpu, __u64 a= ddr, uint8_t ar) } } =20 +static int stsi_15_container(void *p, int nl, int id) +{ + SysIBTl_container *tle =3D (SysIBTl_container *)p; + + tle->nl =3D nl; + tle->id =3D id; + + return sizeof(*tle); +} + +static int stsi_15_cpus(void *p, S390TopologyCores *cd) +{ + SysIBTl_cpu *tle =3D (SysIBTl_cpu *)p; + + tle->nl =3D 0; + tle->dedicated =3D cd->dedicated; + tle->polarity =3D cd->polarity; + tle->type =3D cd->cputype; + tle->origin =3D cd->origin; + tle->mask =3D cd->mask; + + return sizeof(*tle); +} + +static int set_socket(const MachineState *ms, void *p, + S390TopologySocket *socket) +{ + BusChild *kid; + int l, len =3D 0; + + len +=3D stsi_15_container(p, 1, socket->socket_id); + p +=3D len; + + QTAILQ_FOREACH_REVERSE(kid, &socket->bus->children, sibling) { + l =3D stsi_15_cpus(p, S390_TOPOLOGY_CORES(kid->child)); + p +=3D l; + len +=3D l; + } + return len; +} + +static void insert_stsi_15_1_2(const MachineState *ms, void *p) +{ + S390TopologyBook *book; + SysIB_151x *sysib; + BusChild *kid; + int level =3D 2; + int len, l; + + sysib =3D (SysIB_151x *)p; + sysib->mnest =3D level; + sysib->mag[TOPOLOGY_NR_MAG2] =3D ms->smp.sockets; + sysib->mag[TOPOLOGY_NR_MAG1] =3D ms->smp.cores; + + book =3D s390_get_topology(); + len =3D sizeof(SysIB_151x); + p +=3D len; + + QTAILQ_FOREACH_REVERSE(kid, &book->bus->children, sibling) { + l =3D set_socket(ms, p, S390_TOPOLOGY_SOCKET(kid->child)); + p +=3D l; + len +=3D l; + } + + sysib->length =3D len; +} + +static void insert_stsi_15_1_x(S390CPU *cpu, int sel2, __u64 addr, uint8_t= ar) +{ + const MachineState *machine =3D MACHINE(qdev_get_machine()); + void *p; + int ret, cc; + + /* + * Until the SCLP STSI Facility reporting the MNEST value is used, + * a sel2 value of 2 is the only value allowed in STSI 15.1.x. + */ + if (sel2 !=3D 2) { + setcc(cpu, 3); + return; + } + + p =3D g_malloc0(TARGET_PAGE_SIZE); + + insert_stsi_15_1_2(machine, p); + + if (s390_is_pv()) { + ret =3D s390_cpu_pv_mem_write(cpu, 0, p, TARGET_PAGE_SIZE); + } else { + ret =3D s390_cpu_virt_mem_write(cpu, addr, ar, p, TARGET_PAGE_SIZE= ); + } + cc =3D ret ? 3 : 0; + setcc(cpu, cc); + g_free(p); +} + static int handle_stsi(S390CPU *cpu) { CPUState *cs =3D CPU(cpu); @@ -1921,6 +2018,10 @@ static int handle_stsi(S390CPU *cpu) /* Only sysib 3.2.2 needs post-handling for now. */ insert_stsi_3_2_2(cpu, run->s390_stsi.addr, run->s390_stsi.ar); return 0; + case 15: + insert_stsi_15_1_x(cpu, run->s390_stsi.sel2, run->s390_stsi.addr, + run->s390_stsi.ar); + return 0; default: return 0; } --=20 2.25.1