From patchwork Fri Jan 28 18:54:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12728955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 530B9C433EF for ; Fri, 28 Jan 2022 18:54:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240035AbiA1Sy5 (ORCPT ); Fri, 28 Jan 2022 13:54:57 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:25148 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230165AbiA1Sy4 (ORCPT ); Fri, 28 Jan 2022 13:54:56 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SI8veY021042 for ; Fri, 28 Jan 2022 18:54:56 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=lWT7zeCTqvdk1n/X5pH1b3V0Z8A8x/CzYm86bdpOw4o=; b=l9cOxb+qXsRD9wF9NS1+mYleupMvVF68qMXS13plTDq1BxCt5lq36p46zpjwtji+MubA h4ZfOCXsgF6ieDjVZgtddaSmz+8osyc8Vde4oWVlxpkeS3oYbgZOpR5Zi10us8Hz5U1E G5vq+55FL2dRdUpbbveTGtxnmc81wEb7RiasyKKdbGutI2+FxIH4Bk2d80svSfZdOIxc 7vsUirM5drtbGtg0UhXLj/0jbiIJZQiWqh3lcP7t7VllYhAA9+BvhV1p7HI8n4B0vhhp cFdc+PEt7wCHj1I+QGgq8+wg6+CnNyliEXnGRLA5CkXC4TbtYK5W3R/U8hR3NmKinmgn zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dvhm3pkcf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Jan 2022 18:54:56 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20SIdnp8030665 for ; Fri, 28 Jan 2022 18:54:55 GMT 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 3dvhm3pkc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:55 +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 20SIqBQJ006896; Fri, 28 Jan 2022 18:54:54 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3dr9ja45q6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:53 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20SIsoVD36176292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 18:54:50 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A1AE1A4062; Fri, 28 Jan 2022 18:54:50 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 332C5A4068; Fri, 28 Jan 2022 18:54:50 +0000 (GMT) Received: from p-imbrenda.bredband2.com (unknown [9.145.7.17]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Jan 2022 18:54:50 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, david@redhat.com, nrb@linux.ibm.com, scgl@linux.ibm.com, seiden@linux.ibm.com Subject: [kvm-unit-tests PATCH v1 1/5] lib: s390x: smp: add functions to work with CPU indexes Date: Fri, 28 Jan 2022 19:54:45 +0100 Message-Id: <20220128185449.64936-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128185449.64936-1-imbrenda@linux.ibm.com> References: <20220128185449.64936-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: u71NISVQH70C2aoEVNzvQV-BgNpj0YOL X-Proofpoint-ORIG-GUID: SuK1S0kHCKkZKRbE57ccIwCrjtHdET8w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-28_05,2022-01-28_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 mlxlogscore=938 suspectscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201280108 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Knowing the number of active CPUs is not enough to know which ones are active. This patch adds 2 new functions: * smp_cpu_addr_from_idx to get the CPU address from the index * smp_cpu_from_idx allows to retrieve the struct cpu from the index This makes it possible for tests to avoid hardcoding the CPU addresses. It is useful in cases where the address and the index might not match. Signed-off-by: Claudio Imbrenda --- lib/s390x/smp.h | 2 ++ lib/s390x/smp.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/s390x/smp.h b/lib/s390x/smp.h index a2609f11..69aa4003 100644 --- a/lib/s390x/smp.h +++ b/lib/s390x/smp.h @@ -37,6 +37,7 @@ struct cpu_status { int smp_query_num_cpus(void); struct cpu *smp_cpu_from_addr(uint16_t addr); +struct cpu *smp_cpu_from_idx(uint16_t addr); bool smp_cpu_stopped(uint16_t addr); bool smp_sense_running_status(uint16_t addr); int smp_cpu_restart(uint16_t addr); @@ -47,5 +48,6 @@ int smp_cpu_destroy(uint16_t addr); int smp_cpu_setup(uint16_t addr, struct psw psw); void smp_teardown(void); void smp_setup(void); +uint16_t smp_cpu_addr_from_idx(uint16_t idx); #endif diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index b753eab5..64c647ec 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -46,6 +46,18 @@ struct cpu *smp_cpu_from_addr(uint16_t addr) return NULL; } +struct cpu *smp_cpu_from_idx(uint16_t idx) +{ + assert(idx < smp_query_num_cpus()); + return &cpus[idx]; +} + +uint16_t smp_cpu_addr_from_idx(uint16_t idx) +{ + assert(idx < smp_query_num_cpus()); + return cpus[idx].addr; +} + bool smp_cpu_stopped(uint16_t addr) { uint32_t status; From patchwork Fri Jan 28 18:54:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12728957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF47FC433EF for ; Fri, 28 Jan 2022 18:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350710AbiA1SzA (ORCPT ); Fri, 28 Jan 2022 13:55:00 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:30916 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343655AbiA1Sy6 (ORCPT ); Fri, 28 Jan 2022 13:54:58 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SIC18p013415 for ; Fri, 28 Jan 2022 18:54:57 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=ytYdt8JSQZ6igAZXiSg3pm0ngS8+p3zFK/Fy+IuNoT8=; b=UhRjU68Fhc1nGyTeNoEds5gm7hPhE2pSXYyTYdZXBoaCvf4rob/Pbdq9Qxjneh9uUENb I0Sblm+Zd75bI1yFdBQVOsBqZ00Kaqn32jvksgc+2xlNHKuLjs1MzSaQMXvHKmLeaJcI ZoIvF1SdWO5talTdDRDiKSbLSdPNCzcxD6i1RyXeFr1K4lB8PzgoqXj7zy4aDKlmvi8u ZShJ4k5K1xUuhf9iAsbgBDijtmu9aXMK9rLyDwRV3LNvTVPKyic0fiT9wY5Iyn4O4OgV m07jy1Rnx/BAsgHALRUFm2cgf41/g9gBpDjoILajS+gpD9VaJDM9g2RfVH22NboFTc5w og== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dvgqwqbmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Jan 2022 18:54:57 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20SIdiQu008113 for ; Fri, 28 Jan 2022 18:54:57 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dvgqwqbm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:57 +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 20SIrJWc013645; Fri, 28 Jan 2022 18:54:55 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 3dr9ja9grd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:54 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20SIspS042598690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 18:54:51 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31BD7A4068; Fri, 28 Jan 2022 18:54:51 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9016A405C; Fri, 28 Jan 2022 18:54:50 +0000 (GMT) Received: from p-imbrenda.bredband2.com (unknown [9.145.7.17]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Jan 2022 18:54:50 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, david@redhat.com, nrb@linux.ibm.com, scgl@linux.ibm.com, seiden@linux.ibm.com Subject: [kvm-unit-tests PATCH v1 2/5] lib: s390x: smp: guarantee that boot CPU has index 0 Date: Fri, 28 Jan 2022 19:54:46 +0100 Message-Id: <20220128185449.64936-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128185449.64936-1-imbrenda@linux.ibm.com> References: <20220128185449.64936-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: q_om0z0ybW7LA-s9PYMK6pCtGpvIS9cn X-Proofpoint-GUID: tMc0Ag8nLrxyYKt_rrdp46RQqHlgv3Nw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-28_05,2022-01-28_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 adultscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201280108 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Guarantee that the boot CPU has index 0. This simplifies the implementation of tests that require multiple CPUs. Also fix a small bug in the allocation of the cpus array. Signed-off-by: Claudio Imbrenda Fixes: f77c0515 ("s390x: Add initial smp code") Fixes: 52076a63 ("s390x: Consolidate sclp read info") --- lib/s390x/smp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index 64c647ec..01f513f0 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -25,7 +25,6 @@ #include "sclp.h" static struct cpu *cpus; -static struct cpu *cpu0; static struct spinlock lock; extern void smp_cpu_setup_state(void); @@ -81,7 +80,7 @@ static int smp_cpu_stop_nolock(uint16_t addr, bool store) uint8_t order = store ? SIGP_STOP_AND_STORE_STATUS : SIGP_STOP; cpu = smp_cpu_from_addr(addr); - if (!cpu || cpu == cpu0) + if (!cpu || addr == cpus[0].addr) return -1; if (sigp_retry(addr, order, 0, NULL)) @@ -205,7 +204,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw) sigp_retry(cpu->addr, SIGP_SET_PREFIX, (unsigned long )lc, NULL); /* Copy all exception psws. */ - memcpy(lc, cpu0->lowcore, 512); + memcpy(lc, cpus[0].lowcore, 512); /* Setup stack */ cpu->stack = (uint64_t *)alloc_pages(2); @@ -263,15 +262,16 @@ void smp_setup(void) if (num > 1) printf("SMP: Initializing, found %d cpus\n", num); - cpus = calloc(num, sizeof(cpus)); + cpus = calloc(num, sizeof(*cpus)); for (i = 0; i < num; i++) { cpus[i].addr = entry[i].address; cpus[i].active = false; if (entry[i].address == cpu0_addr) { - cpu0 = &cpus[i]; - cpu0->stack = stackptr; - cpu0->lowcore = (void *)0; - cpu0->active = true; + cpus[i].addr = cpus[0].addr; + cpus[0].addr = cpu0_addr; + cpus[0].stack = stackptr; + cpus[0].lowcore = (void *)0; + cpus[0].active = true; } } spin_unlock(&lock); From patchwork Fri Jan 28 18:54:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12728959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6205DC4332F for ; Fri, 28 Jan 2022 18:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350712AbiA1SzA (ORCPT ); Fri, 28 Jan 2022 13:55:00 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42598 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230165AbiA1Sy5 (ORCPT ); Fri, 28 Jan 2022 13:54:57 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SI8xHa016527 for ; Fri, 28 Jan 2022 18:54:57 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=NzJpwTyyUVzkIrcThbWkaOwDmw1HXIpz0tRGoXHg2Xw=; b=J+MPYK3PO4nyfd14CR+Bs1y4p5uIcjQRs/FcuvOkcIL736Dx7/CPLp73F3oQjthz5+RM tUynifLvnFL4O5E22ttgLwjfuA9z1jG6iShX1G8xxS4dtpyz+UF5EqvFBt7PZ/4fYEht JJlKeuf3NG50nkL1EWxLVx5Pp+5xy2zblDnC8jMWwWRIB+4PF//ZyKEwfY/jf20BqORq fvKZJj/t3TIbV7Zw8vObtXG95ji4vdhhusfs6iN9Vd7ohIJubyC4a8B3IbxmWHg1JH59 DC5K3cKIfImccb8+xmDtT0aLulcPkghbSCX/NbYg87fH7AnUDmsyMAEh2Sfi+r1ZTbsI Dg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dvmpthrkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Jan 2022 18:54:57 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20SISUU0012200 for ; Fri, 28 Jan 2022 18:54:57 GMT 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 3dvmpthrju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:57 +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 20SIqB7Y006899; Fri, 28 Jan 2022 18:54:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03ams.nl.ibm.com with ESMTP id 3dr9ja45q7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:54 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20SIspfO20382028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 18:54:51 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAD95A4064; Fri, 28 Jan 2022 18:54:51 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 481D1A406B; Fri, 28 Jan 2022 18:54:51 +0000 (GMT) Received: from p-imbrenda.bredband2.com (unknown [9.145.7.17]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Jan 2022 18:54:51 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, david@redhat.com, nrb@linux.ibm.com, scgl@linux.ibm.com, seiden@linux.ibm.com Subject: [kvm-unit-tests PATCH v1 3/5] s390x: smp: avoid hardcoded CPU addresses Date: Fri, 28 Jan 2022 19:54:47 +0100 Message-Id: <20220128185449.64936-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128185449.64936-1-imbrenda@linux.ibm.com> References: <20220128185449.64936-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: xS_9zS0amJNAJxElZy0PqZfh2wLVLpap X-Proofpoint-GUID: BT_I8FRLoPeQhPOJggbE4Tte1hgy-imX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-28_06,2022-01-28_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 spamscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201280108 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use the recently introduced functions to work with CPU indexes, instead of using hardcoded values. This makes the test more portable. Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 83 ++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/s390x/smp.c b/s390x/smp.c index 1bbe4c31..da668ca6 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -18,6 +18,7 @@ #include #include +static uint16_t cpu0, cpu1; static int testflag = 0; static void wait_for_flag(void) @@ -45,7 +46,7 @@ static void test_start(void) psw.addr = (unsigned long)test_func; set_flag(0); - smp_cpu_start(1, psw); + smp_cpu_start(cpu1, psw); wait_for_flag(); report_pass("start"); } @@ -56,16 +57,16 @@ static void test_start(void) */ static void test_restart(void) { - struct cpu *cpu = smp_cpu_from_addr(1); + struct cpu *cpu = smp_cpu_from_idx(1); struct lowcore *lc = cpu->lowcore; lc->restart_new_psw.mask = extract_psw_mask(); lc->restart_new_psw.addr = (unsigned long)test_func; /* Make sure cpu is running */ - smp_cpu_stop(0); + smp_cpu_stop(cpu0); set_flag(0); - smp_cpu_restart(1); + smp_cpu_restart(cpu1); wait_for_flag(); /* @@ -73,44 +74,44 @@ static void test_restart(void) * restart function. */ set_flag(0); - smp_cpu_restart(1); + smp_cpu_restart(cpu1); wait_for_flag(); report_pass("restart while running"); } static void test_stop(void) { - smp_cpu_stop(1); + smp_cpu_stop(cpu1); /* * The smp library waits for the CPU to shut down, but let's * also do it here, so we don't rely on the library * implementation */ - while (!smp_cpu_stopped(1)) {} + while (!smp_cpu_stopped(cpu1)) {} report_pass("stop"); } static void test_stop_store_status(void) { - struct cpu *cpu = smp_cpu_from_addr(1); + struct cpu *cpu = smp_cpu_from_idx(1); struct lowcore *lc = (void *)0x0; report_prefix_push("stop store status"); report_prefix_push("running"); - smp_cpu_restart(1); + smp_cpu_restart(cpu1); lc->prefix_sa = 0; lc->grs_sa[15] = 0; - smp_cpu_stop_store_status(1); + smp_cpu_stop_store_status(cpu1); mb(); report(lc->prefix_sa == (uint32_t)(uintptr_t)cpu->lowcore, "prefix"); report(lc->grs_sa[15], "stack"); - report(smp_cpu_stopped(1), "cpu stopped"); + report(smp_cpu_stopped(cpu1), "cpu stopped"); report_prefix_pop(); report_prefix_push("stopped"); lc->prefix_sa = 0; lc->grs_sa[15] = 0; - smp_cpu_stop_store_status(1); + smp_cpu_stop_store_status(cpu1); mb(); report(lc->prefix_sa == (uint32_t)(uintptr_t)cpu->lowcore, "prefix"); report(lc->grs_sa[15], "stack"); @@ -128,8 +129,8 @@ static void test_store_status(void) memset(status, 0, PAGE_SIZE * 2); report_prefix_push("running"); - smp_cpu_restart(1); - sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, &r); + smp_cpu_restart(cpu1); + sigp(cpu1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, &r); report(r == SIGP_STATUS_INCORRECT_STATE, "incorrect state"); report(!memcmp(status, (void *)status + PAGE_SIZE, PAGE_SIZE), "status not written"); @@ -137,13 +138,13 @@ static void test_store_status(void) memset(status, 0, PAGE_SIZE); report_prefix_push("stopped"); - smp_cpu_stop(1); - sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL); + smp_cpu_stop(cpu1); + sigp(cpu1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL); while (!status->prefix) { mb(); } report_pass("status written"); free_pages(status); report_prefix_pop(); - smp_cpu_stop(1); + smp_cpu_stop(cpu1); report_prefix_pop(); } @@ -173,12 +174,12 @@ static void test_ecall(void) report_prefix_push("ecall"); set_flag(0); - smp_cpu_start(1, psw); + smp_cpu_start(cpu1, psw); wait_for_flag(); set_flag(0); - sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); + sigp(cpu1, SIGP_EXTERNAL_CALL, 0, NULL); wait_for_flag(); - smp_cpu_stop(1); + smp_cpu_stop(cpu1); report_prefix_pop(); } @@ -207,12 +208,12 @@ static void test_emcall(void) report_prefix_push("emcall"); set_flag(0); - smp_cpu_start(1, psw); + smp_cpu_start(cpu1, psw); wait_for_flag(); set_flag(0); - sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL); + sigp(cpu1, SIGP_EMERGENCY_SIGNAL, 0, NULL); wait_for_flag(); - smp_cpu_stop(1); + smp_cpu_stop(cpu1); report_prefix_pop(); } @@ -220,11 +221,11 @@ static void test_sense_running(void) { report_prefix_push("sense_running"); /* we (CPU0) are running */ - report(smp_sense_running_status(0), "CPU0 sense claims running"); + report(smp_sense_running_status(cpu0), "CPU0 sense claims running"); /* stop the target CPU (CPU1) to speed up the not running case */ - smp_cpu_stop(1); + smp_cpu_stop(cpu1); /* Make sure to have at least one time with a not running indication */ - while(smp_sense_running_status(1)); + while(smp_sense_running_status(cpu1)); report_pass("CPU1 sense claims not running"); report_prefix_pop(); } @@ -250,11 +251,11 @@ static void test_reset_initial(void) report_prefix_push("reset initial"); set_flag(0); - smp_cpu_start(1, psw); + smp_cpu_start(cpu1, psw); wait_for_flag(); - sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL); - sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL); + sigp_retry(cpu1, SIGP_INITIAL_CPU_RESET, 0, NULL); + sigp(cpu1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL); report_prefix_push("clear"); report(!status->psw.mask && !status->psw.addr, "psw"); @@ -273,7 +274,7 @@ static void test_reset_initial(void) report(status->crs[14] == 0xC2000000UL, "cr14 == 0xC2000000"); report_prefix_pop(); - report(smp_cpu_stopped(1), "cpu stopped"); + report(smp_cpu_stopped(cpu1), "cpu stopped"); free_pages(status); report_prefix_pop(); } @@ -299,16 +300,16 @@ static void test_reset(void) psw.addr = (unsigned long)test_func; report_prefix_push("cpu reset"); - sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL); - sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); - smp_cpu_start(1, psw); + sigp(cpu1, SIGP_EMERGENCY_SIGNAL, 0, NULL); + sigp(cpu1, SIGP_EXTERNAL_CALL, 0, NULL); + smp_cpu_start(cpu1, psw); - sigp_retry(1, SIGP_CPU_RESET, 0, NULL); - report(smp_cpu_stopped(1), "cpu stopped"); + sigp_retry(cpu1, SIGP_CPU_RESET, 0, NULL); + report(smp_cpu_stopped(cpu1), "cpu stopped"); set_flag(0); psw.addr = (unsigned long)test_local_ints; - smp_cpu_start(1, psw); + smp_cpu_start(cpu1, psw); wait_for_flag(); report_pass("local interrupts cleared"); report_prefix_pop(); @@ -324,11 +325,15 @@ int main(void) goto done; } + /* the boot CPU is guaranteed to have index 0 */ + cpu0 = stap(); + cpu1 = smp_cpu_addr_from_idx(1); + /* Setting up the cpu to give it a stack and lowcore */ psw.mask = extract_psw_mask(); psw.addr = (unsigned long)test_func; - smp_cpu_setup(1, psw); - smp_cpu_stop(1); + smp_cpu_setup(cpu1, psw); + smp_cpu_stop(cpu1); test_start(); test_restart(); @@ -340,7 +345,7 @@ int main(void) test_sense_running(); test_reset(); test_reset_initial(); - smp_cpu_destroy(1); + smp_cpu_destroy(cpu1); done: report_prefix_pop(); From patchwork Fri Jan 28 18:54:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12728958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A9F8C433FE for ; Fri, 28 Jan 2022 18:55:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350723AbiA1SzB (ORCPT ); Fri, 28 Jan 2022 13:55:01 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39774 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344153AbiA1Sy6 (ORCPT ); Fri, 28 Jan 2022 13:54:58 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SIF2Ng024039 for ; Fri, 28 Jan 2022 18:54:58 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=8LRcpaYWnh+vblcnE4s5y8pNDiJL0x77e8LLl/2dly0=; b=cfM7vHEq9vM34KmcjmTXspcKekaJa7Wre+I/JZFwfHYDzMm2B9Bud/SvWGx8tdE1JUNy NYpjhOSsQYWMZRkDLwOQyVoZbDa9RYMH19l55LJ+by6qctkF3rmvemoKOGbCywBumAVQ 7CMhK37W6PzEI4Y2nE9PdfE9tUvJdigw/4y02ae4Lknu1wtrGGF2A1eYsoJjLUZ7tp99 iJ5txV6N8pOB7/cioz5RE1KJMvZAGN/wxHfx7uzI8Zzo/MPrr9yZIF7PEyiKTCyLfkIH nUuxh/oN9dyxuVmhbxR+41tXrnQkk2zNGhWNajVlwnDGb9QrIZ7UXEeKyIRQ9SYnJOeq 1g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dvn4n97p5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Jan 2022 18:54:57 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20SIs9qu006330 for ; Fri, 28 Jan 2022 18:54:57 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dvn4n97nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:57 +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 20SIrIAK013543; Fri, 28 Jan 2022 18:54:55 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 3dr9ja9grf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:55 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20SIsqK743516214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 18:54:52 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49E51A4065; Fri, 28 Jan 2022 18:54:52 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CDEC8A4066; Fri, 28 Jan 2022 18:54:51 +0000 (GMT) Received: from p-imbrenda.bredband2.com (unknown [9.145.7.17]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Jan 2022 18:54:51 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, david@redhat.com, nrb@linux.ibm.com, scgl@linux.ibm.com, seiden@linux.ibm.com Subject: [kvm-unit-tests PATCH v1 4/5] s390x: firq: avoid hardcoded CPU addresses Date: Fri, 28 Jan 2022 19:54:48 +0100 Message-Id: <20220128185449.64936-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128185449.64936-1-imbrenda@linux.ibm.com> References: <20220128185449.64936-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VAKIUKekm6vTA4rZQt_krNMiQxapek3h X-Proofpoint-ORIG-GUID: 2euCgerECIsfDuwm2A9dB32kln_hRNTY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-28_06,2022-01-28_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 mlxscore=0 malwarescore=0 clxscore=1015 mlxlogscore=959 lowpriorityscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201280108 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use the recently introduced smp_cpu_addr_from_idx to discover the addresses of the CPUs to use in the test, instead of using hardcoded values. This makes the test more portable. Signed-off-by: Claudio Imbrenda --- s390x/firq.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/s390x/firq.c b/s390x/firq.c index fb9a2906..14d0d102 100644 --- a/s390x/firq.c +++ b/s390x/firq.c @@ -33,6 +33,7 @@ static void wait_for_sclp_int(void) */ static void test_wait_state_delivery(void) { + uint16_t cpu1, cpu2; struct psw psw; SCCBHeader *h; int ret; @@ -44,16 +45,14 @@ static void test_wait_state_delivery(void) goto out; } - if (stap()) { - report_skip("need to start on CPU #0"); - goto out; - } + cpu1 = smp_cpu_addr_from_idx(1); + cpu2 = smp_cpu_addr_from_idx(2); /* * We want CPU #2 to be stopped. This should be the case at this * point, however, we want to sense if it even exists as well. */ - ret = smp_cpu_stop(2); + ret = smp_cpu_stop(cpu2); if (ret) { report_skip("CPU #2 not found"); goto out; @@ -68,10 +67,10 @@ static void test_wait_state_delivery(void) /* Start CPU #1 and let it wait for the interrupt. */ psw.mask = extract_psw_mask(); psw.addr = (unsigned long)wait_for_sclp_int; - ret = smp_cpu_setup(1, psw); + ret = smp_cpu_setup(cpu1, psw); if (ret) { sclp_clear_busy(); - report_skip("cpu #1 not found"); + report_skip("CPU #1 not found"); goto out; } @@ -85,7 +84,7 @@ static void test_wait_state_delivery(void) * will take some time as well and smp_cpu_setup() returns when we're * either already in wait_for_sclp_int() or just about to execute it. */ - while(smp_sense_running_status(1)); + while(smp_sense_running_status(cpu1)); h = alloc_pages_flags(0, AREA_DMA31); h->length = 4096; @@ -106,7 +105,7 @@ static void test_wait_state_delivery(void) out_destroy: free_page(h); - smp_cpu_destroy(1); + smp_cpu_destroy(cpu1); out: report_prefix_pop(); } From patchwork Fri Jan 28 18:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12728960 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 165DDC433EF for ; Fri, 28 Jan 2022 18:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350725AbiA1SzC (ORCPT ); Fri, 28 Jan 2022 13:55:02 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:21380 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1344428AbiA1Sy7 (ORCPT ); Fri, 28 Jan 2022 13:54:59 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SI94hl028721 for ; Fri, 28 Jan 2022 18:54:58 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=MmdyLm6rXn33C0pvWqpMEaXEfi3rxXcbXk7aY2y3fn8=; b=nA7P+g8rkJL91kL8yq1dXCoLXrGqe60ABU2ecEzLe+WfQqGPDbPBK5i56TPNKmIKJSYD X2E8fbiV2TdsWJcabU25zVvlj0l7C9GtrPD5qgJ7ZIvYEVkTy0WiYikmEiStb6X+/Y2J kj5cOx8/dr2crLopRYo3Yu+Y9vJlL3CVesSmCJFD5QQsCCiVUnJ1hS9U9LPfh+w5Wp+t RwhwsqhgrPPaYe94QZ2Cx1FQiTT6b7dc2VLG/O0fSxTOTixgsBFQI0S4jVenQuL4HsKT ndPi8Sku9Zldta3x6JtKzvQDcRbaCWIz9fVf8zMwe171RdkFV3wuG5yJiJnDuRJGESNn zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dvgqj77b0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Jan 2022 18:54:58 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20SIhQBI020273 for ; Fri, 28 Jan 2022 18:54:57 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com with ESMTP id 3dvgqj77ak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:57 +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 20SIqOqn030490; Fri, 28 Jan 2022 18:54:56 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 3dr9ja9hs9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jan 2022 18:54:55 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20SIsq7j40501660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 18:54:52 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D5EADA405C; Fri, 28 Jan 2022 18:54:52 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D986A4068; Fri, 28 Jan 2022 18:54:52 +0000 (GMT) Received: from p-imbrenda.bredband2.com (unknown [9.145.7.17]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Jan 2022 18:54:52 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, david@redhat.com, nrb@linux.ibm.com, scgl@linux.ibm.com, seiden@linux.ibm.com Subject: [kvm-unit-tests PATCH v1 5/5] s390x: skrf: avoid hardcoded CPU addresses Date: Fri, 28 Jan 2022 19:54:49 +0100 Message-Id: <20220128185449.64936-6-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128185449.64936-1-imbrenda@linux.ibm.com> References: <20220128185449.64936-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ayn7oP-tLtMHovjw9nprOFbhrO6fTsJA X-Proofpoint-ORIG-GUID: pAWIUB9dIeL04_pzen-4bF-i-TC70ZAH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-28_05,2022-01-28_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201280108 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use the recently introduced smp_cpu_addr_from_idx to discover the addresses of the CPUs to use in the test, instead of using hardcoded values. This makes the test more portable. Signed-off-by: Claudio Imbrenda --- s390x/skrf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/s390x/skrf.c b/s390x/skrf.c index ca4efbf1..bd0abba0 100644 --- a/s390x/skrf.c +++ b/s390x/skrf.c @@ -164,6 +164,7 @@ static void test_exception_ext_new(void) .mask = extract_psw_mask(), .addr = (unsigned long)ecall_setup }; + uint16_t cpu1; report_prefix_push("exception external new"); if (smp_query_num_cpus() < 2) { @@ -171,14 +172,15 @@ static void test_exception_ext_new(void) report_prefix_pop(); return; } + cpu1 = smp_cpu_addr_from_idx(1); - smp_cpu_setup(1, psw); + smp_cpu_setup(cpu1, psw); wait_for_flag(); set_flag(0); - sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); + sigp(cpu1, SIGP_EXTERNAL_CALL, 0, NULL); wait_for_flag(); - smp_cpu_stop(1); + smp_cpu_stop(cpu1); report_prefix_pop(); }