From patchwork Fri Jan 17 10:46:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338727 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1BB513A0 for ; Fri, 17 Jan 2020 10:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 871FA2082F for ; Fri, 17 Jan 2020 10:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727007AbgAQKqy (ORCPT ); Fri, 17 Jan 2020 05:46:54 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58600 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbgAQKqy (ORCPT ); Fri, 17 Jan 2020 05:46:54 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAc5qn017754 for ; Fri, 17 Jan 2020 05:46:53 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xk0qt0s34-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:46:53 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:46:51 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:46:49 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAkmaD51773676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:46:48 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FF67AE053; Fri, 17 Jan 2020 10:46:48 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC11FAE045; Fri, 17 Jan 2020 10:46:46 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:46:46 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 1/9] s390x: smp: Cleanup smp.c Date: Fri, 17 Jan 2020 05:46:32 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-4275-0000-0000-0000039872A5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-4276-0000-0000-000038AC73BE Message-Id: <20200117104640.1983-2-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=1 mlxlogscore=991 impostorscore=0 adultscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Let's remove a lot of badly formatted code by introducing the wait_for_flag() function. Also let's remove some stray spaces. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Reviewed-by: David Hildenbrand --- s390x/smp.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/s390x/smp.c b/s390x/smp.c index ab7e46c..8d8e3a5 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -22,6 +22,13 @@ static int testflag = 0; +static void wait_for_flag(void) +{ + while (!testflag) { + mb(); + } +} + static void cpu_loop(void) { for (;;) {} @@ -30,20 +37,17 @@ static void cpu_loop(void) static void test_func(void) { testflag = 1; - mb(); cpu_loop(); } static void test_start(void) { struct psw psw; - psw.mask = extract_psw_mask(); + psw.mask = extract_psw_mask(); psw.addr = (unsigned long)test_func; smp_cpu_setup(1, psw); - while (!testflag) { - mb(); - } + wait_for_flag(); report(1, "start"); } @@ -115,24 +119,24 @@ static void ecall(void) testflag = 1; while (lc->ext_int_code != 0x1202) { mb(); } report(1, "ecall"); - testflag= 1; + testflag = 1; } static void test_ecall(void) { struct psw psw; - psw.mask = extract_psw_mask(); + psw.mask = extract_psw_mask(); psw.addr = (unsigned long)ecall; report_prefix_push("ecall"); - testflag= 0; + testflag = 0; smp_cpu_destroy(1); smp_cpu_setup(1, psw); - while (!testflag) { mb(); } - testflag= 0; + wait_for_flag(); + testflag = 0; sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); - while(!testflag) {mb();} + wait_for_flag(); smp_cpu_stop(1); report_prefix_pop(); } @@ -147,7 +151,7 @@ static void emcall(void) mask = extract_psw_mask(); mask |= PSW_MASK_EXT; load_psw_mask(mask); - testflag= 1; + testflag = 1; while (lc->ext_int_code != 0x1201) { mb(); } report(1, "ecall"); testflag = 1; @@ -156,18 +160,18 @@ static void emcall(void) static void test_emcall(void) { struct psw psw; - psw.mask = extract_psw_mask(); + psw.mask = extract_psw_mask(); psw.addr = (unsigned long)emcall; report_prefix_push("emcall"); - testflag= 0; + testflag = 0; smp_cpu_destroy(1); smp_cpu_setup(1, psw); - while (!testflag) { mb(); } - testflag= 0; + wait_for_flag(); + testflag = 0; sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL); - while(!testflag) { mb(); } + wait_for_flag(); smp_cpu_stop(1); report_prefix_pop(); } @@ -177,7 +181,7 @@ static void test_reset_initial(void) struct cpu_status *status = alloc_pages(0); struct psw psw; - psw.mask = extract_psw_mask(); + psw.mask = extract_psw_mask(); psw.addr = (unsigned long)test_func; report_prefix_push("reset initial"); @@ -208,7 +212,7 @@ static void test_reset(void) { struct psw psw; - psw.mask = extract_psw_mask(); + psw.mask = extract_psw_mask(); psw.addr = (unsigned long)test_func; report_prefix_push("cpu reset"); From patchwork Fri Jan 17 10:46:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E95D713A0 for ; Fri, 17 Jan 2020 10:46:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1E002073A for ; Fri, 17 Jan 2020 10:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728512AbgAQKq6 (ORCPT ); Fri, 17 Jan 2020 05:46:58 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35630 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727047AbgAQKq6 (ORCPT ); Fri, 17 Jan 2020 05:46:58 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAbvwB001053 for ; Fri, 17 Jan 2020 05:46:57 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xk0qrrh96-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:46:56 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:46:54 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:46:51 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAkotc26280042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:46:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B328DAE056; Fri, 17 Jan 2020 10:46:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11AA7AE051; Fri, 17 Jan 2020 10:46:49 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:46:48 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 2/9] s390x: smp: Only use smp_cpu_setup once Date: Fri, 17 Jan 2020 05:46:33 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0016-0000-0000-000002DE3936 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0017-0000-0000-00003340D4A0 Message-Id: <20200117104640.1983-3-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=3 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 priorityscore=1501 phishscore=0 bulkscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Let's stop and start instead of using setup to run a function on a cpu. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Acked-by: David Hildenbrand --- s390x/smp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/s390x/smp.c b/s390x/smp.c index 8d8e3a5..555ed72 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -46,7 +46,7 @@ static void test_start(void) psw.mask = extract_psw_mask(); psw.addr = (unsigned long)test_func; - smp_cpu_setup(1, psw); + smp_cpu_start(1, psw); wait_for_flag(); report(1, "start"); } @@ -102,6 +102,7 @@ static void test_store_status(void) report(1, "status written"); free_pages(status, PAGE_SIZE * 2); report_prefix_pop(); + smp_cpu_stop(1); report_prefix_pop(); } @@ -130,9 +131,8 @@ static void test_ecall(void) report_prefix_push("ecall"); testflag = 0; - smp_cpu_destroy(1); - smp_cpu_setup(1, psw); + smp_cpu_start(1, psw); wait_for_flag(); testflag = 0; sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); @@ -165,9 +165,8 @@ static void test_emcall(void) report_prefix_push("emcall"); testflag = 0; - smp_cpu_destroy(1); - smp_cpu_setup(1, psw); + smp_cpu_start(1, psw); wait_for_flag(); testflag = 0; sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL); @@ -185,7 +184,7 @@ static void test_reset_initial(void) psw.addr = (unsigned long)test_func; report_prefix_push("reset initial"); - smp_cpu_setup(1, psw); + smp_cpu_start(1, psw); sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL); sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL); @@ -216,7 +215,7 @@ static void test_reset(void) psw.addr = (unsigned long)test_func; report_prefix_push("cpu reset"); - smp_cpu_setup(1, psw); + smp_cpu_start(1, psw); sigp_retry(1, SIGP_CPU_RESET, 0, NULL); report(smp_cpu_stopped(1), "cpu stopped"); @@ -225,6 +224,7 @@ static void test_reset(void) int main(void) { + struct psw psw; report_prefix_push("smp"); if (smp_query_num_cpus() == 1) { @@ -232,6 +232,12 @@ int main(void) goto done; } + /* Setting up the cpu to give it a stack and lowcore */ + psw.mask = extract_psw_mask(); + psw.addr = (unsigned long)cpu_loop; + smp_cpu_setup(1, psw); + smp_cpu_stop(1); + test_start(); test_stop(); test_stop_store_status(); @@ -240,6 +246,7 @@ int main(void) test_emcall(); test_reset(); test_reset_initial(); + smp_cpu_destroy(1); done: report_prefix_pop(); From patchwork Fri Jan 17 10:46:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C20D513BD for ; Fri, 17 Jan 2020 10:47:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB61E2082F for ; Fri, 17 Jan 2020 10:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727231AbgAQKq7 (ORCPT ); Fri, 17 Jan 2020 05:46:59 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:1340 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgAQKq6 (ORCPT ); Fri, 17 Jan 2020 05:46:58 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAcsa4078593 for ; Fri, 17 Jan 2020 05:46:57 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xk0qu0hdr-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:46:57 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:46:55 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:46:53 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAk3eK38535448 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:46:03 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6844AE056; Fri, 17 Jan 2020 10:46:52 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1CFFDAE051; Fri, 17 Jan 2020 10:46:51 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:46:50 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 3/9] s390x: Add cpu id to interrupt error prints Date: Fri, 17 Jan 2020 05:46:34 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0028-0000-0000-000003D1F5D0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0029-0000-0000-0000249620D6 Message-Id: <20200117104640.1983-4-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=853 adultscore=0 malwarescore=0 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 spamscore=0 mlxscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It's good to know which cpu broke the test. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck --- lib/s390x/interrupt.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c index 05f30be..773752a 100644 --- a/lib/s390x/interrupt.c +++ b/lib/s390x/interrupt.c @@ -107,8 +107,8 @@ static void fixup_pgm_int(void) void handle_pgm_int(void) { if (!pgm_int_expected) - report_abort("Unexpected program interrupt: %d at %#lx, ilen %d\n", - lc->pgm_int_code, lc->pgm_old_psw.addr, + report_abort("Unexpected program interrupt: %d on cpu %d at %#lx, ilen %d\n", + lc->pgm_int_code, stap(), lc->pgm_old_psw.addr, lc->pgm_int_id); pgm_int_expected = false; @@ -119,8 +119,8 @@ void handle_ext_int(void) { if (!ext_int_expected && lc->ext_int_code != EXT_IRQ_SERVICE_SIG) { - report_abort("Unexpected external call interrupt (code %#x): at %#lx", - lc->ext_int_code, lc->ext_old_psw.addr); + report_abort("Unexpected external call interrupt (code %#x): on cpu %d at %#lx", + stap(), lc->ext_int_code, lc->ext_old_psw.addr); return; } @@ -137,18 +137,18 @@ void handle_ext_int(void) void handle_mcck_int(void) { - report_abort("Unexpected machine check interrupt: at %#lx", - lc->mcck_old_psw.addr); + report_abort("Unexpected machine check interrupt: on cpu %d at %#lx", + stap(), lc->mcck_old_psw.addr); } void handle_io_int(void) { - report_abort("Unexpected io interrupt: at %#lx", - lc->io_old_psw.addr); + report_abort("Unexpected io interrupt: on cpu %d at %#lx", + stap(), lc->io_old_psw.addr); } void handle_svc_int(void) { - report_abort("Unexpected supervisor call interrupt: at %#lx", - lc->svc_old_psw.addr); + report_abort("Unexpected supervisor call interrupt: on cpu %d at %#lx", + stap(), lc->svc_old_psw.addr); } From patchwork Fri Jan 17 10:46:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338733 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10E3C13BD for ; Fri, 17 Jan 2020 10:47:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE73A2082F for ; Fri, 17 Jan 2020 10:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727504AbgAQKrC (ORCPT ); Fri, 17 Jan 2020 05:47:02 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40182 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728249AbgAQKrC (ORCPT ); Fri, 17 Jan 2020 05:47:02 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAbvRh109527 for ; Fri, 17 Jan 2020 05:47:01 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xk0qt0mxg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:47:01 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:46:59 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:46:55 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAksJE55443526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:46:54 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8909AE045; Fri, 17 Jan 2020 10:46:54 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FD22AE055; Fri, 17 Jan 2020 10:46:53 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:46:52 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 4/9] s390x: smp: Rework cpu start and active tracking Date: Fri, 17 Jan 2020 05:46:35 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0008-0000-0000-0000034A424A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0009-0000-0000-00004A6A9EA9 Message-Id: <20200117104640.1983-5-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=862 bulkscore=0 suspectscore=1 phishscore=0 spamscore=0 adultscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The architecture specifies that processing sigp orders may be asynchronous, and this is indeed the case on some hypervisors, so we need to wait until the cpu runs before we return from the setup/start function. As there was a lot of duplicate code, a common function for cpu restarts has been introduced. Signed-off-by: Janosch Frank Reviewed-by: Cornelia Huck --- lib/s390x/smp.c | 50 ++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index f57f420..84e681d 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -104,35 +104,46 @@ int smp_cpu_stop_store_status(uint16_t addr) return rc; } +static int smp_cpu_restart_nolock(uint16_t addr, struct psw *psw) +{ + int rc; + struct cpu *cpu = smp_cpu_from_addr(addr); + + if (!cpu) + return -1; + if (psw) { + cpu->lowcore->restart_new_psw.mask = psw->mask; + cpu->lowcore->restart_new_psw.addr = psw->addr; + } + rc = sigp(addr, SIGP_RESTART, 0, NULL); + if (rc) + return rc; + /* + * The order has been accepted, but the actual restart may not + * have been performed yet, so wait until the cpu is running. + */ + while (!smp_cpu_running(addr)) + mb(); + cpu->active = true; + return 0; +} + int smp_cpu_restart(uint16_t addr) { - int rc = -1; - struct cpu *cpu; + int rc; spin_lock(&lock); - cpu = smp_cpu_from_addr(addr); - if (cpu) { - rc = sigp(addr, SIGP_RESTART, 0, NULL); - cpu->active = true; - } + rc = smp_cpu_restart_nolock(addr, NULL); spin_unlock(&lock); return rc; } int smp_cpu_start(uint16_t addr, struct psw psw) { - int rc = -1; - struct cpu *cpu; - struct lowcore *lc; + int rc; spin_lock(&lock); - cpu = smp_cpu_from_addr(addr); - if (cpu) { - lc = cpu->lowcore; - lc->restart_new_psw.mask = psw.mask; - lc->restart_new_psw.addr = psw.addr; - rc = sigp(addr, SIGP_RESTART, 0, NULL); - } + rc = smp_cpu_restart_nolock(addr, &psw); spin_unlock(&lock); return rc; } @@ -192,10 +203,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw) lc->sw_int_crs[0] = 0x0000000000040000UL; /* Start processing */ - rc = sigp_retry(cpu->addr, SIGP_RESTART, 0, NULL); - if (!rc) - cpu->active = true; - + smp_cpu_restart_nolock(addr, NULL); out: spin_unlock(&lock); return rc; From patchwork Fri Jan 17 10:46:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92B1B13A0 for ; Fri, 17 Jan 2020 10:47:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C2362083E for ; Fri, 17 Jan 2020 10:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbgAQKrC (ORCPT ); Fri, 17 Jan 2020 05:47:02 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37904 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728596AbgAQKrC (ORCPT ); Fri, 17 Jan 2020 05:47:02 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAc5RW017839 for ; Fri, 17 Jan 2020 05:47:01 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xk0qt0s77-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:47:01 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:46:59 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:46:57 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAkuqC44761288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:46:56 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF536AE056; Fri, 17 Jan 2020 10:46:56 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3495BAE051; Fri, 17 Jan 2020 10:46:55 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:46:54 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 5/9] s390x: smp: Wait for cpu setup to finish Date: Fri, 17 Jan 2020 05:46:36 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0012-0000-0000-0000037E39DF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0013-0000-0000-000021BA705E Message-Id: <20200117104640.1983-6-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=1 mlxlogscore=999 impostorscore=0 adultscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We store the user provided psw address into restart new, so a psw restart does not lead us through setup again. Also we wait on smp_cpu_setup() until the cpu has finished setup before returning. This is necessary for z/VM and LPAR where sigp is asynchronous. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck --- lib/s390x/smp.c | 2 ++ s390x/cstart64.S | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index 84e681d..9dad146 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -204,6 +204,8 @@ int smp_cpu_setup(uint16_t addr, struct psw psw) /* Start processing */ smp_cpu_restart_nolock(addr, NULL); + /* Wait until the cpu has finished setup and started the provided psw */ + while (lc->restart_new_psw.addr != psw.addr) { mb(); } out: spin_unlock(&lock); return rc; diff --git a/s390x/cstart64.S b/s390x/cstart64.S index 86dd4c4..9af6bb3 100644 --- a/s390x/cstart64.S +++ b/s390x/cstart64.S @@ -159,6 +159,8 @@ smp_cpu_setup_state: xgr %r1, %r1 lmg %r0, %r15, GEN_LC_SW_INT_GRS lctlg %c0, %c0, GEN_LC_SW_INT_CRS + /* We should only go once through cpu setup and not for every restart */ + stg %r14, GEN_LC_RESTART_NEW_PSW + 8 br %r14 pgm_int: From patchwork Fri Jan 17 10:46:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338737 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E85413BD for ; Fri, 17 Jan 2020 10:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB4372083E for ; Fri, 17 Jan 2020 10:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728816AbgAQKrG (ORCPT ); Fri, 17 Jan 2020 05:47:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:20130 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728739AbgAQKrF (ORCPT ); Fri, 17 Jan 2020 05:47:05 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAbwJu053163 for ; Fri, 17 Jan 2020 05:47:05 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xk0qrrvwd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:47:04 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:47:03 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:46:59 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAkwjt34865600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:46:58 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 99DDDAE057; Fri, 17 Jan 2020 10:46:58 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2781CAE053; Fri, 17 Jan 2020 10:46:57 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:46:56 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 6/9] s390x: smp: Loop if secondary cpu returns into cpu setup again Date: Fri, 17 Jan 2020 05:46:37 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0008-0000-0000-0000034A424F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0009-0000-0000-00004A6A9EAE Message-Id: <20200117104640.1983-7-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=834 priorityscore=1501 suspectscore=1 impostorscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Up to now a secondary cpu could have returned from the function it was executing and ending up somewhere in cstart64.S. This was mostly circumvented by an endless loop in the function that it executed. Let's add a loop to the end of the cpu setup, so we don't have to rely on added loops in the tests. Signed-off-by: Janosch Frank --- s390x/cstart64.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/s390x/cstart64.S b/s390x/cstart64.S index 9af6bb3..5fd8d2f 100644 --- a/s390x/cstart64.S +++ b/s390x/cstart64.S @@ -162,6 +162,8 @@ smp_cpu_setup_state: /* We should only go once through cpu setup and not for every restart */ stg %r14, GEN_LC_RESTART_NEW_PSW + 8 br %r14 + /* If the function returns, just loop here */ +0: j 0 pgm_int: SAVE_REGS From patchwork Fri Jan 17 10:46:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A49DD13BD for ; Fri, 17 Jan 2020 10:47:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CA582083E for ; Fri, 17 Jan 2020 10:47:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728773AbgAQKrH (ORCPT ); Fri, 17 Jan 2020 05:47:07 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:16054 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728775AbgAQKrG (ORCPT ); Fri, 17 Jan 2020 05:47:06 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAbvjC001004 for ; Fri, 17 Jan 2020 05:47:05 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xk0qrrhcs-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:47:04 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:47:03 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:47:01 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAl00D39911634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:47:00 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5324CAE045; Fri, 17 Jan 2020 10:47:00 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC0D3AE055; Fri, 17 Jan 2020 10:46:58 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:46:58 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 7/9] s390x: smp: Remove unneeded cpu loops Date: Fri, 17 Jan 2020 05:46:38 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0012-0000-0000-0000037E39E2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0013-0000-0000-000021BA7060 Message-Id: <20200117104640.1983-8-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=1 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 priorityscore=1501 phishscore=0 bulkscore=0 clxscore=1015 impostorscore=0 mlxlogscore=877 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Now that we have a loop which is executed after we return from the main function of a secondary cpu, we can remove the surplus loops. Signed-off-by: Janosch Frank --- s390x/smp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/s390x/smp.c b/s390x/smp.c index 555ed72..c12a3db 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -29,15 +29,9 @@ static void wait_for_flag(void) } } -static void cpu_loop(void) -{ - for (;;) {} -} - static void test_func(void) { testflag = 1; - cpu_loop(); } static void test_start(void) @@ -234,7 +228,7 @@ int main(void) /* Setting up the cpu to give it a stack and lowcore */ psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)cpu_loop; + psw.addr = (unsigned long)test_func; smp_cpu_setup(1, psw); smp_cpu_stop(1); From patchwork Fri Jan 17 10:46:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C99CF13A0 for ; Fri, 17 Jan 2020 10:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEE712083E for ; Fri, 17 Jan 2020 10:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728863AbgAQKrJ (ORCPT ); Fri, 17 Jan 2020 05:47:09 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40258 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728890AbgAQKrJ (ORCPT ); Fri, 17 Jan 2020 05:47:09 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAbsG3065612 for ; Fri, 17 Jan 2020 05:47:08 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xk0qgg13b-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:47:07 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:47:05 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:47:03 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAl2Li25428204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:47:02 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36FABAE04D; Fri, 17 Jan 2020 10:47:02 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5DBAAE045; Fri, 17 Jan 2020 10:47:00 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:47:00 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 8/9] s390x: smp: Test all CRs on initial reset Date: Fri, 17 Jan 2020 05:46:39 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0012-0000-0000-0000037E39E5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0013-0000-0000-000021BA7063 Message-Id: <20200117104640.1983-9-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=1 bulkscore=0 impostorscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 malwarescore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values, so we also need to test 1-13 and 15 for 0. And while we're at it, let's also set some values to cr 1, 7 and 13, so we can actually be sure that they will be zeroed. Signed-off-by: Janosch Frank Reviewed-by: Cornelia Huck Reviewed-by: David Hildenbrand --- s390x/smp.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/s390x/smp.c b/s390x/smp.c index c12a3db..1385488 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -169,16 +169,30 @@ static void test_emcall(void) report_prefix_pop(); } +/* Used to dirty registers of cpu #1 before it is reset */ +static void test_func_initial(void) +{ + lctlg(1, 0x42000UL); + lctlg(7, 0x43000UL); + lctlg(13, 0x44000UL); + mb(); + testflag = 1; +} + static void test_reset_initial(void) { struct cpu_status *status = alloc_pages(0); + uint64_t nullp[12] = {}; struct psw psw; psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func; + psw.addr = (unsigned long)test_func_initial; report_prefix_push("reset initial"); + testflag = 0; + mb(); smp_cpu_start(1, psw); + wait_for_flag(); sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL); sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL); @@ -189,6 +203,8 @@ static void test_reset_initial(void) report(!status->fpc, "fpc"); report(!status->cputm, "cpu timer"); report(!status->todpr, "todpr"); + report(!memcmp(&status->crs[1], nullp, sizeof(status->crs[1]) * 12), "cr1-13 == 0"); + report(status->crs[15] == 0, "cr15 == 0"); report_prefix_pop(); report_prefix_push("initialized"); From patchwork Fri Jan 17 10:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11338743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D86213A0 for ; Fri, 17 Jan 2020 10:47:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 264712073A for ; Fri, 17 Jan 2020 10:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728895AbgAQKrL (ORCPT ); Fri, 17 Jan 2020 05:47:11 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49450 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728872AbgAQKrK (ORCPT ); Fri, 17 Jan 2020 05:47:10 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HAbwOl021830 for ; Fri, 17 Jan 2020 05:47:09 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xk0qtrb3p-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 05:47:09 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 10:47:07 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 10:47:04 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HAl3CT37027916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 10:47:03 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9146AE053; Fri, 17 Jan 2020 10:47:03 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 88D02AE051; Fri, 17 Jan 2020 10:47:02 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.184.110]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 10:47:02 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, borntraeger@de.ibm.com, linux-s390@vger.kernel.org, david@redhat.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v3 9/9] s390x: smp: Dirty fpc before initial reset test Date: Fri, 17 Jan 2020 05:46:40 -0500 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117104640.1983-1-frankja@linux.ibm.com> References: <20200117104640.1983-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20011710-0028-0000-0000-000003D1F5D8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011710-0029-0000-0000-0000249620DE Message-Id: <20200117104640.1983-10-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_02:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=1 adultscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 mlxlogscore=910 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170083 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Let's dirty the fpc, before we test if the initial reset sets it to 0. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Reviewed-by: David Hildenbrand --- s390x/smp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/s390x/smp.c b/s390x/smp.c index 1385488..aedcd65 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -172,6 +172,7 @@ static void test_emcall(void) /* Used to dirty registers of cpu #1 before it is reset */ static void test_func_initial(void) { + asm volatile("sfpc %0" :: "d" (0x11)); lctlg(1, 0x42000UL); lctlg(7, 0x43000UL); lctlg(13, 0x44000UL);