KVM ARM Archive on lore.kernel.org
 help / color / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Andrew Jones <drjones@redhat.com>
Cc: thuth@redhat.com, kvm@vger.kernel.org, maz@kernel.org,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	andre.przywara@arm.com, kvmarm@lists.cs.columbia.edu,
	eric.auger.pro@gmail.com
Subject: Re: [kvm-unit-tests PATCH v2 16/16] arm/arm64: ITS: pending table migration test
Date: Wed, 15 Jan 2020 18:06:41 +0100
Message-ID: <dd919bb9-6e1e-501f-b369-eb0d8dfbbcbc@redhat.com> (raw)
In-Reply-To: <20200113184547.zqilrexm27hpkkou@kamzik.brq.redhat.com>

Hi Drew,

On 1/13/20 7:45 PM, Andrew Jones wrote:
> On Fri, Jan 10, 2020 at 03:54:12PM +0100, Eric Auger wrote:
>> 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 <eric.auger@redhat.com>
>> ---
>>  arm/gic.c         | 148 ++++++++++++++++++++++++++++++++++++++++++++++
>>  arm/unittests.cfg |  16 ++++-
>>  2 files changed, 163 insertions(+), 1 deletion(-)
>>
>> diff --git a/arm/gic.c b/arm/gic.c
>> index bf4b5ba..cb976c3 100644
>> --- a/arm/gic.c
>> +++ b/arm/gic.c
>> @@ -170,6 +170,7 @@ static void lpi_handler(struct pt_regs *regs __unused)
>>  	smp_rmb(); /* pairs with wmb in lpi_stats_expect */
>>  	lpi_stats.observed.cpu_id = smp_processor_id();
>>  	lpi_stats.observed.lpi_id = irqnr;
>> +	acked[lpi_stats.observed.cpu_id]++;
>>  	smp_wmb(); /* pairs with rmb in check_lpi_stats */
>>  }
>>  
>> @@ -207,6 +208,18 @@ static void check_lpi_stats(void)
>>  	}
>>  }
>>  
>> +static void check_lpi_hits(int *expected)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < nr_cpus; i++) {
>> +		if (acked[i] != expected[i])
>> +			report(false, "expected %d LPIs on PE #%d, %d observed",
>> +			       expected[i], i, acked[i]);
>> +		}
>> +	report(true, "check LPI on all vcpus");
>> +}
>> +
>>  static void gicv2_ipi_send_self(void)
>>  {
>>  	writel(2 << 24 | IPI_IRQ, gicv2_dist_base() + GICD_SGIR);
>> @@ -641,6 +654,18 @@ static int its_prerequisites(int nb_cpus)
>>  	return 0;
>>  }
>>  
>> +static void set_lpi(struct its_device *dev, u32 eventid, u32 physid,
>> +		    struct its_collection *col)
>> +{
>> +	if (!dev || !col)
>> +		report_abort("wrong device or collection");
>> +
>> +	its_send_mapti(dev, physid, eventid, col);
>> +
>> +	set_lpi_config(physid, LPI_PROP_DEFAULT);
>> +	its_send_invall(col);
>> +}
>> +
>>  /*
>>   * Setup the configuration for those mappings:
>>   * dev_id=2 event=20 -> vcpu 3, intid=8195
>> @@ -765,6 +790,121 @@ static void test_its_migration(void)
>>  	check_lpi_stats();
>>  }
>>  
>> +static void test_migrate_unmapped_collection(void)
>> +{
>> +	struct its_collection *col;
>> +	struct its_device *dev2, *dev7;
>> +	u8 config;
>> +
>> +	if (its_setup1())
>> +		return;
>> +
>> +	col = its_create_collection(nr_cpus - 1, nr_cpus - 1);
>> +	dev2 = its_get_device(2);
>> +	dev7 = 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(true, "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();
>> +
>> +	config = get_lpi_config(8192);
>> +	report(config == LPI_PROP_DEFAULT,
>> +	       "Config of LPI 8192 was properly migrated");
>> +
>> +	lpi_stats_expect(nr_cpus - 1, 8192);
>> +	its_send_int(dev2, 0);
>> +	check_lpi_stats();
>> +
>> +	/* unmap the collection */
>> +	its_send_mapc(col, false);
>> +
>> +	lpi_stats_expect(-1, -1);
>> +	its_send_int(dev2, 0);
>> +	check_lpi_stats();
>> +
>> +	/* remap event 0 onto lpiid 8193 */
>> +	set_lpi(dev2, 0, 8193, col);
>> +	lpi_stats_expect(-1, -1);
>> +	its_send_int(dev2, 0);
>> +	check_lpi_stats();
>> +
>> +	/* remap the collection */
>> +	its_send_mapc(col, true);
>> +	lpi_stats_expect(nr_cpus - 1, 8193);
>> +}
>> +
>> +static void test_its_pending_migration(void)
>> +{
>> +	struct its_device *dev;
>> +	struct its_collection *collection[2];
>> +	int expected[NR_CPUS];
>> +	u64 pendbaser;
>> +	void *ptr;
>> +	int i;
>> +
>> +	if (its_prerequisites(4))
>> +		return;
>> +
>> +	dev = its_create_device(2 /* dev id */, 8 /* nb_ites */);
>> +	its_send_mapd(dev, true);
>> +
>> +	collection[0] = its_create_collection(nr_cpus - 1, nr_cpus - 1);
>> +	collection[1] = its_create_collection(nr_cpus - 2, nr_cpus - 2);
>> +	its_send_mapc(collection[0], true);
>> +	its_send_mapc(collection[1], true);
>> +
>> +	/* disable lpi at redist level */
>> +	gicv3_rdist_ctrl_lpi(nr_cpus - 1, false);
>> +	gicv3_rdist_ctrl_lpi(nr_cpus - 2, false);
>> +
>> +	/* even lpis are assigned to even cpu */
>> +	for (i = 0; i < 256; i++) {
>> +		struct its_collection *col = i % 2 ? collection[0] :
>> +						     collection[1];
>> +		int vcpu = col->target_address >> 16;
>> +
>> +		its_send_mapti(dev, 8192 + i, i, col);
>> +		set_lpi_config(8192 + i, LPI_PROP_DEFAULT);
>> +		set_pending_table_bit(vcpu, 8192 + i, true);
>> +	}
>> +	its_send_invall(collection[0]);
>> +	its_send_invall(collection[1]);
>> +
>> +	/* Set the PTZ bit on each pendbaser */
>> +
>> +	expected[nr_cpus - 1] = 128;
>> +	expected[nr_cpus - 2] = 128;
>> +
>> +	ptr = gicv3_data.redist_base[nr_cpus - 1] + GICR_PENDBASER;
>> +	pendbaser = readq(ptr);
>> +	writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr);
>> +
>> +	ptr = gicv3_data.redist_base[nr_cpus - 2] + GICR_PENDBASER;
>> +	pendbaser = readq(ptr);
>> +	writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr);
>> +
>> +	gicv3_rdist_ctrl_lpi(nr_cpus - 1, true);
>> +	gicv3_rdist_ctrl_lpi(nr_cpus - 2, true);
>> +
>> +	puts("Now migrate the VM, then press a key to continue...\n");
>> +	(void)getchar();
>> +	report(true, "Migration complete");
>> +
>> +	mdelay(1000);
>> +
>> +	check_lpi_hits(expected);
>> +}
>> +
>>  int main(int argc, char **argv)
>>  {
>>  	if (!gic_init()) {
>> @@ -803,6 +943,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") == 0) {
>>  		report_prefix_push(argv[1]);
>>  		test_its_introspection();
>> diff --git a/arm/unittests.cfg b/arm/unittests.cfg
>> index 29e2efc..911f0b7 100644
>> --- a/arm/unittests.cfg
>> +++ b/arm/unittests.cfg
>> @@ -145,7 +145,21 @@ file = gic.flat
>>  smp = $MAX_SMP
>>  accel = kvm
>>  extra_params = -machine gic-version=3 -append 'its-migration'
>> -groups = its migration
>> +groups = migration
>> +
>> +[its-pending-migration]
>> +file = gic.flat
>> +smp = $MAX_SMP
>> +accel = kvm
>> +extra_params = -machine gic-version=3 -append 'its-pending-migration'
>> +groups = migration
>> +
>> +[its-migrate-unmapped-collection]
>> +file = gic.flat
>> +smp = $MAX_SMP
>> +accel = kvm
>> +extra_params = -machine gic-version=3 -append 'its-migrate-unmapped-collection'
>> +groups = migration
> 
> Why drop the 'its' group?
I think the test only works with the migration group. Otherwise it
stalls due to the migration infrastructure. I will double check.

Thanks

Eric
> 
> Thanks,
> drew
> 
>>  
>>  # Test PSCI emulation
>>  [psci]
>> -- 
>> 2.20.1
>>

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

      reply index

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 14:53 [kvm-unit-tests PATCH v2 00/16] arm/arm64: Add ITS tests Eric Auger
2020-01-10 14:53 ` [kvm-unit-tests PATCH v2 01/16] libcflat: Add other size defines Eric Auger
2020-01-10 14:53 ` [kvm-unit-tests PATCH v2 02/16] arm: gic: Provide per-IRQ helper functions Eric Auger
2020-01-10 14:53 ` [kvm-unit-tests PATCH v2 03/16] arm/arm64: gic: Introduce setup_irq() helper Eric Auger
2020-01-13 16:53   ` Andrew Jones
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 04/16] arm/arm64: gicv3: Add some re-distributor defines Eric Auger
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 05/16] arm/arm64: ITS: Introspection tests Eric Auger
2020-01-13 17:11   ` Andrew Jones
2020-01-13 17:33   ` Andrew Jones
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 06/16] arm/arm64: ITS: Test BASER Eric Auger
2020-01-13 17:21   ` Andrew Jones
2020-01-15 17:16     ` Auger Eric
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 07/16] arm/arm64: ITS: Set the LPI config and pending tables Eric Auger
2020-01-13 17:31   ` Andrew Jones
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 08/16] arm/arm64: ITS: Init the command queue Eric Auger
2020-01-13 17:37   ` Andrew Jones
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 09/16] arm/arm64: ITS: Enable/Disable LPIs at re-distributor level Eric Auger
2020-01-13 17:44   ` Andrew Jones
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 10/16] arm/arm64: ITS: its_enable_defaults Eric Auger
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 11/16] arm/arm64: ITS: Device and collection Initialization Eric Auger
2020-01-13 17:48   ` Andrew Jones
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 12/16] arm/arm64: ITS: commands Eric Auger
2020-01-13 18:00   ` Andrew Jones
2020-01-15 17:13     ` Auger Eric
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 13/16] arm/arm64: ITS: INT functional tests Eric Auger
2020-01-13 18:17   ` Andrew Jones
2020-01-15 17:11     ` Auger Eric
2020-01-16  8:06       ` Andrew Jones
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 14/16] arm/run: Allow Migration tests Eric Auger
2020-01-13 18:40   ` Andrew Jones
2020-01-15 17:04     ` Auger Eric
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 15/16] arm/arm64: ITS: migration tests Eric Auger
2020-01-10 14:54 ` [kvm-unit-tests PATCH v2 16/16] arm/arm64: ITS: pending table migration test Eric Auger
2020-01-13 18:45   ` Andrew Jones
2020-01-15 17:06     ` Auger Eric [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dd919bb9-6e1e-501f-b369-eb0d8dfbbcbc@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=andre.przywara@arm.com \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=maz@kernel.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

KVM ARM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvmarm/0 kvmarm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvmarm kvmarm/ https://lore.kernel.org/kvmarm \
		kvmarm@lists.cs.columbia.edu
	public-inbox-index kvmarm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/edu.columbia.cs.lists.kvmarm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git