From patchwork Tue Jun 14 15:00: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: 12881231 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 0273AC43334 for ; Tue, 14 Jun 2022 15:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355556AbiFNPBM (ORCPT ); Tue, 14 Jun 2022 11:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343911AbiFNPBA (ORCPT ); Tue, 14 Jun 2022 11:01:00 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52DD43F88B for ; Tue, 14 Jun 2022 08:00:58 -0700 (PDT) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25EErml7001694 for ; Tue, 14 Jun 2022 15:00: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=9uAVOb2CDkqo0VHE6oBjqs7YdXRPqaTlsGWkM6KlU+w=; b=sq3SRL+yBLKGSbwKD+8UK+LW2n9f3AWSbjI+Lu7i1eDujXVlry+O98FcGE8DT8zR+bn3 1X63bVKk0Dm7858JimE9keTOKSwkXlqVXgHuNJxzWtckPhlPcAyPMsmSQAf7lRBhCLVb su2ZDyfOYlyZLniMBAy87+A/I+CJ3/Em0NYwcXd13/80KMc2i+s8QQK2dtTyJqtj8xkw eGJeA4X5k6ay+kSkedaLe1NHHooudQ3wN8sl15e8v4SzrJK4BA/4BgXdG4y3OSX3CU1O DIMq/T3/jAlua0BF2Pr0bYVlbfBLZnwUnEV1655lXxerHYcHes51qy/PoBY0/PbCjPeB tg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gpbuqfbfc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 14 Jun 2022 15:00:57 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25EEsUEu004566 for ; Tue, 14 Jun 2022 15:00:57 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gpbuqfbea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jun 2022 15:00:56 +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 25EEovm9027262; Tue, 14 Jun 2022 15:00:55 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3gmjp9chm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jun 2022 15:00:54 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25EF0tpU23265600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Jun 2022 15:00:55 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA81242042; Tue, 14 Jun 2022 15:00:51 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7229B4204B; Tue, 14 Jun 2022 15:00:51 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.145.3.94]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 14 Jun 2022 15:00:51 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 2/5] s390x: add cmm migration test Date: Tue, 14 Jun 2022 17:00:46 +0200 Message-Id: <20220614150049.55787-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220614150049.55787-1-imbrenda@linux.ibm.com> References: <20220614150049.55787-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: KE0I7c71nd2zCYiXhdCSpxiyYcZGAgvV X-Proofpoint-ORIG-GUID: pCb_mvDscNTRhck_DpTjddC8VxTI5T31 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-14_05,2022-06-13_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 malwarescore=0 mlxlogscore=869 suspectscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206140057 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr When a VM is migrated, we expect the page states to be preserved. Add a test which checks for that. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 1 + s390x/migration-cmm.c | 77 +++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 +++ 3 files changed, 82 insertions(+) create mode 100644 s390x/migration-cmm.c diff --git a/s390x/Makefile b/s390x/Makefile index a8e04aa6..1877c8a6 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -32,6 +32,7 @@ tests += $(TEST_DIR)/epsw.elf tests += $(TEST_DIR)/adtl-status.elf tests += $(TEST_DIR)/migration.elf tests += $(TEST_DIR)/pv-attest.elf +tests += $(TEST_DIR)/migration-cmm.elf pv-tests += $(TEST_DIR)/pv-diags.elf diff --git a/s390x/migration-cmm.c b/s390x/migration-cmm.c new file mode 100644 index 00000000..aa7910ca --- /dev/null +++ b/s390x/migration-cmm.c @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * CMM migration tests (ESSA) + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ + +#include +#include +#include +#include +#include + +#define NUM_PAGES 128 +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 */ + }; + + 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]); + } + + 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)); + } +} + +int main(void) +{ + bool has_essa = check_essa_available(); + + report_prefix_push("migration-cmm"); + if (!has_essa) { + report_skip("ESSA is not available"); + + /* + * 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(); + + goto done; + } + + test_migration(); +done: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index b456b288..9b97d047 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -176,3 +176,7 @@ extra_params = -cpu qemu,gs=off,vx=off file = migration.elf groups = migration smp = 2 + +[migration-cmm] +file = migration-cmm.elf +groups = migration