From nobody Fri Nov 14 00:46:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583749643; cv=none; d=zohomail.com; s=zohoarc; b=Ym8iuc1OceIyu2OrrGT5AzzsXnsYwJcu3v/8QMYbwVjZ9HeUp072eyLRmfqNdpw8GQlctXDRsuD2W7nR47cO+CVwVaTWUs0g/cFDNwiTdFLmGhMxOLbOJWZH1xJwr+y/wyxHDZLNbBYYgPTBBbPeN9CN+yWNKGyjo/ToeBBWW3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583749643; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EtWY6EtZqZfpLJigCSJmpP6HidMT+k6tciMSfFWxjKM=; b=CGMkIiLTCbJvXjQAGtpDaLwjK/D7rwJsT2202nWeUYZvYHWXTpES1LS4EDoFphd+SH0EAttqhi44IABIUEYU12OhwygmJGxQPWmnErJBDdNwyeCzysv+qSSUrdvlAohxip8mcx17dSI/AkRIDDDk6AElLdiJX/+JeTZf5V7QGno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583749643642439.54850799160545; Mon, 9 Mar 2020 03:27:23 -0700 (PDT) Received: from localhost ([::1]:40274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBFd4-0003pp-G5 for importer@patchew.org; Mon, 09 Mar 2020 06:27:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38109) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBFbM-000157-0j for qemu-devel@nongnu.org; Mon, 09 Mar 2020 06:25:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBFbK-0002aV-8K for qemu-devel@nongnu.org; Mon, 09 Mar 2020 06:25:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39716 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBFbK-0002a7-2m for qemu-devel@nongnu.org; Mon, 09 Mar 2020 06:25:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-yXI4uzByNLmVZSM0ZeQc9g-1; Mon, 09 Mar 2020 06:25:31 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B76E6477; Mon, 9 Mar 2020 10:25:29 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62A0487B08; Mon, 9 Mar 2020 10:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583749533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EtWY6EtZqZfpLJigCSJmpP6HidMT+k6tciMSfFWxjKM=; b=dBwoNTfgpT9ziNrL5p4cJ5jddAIrAGZiMvphwy9+notMghO3mAJ47LmNTjn8hILwGXy0+6 1fGIj1dvQVG3bq24rXuFq7uKPMGYi3BR5jpKGa5EwYoNiLYWgBhffFyzzubqqLwGBg4RaA VxioZVzTDf73RstlX/eNVvZ5R6DfWDs= X-MC-Unique: yXI4uzByNLmVZSM0ZeQc9g-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, maz@kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org Subject: [kvm-unit-tests PATCH v4 13/13] arm/arm64: ITS: pending table migration test Date: Mon, 9 Mar 2020 11:24:20 +0100 Message-Id: <20200309102420.24498-14-eric.auger@redhat.com> In-Reply-To: <20200309102420.24498-1-eric.auger@redhat.com> References: <20200309102420.24498-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, drjones@redhat.com, andre.przywara@arm.com, thuth@redhat.com, yuzenghui@huawei.com, alexandru.elisei@arm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add two new migration tests. One testing the migration of a topology where collection were unmapped. The second test checks the migration of the pending table. Signed-off-by: Eric Auger --- v3 -> v4: - do not talk about odd/even CPUs, use pe0 and pe1 - comment the delay v2 -> v3: - tests belong to both its and migration groups - use LPI(i) - gicv3_lpi_set_pending_table_bit renamed into gicv3_lpi_set_clr_pending --- arm/gic.c | 144 +++++++++++++++++++++++++++++++++++++++ arm/unittests.cfg | 16 +++++ lib/arm/asm/gic-v3-its.h | 9 +++ 3 files changed, 169 insertions(+) diff --git a/arm/gic.c b/arm/gic.c index 96f0fd6..39994eb 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -194,6 +194,7 @@ static void lpi_handler(struct pt_regs *regs __unused) smp_rmb(); /* pairs with wmb in lpi_stats_expect */ lpi_stats.observed.cpu_id =3D smp_processor_id(); lpi_stats.observed.lpi_id =3D irqnr; + acked[lpi_stats.observed.cpu_id]++; smp_wmb(); /* pairs with rmb in check_lpi_stats */ } =20 @@ -236,6 +237,22 @@ static void secondary_lpi_test(void) while (1) wfi(); } + +static void check_lpi_hits(int *expected, const char *msg) +{ + bool pass =3D true; + int i; + + for (i =3D 0; i < nr_cpus; i++) { + if (acked[i] !=3D expected[i]) { + report_info("expected %d LPIs on PE #%d, %d observed", + expected[i], i, acked[i]); + pass =3D false; + break; + } + } + report(pass, "%s", msg); +} #endif =20 static void gicv2_ipi_send_self(void) @@ -653,6 +670,17 @@ static int its_prerequisites(int nb_cpus) return 0; } =20 +static void set_lpi(struct its_device *dev, u32 eventid, u32 physid, + struct its_collection *col) +{ + assert(dev && col); + + its_send_mapti(dev, physid, eventid, col); + + gicv3_lpi_set_config(physid, LPI_PROP_DEFAULT); + its_send_invall(col); +} + /* * Setup the configuration for those mappings: * dev_id=3D2 event=3D20 -> vcpu 3, intid=3D8195 @@ -793,6 +821,114 @@ static void test_its_migration(void) its_send_int(dev7, 255); check_lpi_stats("dev7/eventid=3D255 triggers LPI 8196 on PE #2 after migr= ation"); } + +static void test_migrate_unmapped_collection(void) +{ + struct its_collection *col; + struct its_device *dev2, *dev7; + int pe0 =3D nr_cpus - 1; + u8 config; + + if (its_setup1()) + return; + + col =3D its_create_collection(pe0, pe0); + dev2 =3D its_get_device(2); + dev7 =3D its_get_device(7); + + /* MAPTI with the collection unmapped */ + set_lpi(dev2, 0, 8192, col); + + puts("Now migrate the VM, then press a key to continue...\n"); + (void)getchar(); + report_info("Migration complete"); + + /* on the destination, map the collection */ + its_send_mapc(col, true); + + lpi_stats_expect(2, 8196); + its_send_int(dev7, 255); + check_lpi_stats("dev7/eventid=3D 255 triggered LPI 8196 on PE #2"); + + config =3D gicv3_lpi_get_config(8192); + report(config =3D=3D LPI_PROP_DEFAULT, + "Config of LPI 8192 was properly migrated"); + + lpi_stats_expect(pe0, 8192); + its_send_int(dev2, 0); + check_lpi_stats("dev2/eventid =3D 0 triggered LPI 8192 on PE0"); + + /* unmap the collection */ + its_send_mapc(col, false); + + lpi_stats_expect(-1, -1); + its_send_int(dev2, 0); + check_lpi_stats("no LPI triggered after collection unmapping"); +} + +static void test_its_pending_migration(void) +{ + struct its_device *dev; + struct its_collection *collection[2]; + int *expected =3D malloc(nr_cpus * sizeof(int)); + int pe0 =3D nr_cpus - 1, pe1 =3D nr_cpus - 2; + u64 pendbaser; + void *ptr; + int i; + + if (its_prerequisites(4)) + return; + + dev =3D its_create_device(2 /* dev id */, 8 /* nb_ites */); + its_send_mapd(dev, true); + + collection[0] =3D its_create_collection(pe0, pe0); + collection[1] =3D its_create_collection(pe1, pe1); + its_send_mapc(collection[0], true); + its_send_mapc(collection[1], true); + + /* disable lpi at redist level */ + gicv3_lpi_rdist_disable(pe0); + gicv3_lpi_rdist_disable(pe1); + + /* lpis are interleaved inbetween the 2 PEs */ + for (i =3D 0; i < 256; i++) { + struct its_collection *col =3D i % 2 ? collection[0] : + collection[1]; + int vcpu =3D col->target_address >> 16; + + its_send_mapti(dev, LPI(i), i, col); + gicv3_lpi_set_config(LPI(i), LPI_PROP_DEFAULT); + gicv3_lpi_set_clr_pending(vcpu, LPI(i), true); + } + its_send_invall(collection[0]); + its_send_invall(collection[1]); + + /* Set the PTZ bit on each pendbaser */ + + expected[pe0] =3D 128; + expected[pe1] =3D 128; + + ptr =3D gicv3_data.redist_base[pe0] + GICR_PENDBASER; + pendbaser =3D readq(ptr); + writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr); + + ptr =3D gicv3_data.redist_base[pe1] + GICR_PENDBASER; + pendbaser =3D readq(ptr); + writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr); + + gicv3_lpi_rdist_enable(pe0); + gicv3_lpi_rdist_enable(pe1); + + puts("Now migrate the VM, then press a key to continue...\n"); + (void)getchar(); + report_info("Migration complete"); + + /* let's wait for the 256 LPIs to be handled */ + mdelay(1000); + + check_lpi_hits(expected, "128 LPIs on both PE0 and PE1 after migration"); +} #endif =20 int main(int argc, char **argv) @@ -834,6 +970,14 @@ int main(int argc, char **argv) report_prefix_push(argv[1]); test_its_migration(); report_prefix_pop(); + } else if (!strcmp(argv[1], "its-pending-migration")) { + report_prefix_push(argv[1]); + test_its_pending_migration(); + report_prefix_pop(); + } else if (!strcmp(argv[1], "its-migrate-unmapped-collection")) { + report_prefix_push(argv[1]); + test_migrate_unmapped_collection(); + report_prefix_pop(); } else if (strcmp(argv[1], "its-introspection") =3D=3D 0) { report_prefix_push(argv[1]); test_its_introspection(); diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 480adec..b96f0a1 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -144,6 +144,22 @@ extra_params =3D -machine gic-version=3D3 -append 'its= -migration' groups =3D its migration arch =3D arm64 =20 +[its-pending-migration] +file =3D gic.flat +smp =3D $MAX_SMP +accel =3D kvm +extra_params =3D -machine gic-version=3D3 -append 'its-pending-migration' +groups =3D its migration +arch =3D arm64 + +[its-migrate-unmapped-collection] +file =3D gic.flat +smp =3D $MAX_SMP +accel =3D kvm +extra_params =3D -machine gic-version=3D3 -append 'its-migrate-unmapped-co= llection' +groups =3D its migration +arch =3D arm64 + # Test PSCI emulation [psci] file =3D psci.flat diff --git a/lib/arm/asm/gic-v3-its.h b/lib/arm/asm/gic-v3-its.h index 4d849c4..5ec2a04 100644 --- a/lib/arm/asm/gic-v3-its.h +++ b/lib/arm/asm/gic-v3-its.h @@ -26,5 +26,14 @@ static inline void test_its_migration(void) { report_abort("not supported on 32-bit"); } +static inline void test_its_pending_migration(void) +{ + report_abort("not supported on 32-bit"); +} +static inline void test_migrate_unmapped_collection(void) +{ + report_abort("not supported on 32-bit"); +} + =20 #endif /* _ASMARM_GICv3_ITS */ --=20 2.20.1