From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655733803; cv=none; d=zohomail.com; s=zohoarc; b=ahVQ0d+v9xF/qr3Eus0VorJ3pX6hfqr/FF90f7Mpn3EgH+OdIiBspZu280mn1wXbsc3X/Jq4jzkpszRlCqpYa2WMxWzD8SDTdpR71moujLJkQEbykdTYB1vHw0LkbonnY2vLuPno2lh7HUVaJoI8gatGf1hvbD+RX429IMM3BV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655733803; 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=5YoWqvZJzhkWFO2eqf21yfC8nT5YR3vvQBjB93nkXP4=; b=J7E2rNRMNdjqOggDxhTKwg6k/G/q2shRilSm4GQvtaT8+kONZyrGfYzszvY5c/WTatDskn1mVBCD7t7OC8mM7x7K+HFekJ9vOuDQ4FTZCz34G1WxfdF2SeaaEfKFdbDdhAmH2so5PIeiBWKa8L/l8xjZJxlCdmwSkSnTEnhatWY= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165573380322587.66443346465326; Mon, 20 Jun 2022 07:03:23 -0700 (PDT) Received: from localhost ([::1]:42500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3Hzt-0005nE-Im for importer@patchew.org; Mon, 20 Jun 2022 10:03:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwP-0002sB-EB; Mon, 20 Jun 2022 09:59:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwM-0005jI-6u; Mon, 20 Jun 2022 09:59:45 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KCHIS7000308; Mon, 20 Jun 2022 13:59:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrmhuatj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:38 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25KCSxj4008635; Mon, 20 Jun 2022 13:59:38 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrmhuasb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:37 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDp14T019009; Mon, 20 Jun 2022 13:59:35 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 3gs6b8t1mp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:35 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxV3c17564016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:31 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2F6E11C04C; Mon, 20 Jun 2022 13:59:31 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E10FF11C050; Mon, 20 Jun 2022 13:59:30 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:30 +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=5YoWqvZJzhkWFO2eqf21yfC8nT5YR3vvQBjB93nkXP4=; b=lYYwhj2niWgq8N9HX/Ofy8L3UffyVLfYRo760ch/QDQtE/nOhkx207bb69Y9MxdZH6e+ DekwsBqwz9cC8qsUKWOetz/aVKCx27bD/RrgG9590gK9xrcivStLv+AyViO8wqS8x/le f+qnP9J/UN00NKe7hdrWeGGMo9f7PS1P2I/mISBuiVdIyUXGFbcapWfqPw6pU6xYidTZ +fR/EcU9GDlsx/HdmPorboaY6g0o4ej4B4F7pq1P3AwV7gm1MXnCwi5TX1uCx3u07Qxu F2WFUGerfEpGZc0/K0dNYDP4rTzWKTucNPSkvjBdJ8B3s+tG2zmymG09JgT9eW4J9d38 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, frankja@linux.ibm.com Subject: [PATCH v8 01/12] Update Linux Headers Date: Mon, 20 Jun 2022 16:03:41 +0200 Message-Id: <20220620140352.39398-2-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: p2AZWdvDdde9i9VTG30-vqgIH4RszMkS X-Proofpoint-ORIG-GUID: cogrF6BUXcyXkPvfDu2cQRa5RX_NlwN1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=842 suspectscore=0 malwarescore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655733805295100005 Content-Type: text/plain; charset="utf-8" This does not belong to the serie. It is only there to facilitate review with the coresponding linux series: [PATCH v10 0/3] s390x: KVM: CPU Topology Signed-off-by: Pierre Morel --- linux-headers/asm-s390/kvm.h | 9 +++++++++ linux-headers/linux/kvm.h | 1 + 2 files changed, 10 insertions(+) diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index f053b8304a..2bad030b8c 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req { #define KVM_S390_VM_CRYPTO 2 #define KVM_S390_VM_CPU_MODEL 3 #define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_CPU_TOPOLOGY 5 =20 /* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0 @@ -171,6 +172,14 @@ struct kvm_s390_vm_cpu_subfunc { #define KVM_S390_VM_MIGRATION_START 1 #define KVM_S390_VM_MIGRATION_STATUS 2 =20 +/* kvm attributes for cpu topology */ +#define KVM_S390_VM_CPU_TOPO_MTR_CLEAR 0 +#define KVM_S390_VM_CPU_TOPO_MTR_SET 1 + +struct kvm_s390_cpu_topology { + __u16 mtcr; +}; + /* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs { /* general purpose regs for s390 */ diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 0d05d02ee4..83f7a49a30 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1150,6 +1150,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_DISABLE_QUIRKS2 213 /* #define KVM_CAP_VM_TSC_CONTROL 214 */ #define KVM_CAP_SYSTEM_EVENT_DATA 215 +#define KVM_CAP_S390_CPU_TOPOLOGY 217 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734207; cv=none; d=zohomail.com; s=zohoarc; b=iRveL3NBNFDYJCGJtK5feDSX0aWarALFUEKfWriEuqi/kA/dL/81Kyv+2n9ZvtqcoqZAtpr3PofBhLZh7MOU7T8oq5bQIIVITThuCSoc7k1CXwF5IO1XKh2AI1RdmSxqaxwcTMNat0WZ+62EdTFB6vNvl2Q1E7BfJZxpDk3i4JI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734207; 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=L48e8gu5rvTN3WUl6i56mZp5uXSVms65XKcm1X1jC9o=; b=CqNeCONSwbYOrEKwTZgtWd6d6F2xBnUqRmk8sScLfwFOG1ySXexh9UpDdNZKs8cyeqRxIox3NnVkckDAu9Ipqir7atdxELr6SwsVU2rTb4YkILtVCnJqiqerdqHadNy6dN8UWH+qepzmiHomuBp+O3ZPDiCDsT97um5060Jxvzc= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734207140752.6687270423529; Mon, 20 Jun 2022 07:10:07 -0700 (PDT) Received: from localhost ([::1]:56922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I6Q-00076k-15 for importer@patchew.org; Mon, 20 Jun 2022 10:10:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwQ-0002u8-CZ; Mon, 20 Jun 2022 09:59:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:1372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwM-0005jS-I1; Mon, 20 Jun 2022 09:59:46 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KCN4LQ017085; Mon, 20 Jun 2022 13:59:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrmhuau2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:39 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25KDUEGK011453; Mon, 20 Jun 2022 13:59:39 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 3gsrmhuasv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:38 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDpJfk027989; Mon, 20 Jun 2022 13:59:36 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04fra.de.ibm.com with ESMTP id 3gs6b8t221-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:36 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxW5X22282536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:32 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A16AB11C04A; Mon, 20 Jun 2022 13:59:32 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C637011C050; Mon, 20 Jun 2022 13:59:31 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:31 +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=L48e8gu5rvTN3WUl6i56mZp5uXSVms65XKcm1X1jC9o=; b=PvsQKY9p4/9tZJxF3KWLaiGSeiFoj4AAWmIJ2vG/muwV9oa4QVDz0Ud4Zykqmz1NuXDw iIT9Cz6PSD+kXalX0go9LBrMYHTzZZgZcd2pvh35LGd2B8u74KaJGMCtiHJ7wzOBCaUS 1TCVvF2aebV0+cmvpk37UeOWCUODmhlnSyVNri7/RofHpuvRyBSLDMdOjRi/dx+wv1cN gaUKYuzStNgL2V22v0R2MPZX5bfeTQ65Y3QEZZoFX2fVQWRDBXMzYRR3g6Ikm2u+A8O8 ropZ5+DAEVWQfplJvOp95xe7wPDqOsG77dbo9z5cR5fwE95nYlvaoDOhPbHMpY+Oztc8 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, frankja@linux.ibm.com Subject: [PATCH v8 02/12] s390x/cpu_topology: CPU topology objects and structures Date: Mon, 20 Jun 2022 16:03:42 +0200 Message-Id: <20220620140352.39398-3-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7CCaYZmD27kqNYQQbuwSl10Dgxe3KHeE X-Proofpoint-ORIG-GUID: 8UpLF-GhmIXX5j17jpYlmSA3Y9YsI_zk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734208438100001 Content-Type: text/plain; charset="utf-8" We use new objects to have a dynamic administration of the CPU topology. The highest level object in this implementation is the s390 book and in this first implementation of CPU topology for S390 we have a single book. The book is built as a SYSBUS bridge during the CPU initialization. Other objects, sockets and core will be built after the parsing of the QEMU -smp argument. Every object under this single book will be build dynamically immediately after a CPU has be realized if it is needed. The CPU will fill the sockets once after the other, according to the number of core per socket defined during the smp parsing. Each CPU inside a socket will be represented by a bit in a 64bit unsigned long. Set on plug and clear on unplug of a CPU. For the S390 CPU topology, thread and cores are merged into topology cores and the number of topology cores is the multiplication of cores by the numbers of threads. Signed-off-by: Pierre Morel --- hw/s390x/cpu-topology.c | 391 ++++++++++++++++++++++++++++++++ hw/s390x/meson.build | 1 + hw/s390x/s390-virtio-ccw.c | 6 + include/hw/s390x/cpu-topology.h | 74 ++++++ target/s390x/cpu.h | 47 ++++ 5 files changed, 519 insertions(+) create mode 100644 hw/s390x/cpu-topology.c create mode 100644 include/hw/s390x/cpu-topology.h diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c new file mode 100644 index 0000000000..0fd6f08084 --- /dev/null +++ b/hw/s390x/cpu-topology.c @@ -0,0 +1,391 @@ +/* + * CPU Topology + * + * Copyright 2022 IBM Corp. + * 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/sysbus.h" +#include "hw/s390x/cpu-topology.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" + +/* + * s390_create_cores: + * @ms: Machine state + * @socket: the socket on which to create the core set + * @origin: the origin offset of the first core of the set + * @errp: Error pointer + * + * returns a pointer to the created S390TopologyCores structure + * + * On error: return NULL + */ +static S390TopologyCores *s390_create_cores(MachineState *ms, + S390TopologySocket *socket, + int origin, Error **errp) +{ + DeviceState *dev; + S390TopologyCores *cores; + + if (socket->bus->num_children >=3D ms->smp.cores * ms->smp.threads) { + error_setg(errp, "Unable to create more cores."); + return NULL; + } + + dev =3D qdev_new(TYPE_S390_TOPOLOGY_CORES); + qdev_realize_and_unref(dev, socket->bus, &error_fatal); + + cores =3D S390_TOPOLOGY_CORES(dev); + cores->origin =3D origin; + socket->cnt +=3D 1; + + return cores; +} + +/* + * s390_create_socket: + * @ms: Machine state + * @book: the book on which to create the socket + * @id: the socket id + * @errp: Error pointer + * + * returns a pointer to the created S390TopologySocket structure + * + * On error: return NULL + */ +static S390TopologySocket *s390_create_socket(MachineState *ms, + S390TopologyBook *book, + int id, Error **errp) +{ + DeviceState *dev; + S390TopologySocket *socket; + + if (book->bus->num_children >=3D ms->smp.sockets) { + error_setg(errp, "Unable to create more sockets."); + return NULL; + } + + dev =3D qdev_new(TYPE_S390_TOPOLOGY_SOCKET); + qdev_realize_and_unref(dev, book->bus, &error_fatal); + + socket =3D S390_TOPOLOGY_SOCKET(dev); + socket->socket_id =3D id; + book->cnt++; + + return socket; +} + +/* + * s390_get_cores: + * @ms: Machine state + * @socket: the socket to search into + * @origin: the origin specified for the S390TopologyCores + * @errp: Error pointer + * + * returns a pointer to a S390TopologyCores structure within a socket havi= ng + * the specified origin. + * First search if the socket is already containing the S390TopologyCores + * structure and if not create one with this origin. + */ +static S390TopologyCores *s390_get_cores(MachineState *ms, + S390TopologySocket *socket, + int origin, Error **errp) +{ + S390TopologyCores *cores; + BusChild *kid; + + QTAILQ_FOREACH(kid, &socket->bus->children, sibling) { + cores =3D S390_TOPOLOGY_CORES(kid->child); + if (cores->origin =3D=3D origin) { + return cores; + } + } + return s390_create_cores(ms, socket, origin, errp); +} + +/* + * s390_get_socket: + * @ms: Machine state + * @book: The book to search into + * @socket_id: the identifier of the socket to search for + * @errp: Error pointer + * + * returns a pointer to a S390TopologySocket structure within a book having + * the specified socket_id. + * First search if the book is already containing the S390TopologySocket + * structure and if not create one with this socket_id. + */ +static S390TopologySocket *s390_get_socket(MachineState *ms, + S390TopologyBook *book, + int socket_id, Error **errp) +{ + S390TopologySocket *socket; + BusChild *kid; + + QTAILQ_FOREACH(kid, &book->bus->children, sibling) { + socket =3D S390_TOPOLOGY_SOCKET(kid->child); + if (socket->socket_id =3D=3D socket_id) { + return socket; + } + } + return s390_create_socket(ms, book, socket_id, errp); +} + +/* + * s390_topology_new_cpu: + * @core_id: the core ID is machine wide + * + * We have a single book returned by s390_get_topology(), + * then we build the hierarchy on demand. + * Note that we do not destroy the hierarchy on error creating + * an entry in the topology, we just keep it empty. + * We do not need to worry about not finding a topology level + * entry this would have been caught during smp parsing. + */ +bool s390_topology_new_cpu(MachineState *ms, int core_id, Error **errp) +{ + S390TopologyBook *book; + S390TopologySocket *socket; + S390TopologyCores *cores; + int nb_cores_per_socket; + int origin, bit; + + book =3D s390_get_topology(); + + nb_cores_per_socket =3D ms->smp.cores * ms->smp.threads; + + socket =3D s390_get_socket(ms, book, core_id / nb_cores_per_socket, er= rp); + if (!socket) { + return false; + } + + /* + * At the core level, each CPU is represented by a bit in a 64bit + * unsigned long. Set on plug and clear on unplug of a CPU. + * The firmware assume that all CPU in the core description have the s= ame + * type, polarization and are all dedicated or shared. + * In the case a socket contains CPU with different type, polarization + * or dedication then they will be defined in different CPU containers. + * Currently we assume all CPU are identical and the only reason to ha= ve + * several S390TopologyCores inside a socket is to have more than 64 C= PUs + * in that case the origin field, representing the offset of the first= CPU + * in the CPU container allows to represent up to the maximal number of + * CPU inside several CPU containers inside the socket container. + */ + origin =3D 64 * (core_id / 64); + + cores =3D s390_get_cores(ms, socket, origin, errp); + if (!cores) { + return false; + } + + bit =3D 63 - (core_id - origin); + set_bit(bit, &cores->mask); + cores->origin =3D origin; + + return true; +} + +/* + * Setting the first topology: 1 book, 1 socket + * This is enough for 64 cores if the topology is flat (single socket) + */ +void s390_topology_setup(MachineState *ms) +{ + DeviceState *dev; + + /* Create BOOK bridge device */ + dev =3D qdev_new(TYPE_S390_TOPOLOGY_BOOK); + object_property_add_child(qdev_get_machine(), + TYPE_S390_TOPOLOGY_BOOK, OBJECT(dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); +} + +S390TopologyBook *s390_get_topology(void) +{ + static S390TopologyBook *book; + + if (!book) { + book =3D S390_TOPOLOGY_BOOK( + object_resolve_path(TYPE_S390_TOPOLOGY_BOOK, NULL)); + assert(book !=3D NULL); + } + + return book; +} + +/* --- CORES Definitions --- */ + +static Property s390_topology_cores_properties[] =3D { + DEFINE_PROP_BOOL("dedicated", S390TopologyCores, dedicated, false), + DEFINE_PROP_UINT8("polarity", S390TopologyCores, polarity, + S390_TOPOLOGY_POLARITY_H), + DEFINE_PROP_UINT8("cputype", S390TopologyCores, cputype, + S390_TOPOLOGY_CPU_TYPE), + DEFINE_PROP_UINT16("origin", S390TopologyCores, origin, 0), + DEFINE_PROP_UINT64("mask", S390TopologyCores, mask, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void cpu_cores_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); + + device_class_set_props(dc, s390_topology_cores_properties); + hc->unplug =3D qdev_simple_device_unplug_cb; + dc->bus_type =3D TYPE_S390_TOPOLOGY_SOCKET_BUS; + dc->desc =3D "topology cpu entry"; +} + +static const TypeInfo cpu_cores_info =3D { + .name =3D TYPE_S390_TOPOLOGY_CORES, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(S390TopologyCores), + .class_init =3D cpu_cores_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { } + } +}; + +static char *socket_bus_get_dev_path(DeviceState *dev) +{ + S390TopologySocket *socket =3D S390_TOPOLOGY_SOCKET(dev); + DeviceState *book =3D dev->parent_bus->parent; + char *id =3D qdev_get_dev_path(book); + char *ret; + + if (id) { + ret =3D g_strdup_printf("%s:%02d", id, socket->socket_id); + g_free(id); + } else { + ret =3D g_strdup_printf("_:%02d", socket->socket_id); + } + + return ret; +} + +static void socket_bus_class_init(ObjectClass *oc, void *data) +{ + BusClass *k =3D BUS_CLASS(oc); + + k->get_dev_path =3D socket_bus_get_dev_path; + k->max_dev =3D S390_MAX_SOCKETS; +} + +static const TypeInfo socket_bus_info =3D { + .name =3D TYPE_S390_TOPOLOGY_SOCKET_BUS, + .parent =3D TYPE_BUS, + .instance_size =3D 0, + .class_init =3D socket_bus_class_init, +}; + +static void s390_socket_device_realize(DeviceState *dev, Error **errp) +{ + S390TopologySocket *socket =3D S390_TOPOLOGY_SOCKET(dev); + BusState *bus; + + bus =3D qbus_new(TYPE_S390_TOPOLOGY_SOCKET_BUS, dev, + TYPE_S390_TOPOLOGY_SOCKET_BUS); + qbus_set_hotplug_handler(bus, OBJECT(dev)); + socket->bus =3D bus; +} + +static void socket_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); + + hc->unplug =3D qdev_simple_device_unplug_cb; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->bus_type =3D TYPE_S390_TOPOLOGY_BOOK_BUS; + dc->realize =3D s390_socket_device_realize; + dc->desc =3D "topology socket"; +} + +static const TypeInfo socket_info =3D { + .name =3D TYPE_S390_TOPOLOGY_SOCKET, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(S390TopologySocket), + .class_init =3D socket_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { } + } +}; + +static char *book_bus_get_dev_path(DeviceState *dev) +{ + return g_strdup("00"); +} + +static void book_bus_class_init(ObjectClass *oc, void *data) +{ + BusClass *k =3D BUS_CLASS(oc); + + k->get_dev_path =3D book_bus_get_dev_path; + k->max_dev =3D S390_MAX_BOOKS; +} + +static const TypeInfo book_bus_info =3D { + .name =3D TYPE_S390_TOPOLOGY_BOOK_BUS, + .parent =3D TYPE_BUS, + .instance_size =3D 0, + .class_init =3D book_bus_class_init, +}; + +static void s390_book_device_realize(DeviceState *dev, Error **errp) +{ + S390TopologyBook *book =3D S390_TOPOLOGY_BOOK(dev); + BusState *bus; + + bus =3D qbus_new(TYPE_S390_TOPOLOGY_BOOK_BUS, dev, + TYPE_S390_TOPOLOGY_BOOK_BUS); + qbus_set_hotplug_handler(bus, OBJECT(dev)); + book->bus =3D bus; +} + +static void book_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); + + hc->unplug =3D qdev_simple_device_unplug_cb; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->realize =3D s390_book_device_realize; + dc->desc =3D "topology book"; +} + +static const TypeInfo book_info =3D { + .name =3D TYPE_S390_TOPOLOGY_BOOK, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(S390TopologyBook), + .class_init =3D book_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { } + } +}; + +static void topology_register(void) +{ + type_register_static(&cpu_cores_info); + type_register_static(&socket_bus_info); + type_register_static(&socket_info); + type_register_static(&book_bus_info); + type_register_static(&book_info); +} + +type_init(topology_register); diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build index feefe0717e..3592fa952b 100644 --- a/hw/s390x/meson.build +++ b/hw/s390x/meson.build @@ -2,6 +2,7 @@ s390x_ss =3D ss.source_set() s390x_ss.add(files( 'ap-bridge.c', 'ap-device.c', + 'cpu-topology.c', 'ccw-device.c', 'css-bridge.c', 'css.c', diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index cc3097bfee..a586875b24 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -43,6 +43,7 @@ #include "sysemu/sysemu.h" #include "hw/s390x/pv.h" #include "migration/blocker.h" +#include "hw/s390x/cpu-topology.h" =20 static Error *pv_mig_blocker; =20 @@ -89,6 +90,7 @@ static void s390_init_cpus(MachineState *machine) /* initialize possible_cpus */ mc->possible_cpu_arch_ids(machine); =20 + s390_topology_setup(machine); for (i =3D 0; i < machine->smp.cpus; i++) { s390x_new_cpu(machine->cpu_type, i, &error_fatal); } @@ -306,6 +308,10 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev, 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_topology_new_cpu(ms, cpu->env.core_id, errp)) { + return; + } + if (dev->hotplugged) { raise_irq_cpu_hotplug(); } diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h new file mode 100644 index 0000000000..beec61706c --- /dev/null +++ b/include/hw/s390x/cpu-topology.h @@ -0,0 +1,74 @@ +/* + * CPU Topology + * + * Copyright 2022 IBM Corp. + * + * 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 + +#include "hw/qdev-core.h" +#include "qom/object.h" + +#define S390_TOPOLOGY_CPU_TYPE 0x03 + +#define S390_TOPOLOGY_POLARITY_H 0x00 +#define S390_TOPOLOGY_POLARITY_VL 0x01 +#define S390_TOPOLOGY_POLARITY_VM 0x02 +#define S390_TOPOLOGY_POLARITY_VH 0x03 + +#define TYPE_S390_TOPOLOGY_CORES "topology cores" + /* + * Each CPU inside a socket will be represented by a bit in a 64bit + * unsigned long. Set on plug and clear on unplug of a CPU. + * All CPU inside a mask share the same dedicated, polarity and + * cputype values. + * The origin is the offset of the first CPU in a mask. + */ +struct S390TopologyCores { + DeviceState parent_obj; + int id; + bool dedicated; + uint8_t polarity; + uint8_t cputype; + uint16_t origin; + uint64_t mask; + int cnt; +}; +typedef struct S390TopologyCores S390TopologyCores; +OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyCores, S390_TOPOLOGY_CORES) + +#define TYPE_S390_TOPOLOGY_SOCKET "topology socket" +#define TYPE_S390_TOPOLOGY_SOCKET_BUS "socket-bus" +struct S390TopologySocket { + DeviceState parent_obj; + BusState *bus; + int socket_id; + int cnt; +}; +typedef struct S390TopologySocket S390TopologySocket; +OBJECT_DECLARE_SIMPLE_TYPE(S390TopologySocket, S390_TOPOLOGY_SOCKET) +#define S390_MAX_SOCKETS 4 + +#define TYPE_S390_TOPOLOGY_BOOK "topology book" +#define TYPE_S390_TOPOLOGY_BOOK_BUS "book-bus" +struct S390TopologyBook { + SysBusDevice parent_obj; + BusState *bus; + int book_id; + int cnt; +}; +typedef struct S390TopologyBook S390TopologyBook; +OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyBook, S390_TOPOLOGY_BOOK) +#define S390_MAX_BOOKS 1 + +S390TopologyBook *s390_init_topology(void); + +S390TopologyBook *s390_get_topology(void); +void s390_topology_setup(MachineState *ms); +bool s390_topology_new_cpu(MachineState *ms, int core_id, Error **errp); + +#endif diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7d6d01325b..216adfde26 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -565,6 +565,53 @@ typedef union SysIB { } SysIB; QEMU_BUILD_BUG_ON(sizeof(SysIB) !=3D 4096); =20 +/* CPU type Topology List Entry */ +typedef struct SysIBTl_cpu { + uint8_t nl; + uint8_t reserved0[3]; + uint8_t reserved1:5; + uint8_t dedicated:1; + uint8_t polarity:2; + uint8_t type; + uint16_t origin; + uint64_t mask; +} SysIBTl_cpu; +QEMU_BUILD_BUG_ON(sizeof(SysIBTl_cpu) !=3D 16); + +/* Container type Topology List Entry */ +typedef struct SysIBTl_container { + uint8_t nl; + uint8_t reserved[6]; + uint8_t id; +} QEMU_PACKED SysIBTl_container; +QEMU_BUILD_BUG_ON(sizeof(SysIBTl_container) !=3D 8); + +/* Generic Topology List Entry */ +typedef union SysIBTl_entry { + uint8_t nl; + SysIBTl_container container; + SysIBTl_cpu cpu; +} SysIBTl_entry; + +#define TOPOLOGY_NR_MAG 6 +#define TOPOLOGY_NR_MAG6 0 +#define TOPOLOGY_NR_MAG5 1 +#define TOPOLOGY_NR_MAG4 2 +#define TOPOLOGY_NR_MAG3 3 +#define TOPOLOGY_NR_MAG2 4 +#define TOPOLOGY_NR_MAG1 5 +/* Configuration topology */ +typedef struct SysIB_151x { + uint8_t res0[2]; + uint16_t length; + uint8_t mag[TOPOLOGY_NR_MAG]; + uint8_t res1; + uint8_t mnest; + uint32_t res2; + SysIBTl_entry tle[0]; +} SysIB_151x; +QEMU_BUILD_BUG_ON(sizeof(SysIB_151x) !=3D 16); + /* MMU defines */ #define ASCE_ORIGIN (~0xfffULL) /* segment table origin = */ #define ASCE_SUBSPACE 0x200 /* subspace group control = */ --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734085; cv=none; d=zohomail.com; s=zohoarc; b=j+w/91vDeE7rwOUu4e8veLM925zMKxJUDNqp1cSYKtYpSmmx+RZyibSPzKmnzQWNYFVq0+49syWgR0/GnX0U/XLfNVUasF/auM4XdNaybzMqIM75HJO9NRr4DiRahoSOYrHzrLwPf64LgM6xLR+4QEo0WbFiTA8ffwUYhHw8LQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734085; 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=5SBG0RNux8jmuMRl37DWb4HK2j1MpzzrJ+IzkrpR87o=; b=LCNj+alg8HkQWolvrPggD7LpTQTQixgtMdBCiKTFnfeJN1fbiWHsgp+zdYKMaiEg6TtSW/cbl6igouP7dWI89GL3E7lvyBy7PEz5+o9FK+hQANj/ZwhY5CqxBwm9mjAZ+MRTghTS/T+Y/tjFqBiEhHNX0lnAprg8xERDj2Ipn1M= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734085127565.2584222588729; Mon, 20 Jun 2022 07:08:05 -0700 (PDT) Received: from localhost ([::1]:50126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I4S-0002a0-3D for importer@patchew.org; Mon, 20 Jun 2022 10:08:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwP-0002sA-Du; Mon, 20 Jun 2022 09:59:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64560) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwM-0005jM-34; Mon, 20 Jun 2022 09:59:45 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KDZikZ015934; Mon, 20 Jun 2022 13:59:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrpfawsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:39 +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 25KDWuOH033449; Mon, 20 Jun 2022 13:59:39 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 3gsrpfaws3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:38 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDpOOK023580; Mon, 20 Jun 2022 13:59:36 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3gs6b8tkne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:36 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxXra13304204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:33 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A70711C04A; Mon, 20 Jun 2022 13:59:33 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B363E11C04C; Mon, 20 Jun 2022 13:59:32 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:32 +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=5SBG0RNux8jmuMRl37DWb4HK2j1MpzzrJ+IzkrpR87o=; b=G1fO7AruLCCSOQx9dW32lJM1ieYrTKQS03Q49gJAot2P+bj2fKj+CzGG4MRER+AM5fAN HWAf50Kma9XptKEgpglMnXy++Vz+mrFBR586R7Ko33GYbqGU4rBqGylAuYcsvXXiX2EZ mnKLbDMfO28gK9hQ6prbAoymXZFF8fbIZDcHCkvR2Osjwf9rQCh8HpCt0pY69SfKKZSX Kmh5SMMv+yIjxvmUCEGFDg/AXSRLlZYXla+ePIj5Wkh/xLCMsByw0jMVEOFag7WXe1Ab VXrSvzwP61t0lxNpA6DEITQS+zkRstch3yeF64bYtwptFQSlgZ6lBx85GsNktGbBrDpK sA== 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, frankja@linux.ibm.com Subject: [PATCH v8 03/12] s390x/cpu_topology: implementating Store Topology System Information Date: Mon, 20 Jun 2022 16:03:43 +0200 Message-Id: <20220620140352.39398-4-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _nUs10jpSvAZ7WgCnLOZXxb2pzN3mJ0q X-Proofpoint-GUID: Q8eHH5yIwEXFVvDdCzlsi9MkkjgCZvhP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734085457100001 Content-Type: text/plain; charset="utf-8" The handling of STSI is enhanced with the interception of the function code 15 for storing CPU topology. Using the objects built during the plugging of CPU, we build the SYSIB 15_1_x structures. With this patch the maximum MNEST level is 2, this is also the only level allowed and only SYSIB 15_1_2 will be built. Signed-off-by: Pierre Morel --- target/s390x/cpu.h | 2 + target/s390x/cpu_topology.c | 112 ++++++++++++++++++++++++++++++++++++ target/s390x/kvm/kvm.c | 5 ++ target/s390x/meson.build | 1 + 4 files changed, 120 insertions(+) create mode 100644 target/s390x/cpu_topology.c diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 216adfde26..9d48087b71 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -890,4 +890,6 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); =20 #include "exec/cpu-all.h" =20 +void insert_stsi_15_1_x(S390CPU *cpu, int sel2, __u64 addr, uint8_t ar); + #endif diff --git a/target/s390x/cpu_topology.c b/target/s390x/cpu_topology.c new file mode 100644 index 0000000000..9f656d7e51 --- /dev/null +++ b/target/s390x/cpu_topology.c @@ -0,0 +1,112 @@ +/* + * 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/cpu-topology.h" + +static int stsi_15_container(void *p, int nl, int id) +{ + SysIBTl_container *tle =3D (SysIBTl_container *)p; + + tle->nl =3D nl; + tle->id =3D id; + + return sizeof(*tle); +} + +static int stsi_15_cpus(void *p, S390TopologyCores *cd) +{ + SysIBTl_cpu *tle =3D (SysIBTl_cpu *)p; + + tle->nl =3D 0; + tle->dedicated =3D cd->dedicated; + tle->polarity =3D cd->polarity; + tle->type =3D cd->cputype; + tle->origin =3D be16_to_cpu(cd->origin); + tle->mask =3D be64_to_cpu(cd->mask); + + return sizeof(*tle); +} + +static int set_socket(const MachineState *ms, void *p, + S390TopologySocket *socket) +{ + BusChild *kid; + int l, len =3D 0; + + len +=3D stsi_15_container(p, 1, socket->socket_id); + p +=3D len; + + QTAILQ_FOREACH_REVERSE(kid, &socket->bus->children, sibling) { + l =3D stsi_15_cpus(p, S390_TOPOLOGY_CORES(kid->child)); + p +=3D l; + len +=3D l; + } + return len; +} + +static void setup_stsi(const MachineState *ms, void *p, int level) +{ + S390TopologyBook *book; + SysIB_151x *sysib; + BusChild *kid; + int len, l; + + sysib =3D (SysIB_151x *)p; + sysib->mnest =3D level; + sysib->mag[TOPOLOGY_NR_MAG2] =3D ms->smp.sockets; + sysib->mag[TOPOLOGY_NR_MAG1] =3D ms->smp.cores * ms->smp.threads; + + book =3D s390_get_topology(); + len =3D sizeof(SysIB_151x); + p +=3D len; + + QTAILQ_FOREACH_REVERSE(kid, &book->bus->children, sibling) { + l =3D set_socket(ms, p, S390_TOPOLOGY_SOCKET(kid->child)); + p +=3D l; + len +=3D l; + } + + sysib->length =3D be16_to_cpu(len); +} + +void insert_stsi_15_1_x(S390CPU *cpu, int sel2, __u64 addr, uint8_t ar) +{ + const MachineState *machine =3D MACHINE(qdev_get_machine()); + void *p; + int ret; + + /* + * Until the SCLP STSI Facility reporting the MNEST value is used, + * a sel2 value of 2 is the only value allowed in STSI 15.1.x. + */ + if (sel2 !=3D 2) { + setcc(cpu, 3); + return; + } + + p =3D g_malloc0(TARGET_PAGE_SIZE); + + setup_stsi(machine, p, 2); + + if (s390_is_pv()) { + ret =3D s390_cpu_pv_mem_write(cpu, 0, p, TARGET_PAGE_SIZE); + } else { + ret =3D s390_cpu_virt_mem_write(cpu, addr, ar, p, TARGET_PAGE_SIZE= ); + } + + setcc(cpu, ret ? 3 : 0); + g_free(p); +} + diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 7bd8db0e7b..563bf5ac60 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -51,6 +51,7 @@ #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/s390-virtio-hcall.h" #include "hw/s390x/pv.h" +#include "hw/s390x/cpu-topology.h" =20 #ifndef DEBUG_KVM #define DEBUG_KVM 0 @@ -1918,6 +1919,10 @@ static int handle_stsi(S390CPU *cpu) /* Only sysib 3.2.2 needs post-handling for now. */ insert_stsi_3_2_2(cpu, run->s390_stsi.addr, run->s390_stsi.ar); return 0; + case 15: + insert_stsi_15_1_x(cpu, run->s390_stsi.sel2, run->s390_stsi.addr, + run->s390_stsi.ar); + return 0; default: return 0; } diff --git a/target/s390x/meson.build b/target/s390x/meson.build index 84c1402a6a..890ccfa789 100644 --- a/target/s390x/meson.build +++ b/target/s390x/meson.build @@ -29,6 +29,7 @@ s390x_softmmu_ss.add(files( 'sigp.c', 'cpu-sysemu.c', 'cpu_models_sysemu.c', + 'cpu_topology.c', )) =20 s390x_user_ss =3D ss.source_set() --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655733800; cv=none; d=zohomail.com; s=zohoarc; b=gRnM1GP8+gghdMyoHMnw9ZZZGyxJU3qVl+54yW2lKaFop/sQLRvwQ7lFww11gJzPFe489yT7eyGwa169IJ7d1stixMqQV5nKgatyHxP7pklRNv8MN+4iDZqjNuxRXWAqS6R2TPJdWNATQWKaG/xKmt/7YZLz2CV3z6LvunK47iY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655733800; 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=B/8ia93HkNTN8qIyrvY3eaMv1Vkt2v/YBt1x45pOjcw=; b=gmnw2bRJ7itS+2Bg5tq9przjaNloqzOhr3nOmwWehW4mtlMmNlaRqhwqk7gAbzk6LoDSt4B+JSDnX+IOhCADjEQjYYRG1MKZK9rd2MHL7jm7bxAx7Ccwz26OLfsJfwJhG5WDpHuZaF4KkRJhXSGS1kn0kD+NDwohkJ3p2yJIOQI= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16557338005661014.5189381851512; Mon, 20 Jun 2022 07:03:20 -0700 (PDT) Received: from localhost ([::1]:42428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3Hzq-0005jT-IV for importer@patchew.org; Mon, 20 Jun 2022 10:03:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwN-0002rO-Vo; Mon, 20 Jun 2022 09:59:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:23080 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 1o3HwM-0005jO-0v; Mon, 20 Jun 2022 09:59:43 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KC7Qjs024159; Mon, 20 Jun 2022 13:59:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsr4kk70c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:40 +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 25KCHlhA002278; Mon, 20 Jun 2022 13:59:39 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 3gsr4kk6ym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:39 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDqOcc021346; Mon, 20 Jun 2022 13:59:37 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3gs6b92kq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:37 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxdZY25100578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:39 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E5DD11C04A; Mon, 20 Jun 2022 13:59:34 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D2C111C04C; Mon, 20 Jun 2022 13:59:33 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:33 +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=B/8ia93HkNTN8qIyrvY3eaMv1Vkt2v/YBt1x45pOjcw=; b=P1Dc8Ah6yJz8mNzUlPQwJcr8yHbFdF0fo6BUK/dfb8FimuRM+sgYYjFeoxORYCq/Vaox EQ64vF6DCpZIlU+A9rNeDJPq0mU2yK602SxsBY4EJlWq658XlYY2iJr4YJ9/RDpbX3Hc Mm4FuIM/1POo0ixGVt+aHbTmwzPKBdkTjVusNKmIXMEYJL3um9v2t2F/ykF13sPFH2aQ wnqbR3+iRtCf/J6H3uepM4tngxAmbhapHieGRNjoc+dbH8N2DHCq05J6pe8wjQVs4RyC UEwATwjbYkx70DgI6etq93CBGxiPDIcEB1xzRhrqFkS1TkzmIpTIebNt3ksUNlaGmwxE 8Q== 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, frankja@linux.ibm.com Subject: [PATCH v8 04/12] s390x/cpu_topology: Adding books to CPU topology Date: Mon, 20 Jun 2022 16:03:44 +0200 Message-Id: <20220620140352.39398-5-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: P3UmTeVH0avHTZlk6apiFD-Ad3zIgV3h X-Proofpoint-GUID: _2kTubkiyqR5RBCxh4kMOc-ulK6j4CZY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 spamscore=0 mlxscore=0 phishscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655733801337100001 Content-Type: text/plain; charset="utf-8" S390 CPU topology may have up to 5 topology containers. The first container above the cores is level 2, the sockets. We introduce here the books, book is the level containing sockets. Let's add books, level3, containers to the CPU topology. Signed-off-by: Pierre Morel --- hw/core/machine-smp.c | 29 ++++++++++++++++++++++------- hw/core/machine.c | 2 ++ hw/s390x/s390-virtio-ccw.c | 1 + include/hw/boards.h | 4 ++++ qapi/machine.json | 7 ++++++- qemu-options.hx | 5 +++-- softmmu/vl.c | 3 +++ 7 files changed, 41 insertions(+), 10 deletions(-) diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index b39ed21e65..d7aa39d540 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -31,6 +31,10 @@ 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.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 +77,7 @@ void machine_parse_smp_config(MachineState *ms, { MachineClass *mc =3D MACHINE_GET_CLASS(ms); unsigned cpus =3D config->has_cpus ? config->cpus : 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 +90,7 @@ 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_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 +117,13 @@ 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; + /* 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 +137,35 @@ 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 / (books * dies * clusters * cores * t= hreads); } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * dies * clusters * threads); + cores =3D maxcpus / (books * sockets * dies * clusters * t= hreads); } } 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 / (books * sockets * dies * clusters * t= hreads); } else if (sockets =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (dies * clusters * cores * threads); + sockets =3D maxcpus / (books * dies * clusters * cores * t= hreads); } } =20 /* try to calculate omitted threads at last */ if (threads =3D=3D 0) { - threads =3D maxcpus / (sockets * dies * clusters * cores); + threads =3D maxcpus / (books * sockets * dies * clusters * cor= es); } } =20 - maxcpus =3D maxcpus > 0 ? maxcpus : sockets * dies * clusters * cores = * threads; + maxcpus =3D maxcpus > 0 ? maxcpus : books * sockets * dies * + clusters * cores * threads; cpus =3D cpus > 0 ? cpus : maxcpus; =20 ms->smp.cpus =3D cpus; + ms->smp.books =3D books; ms->smp.sockets =3D sockets; ms->smp.dies =3D dies; ms->smp.clusters =3D clusters; @@ -159,7 +174,7 @@ void machine_parse_smp_config(MachineState *ms, ms->smp.max_cpus =3D maxcpus; =20 /* sanity-check of the computed topology */ - if (sockets * dies * clusters * cores * threads !=3D maxcpus) { + if (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 a673302cce..8861f58d23 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -821,6 +821,7 @@ 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_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, @@ -1087,6 +1088,7 @@ 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.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 a586875b24..ace65164d8 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -619,6 +619,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) hc->unplug_request =3D s390_machine_device_unplug_request; nc->nmi_monitor_handler =3D s390_nmi; mc->default_ram_id =3D "s390.ram"; + mc->smp_props.books_supported =3D true; } =20 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) diff --git a/include/hw/boards.h b/include/hw/boards.h index d94edcef28..2b44f50b6e 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -130,11 +130,13 @@ typedef struct { * @prefer_sockets - whether sockets are preferred over cores in smp parsi= ng * @dies_supported - whether dies are supported by the machine * @clusters_supported - whether clusters are supported by the machine + * @books_supported - whether books are supported by the machine */ typedef struct { bool prefer_sockets; bool dies_supported; bool clusters_supported; + bool books_supported; } SMPCompatProps; =20 /** @@ -299,6 +301,7 @@ typedef struct DeviceMemoryState { /** * CpuTopology: * @cpus: the number of present logical processors on the machine + * @books: the number of books on the machine * @sockets: the number of sockets on the machine * @dies: the number of dies in one socket * @clusters: the number of clusters in one die @@ -308,6 +311,7 @@ typedef struct DeviceMemoryState { */ typedef struct CpuTopology { unsigned int cpus; + unsigned int books; unsigned int sockets; unsigned int dies; unsigned int clusters; diff --git a/qapi/machine.json b/qapi/machine.json index 6afd1936b0..f838b0c51f 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -900,7 +900,8 @@ # 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 +# @book-id: book number within node/board the CPU belongs to +# @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 @@ -916,6 +917,7 @@ ## { 'struct': 'CpuInstanceProperties', 'data': { '*node-id': 'int', + '*book-id': 'int', '*socket-id': 'int', '*die-id': 'int', '*cluster-id': 'int', @@ -1465,6 +1467,8 @@ # # @cpus: number of virtual CPUs in the virtual machine # +# @books: number of books in the CPU topology +# # @sockets: number of sockets in the CPU topology # # @dies: number of dies per socket in the CPU topology @@ -1481,6 +1485,7 @@ ## { 'struct': 'SMPConfiguration', 'data': { '*cpus': 'int', + '*books': 'int', '*sockets': 'int', '*dies': 'int', '*clusters': 'int', diff --git a/qemu-options.hx b/qemu-options.hx index 377d22fbd8..9d72208f50 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -239,11 +239,12 @@ 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][,books=3Dbooks][,sockets=3Dsock= ets][,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" + " books=3D number of books on the machine board\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" diff --git a/softmmu/vl.c b/softmmu/vl.c index 54e920ada1..c13edd6948 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -726,6 +726,9 @@ static QemuOptsList qemu_smp_opts =3D { { .name =3D "cpus", .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "books", + .type =3D QEMU_OPT_NUMBER, }, { .name =3D "sockets", .type =3D QEMU_OPT_NUMBER, --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734115; cv=none; d=zohomail.com; s=zohoarc; b=W4D4ka5EJQFVyGW4k3wUlWQcKGz5ypngGH4WwtV4wWQiCaWkwPD27RKidCh0UB0nBundnm/lY7Ipbr1sRiyEjCifjxcpdR4PBP1xTZBDPxI67yAvqSwuqtsz2+ikgnxaHbRiM3PSWwHCcuR4OyGmsUcVq3RfefDqD8JrjPixWp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734115; 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=CZPWJPTcxFWpRspZVjIsT9QqXdcAmTeeMxF1ghqApZ4=; b=QaLJzEZDHD2t91XyN9DMTNoPD739p+vZ4rxHqOyWJxujSxUhUPNqEI5FLAUkZ4z44aHHONzZMPzFdAb5L3f1awYAeUPgas/ZZTW2WphnpFFBRDBsy685Zq0c2F5cD+O2Z7Msjh1u1AWQojPrtssiK4F40W5dzBTVbzFgQPnn9sY= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734115589255.87624874712287; Mon, 20 Jun 2022 07:08:35 -0700 (PDT) Received: from localhost ([::1]:50826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I4w-000349-88 for importer@patchew.org; Mon, 20 Jun 2022 10:08:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwQ-0002tL-2O; Mon, 20 Jun 2022 09:59:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:43414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwM-0005jY-Ie; Mon, 20 Jun 2022 09:59:45 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KCevkY023836; Mon, 20 Jun 2022 13:59:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrcjtsma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:40 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25KCxkS1024516; Mon, 20 Jun 2022 13:59:40 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 3gsrcjtskq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:40 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDpN16023576; Mon, 20 Jun 2022 13:59:38 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 3gs6b8tknf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDwrXb21823894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:58:53 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 536CF11C04A; Mon, 20 Jun 2022 13:59:35 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82F0411C04C; Mon, 20 Jun 2022 13:59:34 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:34 +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=CZPWJPTcxFWpRspZVjIsT9QqXdcAmTeeMxF1ghqApZ4=; b=dGM62NQUKl/+G5RysWymbLBYWNFCR5jKmYwk568f/CIMBpdgzwmYiTD7HiIXmkA7NvM4 /fgTJsnTV8PEa627+m8dP2uF6S2TEN5bOeLnPTOeMp325IcXsgxzHbGuNiewEyCVp62B Sq4YiOPpwkDZznGjnV9cjmML3vJNA9NbC1EyVYUiMRtf16knUZ06qtfXLiDC9yA99qbg eL24QId1EGMW6xdh93/neGui/NG/f9m3eY3fO7+qEVKbwXOASBKoMPZJZ5cmNZs71+yv qAmYLpXwLlg7FBsDhIPR6p8xVuX6PtCSB//AL/102wBQnl4ps5/Fv7vTR9XLd2PJAE3x sw== 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, frankja@linux.ibm.com Subject: [PATCH v8 05/12] s390x/cpu_topology: Adding books to STSI Date: Mon, 20 Jun 2022 16:03:45 +0200 Message-Id: <20220620140352.39398-6-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: JzNK1SM0p7NjkcklXvVeHbWKaxicCx-3 X-Proofpoint-GUID: g8LezQPYDgM5uKZiImQtrx3im_GRX0bP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734117776100003 Content-Type: text/plain; charset="utf-8" Let's add STSI support for the container level 3, books, and provide the information back to the guest. Signed-off-by: Pierre Morel --- hw/s390x/cpu-topology.c | 163 +++++++++++++++++++++++++++++--- include/hw/s390x/cpu-topology.h | 20 +++- include/hw/s390x/sclp.h | 1 + target/s390x/cpu_topology.c | 53 ++++++++--- 4 files changed, 210 insertions(+), 27 deletions(-) diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 0fd6f08084..eba003d498 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -86,6 +86,38 @@ static S390TopologySocket *s390_create_socket(MachineSta= te *ms, return socket; } =20 +/* + * s390_create_book: + * @ms: Machine state + * @drawer: the drawer on which to create the book + * @id: the book id + * + * returns a pointer to the created S390TopologyBook structure + * + * On error: return NULL + */ +static S390TopologyBook *s390_create_book(MachineState *ms, + S390TopologyDrawer *drawer, + int id, Error **errp) +{ + DeviceState *dev; + S390TopologyBook *book; + + if (drawer->bus->num_children >=3D ms->smp.books) { + error_setg(errp, "Unable to create more books."); + return NULL; + } + + dev =3D qdev_new(TYPE_S390_TOPOLOGY_BOOK); + qdev_realize_and_unref(dev, drawer->bus, &error_fatal); + + book =3D S390_TOPOLOGY_BOOK(dev); + book->book_id =3D id; + drawer->cnt++; + + return book; +} + /* * s390_get_cores: * @ms: Machine state @@ -142,6 +174,34 @@ static S390TopologySocket *s390_get_socket(MachineStat= e *ms, return s390_create_socket(ms, book, socket_id, errp); } =20 +/* + * s390_get_book: + * @ms: Machine state + * @drawer: The drawer to search into + * @book_id: the identifier of the book to search for + * @errp: Error pointer + * + * returns a pointer to a S390TopologySocket structure within a drawer hav= ing + * the specified book_id. + * First search if the drawer is already containing the S390TopologySocket + * structure and if not create one with this book_id. + */ +static S390TopologyBook *s390_get_book(MachineState *ms, + S390TopologyDrawer *drawer, + int book_id, Error **errp) +{ + S390TopologyBook *book; + BusChild *kid; + + QTAILQ_FOREACH(kid, &drawer->bus->children, sibling) { + book =3D S390_TOPOLOGY_BOOK(kid->child); + if (book->book_id =3D=3D book_id) { + return book; + } + } + return s390_create_book(ms, drawer, book_id, errp); +} + /* * s390_topology_new_cpu: * @core_id: the core ID is machine wide @@ -155,16 +215,23 @@ static S390TopologySocket *s390_get_socket(MachineSta= te *ms, */ bool s390_topology_new_cpu(MachineState *ms, int core_id, Error **errp) { + S390TopologyDrawer *drawer; S390TopologyBook *book; S390TopologySocket *socket; S390TopologyCores *cores; int nb_cores_per_socket; + int nb_cores_per_book; int origin, bit; =20 - book =3D s390_get_topology(); + drawer =3D s390_get_topology(); =20 nb_cores_per_socket =3D ms->smp.cores * ms->smp.threads; + nb_cores_per_book =3D ms->smp.sockets * nb_cores_per_socket; =20 + book =3D s390_get_book(ms, drawer, core_id / nb_cores_per_book, errp); + if (!book) { + return false; + } socket =3D s390_get_socket(ms, book, core_id / nb_cores_per_socket, er= rp); if (!socket) { return false; @@ -206,23 +273,23 @@ void s390_topology_setup(MachineState *ms) DeviceState *dev; =20 /* Create BOOK bridge device */ - dev =3D qdev_new(TYPE_S390_TOPOLOGY_BOOK); + dev =3D qdev_new(TYPE_S390_TOPOLOGY_DRAWER); object_property_add_child(qdev_get_machine(), - TYPE_S390_TOPOLOGY_BOOK, OBJECT(dev)); + TYPE_S390_TOPOLOGY_DRAWER, OBJECT(dev)); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); } =20 -S390TopologyBook *s390_get_topology(void) +S390TopologyDrawer *s390_get_topology(void) { - static S390TopologyBook *book; + static S390TopologyDrawer *drawer; =20 - if (!book) { - book =3D S390_TOPOLOGY_BOOK( - object_resolve_path(TYPE_S390_TOPOLOGY_BOOK, NULL)); - assert(book !=3D NULL); + if (!drawer) { + drawer =3D S390_TOPOLOGY_DRAWER(object_resolve_path( + TYPE_S390_TOPOLOGY_DRAWER, NULL)); + assert(drawer !=3D NULL); } =20 - return book; + return drawer; } =20 /* --- CORES Definitions --- */ @@ -365,12 +432,13 @@ static void book_class_init(ObjectClass *oc, void *da= ta) hc->unplug =3D qdev_simple_device_unplug_cb; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); dc->realize =3D s390_book_device_realize; + dc->bus_type =3D TYPE_S390_TOPOLOGY_DRAWER_BUS; dc->desc =3D "topology book"; } =20 static const TypeInfo book_info =3D { .name =3D TYPE_S390_TOPOLOGY_BOOK, - .parent =3D TYPE_SYS_BUS_DEVICE, + .parent =3D TYPE_DEVICE, .instance_size =3D sizeof(S390TopologyBook), .class_init =3D book_class_init, .interfaces =3D (InterfaceInfo[]) { @@ -379,6 +447,77 @@ static const TypeInfo book_info =3D { } }; =20 +/* --- DRAWER Definitions --- */ +static Property s390_topology_drawer_properties[] =3D { + DEFINE_PROP_UINT8("drawer_id", S390TopologyDrawer, drawer_id, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static char *drawer_bus_get_dev_path(DeviceState *dev) +{ + S390TopologyDrawer *drawer =3D S390_TOPOLOGY_DRAWER(dev); + DeviceState *node =3D dev->parent_bus->parent; + char *id =3D qdev_get_dev_path(node); + char *ret; + + if (id) { + ret =3D g_strdup_printf("%s:%02d", id, drawer->drawer_id); + g_free(id); + } else { + ret =3D g_strdup_printf("_:%02d", drawer->drawer_id); + } + + return ret; +} + +static void drawer_bus_class_init(ObjectClass *oc, void *data) +{ + BusClass *k =3D BUS_CLASS(oc); + + k->get_dev_path =3D drawer_bus_get_dev_path; + k->max_dev =3D S390_MAX_DRAWERS; +} + +static const TypeInfo drawer_bus_info =3D { + .name =3D TYPE_S390_TOPOLOGY_DRAWER_BUS, + .parent =3D TYPE_BUS, + .instance_size =3D 0, + .class_init =3D drawer_bus_class_init, +}; + +static void s390_drawer_device_realize(DeviceState *dev, Error **errp) +{ + S390TopologyDrawer *drawer =3D S390_TOPOLOGY_DRAWER(dev); + BusState *bus; + + bus =3D qbus_new(TYPE_S390_TOPOLOGY_DRAWER_BUS, dev, + TYPE_S390_TOPOLOGY_DRAWER_BUS); + qbus_set_hotplug_handler(bus, OBJECT(dev)); + drawer->bus =3D bus; +} + +static void drawer_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); + + hc->unplug =3D qdev_simple_device_unplug_cb; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->realize =3D s390_drawer_device_realize; + device_class_set_props(dc, s390_topology_drawer_properties); + dc->desc =3D "topology drawer"; +} + +static const TypeInfo drawer_info =3D { + .name =3D TYPE_S390_TOPOLOGY_DRAWER, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(S390TopologyDrawer), + .class_init =3D drawer_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { } + } +}; static void topology_register(void) { type_register_static(&cpu_cores_info); @@ -386,6 +525,8 @@ static void topology_register(void) type_register_static(&socket_info); type_register_static(&book_bus_info); type_register_static(&book_info); + type_register_static(&drawer_bus_info); + type_register_static(&drawer_info); } =20 type_init(topology_register); diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index beec61706c..5ffb8cba77 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -56,18 +56,30 @@ OBJECT_DECLARE_SIMPLE_TYPE(S390TopologySocket, S390_TOP= OLOGY_SOCKET) #define TYPE_S390_TOPOLOGY_BOOK "topology book" #define TYPE_S390_TOPOLOGY_BOOK_BUS "book-bus" struct S390TopologyBook { - SysBusDevice parent_obj; + DeviceState parent_obj; BusState *bus; int book_id; int cnt; }; typedef struct S390TopologyBook S390TopologyBook; OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyBook, S390_TOPOLOGY_BOOK) -#define S390_MAX_BOOKS 1 +#define S390_MAX_BOOKS 4 + +#define TYPE_S390_TOPOLOGY_DRAWER "topology drawer" +#define TYPE_S390_TOPOLOGY_DRAWER_BUS "drawer-bus" +struct S390TopologyDrawer { + SysBusDevice parent_obj; + BusState *bus; + uint8_t drawer_id; + int cnt; +}; +typedef struct S390TopologyDrawer S390TopologyDrawer; +OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyDrawer, S390_TOPOLOGY_DRAWER) +#define S390_MAX_DRAWERS 1 =20 -S390TopologyBook *s390_init_topology(void); +S390TopologyDrawer *s390_init_topology(void); =20 -S390TopologyBook *s390_get_topology(void); +S390TopologyDrawer *s390_get_topology(void); void s390_topology_setup(MachineState *ms); bool s390_topology_new_cpu(MachineState *ms, int core_id, Error **errp); =20 diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index d3ade40a5a..139d46efa4 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -111,6 +111,7 @@ typedef struct CPUEntry { uint8_t reserved1; } QEMU_PACKED CPUEntry; =20 +#define SCLP_READ_SCP_INFO_MNEST 3 #define SCLP_READ_SCP_INFO_FIXED_CPU_OFFSET 128 typedef struct ReadInfo { SCCBHeader h; diff --git a/target/s390x/cpu_topology.c b/target/s390x/cpu_topology.c index 9f656d7e51..d14b2fb25c 100644 --- a/target/s390x/cpu_topology.c +++ b/target/s390x/cpu_topology.c @@ -14,6 +14,7 @@ #include "hw/s390x/pv.h" #include "hw/sysbus.h" #include "hw/s390x/cpu-topology.h" +#include "hw/s390x/sclp.h" =20 static int stsi_15_container(void *p, int nl, int id) { @@ -40,7 +41,7 @@ static int stsi_15_cpus(void *p, S390TopologyCores *cd) } =20 static int set_socket(const MachineState *ms, void *p, - S390TopologySocket *socket) + S390TopologySocket *socket, int level) { BusChild *kid; int l, len =3D 0; @@ -56,24 +57,56 @@ static int set_socket(const MachineState *ms, void *p, return len; } =20 +static int set_book(const MachineState *ms, void *p, + S390TopologyBook *book, int level) +{ + BusChild *kid; + int l, len =3D 0; + + if (level >=3D 3) { + len +=3D stsi_15_container(p, 2, book->book_id); + p +=3D len; + } + + QTAILQ_FOREACH_REVERSE(kid, &book->bus->children, sibling) { + l =3D set_socket(ms, p, S390_TOPOLOGY_SOCKET(kid->child), level); + p +=3D l; + len +=3D l; + } + + return len; +} + static void setup_stsi(const MachineState *ms, void *p, int level) { - S390TopologyBook *book; + S390TopologyDrawer *drawer; SysIB_151x *sysib; BusChild *kid; + int nb_sockets, nb_books; int len, l; =20 sysib =3D (SysIB_151x *)p; sysib->mnest =3D level; - sysib->mag[TOPOLOGY_NR_MAG2] =3D ms->smp.sockets; + switch (level) { + case 2: + nb_books =3D 0; + nb_sockets =3D ms->smp.sockets * ms->smp.books; + break; + case 3: + nb_books =3D ms->smp.books; + nb_sockets =3D ms->smp.sockets; + break; + } + sysib->mag[TOPOLOGY_NR_MAG3] =3D nb_books; + sysib->mag[TOPOLOGY_NR_MAG2] =3D nb_sockets; sysib->mag[TOPOLOGY_NR_MAG1] =3D ms->smp.cores * ms->smp.threads; =20 - book =3D s390_get_topology(); + drawer =3D s390_get_topology(); len =3D sizeof(SysIB_151x); p +=3D len; =20 - QTAILQ_FOREACH_REVERSE(kid, &book->bus->children, sibling) { - l =3D set_socket(ms, p, S390_TOPOLOGY_SOCKET(kid->child)); + QTAILQ_FOREACH_REVERSE(kid, &drawer->bus->children, sibling) { + l =3D set_book(ms, p, S390_TOPOLOGY_BOOK(kid->child), level); p +=3D l; len +=3D l; } @@ -87,18 +120,14 @@ void insert_stsi_15_1_x(S390CPU *cpu, int sel2, __u64 = addr, uint8_t ar) void *p; int ret; =20 - /* - * Until the SCLP STSI Facility reporting the MNEST value is used, - * a sel2 value of 2 is the only value allowed in STSI 15.1.x. - */ - if (sel2 !=3D 2) { + if (sel2 < 2 || sel2 > SCLP_READ_SCP_INFO_MNEST) { setcc(cpu, 3); return; } =20 p =3D g_malloc0(TARGET_PAGE_SIZE); =20 - setup_stsi(machine, p, 2); + setup_stsi(machine, p, sel2); =20 if (s390_is_pv()) { ret =3D s390_cpu_pv_mem_write(cpu, 0, p, TARGET_PAGE_SIZE); --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734221; cv=none; d=zohomail.com; s=zohoarc; b=g+JRntMPOHN8uldrXhvhNImekUTG+jRRMRVE65cUep8AccFaLcU+ZZyvNj1r5QJEQnIa+qei545Wde3q6CMvkAhhGBVxBN79c2L23SyXL0++KEa5+dI5q3G1V8adOWDCzwJdpXz9QtY8G3tZaq27EWJVjjVFZGm0uQiQ39i3BSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734221; 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=DwYIKfy6fpv2hjmSUuo2KjthR7ZfIXTCdnja0yTYkg0=; b=DwJU4XyyAdOxBbiXd1Mj/1budRX4W7YWwkkiHauNSdzhZhWggBQqjYks9rZTTMrYSQpD1L5Ws8Y6Ek3eVMC/SRdv4TWwqCM/rWoO2/x6jAPlIhxXPRv2oixaUx1Gb097kqTZQREalUc6hHUZ+KL8OefRZcmYw4tb/beYUAtUi/U= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734221870726.1917720369962; Mon, 20 Jun 2022 07:10:21 -0700 (PDT) Received: from localhost ([::1]:57534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I6e-0007Vp-Fl for importer@patchew.org; Mon, 20 Jun 2022 10:10:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwR-0002vs-86; Mon, 20 Jun 2022 09:59:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51118 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 1o3HwN-0005jo-FQ; Mon, 20 Jun 2022 09:59:46 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KCMKRH009951; Mon, 20 Jun 2022 13:59:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrs7js2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:41 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25KCJBTs019993; Mon, 20 Jun 2022 13:59:41 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrs7js1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:41 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDq55R006811; Mon, 20 Jun 2022 13:59:39 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03fra.de.ibm.com with ESMTP id 3gs6b8t267-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:39 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxar317957192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:36 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3983011C050; Mon, 20 Jun 2022 13:59:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6569911C052; Mon, 20 Jun 2022 13:59:35 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:35 +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=DwYIKfy6fpv2hjmSUuo2KjthR7ZfIXTCdnja0yTYkg0=; b=E+lJM0WHB7eOl0xqqJS6SPLREi4gG8QOEd4yppWpt8aDEiHnRZgWSt02RjETBEPHlNUj 1XJGBV0vTlx7BBFxJfB96pKAmIeWoq95ZiDOl3p7skp9EXvcGwRrj1aEiCbub8vI8VC0 0Kd8UYF1vWsjCjd5ExrlXrxZ4fC1ddTkSNaWjLK7viijgkkR3017GjvRr2oH8Z07MwgM DwQCT08WqUWGmue5UGQFquZPewPyvhjuSLwR/i6kVOPd+sopzWWFgBCuFvSz4y5+6p+T 8VEH8WUW/fNqA6Qv3GRWCdN43DuwMV9Yf98eFKf1yff77baJRXZsx00mgAFx8ShI1B75 Pw== 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, frankja@linux.ibm.com Subject: [PATCH v8 06/12] s390x/cpu_topology: Adding drawers to CPU topology Date: Mon, 20 Jun 2022 16:03:46 +0200 Message-Id: <20220620140352.39398-7-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: JP_IuQJkJPaVx27AVlCPCavxSFGPxGY1 X-Proofpoint-ORIG-GUID: Jmu1z-Q0vzPzkQYUP-qpr1ko40rVsAZl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734223258100001 Content-Type: text/plain; charset="utf-8" S390 CPU topology may have up to 5 topology containers. The first container above the cores is level 2, the sockets, and the level 3, containing sockets are the books. We introduce here the drawers, drawers is the level containing books. Let's add drawers, level4, containers to the CPU topology. Signed-off-by: Pierre Morel --- hw/core/machine-smp.c | 33 ++++++++++++++++++++++++++------- hw/core/machine.c | 2 ++ hw/s390x/s390-virtio-ccw.c | 1 + include/hw/boards.h | 4 ++++ qapi/machine.json | 9 +++++++-- qemu-options.hx | 5 +++-- softmmu/vl.c | 3 +++ 7 files changed, 46 insertions(+), 11 deletions(-) diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index d7aa39d540..26150c748f 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -31,6 +31,10 @@ 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); } @@ -77,6 +81,7 @@ 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; @@ -90,6 +95,7 @@ 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) || @@ -124,6 +130,13 @@ void machine_parse_smp_config(MachineState *ms, =20 books =3D books > 0 ? books : 1; =20 + if (!mc->smp_props.drawers_supported && drawers > 1) { + error_setg(errp, "drawers not supported by this machine's CPU topo= logy"); + 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; @@ -137,34 +150,40 @@ 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 / (books * dies * clusters * cores * t= hreads); + 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 / (books * sockets * dies * clusters * t= hreads); + 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 / (books * sockets * dies * clusters * t= hreads); + 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 / (books * dies * clusters * cores * t= hreads); + sockets =3D maxcpus / + (drawers * books * dies * clusters * cores * thre= ads); } } =20 /* try to calculate omitted threads at last */ if (threads =3D=3D 0) { - threads =3D maxcpus / (books * sockets * dies * clusters * cor= es); + threads =3D maxcpus / + (drawers * books * sockets * dies * clusters * cores= ); } } =20 - maxcpus =3D maxcpus > 0 ? maxcpus : books * sockets * dies * + 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; @@ -174,7 +193,7 @@ void machine_parse_smp_config(MachineState *ms, ms->smp.max_cpus =3D maxcpus; =20 /* sanity-check of the computed topology */ - if (books * 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 8861f58d23..4c5c8d1655 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -821,6 +821,7 @@ 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, @@ -1088,6 +1089,7 @@ 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; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index ace65164d8..3b2a1f2729 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -620,6 +620,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) nc->nmi_monitor_handler =3D s390_nmi; mc->default_ram_id =3D "s390.ram"; mc->smp_props.books_supported =3D true; + mc->smp_props.drawers_supported =3D true; } =20 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) diff --git a/include/hw/boards.h b/include/hw/boards.h index 2b44f50b6e..53014275b2 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -131,12 +131,14 @@ typedef struct { * @dies_supported - whether dies are supported by the machine * @clusters_supported - whether clusters are supported by the machine * @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 books_supported; + bool drawers_supported; } SMPCompatProps; =20 /** @@ -301,6 +303,7 @@ typedef struct DeviceMemoryState { /** * CpuTopology: * @cpus: the number of present logical processors on the machine + * @drawers: the number of drawers on the machine * @books: the number of books on the machine * @sockets: the number of sockets on the machine * @dies: the number of dies in one socket @@ -311,6 +314,7 @@ typedef struct DeviceMemoryState { */ typedef struct CpuTopology { unsigned int cpus; + unsigned int drawers; unsigned int books; unsigned int sockets; unsigned int dies; diff --git a/qapi/machine.json b/qapi/machine.json index f838b0c51f..bdd92e3cb1 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -900,14 +900,15 @@ # a CPU is being hotplugged. # # @node-id: NUMA node ID the CPU belongs to -# @book-id: book number within node/board the CPU belongs to +# @drawer-id: drawer number within node/board the CPU belongs to +# @book-id: book number within drawer/node/board the CPU belongs to # @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 7 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 @@ -917,6 +918,7 @@ ## { 'struct': 'CpuInstanceProperties', 'data': { '*node-id': 'int', + '*drawer-id': 'int', '*book-id': 'int', '*socket-id': 'int', '*die-id': 'int', @@ -1467,6 +1469,8 @@ # # @cpus: number of virtual CPUs in the virtual machine # +# @drawers: number of drawers in the CPU topology +# # @books: number of books in the CPU topology # # @sockets: number of sockets in the CPU topology @@ -1485,6 +1489,7 @@ ## { 'struct': 'SMPConfiguration', 'data': { '*cpus': 'int', + '*drawers': 'int', '*books': 'int', '*sockets': 'int', '*dies': 'int', diff --git a/qemu-options.hx b/qemu-options.hx index 9d72208f50..46aa79ee26 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -239,11 +239,12 @@ SRST ERST =20 DEF("smp", HAS_ARG, QEMU_OPTION_smp, - "-smp [[cpus=3D]n][,maxcpus=3Dmaxcpus][,books=3Dbooks][,sockets=3Dsock= ets][,dies=3Ddies][,clusters=3Dclusters][,cores=3Dcores][,threads=3Dthreads= ]\n" + "-smp [[cpus=3D]n][,maxcpus=3Dmaxcpus][,drawers=3Ddrawers][,books=3Dbo= oks][,sockets=3Dsockets][,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" - " books=3D number of books 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" diff --git a/softmmu/vl.c b/softmmu/vl.c index c13edd6948..299a85a97a 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -726,6 +726,9 @@ 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, --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655733826; cv=none; d=zohomail.com; s=zohoarc; b=VXBStW63e1OHvEUJA35HirlWSjACuP+fwVzOMVf8hlwUk2DoTS1AGpgf4Ok70hTJWjg1HbPANHiLTtA2iHv5r+QvZ7FzahKzfYThEY7hQsCNIp8aw4HHldvLYQC9T51jcEibWqjVbtCivAmUorklb/ntAG2DS8icQzG4KbtEdjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655733826; 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=G9j1+/yevYHbvtRG2qJ3oucNY4LQ5FBP4Bi4PSa/zjI=; b=HFqid6QtrXU4Q/7sm7ur/w72jYsF8801+uc2jJEyNmwe3fcGhKoOm9JuwFHw1AVLzZfrkp6++qmCOUMULJcttRRDcyZlAt2jS1QNfGRJ4mOS0W2YyrQUssjKMR4AVZpoGhrVFVjmAw/BH6VJ7oieJ7xueouInfwQf7DYW9RGMZY= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655733826651163.86681268700136; Mon, 20 Jun 2022 07:03:46 -0700 (PDT) Received: from localhost ([::1]:43002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I0G-00067r-9c for importer@patchew.org; Mon, 20 Jun 2022 10:03:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwR-0002wV-EL; Mon, 20 Jun 2022 09:59:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:1832 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 1o3HwO-0005k9-T2; Mon, 20 Jun 2022 09:59:47 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KBwerN009104; Mon, 20 Jun 2022 13:59:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrb633g3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:42 +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 25KCTUAX024605; Mon, 20 Jun 2022 13:59:42 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrb633fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:42 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDoefj002887; Mon, 20 Jun 2022 13:59:40 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 3gs6b921yp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:40 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxbSQ23003506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:37 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EC1211C04C; Mon, 20 Jun 2022 13:59:37 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C7A311C04A; Mon, 20 Jun 2022 13:59:36 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:36 +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=G9j1+/yevYHbvtRG2qJ3oucNY4LQ5FBP4Bi4PSa/zjI=; b=FjCP9TU3VLZiPE6ocy5uB7h6hDpxu1O32fz4Z2/Qw3OOfsDDghMum0NrWYsBQwSztl3I ZEC4Q2/a+Baj30L4GjD8VObN6Izs9rMEl3kHlovi5+w2xM8M0miMxSY9f+ovI5xcjUxt JeGHuTpAf6hFLNOn3/gs+ASqiX+gqzyh/9PerZ2amA0zPuhSYo72H716VA1D73C4LkQG jrtuPWfKSE/zdhVv/JEVAzUsvVtBDWROM1q0RKhvjjzo+r7UYE4rLIh9pvab22tvlQ85 kNFnf4QmqllndckepIeRc377+whZKv8Xn9cIsR3cuOMv4+k/ykzF89l0yD1REZfNg5Ii +g== 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, frankja@linux.ibm.com Subject: [PATCH v8 07/12] s390x/cpu_topology: Adding drawers to STSI Date: Mon, 20 Jun 2022 16:03:47 +0200 Message-Id: <20220620140352.39398-8-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: jbSo_v-AeLeGXFnFiqJiWTvNgAXBbeCz X-Proofpoint-GUID: s835T-rfq2ezT0eZ-PNQo8lGBX-HQeAo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 spamscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655733827339100001 Content-Type: text/plain; charset="utf-8" Let's add STSI support for the container level 4, drawers, and provide the information back to the guest. Signed-off-by: Pierre Morel --- hw/s390x/cpu-topology.c | 145 +++++++++++++++++++++++++++++--- include/hw/s390x/cpu-topology.h | 19 ++++- include/hw/s390x/sclp.h | 2 +- target/s390x/cpu_topology.c | 40 +++++++-- 4 files changed, 184 insertions(+), 22 deletions(-) diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index eba003d498..107cdbecad 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -118,6 +118,28 @@ static S390TopologyBook *s390_create_book(MachineState= *ms, return book; } =20 +static S390TopologyDrawer *s390_create_drawer(S390TopologyNode *node, + int id, Error **errp) +{ + DeviceState *dev; + S390TopologyDrawer *drawer; + const MachineState *ms =3D MACHINE(qdev_get_machine()); + + if (node->bus->num_children >=3D ms->smp.drawers) { + error_setg(errp, "Unable to create more drawers."); + return NULL; + } + + dev =3D qdev_new(TYPE_S390_TOPOLOGY_DRAWER); + qdev_realize_and_unref(dev, node->bus, &error_fatal); + + drawer =3D S390_TOPOLOGY_DRAWER(dev); + drawer->drawer_id =3D id; + node->cnt++; + + return drawer; +} + /* * s390_get_cores: * @ms: Machine state @@ -174,6 +196,34 @@ static S390TopologySocket *s390_get_socket(MachineStat= e *ms, return s390_create_socket(ms, book, socket_id, errp); } =20 +/* + * s390_get_drawer: + * @ms: Machine state + * @node: The node to search into + * @drawer_id: the identifier of the drawer to search for + * @errp: Error pointer + * + * returns a pointer to a S390TopologyDrawer structure within a book having + * the specified drawer_id. + * First search if the book is already containing the S390TopologyDrawer + * structure and if not create one with this drawer_id. + */ +static S390TopologyDrawer *s390_get_drawer(MachineState *ms, + S390TopologyNode *node, + int drawer_id, Error **errp) +{ + S390TopologyDrawer *drawer; + BusChild *kid; + + QTAILQ_FOREACH(kid, &node->bus->children, sibling) { + drawer =3D S390_TOPOLOGY_DRAWER(kid->child); + if (drawer->drawer_id =3D=3D drawer_id) { + return drawer; + } + } + return s390_create_drawer(node, drawer_id, errp); +} + /* * s390_get_book: * @ms: Machine state @@ -215,19 +265,26 @@ static S390TopologyBook *s390_get_book(MachineState *= ms, */ bool s390_topology_new_cpu(MachineState *ms, int core_id, Error **errp) { + S390TopologyNode *node; S390TopologyDrawer *drawer; S390TopologyBook *book; S390TopologySocket *socket; S390TopologyCores *cores; int nb_cores_per_socket; int nb_cores_per_book; + int nb_cores_per_drawer; int origin, bit; =20 - drawer =3D s390_get_topology(); + node =3D s390_get_topology(); =20 nb_cores_per_socket =3D ms->smp.cores * ms->smp.threads; nb_cores_per_book =3D ms->smp.sockets * nb_cores_per_socket; + nb_cores_per_drawer =3D ms->smp.books * nb_cores_per_book; =20 + drawer =3D s390_get_drawer(ms, node, core_id / nb_cores_per_drawer, er= rp); + if (!drawer) { + return false; + } book =3D s390_get_book(ms, drawer, core_id / nb_cores_per_book, errp); if (!book) { return false; @@ -273,23 +330,23 @@ void s390_topology_setup(MachineState *ms) DeviceState *dev; =20 /* Create BOOK bridge device */ - dev =3D qdev_new(TYPE_S390_TOPOLOGY_DRAWER); + dev =3D qdev_new(TYPE_S390_TOPOLOGY_NODE); object_property_add_child(qdev_get_machine(), - TYPE_S390_TOPOLOGY_DRAWER, OBJECT(dev)); + TYPE_S390_TOPOLOGY_NODE, OBJECT(dev)); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); } =20 -S390TopologyDrawer *s390_get_topology(void) +S390TopologyNode *s390_get_topology(void) { - static S390TopologyDrawer *drawer; + static S390TopologyNode *node; =20 - if (!drawer) { - drawer =3D S390_TOPOLOGY_DRAWER(object_resolve_path( - TYPE_S390_TOPOLOGY_DRAWER, NULL)); - assert(drawer !=3D NULL); + if (!node) { + node =3D S390_TOPOLOGY_NODE(object_resolve_path( + TYPE_S390_TOPOLOGY_NODE, NULL)); + assert(node !=3D NULL); } =20 - return drawer; + return node; } =20 /* --- CORES Definitions --- */ @@ -503,6 +560,7 @@ static void drawer_class_init(ObjectClass *oc, void *da= ta) =20 hc->unplug =3D qdev_simple_device_unplug_cb; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->bus_type =3D TYPE_S390_TOPOLOGY_NODE_BUS; dc->realize =3D s390_drawer_device_realize; device_class_set_props(dc, s390_topology_drawer_properties); dc->desc =3D "topology drawer"; @@ -510,7 +568,7 @@ static void drawer_class_init(ObjectClass *oc, void *da= ta) =20 static const TypeInfo drawer_info =3D { .name =3D TYPE_S390_TOPOLOGY_DRAWER, - .parent =3D TYPE_SYS_BUS_DEVICE, + .parent =3D TYPE_DEVICE, .instance_size =3D sizeof(S390TopologyDrawer), .class_init =3D drawer_class_init, .interfaces =3D (InterfaceInfo[]) { @@ -518,6 +576,69 @@ static const TypeInfo drawer_info =3D { { } } }; + +/* --- NODE Definitions --- */ + +/* + * Nodes are the first level of CPU topology we support + * only one NODE for the moment. + */ +static char *node_bus_get_dev_path(DeviceState *dev) +{ + return g_strdup("00"); +} + +static void node_bus_class_init(ObjectClass *oc, void *data) +{ + BusClass *k =3D BUS_CLASS(oc); + + k->get_dev_path =3D node_bus_get_dev_path; + k->max_dev =3D S390_MAX_NODES; +} + +static const TypeInfo node_bus_info =3D { + .name =3D TYPE_S390_TOPOLOGY_NODE_BUS, + .parent =3D TYPE_BUS, + .instance_size =3D 0, + .class_init =3D node_bus_class_init, +}; + +static void s390_node_device_realize(DeviceState *dev, Error **errp) +{ + S390TopologyNode *node =3D S390_TOPOLOGY_NODE(dev); + BusState *bus; + + /* Create NODE bus on NODE bridge device */ + bus =3D qbus_new(TYPE_S390_TOPOLOGY_NODE_BUS, dev, + TYPE_S390_TOPOLOGY_NODE_BUS); + node->bus =3D bus; + + /* Enable hotplugging */ + qbus_set_hotplug_handler(bus, OBJECT(dev)); +} + +static void node_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); + + hc->unplug =3D qdev_simple_device_unplug_cb; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->realize =3D s390_node_device_realize; + dc->desc =3D "topology node"; +} + +static const TypeInfo node_info =3D { + .name =3D TYPE_S390_TOPOLOGY_NODE, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(S390TopologyNode), + .class_init =3D node_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { } + } +}; + static void topology_register(void) { type_register_static(&cpu_cores_info); @@ -527,6 +648,8 @@ static void topology_register(void) type_register_static(&book_info); type_register_static(&drawer_bus_info); type_register_static(&drawer_info); + type_register_static(&node_bus_info); + type_register_static(&node_info); } =20 type_init(topology_register); diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index 5ffb8cba77..ba0b1c1d7a 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -68,18 +68,29 @@ OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyBook, S390_TOPOL= OGY_BOOK) #define TYPE_S390_TOPOLOGY_DRAWER "topology drawer" #define TYPE_S390_TOPOLOGY_DRAWER_BUS "drawer-bus" struct S390TopologyDrawer { - SysBusDevice parent_obj; + DeviceState parent_obj; BusState *bus; uint8_t drawer_id; int cnt; }; typedef struct S390TopologyDrawer S390TopologyDrawer; OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyDrawer, S390_TOPOLOGY_DRAWER) -#define S390_MAX_DRAWERS 1 +#define S390_MAX_DRAWERS 4 =20 -S390TopologyDrawer *s390_init_topology(void); +#define TYPE_S390_TOPOLOGY_NODE "topology node" +#define TYPE_S390_TOPOLOGY_NODE_BUS "node-bus" +struct S390TopologyNode { + SysBusDevice parent_obj; + BusState *bus; + uint8_t node_id; + int cnt; +}; +typedef struct S390TopologyNode S390TopologyNode; +OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyNode, S390_TOPOLOGY_NODE) +#define S390_MAX_NODES 1 =20 -S390TopologyDrawer *s390_get_topology(void); +S390TopologyNode *s390_init_topology(void); +S390TopologyNode *s390_get_topology(void); void s390_topology_setup(MachineState *ms); bool s390_topology_new_cpu(MachineState *ms, int core_id, Error **errp); =20 diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index 139d46efa4..7f9ff84bf8 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -111,7 +111,7 @@ typedef struct CPUEntry { uint8_t reserved1; } QEMU_PACKED CPUEntry; =20 -#define SCLP_READ_SCP_INFO_MNEST 3 +#define SCLP_READ_SCP_INFO_MNEST 4 #define SCLP_READ_SCP_INFO_FIXED_CPU_OFFSET 128 typedef struct ReadInfo { SCCBHeader h; diff --git a/target/s390x/cpu_topology.c b/target/s390x/cpu_topology.c index d14b2fb25c..bd2ca171f6 100644 --- a/target/s390x/cpu_topology.c +++ b/target/s390x/cpu_topology.c @@ -77,36 +77,64 @@ static int set_book(const MachineState *ms, void *p, return len; } =20 +static int set_drawer(const MachineState *ms, void *p, + S390TopologyDrawer *drawer, int level) +{ + BusChild *kid; + int l, len =3D 0; + + if (level >=3D 4) { + len +=3D stsi_15_container(p, 3, drawer->drawer_id); + p +=3D len; + } + + QTAILQ_FOREACH_REVERSE(kid, &drawer->bus->children, sibling) { + l =3D set_book(ms, p, S390_TOPOLOGY_BOOK(kid->child), level); + p +=3D l; + len +=3D l; + } + + return len; +} + static void setup_stsi(const MachineState *ms, void *p, int level) { - S390TopologyDrawer *drawer; + S390TopologyNode *node; SysIB_151x *sysib; BusChild *kid; - int nb_sockets, nb_books; + int nb_sockets, nb_books, nb_drawers; int len, l; =20 sysib =3D (SysIB_151x *)p; sysib->mnest =3D level; switch (level) { case 2: + nb_drawers =3D 0; nb_books =3D 0; - nb_sockets =3D ms->smp.sockets * ms->smp.books; + nb_sockets =3D ms->smp.sockets * ms->smp.books * ms->smp.drawers; break; case 3: + nb_drawers =3D 0; + nb_books =3D ms->smp.books * ms->smp.drawers; + nb_sockets =3D ms->smp.sockets; + break; + case 4: + nb_drawers =3D ms->smp.drawers; nb_books =3D ms->smp.books; nb_sockets =3D ms->smp.sockets; break; } + sysib->mag[TOPOLOGY_NR_MAG4] =3D nb_drawers; sysib->mag[TOPOLOGY_NR_MAG3] =3D nb_books; sysib->mag[TOPOLOGY_NR_MAG2] =3D nb_sockets; sysib->mag[TOPOLOGY_NR_MAG1] =3D ms->smp.cores * ms->smp.threads; =20 - drawer =3D s390_get_topology(); + node =3D s390_get_topology(); len =3D sizeof(SysIB_151x); p +=3D len; =20 - QTAILQ_FOREACH_REVERSE(kid, &drawer->bus->children, sibling) { - l =3D set_book(ms, p, S390_TOPOLOGY_BOOK(kid->child), level); + QTAILQ_FOREACH_REVERSE(kid, &node->bus->children, sibling) { + l =3D set_drawer(ms, p, S390_TOPOLOGY_DRAWER(kid->child), level); p +=3D l; len +=3D l; } --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734141; cv=none; d=zohomail.com; s=zohoarc; b=NOLL2gaeyfm1a5pSQCeGDKTQZcasuzDPldjWz5TGl1pX35pNMLa/d9LX422YtCQc2M1w35LXDxFSaSLUgTfV3tIugUEOCLbWdkqo9IsgGv0Eol3G9cAB9h2DEm6Uif9kwnettKXOn+5Wn174yIWgfc/qCtaUMJSMpvFLICY5r1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734141; 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=Iur1XtJOldKsIw2vepB5Gr/txk7H3Frv0yM5d5CqFPI=; b=RE+nrrLTWBcKLm59KF7UmLP4ulVHDG0ApBQhER2LQBiA9Z65MloaCNsIMuSbIp9RhEEIIMHMIAXb4Ab9LZnSot7cqBMpMWgsXIF41jXD9qwVTlIAW1JlP+pw/i0VHlMRvVy7nqoB5IvW9m5LfyWSXQPTFZHnOp3ppk0mot1rwSY= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734141845796.342095826672; Mon, 20 Jun 2022 07:09:01 -0700 (PDT) Received: from localhost ([::1]:52348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I5M-00046I-37 for importer@patchew.org; Mon, 20 Jun 2022 10:09:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwR-0002vU-38; Mon, 20 Jun 2022 09:59:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:3088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwP-0005kD-1W; Mon, 20 Jun 2022 09:59:46 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KDMImD005819; Mon, 20 Jun 2022 13:59:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrrrjtv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:43 +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 25KClnFn026767; Mon, 20 Jun 2022 13:59:43 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 3gsrrrjtuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:42 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDpPH8028001; Mon, 20 Jun 2022 13:59:41 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04fra.de.ibm.com with ESMTP id 3gs6b8t223-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:41 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxcu418022688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:38 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05DF411C04A; Mon, 20 Jun 2022 13:59:38 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32BB811C052; Mon, 20 Jun 2022 13:59:37 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:37 +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=Iur1XtJOldKsIw2vepB5Gr/txk7H3Frv0yM5d5CqFPI=; b=R/C7aFfLpalg4PMFag5Tw6HM1z65JrWvVRyGY6AcIeChv/pQm0NgyIBPYtMgWgoZJgkH MjdimHYYjKlRs3muQVqSOFW6QlkjnbQ1AU0zhPJxoP2ssjbxuwpkgNUfyQlDuylvHUwg WzqnoWw2rgEg32aT3JpTGG6Fe3ajkPpKApJBX+ZhsS310ZIqZb1YrX8EptZAg/tfTEhy T+jNrVEU9brrYu4jENfYjw6KOO7uVHYTmxOXTF0x70XS+WEzOLDqJuo1zLD5ay1xSBLV taBAI1ktLeXmI6tLHMlv4q+oyfRfmNXIY+wSjxWL2G6zKKHIkWJbpkXUJ++bEM2KRX6P Yw== 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, frankja@linux.ibm.com Subject: [PATCH v8 08/12] s390x/cpu_topology: implementing numa for the s390x topology Date: Mon, 20 Jun 2022 16:03:48 +0200 Message-Id: <20220620140352.39398-9-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yLKGMltHtriVm2qkvdAyUnJIVWP745-q X-Proofpoint-ORIG-GUID: 7-6mNzzf7hLZZYTS9X1lFNoktkucLr44 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734143886100001 Content-Type: text/plain; charset="utf-8" S390x CPU Topology allows a non uniform repartition of the CPU inside the topology containers, sockets, books and drawers. We use numa to place the CPU inside the right topology container and report the non uniform topology to the guest. Note that s390x needs CPU0 to belong to the topology and consequently all topology must include CPU0. We accept a partial QEMU numa definition, in that case undefined CPUs are added to free slots in the topology starting with slot 0 and going up. Signed-off-by: Pierre Morel --- hw/core/machine.c | 18 ++++++++++ hw/s390x/s390-virtio-ccw.c | 68 ++++++++++++++++++++++++++++++++++---- 2 files changed, 79 insertions(+), 7 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 4c5c8d1655..3bee66acc6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -760,6 +760,16 @@ void machine_set_cpu_numa_node(MachineState *machine, return; } =20 + if (props->has_book_id && !slot->props.has_book_id) { + error_setg(errp, "book-id is not supported"); + return; + } + + if (props->has_drawer_id && !slot->props.has_drawer_id) { + error_setg(errp, "drawer-id is not supported"); + return; + } + /* skip slots with explicit mismatch */ if (props->has_thread_id && props->thread_id !=3D slot->props.thre= ad_id) { continue; @@ -782,6 +792,14 @@ void machine_set_cpu_numa_node(MachineState *machine, continue; } =20 + if (props->has_book_id && props->book_id !=3D slot->props.book_id)= { + continue; + } + + if (props->has_drawer_id && props->drawer_id !=3D slot->props.draw= er_id) { + continue; + } + /* reject assignment if slot is already assigned, for compatibility * of legacy cpu_index mapping with SPAPR core based mapping do not * error out if cpu thread and matched core have the same node-id = */ diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 3b2a1f2729..5c0dbff6fd 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -85,14 +85,34 @@ out: static void s390_init_cpus(MachineState *machine) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); - int i; + CPUArchId *slot; + int i, n =3D 0; =20 /* initialize possible_cpus */ mc->possible_cpu_arch_ids(machine); =20 s390_topology_setup(machine); - for (i =3D 0; i < machine->smp.cpus; i++) { + + /* For NUMA configuration create defined nodes */ + if (machine->numa_state->num_nodes) { + for (i =3D 0; i < machine->smp.max_cpus; i++) { + slot =3D &machine->possible_cpus->cpus[i]; + if (slot->arch_id !=3D -1 && n < machine->smp.cpus) { + s390x_new_cpu(machine->cpu_type, i, &error_fatal); + n++; + } + } + } + + /* create all remaining CPUs */ + for (i =3D 0; n < machine->smp.cpus && i < machine->smp.max_cpus; i++)= { + slot =3D &machine->possible_cpus->cpus[i]; + /* For NUMA configuration skip defined nodes */ + if (machine->numa_state->num_nodes && slot->arch_id !=3D -1) { + continue; + } s390x_new_cpu(machine->cpu_type, i, &error_fatal); + n++; } } =20 @@ -275,6 +295,11 @@ static void ccw_init(MachineState *machine) /* register hypercalls */ virtio_ccw_register_hcalls(); =20 + /* CPU0 must exist on S390x */ + if (!s390_cpu_addr2state(0)) { + error_printf("Core_id 0 must be defined in the CPU configuration\n= "); + exit(1); + } s390_enable_css_support(s390_cpu_addr2state(0)); =20 ret =3D css_create_css_image(VIRTUAL_CSSID, true); @@ -307,6 +332,7 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev, =20 g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); ms->possible_cpus->cpus[cpu->env.core_id].cpu =3D OBJECT(dev); + ms->possible_cpus->cpus[cpu->env.core_id].arch_id =3D cpu->env.core_id; =20 if (!s390_topology_new_cpu(ms, cpu->env.core_id, errp)) { return; @@ -532,7 +558,9 @@ static CpuInstanceProperties s390_cpu_index_to_props(Ma= chineState *ms, static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms) { int i; + int drawer_id, book_id, socket_id; unsigned int max_cpus =3D ms->smp.max_cpus; + CPUArchId *slot; =20 if (ms->possible_cpus) { g_assert(ms->possible_cpus && ms->possible_cpus->len =3D=3D max_cp= us); @@ -543,11 +571,25 @@ 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++) { - 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; + slot =3D &ms->possible_cpus->cpus[i]; + + slot->type =3D ms->cpu_type; + slot->vcpus_count =3D 1; + slot->arch_id =3D i; + slot->props.has_core_id =3D true; + slot->props.core_id =3D i; + + socket_id =3D i / ms->smp.cores; + slot->props.socket_id =3D socket_id; + slot->props.has_socket_id =3D true; + + book_id =3D socket_id / ms->smp.sockets; + slot->props.book_id =3D book_id; + slot->props.has_book_id =3D true; + + drawer_id =3D book_id / ms->smp.books; + slot->props.drawer_id =3D drawer_id; + slot->props.has_drawer_id =3D true; } =20 return ms->possible_cpus; @@ -589,6 +631,17 @@ static ram_addr_t s390_fixup_ram_size(ram_addr_t sz) return newsz; } =20 +/* + * S390 defines CPU topology level 2 as the level for which a change in to= pology + * is worth being taking care of. + * Let use level 2, socket, as the numa node. + */ +static int64_t s390_get_default_cpu_node_id(const MachineState *ms, int id= x) +{ + ms->possible_cpus->cpus[idx].arch_id =3D -1; + return idx / ms->smp.cores; +} + static void ccw_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -621,6 +674,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) mc->default_ram_id =3D "s390.ram"; mc->smp_props.books_supported =3D true; mc->smp_props.drawers_supported =3D true; + mc->get_default_cpu_node_id =3D s390_get_default_cpu_node_id; } =20 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734409; cv=none; d=zohomail.com; s=zohoarc; b=me0OvDpXBlmjPvdiPI8Ebs3vy+4osbRAizrWDL3kADs/xGf+BpQwQZ+JF1nAu4/sedZlBAsZY2WccbGlknglNMlYFN93htnfVu8goigH55in5kM53JsVpShI/alrMDCy1qlT5eYl0FpKMJSNQk8xWCrzSkiG9RvvOiH5g+YKt9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734409; 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=pmxlHQTPLuQWjWWffZUOf857m+unAVhna8a8UF/oL98=; b=WdmyVhs5tN/yRqQ9fPB4qNcd4qcUdA8kl2he/+B1U3blNbh31DlMrqgRDljyrffovmfwPnzujQucJi2LCMRwfFPhvmyCDr8RNiZgbqt/lFJdBGFJv8D3Pkmhm6xCdnigwt9Ko56++nWfzSXRwefBYmutp0oCY+90BOVGYRQOOdE= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734409423421.48512693098996; Mon, 20 Jun 2022 07:13:29 -0700 (PDT) Received: from localhost ([::1]:36126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I9f-0003jO-PR for importer@patchew.org; Mon, 20 Jun 2022 10:13:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwU-00033R-Q8; Mon, 20 Jun 2022 09:59:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:30564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwR-0005kq-Te; Mon, 20 Jun 2022 09:59:50 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KCaKgZ001209; Mon, 20 Jun 2022 13:59:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrgvkd82-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:45 +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 25KDNCg5013097; Mon, 20 Jun 2022 13:59:44 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 3gsrgvkd78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:44 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDpBiE009321; Mon, 20 Jun 2022 13:59:42 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3gs5yhjm0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:41 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxcMM11993578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:39 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D755A11C04A; Mon, 20 Jun 2022 13:59:38 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1800211C04C; Mon, 20 Jun 2022 13:59:38 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:38 +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=pmxlHQTPLuQWjWWffZUOf857m+unAVhna8a8UF/oL98=; b=aflzalbZDRoDJ6DAiunV1LeOKqkbzIlhWptiTnTtagfC5RY82/XkUQ0mF8KacexsypRw J3xfOWIsldjT70E0hBl+8ZsFtYEyk+CV5twI47441z9yXtm14QiK1Y7hZSIRptFHeDdx Twhm15VerEhQzMrLWRehQWwalK+B1TnzEjAA4CVBtpBv34cwKmOy+u3v86vx+kgGHBSL Ejm/QEzvsBr8FIhtShlgeibbeNDMKnqhrakzMn24RlHYA4aEx414bFKF5PeOsT2yB/88 BveN9HPGVrGNWX8XdvmQEBPfzQIayDz5gogeuuBlVZMJJfweky87qxA0zYztGhuzmBWn aA== 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, frankja@linux.ibm.com Subject: [PATCH v8 09/12] target/s390x: interception of PTF instruction Date: Mon, 20 Jun 2022 16:03:49 +0200 Message-Id: <20220620140352.39398-10-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: EKgmt6jDwYy8I5R3ZQ-BrORG_4CiXy8V X-Proofpoint-ORIG-GUID: 9HCbIqDw9avsgFcJkWuGzxy3rhgZtGoc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734411543100001 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 hypervizor 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 hypervizor. Signed-off-by: Pierre Morel --- hw/s390x/cpu-topology.c | 50 ++++++++++++++++++++++++++++++ include/hw/s390x/s390-virtio-ccw.h | 6 ++++ target/s390x/kvm/kvm.c | 13 ++++++++ 3 files changed, 69 insertions(+) diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 107cdbecad..2dbb42ee2b 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -20,6 +20,56 @@ #include "target/s390x/cpu.h" #include "hw/s390x/s390-virtio-ccw.h" =20 +/* + * s390_handle_ptf: + * + * @register 1: contains the function code + * + * Function codes 0 and 1 handle the CPU polarization. + * We assume an horizontal topology, the only one supported currently + * by Linux, consequently we answer to function code 0, requesting + * horizontal polarization that it is already the current polarization + * and reject vertical polarization request without further explanation. + * + * 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]; + uint8_t 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 0: /* Horizontal polarization is already set */ + env->regs[r1] |=3D S390_PTF_REASON_DONE; + setcc(cpu, 2); + break; + case 1: /* Vertical polarization is not supported */ + env->regs[r1] |=3D S390_PTF_REASON_NONE; + setcc(cpu, 2); + break; + default: + /* Note that fc =3D=3D 2 is interpreted by the SIE */ + s390_program_interrupt(env, PGM_SPECIFICATION, ra); + } +} + /* * s390_create_cores: * @ms: Machine state diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-vir= tio-ccw.h index 3331990e02..f2c64dbc1a 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/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 563bf5ac60..c664c45e8a 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -97,6 +97,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 @@ -1461,6 +1462,15 @@ static int kvm_mpcifc_service_call(S390CPU *cpu, str= uct kvm_run *run) } } =20 +static int 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); + + return 0; +} + static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) { int r =3D 0; @@ -1478,6 +1488,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: + r =3D kvm_handle_ptf(cpu, run); + break; case PRIV_B9_EQBS: /* just inject exception */ r =3D -1; --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734455; cv=none; d=zohomail.com; s=zohoarc; b=kmi8vuBVyQjezJ/48NlwndWrGpYoIw+raWwUZlOImwnPPbwwy5nCuxZhPA8q4YX4f4ADCLXrzUBVW3M8PCpZtMUtaPjez+xD8IrCh2NMv/K5+A/teWQT5RhSOJV2o+NPBZV6TmmRrQwgOMtSivM3xNHU1cnimSMPLSVNv1YEVt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734455; 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=pmruLiCT7e8VOWqJPP9lMjJ9ScQTZQpfnWgo06cTogw=; b=gkn9jnSKmBL5LeW1S/THgcJzzJ4JvDytENSIzjKBVqNCZZxdsHXQxJv//LJEnwWfziAo6hhI1DH1YxQdBrYsxf4OaC+CDg5NVB+4Rg0RkLwRHpNoSNKFOspjndxYZBmBMOz64eKHpl3vlzQK/BCawTe+oeGbFJdXq8vg2XVdlbI= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734455736779.6138461124722; Mon, 20 Jun 2022 07:14:15 -0700 (PDT) Received: from localhost ([::1]:38224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3IAQ-0005Ah-Nl for importer@patchew.org; Mon, 20 Jun 2022 10:14:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwU-00033p-Vi; Mon, 20 Jun 2022 09:59:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwS-0005lH-KM; Mon, 20 Jun 2022 09:59:50 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KDueTE002836; Mon, 20 Jun 2022 13:59:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsr1asbrr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:46 +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 25KDwSlI017287; Mon, 20 Jun 2022 13:59:45 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 3gsr1asbqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:45 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDpOOL023580; Mon, 20 Jun 2022 13:59:42 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3gs6b8tkng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:42 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxdAc12190176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:39 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B74CB11C04C; Mon, 20 Jun 2022 13:59:39 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8C0211C050; Mon, 20 Jun 2022 13:59:38 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:38 +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=pmruLiCT7e8VOWqJPP9lMjJ9ScQTZQpfnWgo06cTogw=; b=owC/d4mgXYdduYZlY2J73DRe6FE0bbh16LphUmoBzzkTKJNJUwPdjQY9wK3fPP3V2rwH lwpTKEy8QPYrZH6LJZgDuMe4VE1ia8q03bXCPqUhqV1S7ELzyJVnJeeobleRoLwGvxzo qiZF/IdCu6QFRiDZzQ9lzy9m2aIuITgY5+OWsGXv0mhDS0jhsXNYhqko4UQkehsdJ3P9 WfNasJ0wH09YKRenN59VDqj+LePKOOOg2NBFAdgY+GIwKS/oUKaSzwwjyxoXawf2Ccma DazPljCN6OVV/poa06fSB/BKe/G2LRsAwxIjmXOpAQLxNhV7dzZwv70x4J/rl9LY2eKL 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, frankja@linux.ibm.com Subject: [PATCH v8 10/12] s390x/cpu_topology: resetting the Topology-Change-Report Date: Mon, 20 Jun 2022 16:03:50 +0200 Message-Id: <20220620140352.39398-11-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: y5Vj8XfE-XM3jQNlf46rBM7gnkVyCeuE X-Proofpoint-GUID: aFl9gLy3VL9XraGjz1YC7R0K3g_oFggg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 spamscore=0 phishscore=0 impostorscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734457813100001 Content-Type: text/plain; charset="utf-8" During a subsystem reset the Topology-Change-Report is cleared. Let's ask KVM to clear the MTCR in the case of a subsystem reset. Signed-off-by: Pierre Morel --- hw/s390x/cpu-topology.c | 6 ++++++ hw/s390x/s390-virtio-ccw.c | 1 + target/s390x/cpu-sysemu.c | 7 +++++++ target/s390x/cpu.h | 1 + target/s390x/kvm/kvm.c | 30 ++++++++++++++++++++++++++++++ target/s390x/kvm/kvm_s390x.h | 2 ++ 6 files changed, 47 insertions(+) diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 2dbb42ee2b..ba12cafaf7 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -667,6 +667,11 @@ static void s390_node_device_realize(DeviceState *dev,= Error **errp) qbus_set_hotplug_handler(bus, OBJECT(dev)); } =20 +static void s390_topology_reset(DeviceState *dev) +{ + s390_cpu_topology_mtr_reset(); +} + static void node_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -676,6 +681,7 @@ static void node_class_init(ObjectClass *oc, void *data) set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); dc->realize =3D s390_node_device_realize; dc->desc =3D "topology node"; + dc->reset =3D s390_topology_reset; } =20 static const TypeInfo node_info =3D { diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 5c0dbff6fd..0b30633ed5 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -122,6 +122,7 @@ static const char *const reset_dev_types[] =3D { "s390-flic", "diag288", TYPE_S390_PCI_HOST_BRIDGE, + TYPE_S390_TOPOLOGY_NODE, }; =20 static void subsystem_reset(void) diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 948e4bd3e0..11d0d87301 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -306,3 +306,10 @@ 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_mtr_reset(void) +{ + if (kvm_enabled()) { + kvm_s390_cpu_topology_reset(); + } +} diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 9d48087b71..793e72c81a 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -826,6 +826,7 @@ void s390_enable_css_support(S390CPU *cpu); void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg); int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id, int vq, bool assign); +void s390_cpu_topology_mtr_reset(void); #ifndef CONFIG_USER_ONLY unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu); #else diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index c664c45e8a..277f8d37cf 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2592,3 +2592,33 @@ bool kvm_arch_cpu_check_are_resettable(void) { return true; } + +static void kvm_s390_set_mtr(uint64_t attr) +{ + struct kvm_device_attr attribute =3D { + .group =3D KVM_S390_VM_CPU_TOPOLOGY, + .attr =3D attr, + }; + int ret =3D kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attribute); + + if (ret) { + error_report("Failed to set cpu topology attribute %lu: %s", + attr, strerror(-ret)); + } +} + +static void kvm_s390_reset_mtr(void) +{ + uint64_t attr =3D KVM_S390_VM_CPU_TOPO_MTR_CLEAR; + + if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) { + kvm_s390_set_mtr(attr); + } +} + +void kvm_s390_cpu_topology_reset(void) +{ + if (s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) { + kvm_s390_reset_mtr(); + } +} diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h index 05a5e1e6f4..d717c05827 100644 --- a/target/s390x/kvm/kvm_s390x.h +++ b/target/s390x/kvm/kvm_s390x.h @@ -46,4 +46,6 @@ 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); =20 +void kvm_s390_cpu_topology_reset(void); + #endif /* KVM_S390X_H */ --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734270; cv=none; d=zohomail.com; s=zohoarc; b=fiH1gFmE/lLN4ePVCn8uNzTc0Xek+RqVCcj1cPGYtQfNXit9AJmBpcinurx61ypDojfBQ/PcVH3SWfo+1YIhmBJInO5n7NYIHvmzasJcwg0BrzWV+/NFN/sh5+nkCsi7L695V9LVDBojKQuFKJLRv7vvtlnjobDTKUKz+ICrHhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734270; 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=WA6U8UJzN4BVznmx1Tk3X7vRSNImIwx9No2tEjPGN9M=; b=k15Z+/eu4S5lRQmJnMGN61zG8WJV+YWAMMiUik3m1FeCGexN9lJvK1IEdeyqlaGIJUJHPbU8jJnhgmY7lTq/g6jb6e3Y/am/XnaapZZGoAhv9GrWPPR93OhJc2swDqHvOjiIGMcXNoev8y7tKj09r7OunBhHWjY4AjQ98+VkcpE= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734270578696.5798612822063; Mon, 20 Jun 2022 07:11:10 -0700 (PDT) Received: from localhost ([::1]:59200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I7R-0000Am-Hz for importer@patchew.org; Mon, 20 Jun 2022 10:11:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwT-00031e-IC; Mon, 20 Jun 2022 09:59:49 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:24888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwR-0005kw-PB; Mon, 20 Jun 2022 09:59:49 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KDUNwx023758; Mon, 20 Jun 2022 13:59:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsrcjtspn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:46 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25KCEcZe024566; Mon, 20 Jun 2022 13:59:45 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 3gsrcjtsp0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:45 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDpBAb010890; Mon, 20 Jun 2022 13:59:43 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma01fra.de.ibm.com with ESMTP id 3gs6b8j2mc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:43 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxeJc11338232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:40 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9915211C04A; Mon, 20 Jun 2022 13:59:40 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C961711C050; Mon, 20 Jun 2022 13:59:39 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:39 +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=WA6U8UJzN4BVznmx1Tk3X7vRSNImIwx9No2tEjPGN9M=; b=lHiWRjmT5BEixNhwaGbn2cqfVN5bxpJLUrKPPmlc5aAIB4oQ6r74hbwUldklx1LySzPA 4lIxiIRfvb2BprjTSwR8DqIJ9lwNqs/FD2jCrYwhois8AMAgme2ut8TsrXvbtED6ibrI LDwFWMTzx/mE5sfiqb4XNlKBsTpjFsmyMHJYjgFrm0x1aOVhBrNraoUxgsOqVKuBMO4u O5xZtjAlVu/zBJjJuubNL3T0n059L4dw+qz2CD1WLCuP8MWMba94wRUFIOAyslcZdT3V DAnvN3ZHDoDJWKMpDUrcRxUurl8chyULx5u1wthDDn/YzEKqIFjdSPbfGG1NJ/2vU1jU +A== 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, frankja@linux.ibm.com Subject: [PATCH v8 11/12] s390x/cpu_topology: CPU topology migration Date: Mon, 20 Jun 2022 16:03:51 +0200 Message-Id: <20220620140352.39398-12-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6dkzbLFkrfTSPzT6VYPirK1cCZkBFauu X-Proofpoint-GUID: pTOUFJnJvVCgxsUN-J4PuVwEGZ6l3SLf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734271814100001 Content-Type: text/plain; charset="utf-8" To migrate the Multiple Topology Change report, MTCR, we get it from KVM and save its state in the topology VM State Description during the presave and restore it to KVM on the destination during the postload. The migration state is needed whenever the CPU topology feature is activated. Signed-off-by: Pierre Morel --- hw/s390x/cpu-topology.c | 43 +++++++++++++++++++++++++++++++++ include/hw/s390x/cpu-topology.h | 2 ++ target/s390x/cpu.h | 2 ++ target/s390x/cpu_models.c | 1 + target/s390x/kvm/kvm.c | 38 ++++++++++++++++++++++++++++- 5 files changed, 85 insertions(+), 1 deletion(-) diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index ba12cafaf7..8fba2c8144 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -19,6 +19,8 @@ #include "qemu/typedefs.h" #include "target/s390x/cpu.h" #include "hw/s390x/s390-virtio-ccw.h" +#include "migration/vmstate.h" +#include "qemu/error-report.h" =20 /* * s390_handle_ptf: @@ -672,6 +674,46 @@ static void s390_topology_reset(DeviceState *dev) s390_cpu_topology_mtr_reset(); } =20 +static int cpu_topology_postload(void *opaque, int version_id) +{ + S390TopologyNode *node =3D opaque; + + if (node->topology_needed !=3D s390_has_feat(S390_FEAT_CONFIGURATION_T= OPOLOGY)) { + return -EINVAL; + } + + return s390_cpu_topology_mtcr_set(node->mtcr); +} + +static int cpu_topology_presave(void *opaque) +{ + S390TopologyNode *node =3D opaque; + + node->topology_needed =3D s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLO= GY); + node->mtcr =3D s390_cpu_topology_mtcr_get(); + return 1; +} + +static bool cpu_topology_needed(void *opaque) +{ + return s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY); +} + + +const VMStateDescription vmstate_cpu_topology =3D { + .name =3D "cpu_topology", + .version_id =3D 1, + .pre_save =3D cpu_topology_presave, + .post_load =3D cpu_topology_postload, + .minimum_version_id =3D 1, + .needed =3D cpu_topology_needed, + .fields =3D (VMStateField[]) { + VMSTATE_BOOL(mtcr, S390TopologyNode), + VMSTATE_BOOL(topology_needed, S390TopologyNode), + VMSTATE_END_OF_LIST() + } +}; + static void node_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -682,6 +724,7 @@ static void node_class_init(ObjectClass *oc, void *data) dc->realize =3D s390_node_device_realize; dc->desc =3D "topology node"; dc->reset =3D s390_topology_reset; + dc->vmsd =3D &vmstate_cpu_topology; } =20 static const TypeInfo node_info =3D { diff --git a/include/hw/s390x/cpu-topology.h b/include/hw/s390x/cpu-topolog= y.h index ba0b1c1d7a..bd94a41135 100644 --- a/include/hw/s390x/cpu-topology.h +++ b/include/hw/s390x/cpu-topology.h @@ -84,6 +84,8 @@ struct S390TopologyNode { BusState *bus; uint8_t node_id; int cnt; + bool mtcr; + bool topology_needed; }; typedef struct S390TopologyNode S390TopologyNode; OBJECT_DECLARE_SIMPLE_TYPE(S390TopologyNode, S390_TOPOLOGY_NODE) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 793e72c81a..0b697f3021 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -827,6 +827,8 @@ void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_d= ata arg); int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id, int vq, bool assign); void s390_cpu_topology_mtr_reset(void); +int s390_cpu_topology_mtcr_set(uint16_t mtcr); +bool s390_cpu_topology_mtcr_get(void); #ifndef CONFIG_USER_ONLY unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu); #else diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 1a562d2801..adf001debb 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -253,6 +253,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 277f8d37cf..e9aa689da7 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -63,6 +63,8 @@ } \ } while (0) =20 +#include "qemu/error-report.h" + #define kvm_vm_check_mem_attr(s, attr) \ kvm_vm_check_attr(s, KVM_S390_VM_MEM_CTRL, attr) =20 @@ -2607,13 +2609,47 @@ static void kvm_s390_set_mtr(uint64_t attr) } } =20 -static void kvm_s390_reset_mtr(void) +int s390_cpu_topology_mtcr_set(uint16_t mtcr) { uint64_t attr =3D KVM_S390_VM_CPU_TOPO_MTR_CLEAR; =20 + attr =3D mtcr ? KVM_S390_VM_CPU_TOPO_MTR_SET : + KVM_S390_VM_CPU_TOPO_MTR_CLEAR; + if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) { kvm_s390_set_mtr(attr); } + + return 0; +} + +bool s390_cpu_topology_mtcr_get(void) +{ + struct kvm_s390_cpu_topology topology; + struct kvm_device_attr attribute =3D { + .group =3D KVM_S390_VM_CPU_TOPOLOGY, + .addr =3D (uint64_t)&topology, + }; + int ret; + + if (!kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, 0)) { + return -ENODEV; + } + + ret =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attribute); + if (ret) { + error_report("Failed to get cpu topology"); + return false; + } + return !!topology.mtcr; +} + +static void kvm_s390_reset_mtr(void) +{ + if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, + KVM_S390_VM_CPU_TOPO_MTR_CLEAR)) { + kvm_s390_set_mtr(KVM_S390_VM_CPU_TOPO_MTR_CLEAR); + } } =20 void kvm_s390_cpu_topology_reset(void) --=20 2.31.1 From nobody Tue May 21 22:12:07 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1655734420; cv=none; d=zohomail.com; s=zohoarc; b=fyJF2MB/KI2EA77ymQaQ9AbTGgwRYikwmgkIj4xFVNqY6HPqcKxLy4fp8pZvCOYn6UOGrqf6DruGuwm80lZtlGAC69tHT415TuMsmYuleHjNPS1YTB1o8AEUNvxcD0neU3sUwjKWy8pTy8JR7PtvPwxHE5dtgo26hxWSesnzNa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655734420; 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=dxOLMsr6ecQfQhcHPssuho4ZwGqBeAa1QzScZxpkqbI=; b=jwjMt/V0cExwQJtUYHZLFRzmiWwQUDSyYQOVaDF7c0Wrc96lFxwrezWdUbpodoDTPmDMfryKxzS+ABHWOPoqnaOgyTqDNjDgHoW17nHjRK/UeggI+ud0mvqRa5L3i4vomXWt4BTTngy/JaglG543LQogNQpEisR5O9Fa/f2KlaY= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655734420231781.2415892134283; Mon, 20 Jun 2022 07:13:40 -0700 (PDT) Received: from localhost ([::1]:36770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3I9q-00049q-UN for importer@patchew.org; Mon, 20 Jun 2022 10:13:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwX-0003Ak-JM; Mon, 20 Jun 2022 09:59:53 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3HwU-0005lZ-SV; Mon, 20 Jun 2022 09:59:53 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25KDv9Ig004737; Mon, 20 Jun 2022 13:59:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gsr1asbsq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:48 +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 25KDwYnn017720; Mon, 20 Jun 2022 13:59:47 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 3gsr1asbrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:47 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25KDotTQ008987; Mon, 20 Jun 2022 13:59:44 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 3gs5yhjm0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Jun 2022 13:59:44 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25KDxkHQ19595750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Jun 2022 13:59:46 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7998B11C052; Mon, 20 Jun 2022 13:59:41 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAEA011C04C; Mon, 20 Jun 2022 13:59:40 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.62.140]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 20 Jun 2022 13:59:40 +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=dxOLMsr6ecQfQhcHPssuho4ZwGqBeAa1QzScZxpkqbI=; b=a04dJl08jaqJxavOvmjY3Q7KNo0jFVsoYbD5nJ1mwYUFLfU3Yu5nC5A7J45d9KxR9v43 shxxfe9G9eT2TFnAdJOtiEuv5rwdkOURn+K5Pqqt/cglNJZw9ZDJe2iSBGmNRAt7Z7dr 9a8h9VF/i/Dn4eDK2xQOF90I3AVbVx42MPBXeUDvBvNj/0VZLabUlk1SH6DGKceqKqvZ RRYccnqhEGpWBQB76PXICWuTEhkcW5YRbIHeJXlw8CDiuzASIrqdWzdSQDt0Mnslrh3j LJOUv2fNMJTTYFcPnLnZxw3PmAj0Ngsj9oUe8M4a+HBJyuHoxpbpMuK1RzCKxB8rO1uu bg== 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, frankja@linux.ibm.com Subject: [PATCH v8 12/12] s390x/cpu_topology: activating CPU topology Date: Mon, 20 Jun 2022 16:03:52 +0200 Message-Id: <20220620140352.39398-13-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220620140352.39398-1-pmorel@linux.ibm.com> References: <20220620140352.39398-1-pmorel@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NqY0BG7VWbJHq8ntsE-_PdUYiEY5Q590 X-Proofpoint-GUID: uFYW1oZQtDTq6c_orDWJB7pqNrukblBG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_05,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=862 spamscore=0 phishscore=0 impostorscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206200063 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1655734421419100001 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. Signed-off-by: Pierre Morel --- target/s390x/kvm/kvm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index e9aa689da7..50920bdbca 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -370,6 +370,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; @@ -2467,6 +2468,14 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model= , Error **errp) set_bit(S390_FEAT_UNPACK, model->features); } =20 + /* + * If we have the CPU Topology implemented in KVM activate + * the CPU TOPOLOGY feature. + */ + 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