From patchwork Mon Aug 9 08:48:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12425863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68EB1C432BE for ; Mon, 9 Aug 2021 08:49:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4805361019 for ; Mon, 9 Aug 2021 08:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234052AbhHIIti (ORCPT ); Mon, 9 Aug 2021 04:49:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:14634 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234036AbhHIIt1 (ORCPT ); Mon, 9 Aug 2021 04:49:27 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1798ZLsY024960; Mon, 9 Aug 2021 04:49:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=JQu0Ae2sq2CFtm+EyyHhqWHYlMfvGwwqyUfJNCsZ8is=; b=SFBqKoYjaUG7gQXtm9rYpJj0nUCvu2sUo8UVOz22s4kG4VEUuO4cR0c7RoSB+S74MjAl V21raL+ipt+WIM1uosBRmKb8bmli+Qg6Ra7ukakLqcNiqwwB/LIZS5n9p7ctleBG8dfr ttHD7qtv15G2ypXY06Lw4G4uvMv/9n8HKW5KKb/b4A3PCZvuHCz7aJxmD1aOsKCFj+BK FdQbpxDFJLcEYiMz/GRPTp05cSletAuY0tv/v1Y5ZanNLHv5mRBLS8QWrFYWMk8s8dn0 zSknqNpnrFH5+5I9TOG3Vml3eBOlWcKY9Q+2ItqDNaeUjgeXS5d5LYmVgvoLHlVL9k1t xQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aa78t1utq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:03 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1798ZXm8027149; Mon, 9 Aug 2021 04:49:03 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aa78t1usy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:02 -0400 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 1798m6uJ003746; Mon, 9 Aug 2021 08:49:00 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03fra.de.ibm.com with ESMTP id 3a9ht8k9g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 08:49:00 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1798mujF53084578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Aug 2021 08:48:56 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD6AB42041; Mon, 9 Aug 2021 08:48:56 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 502184204B; Mon, 9 Aug 2021 08:48:56 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.151.189]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Aug 2021 08:48:56 +0000 (GMT) From: Pierre Morel To: linux-s390@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, kvm@vger.kernel.org, cohuck@redhat.com, imbrenda@linux.ibm.com, david@redhat.com Subject: [kvm-unit-tests PATCH v1 1/4] s390x: lib: Add SCLP toplogy nested level Date: Mon, 9 Aug 2021 10:48:51 +0200 Message-Id: <1628498934-20735-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> References: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: W4dk_eewj2H91z-50alW9dHfUHzVuqxD X-Proofpoint-GUID: APOdZfVHathere8NYubT8fbSXDZveEg1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-09_01:2021-08-06,2021-08-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108090069 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The maximum CPU Topology nested level is available with the SCLP READ_INFO command inside the byte at offset 15 of the ReadInfo structure. Let's return this information to check the number of topology nested information available with the STSI 15.1.x instruction. Signed-off-by: Pierre Morel Reviewed-by: Claudio Imbrenda --- lib/s390x/sclp.c | 6 ++++++ lib/s390x/sclp.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 9502d161..ee379ddf 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -123,6 +123,12 @@ int sclp_get_cpu_num(void) return read_info->entries_cpu; } +int sclp_get_stsi_parm(void) +{ + assert(read_info); + return read_info->stsi_parm; +} + CPUEntry *sclp_get_cpu_entries(void) { assert(read_info); diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 28e526e2..1a365958 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -146,7 +146,8 @@ typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax; uint8_t rnsize; - uint8_t _reserved1[16 - 11]; /* 11-15 */ + uint8_t _reserved1[15 - 11]; /* 11-14 */ + uint8_t stsi_parm; uint16_t entries_cpu; /* 16-17 */ uint16_t offset_cpu; /* 18-19 */ uint8_t _reserved2[24 - 20]; /* 20-23 */ @@ -322,6 +323,7 @@ void sclp_console_setup(void); void sclp_print(const char *str); void sclp_read_info(void); int sclp_get_cpu_num(void); +int sclp_get_stsi_parm(void); CPUEntry *sclp_get_cpu_entries(void); void sclp_facilities_setup(void); int sclp_service_call(unsigned int command, void *sccb); From patchwork Mon Aug 9 08:48:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12425857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC281C4338F for ; Mon, 9 Aug 2021 08:49:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3BBD61056 for ; Mon, 9 Aug 2021 08:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234090AbhHIItd (ORCPT ); Mon, 9 Aug 2021 04:49:33 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:10000 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234060AbhHIIt1 (ORCPT ); Mon, 9 Aug 2021 04:49:27 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1798YqGo045087; Mon, 9 Aug 2021 04:49:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=6+6ELF7atY8iBAVtsC7aXKLl3Z44aoVuUI+MvxNZEio=; b=I82gQ+GupGGhq41oUwn8GUT8Xa1BJOxY+Hsgtt6h7aW3zZVUSCqjpubWSiN3UpR/Gb2B LiK7Ya/0BiMNqsJU6csX0X2jvg0Jzoy5SH2sHqAhWKyQ36ayy7rT8NXxsxJ7WPWoljRK UyPy/Asc5Jf1Yvw+OgjdNH+pEXchSjupeSFLtkWuq2baI1+tXHwrofdnmmZcWKS2TAGC go+EahoXq03CUQcJKL6Mj14xOZmcF0J/BrE5NPBrEJll+Aa9/W6+zw2KdCBMHXKjAl99 B3g3LzsyviV9rYYxXQ/CyYTN+HhMx9CqzOdyZ/SQIy5Hvr7eT9afT6lX0DbSVtD3LEel hA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aam0kwg97-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:05 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1798ZU1x048635; Mon, 9 Aug 2021 04:49:04 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aam0kwg7y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:04 -0400 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 1798m90H006407; Mon, 9 Aug 2021 08:49:01 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3a9hehbp7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 08:49:00 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1798mvQZ9306520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Aug 2021 08:48:57 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27AC842047; Mon, 9 Aug 2021 08:48:57 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BEEB542049; Mon, 9 Aug 2021 08:48:56 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.151.189]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Aug 2021 08:48:56 +0000 (GMT) From: Pierre Morel To: linux-s390@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, kvm@vger.kernel.org, cohuck@redhat.com, imbrenda@linux.ibm.com, david@redhat.com Subject: [kvm-unit-tests PATCH v1 2/4] s390x: lib: Move stsi_get_fc to library Date: Mon, 9 Aug 2021 10:48:52 +0200 Message-Id: <1628498934-20735-3-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> References: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Nh934kVQdRF7iqfOP7dEwLCYVdVymWKp X-Proofpoint-ORIG-GUID: kn6CAGjlJwy41vyttdi_TnmyBtjwVgaX X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-09_01:2021-08-06,2021-08-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108090069 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It's needed in multiple tests now. Signed-off-by: Pierre Morel Reviewed-by: Claudio Imbrenda --- lib/s390x/asm/arch_def.h | 16 ++++++++++++++++ s390x/stsi.c | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 15cf7d48..57d7ddac 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -328,6 +328,22 @@ static inline int stsi(void *addr, int fc, int sel1, int sel2) return cc; } +static inline unsigned long stsi_get_fc(void *addr) +{ + register unsigned long r0 asm("0") = 0; + register unsigned long r1 asm("1") = 0; + int cc; + + asm volatile("stsi 0(%[addr])\n" + "ipm %[cc]\n" + "srl %[cc],28\n" + : "+d" (r0), [cc] "=d" (cc) + : "d" (r1), [addr] "a" (addr) + : "cc", "memory"); + assert(!cc); + return r0 >> 28; +} + static inline int servc(uint32_t command, unsigned long sccb) { int cc; diff --git a/s390x/stsi.c b/s390x/stsi.c index 87d48047..11986d13 100644 --- a/s390x/stsi.c +++ b/s390x/stsi.c @@ -71,22 +71,6 @@ static void test_priv(void) report_prefix_pop(); } -static inline unsigned long stsi_get_fc(void *addr) -{ - register unsigned long r0 asm("0") = 0; - register unsigned long r1 asm("1") = 0; - int cc; - - asm volatile("stsi 0(%[addr])\n" - "ipm %[cc]\n" - "srl %[cc],28\n" - : "+d" (r0), [cc] "=d" (cc) - : "d" (r1), [addr] "a" (addr) - : "cc", "memory"); - assert(!cc); - return r0 >> 28; -} - static void test_fc(void) { report(stsi(pagebuf, 7, 0, 0) == 3, "invalid fc"); From patchwork Mon Aug 9 08:48:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12425861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C61E3C4320A for ; Mon, 9 Aug 2021 08:49:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB11861019 for ; Mon, 9 Aug 2021 08:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234107AbhHIItr (ORCPT ); Mon, 9 Aug 2021 04:49:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:4320 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234057AbhHIIt1 (ORCPT ); Mon, 9 Aug 2021 04:49:27 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1798Xf7m125809; Mon, 9 Aug 2021 04:49:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=1amWH3ZtCJIaZPJ9kInFETzN6KlEGy7GYxiiGi+3fec=; b=XO6B7zfqLaj5FN4ZUDlXDMygq+yfufaVtOW9I2EEQC5A1ROfqxj4kzbSQ5zALeuhYWD8 VKuZk1Bfa8eoN5r/OJ0XfEnERKzzYNiS8qm+ZIlRRpjUo9IZ1KdUogNzMKOdZUTA1Xri g8s7A8aekzro9x8hzwWQPIV/jT1aosOXcDB+4HLpIm95ECK/8sUzn6mMjsBKcswED1rr SXIl1zOSvt6p4bv0qeWKR75kZwfuzXhUDl/PswZDc0FQxpG3s68QW3nMFXs3+gA/dX1d +kUQgbrQbohO/jyNA8D3el7iJZIExc+pkpqMPsl8sQ63q8TCSy5unudT6AhdhaOvYj4o TA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aa74j2fdw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:03 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1798XsrX126746; Mon, 9 Aug 2021 04:49:03 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aa74j2fd4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:03 -0400 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 1798lQ4N010998; Mon, 9 Aug 2021 08:49:01 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 3a9ht8untb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 08:49:01 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1798mvWC23986596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Aug 2021 08:48:57 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A471D42057; Mon, 9 Aug 2021 08:48:57 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A74C42045; Mon, 9 Aug 2021 08:48:57 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.151.189]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Aug 2021 08:48:57 +0000 (GMT) From: Pierre Morel To: linux-s390@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, kvm@vger.kernel.org, cohuck@redhat.com, imbrenda@linux.ibm.com, david@redhat.com Subject: [kvm-unit-tests PATCH v1 3/4] s390x: topology: check the Perform Topology Function Date: Mon, 9 Aug 2021 10:48:53 +0200 Message-Id: <1628498934-20735-4-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> References: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: U5-9dnRaObRegIeDnuphkfL3444_-lut X-Proofpoint-GUID: _RAqKBP4ZSBtWwJoRAx9RvcD4fXefl-b X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-09_01:2021-08-06,2021-08-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108090069 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We check the PTF instruction. - We do not expect to support vertical polarization. - We do not expect the Modified Topology Change Report to be pending or not at the moment the first PTF instruction with PTF_CHECK function code is done as some code already did run a polarization change may have occur. Signed-off-by: Pierre Morel --- s390x/Makefile | 1 + s390x/topology.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 91 insertions(+) create mode 100644 s390x/topology.c diff --git a/s390x/Makefile b/s390x/Makefile index 6565561b..c82b7dbf 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -24,6 +24,7 @@ tests += $(TEST_DIR)/mvpg.elf tests += $(TEST_DIR)/uv-host.elf tests += $(TEST_DIR)/edat.elf tests += $(TEST_DIR)/mvpg-sie.elf +tests += $(TEST_DIR)/topology.elf tests_binary = $(patsubst %.elf,%.bin,$(tests)) ifneq ($(HOST_KEY_DOCUMENT),) diff --git a/s390x/topology.c b/s390x/topology.c new file mode 100644 index 00000000..4146189a --- /dev/null +++ b/s390x/topology.c @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * CPU Topology + * + * Copyright (c) 2021 IBM Corp + * + * Authors: + * Pierre Morel + */ + +#include +#include +#include +#include +#include +#include +#include + +static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2))); +int machine_level; +int mnest; + +#define PTF_HORIZONTAL 0 +#define PTF_VERTICAL 1 +#define PTF_CHECK 2 + +#define PTF_ERR_NO_REASON 0 +#define PTF_ERR_ALRDY_POLARIZED 1 +#define PTF_ERR_IN_PROGRESS 2 + +static int ptf(unsigned long fc, unsigned long *rc) +{ + int cc; + + asm volatile( + " .insn rre,0xb9a20000,%1,%1\n" + " ipm %0\n" + " srl %0,28\n" + : "=d" (cc), "+d" (fc) + : "d" (fc) + : "cc"); + + *rc = fc >> 8; + return cc; +} + +static void test_ptf(void) +{ + unsigned long rc; + int cc; + + report_prefix_push("Topology Report pending"); + /* + * At this moment the topology may already have changed + * since the VM has been started. + * However, we can test if a second PTF instruction + * reports that the topology did not change since the + * preceding PFT instruction. + */ + ptf(PTF_CHECK, &rc); + cc = ptf(PTF_CHECK, &rc); + report(cc == 0, "PTF check clear"); + cc = ptf(PTF_HORIZONTAL, &rc); + report(cc == 2 && rc == PTF_ERR_ALRDY_POLARIZED, + "PTF horizontal already configured"); + cc = ptf(PTF_VERTICAL, &rc); + report(cc == 2 && rc == PTF_ERR_NO_REASON, + "PTF vertical non possible"); + + report_prefix_pop(); +} + +int main(int argc, char *argv[]) +{ + report_prefix_push("stsi"); + + if (!test_facility(11)) { + report_skip("Topology facility not present"); + goto end; + } + + report_info("Machine level %ld", stsi_get_fc(pagebuf)); + + test_ptf(); +end: + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 9e1802fd..0f84d279 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -109,3 +109,6 @@ file = edat.elf [mvpg-sie] file = mvpg-sie.elf + +[topology] +file = topology.elf From patchwork Mon Aug 9 08:48:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12425859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48835C4338F for ; Mon, 9 Aug 2021 08:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2260B61004 for ; Mon, 9 Aug 2021 08:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234092AbhHIItp (ORCPT ); Mon, 9 Aug 2021 04:49:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:7672 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234059AbhHIIt1 (ORCPT ); Mon, 9 Aug 2021 04:49:27 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1798XfYc125814; Mon, 9 Aug 2021 04:49:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=VR/Nrxf0VCY2lgTzvl5UWhJQodkU0Z/7KGYUvleT39c=; b=U/Et+s56crdDxndsGq/LT4GiMSLH3/M1uzVx4kd4E+RBvrfE4IExdRMOMJaoHNduT/PB LSvpg6YhllTkiuBSRhnasq2Cohrse1VjgLjzznTzBeaD0kUz4iy/4an7obpXFa2CwIlH r8GoLsPdD6FxvW+wzKyRfqHYLrRXk+On8ubMLxZkZS7Gzwf8haRTp+NQ/Y8HIPmbTcSy canRBJ9hMFmVTT5eskScvQtSjqTKnn/iN8RDh4vTFqIxK6oYyhGLGDDOuq5JTt8J/Q8Y BkLUe825u/ElUzezR9p4t/zq9dvIdg5c3IygQzhz+AqN5RR8FxCGpf9Dz18A1YJk86N/ Dw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aa74j2fe6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:04 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1798YiaC130418; Mon, 9 Aug 2021 04:49:04 -0400 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aa74j2fdf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 04:49:04 -0400 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1798ks6x014969; Mon, 9 Aug 2021 08:49:01 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 3a9ht8k9jw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Aug 2021 08:49:01 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1798mw1C55312794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Aug 2021 08:48:58 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EDEA4204B; Mon, 9 Aug 2021 08:48:58 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B3C6142045; Mon, 9 Aug 2021 08:48:57 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.151.189]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Aug 2021 08:48:57 +0000 (GMT) From: Pierre Morel To: linux-s390@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, kvm@vger.kernel.org, cohuck@redhat.com, imbrenda@linux.ibm.com, david@redhat.com Subject: [kvm-unit-tests PATCH v1 4/4] s390x: Topology: checking Configuration Topology Information Date: Mon, 9 Aug 2021 10:48:54 +0200 Message-Id: <1628498934-20735-5-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> References: <1628498934-20735-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: hiuOa-pQWKTgjvnfYq2aJm1y7rgOL3Uu X-Proofpoint-GUID: dcnfWGNfpYVrqlUA-gDHcAt92GFyhYBZ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-09_01:2021-08-06,2021-08-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108090069 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org STSI with function code 15 is used to store the CPU configuration topology. We check if the topology stored is coherent with the QEMU -smp parameters. The current check is done on the number of CPUs, the maximum number of CPUs, the number of sockets and the number of cores per sockets. Signed-off-by: Pierre Morel --- s390x/topology.c | 207 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 1 + 2 files changed, 208 insertions(+) diff --git a/s390x/topology.c b/s390x/topology.c index 4146189a..1eb463fd 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -19,6 +19,51 @@ static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2))); int machine_level; int mnest; +static long max_cpus; +static long cores; +static long sockets; +static long books; +static long drawers; +static long nodes; +static long ncpus; + +struct topology_core { + unsigned char nl; + unsigned char reserved0[3]; + unsigned char :5; + unsigned char d:1; + unsigned char pp:2; + unsigned char type; + unsigned short origin; + unsigned long mask; +}; + +struct topology_container { + unsigned char nl; + unsigned char reserved[6]; + unsigned char id; +}; + +union topology_entry { + unsigned char nl; + struct topology_core cpu; + struct topology_container container; +}; + +struct sysinfo_15_1_x { + unsigned char reserved0[2]; + unsigned short length; + unsigned char mag6; + unsigned char mag5; + unsigned char mag4; + unsigned char mag3; + unsigned char mag2; + unsigned char mag1; + unsigned char reserved1; + unsigned char mnest; + unsigned char reserved2[4]; + union topology_entry tle[0]; +}; #define PTF_HORIZONTAL 0 #define PTF_VERTICAL 1 @@ -70,9 +115,170 @@ static void test_ptf(void) report_prefix_pop(); } +static void check_sysinfo_15_1_x(struct sysinfo_15_1_x *info) +{ + struct topology_container *tc, *end; + struct topology_core *cpus; + int nb_nl0 = 0, nb_nl1 = 0, nb_nl2 = 0, nb_nl3 = 0; + + if (mnest > 5) + report(info->mag6 == 0, "topology level 6"); + if (mnest > 4) + report(info->mag5 == nodes, "Maximum number of nodes"); + if (mnest > 3) + report(info->mag4 == drawers, "Maximum number of drawers"); + if (mnest > 2) + report(info->mag3 == books, "Maximum number of book"); + + /* Both levels 2 and 1 are always valid */ + report(info->mag2 == sockets, "Maximum number of sockets"); + report(info->mag1 == cores, "Maximum number of cores"); + + tc = (void *)&info->tle[0]; + end = (struct topology_container *)((unsigned long)info + info->length); + + while (tc < end) { + switch (tc->nl) { + case 3: + report_info("drawer: %d %d", tc->nl, tc->id); + nb_nl3++; + break; + case 2: + report_info("book : %d %d", tc->nl, tc->id); + nb_nl2++; + break; + case 1: + report_info("socket: %d %d", tc->nl, tc->id); + nb_nl1++; + break; + case 0: + cpus = (struct topology_core *) tc; + report_info("cpu type %02x d: %d pp: %d", cpus->type, cpus->d, cpus->pp); + report_info("origin : %04x mask %016lx", cpus->origin, cpus->mask); + tc++; + nb_nl0++; + break; + default: + report_abort("Unexpected TL Entry: tle->nl: %d", tc->nl); + return; + } + tc++; + } + /* + * As we accept only 1 type of CPU, and only horizontal and dedicated CPUs + * We expect max_cpus / cores CPU entries + */ + report(nb_nl0 == (1 + (ncpus - 1) / cores), + "Check count of cores: %d %ld", nb_nl0, ncpus / cores); + /* We expect the same count of sockets and CPU entries */ + report(nb_nl1 == nb_nl0, "Check count of sockets"); + if (mnest > 2) + report(nb_nl2 == nb_nl1 / sockets, "Checks count of books"); + if (mnest > 3) + report(nb_nl3 == nb_nl2 / books, "Checks count of drawers"); +} + +static void test_stsi(void) +{ + int ret; + + report_info("VM Level: %ld", stsi_get_fc(pagebuf)); + + mnest = sclp_get_stsi_parm(); + /* If the STSI parm is 0, the maximum MNEST for STSI is 2 */ + if (!mnest) + mnest = 2; + report_info("SCLP MNEST: %d", mnest); + + ret = sclp_get_cpu_num(); + report_info("SCLP CPU : %d", ret); + + ret = stsi(pagebuf, 15, 1, 2); + report(!ret, "valid stsi 15.1.2"); + if (!ret) + check_sysinfo_15_1_x((struct sysinfo_15_1_x *)pagebuf); + else + report_info(" ret: %d", ret); + + if (mnest < 3) { + report(stsi(pagebuf, 15, 1, 3) == 3, "invalid stsi 15.1.3"); + } else { + report(stsi(pagebuf, 15, 1, 3) == 0, "valid stsi 15.1.3"); + check_sysinfo_15_1_x((struct sysinfo_15_1_x *)pagebuf); + } + + if (mnest < 4) { + report(stsi(pagebuf, 15, 1, 4) == 3, "invalid stsi 15.1.4"); + } else { + report(stsi(pagebuf, 15, 1, 4) == 0, "valid stsi 15.1.4"); + check_sysinfo_15_1_x((struct sysinfo_15_1_x *)pagebuf); + } + + if (mnest < 5) { + report(stsi(pagebuf, 15, 1, 5) == 3, "invalid stsi 15.1.5"); + } else { + report(stsi(pagebuf, 15, 1, 5) == 0, "valid stsi 15.1.5"); + check_sysinfo_15_1_x((struct sysinfo_15_1_x *)pagebuf); + } + + if (mnest < 6) { + report(stsi(pagebuf, 15, 1, 6) == 3, "invalid stsi 15.1.6"); + } else { + report(stsi(pagebuf, 15, 1, 6) == 0, "valid stsi 15.1.6"); + check_sysinfo_15_1_x((struct sysinfo_15_1_x *)pagebuf); + } +} + +static void parse_topology_args(int argc, char **argv) +{ + int i; + + for (i = 1; i < argc; i++) { + if (!strcmp("-c", argv[i])) { + i++; + if (i >= argc) + report_abort("-c (cores) needs a parameter"); + cores = atol(argv[i]); + } else if (!strcmp("-s", argv[i])) { + i++; + if (i >= argc) + report_abort("-s (sockets) needs a parameter"); + sockets = atol(argv[i]); + } else if (!strcmp("-b", argv[i])) { + i++; + if (i >= argc) + report_abort("-b (books) needs a parameter"); + books = atol(argv[i]); + } else if (!strcmp("-d", argv[i])) { + i++; + if (i >= argc) + report_abort("-d (drawers) needs a parameter"); + drawers = atol(argv[i]); + } else if (!strcmp("-n", argv[i])) { + i++; + if (i >= argc) + report_abort("-n (nodes) needs a parameter"); + nodes = atol(argv[i]); + } + } + if (!cores) + cores = 1; + if (!sockets) + sockets = 1; + if (!books) + books = 1; + if (!drawers) + drawers = 1; + if (!nodes) + nodes = 1; + max_cpus = cores * sockets * books * drawers * nodes; + ncpus = smp_query_num_cpus(); +} + int main(int argc, char *argv[]) { report_prefix_push("stsi"); + parse_topology_args(argc, argv); if (!test_facility(11)) { report_skip("Topology facility not present"); @@ -82,6 +288,7 @@ int main(int argc, char *argv[]) report_info("Machine level %ld", stsi_get_fc(pagebuf)); test_ptf(); + test_stsi(); end: return report_summary(); } diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 0f84d279..390e8398 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -112,3 +112,4 @@ file = mvpg-sie.elf [topology] file = topology.elf +extra_params=-smp 5,sockets=4,cores=4,maxcpus=16 -append "-n 5 -s 4 -c 4 -m 16"