From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678890989; cv=none; d=zohomail.com; s=zohoarc; b=g2AR2HkGm4ZKCgjkEiNGmKYdWL9yKlolzJ00JpnOQRKCvnPuMhV0IgH8BAjoJtG1Btm5+vpAEaK/II611pFsQnHG6+MpegTfJZdmdgpJ0lkvB45VqdR5owCxQUhhz/VoS3u5TytaNdXSjg+dtU6w88o/7Atx49DVJ132a4Ai41s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678890989; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+2K1AZzN0GIH6OPjFRaxlzLpszFQBi7LdUEfkX9QPcQ=; b=JN+VGDCe9f1vpxiOD6u2XzKSa0pHZWflMDNFnf1D8Hwbd+zW1XyPCnc2du5syiViHdRlHah477S6lJ78dcoitey+gPNa0OOE6tyNIes/Sjyf1jpCZr38LXiRLdZoj8tol5tStwfb8lGeWTKS38MfrnlvIEo0mgAQhq6dNyGcCAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678890989791892.1974704570184; Wed, 15 Mar 2023 07:36:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSDx-0004OD-Q6; Wed, 15 Mar 2023 10:35:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDw-0004NO-Lg; Wed, 15 Mar 2023 10:35:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDt-0007XW-Tp; Wed, 15 Mar 2023 10:35:28 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FEWSOS000897; Wed, 15 Mar 2023 14:35:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ucsu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:14 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDaJIJ024479; Wed, 15 Mar 2023 14:35:13 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ucr9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:13 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FE0SQF032232; Wed, 15 Mar 2023 14:35:10 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3pb29u8wps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:10 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZ7oM26477250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:07 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32E942004D; Wed, 15 Mar 2023 14:35:07 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BDCF22004F; Wed, 15 Mar 2023 14:35:05 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:05 +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 : mime-version : content-transfer-encoding; s=pp1; bh=+2K1AZzN0GIH6OPjFRaxlzLpszFQBi7LdUEfkX9QPcQ=; b=jj5JTk5CRB2FEFAe345it5ZzvPVBtcUOynmCpPK/fHuHvdl9hZpDYnrugfygvxrEDnQr 1yTJAtC0FL7zyAdiKeTo9My85tbZewuA9C5Ibe1MJs/p1LHVbxWc8v4HLdI99RRIdMVB CurSMryMJ1nZ0AQlgch4gryV2xYxwtc+rJOlFFOIPqm72mXCvma5r7kSrxefJBO/u99e au27SDxxbWdMywKt4Xcs5MxUdX2z6JSbcCbiHPotOhqUTksA7JZm4WdxQ96IJ4HopJN9 /G61WyevgX0KgghIscLM/i2GEhhrj+KWuhqLNVjp4/w1kOE4D/uJKuiFGH9yTeovEGPc kw== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 01/17] s390x/cpu topology: add s390 specifics to CPU topology Date: Wed, 15 Mar 2023 15:34:46 +0100 Message-Id: <20230315143502.135750-2-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dwYqQI5AlSpYZAJVSz1OT_EUtTHFWJYu X-Proofpoint-ORIG-GUID: ZdV6BdxTQ_j5rtXZ0QcDqYjbfKhDfLot X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678890990456100001 Content-Type: text/plain; charset="utf-8" S390 adds two new SMP levels, drawers and books to the CPU topology. The S390 CPU have specific topology features like dedication and entitlement to give to the guest indications on the host vCPUs scheduling and help the guest take the best decisions on the scheduling of threads on the vCPUs. Let us provide the SMP properties with books and drawers levels and S390 CPU with dedication and entitlement, Signed-off-by: Pierre Morel Reviewed-by: Thomas Huth --- qapi/machine-common.json | 22 +++++++++++++++ qapi/machine-target.json | 12 +++++++++ qapi/machine.json | 17 +++++++++--- include/hw/boards.h | 10 ++++++- include/hw/s390x/cpu-topology.h | 15 +++++++++++ target/s390x/cpu.h | 6 +++++ hw/core/machine-smp.c | 48 ++++++++++++++++++++++++++++----- hw/core/machine.c | 4 +++ hw/s390x/s390-virtio-ccw.c | 2 ++ softmmu/vl.c | 6 +++++ target/s390x/cpu.c | 7 +++++ qapi/meson.build | 1 + qemu-options.hx | 7 +++-- 13 files changed, 144 insertions(+), 13 deletions(-) create mode 100644 qapi/machine-common.json create mode 100644 include/hw/s390x/cpu-topology.h diff --git a/qapi/machine-common.json b/qapi/machine-common.json new file mode 100644 index 0000000000..73ea38d976 --- /dev/null +++ b/qapi/machine-common.json @@ -0,0 +1,22 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +## +# =3D Machines S390 data types +## + +## +# @CpuS390Entitlement: +# +# An enumeration of cpu entitlements that can be assumed by a virtual +# S390 CPU +# +# Since: 8.1 +## +{ 'enum': 'CpuS390Entitlement', + 'prefix': 'S390_CPU_ENTITLEMENT', + 'data': [ 'horizontal', 'low', 'medium', 'high' ] } + diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 2e267fa458..42a6a40333 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -342,3 +342,15 @@ 'TARGET_S390X', 'TARGET_MIPS', 'TARGET_LOONGARCH64' ] } } + +## +# @CpuS390Polarization: +# +# An enumeration of cpu polarization that can be assumed by a virtual +# S390 CPU +# +# Since: 8.1 +## +{ 'enum': 'CpuS390Polarization', + 'prefix': 'S390_CPU_POLARIZATION', + 'data': [ 'horizontal', 'vertical' ] } diff --git a/qapi/machine.json b/qapi/machine.json index 604b686e59..1cdd83f3fd 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -9,6 +9,7 @@ ## =20 { 'include': 'common.json' } +{ 'include': 'machine-common.json' } =20 ## # @SysEmuTarget: @@ -70,7 +71,7 @@ # # @thread-id: ID of the underlying host thread # -# @props: properties describing to which node/socket/core/thread +# @props: properties describing to which node/drawer/book/socket/core/thre= ad # virtual CPU belongs to, provided if supported by board # # @target: the QEMU system emulation target, which determines which @@ -902,13 +903,15 @@ # a CPU is being hotplugged. # # @node-id: NUMA node ID the CPU belongs to -# @socket-id: socket number within node/board the CPU belongs to +# @drawer-id: drawer number within node/board the CPU belongs to (since 8.= 1) +# @book-id: book number within drawer/node/board the CPU belongs to (since= 8.1) +# @socket-id: socket number within book/node/board the CPU belongs to # @die-id: die number within socket the CPU belongs to (since 4.1) # @cluster-id: cluster number within die the CPU belongs to (since 7.1) # @core-id: core number within cluster the CPU belongs to # @thread-id: thread number within core the CPU belongs to # -# Note: currently there are 6 properties that could be present +# Note: currently there are 8 properties that could be present # but management should be prepared to pass through other # properties with device_add command to allow for future # interface extension. This also requires the filed names to be kept= in @@ -918,6 +921,8 @@ ## { 'struct': 'CpuInstanceProperties', 'data': { '*node-id': 'int', + '*drawer-id': 'int', + '*book-id': 'int', '*socket-id': 'int', '*die-id': 'int', '*cluster-id': 'int', @@ -1467,6 +1472,10 @@ # # @cpus: number of virtual CPUs in the virtual machine # +# @drawers: number of drawers in the CPU topology (since 8.1) +# +# @books: number of books in the CPU topology (since 8.1) +# # @sockets: number of sockets in the CPU topology # # @dies: number of dies per socket in the CPU topology @@ -1483,6 +1492,8 @@ ## { 'struct': 'SMPConfiguration', 'data': { '*cpus': 'int', + '*drawers': 'int', + '*books': 'int', '*sockets': 'int', '*dies': 'int', '*clusters': 'int', diff --git a/include/hw/boards.h b/include/hw/boards.h index 6fbbfd56c8..9ef0bb76cf 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -131,12 +131,16 @@ typedef struct { * @clusters_supported - whether clusters are supported by the machine * @has_clusters - whether clusters are explicitly specified in the user * provided SMP configuration + * @books_supported - whether books are supported by the machine + * @drawers_supported - whether drawers are supported by the machine */ typedef struct { bool prefer_sockets; bool dies_supported; bool clusters_supported; bool has_clusters; + bool books_supported; + bool drawers_supported; } SMPCompatProps; =20 /** @@ -301,7 +305,9 @@ typedef struct DeviceMemoryState { /** * CpuTopology: * @cpus: the number of present logical processors on the machine - * @sockets: the number of sockets on the machine + * @drawers: the number of drawers on the machine + * @books: the number of books in one drawer + * @sockets: the number of sockets in one book * @dies: the number of dies in one socket * @clusters: the number of clusters in one die * @cores: the number of cores in one cluster @@ -310,6 +316,8 @@ typedef struct DeviceMemoryState { */ typedef struct CpuTopology { unsigned int cpus; + unsigned int drawers; + unsigned int books; unsigned int sockets; unsigned int dies; unsigned int clusters; diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h new file mode 100644 index 0000000000..83f31604cc --- /dev/null +++ b/include/hw/s390x/cpu-topology.h @@ -0,0 +1,15 @@ +/* + * CPU Topology + * + * Copyright IBM Corp. 2022 + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ +#ifndef HW_S390X_CPU_TOPOLOGY_H +#define HW_S390X_CPU_TOPOLOGY_H + +#define S390_TOPOLOGY_CPU_IFL 0x03 + +#endif diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7d6d01325b..f7b4cd78d1 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -131,6 +131,12 @@ struct CPUArchState { =20 #if !defined(CONFIG_USER_ONLY) uint32_t core_id; /* PoP "CPU address", same as cpu_index */ + int32_t socket_id; + int32_t book_id; + int32_t drawer_id; + bool dedicated; + uint8_t entitlement; /* Used only for vertical polarization */ + uint8_t shadow_entitlement; /* Shadow during horizontal polarization */ uint64_t cpuid; #endif =20 diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index c3dab007da..b8233df5a9 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -31,6 +31,14 @@ static char *cpu_hierarchy_to_string(MachineState *ms) MachineClass *mc =3D MACHINE_GET_CLASS(ms); GString *s =3D g_string_new(NULL); =20 + if (mc->smp_props.drawers_supported) { + g_string_append_printf(s, " * drawers (%u)", ms->smp.drawers); + } + + if (mc->smp_props.books_supported) { + g_string_append_printf(s, " * books (%u)", ms->smp.books); + } + g_string_append_printf(s, "sockets (%u)", ms->smp.sockets); =20 if (mc->smp_props.dies_supported) { @@ -73,6 +81,8 @@ void machine_parse_smp_config(MachineState *ms, { MachineClass *mc =3D MACHINE_GET_CLASS(ms); unsigned cpus =3D config->has_cpus ? config->cpus : 0; + unsigned drawers =3D config->has_drawers ? config->drawers : 0; + unsigned books =3D config->has_books ? config->books : 0; unsigned sockets =3D config->has_sockets ? config->sockets : 0; unsigned dies =3D config->has_dies ? config->dies : 0; unsigned clusters =3D config->has_clusters ? config->clusters : 0; @@ -85,6 +95,8 @@ void machine_parse_smp_config(MachineState *ms, * explicit configuration like "cpus=3D0" is not allowed. */ if ((config->has_cpus && config->cpus =3D=3D 0) || + (config->has_drawers && config->drawers =3D=3D 0) || + (config->has_books && config->books =3D=3D 0) || (config->has_sockets && config->sockets =3D=3D 0) || (config->has_dies && config->dies =3D=3D 0) || (config->has_clusters && config->clusters =3D=3D 0) || @@ -111,6 +123,19 @@ void machine_parse_smp_config(MachineState *ms, dies =3D dies > 0 ? dies : 1; clusters =3D clusters > 0 ? clusters : 1; =20 + if (!mc->smp_props.books_supported && books > 1) { + error_setg(errp, "books not supported by this machine's CPU topolo= gy"); + return; + } + books =3D books > 0 ? books : 1; + + if (!mc->smp_props.drawers_supported && drawers > 1) { + error_setg(errp, + "drawers not supported by this machine's CPU topology"); + return; + } + drawers =3D drawers > 0 ? drawers : 1; + /* compute missing values based on the provided ones */ if (cpus =3D=3D 0 && maxcpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; @@ -124,33 +149,41 @@ void machine_parse_smp_config(MachineState *ms, if (sockets =3D=3D 0) { cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (dies * clusters * cores * threads); + sockets =3D maxcpus / + (drawers * books * dies * clusters * cores * thr= eads); } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * dies * clusters * threads); + cores =3D maxcpus / + (drawers * books * sockets * dies * clusters * thr= eads); } } else { /* prefer cores over sockets since 6.2 */ if (cores =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * dies * clusters * threads); + cores =3D maxcpus / + (drawers * books * sockets * dies * clusters * thr= eads); } else if (sockets =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (dies * clusters * cores * threads); + sockets =3D maxcpus / + (drawers * books * dies * clusters * cores * thr= eads); } } =20 /* try to calculate omitted threads at last */ if (threads =3D=3D 0) { - threads =3D maxcpus / (sockets * dies * clusters * cores); + threads =3D maxcpus / + (drawers * books * sockets * dies * clusters * cores= ); } } =20 - maxcpus =3D maxcpus > 0 ? maxcpus : sockets * dies * clusters * cores = * threads; + maxcpus =3D maxcpus > 0 ? maxcpus : drawers * books * sockets * dies * + clusters * cores * threads; cpus =3D cpus > 0 ? cpus : maxcpus; =20 ms->smp.cpus =3D cpus; + ms->smp.drawers =3D drawers; + ms->smp.books =3D books; ms->smp.sockets =3D sockets; ms->smp.dies =3D dies; ms->smp.clusters =3D clusters; @@ -161,7 +194,8 @@ void machine_parse_smp_config(MachineState *ms, mc->smp_props.has_clusters =3D config->has_clusters; =20 /* sanity-check of the computed topology */ - if (sockets * dies * clusters * cores * threads !=3D maxcpus) { + if (drawers * books * sockets * dies * clusters * cores * threads !=3D + maxcpus) { g_autofree char *topo_msg =3D cpu_hierarchy_to_string(ms); error_setg(errp, "Invalid CPU topology: " "product of the hierarchy must match maxcpus: " diff --git a/hw/core/machine.c b/hw/core/machine.c index 1cf6822e06..41c7ba7027 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -831,6 +831,8 @@ static void machine_get_smp(Object *obj, Visitor *v, co= nst char *name, MachineState *ms =3D MACHINE(obj); SMPConfiguration *config =3D &(SMPConfiguration){ .has_cpus =3D true, .cpus =3D ms->smp.cpus, + .has_drawers =3D true, .drawers =3D ms->smp.drawers, + .has_books =3D true, .books =3D ms->smp.books, .has_sockets =3D true, .sockets =3D ms->smp.sockets, .has_dies =3D true, .dies =3D ms->smp.dies, .has_clusters =3D true, .clusters =3D ms->smp.clusters, @@ -1096,6 +1098,8 @@ static void machine_initfn(Object *obj) /* default to mc->default_cpus */ ms->smp.cpus =3D mc->default_cpus; ms->smp.max_cpus =3D mc->default_cpus; + ms->smp.drawers =3D 1; + ms->smp.books =3D 1; ms->smp.sockets =3D 1; ms->smp.dies =3D 1; ms->smp.clusters =3D 1; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 503f212a31..1a9bcda8b6 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -736,6 +736,8 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) mc->no_sdcard =3D 1; mc->max_cpus =3D S390_MAX_CPUS; mc->has_hotpluggable_cpus =3D true; + mc->smp_props.books_supported =3D true; + mc->smp_props.drawers_supported =3D true; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D s390_get_hotplug_handler; mc->cpu_index_to_instance_props =3D s390_cpu_index_to_props; diff --git a/softmmu/vl.c b/softmmu/vl.c index 3340f63c37..bc293f8100 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -724,6 +724,12 @@ static QemuOptsList qemu_smp_opts =3D { { .name =3D "cpus", .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "drawers", + .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "books", + .type =3D QEMU_OPT_NUMBER, }, { .name =3D "sockets", .type =3D QEMU_OPT_NUMBER, diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index b10a8541ff..b80c617c53 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -37,6 +37,7 @@ #ifndef CONFIG_USER_ONLY #include "sysemu/reset.h" #endif +#include "hw/s390x/cpu-topology.h" =20 #define CR0_RESET 0xE0UL #define CR14_RESET 0xC2000000UL; @@ -259,6 +260,12 @@ static gchar *s390_gdb_arch_name(CPUState *cs) static Property s390x_cpu_properties[] =3D { #if !defined(CONFIG_USER_ONLY) DEFINE_PROP_UINT32("core-id", S390CPU, env.core_id, 0), + DEFINE_PROP_INT32("socket-id", S390CPU, env.socket_id, -1), + DEFINE_PROP_INT32("book-id", S390CPU, env.book_id, -1), + DEFINE_PROP_INT32("drawer-id", S390CPU, env.drawer_id, -1), + DEFINE_PROP_BOOL("dedicated", S390CPU, env.dedicated, false), + DEFINE_PROP_UINT8("entitlement", S390CPU, env.entitlement, + S390_CPU_ENTITLEMENT_MEDIUM), #endif DEFINE_PROP_END_OF_LIST() }; diff --git a/qapi/meson.build b/qapi/meson.build index fbdb442fdf..b5b01fb7b5 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -35,6 +35,7 @@ qapi_all_modules =3D [ 'error', 'introspect', 'job', + 'machine-common', 'machine', 'machine-target', 'migration', diff --git a/qemu-options.hx b/qemu-options.hx index d42f60fb91..4c79e153fb 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -250,11 +250,14 @@ SRST ERST =20 DEF("smp", HAS_ARG, QEMU_OPTION_smp, - "-smp [[cpus=3D]n][,maxcpus=3Dmaxcpus][,sockets=3Dsockets][,dies=3Ddie= s][,clusters=3Dclusters][,cores=3Dcores][,threads=3Dthreads]\n" + "-smp [[cpus=3D]n][,maxcpus=3Dmaxcpus][,drawers=3Ddrawers][,books=3Dbo= oks][,sockets=3Dsockets]\n" + " [,dies=3Ddies][,clusters=3Dclusters][,cores=3Dcores][,= threads=3Dthreads]\n" " set the number of initial CPUs to 'n' [default=3D1]\n" " maxcpus=3D maximum number of total CPUs, including\n" " offline CPUs for hotplug, etc\n" - " sockets=3D number of sockets on the machine board\n" + " drawers=3D number of drawers on the machine board\n" + " books=3D number of books in one drawer\n" + " sockets=3D number of sockets in one book\n" " dies=3D number of dies in one socket\n" " clusters=3D number of clusters in one die\n" " cores=3D number of cores in one cluster\n" --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678890972; cv=none; d=zohomail.com; s=zohoarc; b=O5lpnZSkyEuN91Ik+Z+AhNoQVAvxE32OtDmwi4BFACqrMZpg0I9dUzZnobyqRSmblsZHPx5aeps7q+kazPPmPP5fDjJZ90OsGu9T9o1TN/2Y8QIPOdcAmDG9T8AChon+aKkEMOvgZNlwy2+Xk4jXgvzegOl9u2zwK6y5+83jBVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678890972; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IHQKFZt5vOy3WbIUKj+kc+DOHlhzgTfHykXFJpCuu2s=; b=PtqjZHiFdTZSC0+htOmsbqA8ef6NSEZeM18p8ZyacBa66um1Oc1jP+DRXl0f5M2MB4pltdtwM599HSOH6MdHoYKRX+LbuICjIF7yuFEldSWAcw3yA4uENGWAwcgADIMtfdNCTL+OHwX6hU3kTYSAETqCXk9xTImT1XV99bR6Q+Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678890972552249.72172597455574; Wed, 15 Mar 2023 07:36:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSDx-0004OG-Sw; Wed, 15 Mar 2023 10:35:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDw-0004NN-L2; Wed, 15 Mar 2023 10:35:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDu-0007Xr-6w; Wed, 15 Mar 2023 10:35:28 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FE9jYX032195; Wed, 15 Mar 2023 14:35:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsg2p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:15 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FEZF1p018605; Wed, 15 Mar 2023 14:35:15 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsg0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:15 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN5pvi014945; Wed, 15 Mar 2023 14:35:12 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3pb29t0rg3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:12 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZ8Fo25232046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:08 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8F8020043; Wed, 15 Mar 2023 14:35:08 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E9D820040; Wed, 15 Mar 2023 14:35:07 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:07 +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 : mime-version : content-transfer-encoding; s=pp1; bh=IHQKFZt5vOy3WbIUKj+kc+DOHlhzgTfHykXFJpCuu2s=; b=HbIIHSZk7YgzO5K4BqUjP8Sfs7GBWsRFkzYXN6OhbXeB2YgcPwn4Kc4/op9fbHUaH61x Ur6T0dN9WuOAK2uDjlaG53tTjoSwG58u2dkBZw8ig5+8xoqwiuBGrIf8zBbb/g90fDYM l/+7q/TPpx4evaR2YH0EnvZPpxCm1f+HCNwgRCBlHSejASIq5P7K0jYV/0DsMHm+jEJi AWRHkYUkDerKuKvFTxvaHG5MaKiVdOvqMbmAQ9gJCkYEC23XgogStvSwqIiG2E9nvA4O 0DEAIrHZGNBjCqwwBM9J1XdKkExALlxTJrFKxse53tR7xcglFgsiIFtcSwZSz4UNpaAD cQ== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 02/17] s390x/cpu topology: add topology entries on CPU hotplug Date: Wed, 15 Mar 2023 15:34:47 +0100 Message-Id: <20230315143502.135750-3-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: okbAd31ZpujDeueEsNxLHXSbSI2n8Q02 X-Proofpoint-ORIG-GUID: bft3l432C2T0PkZSZ3LmriPvHe4Z4DLs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 spamscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678890974272100003 Content-Type: text/plain; charset="utf-8" The topology information are attributes of the CPU and are specified during the CPU device creation. On hot plug we: - calculate the default values for the topology for drawers, books and sockets in the case they are not specified. - verify the CPU attributes - check that we have still room on the desired socket The possibility to insert a CPU in a mask is dependent on the number of cores allowed in a socket, a book or a drawer, the checking is done during the hot plug of the CPU to have an immediate answer. If the complete topology is not specified, the core is added in the physical topology based on its core ID and it gets defaults values for the modifier attributes. This way, starting QEMU without specifying the topology can still get some advantage of the CPU topology. Signed-off-by: Pierre Morel --- include/hw/s390x/cpu-topology.h | 45 +++++ hw/s390x/cpu-topology.c | 300 ++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 22 ++- hw/s390x/meson.build | 1 + 4 files changed, 366 insertions(+), 2 deletions(-) create mode 100644 hw/s390x/cpu-topology.c diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index 83f31604cc..76149de077 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -10,6 +10,51 @@ #ifndef HW_S390X_CPU_TOPOLOGY_H #define HW_S390X_CPU_TOPOLOGY_H =20 +#ifndef CONFIG_USER_ONLY + +#include "qemu/queue.h" +#include "hw/boards.h" +#include "qapi/qapi-types-machine-target.h" + #define S390_TOPOLOGY_CPU_IFL 0x03 =20 +typedef struct S390Topology { + uint8_t *cores_per_socket; + CpuTopology *smp; + CpuS390Polarization polarization; +} S390Topology; + +#ifdef CONFIG_KVM +bool s390_has_topology(void); +void s390_topology_setup_cpu(MachineState *ms, S390CPU *cpu, Error **errp); +#else +static inline bool s390_has_topology(void) +{ + return false; +} +static inline void s390_topology_setup_cpu(MachineState *ms, + S390CPU *cpu, + Error **errp) {} +#endif + +extern S390Topology s390_topology; +int s390_socket_nb(S390CPU *cpu); + +static inline int s390_std_socket(int n, CpuTopology *smp) +{ + return (n / smp->cores) % smp->sockets; +} + +static inline int s390_std_book(int n, CpuTopology *smp) +{ + return (n / (smp->cores * smp->sockets)) % smp->books; +} + +static inline int s390_std_drawer(int n, CpuTopology *smp) +{ + return (n / (smp->cores * smp->sockets * smp->books)) % smp->drawers; +} + +#endif /* CONFIG_USER_ONLY */ + #endif diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c new file mode 100644 index 0000000000..cab15edd15 --- /dev/null +++ b/hw/s390x/cpu-topology.c @@ -0,0 +1,300 @@ +/* + * CPU Topology + * + * Copyright IBM Corp. 2022 + * Author(s): Pierre Morel + + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "hw/qdev-properties.h" +#include "hw/boards.h" +#include "qemu/typedefs.h" +#include "target/s390x/cpu.h" +#include "hw/s390x/s390-virtio-ccw.h" +#include "hw/s390x/cpu-topology.h" + +/* + * s390_topology is used to keep the topology information. + * .cores_per_socket: tracks information on the count of cores + * per socket. + * .smp: keeps track of the machine topology. + * + */ +S390Topology s390_topology =3D { + /* will be initialized after the cpu model is realized */ + .cores_per_socket =3D NULL, + .smp =3D NULL, + .polarization =3D S390_CPU_POLARIZATION_HORIZONTAL, +}; + +/** + * s390_socket_nb: + * @cpu: s390x CPU + * + * Returns the socket number used inside the cores_per_socket array + * for a cpu. + */ +int s390_socket_nb(S390CPU *cpu) +{ + return (cpu->env.drawer_id * s390_topology.smp->books + cpu->env.book_= id) * + s390_topology.smp->sockets + cpu->env.socket_id; +} + +/** + * s390_has_topology: + * + * Return value: if the topology is supported by the machine. + */ +bool s390_has_topology(void) +{ + return false; +} + +/** + * s390_topology_init: + * @ms: the machine state where the machine topology is defined + * + * Keep track of the machine topology. + * + * Allocate an array to keep the count of cores per socket. + * The index of the array starts at socket 0 from book 0 and + * drawer 0 up to the maximum allowed by the machine topology. + */ +static void s390_topology_init(MachineState *ms) +{ + CpuTopology *smp =3D &ms->smp; + + s390_topology.smp =3D smp; + s390_topology.cores_per_socket =3D g_new0(uint8_t, smp->sockets * + smp->books * smp->drawers); +} + +/** + * s390_topology_cpu_default: + * @cpu: pointer to a S390CPU + * @errp: Error pointer + * + * Setup the default topology if no attributes are already set. + * Passing a CPU with some, but not all, attributes set is considered + * an error. + * + * The function calculates the (drawer_id, book_id, socket_id) + * topology by filling the cores starting from the first socket + * (0, 0, 0) up to the last (smp->drawers, smp->books, smp->sockets). + * + * CPU type, entitlement and dedication have defaults values set in the + * s390x_cpu_properties, however entitlement is forced to 0 'none' when + * the polarization is horizontale. + */ +static void s390_topology_cpu_default(S390CPU *cpu, Error **errp) +{ + CpuTopology *smp =3D s390_topology.smp; + CPUS390XState *env =3D &cpu->env; + + /* All geometry topology attributes must be set or all unset */ + if ((env->socket_id < 0 || env->book_id < 0 || env->drawer_id < 0) && + (env->socket_id >=3D 0 || env->book_id >=3D 0 || env->drawer_id >= =3D 0)) { + error_setg(errp, + "Please define all or none of the topology geometry att= ributes"); + return; + } + + /* Check if one of the geometry topology is unset */ + if (env->socket_id < 0) { + /* Calculate default geometry topology attributes */ + env->socket_id =3D s390_std_socket(env->core_id, smp); + env->book_id =3D s390_std_book(env->core_id, smp); + env->drawer_id =3D s390_std_drawer(env->core_id, smp); + } +} + +/** + * s390_topology_check: + * @socket_id: socket to check + * @book_id: book to check + * @drawer_id: drawer to check + * @entitlement: entitlement to check + * @dedicated: dedication to check + * @errp: Error pointer + * + * The function first setup default values and then checks if the topology + * attributes fits inside the system topology. + */ +static void s390_topology_check(uint16_t socket_id, uint16_t book_id, + uint16_t drawer_id, uint16_t entitlement, + bool dedicated, Error **errp) +{ + CpuTopology *smp =3D s390_topology.smp; + ERRP_GUARD(); + + if (socket_id >=3D smp->sockets) { + error_setg(errp, "Unavailable socket: %d", socket_id); + return; + } + if (book_id >=3D smp->books) { + error_setg(errp, "Unavailable book: %d", book_id); + return; + } + if (drawer_id >=3D smp->drawers) { + error_setg(errp, "Unavailable drawer: %d", drawer_id); + return; + } + if (entitlement >=3D S390_CPU_ENTITLEMENT__MAX) { + error_setg(errp, "Unknown entitlement: %d", entitlement); + return; + } + if (dedicated && (entitlement =3D=3D S390_CPU_ENTITLEMENT_LOW || + entitlement =3D=3D S390_CPU_ENTITLEMENT_MEDIUM)) { + error_setg(errp, "A dedicated cpu implies high entitlement"); + return; + } +} + +/** + * s390_topology_add_core_to_socket: + * @cpu: the new S390CPU to insert in the topology structure + * @drawer_id: new drawer_id + * @book_id: new book_id + * @socket_id: new socket_id + * @creation: if is true the CPU is a new CPU and there is no old socket + * to handle. + * if is false, this is a moving the CPU and old socket count + * must be decremented. + * @errp: the error pointer + * + */ +static void s390_topology_add_core_to_socket(S390CPU *cpu, int drawer_id, + int book_id, int socket_id, + bool creation, Error **errp) +{ + int old_socket_entry =3D s390_socket_nb(cpu); + int new_socket_entry; + + if (creation) { + new_socket_entry =3D old_socket_entry; + } else { + new_socket_entry =3D (drawer_id * s390_topology.smp->books + book_= id) * + s390_topology.smp->sockets + socket_id; + } + + /* Check for space on new socket */ + if ((new_socket_entry !=3D old_socket_entry) && + (s390_topology.cores_per_socket[new_socket_entry] >=3D + s390_topology.smp->cores)) { + error_setg(errp, "No more space on this socket"); + return; + } + + /* Update the count of cores in sockets */ + s390_topology.cores_per_socket[new_socket_entry] +=3D 1; + if (!creation) { + s390_topology.cores_per_socket[old_socket_entry] -=3D 1; + } +} + +/** + * s390_update_cpu_props: + * @ms: the machine state + * @cpu: the CPU for which to update the properties from the environment. + * + */ +static void s390_update_cpu_props(MachineState *ms, S390CPU *cpu) +{ + CpuInstanceProperties *props; + + props =3D &ms->possible_cpus->cpus[cpu->env.core_id].props; + + props->socket_id =3D cpu->env.socket_id; + props->book_id =3D cpu->env.book_id; + props->drawer_id =3D cpu->env.drawer_id; +} + +/** + * s390_normalize_entitlement: + * @cpu: CPU for which to normalize entitlement + * + * Even when the entitlement given by the user is correct in itself + * it may not correspond to the current polarization. + * Save the value corresponding to a vertical polarization inside + * the shadow and store the effective entitlement according to the + * polarization. + */ +static void s390_normalize_entitlement(S390CPU *cpu) +{ + /* Save entitlement for vertical polarization */ + if (cpu->env.entitlement =3D=3D S390_CPU_ENTITLEMENT_HORIZONTAL) { + cpu->env.shadow_entitlement =3D S390_CPU_ENTITLEMENT_MEDIUM; + } else { + cpu->env.shadow_entitlement =3D cpu->env.entitlement; + } + + /* Set the effective entitlement according to polarization */ + if (s390_topology.polarization =3D=3D S390_CPU_POLARIZATION_HORIZONTAL= ) { + cpu->env.entitlement =3D S390_CPU_ENTITLEMENT_HORIZONTAL; + } else if (cpu->env.entitlement =3D=3D S390_CPU_ENTITLEMENT_HORIZONTAL= ) { + if (cpu->env.dedicated) { + cpu->env.entitlement =3D S390_CPU_ENTITLEMENT_HIGH; + } else { + cpu->env.entitlement =3D S390_CPU_ENTITLEMENT_MEDIUM; + } + } +} + +/** + * s390_topology_setup_cpu: + * @ms: MachineState used to initialize the topology structure on + * first call. + * @cpu: the new S390CPU to insert in the topology structure + * @errp: the error pointer + * + * Called from CPU Hotplug to check and setup the CPU attributes + * before to insert the CPU in the topology. + * There is no use to update the MTCR explicitely here because it + * will be updated by KVM on creation of the new vCPU. + */ +void s390_topology_setup_cpu(MachineState *ms, S390CPU *cpu, Error **errp) +{ + ERRP_GUARD(); + + /* + * We do not want to initialize the topology if the cpu model + * does not support topology, consequently, we have to wait for + * the first CPU to be realized, which realizes the CPU model + * to initialize the topology structures. + * + * s390_topology_setup_cpu() is called from the cpu hotplug. + */ + if (!s390_topology.cores_per_socket) { + s390_topology_init(ms); + } + + s390_topology_cpu_default(cpu, errp); + if (*errp) { + return; + } + + s390_topology_check(cpu->env.socket_id, cpu->env.book_id, + cpu->env.drawer_id, cpu->env.entitlement, + cpu->env.dedicated, errp); + if (*errp) { + return; + } + + /* Set the CPU inside the socket */ + s390_topology_add_core_to_socket(cpu, 0, 0, 0, true, errp); + if (*errp) { + return; + } + + /* Setup shadow and effective entitlement */ + s390_normalize_entitlement(cpu); + + /* topology tree is reflected in props */ + s390_update_cpu_props(ms, cpu); +} diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 1a9bcda8b6..9df60ac447 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -45,6 +45,7 @@ #include "hw/s390x/pv.h" #include "migration/blocker.h" #include "qapi/visitor.h" +#include "hw/s390x/cpu-topology.h" =20 static Error *pv_mig_blocker; =20 @@ -311,10 +312,18 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev, { MachineState *ms =3D MACHINE(hotplug_dev); S390CPU *cpu =3D S390_CPU(dev); + ERRP_GUARD(); =20 g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); ms->possible_cpus->cpus[cpu->env.core_id].cpu =3D OBJECT(dev); =20 + if (s390_has_topology()) { + s390_topology_setup_cpu(ms, cpu, errp); + if (*errp) { + return; + } + } + if (dev->hotplugged) { raise_irq_cpu_hotplug(); } @@ -554,11 +563,20 @@ static const CPUArchIdList *s390_possible_cpu_arch_id= s(MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (i =3D 0; i < ms->possible_cpus->len; i++) { + CpuInstanceProperties *props =3D &ms->possible_cpus->cpus[i].props; + ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; ms->possible_cpus->cpus[i].arch_id =3D i; - ms->possible_cpus->cpus[i].props.has_core_id =3D true; - ms->possible_cpus->cpus[i].props.core_id =3D i; + + props->has_core_id =3D true; + props->core_id =3D i; + props->has_socket_id =3D true; + props->socket_id =3D s390_std_socket(i, &ms->smp); + props->has_book_id =3D true; + props->book_id =3D s390_std_book(i, &ms->smp); + props->has_drawer_id =3D true; + props->drawer_id =3D s390_std_drawer(i, &ms->smp); } =20 return ms->possible_cpus; diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index f291016fee..58dfbdff4f 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -24,6 +24,7 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files( 's390-stattrib-kvm.c', 'pv.c', 's390-pci-kvm.c', + 'cpu-topology.c', )) s390x_ss.add(when: 'CONFIG_TCG', if_true: files( 'tod-tcg.c', --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891062; cv=none; d=zohomail.com; s=zohoarc; b=XQQv/YvMAiPpgbE3TkPQN47ODfhtJ2YSc8pHvGjwsGUbIIyN7Q6vv+X/VxRmB7jxAtR7Ov+JVaO5jB25iO+NBKYPDR/6as5Coehe2inGOCLcbdRjsh0RE2jS2yQ9Kzz6nXGnWsWf88ipnqH8psnJDfQJ9FGkg/6zO3UJOLqLFSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891062; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HwF5AW6jj2tiO5mhiH8CML+Oi1KMGPR7x8B6DhmlPf4=; b=QMo3l9wIS9rvEIJKg6rApHYRVPhopcc9TJqu7HHh6xlRw6oZvkeQwhAsxM0kBXCU6G+qw0QaZiyMQ3byV0Gs0ROxQXK+QzCgdhC4PA9TaYHfVLugkPCNA8/mfz252mXlc+qCrpb6NHHzltYuMh71SFkNw5Zlmb4ZyAbrBxtA28s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891062848250.18899154281326; Wed, 15 Mar 2023 07:37:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSE3-0004Rl-Qg; Wed, 15 Mar 2023 10:35:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDy-0004P3-V9; Wed, 15 Mar 2023 10:35:33 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDw-0007Ye-Fi; Wed, 15 Mar 2023 10:35:30 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FCpsKH000891; Wed, 15 Mar 2023 14:35:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ucum-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:17 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FCrvkT009786; Wed, 15 Mar 2023 14:35:17 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ucta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:16 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FECjln008595; Wed, 15 Mar 2023 14:35:14 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3pb29sgwje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:13 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZAjY42271182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:10 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44E842004B; Wed, 15 Mar 2023 14:35:10 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D595E20040; Wed, 15 Mar 2023 14:35:08 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:08 +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 : mime-version : content-transfer-encoding; s=pp1; bh=HwF5AW6jj2tiO5mhiH8CML+Oi1KMGPR7x8B6DhmlPf4=; b=H3m4IK+lQ5xOgdsVKOHNtoOUepMAUwHkiumrvmEex0R6OUT9+s1poOA0gJE80ZhjObr7 EJQ8J+NqLNImq2QdCpqKowXGzwWmzvhSl3qJw3NcOHtmXiyOsJVcRU2hmpqpTcSDZTpg gqr05AMxcRldA0IM6pBCtC8sfUVzTldYZ7ZTa3fRJ2f9Rq/paumCdLjyn+UpJeV5wtMD +Btav+Lm9d9tW++HstxGDWeUM8Ud0aW1x/s7+80vrOpXVPsC9g1uT/UGjyRL3JIY/J6J /y9QnmtN+TI9WNzhgsN6XKm1/OVxrrtjRuONd2vLQfRM9InwOWP6NfhOrrAlPv6n1wqL mw== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 03/17] target/s390x/cpu topology: handle STSI(15) and build the SYSIB Date: Wed, 15 Mar 2023 15:34:48 +0100 Message-Id: <20230315143502.135750-4-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: lwVvc2BgkwIgGcunhdXzrINhmszt5CxG X-Proofpoint-ORIG-GUID: SZMUJ1tfIy2ZZv6pVVcaLgCWgV6BoP6- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891064594100007 Content-Type: text/plain; charset="utf-8" On interception of STSI(15.1.x) the System Information Block (SYSIB) is built from the list of pre-ordered topology entries. Signed-off-by: Pierre Morel --- include/hw/s390x/cpu-topology.h | 21 +++ include/hw/s390x/sclp.h | 1 + target/s390x/cpu.h | 72 ++++++++ hw/s390x/cpu-topology.c | 12 ++ target/s390x/kvm/cpu_topology.c | 310 ++++++++++++++++++++++++++++++++ target/s390x/kvm/kvm.c | 5 +- target/s390x/kvm/meson.build | 3 +- 7 files changed, 422 insertions(+), 2 deletions(-) create mode 100644 target/s390x/kvm/cpu_topology.c diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index 76149de077..7a1dd6b136 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -18,8 +18,29 @@ =20 #define S390_TOPOLOGY_CPU_IFL 0x03 =20 +typedef union s390_topology_id { + uint64_t id; + struct { + uint8_t sentinel; + uint8_t drawer; + uint8_t book; + uint8_t socket; + uint8_t dedicated; + uint8_t entitlement; + uint8_t type; + uint8_t origin; + }; +} s390_topology_id; + +typedef struct S390TopologyEntry { + QTAILQ_ENTRY(S390TopologyEntry) next; + s390_topology_id id; + uint64_t mask; +} S390TopologyEntry; + typedef struct S390Topology { uint8_t *cores_per_socket; + QTAILQ_HEAD(, S390TopologyEntry) list; CpuTopology *smp; CpuS390Polarization polarization; } S390Topology; diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index d3ade40a5a..712fd68123 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -112,6 +112,7 @@ typedef struct CPUEntry { } QEMU_PACKED CPUEntry; =20 #define SCLP_READ_SCP_INFO_FIXED_CPU_OFFSET 128 +#define SCLP_READ_SCP_INFO_MNEST 2 typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax; diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index f7b4cd78d1..61210303e4 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -561,6 +561,25 @@ typedef struct SysIB_322 { } SysIB_322; QEMU_BUILD_BUG_ON(sizeof(SysIB_322) !=3D 4096); =20 +#define S390_TOPOLOGY_MAG 6 +#define S390_TOPOLOGY_MAG6 0 +#define S390_TOPOLOGY_MAG5 1 +#define S390_TOPOLOGY_MAG4 2 +#define S390_TOPOLOGY_MAG3 3 +#define S390_TOPOLOGY_MAG2 4 +#define S390_TOPOLOGY_MAG1 5 +/* Configuration topology */ +typedef struct SysIB_151x { + uint8_t reserved0[2]; + uint16_t length; + uint8_t mag[S390_TOPOLOGY_MAG]; + uint8_t reserved1; + uint8_t mnest; + uint32_t reserved2; + char tle[]; +} SysIB_151x; +QEMU_BUILD_BUG_ON(sizeof(SysIB_151x) !=3D 16); + typedef union SysIB { SysIB_111 sysib_111; SysIB_121 sysib_121; @@ -568,9 +587,62 @@ typedef union SysIB { SysIB_221 sysib_221; SysIB_222 sysib_222; SysIB_322 sysib_322; + SysIB_151x sysib_151x; } SysIB; QEMU_BUILD_BUG_ON(sizeof(SysIB) !=3D 4096); =20 +/* + * CPU Topology List provided by STSI with fc=3D15 provides a list + * of two different Topology List Entries (TLE) types to specify + * the topology hierarchy. + * + * - Container Topology List Entry + * Defines a container to contain other Topology List Entries + * of any type, nested containers or CPU. + * - CPU Topology List Entry + * Specifies the CPUs position, type, entitlement and polarization + * of the CPUs contained in the last Container TLE. + * + * There can be theoretically up to five levels of containers, QEMU + * uses only three levels, the drawer's, book's and socket's level. + * + * A container with a nesting level (NL) greater than 1 can only + * contain another container of nesting level NL-1. + * + * A container of nesting level 1 (socket), contains as many CPU TLE + * as needed to describe the position and qualities of all CPUs inside + * the container. + * The qualities of a CPU are polarization, entitlement and type. + * + * The CPU TLE defines the position of the CPUs of identical qualities + * using a 64bits mask which first bit has its offset defined by + * the CPU address orgin field of the CPU TLE like in: + * CPU address =3D origin * 64 + bit position within the mask + * + */ +/* Container type Topology List Entry */ +typedef struct SysIBTl_container { + uint8_t nl; + uint8_t reserved[6]; + uint8_t id; +} SysIBTl_container; +QEMU_BUILD_BUG_ON(sizeof(SysIBTl_container) !=3D 8); + +/* CPU type Topology List Entry */ +typedef struct SysIBTl_cpu { + uint8_t nl; + uint8_t reserved0[3]; +#define SYSIB_TLE_POLARITY_MASK 0x03 +#define SYSIB_TLE_DEDICATED 0x04 + uint8_t flags; + uint8_t type; + uint16_t origin; + uint64_t mask; +} SysIBTl_cpu; +QEMU_BUILD_BUG_ON(sizeof(SysIBTl_cpu) !=3D 16); + +void insert_stsi_15_1_x(S390CPU *cpu, int sel2, uint64_t addr, uint8_t ar); + /* MMU defines */ #define ASCE_ORIGIN (~0xfffULL) /* segment table origin = */ #define ASCE_SUBSPACE 0x200 /* subspace group control = */ diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index cab15edd15..36c8c687b8 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -24,6 +24,9 @@ * .cores_per_socket: tracks information on the count of cores * per socket. * .smp: keeps track of the machine topology. + * .list: queue the topology entries inside which + * we keep the information on the CPU topology. + * .polarization: the current subsystem polarization * */ S390Topology s390_topology =3D { @@ -31,6 +34,7 @@ S390Topology s390_topology =3D { .cores_per_socket =3D NULL, .smp =3D NULL, .polarization =3D S390_CPU_POLARIZATION_HORIZONTAL, + .list =3D QTAILQ_HEAD_INITIALIZER(s390_topology.list), }; =20 /** @@ -65,14 +69,22 @@ bool s390_has_topology(void) * Allocate an array to keep the count of cores per socket. * The index of the array starts at socket 0 from book 0 and * drawer 0 up to the maximum allowed by the machine topology. + * + * Insert a sentinel entry with a non null value. + * This entry will never be free. */ static void s390_topology_init(MachineState *ms) { CpuTopology *smp =3D &ms->smp; + S390TopologyEntry *entry; =20 s390_topology.smp =3D smp; s390_topology.cores_per_socket =3D g_new0(uint8_t, smp->sockets * smp->books * smp->drawers); + + entry =3D g_malloc0(sizeof(S390TopologyEntry)); + entry->id.sentinel =3D 0xff; + QTAILQ_INSERT_HEAD(&s390_topology.list, entry, next); } =20 /** diff --git a/target/s390x/kvm/cpu_topology.c b/target/s390x/kvm/cpu_topolog= y.c new file mode 100644 index 0000000000..5ad20c1efa --- /dev/null +++ b/target/s390x/kvm/cpu_topology.c @@ -0,0 +1,310 @@ +/* + * QEMU S390x CPU Topology + * + * Copyright IBM Corp. 2022 + * Author(s): Pierre Morel + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ +#include "qemu/osdep.h" +#include "cpu.h" +#include "hw/s390x/pv.h" +#include "hw/sysbus.h" +#include "hw/s390x/sclp.h" +#include "hw/s390x/cpu-topology.h" + +/** + * fill_container: + * @p: The address of the container TLE to fill + * @level: The level of nesting for this container + * @id: The container receives a uniq ID inside its own container + * + * Returns the next free TLE entry. + */ +static char *fill_container(char *p, int level, int id) +{ + SysIBTl_container *tle =3D (SysIBTl_container *)p; + + tle->nl =3D level; + tle->id =3D id; + return p + sizeof(*tle); +} + +/** + * fill_tle_cpu: + * @p: The address of the CPU TLE to fill + * @entry: a pointer to the S390TopologyEntry defining this + * CPU container. + * + * Returns the next free TLE entry. + */ +static char *fill_tle_cpu(char *p, S390TopologyEntry *entry) +{ + SysIBTl_cpu *tle =3D (SysIBTl_cpu *)p; + s390_topology_id topology_id =3D entry->id; + + tle->nl =3D 0; + if (topology_id.dedicated) { + tle->flags =3D SYSIB_TLE_DEDICATED; + } + tle->flags |=3D topology_id.entitlement; + tle->type =3D topology_id.type; + tle->origin =3D cpu_to_be16(topology_id.origin * 64); + tle->mask =3D cpu_to_be64(entry->mask); + return p + sizeof(*tle); +} + +/* + * Macro to check that the size of data after increment + * will not get bigger than the size of the SysIB. + */ +#define SYSIB_GUARD(data, x) do { \ + data +=3D x; \ + if (data > sizeof(SysIB)) { \ + return 0; \ + } \ + } while (0) + +/** + * stsi_topology_fill_sysib: + * @p: A pointer to the position of the first TLE + * @level: The nested level wanted by the guest + * + * Fill the SYSIB with the topology information as described in + * the PoP, nesting containers as appropriate, with the maximum + * nesting limited by @level. + * + * Return value: + * On success: the size of the SysIB_15x after being filled with TLE. + * On error: 0 in the case we would overrun the end of the SysIB. + */ +static int stsi_topology_fill_sysib(char *p, int level) +{ + S390TopologyEntry *entry; + int last_drawer =3D -1; + int last_book =3D -1; + int last_socket =3D -1; + int drawer_id =3D 0; + int book_id =3D 0; + int socket_id =3D 0; + int n =3D sizeof(SysIB_151x); + + QTAILQ_FOREACH(entry, &s390_topology.list, next) { + bool drawer_change =3D last_drawer !=3D entry->id.drawer; + bool book_change =3D drawer_change || last_book !=3D entry->id.boo= k; + bool socket_change =3D book_change || last_socket !=3D entry->id.s= ocket; + + /* If we reach the sentinel get out */ + if (entry->id.sentinel) { + break; + } + + if (level > 3 && drawer_change) { + SYSIB_GUARD(n, sizeof(SysIBTl_container)); + p =3D fill_container(p, 3, drawer_id++); + book_id =3D 0; + } + if (level > 2 && book_change) { + SYSIB_GUARD(n, sizeof(SysIBTl_container)); + p =3D fill_container(p, 2, book_id++); + socket_id =3D 0; + } + if (socket_change) { + SYSIB_GUARD(n, sizeof(SysIBTl_container)); + p =3D fill_container(p, 1, socket_id++); + } + + SYSIB_GUARD(n, sizeof(SysIBTl_cpu)); + p =3D fill_tle_cpu(p, entry); + last_drawer =3D entry->id.drawer; + last_book =3D entry->id.book; + last_socket =3D entry->id.socket; + } + + return n; +} + +/** + * setup_stsi: + * sysib: pointer to a SysIB to be filled with SysIB_151x data + * level: Nested level specified by the guest + * + * Setup the SYSIB for STSI 15.1, the header as well as the description + * of the topology. + */ +static int setup_stsi(SysIB_151x *sysib, int level) +{ + sysib->mnest =3D level; + switch (level) { + case 4: + sysib->mag[S390_TOPOLOGY_MAG4] =3D current_machine->smp.drawers; + sysib->mag[S390_TOPOLOGY_MAG3] =3D current_machine->smp.books; + sysib->mag[S390_TOPOLOGY_MAG2] =3D current_machine->smp.sockets; + sysib->mag[S390_TOPOLOGY_MAG1] =3D current_machine->smp.cores; + break; + case 3: + sysib->mag[S390_TOPOLOGY_MAG3] =3D current_machine->smp.drawers * + current_machine->smp.books; + sysib->mag[S390_TOPOLOGY_MAG2] =3D current_machine->smp.sockets; + sysib->mag[S390_TOPOLOGY_MAG1] =3D current_machine->smp.cores; + break; + case 2: + sysib->mag[S390_TOPOLOGY_MAG2] =3D current_machine->smp.drawers * + current_machine->smp.books * + current_machine->smp.sockets; + sysib->mag[S390_TOPOLOGY_MAG1] =3D current_machine->smp.cores; + break; + } + + return stsi_topology_fill_sysib(sysib->tle, level); +} + +/** + * s390_topology_add_cpu_to_entry: + * @entry: Topology entry to setup + * @cpu: the S390CPU to add + * + * Set the core bit inside the topology mask and + * increments the number of cores for the socket. + */ +static void s390_topology_add_cpu_to_entry(S390TopologyEntry *entry, + S390CPU *cpu) +{ + set_bit(63 - (cpu->env.core_id % 64), &entry->mask); +} + +/** + * s390_topology_from_cpu: + * @cpu: The S390CPU + * + * Initialize the topology id from the CPU environment. + */ +static s390_topology_id s390_topology_from_cpu(S390CPU *cpu) +{ + s390_topology_id topology_id =3D {0}; + + topology_id.drawer =3D cpu->env.drawer_id; + topology_id.book =3D cpu->env.book_id; + topology_id.socket =3D cpu->env.socket_id; + topology_id.origin =3D cpu->env.core_id / 64; + topology_id.type =3D S390_TOPOLOGY_CPU_IFL; + topology_id.dedicated =3D cpu->env.dedicated; + + if (s390_topology.polarization =3D=3D S390_CPU_POLARIZATION_VERTICAL) { + /* + * Vertical polarization with dedicated CPU implies + * vertical high entitlement. + */ + if (topology_id.dedicated) { + topology_id.entitlement =3D S390_CPU_ENTITLEMENT_HIGH; + } else { + topology_id.entitlement =3D cpu->env.entitlement; + } + } + + return topology_id; +} + +/** + * s390_topology_insert: + * @cpu: s390CPU insert. + * + * Parse the topology list to find if the entry already + * exist and add the core in it. + * If it does not exist, allocate a new entry and insert + * it in the queue from lower id to greater id. + */ +static void s390_topology_insert(S390CPU *cpu) +{ + s390_topology_id id =3D s390_topology_from_cpu(cpu); + S390TopologyEntry *entry =3D NULL; + S390TopologyEntry *tmp =3D NULL; + + QTAILQ_FOREACH(tmp, &s390_topology.list, next) { + if (id.id =3D=3D tmp->id.id) { + s390_topology_add_cpu_to_entry(tmp, cpu); + return; + } else if (id.id < tmp->id.id) { + entry =3D g_malloc0(sizeof(S390TopologyEntry)); + entry->id.id =3D id.id; + s390_topology_add_cpu_to_entry(entry, cpu); + QTAILQ_INSERT_BEFORE(tmp, entry, next); + return; + } + } +} + +/** + * s390_topology_fill_list_sorted: + * + * Loop over all CPU and insert it at the right place + * inside the TLE entry list. + * Fill the S390Topology list with entries according to the order + * specified by the PoP. + */ +static void s390_topology_fill_list_sorted(void) +{ + CPUState *cs; + + CPU_FOREACH(cs) { + s390_topology_insert(S390_CPU(cs)); + } +} + +/** + * s390_topology_empty_list: + * + * Clear all entries in the S390Topology list except the sentinel. + */ +static void s390_topology_empty_list(void) +{ + S390TopologyEntry *entry =3D NULL; + S390TopologyEntry *tmp =3D NULL; + + QTAILQ_FOREACH_SAFE(entry, &s390_topology.list, next, tmp) { + if (!entry->id.sentinel) { + QTAILQ_REMOVE(&s390_topology.list, entry, next); + g_free(entry); + } + } +} + +/** + * insert_stsi_15_1_x: + * cpu: the CPU doing the call for which we set CC + * sel2: the selector 2, containing the nested level + * addr: Guest logical address of the guest SysIB + * ar: the access register number + * + * Emulate STSI 15.1.x, that is, perform all necessary checks and + * fill the SYSIB. + * In case the topology description is too long to fit into the SYSIB, + * set CC=3D3 and abort without writing the SYSIB. + */ +void insert_stsi_15_1_x(S390CPU *cpu, int sel2, uint64_t addr, uint8_t ar) +{ + SysIB sysib =3D {0}; + int length; + + if (!s390_has_topology() || sel2 < 2 || sel2 > SCLP_READ_SCP_INFO_MNES= T) { + setcc(cpu, 3); + return; + } + + s390_topology_fill_list_sorted(); + + length =3D setup_stsi(&sysib.sysib_151x, sel2); + + if (!length) { + setcc(cpu, 3); + return; + } + + sysib.sysib_151x.length =3D cpu_to_be16(length); + s390_cpu_virt_mem_write(cpu, addr, ar, &sysib, length); + setcc(cpu, 0); + + s390_topology_empty_list(); +} diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 3ac7ec9acf..5ea358cbb0 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -1919,9 +1919,12 @@ static int handle_stsi(S390CPU *cpu) if (run->s390_stsi.sel1 !=3D 2 || run->s390_stsi.sel2 !=3D 2) { return 0; } - /* 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; } diff --git a/target/s390x/kvm/meson.build b/target/s390x/kvm/meson.build index aef52b6686..5daa5c6033 100644 --- a/target/s390x/kvm/meson.build +++ b/target/s390x/kvm/meson.build @@ -1,6 +1,7 @@ =20 s390x_ss.add(when: 'CONFIG_KVM', if_true: files( - 'kvm.c' + 'kvm.c', + 'cpu_topology.c' ), if_false: files( 'stubs.c' )) --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891089; cv=none; d=zohomail.com; s=zohoarc; b=PrpgqdicXdHDfIVh3rMEVACu+9hJ/hgLaAinA6LAXl2oLC5TCuW34irbzgetLtz3d8df6CxzuowBhk7nV1DkJB0RXpohyAP5/FLsgIdokIxK9IunnwSqNrUsMoGJumIDRqcWN+ON6X9TYbh/lYBrrHd2CIXo3mUXZ4xVPmICaEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891089; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3eu0zFICVookgj1YRxiGpwqJlzDHo02+NaMVsBUQU+k=; b=kiQDGe/faa7Ac8SQ/gECLiwV0WD5uick9Pfrh79B1l6L8im0tXjeaBcPRStWV2v7WPWFKm9d+me0dX660gdFFKPky64CVdOxksz3cG4ggQPlcEsLzHukK8p3BQ7oemPA0qVcOclv01DUtRVfTEo2TM+Pneswe4pVjBztA7xWc9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891089395780.8262695646671; Wed, 15 Mar 2023 07:38:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSE3-0004R3-0C; Wed, 15 Mar 2023 10:35:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDy-0004OT-0o; Wed, 15 Mar 2023 10:35:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDu-0007YN-Ob; Wed, 15 Mar 2023 10:35:29 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDdTYs030714; Wed, 15 Mar 2023 14:35:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbdb7n34e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:17 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FD0MuW010855; Wed, 15 Mar 2023 14:35:17 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbdb7n33h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:17 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FECjlo008595; Wed, 15 Mar 2023 14:35:15 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3pb29sgwjg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:15 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZBEI19726904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:11 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B919E2004F; Wed, 15 Mar 2023 14:35:11 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 618FE20040; Wed, 15 Mar 2023 14:35:10 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:10 +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 : mime-version : content-transfer-encoding; s=pp1; bh=3eu0zFICVookgj1YRxiGpwqJlzDHo02+NaMVsBUQU+k=; b=oK9ZTNY5O+Uc38p4JMgI3AUQ9KgIXN+/yx+3clmHH5HG2M/nmj+TOVOJSPng9r6griha 7JeTiCkzzVND7QpQyowRl8G9TNI4sbB3rZ/f1Smt2K2Nva0iSjUaY6+Y9oQzu4sLE+n7 hFdsujrMXNGrbRHLRpTTULu2rZbyBeBv3DcfsJq3F4DU1bNeORc606CZekBT3yJoQ9ah QsxYfH1aA324XzZklh96gjMWwBroamJOH8hYjeR/jyDIMjiaIQnODWY5KkNsC5FKM+Qz OBNVovLhmNBeqLaEuZURn1ObRGl4YBKUCMplVqdGYbwKVs7T+FPqYU/Q9z9NJXKOq58g rw== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 04/17] s390x/sclp: reporting the maximum nested topology entries Date: Wed, 15 Mar 2023 15:34:49 +0100 Message-Id: <20230315143502.135750-5-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ngFSFiUZJZtn0GNivnQ1B3My8DuWY3hH X-Proofpoint-ORIG-GUID: 17CwBHxaF0-rO3Gp-6Mf6oqdcnwDT48p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_07,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 mlxscore=0 adultscore=0 malwarescore=0 impostorscore=0 clxscore=1015 spamscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150118 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=mx0b-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_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891090769100001 Content-Type: text/plain; charset="utf-8" The maximum nested topology entries is used by the guest to know how many nested topology are available on the machine. Let change the MNEST value from 2 to 4 in the SCLP READ INFO structure now that we support books and drawers. Signed-off-by: Pierre Morel Reviewed-by: Nina Schoetterl-Glausch Reviewed-by: Thomas Huth --- include/hw/s390x/sclp.h | 5 +++-- hw/s390x/sclp.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index 712fd68123..902252b319 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -112,12 +112,13 @@ typedef struct CPUEntry { } QEMU_PACKED CPUEntry; =20 #define SCLP_READ_SCP_INFO_FIXED_CPU_OFFSET 128 -#define SCLP_READ_SCP_INFO_MNEST 2 +#define SCLP_READ_SCP_INFO_MNEST 4 typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax; uint8_t rnsize; - uint8_t _reserved1[16 - 11]; /* 11-15 */ + uint8_t _reserved1[15 - 11]; /* 11-14 */ + uint8_t stsi_parm; /* 15-15 */ uint16_t entries_cpu; /* 16-17 */ uint16_t offset_cpu; /* 18-19 */ uint8_t _reserved2[24 - 20]; /* 20-23 */ diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index eff74479f4..d339cbb7e4 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -20,6 +20,7 @@ #include "hw/s390x/event-facility.h" #include "hw/s390x/s390-pci-bus.h" #include "hw/s390x/ipl.h" +#include "hw/s390x/cpu-topology.h" =20 static inline SCLPDevice *get_sclp_device(void) { @@ -123,6 +124,10 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) return; } =20 + if (s390_has_topology()) { + read_info->stsi_parm =3D SCLP_READ_SCP_INFO_MNEST; + } + /* CPU information */ prepare_cpu_entries(machine, entries_start, &cpu_count); read_info->entries_cpu =3D cpu_to_be16(cpu_count); --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678890957; cv=none; d=zohomail.com; s=zohoarc; b=nkNAxWEKEu9CF4BOcXZAT6VzSCvmrX4GwK2X2Ei+A2A7Sgyq9UTZRwho3smLu7cWRs9Uo1T7mlYJ8uQ6Tz0doxqa+WrquYhODYztn2csxcIbRzppVB/qvcHmVLGJw19xX+CVlAQQDZAXENUQG5TpAcx+sOOTPtiAR9aRWdFN2PI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678890957; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nh4UkelZCZgKn56/i8Mm3XOFEFRLGgInyMowtH3ITEU=; b=H6zxUCMoIGhm2jEq2SEa3FXeBtuQqffIV9rrqZzFKI0MKUUAjz7fIhMBs9GmXznU0lTSVtAJ7FuT3fw8O4YYZ1eII6pxTUtlBoim0zveK3gdmm6kmf6JxMZzTpHqPOIP8USTt7JfQ1m2FaUGrw92/sZChez0mxK2yFo5hO72Bl4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678890957240524.424010329553; Wed, 15 Mar 2023 07:35:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSDv-0004MX-2u; Wed, 15 Mar 2023 10:35:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSDs-0004L8-Pm; Wed, 15 Mar 2023 10:35:24 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] 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 1pcSDq-0007Vs-KC; Wed, 15 Mar 2023 10:35:24 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDtUGe023159; Wed, 15 Mar 2023 14:35:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbfavh7e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:19 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDuhUo030910; Wed, 15 Mar 2023 14:35:19 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbfavh7d1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:19 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN7YDN003737; Wed, 15 Mar 2023 14:35:16 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3pb29t0r2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:16 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZD2B43712994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:13 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C7FF20040; Wed, 15 Mar 2023 14:35:13 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D76E62004E; Wed, 15 Mar 2023 14:35:11 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:11 +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 : mime-version : content-transfer-encoding; s=pp1; bh=nh4UkelZCZgKn56/i8Mm3XOFEFRLGgInyMowtH3ITEU=; b=dDBs2U4pWWKfWNKsYl4xRgnnAZyJZFAhhI33dXtNjfOf937RRv/tddbinLRcVOHbBKZR wzC/S6mzPO/kBkjq7jbpgFzxh7s4Wmb2NK2RR+h/O9H1jb3T/rIcgrQOk0Q7BoeBAvsM gsFomdr/7tWIrpYcN2xB5K5z1Oj2Y0poxmmyhVuBj5JauXDC5DVUI96pUgXSjrDVQ69b M141W98L7nm6LU3khHm+i4/omxXBI11Zq3amTYYU5ftmvSQPamlwWRrDQmoBtBNybtJq EdIyiQgFJ+oefO6lq7vlWdNl0PiyZIbXy4SOgBq2lrXVk3DSoU7hJAIk+WWkw/pjYTKv zA== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 05/17] s390x/cpu topology: resetting the Topology-Change-Report Date: Wed, 15 Mar 2023 15:34:50 +0100 Message-Id: <20230315143502.135750-6-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pPPruMTw1psU2S0G2hmGAs85Eo84TKPN X-Proofpoint-ORIG-GUID: AFDJkWKPQA9pzdHd63Ce5vhzwLlzjqQK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_07,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150118 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+importer2=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_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678890958074100001 Content-Type: text/plain; charset="utf-8" During a subsystem reset the Topology-Change-Report is cleared by the machine. Let's ask KVM to clear the Modified Topology Change Report (MTCR) bit of the SCA in the case of a subsystem reset. Signed-off-by: Pierre Morel Reviewed-by: Thomas Huth --- include/hw/s390x/cpu-topology.h | 1 + target/s390x/cpu.h | 1 + target/s390x/kvm/kvm_s390x.h | 1 + hw/s390x/cpu-topology.c | 11 +++++++++++ hw/s390x/s390-virtio-ccw.c | 3 +++ target/s390x/cpu-sysemu.c | 13 +++++++++++++ target/s390x/kvm/kvm.c | 17 +++++++++++++++++ 7 files changed, 47 insertions(+) diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index 7a1dd6b136..fa42236dfa 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -60,6 +60,7 @@ static inline void s390_topology_setup_cpu(MachineState *= ms, =20 extern S390Topology s390_topology; int s390_socket_nb(S390CPU *cpu); +void s390_topology_reset(void); =20 static inline int s390_std_socket(int n, CpuTopology *smp) { diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 61210303e4..9842c36c80 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -642,6 +642,7 @@ typedef struct SysIBTl_cpu { QEMU_BUILD_BUG_ON(sizeof(SysIBTl_cpu) !=3D 16); =20 void insert_stsi_15_1_x(S390CPU *cpu, int sel2, uint64_t addr, uint8_t ar); +void s390_cpu_topology_set_changed(bool changed); =20 /* MMU defines */ #define ASCE_ORIGIN (~0xfffULL) /* segment table origin = */ diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h index f9785564d0..649dae5948 100644 --- a/target/s390x/kvm/kvm_s390x.h +++ b/target/s390x/kvm/kvm_s390x.h @@ -47,5 +47,6 @@ void kvm_s390_crypto_reset(void); void kvm_s390_restart_interrupt(S390CPU *cpu); void kvm_s390_stop_interrupt(S390CPU *cpu); void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info); +int kvm_s390_topology_set_mtcr(uint64_t attr); =20 #endif /* KVM_S390X_H */ diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 36c8c687b8..45462b01fe 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -87,6 +87,17 @@ static void s390_topology_init(MachineState *ms) QTAILQ_INSERT_HEAD(&s390_topology.list, entry, next); } =20 +/** + * s390_topology_reset: + * + * Generic reset for CPU topology, calls s390_topology_reset() + * to reset the kernel Modified Topology Change Record. + */ +void s390_topology_reset(void) +{ + s390_cpu_topology_set_changed(false); +} + /** * s390_topology_cpu_default: * @cpu: pointer to a S390CPU diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 9df60ac447..7e6d88e23c 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -123,6 +123,9 @@ static void subsystem_reset(void) device_cold_reset(dev); } } + if (s390_has_topology()) { + s390_topology_reset(); + } } =20 static int virtio_ccw_hcall_notify(const uint64_t *args) diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 948e4bd3e0..9d41acfe1a 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -306,3 +306,16 @@ void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_= data arg) kvm_s390_set_diag318(cs, arg.host_ulong); } } + +void s390_cpu_topology_set_changed(bool changed) +{ + int ret; + + if (kvm_enabled()) { + ret =3D kvm_s390_topology_set_mtcr(changed); + if (ret) { + error_report("Failed to set Modified Topology Change Report: %= s", + strerror(-ret)); + } + } +} diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 5ea358cbb0..bc953151ce 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2592,6 +2592,23 @@ int kvm_s390_get_zpci_op(void) return cap_zpci_op; } =20 +int kvm_s390_topology_set_mtcr(uint64_t attr) +{ + struct kvm_device_attr attribute =3D { + .group =3D KVM_S390_VM_CPU_TOPOLOGY, + .attr =3D attr, + }; + + if (!s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) { + return 0; + } + if (!kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) { + return -ENOTSUP; + } + + return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attribute); +} + void kvm_arch_accel_class_init(ObjectClass *oc) { } --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891061; cv=none; d=zohomail.com; s=zohoarc; b=MnoCEV1BrCrNrvpxfQhAxu2sozIUjLXUYWwC8IRZKC4t3yCRAud6QDSL37DYaTy4FvSgKgWfxhcj4OahAtQTAEocO2zoHj7k9qSfA5ry+4Zz95zShSj3NHvrXS+0pjq7n2m/41ugr6o+C6TJ3XrCsKyO2MBuIoGRUNgV7Iqxjq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891061; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zjXhEv9Sg2xvVQInV2f91C7+gxt99fWJ58I2gvUYAUA=; b=Vly+AT367VpcM6TvLq4i2Ov+H+lgHUrIVwjZ7UNId1Ya9aG94ka8o8jQIlDuqptJV1FZAoOV8sW92Cj6azaFKZhPx+A6h7LVh7HUCZ2dp1or/2CwLS03jfi5HEkY5UZRvbU7bt/bH0ifOxhRRQE+gU7lKrf5slaVHIjlk/qOIoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891061455582.3727068389472; Wed, 15 Mar 2023 07:37:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSE3-0004Rm-Qz; Wed, 15 Mar 2023 10:35:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE1-0004PA-S3; Wed, 15 Mar 2023 10:35:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE0-0007ZX-39; Wed, 15 Mar 2023 10:35:33 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FE9k1J032291; Wed, 15 Mar 2023 14:35:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsg56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:21 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FEZF1s018605; Wed, 15 Mar 2023 14:35:21 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsg4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:20 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN5tnL001285; Wed, 15 Mar 2023 14:35:18 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3pb29rrreq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:18 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZElb27459848 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:14 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AFA4820043; Wed, 15 Mar 2023 14:35:14 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 578EC2004D; Wed, 15 Mar 2023 14:35:13 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:13 +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 : mime-version : content-transfer-encoding; s=pp1; bh=zjXhEv9Sg2xvVQInV2f91C7+gxt99fWJ58I2gvUYAUA=; b=hwfXNu3HH8KfTMvrCZRveNbO9W0QFDyof15AmI/LxA4iS9TGb4p08SPBKS/9Zb5VJfzc 97BXa1hqb2pyKo7zcahXEMYSYTcIknXLKapoFLXbdMK0+xGMfxwdHgLbfBJTDz488j0c 4dx4jUfOlq0Ae2ky1LyTMPB5MpajdPhlkI2SKmr24x5UCoitEUcdWnLlcABsbQVOx7mL PnoeGOCLQqmr0/FaXUFKSRIhm2ZP31M0NWqbmkH9jmWjtjf0R8xpoTOM/03Hqp3Y9XZ/ M4JLFzwR4uJD+1fxaznpfYC3GK7FV/EIZfZJPt0xjdmEvqVItRMhXlVosATBOJbGqxjR WQ== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 06/17] s390x/cpu topology: interception of PTF instruction Date: Wed, 15 Mar 2023 15:34:51 +0100 Message-Id: <20230315143502.135750-7-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pOcDnjAwFlGYAfMASjRlFT_Jp72vIpf1 X-Proofpoint-ORIG-GUID: ECcSmWwxfxy99Ax4YtkUaMB4WPRSRUQb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 spamscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891062592100001 Content-Type: text/plain; charset="utf-8" When the host supports the CPU topology facility, the PTF instruction with function code 2 is interpreted by the SIE, provided that the userland hypervisor activates the interpretation by using the KVM_CAP_S390_CPU_TOPOLOGY KVM extension. The PTF instructions with function code 0 and 1 are intercepted and must be emulated by the userland hypervisor. During RESET all CPU of the configuration are placed in horizontal polarity. Signed-off-by: Pierre Morel --- include/hw/s390x/s390-virtio-ccw.h | 6 ++ hw/s390x/cpu-topology.c | 93 +++++++++++++++++++++++++++--- target/s390x/kvm/kvm.c | 11 ++++ 3 files changed, 101 insertions(+), 9 deletions(-) diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-vir= tio-ccw.h index 9bba21a916..c1d46e78af 100644 --- a/include/hw/s390x/s390-virtio-ccw.h +++ b/include/hw/s390x/s390-virtio-ccw.h @@ -30,6 +30,12 @@ struct S390CcwMachineState { uint8_t loadparm[8]; }; =20 +#define S390_PTF_REASON_NONE (0x00 << 8) +#define S390_PTF_REASON_DONE (0x01 << 8) +#define S390_PTF_REASON_BUSY (0x02 << 8) +#define S390_TOPO_FC_MASK 0xffUL +void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_t ra); + struct S390CcwMachineClass { /*< private >*/ MachineClass parent_class; diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 45462b01fe..2cce866fc7 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -87,6 +87,87 @@ static void s390_topology_init(MachineState *ms) QTAILQ_INSERT_HEAD(&s390_topology.list, entry, next); } =20 +/** + * s390_topology_set_cpus_entitlement: + * + * On hotplug or when changing CPU attributes the shadow_entitlement + * is set to hold the entitlement used on a vertical polarization. + * When polarization is horizontal, the entitlement is horizontal too. + */ +static void s390_topology_set_cpus_entitlement(void) +{ + CPUState *cs; + + CPU_FOREACH(cs) { + CPUS390XState *env =3D &S390_CPU(cs)->env; + + if (s390_topology.polarization =3D=3D S390_CPU_POLARIZATION_HORIZO= NTAL) { + env->entitlement =3D S390_CPU_ENTITLEMENT_HORIZONTAL; + } else if (env->entitlement =3D=3D S390_CPU_ENTITLEMENT_HORIZONTAL= ) { + if (env->dedicated) { + env->entitlement =3D S390_CPU_ENTITLEMENT_HIGH; + } else { + env->entitlement =3D env->shadow_entitlement; + } + } + } +} + +/* + * s390_handle_ptf: + * + * @register 1: contains the function code + * + * Function codes 0 (horizontal) and 1 (vertical) define the CPU + * polarization requested by the guest. + * + * Verify that the polarization really need to change and call + * s390_topology_set_cpus_entitlement() specifying the requested polarizat= ion + * to set for all CPUs. + * + * Function code 2 is handling topology changes and is interpreted + * by the SIE. + */ +void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_t ra) +{ + CPUS390XState *env =3D &cpu->env; + uint64_t reg =3D env->regs[r1]; + int fc =3D reg & S390_TOPO_FC_MASK; + + if (!s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) { + s390_program_interrupt(env, PGM_OPERATION, ra); + return; + } + + if (env->psw.mask & PSW_MASK_PSTATE) { + s390_program_interrupt(env, PGM_PRIVILEGED, ra); + return; + } + + if (reg & ~S390_TOPO_FC_MASK) { + s390_program_interrupt(env, PGM_SPECIFICATION, ra); + return; + } + + switch (fc) { + case S390_CPU_POLARIZATION_VERTICAL: + case S390_CPU_POLARIZATION_HORIZONTAL: + if (s390_topology.polarization =3D=3D fc) { + env->regs[r1] |=3D S390_PTF_REASON_DONE; + setcc(cpu, 2); + } else { + s390_topology.polarization =3D fc; + s390_topology_set_cpus_entitlement(); + s390_cpu_topology_set_changed(true); + setcc(cpu, 0); + } + break; + default: + /* Note that fc =3D=3D 2 is interpreted by the SIE */ + s390_program_interrupt(env, PGM_SPECIFICATION, ra); + } +} + /** * s390_topology_reset: * @@ -96,6 +177,8 @@ static void s390_topology_init(MachineState *ms) void s390_topology_reset(void) { s390_cpu_topology_set_changed(false); + s390_topology.polarization =3D S390_CPU_POLARIZATION_HORIZONTAL; + s390_topology_set_cpus_entitlement(); } =20 /** @@ -258,15 +341,7 @@ static void s390_normalize_entitlement(S390CPU *cpu) } =20 /* Set the effective entitlement according to polarization */ - if (s390_topology.polarization =3D=3D S390_CPU_POLARIZATION_HORIZONTAL= ) { - cpu->env.entitlement =3D S390_CPU_ENTITLEMENT_HORIZONTAL; - } else if (cpu->env.entitlement =3D=3D S390_CPU_ENTITLEMENT_HORIZONTAL= ) { - if (cpu->env.dedicated) { - cpu->env.entitlement =3D S390_CPU_ENTITLEMENT_HIGH; - } else { - cpu->env.entitlement =3D S390_CPU_ENTITLEMENT_MEDIUM; - } - } + s390_topology_set_cpus_entitlement(); } =20 /** diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index bc953151ce..fb63be41b7 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -96,6 +96,7 @@ =20 #define PRIV_B9_EQBS 0x9c #define PRIV_B9_CLP 0xa0 +#define PRIV_B9_PTF 0xa2 #define PRIV_B9_PCISTG 0xd0 #define PRIV_B9_PCILG 0xd2 #define PRIV_B9_RPCIT 0xd3 @@ -1464,6 +1465,13 @@ static int kvm_mpcifc_service_call(S390CPU *cpu, str= uct kvm_run *run) } } =20 +static void kvm_handle_ptf(S390CPU *cpu, struct kvm_run *run) +{ + uint8_t r1 =3D (run->s390_sieic.ipb >> 20) & 0x0f; + + s390_handle_ptf(cpu, r1, RA_IGNORED); +} + static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) { int r =3D 0; @@ -1481,6 +1489,9 @@ static int handle_b9(S390CPU *cpu, struct kvm_run *ru= n, uint8_t ipa1) case PRIV_B9_RPCIT: r =3D kvm_rpcit_service_call(cpu, run); break; + case PRIV_B9_PTF: + kvm_handle_ptf(cpu, run); + break; case PRIV_B9_EQBS: /* just inject exception */ r =3D -1; --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891065; cv=none; d=zohomail.com; s=zohoarc; b=Q6z0/SqnkQi//VrULwXPwiu2fHTHvil57Z69J3AJxH4HS3aQ4h3Z4gSs8wY612TqOU7O5l2ucDl6GBjA5GNMfFUYqad4fEEm/6C6B00NS0XAVY7XoAzZf71bm0JdEsw63yZKjCs5HVNb9AC3bBUc+HYpnGR8lAkWMt7Gy6uy/9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891065; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=obSM9XMDHSwTRAVnjaM57mQfrZaC5ZNIHKm+MUoCZow=; b=gPSteiTA5o5Ajw+wm6uoIL0+Pn2ZaesyODzu4pg5pjl8goZlwT6/yDksu/Jhs5uEBcfIVesM4xX7doEy7Cj+UDZu9RNGDDvsry8aCBb2cJsxHp3kKyHpvAnTurmwE9tnu9NN3YJTmjWTH2ApYmsmapDY9jUSK+7+sK8o9ZL4yvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891065176685.4523974905012; Wed, 15 Mar 2023 07:37:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSE4-0004Sr-Py; Wed, 15 Mar 2023 10:35:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE2-0004R2-Ts; Wed, 15 Mar 2023 10:35:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE1-0007Zk-3r; Wed, 15 Mar 2023 10:35:34 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDqNxD037852; Wed, 15 Mar 2023 14:35:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf9fse92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:22 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FEOTZw021824; Wed, 15 Mar 2023 14:35:22 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf9fse7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:22 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32F1godI020788; Wed, 15 Mar 2023 14:35:19 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3pb29srwr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:19 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZGJa17892014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:16 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F3D42004D; Wed, 15 Mar 2023 14:35:16 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC00A2004B; Wed, 15 Mar 2023 14:35:14 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:14 +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 : mime-version : content-transfer-encoding; s=pp1; bh=obSM9XMDHSwTRAVnjaM57mQfrZaC5ZNIHKm+MUoCZow=; b=abr1mCAlLgSB6EalSj+ArS+ZtkYAQ98l3M0msBaeT3tW2Exn7OFly6s55kPampLH4sxO 8dwt4In9IvNn1vkQfRt1o8eAdWEd7KnzWMTKZACxr3K1dR2mKittastKgxEvIhpn/cHn cjl0wppF+qvP7jHwaxaYUyT+h3HoyJhRr9ngVN6cVksUdn8n+uodWjWmu1BElhAn8Znq EioYH3MYinxRI2dfC+jvnfBkmoNPpqUZbLrIRZu68I4ogFeezjak0tIvs0h0JlrB7wZd 4a04x372/tmNZk+a5EMru5aBvfjiZ1i7MVZ1QAUW6Mqiy7x5QF2i68mxez7EBwo3e2yL XQ== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 07/17] target/s390x/cpu topology: activate CPU topology Date: Wed, 15 Mar 2023 15:34:52 +0100 Message-Id: <20230315143502.135750-8-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0yIdasEmPBm2NJHEEuJhy86Bcn-hGM5x X-Proofpoint-ORIG-GUID: GIAl8VfIPqlGJK-y-A-dS9-8i01-kk5h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_07,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 malwarescore=0 adultscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150118 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891066580100009 Content-Type: text/plain; charset="utf-8" The KVM capability KVM_CAP_S390_CPU_TOPOLOGY is used to activate the S390_FEAT_CONFIGURATION_TOPOLOGY feature and the topology facility in the host CPU model for the guest in the case the topology is available in QEMU and in KVM. The feature is disabled by default and fenced for SE (secure execution). Signed-off-by: Pierre Morel Reviewed-by: Thomas Huth --- hw/s390x/cpu-topology.c | 2 +- target/s390x/cpu_models.c | 1 + target/s390x/kvm/kvm.c | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 2cce866fc7..5f8ca904bf 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -57,7 +57,7 @@ int s390_socket_nb(S390CPU *cpu) */ bool s390_has_topology(void) { - return false; + return s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY); } =20 /** diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 065ec6d66c..aca2c5c96b 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -254,6 +254,7 @@ bool s390_has_feat(S390Feat feat) case S390_FEAT_SIE_CMMA: case S390_FEAT_SIE_PFMFI: case S390_FEAT_SIE_IBS: + case S390_FEAT_CONFIGURATION_TOPOLOGY: return false; break; default: diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index fb63be41b7..e6f5b65dbe 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -371,6 +371,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) kvm_vm_enable_cap(s, KVM_CAP_S390_USER_SIGP, 0); kvm_vm_enable_cap(s, KVM_CAP_S390_VECTOR_REGISTERS, 0); kvm_vm_enable_cap(s, KVM_CAP_S390_USER_STSI, 0); + kvm_vm_enable_cap(s, KVM_CAP_S390_CPU_TOPOLOGY, 0); if (ri_allowed()) { if (kvm_vm_enable_cap(s, KVM_CAP_S390_RI, 0) =3D=3D 0) { cap_ri =3D 1; @@ -2470,6 +2471,14 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model= , Error **errp) set_bit(S390_FEAT_UNPACK, model->features); } =20 + /* + * If we have kernel support for CPU Topology indicate the + * configuration-topology facility. + */ + if (kvm_check_extension(kvm_state, KVM_CAP_S390_CPU_TOPOLOGY)) { + set_bit(S390_FEAT_CONFIGURATION_TOPOLOGY, model->features); + } + /* We emulate a zPCI bus and AEN, therefore we don't need HW support */ set_bit(S390_FEAT_ZPCI, model->features); set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features); --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891067; cv=none; d=zohomail.com; s=zohoarc; b=EXc+VB+4sAQPcD6VOJ+IkTw5cjHMOjrW37R3g/6dOvQMg3sjtrryYq02QfWozcOMSOCmNK8QfZ5Auv8qP1vYM4FZBkCom4Iy0a+q+9YjKDqOqKy9J28bSF9G6BERrAFZhLX9P584R/173xrLb1b0M9+nYYD9shNn2eDci0uJCJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891067; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=99/fxhf7ywQ4EBNI+fDkWj+omjXFf3dPUiIIVZ/O0c4=; b=mk3ybUsRvX35npQ4eVX0p2G+CpMg6APehUyarkCPHDbYOfCVAFkD4OtBIn7VLNMP6ZrrPxSONGAJNDAfykvNdngHx/TOpUxadXG9wCuq8cXmfq8RznUYuRucyGnOnE51WbmNacI5tzcVteiLgSVsxNJz4EgJZOtjCDEefmPcEL4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891067039862.1302718368675; Wed, 15 Mar 2023 07:37:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSE7-0004VH-05; Wed, 15 Mar 2023 10:35:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE5-0004UE-KS; Wed, 15 Mar 2023 10:35:37 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE3-0007a8-Ht; Wed, 15 Mar 2023 10:35:37 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FEWdqe001600; Wed, 15 Mar 2023 14:35:25 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ucyu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:24 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDWYQf007131; Wed, 15 Mar 2023 14:35:24 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ucxh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:24 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDiZdx008546; Wed, 15 Mar 2023 14:35:21 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3pb29sgwjh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:21 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZHD840960344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:18 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4B8D20040; Wed, 15 Mar 2023 14:35:17 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D4B32004B; Wed, 15 Mar 2023 14:35:16 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:16 +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 : mime-version : content-transfer-encoding; s=pp1; bh=99/fxhf7ywQ4EBNI+fDkWj+omjXFf3dPUiIIVZ/O0c4=; b=eaaGKHhxw5vE4vRzY6ouZYgV1ZPLpNRhoBlZFfHHQ3c4b3xY1G9HxHz+12M9npQ7r1BZ 4k1PX+5DVglFQq0GVBXCtTbbeE1f5yvSDhUxKalEOwfrBa/Lx7p+Yzi8GyzXdNGncqTM vEoKFDPmtdafIQGEm1wnz7I2Kc88gBaO1P5VnWkMc/gs8UzLJ8dL9eXgpZw3DPPJDTrY mqxxMl+UdWASk/Bh/zjkL4b4GkRDU/kh1FEZAPg++zF3pdLNIdatQPaJzaeUnkXvxZ4h 3TXZ6OP+5SAIU48F/VFwVX44jkiDnjcEi3zihVbs4UXkrorDh5qvTuHAJCStdqWuXLSS rA== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 08/17] qapi/s390x/cpu topology: set-cpu-topology qmp command Date: Wed, 15 Mar 2023 15:34:53 +0100 Message-Id: <20230315143502.135750-9-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QvdAXoyI_VBoIM4ND4KR73Ciwp8lHYk9 X-Proofpoint-ORIG-GUID: nlbU199l2LOzpJkzVoR3IDqPQPr__bHz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891068611100019 Content-Type: text/plain; charset="utf-8" The modification of the CPU attributes are done through a monitor command. It allows to move the core inside the topology tree to optimize the cache usage in the case the host's hypervisor previously moved the CPU. The same command allows to modify the CPU attributes modifiers like polarization entitlement and the dedicated attribute to notify the guest if the host admin modified scheduling or dedication of a vCPU. With this knowledge the guest has the possibility to optimize the usage of the vCPUs. The command has a feature unstable for the moment. Signed-off-by: Pierre Morel --- qapi/machine-target.json | 37 ++++++++++++ hw/s390x/cpu-topology.c | 119 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 42a6a40333..3b7a0b77f4 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -4,6 +4,8 @@ # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. =20 +{ 'include': 'machine-common.json' } + ## # @CpuModelInfo: # @@ -354,3 +356,38 @@ { 'enum': 'CpuS390Polarization', 'prefix': 'S390_CPU_POLARIZATION', 'data': [ 'horizontal', 'vertical' ] } + +## +# @set-cpu-topology: +# +# @core-id: the vCPU ID to be moved +# @socket-id: optional destination socket where to move the vCPU +# @book-id: optional destination book where to move the vCPU +# @drawer-id: optional destination drawer where to move the vCPU +# @entitlement: optional entitlement +# @dedicated: optional, if the vCPU is dedicated to a real CPU +# +# Features: +# @unstable: This command may still be modified. +# +# Modifies the topology by moving the CPU inside the topology +# tree or by changing a modifier attribute of a CPU. +# Default value for optional parameter is the current value +# used by the CPU. +# +# Returns: Nothing on success, the reason on failure. +# +# Since: 8.1 +## +{ 'command': 'set-cpu-topology', + 'data': { + 'core-id': 'uint16', + '*socket-id': 'uint16', + '*book-id': 'uint16', + '*drawer-id': 'uint16', + '*entitlement': 'CpuS390Entitlement', + '*dedicated': 'bool' + }, + 'features': [ 'unstable' ], + 'if': { 'all': [ 'TARGET_S390X' , 'CONFIG_KVM' ] } +} diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 5f8ca904bf..1cf3adec31 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -18,6 +18,7 @@ #include "target/s390x/cpu.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/cpu-topology.h" +#include "qapi/qapi-commands-machine-target.h" =20 /* * s390_topology is used to keep the topology information. @@ -304,6 +305,26 @@ static void s390_topology_add_core_to_socket(S390CPU *= cpu, int drawer_id, } } =20 +/** + * s390_topology_need_report + * @cpu: Current cpu + * @drawer_id: future drawer ID + * @book_id: future book ID + * @socket_id: future socket ID + * + * A modified topology change report is needed if the + */ +static int s390_topology_need_report(S390CPU *cpu, int drawer_id, + int book_id, int socket_id, + uint16_t entitlement, bool dedicated) +{ + return cpu->env.drawer_id !=3D drawer_id || + cpu->env.book_id !=3D book_id || + cpu->env.socket_id !=3D socket_id || + cpu->env.entitlement !=3D entitlement || + cpu->env.dedicated !=3D dedicated; +} + /** * s390_update_cpu_props: * @ms: the machine state @@ -396,3 +417,101 @@ void s390_topology_setup_cpu(MachineState *ms, S390CP= U *cpu, Error **errp) /* topology tree is reflected in props */ s390_update_cpu_props(ms, cpu); } + +static void s390_change_topology(uint16_t core_id, + bool has_socket_id, uint16_t socket_id, + bool has_book_id, uint16_t book_id, + bool has_drawer_id, uint16_t drawer_id, + bool has_entitlement, uint16_t entitlemen= t, + bool has_dedicated, bool dedicated, + Error **errp) +{ + MachineState *ms =3D current_machine; + S390CPU *cpu; + int report_needed; + ERRP_GUARD(); + + if (core_id >=3D ms->smp.max_cpus) { + error_setg(errp, "Core-id %d out of range!", core_id); + return; + } + + cpu =3D (S390CPU *)ms->possible_cpus->cpus[core_id].cpu; + if (!cpu) { + error_setg(errp, "Core-id %d does not exist!", core_id); + return; + } + + /* Get attributes not provided from cpu and verify the new topology */ + if (!has_entitlement) { + entitlement =3D cpu->env.entitlement; + } + if (!has_dedicated) { + dedicated =3D cpu->env.dedicated; + } + if (!has_socket_id) { + socket_id =3D cpu->env.socket_id; + } + if (!has_book_id) { + book_id =3D cpu->env.book_id; + } + if (!has_drawer_id) { + drawer_id =3D cpu->env.drawer_id; + } + + s390_topology_check(socket_id, book_id, drawer_id, + entitlement, dedicated, errp); + if (*errp) { + return; + } + + /* Move the CPU into its new socket */ + s390_topology_add_core_to_socket(cpu, drawer_id, book_id, + socket_id, false, errp); + if (*errp) { + return; + } + + /* Check if we need to report the modified topology */ + report_needed =3D s390_topology_need_report(cpu, drawer_id, book_id, + socket_id, entitlement, + dedicated); + + /* All checks done, report new topology into the vCPU */ + cpu->env.drawer_id =3D drawer_id; + cpu->env.book_id =3D book_id; + cpu->env.socket_id =3D socket_id; + cpu->env.dedicated =3D dedicated; + cpu->env.entitlement =3D entitlement; + + /* Setup shadow and effective entitlement */ + s390_normalize_entitlement(cpu); + + /* topology tree is reflected in props */ + s390_update_cpu_props(ms, cpu); + + /* Advertise the topology change */ + if (report_needed) { + s390_cpu_topology_set_changed(true); + } +} + +void qmp_set_cpu_topology(uint16_t core, + bool has_socket, uint16_t socket, + bool has_book, uint16_t book, + bool has_drawer, uint16_t drawer, + bool has_entitlement, CpuS390Entitlement entitlem= ent, + bool has_dedicated, bool dedicated, + Error **errp) +{ + ERRP_GUARD(); + + if (!s390_has_topology()) { + error_setg(errp, "This machine doesn't support topology"); + return; + } + + s390_change_topology(core, has_socket, socket, has_book, book, + has_drawer, drawer, has_entitlement, entitlement, + has_dedicated, dedicated, errp); +} --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891006; cv=none; d=zohomail.com; s=zohoarc; b=GqONBYwHwUOMbga26F4JOTAWTuedMgUJqF7JJP5xI2ojvI5ppU26DRGpRdHyKiWzCYSuVlNH3IybqNgr2SHffz7BVTxewLNlSbjLvVRk5RUog5r2lhmajLB28nGKy0piP2sII9vmvhE8TCYKxwWDDtcmYLESe8PwcbJwMBJGO5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891006; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l3RVD15EqoSBupoSQjJcxlIGPf6G34/auclhs9bUJ5w=; b=cqAnYqzrBzJbYn56iJd3ogypOl005rvX5hgIXkoCv10nEk5EMHxabjU63AvuI44Edjtx4GbPS+pb8K1pmfMwlux3dvJOiXdTgK/NUF8y/xfDopETuhurkh/WV/i+jIsjpsDftml6BT3ODU0odlxRjgmG3GSk3k3/jTuAmfwI/XE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891006317185.20365647051005; Wed, 15 Mar 2023 07:36:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSE8-0004Yr-5c; Wed, 15 Mar 2023 10:35:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE5-0004US-Uv; Wed, 15 Mar 2023 10:35:37 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE4-0007aS-8K; Wed, 15 Mar 2023 10:35:37 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FE9kWo032328; Wed, 15 Mar 2023 14:35:26 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsg7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:26 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FEACP7001960; Wed, 15 Mar 2023 14:35:25 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsg69-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:25 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN5t2e001850; Wed, 15 Mar 2023 14:35:22 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3pb29t0r2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:22 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZJ3824314562 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:19 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3591020040; Wed, 15 Mar 2023 14:35:19 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0D1A2004B; Wed, 15 Mar 2023 14:35:17 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:17 +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 : mime-version : content-transfer-encoding; s=pp1; bh=l3RVD15EqoSBupoSQjJcxlIGPf6G34/auclhs9bUJ5w=; b=enze7UGhmgR8Aa4ShWoXLuox2mPC6ytM6PzY5g3bAQ8vZ64pIa4THdrIXLWfRrImo4UZ PB59efgxCS0CO9d33nA+qSTqpOsYzptT2NYZmIX8D/DEW4yDtIZF51x8R2HJhrJ97AZ4 YWWqeUjxI/CcRCpLYlciePM6aYAZhpIkT1liSOGZ4ivKmnjo/sAjfjSHjnHYjPOW50k4 EWhnWFnecWpXEzpa2TBjTnHq14bUx02hq6zHEKW4UhzaR0jRhhmBYlhEtjyncKZxfA7u uMFH2752uAds7GypZAybm1+NHrdJTYlxIEp0RugYNtqYAo8ypamn7msusVwJDgZ1U74b yA== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 09/17] machine: adding s390 topology to query-cpu-fast Date: Wed, 15 Mar 2023 15:34:54 +0100 Message-Id: <20230315143502.135750-10-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 56HunjXHRDa--NWQTr18nXN2yjcOzydB X-Proofpoint-ORIG-GUID: 98NKQygjXUq9IMAiQ_qiwhUFhsBTTokM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 spamscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891007402100001 Content-Type: text/plain; charset="utf-8" S390x provides two more topology attributes, entitlement and dedication. Let's add these CPU attributes to the QAPI command query-cpu-fast. Signed-off-by: Pierre Morel Reviewed-by: Nina Schoetterl-Glausch Reviewed-by: Thomas Huth --- qapi/machine.json | 9 ++++++++- hw/core/machine-qmp-cmds.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/qapi/machine.json b/qapi/machine.json index 1cdd83f3fd..c6a12044e0 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -55,10 +55,17 @@ # Additional information about a virtual S390 CPU # # @cpu-state: the virtual CPU's state +# @dedicated: the virtual CPU's dedication (since 8.1) +# @entitlement: the virtual CPU's entitlement (since 8.1) # # Since: 2.12 ## -{ 'struct': 'CpuInfoS390', 'data': { 'cpu-state': 'CpuS390State' } } +{ 'struct': 'CpuInfoS390', + 'data': { 'cpu-state': 'CpuS390State', + 'dedicated': 'bool', + 'entitlement': 'CpuS390Entitlement' + } +} =20 ## # @CpuInfoFast: diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index b98ff15089..3f35ed83a6 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -35,6 +35,8 @@ static void cpustate_to_cpuinfo_s390(CpuInfoS390 *info, c= onst CPUState *cpu) CPUS390XState *env =3D &s390_cpu->env; =20 info->cpu_state =3D env->cpu_state; + info->dedicated =3D env->dedicated; + info->entitlement =3D env->entitlement; #else abort(); #endif --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891049; cv=none; d=zohomail.com; s=zohoarc; b=GjqP60/HGORI6l1O2dLAWVer0TLG6r4GzJ390DQW1f+tmnbo0kPCSeyY5mezdNg4cW/t0OXxA6B8PWdJMooNmrRMLRULh8tMH5muqz1b6quiptMhRkxj7os4s9QzmAD03gw7ldGf+aqT1MXKqizbNWCDGziqRzPd4xqX/dhZCOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891049; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OgMa/FL/Fg2JPxk6c485XtvR8cr9+IcfLTc85Echlyg=; b=mc1vFNmtLRjoaTaX5kkwFXGuEb6mFU9awynRCH4W1F/wEpERV5SeJU+ad4do+C0dCtwV+SUm1hBOcjkm3/C/+yA2hYHa5OAUw0upmFkXdZ74tu26e4EoZGp4XbKFXcLFYmVbIdRC+HxPvZhV1rofQTOaAkMw9giaCBRtOWsAlBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891049950397.668931320938; Wed, 15 Mar 2023 07:37:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSE9-0004cH-Oj; Wed, 15 Mar 2023 10:35:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE6-0004Up-Pq; Wed, 15 Mar 2023 10:35:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE4-0007aZ-0S; Wed, 15 Mar 2023 10:35:38 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FCi7q2008553; Wed, 15 Mar 2023 14:35:27 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbe9f3ckq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:27 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDTGDh017675; Wed, 15 Mar 2023 14:35:26 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbe9f3cjv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:26 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FE0H00021588; Wed, 15 Mar 2023 14:35:24 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3pb29srwr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:24 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZKGL11076214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:20 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC82B2004B; Wed, 15 Mar 2023 14:35:20 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 516592004E; Wed, 15 Mar 2023 14:35:19 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:19 +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 : mime-version : content-transfer-encoding; s=pp1; bh=OgMa/FL/Fg2JPxk6c485XtvR8cr9+IcfLTc85Echlyg=; b=UPWQghAXC0UjSPprolcfOO6Vai1gBo6yryb8dwNOxmAJpHpQPCmdnQv8sO8PbLowJK6o jWM9s1iBokKaAJShbQksU/q9fzB25KvtoI5Sxdgu/w3fNJF/EnFtsY80ur9Ww6pBSukg QPRzCpIGJMu9SavQNvXk8zl0PW0tc2yp/hAla8uEj5xA32CfIy1zGJdUpIN14TzFirsH h2VINrWzDAbVNc+80jD9u34NzrWYfwtAmPmcaaW9yHXH6+RUowxjqGtgaDFOKhmS0Vm0 yC/ZNZNdIv3zQzQAP7dchzI0Ybup9QRmf6itdvV5KMvYYPOfgxE/3OdLA7dga2DL5EBg Wg== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 10/17] machine: adding s390 topology to info hotpluggable-cpus Date: Wed, 15 Mar 2023 15:34:55 +0100 Message-Id: <20230315143502.135750-11-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: A9P4xk27m47mDvNBM1lMnDQD92eun-1q X-Proofpoint-ORIG-GUID: SY0RKG1ib1hgX9wP8faeUozaIvG0FYzr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_07,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150118 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=mx0b-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_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891050237100001 Content-Type: text/plain; charset="utf-8" S390 topology adds books and drawers topology containers. Let's add these to the HMP information for hotpluggable cpus. Signed-off-by: Pierre Morel --- hw/core/machine-hmp-cmds.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index c3e55ef9e9..971212242d 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -71,6 +71,12 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qd= ict) if (c->has_node_id) { monitor_printf(mon, " node-id: \"%" PRIu64 "\"\n", c->node_= id); } + if (c->has_drawer_id) { + monitor_printf(mon, " drawer_id: \"%" PRIu64 "\"\n", c->dra= wer_id); + } + if (c->has_book_id) { + monitor_printf(mon, " book_id: \"%" PRIu64 "\"\n", c->boo= k_id); + } if (c->has_socket_id) { monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->soc= ket_id); } --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678890976; cv=none; d=zohomail.com; s=zohoarc; b=LumrX275V8+RV00OvMIJASMZHmXu95hJc1EKXPHh82mRU8g5md7wnZM5aLPY2/62q+C0KBCtT8eMb1Ey6cdoEhOtPF9Ow8trgR3qjd0v2IU3hkQ6BWkDZEeUssQNkgaFOOQ1GEP5JdkF8RzyAY9uegpzqJ5GMaBZ6SI3DUW8LHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678890976; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p9Cf6rXrsg6BjY1jjq/9gLeqeSCOALi7qIzPvP2a/o4=; b=R7l6/4pJp4LiINHmsl+i2g1lvbPiHluZ+4ZU9tm0NKoLOMvN87ICarOWD46Itr69pjxRiJXR5GyiC6UfLnCHVkSYmuQcP/z9fnrWTgeO29K4NlQUlAFN9p4/tmcgoFdTsSDe18LHKZRRgV77RgnMmBG/lo2936aAxR2JRI+ziYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167889097650374.20881581576361; Wed, 15 Mar 2023 07:36:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSEF-0004ji-Ki; Wed, 15 Mar 2023 10:35:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE7-0004VP-8m; Wed, 15 Mar 2023 10:35:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] 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 1pcSE5-0007bS-KQ; Wed, 15 Mar 2023 10:35:38 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FEUiPi019844; Wed, 15 Mar 2023 14:35:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbeebk3gq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:28 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FCtpSC028488; Wed, 15 Mar 2023 14:35:28 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbeebk3fv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:27 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDiGDv032168; Wed, 15 Mar 2023 14:35:25 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3pb29u8wq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:25 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZMM628574102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:22 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DF1020040; Wed, 15 Mar 2023 14:35:22 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7C642004E; Wed, 15 Mar 2023 14:35:20 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:20 +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 : mime-version : content-transfer-encoding; s=pp1; bh=p9Cf6rXrsg6BjY1jjq/9gLeqeSCOALi7qIzPvP2a/o4=; b=lESGXmpEhuFIOOOOkZjfTIW6kYbwDSnB/PIYYxwdxEbpEXWNDH7Km14RmV370p3B07Js 9IBI2QQJY/opmRdrRbILxZyv+DJE/kjJfNDYhnYIja/0nN3o7MRij4R9q6hmDkNJxy3P cjcaYONMhwfHiPRhqpKqDrklKYNa9yge/XZBJzQCU7TYdNxjLZzJ8LpCkXewIrQ33hv7 bClHqBq9ckrsM6NwWhEspSwbGTWe5Dsf+CXpTSqzwXwHWmWx/simQY7tPtp53r/xrInQ S44sVJ50ARQjtRmnFsbYdsQgt5vb1+pBcOpqnnnDa6359jmbodBK8kDt/ojEku77WufJ VQ== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 11/17] qapi/s390x/cpu topology: CPU_POLARIZATION_CHANGE qapi event Date: Wed, 15 Mar 2023 15:34:56 +0100 Message-Id: <20230315143502.135750-12-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: p4-1hXjlpBFKktn_YlqgdXOsu97XEKic X-Proofpoint-ORIG-GUID: 3LJYDCnNQBqByF2HHAaCnQp3tIT7uhzd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_07,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 phishscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150118 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+importer2=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_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678890978183100003 Content-Type: text/plain; charset="utf-8" When the guest asks to change the polarization this change is forwarded to the upper layer using QAPI. The upper layer is supposed to take according decisions concerning CPU provisioning. Signed-off-by: Pierre Morel --- qapi/machine-target.json | 33 +++++++++++++++++++++++++++++++++ hw/s390x/cpu-topology.c | 2 ++ 2 files changed, 35 insertions(+) diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 3b7a0b77f4..ffde2e9cbd 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -391,3 +391,36 @@ 'features': [ 'unstable' ], 'if': { 'all': [ 'TARGET_S390X' , 'CONFIG_KVM' ] } } + +## +# @CPU_POLARIZATION_CHANGE: +# +# Emitted when the guest asks to change the polarization. +# +# @polarization: polarization specified by the guest +# +# Features: +# @unstable: This command may still be modified. +# +# The guest can tell the host (via the PTF instruction) whether the +# CPUs should be provisioned using horizontal or vertical polarization. +# +# On horizontal polarization the host is expected to provision all vCPUs +# equally. +# On vertical polarization the host can provision each vCPU differently. +# The guest will get information on the details of the provisioning +# the next time it uses the STSI(15) instruction. +# +# Since: 8.1 +# +# Example: +# +# <- { "event": "CPU_POLARIZATION_CHANGE", +# "data": { "polarization": 0 }, +# "timestamp": { "seconds": 1401385907, "microseconds": 422329 } } +## +{ 'event': 'CPU_POLARIZATION_CHANGE', + 'data': { 'polarization': 'CpuS390Polarization' }, + 'features': [ 'unstable' ], + 'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] } +} diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 1cf3adec31..39c6d262e3 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -19,6 +19,7 @@ #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/cpu-topology.h" #include "qapi/qapi-commands-machine-target.h" +#include "qapi/qapi-events-machine-target.h" =20 /* * s390_topology is used to keep the topology information. @@ -160,6 +161,7 @@ void s390_handle_ptf(S390CPU *cpu, uint8_t r1, uintptr_= t ra) s390_topology.polarization =3D fc; s390_topology_set_cpus_entitlement(); s390_cpu_topology_set_changed(true); + qapi_event_send_cpu_polarization_change(fc); setcc(cpu, 0); } break; --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891092; cv=none; d=zohomail.com; s=zohoarc; b=Gjks/d3mc5VKS7osQL7lV8uYqwu68vEINKAACS46l8itoZdXceW94YxcXt/JPRD8EDpI/5LdC4t2ZNautEgtaIaBlC1hCQBkLvFWHk333K/eQiYjcP64ya5ryPc/UdcycEGSsLKW0kZpchufBz2gHwVd0Rkb+/pSIXGq8nKWrJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891092; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xfBtvKduDgGdJVJLEJLkShJlLpbkM6iVKgaI9iZ1PiA=; b=L7PIBfrvFZRWF0H9VrQuaEfAPzNpicKueV2Ib1k+8KwA9IYtFNivmaCfQpaZUTThZqu1JETTrFV+Jr/d4YttbJpWRnqKUysOk7Ep1i7wfpoYWGhXKok4/muJkAfiuxk10JC2WHU6GC+hYIgf4cXiHektYQxXA3cOjAexvZT2O60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167889109272138.66361791615407; Wed, 15 Mar 2023 07:38:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSEH-0004pX-O4; Wed, 15 Mar 2023 10:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSEE-0004ia-JP; Wed, 15 Mar 2023 10:35:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE9-0007ct-5c; Wed, 15 Mar 2023 10:35:43 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FE9kWs032328; Wed, 15 Mar 2023 14:35:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsga6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:30 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FEAZtc003195; Wed, 15 Mar 2023 14:35:29 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbf4qsg8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:29 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDZuLH021175; Wed, 15 Mar 2023 14:35:27 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3pb29srwr6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:27 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZNYo14025256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:23 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC37A20040; Wed, 15 Mar 2023 14:35:23 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C6D52004B; Wed, 15 Mar 2023 14:35:22 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:22 +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 : mime-version : content-transfer-encoding; s=pp1; bh=xfBtvKduDgGdJVJLEJLkShJlLpbkM6iVKgaI9iZ1PiA=; b=MPx0zcZ9QYs85FjkouLUarcqqtEFIgVFLxDzb4ChPe81NHE8y5Mc+9/t5NNdHA30/PcZ BgS7qQIDGe/jqf8Qc34h5BLZeAiNnXz/+G5XngyZE569lcoQQMWDdqpqxT8fk19J/LXc oJU5RItmbPmphFpyvDL8FitO7PI2in8tWVA/EkUsOiMC+eTywAoHYzcyBPbcdPT6qtjI j0twW5yiBUgsr9c5SilEqsd8RMJhvTyzAbT+zCwcrKeQamVNTfK3iMNaNgHE1Pb/xguC USI5mYFL4BwYFyseR73BD/fNqnY757yAZ+wd8XjgjlSBJpMyY829LqakpkQXWAxU2+L2 TQ== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 12/17] docs/s390x/cpu topology: document s390x cpu topology Date: Wed, 15 Mar 2023 15:34:57 +0100 Message-Id: <20230315143502.135750-13-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Q_ATpWh06IEvmEowa-nCB6Il156gyR0a X-Proofpoint-ORIG-GUID: 3f5WS4KwXbFNbQAtgAHAri5BkKq8pscO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 spamscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891094840100003 Content-Type: text/plain; charset="utf-8" Add some basic examples for the definition of cpu topology in s390x. Signed-off-by: Pierre Morel --- docs/devel/index-internals.rst | 1 + docs/devel/s390-cpu-topology.rst | 146 ++++++++++++++++++ docs/system/s390x/cpu-topology.rst | 238 +++++++++++++++++++++++++++++ docs/system/target-s390x.rst | 1 + 4 files changed, 386 insertions(+) create mode 100644 docs/devel/s390-cpu-topology.rst create mode 100644 docs/system/s390x/cpu-topology.rst diff --git a/docs/devel/index-internals.rst b/docs/devel/index-internals.rst index e1a93df263..6f81df92bc 100644 --- a/docs/devel/index-internals.rst +++ b/docs/devel/index-internals.rst @@ -14,6 +14,7 @@ Details about QEMU's various subsystems including how to = add features to them. migration multi-process reset + s390-cpu-topology s390-dasd-ipl tracing vfio-migration diff --git a/docs/devel/s390-cpu-topology.rst b/docs/devel/s390-cpu-topolog= y.rst new file mode 100644 index 0000000000..014b40f310 --- /dev/null +++ b/docs/devel/s390-cpu-topology.rst @@ -0,0 +1,146 @@ +QAPI interface for S390 CPU topology +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Let's start QEMU with the following command: + +.. code-block:: bash + + qemu-system-s390x \ + -enable-kvm \ + -cpu z14,ctop=3Don \ + -smp 1,drawers=3D3,books=3D3,sockets=3D2,cores=3D2,maxcpus=3D36 \ + \ + -device z14-s390x-cpu,core-id=3D19,polarization=3D3 \ + -device z14-s390x-cpu,core-id=3D11,polarization=3D1 \ + -device z14-s390x-cpu,core-id=3D112,polarization=3D3 \ + ... + +and see the result when using the QAPI interface. + +Addons to query-cpus-fast +------------------------- + +The command query-cpus-fast allows to query the topology tree and +modifiers for all configured vCPUs. + +.. code-block:: QMP + + { "execute": "query-cpus-fast" } + { + "return": [ + { + "dedicated": false, + "thread-id": 536993, + "props": { + "core-id": 0, + "socket-id": 0, + "drawer-id": 0, + "book-id": 0 + }, + "cpu-state": "operating", + "entitlement": "medium", + "qom-path": "/machine/unattached/device[0]", + "cpu-index": 0, + "target": "s390x" + }, + { + "dedicated": false, + "thread-id": 537003, + "props": { + "core-id": 19, + "socket-id": 1, + "drawer-id": 0, + "book-id": 2 + }, + "cpu-state": "operating", + "entitlement": "high", + "qom-path": "/machine/peripheral-anon/device[0]", + "cpu-index": 19, + "target": "s390x" + }, + { + "dedicated": false, + "thread-id": 537004, + "props": { + "core-id": 11, + "socket-id": 1, + "drawer-id": 0, + "book-id": 1 + }, + "cpu-state": "operating", + "entitlement": "low", + "qom-path": "/machine/peripheral-anon/device[1]", + "cpu-index": 11, + "target": "s390x" + }, + { + "dedicated": true, + "thread-id": 537005, + "props": { + "core-id": 112, + "socket-id": 0, + "drawer-id": 3, + "book-id": 2 + }, + "cpu-state": "operating", + "entitlement": "high", + "qom-path": "/machine/peripheral-anon/device[2]", + "cpu-index": 112, + "target": "s390x" + } + ] + } + + +QAPI command: set-cpu-topology +------------------------------ + +The command set-cpu-topology allows to modify the topology tree +or the topology modifiers of a vCPU in the configuration. + +.. code-block:: QMP + + { "execute": "set-cpu-topology", + "arguments": { + "core-id": 11, + "socket-id": 0, + "book-id": 0, + "drawer-id": 0, + "entitlement": "low", + "dedicated": false + } + } + {"return": {}} + +The core-id parameter is the only non optional parameter and every +unspecified parameter keeps its previous value. + +QAPI event CPU_POLARIZATION_CHANGE +---------------------------------- + +When a guest is requests a modification of the polarization, +QEMU sends a CPU_POLARIZATION_CHANGE event. + +When requesting the change, the guest only specifies horizontal or +vertical polarization. +It is the job of the upper layer to set the dedication and fine grained +vertical entitlement in response to this event. + +Note that a vertical polarized dedicated vCPU can only have a high +entitlement, this gives 6 possibilities for vCPU polarization: + +- Horizontal +- Horizontal dedicated +- Vertical low +- Vertical medium +- Vertical high +- Vertical high dedicated + +Example of the event received when the guest issues the CPU instruction +Perform Topology Function PTF(0) to request an horizontal polarization: + +.. code-block:: QMP + + { "event": "CPU_POLARIZATION_CHANGE", + "data": { "polarization": 0 }, + "timestamp": { "seconds": 1401385907, "microseconds": 422329 } } diff --git a/docs/system/s390x/cpu-topology.rst b/docs/system/s390x/cpu-top= ology.rst new file mode 100644 index 0000000000..c1fe3da51c --- /dev/null +++ b/docs/system/s390x/cpu-topology.rst @@ -0,0 +1,238 @@ +CPU topology on s390x +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Since QEMU 8.1, CPU topology on s390x provides up to 3 levels of +topology containers: drawers, books, sockets, defining a tree shaped +hierarchy. + +The socket container contains one or more CPU entries. +Each of these CPU entries consists of a bitmap and three CPU attributes: + +- CPU type +- polarization entitlement +- dedication + +Each bit set in the bitmap correspond to the core-id of a vCPU with +matching the three attribute. + +This documentation provide general information on S390 CPU topology, +how to enable it and on the new CPU attributes. +For information on how to modify the S390 CPU topology and on how to +monitor the polarization change see ``Developer Information``. + +Prerequisites +------------- + +To use the CPU topology, you need to run with KVM on a s390x host that +uses the Linux kernel v6.0 or newer (which provide the so-called +``KVM_CAP_S390_CPU_TOPOLOGY`` capability that allows QEMU to signal the +CPU topology facility via the so-called STFLE bit 11 to the VM). + +Enabling CPU topology +--------------------- + +Currently, CPU topology is only enabled in the host model by default. + +Enabling CPU topology in a CPU model is done by setting the CPU flag +``ctop`` to ``on`` like in: + +.. code-block:: bash + + -cpu gen16b,ctop=3Don + +Having the topology disabled by default allows migration between +old and new QEMU without adding new flags. + +Default topology usage +---------------------- + +The CPU topology can be specified on the QEMU command line +with the ``-smp`` or the ``-device`` QEMU command arguments. + +Note also that since 7.2 threads are no longer supported in the topology +and the ``-smp`` command line argument accepts only ``threads=3D1``. + +If none of the containers attributes (drawers, books, sockets) are +specified for the ``-smp`` flag, the number of these containers +is ``1`` . + +.. code-block:: bash + + -smp cpus=3D5,drawer=3D1,books=3D1,sockets=3D8,cores=3D4,maxcpus=3D32 + +or + +.. code-block:: bash + + -smp cpus=3D5,sockets=3D8,cores=3D4,maxcpus=3D32 + +When a CPU is defined by the ``-smp`` command argument, its position +inside the topology is calculated by adding the CPUs to the topology +based on the core-id starting with core-0 at position 0 of socket-0, +book-0, drawer-0 and filling all CPUs of socket-0 before to fill socket-1 +of book-0 and so on up to the last socket of the last book of the last +drawer. + +When a CPU is defined by the ``-device`` command argument, the +tree topology attributes must be all defined or all not defined. + +.. code-block:: bash + + -device gen16b-s390x-cpu,drawer-id=3D1,book-id=3D1,socket-id=3D2,core-= id=3D1 + +or + +.. code-block:: bash + + -device gen16b-s390x-cpu,core-id=3D1,dedication=3Dtrue + +If none of the tree attributes (drawer, book, sockets), are specified +for the ``-device`` argument, as for all CPUs defined with the ``-smp`` +command argument the topology tree attributes will be set by simply +adding the CPUs to the topology based on the core-id starting with +core-0 at position 0 of socket-0, book-0, drawer-0. + +QEMU will not try to solve collisions and will report an error if the +CPU topology, explicitly or implicitly defined on a ``-device`` +argument collides with the definition of a CPU implicitely defined +on the ``-smp`` argument. + +When the topology modifier attributes are not defined for the +``-device`` command argument they takes following default values: + +- dedication: ``false`` +- entitlement: ``medium`` + + +Hot plug +++++++++ + +New CPUs can be plugged using the device_add hmp command as in: + +.. code-block:: bash + + (qemu) device_add gen16b-s390x-cpu,core-id=3D9 + +The same placement of the CPU is derived from the core-id as described abo= ve. + +The topology can of course be fully defined: + +.. code-block:: bash + + (qemu) device_add gen16b-s390x-cpu,drawer-id=3D1,book-id=3D1,socket-id= =3D2,core-id=3D1 + + +Examples +++++++++ + +In the following machine we define 8 sockets with 4 cores each. + +.. code-block:: bash + + $ qemu-system-s390x -m 2G \ + -cpu gen16b,ctop=3Don \ + -smp cpus=3D5,sockets=3D8,cores=3D4,maxcpus=3D32 \ + -device host-s390x-cpu,core-id=3D14 \ + +A new CPUs can be plugged using the device_add hmp command as before: + +.. code-block:: bash + + (qemu) device_add gen16b-s390x-cpu,core-id=3D9 + +The core-id defines the placement of the core in the topology by +starting with core 0 in socket 0 up to maxcpus. + +In the example above: + +* There are 5 CPUs provided to the guest with the ``-smp`` command line + They will take the core-ids 0,1,2,3,4 + As we have 4 cores in a socket, we have 4 CPUs provided + to the guest in socket 0, with core-ids 0,1,2,3. + The last cpu, with core-id 4, will be on socket 1. + +* the core with ID 14 provided by the ``-device`` command line will + be placed in socket 3, with core-id 14 + +* the core with ID 9 provided by the ``device_add`` qmp command will + be placed in socket 2, with core-id 9 + + +Polarization, entitlement and dedication +---------------------------------------- + +Polarization +++++++++++++ + +The polarization is an indication given by the ``guest`` to the host +that it is able to make use of CPU provisioning information. +The guest indicates the polarization by using the PTF instruction. + +Polarization is define two models of CPU provisioning: horizontal +and vertical. + +The horizontal polarization is the default model on boot and after +subsystem reset in which the guest considers all vCPUs being having +an equal provisioning of CPUs by the host. + +In the vertical polarization model the guest can make use of the +vCPU entitlement information provided by the host to optimize +kernel thread scheduling. + +A subsystem reset puts all vCPU of the configuration into the +horizontal polarization. + +Entitlement ++++++++++++ + +The vertical polarization specifies that the guest's vCPU can get +different real CPU provisions: + +- a vCPU with vertical high entitlement specifies that this + vCPU gets 100% of the real CPU provisioning. + +- a vCPU with vertical medium entitlement specifies that this + vCPU shares the real CPU with other vCPUs. + +- a vCPU with vertical low entitlement specifies that this + vCPU only gets real CPU provisioning when no other vCPUs needs it. + +In the case a vCPU with vertical high entitlement does not use +the real CPU, the unused "slack" can be dispatched to other vCPU +with medium or low entitlement. + +The upper level specifies a vCPU as ``dedicated`` when the vCPU is +fully dedicated to a single real CPU. + +The dedicated bit is an indication of affinity of a vCPU for a real CPU +while the entitlement indicates the sharing or exclusivity of use. + +Defining the topology on command line +------------------------------------- + +The topology can entirely be defined using -device cpu statements, +with the exception of CPU 0 which must be defined with the -smp +argument. + +For example, here we set the position of the cores 1,2,3 to +drawer 1, book 1, socket 2 and cores 0,9 and 14 to drawer 0, +book 0, socket 0 with all horizontal polarization and not dedicated. +The core 4, will be set on its default position on socket 1 +(since we have 4 core per socket) and we define it with dedication and +vertical high entitlement. + +.. code-block:: bash + + $ qemu-system-s390x -m 2G \ + -cpu gen16b,ctop=3Don \ + -smp cpus=3D1,sockets=3D8,cores=3D4,maxcpus=3D32 \ + \ + -device gen16b-s390x-cpu,drawer-id=3D1,book-id=3D1,socket-id=3D2,core-= id=3D1 \ + -device gen16b-s390x-cpu,drawer-id=3D1,book-id=3D1,socket-id=3D2,core-= id=3D2 \ + -device gen16b-s390x-cpu,drawer-id=3D1,book-id=3D1,socket-id=3D2,core-= id=3D3 \ + \ + -device gen16b-s390x-cpu,drawer-id=3D0,book-id=3D0,socket-id=3D0,core-= id=3D9 \ + -device gen16b-s390x-cpu,drawer-id=3D0,book-id=3D0,socket-id=3D0,core-= id=3D14 \ + \ + -device gen16b-s390x-cpu,core-id=3D4,dedicated=3Don,polarization=3D3 \ + diff --git a/docs/system/target-s390x.rst b/docs/system/target-s390x.rst index f6f11433c7..94c981e732 100644 --- a/docs/system/target-s390x.rst +++ b/docs/system/target-s390x.rst @@ -34,3 +34,4 @@ Architectural features .. toctree:: s390x/bootdevices s390x/protvirt + s390x/cpu-topology --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891023; cv=none; d=zohomail.com; s=zohoarc; b=BsMu8+eDQktjYi0W1Ip/NFxyNCKrcovzRckx7zgo+a4KszK8pwsmjWVqIk6F5J5FCBU5Z1l4M1TGmGZ7JGd5MU/Oi/eFS/yznLSK+B1ocOBXRlrXU/JyLbEnG6vpCxqYagw3O4n2H1FUMWM3NzQCjxWcJ9fsSOHA0SpD2GityFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891023; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MTl5H7cPHTT/rfR8rpNYox3VA/QOvoRK8DT+AJtIxFY=; b=XRX+YI9/uXPPSDRfFJufaNJY3yBTE4wkW+ACKV8BtlOGFSihQFh7Slm4j5NKvzuQJ7HfS9Gn2crKUWoQkxcTU0inWXGLK0hjkOp96tn5ExFovvlFKf8ULXvynrA+NYFChZubD6wAw9D/VA7vfa2/tJSbRjwCRkNopN0BOFuGCCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891023030861.2752336008764; Wed, 15 Mar 2023 07:37:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSEA-0004cf-5w; Wed, 15 Mar 2023 10:35:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE7-0004VW-C7; Wed, 15 Mar 2023 10:35:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE4-0007ap-UU; Wed, 15 Mar 2023 10:35:39 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDP5Wp020346; Wed, 15 Mar 2023 14:35:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbevhtb7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:31 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDR5W0029921; Wed, 15 Mar 2023 14:35:31 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbevhtb6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:31 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN5FXf001331; Wed, 15 Mar 2023 14:35:28 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3pb29t0r2w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:28 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZPWd26673780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:25 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 410AD2004B; Wed, 15 Mar 2023 14:35:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C858220043; Wed, 15 Mar 2023 14:35:23 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:23 +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 : content-transfer-encoding : mime-version; s=pp1; bh=MTl5H7cPHTT/rfR8rpNYox3VA/QOvoRK8DT+AJtIxFY=; b=TC1s+Pnx/Z7f5a81hSSm6Hnq9rmbEAMwOoz0F0lCZpwdj9sA1q8d02FkLzFGF8q0IAuB kWMhAPRBuIUZspn0h0PEhjbun4Dg2oyfPXnWA8lSDKqKysA/OJ/q91d8D6iGKJIVvna5 PNcP0c0q7hl4VrPX9+UDTMbF5xWl61Vt7oiuTYJst6aSKnnYoDdGhmMIKz4uG/Ozt1hY 2QkWe8KTpPKcJFJ8jdVRjU5jZqXv9hB82pz+g/szhgZUhR8CdVA8VPtUNso/L+pWUnQh oNy76Y92d3tTwcVFuv6YD9wQzIhsE3jG2fb17JRpsbSdOoYe4mbY9gJYVrX2Qr3lx6Bl Mg== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 13/17] tests/avocado: s390x cpu topology core Date: Wed, 15 Mar 2023 15:34:58 +0100 Message-Id: <20230315143502.135750-14-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fyDVTo5TLd44y5xUvKtpCYgNKKvLjaQh X-Proofpoint-ORIG-GUID: uK3PKZiDpAHc56k6zs0InSFDbwmj1BFV Content-Transfer-Encoding: quoted-printable X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891023583100001 Content-Type: text/plain; charset="utf-8" Introduction of the s390x cpu topology core functions and basic tests. We test the corelation between the command line and the QMP results in query-cpus-fast for various CPU topology. Signed-off-by: Pierre Morel --- tests/avocado/s390_topology.py | 196 +++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 tests/avocado/s390_topology.py diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py new file mode 100644 index 0000000000..c908111e94 --- /dev/null +++ b/tests/avocado/s390_topology.py @@ -0,0 +1,196 @@ +# Functional test that boots a Linux kernel and checks the console +# +# Copyright (c) 2023 IBM Corp. +# +# Author: +# Pierre Morel +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import os +import shutil +import time + +from avocado import skip +from avocado import skipUnless +from avocado import skipIf +from avocado_qemu import QemuSystemTest +from avocado_qemu import exec_command +from avocado_qemu import exec_command_and_wait_for_pattern +from avocado_qemu import interrupt_interactive_console_until_pattern +from avocado_qemu import wait_for_console_pattern +from avocado.utils import process +from avocado.utils import archive + + +class LinuxKernelTest(QemuSystemTest): + KERNEL_COMMON_COMMAND_LINE =3D 'printk.time=3D0 ' + + def wait_for_console_pattern(self, success_message, vm=3DNone): + wait_for_console_pattern(self, success_message, + failure_message=3D'Kernel panic - not syn= cing', + vm=3Dvm) + + +class S390CPUTopology(LinuxKernelTest): + """ + S390x CPU topology consist of 4 topology layers, from bottom to top, + the cores, sockets, books and drawers and 2 modifiers attributes, + the entitlement and the dedication. + See: docs/system/s390x/cpu-topology.rst. + + S390x CPU topology is setup in different ways: + - implicitely from the '-smp' argument by completing each topology + level one after the other begining with drawer 0, book 0 and socket = 0. + - explicitely from the '-device' argument on the QEMU command line + - explicitely by hotplug of a new CPU using QMP or HMP + - it is modified by using QMP 'set-cpu-topology' + + The S390x modifier attribute entitlement depends on the machine + polarization, which can be horizontal or vertical. + The polarization is changed on a request from the guest. + """ + timeout =3D 90 + + + def check_topology(self, c, s, b, d, e, t): + res =3D self.vm.qmp('query-cpus-fast') + line =3D res['return'] + for x in line: + core =3D x['props']['core-id'] + socket =3D x['props']['socket-id'] + book =3D x['props']['book-id'] + drawer =3D x['props']['drawer-id'] + entitlement =3D x['entitlement'] + dedicated =3D x['dedicated'] + if core =3D=3D c: + self.assertEqual(drawer, d) + self.assertEqual(book, b) + self.assertEqual(socket, s) + self.assertEqual(entitlement, e) + self.assertEqual(dedicated, t) + + def kernel_init(self): + """ + We need a kernel supporting the CPU topology. + We need a minimal root filesystem with a shell. + """ + kernel_url =3D ('https://archives.fedoraproject.org/pub/archive' + '/fedora-secondary/releases/35/Server/s390x/os' + '/images/kernel.img') + kernel_hash =3D '0d1aaaf303f07cf0160c8c48e56fe638' + kernel_path =3D self.fetch_asset(kernel_url, algorithm=3D'md5', + asset_hash=3Dkernel_hash) + + initrd_url =3D ('https://archives.fedoraproject.org/pub/archive' + '/fedora-secondary/releases/35/Server/s390x/os' + '/images/initrd.img') + initrd_hash =3D 'a122057d95725ac030e2ec51df46e172' + initrd_path_xz =3D self.fetch_asset(initrd_url, algorithm=3D'md5', + asset_hash=3Dinitrd_hash) + initrd_path =3D os.path.join(self.workdir, 'initrd-raw.img') + archive.lzma_uncompress(initrd_path_xz, initrd_path) + + self.vm.set_console() + kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + + 'root=3D/dev/ram ' + 'selinux=3D0 ' + 'rdinit=3D/bin/sh') + self.vm.add_args('-nographic', + '-enable-kvm', + '-cpu', 'z14,ctop=3Don', + '-m', '512', + '-name', 'Some Guest Name', + '-uuid', '30de4fd9-b4d5-409e-86a5-09b387f70bfa', + '-kernel', kernel_path, + '-initrd', initrd_path, + '-append', kernel_command_line) + + def test_single(self): + self.kernel_init() + self.vm.launch() + self.wait_for_console_pattern('no job control') + self.check_topology(0, 0, 0, 0, 'horizontal', False) + + def test_default(self): + """ + This test checks the implicite topology. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.add_args('-smp', + '13,drawers=3D2,books=3D2,sockets=3D3,cores=3D2,m= axcpus=3D24') + self.vm.launch() + self.wait_for_console_pattern('no job control') + self.check_topology(0, 0, 0, 0, 'horizontal', False) + self.check_topology(1, 0, 0, 0, 'horizontal', False) + self.check_topology(2, 1, 0, 0, 'horizontal', False) + self.check_topology(3, 1, 0, 0, 'horizontal', False) + self.check_topology(4, 2, 0, 0, 'horizontal', False) + self.check_topology(5, 2, 0, 0, 'horizontal', False) + self.check_topology(6, 0, 1, 0, 'horizontal', False) + self.check_topology(7, 0, 1, 0, 'horizontal', False) + self.check_topology(8, 1, 1, 0, 'horizontal', False) + self.check_topology(9, 1, 1, 0, 'horizontal', False) + self.check_topology(10, 2, 1, 0, 'horizontal', False) + self.check_topology(11, 2, 1, 0, 'horizontal', False) + self.check_topology(12, 0, 0, 1, 'horizontal', False) + + def test_move(self): + """ + This test checks the topology modification by moving a CPU + to another socket: CPU 0 is moved from socket 0 to socket 2. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.add_args('-smp', + '1,drawers=3D2,books=3D2,sockets=3D3,cores=3D2,ma= xcpus=3D24') + self.vm.launch() + self.wait_for_console_pattern('no job control') + + self.check_topology(0, 0, 0, 0, 'horizontal', False) + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 0, 'socket-id': 2, 'entitlement': 'l= ow'}) + self.assertEqual(res['return'], {}) + self.check_topology(0, 2, 0, 0, 'horizontal', False) + + def test_hotplug(self): + """ + This test verifies that a CPU defined with '-device' command line + argument finds its right place inside the topology. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.add_args('-smp', + '1,drawers=3D2,books=3D2,sockets=3D3,cores=3D2,ma= xcpus=3D24') + self.vm.add_args('-device', 'z14-s390x-cpu,core-id=3D10') + self.vm.launch() + self.wait_for_console_pattern('no job control') + + self.check_topology(10, 2, 1, 0, 'horizontal', False) + + def test_hotplug_full(self): + """ + This test verifies that a hotplugged fully defined with '-device' + command line argument finds its right place inside the topology. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.add_args('-smp', + '1,drawers=3D2,books=3D2,sockets=3D3,cores=3D2,ma= xcpus=3D24') + self.vm.add_args('-device', + 'z14-s390x-cpu,' + 'core-id=3D1,socket-id=3D1,book-id=3D1,drawer-id= =3D1') + self.vm.launch() + self.wait_for_console_pattern('no job control') + self.check_topology(1, 1, 1, 1, 'horizontal', False) + --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891065; cv=none; d=zohomail.com; s=zohoarc; b=VUxKxmCxI6E0rNJlF2pbNI204VB291Tgh4gLyM6cxGwoa5bYhZD2mt924Ss+ZJ3Fx53ZwCPhux6+YCvQzd/y5+9UBwxdlYU8h0e+g1V+keQGUqby8uhLM0Y2QkOfUYeHmySccd/ogDiuJ9ey+PXJKnTyu5rOo8iGy7mZRdQWhbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891065; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N0vW1+w774dkCmI3ncBWIImCzCYY7NMi+9NA3Ik1WUA=; b=W/tEScmZjiSTuAPEEgQnsOBpbVdgiPlMJiu/lPuEQhPTYKBENC1eJCzCtK7fOkrFp1kdrMNdycp4lMg6RWvj55G0fjarAhpaK7iVwnee1vMI4PnHqUc4VTGq3gInj3BOX9IyLA5EiCUXT8hFfqtuvk/T+iu2s9SgueKn5BIjcEg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891065763676.1886165808385; Wed, 15 Mar 2023 07:37:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSEH-0004pc-Qd; Wed, 15 Mar 2023 10:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSEG-0004mO-68; Wed, 15 Mar 2023 10:35:48 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSEE-0007dl-B5; Wed, 15 Mar 2023 10:35:47 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FCpnJY000743; Wed, 15 Mar 2023 14:35:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ud5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:33 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDVnW2004355; Wed, 15 Mar 2023 14:35:33 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbed8ud3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:32 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN62qT001318; Wed, 15 Mar 2023 14:35:30 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3pb29rrrex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:30 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZQwG12649156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:26 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B47782004D; Wed, 15 Mar 2023 14:35:26 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D27320043; Wed, 15 Mar 2023 14:35:25 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:25 +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 : mime-version : content-transfer-encoding; s=pp1; bh=N0vW1+w774dkCmI3ncBWIImCzCYY7NMi+9NA3Ik1WUA=; b=ImLXU/Uo01dhX8p4HBJIDP0UitJnnDmu8dKlfaFfIEZ/6PCzuO08Dc66JaOh1xgjtPyF H48tYvaWU0f9cebz6Gr/mMwzpQzX0jZxMhUD5GBv5kA3P0M2ygYJ5/11lPCUskgRA7Fm jg1rKjml7+UaipgrXD8Nh62uzESKXbhZvB5kbU45sc2yNWSjM/uYDxqovfxQyL1nrGI5 1gf292CwAgvuZRC9zup7dmspvMOd1I5fZEJYPx+qC5HLai9NrcN3z3WEXxu3AJdluS3z PS0Q0Y5Cuqs5MfyFoHWz+ma0GNTAu8TB+5aeNr4hCtjegD6BSjEDFSjHfilpvE6712kl gA== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 14/17] tests/avocado: s390x cpu topology polarisation Date: Wed, 15 Mar 2023 15:34:59 +0100 Message-Id: <20230315143502.135750-15-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: EvxjnNWuEVchWBN9sMGxW_wNW6qo9AAa X-Proofpoint-ORIG-GUID: -TsCJZQ1sgv4qSymgrPB8O710KXzDitC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891066632100011 Content-Type: text/plain; charset="utf-8" Polarization is changed on a request from the guest. Let's verify the polarization is accordingly set by QEMU. Signed-off-by: Pierre Morel --- tests/avocado/s390_topology.py | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py index c908111e94..70bd3a8b5a 100644 --- a/tests/avocado/s390_topology.py +++ b/tests/avocado/s390_topology.py @@ -107,6 +107,15 @@ def kernel_init(self): '-initrd', initrd_path, '-append', kernel_command_line) =20 + def system_init(self): + self.log.info("System init") + exec_command(self, 'mount proc -t proc /proc') + time.sleep(0.2) + exec_command(self, 'mount sys -t sysfs /sys') + time.sleep(0.2) + exec_command_and_wait_for_pattern(self, + '/bin/cat /sys/devices/system/cpu/dispatching', '0') + def test_single(self): self.kernel_init() self.vm.launch() @@ -116,7 +125,6 @@ def test_single(self): def test_default(self): """ This test checks the implicite topology. - :avocado: tags=3Darch:s390x :avocado: tags=3Dmachine:s390-ccw-virtio """ @@ -194,3 +202,31 @@ def test_hotplug_full(self): self.wait_for_console_pattern('no job control') self.check_topology(1, 1, 1, 1, 'horizontal', False) =20 + def test_polarisation(self): + """ + This test verifies that QEMU modifies the entitlement change after + several guest polarization change requests. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.launch() + self.wait_for_console_pattern('no job control') + + self.system_init() + self.check_topology(0, 0, 0, 0, 'horizontal', False) + + exec_command(self, 'echo 1 > /sys/devices/system/cpu/dispatching') + time.sleep(0.2) + exec_command_and_wait_for_pattern(self, + '/bin/cat /sys/devices/system/cpu/dispatching', '1') + + self.check_topology(0, 0, 0, 0, 'medium', False) + + exec_command(self, 'echo 0 > /sys/devices/system/cpu/dispatching') + time.sleep(0.2) + exec_command_and_wait_for_pattern(self, + '/bin/cat /sys/devices/system/cpu/dispatching', '0') + + self.check_topology(0, 0, 0, 0, 'horizontal', False) --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891015; cv=none; d=zohomail.com; s=zohoarc; b=cln5ZXXN1EKiMuGE0bNgBC5y4oWYfN/0ab6XLYoOQyBkt6wByenAyks8z8fQj+58tOYTGxmkW7xZ/b7g7UYSafKdHPw9YFtGgc3Zvk79vO8GECvYvAEAbbzUmSxfyEJTpcZNQivc2Dx0yOn+QSE+o+g2i24KSekd20fF5UAtfWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891015; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ek2lOIkvKWSSoCxa8k3ftABFZERtuPglm0HjagHrlu8=; b=Y78eiabvfeS8sM8OBBgkfWCHvFCi340aKioQSjnPErU4Zo06KSw7umWssVnvCQSmWWpOwxAa+ARnrT3PlxLTtwWKrezqULsnpWy359xf5+FmaLdRWyf+9F62V3pSscubASEuS5mgoB76vTx37Xz6w7167NL3K0D4j3j/TEd/cMw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891015808625.4536462044181; Wed, 15 Mar 2023 07:36:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSEG-0004nP-Km; Wed, 15 Mar 2023 10:35:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE9-0004c1-Hu; Wed, 15 Mar 2023 10:35:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSE7-0007cC-Ob; Wed, 15 Mar 2023 10:35:41 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDP2MO020024; Wed, 15 Mar 2023 14:35:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbevhtb99-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:34 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDQBHY027188; Wed, 15 Mar 2023 14:35:34 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbevhtb7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:34 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32FE0Xn5032336; Wed, 15 Mar 2023 14:35:31 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3pb29u8wq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:31 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZSqv31654384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:28 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3744A20043; Wed, 15 Mar 2023 14:35:28 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0A4920040; Wed, 15 Mar 2023 14:35:26 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:26 +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 : mime-version : content-transfer-encoding; s=pp1; bh=ek2lOIkvKWSSoCxa8k3ftABFZERtuPglm0HjagHrlu8=; b=VLlFoJv1XJhi9Nl2kNLV0FL1IOtWdPyku2v5ZbsTV/XXCueDgl9JlhzSqxLLXLBXu9sY 0D+3vj9eneaUYTiZR+d0IjeMFJSHTR2IhATmBnyDgkCrJYxTM8RHBQKBN8TQ48qep+zT adVjzemKKIZl29NZvc/yvPH32zRG2XBs5qRVXWXSf50DObkv7YixVtg0WyQ1KVv1XS4S fRErR6Uioj82Dfg9caNzUVzpc9AYri6fHiNanmV41d5t9oJBmUGBZtEn5meoUcYVfAwT fS5xr98UMfIXRANd8D+sVISVP9DkngOb/1bZfh4TgimwGGiKx7d4nSeLMVoVevqUoAEq aQ== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 15/17] tests/avocado: s390x cpu topology entitlement tests Date: Wed, 15 Mar 2023 15:35:00 +0100 Message-Id: <20230315143502.135750-16-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CnYfULr4VER6wFTBIdhrdCn88nrx9Zhe X-Proofpoint-ORIG-GUID: rkgNTiR1kFVpnzfxKmhFjA9w02ANzXNa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150122 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891017574100003 Content-Type: text/plain; charset="utf-8" This test takes care to check the changes on different entitlements when the guest requests a polarization change. Signed-off-by: Pierre Morel --- tests/avocado/s390_topology.py | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py index 70bd3a8b5a..c6ee46fb52 100644 --- a/tests/avocado/s390_topology.py +++ b/tests/avocado/s390_topology.py @@ -230,3 +230,59 @@ def test_polarisation(self): '/bin/cat /sys/devices/system/cpu/dispatching', '0') =20 self.check_topology(0, 0, 0, 0, 'horizontal', False) + + def test_set_cpu_topology_entitlement(self): + """ + This test verifies that QEMU modifies the polarization + after a guest request. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.add_args('-smp', + '1,drawers=3D2,books=3D2,sockets=3D3,cores=3D2,ma= xcpus=3D24') + self.vm.add_args('-device', 'z14-s390x-cpu,core-id=3D1') + self.vm.add_args('-device', 'z14-s390x-cpu,core-id=3D2') + self.vm.add_args('-device', 'z14-s390x-cpu,core-id=3D3') + self.vm.launch() + self.wait_for_console_pattern('no job control') + + self.system_init() + + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 0, 'entitlement': 'low'}) + self.assertEqual(res['return'], {}) + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 1, 'entitlement': 'medium'}) + self.assertEqual(res['return'], {}) + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 2, 'entitlement': 'high'}) + self.assertEqual(res['return'], {}) + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 3, 'entitlement': 'high'}) + self.assertEqual(res['return'], {}) + self.check_topology(0, 0, 0, 0, 'horizontal', False) + self.check_topology(1, 0, 0, 0, 'horizontal', False) + self.check_topology(2, 1, 0, 0, 'horizontal', False) + self.check_topology(3, 1, 0, 0, 'horizontal', False) + + exec_command(self, 'echo 1 > /sys/devices/system/cpu/dispatching') + time.sleep(0.2) + exec_command_and_wait_for_pattern(self, + '/bin/cat /sys/devices/system/cpu/dispatching', '1') + + self.check_topology(0, 0, 0, 0, 'low', False) + self.check_topology(1, 0, 0, 0, 'medium', False) + self.check_topology(2, 1, 0, 0, 'high', False) + self.check_topology(3, 1, 0, 0, 'high', False) + + exec_command(self, 'echo 0 > /sys/devices/system/cpu/dispatching') + time.sleep(0.2) + exec_command_and_wait_for_pattern(self, + '/bin/cat /sys/devices/system/cpu/dispatching', '0') + + self.check_topology(0, 0, 0, 0, 'horizontal', False) + self.check_topology(1, 0, 0, 0, 'horizontal', False) + self.check_topology(2, 1, 0, 0, 'horizontal', False) + self.check_topology(3, 1, 0, 0, 'horizontal', False) --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678890977; cv=none; d=zohomail.com; s=zohoarc; b=noeqziWDAhsJ5kdyjP6+HAR+YdfnFFq24gXmDhf9KfLJSnVHPKbQ9gIWSDFTQF9ZCiS9hbXX8bXYXXIsuh7dVYH9foVOC996wyevIYAXfzcfuwZ5YG5ChoWUlRwkXw2jq7Jd2Zx8LnjgtSmofa2VW7sKOY1U+tECtZEcjpQ/OL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678890977; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5U9DW9qO++BtSEyMWDOX/G2DdsQ2DmlQkqsLk17OEhw=; b=AuJhT03P2BW6gAgft+Q6mbjHPizlgMNU9XjPcINmpTdRoVnv9wt7TY0GqmR3I+97dBy4KYyZuHwkMQTOkaOHeaEOWfuVwHmSh9dy7jEnngUUutPB5WnUjn9gXH+4GP+N/TvbhaT6FnBwJA1nNab0zXGQCDT3rI91FLeYkKvDLko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678890977925595.7081818786088; Wed, 15 Mar 2023 07:36:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSEJ-0004tJ-J4; Wed, 15 Mar 2023 10:35:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSEH-0004pb-Nw; Wed, 15 Mar 2023 10:35:49 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSEF-0007fO-8L; Wed, 15 Mar 2023 10:35:49 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FELT2O015062; Wed, 15 Mar 2023 14:35:36 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbfq8rcf0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:36 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FELQJj014914; Wed, 15 Mar 2023 14:35:36 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbfq8rcdc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:35 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN66ci015062; Wed, 15 Mar 2023 14:35:33 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3pb29t0rgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:33 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZTp847251934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:29 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABF612004E; Wed, 15 Mar 2023 14:35:29 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51F9B20040; Wed, 15 Mar 2023 14:35:28 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:28 +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 : mime-version : content-transfer-encoding; s=pp1; bh=5U9DW9qO++BtSEyMWDOX/G2DdsQ2DmlQkqsLk17OEhw=; b=j1Km4k0ANFIWHsnJn5FYFSLQepCsUF1QO/iyUODd6PgQvSaacJ+8mJNX3NMkxkVgyyhC bsOUkpaBwoAltm2wiwUqLOcdoglJRpvwkJbvi1Benwges/TgyjRJHZqmmW+pxmmsIvnE 26y5C9TupQg6iZQaWR5V3KRWYhTmNbTC+MMgDngc1gf1PeuMtL+KDevLTsNaO0xwefSJ ABqCiiWFPkNSIUOmkLBl/zFWw8bJHhNln9THZvsNsqbmVz+V8C+oLt4/BHcQuIxv8sO5 1KNrcQY6peiqQbB0tZTas1mRGgMLUy4bgDOSq0O9L/Cw/Kux3kTokOTCGJNFumxOghE1 Zg== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 16/17] tests/avocado: s390x cpu topology test dedicated CPU Date: Wed, 15 Mar 2023 15:35:01 +0100 Message-Id: <20230315143502.135750-17-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ufCC1_ULk_zyVcQfWvk9ABoeU2NVIdSL X-Proofpoint-GUID: y2XksO21LPDcONgDbh4AW9-R691IznU4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_08,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 adultscore=0 clxscore=1015 impostorscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150118 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; 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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678890978215100004 Content-Type: text/plain; charset="utf-8" A dedicated CPU in vertical polarization can only have a high entitlement. Let's check this. Signed-off-by: Pierre Morel --- tests/avocado/s390_topology.py | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py index c6ee46fb52..be1db67ff4 100644 --- a/tests/avocado/s390_topology.py +++ b/tests/avocado/s390_topology.py @@ -52,6 +52,7 @@ class S390CPUTopology(LinuxKernelTest): The polarization is changed on a request from the guest. """ timeout =3D 90 + skip_basis =3D False =20 =20 def check_topology(self, c, s, b, d, e, t): @@ -116,12 +117,14 @@ def system_init(self): exec_command_and_wait_for_pattern(self, '/bin/cat /sys/devices/system/cpu/dispatching', '0') =20 + @skipIf(skip_basis, 'skipping basis tests') def test_single(self): self.kernel_init() self.vm.launch() self.wait_for_console_pattern('no job control') self.check_topology(0, 0, 0, 0, 'horizontal', False) =20 + @skipIf(skip_basis, 'skipping basis tests') def test_default(self): """ This test checks the implicite topology. @@ -147,6 +150,7 @@ def test_default(self): self.check_topology(11, 2, 1, 0, 'horizontal', False) self.check_topology(12, 0, 0, 1, 'horizontal', False) =20 + @skipIf(skip_basis, 'skipping basis tests') def test_move(self): """ This test checks the topology modification by moving a CPU @@ -167,6 +171,7 @@ def test_move(self): self.assertEqual(res['return'], {}) self.check_topology(0, 2, 0, 0, 'horizontal', False) =20 + @skipIf(skip_basis, 'skipping basis tests') def test_hotplug(self): """ This test verifies that a CPU defined with '-device' command line @@ -184,6 +189,7 @@ def test_hotplug(self): =20 self.check_topology(10, 2, 1, 0, 'horizontal', False) =20 + @skipIf(skip_basis, 'skipping basis tests') def test_hotplug_full(self): """ This test verifies that a hotplugged fully defined with '-device' @@ -202,6 +208,7 @@ def test_hotplug_full(self): self.wait_for_console_pattern('no job control') self.check_topology(1, 1, 1, 1, 'horizontal', False) =20 + @skipIf(skip_basis, 'skipping basis tests') def test_polarisation(self): """ This test verifies that QEMU modifies the entitlement change after @@ -231,7 +238,7 @@ def test_polarisation(self): =20 self.check_topology(0, 0, 0, 0, 'horizontal', False) =20 - def test_set_cpu_topology_entitlement(self): + def test_entitlement(self): """ This test verifies that QEMU modifies the polarization after a guest request. @@ -286,3 +293,37 @@ def test_set_cpu_topology_entitlement(self): self.check_topology(1, 0, 0, 0, 'horizontal', False) self.check_topology(2, 1, 0, 0, 'horizontal', False) self.check_topology(3, 1, 0, 0, 'horizontal', False) + + def test_dedicated(self): + """ + This test verifies that QEMU modifies the entitlement change corre= ctly + for a dedicated CPU after several guest polarization change reques= ts. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.launch() + self.wait_for_console_pattern('no job control') + + self.system_init() + + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 0, 'dedicated': True}) + self.assertEqual(res['return'], {}) + + self.check_topology(0, 0, 0, 0, 'horizontal', True) + + exec_command(self, 'echo 1 > /sys/devices/system/cpu/dispatching') + time.sleep(0.2) + exec_command_and_wait_for_pattern(self, + '/bin/cat /sys/devices/system/cpu/dispatching', '1') + + self.check_topology(0, 0, 0, 0, 'high', True) + + exec_command(self, 'echo 0 > /sys/devices/system/cpu/dispatching') + time.sleep(0.2) + exec_command_and_wait_for_pattern(self, + '/bin/cat /sys/devices/system/cpu/dispatching', '0') + + self.check_topology(0, 0, 0, 0, 'horizontal', True) --=20 2.31.1 From nobody Sun May 5 01:53:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1678891107; cv=none; d=zohomail.com; s=zohoarc; b=WrgIoWM5D4KdgohzYDp/OJ2glBQOC65qqIHVIMioGgEMyg1CB3eQEIlYCrJmp+jVn+bJC9LCzP1XjoSUrM4Xnq0vVXd/JFZqIO+4/zxulO85rq9SDpZw4wGZ7AsJbAdXCskHZCkZG+zX308HeP7rcDeVDKjs64z9+whFBZUxods= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678891107; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WmJdsdGH5oA91Fqg46aqUbc069QFnp/WV2vlMk3h8h4=; b=OdU3CckCwXH5vYeMH4g4qWnmXQrkJlYuyQxBXJ3mI/ONKcvy+lnrRMwkHujzIhCDa6l4KBxSKD3vTWoQr4Po5nyV3M2U2HPnc1XP3e8+/H2Nch/DSL4vos+xwWyJR/QtiQy5cLYJ0myREdzUH+E5MgsuxyHBpV+hdSrIDtsg4w0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678891107497755.0729214481244; Wed, 15 Mar 2023 07:38:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcSEH-0004pP-ND; Wed, 15 Mar 2023 10:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcSEA-0004d0-7T; Wed, 15 Mar 2023 10:35:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] 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 1pcSE8-0007cn-Jv; Wed, 15 Mar 2023 10:35:41 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32FDt0gi022785; Wed, 15 Mar 2023 14:35:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbfavh7qf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:37 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32FDuhUr030910; Wed, 15 Mar 2023 14:35:36 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pbfavh7pd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:36 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32EN6QwS022764; Wed, 15 Mar 2023 14:35:34 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3pb29t8rg7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Mar 2023 14:35:34 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32FEZV3d41026286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Mar 2023 14:35:31 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D4052004B; Wed, 15 Mar 2023 14:35:31 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C899620040; Wed, 15 Mar 2023 14:35:29 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.95.209]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Mar 2023 14:35:29 +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 : mime-version : content-transfer-encoding; s=pp1; bh=WmJdsdGH5oA91Fqg46aqUbc069QFnp/WV2vlMk3h8h4=; b=KUcwq52/J+6cPBPFzljSkTl7Azn3Inq6uaoBgJvCxDhvx9me94mtHGi4WwMTS8M6py0d ha5uXHVr3ECSY48rs3EHJXXnAXYUYWV2CwSOoZSxQWlsalDJz7upOQxL5MGJsjhr5d9I 5dyE2oOJzT9GV9xzlZueRvOz/FfoBJMhTaUsfaO17vPn9/eVeSQd0CVdUQ4QX5mlmaSb ODDf5dz1wdlx7xjvpQz3He6KqjS8m7HMii9OSmMOLxUc5dbwL6NOxXdqctc+uz32t62M 5Ppa/bBJLF7l2AKiJ4m5bEvJ9xhS5jj6ar3yh+5XJ8UuPECdUPCVLIga3ttYCAJaRUgx Ug== From: Pierre Morel To: qemu-s390x@nongnu.org Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com, pasic@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, mst@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org, ehabkost@redhat.com, marcel.apfelbaum@gmail.com, eblake@redhat.com, armbru@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, frankja@linux.ibm.com, berrange@redhat.com, clg@kaod.org Subject: [PATCH v18 17/17] tests/avocado: s390x cpu topology test socket full Date: Wed, 15 Mar 2023 15:35:02 +0100 Message-Id: <20230315143502.135750-18-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315143502.135750-1-pmorel@linux.ibm.com> References: <20230315143502.135750-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: NGkP-c20t6njFGhswzDL0gDrf9ZS1tj5 X-Proofpoint-ORIG-GUID: XnMO1adkOypOm2R_viqSzENBFGaGTZkK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-15_07,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2302240000 definitions=main-2303150118 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+importer2=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_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1678891108952100001 Content-Type: text/plain; charset="utf-8" This test verifies that QMP set-cpu-topology does not accept to overload a socket. Signed-off-by: Pierre Morel --- tests/avocado/s390_topology.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/avocado/s390_topology.py b/tests/avocado/s390_topology.py index be1db67ff4..e3e8259a0b 100644 --- a/tests/avocado/s390_topology.py +++ b/tests/avocado/s390_topology.py @@ -327,3 +327,30 @@ def test_dedicated(self): '/bin/cat /sys/devices/system/cpu/dispatching', '0') =20 self.check_topology(0, 0, 0, 0, 'horizontal', True) + + def test_socket_full(self): + """ + This test verifies that QEMU does not accept to overload a socket. + The socket-id 0 on book-id 0 already contains CPUs 0 and 1 and can + not accept any new CPU while socket-id 0 on book-id 1 is free. + + :avocado: tags=3Darch:s390x + :avocado: tags=3Dmachine:s390-ccw-virtio + """ + self.kernel_init() + self.vm.add_args('-smp', + '1,drawers=3D2,books=3D2,sockets=3D3,cores=3D2,ma= xcpus=3D24') + self.vm.add_args('-device', 'z14-s390x-cpu,core-id=3D1') + self.vm.add_args('-device', 'z14-s390x-cpu,core-id=3D2') + self.vm.launch() + self.wait_for_console_pattern('no job control') + + self.system_init() + + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 2, 'socket-id': 0, 'book-id': 0}) + self.assertEqual(res['error']['class'], 'GenericError') + + res =3D self.vm.qmp('set-cpu-topology', + {'core-id': 2, 'socket-id': 0, 'book-id': 1}) + self.assertEqual(res['return'], {}) --=20 2.31.1