From patchwork Tue Nov 22 16:12:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13052541 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 AA852C4332F for ; Tue, 22 Nov 2022 16:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbiKVQP3 (ORCPT ); Tue, 22 Nov 2022 11:15:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233026AbiKVQOr (ORCPT ); Tue, 22 Nov 2022 11:14:47 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECFDD6EB50 for ; Tue, 22 Nov 2022 08:12:52 -0800 (PST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AMEbFUZ010103 for ; Tue, 22 Nov 2022 16:12:52 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=ZLGK717oQ4tgdGOwkP+QXXZSQK4t0PpspbxonpYgWyI=; b=XlNzcHAoXf6YqUZf/bJ80UiFTpxQ5+jHwXvdkvONwMkNbiaZ8sE7PlJ7zMCegSHECJvW +DDRgoQLhVWSmgVGq1/30F9z49fauvctw42mp3Cc6eH2yFTFWsnnlpBv2CaFW4VeE1uX UPVLlqCTcKRCdwaBrSyHwkXoL30djUIsn4QWz8W4kH1ywe3ivFbNGJLKeo+v7RaiX41t A/6fjlQNo8fFrmKD0sdeWnivu2CIiAXz9w5Fr9MUd38ZwEkXObvzwArIo+EvdkPkK97h iqi/RnCeJ6AytjbUfw4IAjHGJyBBy5g7wj1No/FU/61Yygn0xtp19A5t9w/P04uKmhuj LA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10bkjn3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 Nov 2022 16:12:52 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AMFlK3K019886 for ; Tue, 22 Nov 2022 16:12:51 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10bkjn1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Nov 2022 16:12:51 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AMG6fmI002480; Tue, 22 Nov 2022 16:12:48 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 3kxps8k9jy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Nov 2022 16:12:47 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AMGCilS6292056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Nov 2022 16:12:44 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC8564C040; Tue, 22 Nov 2022 16:12:44 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 788F44C04A; Tue, 22 Nov 2022 16:12:44 +0000 (GMT) Received: from a46lp57.lnxne.boe (unknown [9.152.108.100]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 22 Nov 2022 16:12:44 +0000 (GMT) From: Nico Boehr To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, imbrenda@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v1 1/2] s390x: add a library for CMM-related functions Date: Tue, 22 Nov 2022 17:12:42 +0100 Message-Id: <20221122161243.214814-2-nrb@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221122161243.214814-1-nrb@linux.ibm.com> References: <20221122161243.214814-1-nrb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: y2FabRj5bmI-PTGsbItPzlcxCEyKLETD X-Proofpoint-GUID: jEuI2Q_jyviNm21N7QylDIB-6YbPjOAM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-22_10,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=786 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211220121 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Upcoming changes will add a test which is very similar to the existing CMM migration test. To reduce code duplication, move the common function to a library which can be re-used by both tests. Signed-off-by: Nico Boehr --- lib/s390x/cmm.c | 83 +++++++++++++++++++++++++++++++++++++++++++ lib/s390x/cmm.h | 29 +++++++++++++++ s390x/Makefile | 1 + s390x/migration-cmm.c | 36 ++++++------------- 4 files changed, 123 insertions(+), 26 deletions(-) create mode 100644 lib/s390x/cmm.c create mode 100644 lib/s390x/cmm.h diff --git a/lib/s390x/cmm.c b/lib/s390x/cmm.c new file mode 100644 index 000000000000..9609cea68950 --- /dev/null +++ b/lib/s390x/cmm.c @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * CMM test library + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ +#include +#include +#include "cmm.h" + +/* + * Maps ESSA actions to states the page is allowed to be in after the + * respective action was executed. + */ +const int allowed_essa_state_masks[4] = { + BIT(ESSA_USAGE_STABLE), /* ESSA_SET_STABLE */ + BIT(ESSA_USAGE_UNUSED), /* ESSA_SET_UNUSED */ + BIT(ESSA_USAGE_VOLATILE), /* ESSA_SET_VOLATILE */ + BIT(ESSA_USAGE_VOLATILE) | BIT(ESSA_USAGE_POT_VOLATILE) /* ESSA_SET_POT_VOLATILE */ +}; + +static inline unsigned long get_page_addr(uint8_t *pagebuf, int page_idx) +{ + return (unsigned long)(pagebuf + PAGE_SIZE * page_idx); +} + +/* + * Set CMM page states on pagebuf. + * pagebuf must point to page_count consecutive pages. + * page_count must be a multiple of 4. + */ +void cmm_set_page_states(uint8_t *pagebuf, int page_count) +{ + int i; + + assert(page_count % 4 == 0); + for (i = 0; i < page_count; i += 4) { + essa(ESSA_SET_STABLE, get_page_addr(pagebuf, i)); + essa(ESSA_SET_UNUSED, get_page_addr(pagebuf, i + 1)); + essa(ESSA_SET_VOLATILE, get_page_addr(pagebuf, i + 2)); + essa(ESSA_SET_POT_VOLATILE, get_page_addr(pagebuf, i + 3)); + } +} + +/* + * Verify CMM page states on pagebuf. + * Page states must have been set by cmm_set_page_states on pagebuf before. + * page_count must be a multiple of 4. + * + * If page states match the expected result, + * will return true and result will be untouched. When a mismatch occurs, will + * return false and result will be filled with details on the first mismatch. + */ +bool cmm_verify_page_states(uint8_t *pagebuf, int page_count, struct cmm_verify_result *result) +{ + int i, state_mask, actual_state; + + assert(page_count % 4 == 0); + + for (i = 0; i < page_count; i++) { + actual_state = essa(ESSA_GET_STATE, get_page_addr(pagebuf, i)); + /* extract the usage state in bits 60 and 61 */ + actual_state = (actual_state >> 2) & 0x3; + state_mask = allowed_essa_state_masks[i % ARRAY_SIZE(allowed_essa_state_masks)]; + if (!(BIT(actual_state) & state_mask)) { + result->page_mismatch = i; + result->expected_mask = state_mask; + result->actual_mask = BIT(actual_state); + return false; + } + } + + return true; +} + +void cmm_report_verify_fail(struct cmm_verify_result const *result) +{ + report_fail("page state mismatch: first page = %d, expected_mask = 0x%x, actual_mask = 0x%x", result->page_mismatch, result->expected_mask, result->actual_mask); +} + diff --git a/lib/s390x/cmm.h b/lib/s390x/cmm.h new file mode 100644 index 000000000000..56e188c78704 --- /dev/null +++ b/lib/s390x/cmm.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * CMM test library + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ +#ifndef S390X_CMM_H +#define S390X_CMM_H + +#include +#include +#include + +struct cmm_verify_result { + int page_mismatch; + int expected_mask; + int actual_mask; +}; + +void cmm_set_page_states(uint8_t *pagebuf, int page_count); + +bool cmm_verify_page_states(uint8_t *pagebuf, int page_count, struct cmm_verify_result *result); + +void cmm_report_verify_fail(struct cmm_verify_result const *result); + +#endif /* S390X_CMM_H */ diff --git a/s390x/Makefile b/s390x/Makefile index bf1504f9d58c..401cb6371cee 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -99,6 +99,7 @@ cflatobjs += lib/s390x/malloc_io.o cflatobjs += lib/s390x/uv.o cflatobjs += lib/s390x/sie.o cflatobjs += lib/s390x/fault.o +cflatobjs += lib/s390x/cmm.o OBJDIRS += lib/s390x diff --git a/s390x/migration-cmm.c b/s390x/migration-cmm.c index aa7910ca76bf..ffd656f4db75 100644 --- a/s390x/migration-cmm.c +++ b/s390x/migration-cmm.c @@ -14,41 +14,25 @@ #include #include +#include "cmm.h" + #define NUM_PAGES 128 -static uint8_t pagebuf[NUM_PAGES][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + +static uint8_t pagebuf[NUM_PAGES * PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); static void test_migration(void) { - int i, state_mask, actual_state; - /* - * Maps ESSA actions to states the page is allowed to be in after the - * respective action was executed. - */ - int allowed_essa_state_masks[4] = { - BIT(ESSA_USAGE_STABLE), /* ESSA_SET_STABLE */ - BIT(ESSA_USAGE_UNUSED), /* ESSA_SET_UNUSED */ - BIT(ESSA_USAGE_VOLATILE), /* ESSA_SET_VOLATILE */ - BIT(ESSA_USAGE_VOLATILE) | BIT(ESSA_USAGE_POT_VOLATILE) /* ESSA_SET_POT_VOLATILE */ - }; + struct cmm_verify_result result = {}; - assert(NUM_PAGES % 4 == 0); - for (i = 0; i < NUM_PAGES; i += 4) { - essa(ESSA_SET_STABLE, (unsigned long)pagebuf[i]); - essa(ESSA_SET_UNUSED, (unsigned long)pagebuf[i + 1]); - essa(ESSA_SET_VOLATILE, (unsigned long)pagebuf[i + 2]); - essa(ESSA_SET_POT_VOLATILE, (unsigned long)pagebuf[i + 3]); - } + cmm_set_page_states(pagebuf, NUM_PAGES); puts("Please migrate me, then press return\n"); (void)getchar(); - for (i = 0; i < NUM_PAGES; i++) { - actual_state = essa(ESSA_GET_STATE, (unsigned long)pagebuf[i]); - /* extract the usage state in bits 60 and 61 */ - actual_state = (actual_state >> 2) & 0x3; - state_mask = allowed_essa_state_masks[i % ARRAY_SIZE(allowed_essa_state_masks)]; - report(BIT(actual_state) & state_mask, "page %d state: expected_mask=0x%x actual_mask=0x%lx", i, state_mask, BIT(actual_state)); - } + if (!cmm_verify_page_states(pagebuf, NUM_PAGES, &result)) + cmm_report_verify_fail(&result); + else + report_pass("page states match"); } int main(void) From patchwork Tue Nov 22 16:12:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13052540 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 379EDC433FE for ; Tue, 22 Nov 2022 16:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234292AbiKVQP1 (ORCPT ); Tue, 22 Nov 2022 11:15:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233709AbiKVQOr (ORCPT ); Tue, 22 Nov 2022 11:14:47 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDA396EB7C for ; Tue, 22 Nov 2022 08:12:53 -0800 (PST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AMG1DTN030333 for ; Tue, 22 Nov 2022 16:12:52 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=IAG8gCjGyVDBkZYJCCeyZuZ53p57vfPUFeEiq0fIR68=; b=TRUFRvMqXSB2/RKQukwErTQuY+jWCisqBaZ3+vmXAfzIorcLHmJr/u6L4MMB8Dosxdrl TZsAwkPnyCZtoAi1hAvCYZCD6cjpFcxbO66KF7a3QgAdEiBXsAoOaq0PxDXOK5ZKJDtl 3kw0Vk5Ysqg3aDGVqB4rgqpCtftyR51FLR2UKe7Xr/3xoQXpT4EXzVbFd/JWjDOp1AZ6 DgMOp8W1xuWF8x9Oqw1mjMzWHHrBbjCXbgUxz3M8Yiz495CsIo/9i/HJueKnvOhEx4+2 dBGG9qyjmedmy1E+u2RiPD3D0cnHrX9rKoLJRsyOWbKVTppOn1Y/Q/aDKQkagVz6wg8H Hw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m0yk6m2mv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 Nov 2022 16:12:52 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AMFUWF3000592 for ; Tue, 22 Nov 2022 16:12:52 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m0yk6m2k2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Nov 2022 16:12:51 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AMG7a4v018846; Tue, 22 Nov 2022 16:12:48 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3kxpdhvgmx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Nov 2022 16:12:47 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AMGCjiR63177030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Nov 2022 16:12:45 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED52A4C040; Tue, 22 Nov 2022 16:12:44 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8D0D4C046; Tue, 22 Nov 2022 16:12:44 +0000 (GMT) Received: from a46lp57.lnxne.boe (unknown [9.152.108.100]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 22 Nov 2022 16:12:44 +0000 (GMT) From: Nico Boehr To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, imbrenda@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v1 2/2] s390x: add CMM test during migration Date: Tue, 22 Nov 2022 17:12:43 +0100 Message-Id: <20221122161243.214814-3-nrb@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221122161243.214814-1-nrb@linux.ibm.com> References: <20221122161243.214814-1-nrb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: y60KZHK8cENzw--Py1BeUC7-0oPdmiGt X-Proofpoint-ORIG-GUID: WvMDJk9YhNhSL3kGNkhGswx8mNZBR9B3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-22_09,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211220121 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add a test which modifies CMM page states while migration is in progress. Signed-off-by: Nico Boehr --- s390x/Makefile | 1 + s390x/migration-during-cmm.c | 111 +++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 5 ++ 3 files changed, 117 insertions(+) create mode 100644 s390x/migration-during-cmm.c diff --git a/s390x/Makefile b/s390x/Makefile index 401cb6371cee..64c7c04409ae 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -39,6 +39,7 @@ tests += $(TEST_DIR)/panic-loop-extint.elf tests += $(TEST_DIR)/panic-loop-pgm.elf tests += $(TEST_DIR)/migration-sck.elf tests += $(TEST_DIR)/exittime.elf +tests += $(TEST_DIR)/migration-during-cmm.elf pv-tests += $(TEST_DIR)/pv-diags.elf diff --git a/s390x/migration-during-cmm.c b/s390x/migration-during-cmm.c new file mode 100644 index 000000000000..3c96283d7b00 --- /dev/null +++ b/s390x/migration-during-cmm.c @@ -0,0 +1,111 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Perform CMMA actions while migrating. + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ + +#include +#include +#include + +#include "cmm.h" + +#define NUM_PAGES 128 + +static uint8_t pagebuf[NUM_PAGES * PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + +static int thread_iters; +static int thread_should_exit; +static int thread_exited; +static bool verification_failure_occured; +struct cmm_verify_result result; + +static void test_cmm_during_migration(void) +{ + /* + * The second CPU must not print on the console, otherwise it will race with + * the primary CPU on the SCLP buffer. + */ + while (!thread_should_exit) { + cmm_set_page_states(pagebuf, NUM_PAGES); + if (!cmm_verify_page_states(pagebuf, NUM_PAGES, &result)) { + verification_failure_occured = true; + goto out; + } + thread_iters++; + } + +out: + thread_exited = 1; +} + +int main(void) +{ + bool has_essa = check_essa_available(); + struct psw psw; + + report_prefix_push("migration-during-cmm"); + if (!has_essa) { + report_skip("ESSA is not available"); + goto error; + } + + if (smp_query_num_cpus() == 1) { + report_skip("need at least 2 cpus for this test"); + goto error; + } + + psw.mask = extract_psw_mask(); + psw.addr = (unsigned long)test_cmm_during_migration; + smp_cpu_setup(1, psw); + + puts("Please migrate me, then press return\n"); + (void)getchar(); + + thread_should_exit = 1; + + while (!thread_exited) + mb(); + + report_info("thread completed %d iterations", thread_iters); + + report_prefix_push("during migration"); + if (verification_failure_occured) + cmm_report_verify_fail(&result); + else + report_pass("page states matched"); + report_prefix_pop(); + + /* + * Verification of page states occurs on the thread. We don't know if we + * were still migrating during the verification. + * To be sure, make another verification round after the migration + * finished to catch page states which might not have been migrated + * correctly. + */ + report_prefix_push("after migration"); + if (!cmm_verify_page_states(pagebuf, NUM_PAGES, &result)) + cmm_report_verify_fail(&result); + else + report_pass("page states matched"); + report_prefix_pop(); + + goto done; + +error: + /* + * If we just exit and don't ask migrate_cmd to migrate us, it + * will just hang forever. Hence, also ask for migration when we + * skip this test alltogether. + */ + puts("Please migrate me, then press return\n"); + (void)getchar(); + +done: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 3caf81eda396..f6889bd4da01 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -208,3 +208,8 @@ groups = migration [exittime] file = exittime.elf smp = 2 + +[migration-during-cmm] +file = migration-during-cmm.elf +groups = migration +smp = 2