kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Zenghui Yu <yuzenghui@huawei.com>
Cc: kvm@vger.kernel.org, maz@kernel.org, qemu-devel@nongnu.org,
	qemu-arm@nongnu.org, andre.przywara@arm.com, thuth@redhat.com,
	kvmarm@lists.cs.columbia.edu, eric.auger.pro@gmail.com
Subject: Re: [kvm-unit-tests PATCH v7 13/13] arm/arm64: ITS: pending table migration test
Date: Mon, 30 Mar 2020 14:38:32 +0200	[thread overview]
Message-ID: <ea74559c-2ab4-752c-e587-2bf40eab14b0@redhat.com> (raw)
In-Reply-To: <296c574b-810c-9c90-a613-df732a9ac193@huawei.com>

Hi Zenghui,

On 3/30/20 2:06 PM, Zenghui Yu wrote:
> Hi Eric,
> 
> On 2020/3/20 17:24, 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>
> 
> [...]
> 
>> @@ -659,6 +678,15 @@ 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)
>> +{
>> +    assert(dev && col);
>> +
>> +    its_send_mapti(dev, physid, eventid, col);
>> +    gicv3_lpi_set_config(physid, LPI_PROP_DEFAULT);
>> +}
> 
> I'd say we can just drop this helper and open-code it anywhere
> necessarily. The name 'set_lpi' doesn't tell me too much about
> what has been implemented inside the helper.
> 
>> +
>>   /*
>>    * Setup the configuration for those mappings:
>>    * dev_id=2 event=20 -> vcpu 3, intid=8195
>> @@ -790,6 +818,108 @@ static void test_its_migration(void)
>>       its_send_int(dev7, 255);
>>       check_lpi_stats("dev7/eventid=255 triggers LPI 8196 on PE #2
>> after migration");
>>   }
>> +
>> +static void test_migrate_unmapped_collection(void)
>> +{
>> +    struct its_collection *col;
>> +    struct its_device *dev2, *dev7;
>> +    int pe0 = 0;
>> +    u8 config;
>> +
>> +    if (its_setup1())
>> +        return;
>> +
>> +    col = its_create_collection(pe0, pe0);
>> +    dev2 = its_get_device(2);
>> +    dev7 = its_get_device(7);
>> +
>> +    /* MAPTI with the collection unmapped */
>> +    set_lpi(dev2, 0, 8192, col);
> 
> ... and it's only invoked here.
> 
>> +
>> +    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);
>> +    its_send_invall(col);
>> +
>> +    lpi_stats_expect(2, 8196);
>> +    its_send_int(dev7, 255);
>> +    check_lpi_stats("dev7/eventid= 255 triggered LPI 8196 on PE #2");
>> +
>> +    config = gicv3_lpi_get_config(8192);
>> +    report(config == 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 = 0 triggered LPI 8192 on PE0");
>> +}
>> +
>> +static void test_its_pending_migration(void)
>> +{
>> +    struct its_device *dev;
>> +    struct its_collection *collection[2];
>> +    int *expected = malloc(nr_cpus * sizeof(int));
>> +    int pe0 = nr_cpus - 1, pe1 = nr_cpus - 2;
>> +    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(pe0, pe0);
>> +    collection[1] = 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 = 0; i < 256; i++) {
>> +        struct its_collection *col = i % 2 ? collection[0] :
>> +                             collection[1];
>> +        int vcpu = 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]);
>> +
>> +    /* Clear the PTZ bit on each pendbaser */
>> +
>> +    expected[pe0] = 128;
>> +    expected[pe1] = 128;
> 
> Do we need to initialize expected[] for other PEs? Or it has always
> been zeroed by the kvm-unit-tests implementation of malloc()?
> 
>> +
>> +    ptr = gicv3_data.redist_base[pe0] + GICR_PENDBASER;
>> +    pendbaser = readq(ptr);
>> +    writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr);
>> +
>> +    ptr = gicv3_data.redist_base[pe1] + GICR_PENDBASER;
>> +    pendbaser = readq(ptr);
>> +    writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr);
>> +
>> +    gicv3_lpi_rdist_enable(pe0);
>> +    gicv3_lpi_rdist_enable(pe1);
> 
> I don't know how the migration gets implemented in kvm-unit-tests.
> But is there any guarantee that the LPIs will only be triggered on the
> destination side? As once the EnableLPIs bit becomes 1, VGIC will start
> reading the pending bit in guest memory and potentially injecting LPIs
> into the target vcpu (in the source side).

I expect some LPIs to hit on source and some others to hit on the
destination. To me, this does not really matter as long as the handlers
gets called and accumulate the stats. Given the number of LPIs, we will
at least test the migration of some of the pending bits and especially
adjacent ones. It does work as it allows to test your fix:

ca185b260951  KVM: arm/arm64: vgic: Don't rely on the wrong pending table

Thanks

Eric
> 
>> +
>> +    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");
>> +}
> 
> 
> Thanks,
> Zenghui
> 
> 

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

  reply	other threads:[~2020-03-30 12:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20  9:24 [kvm-unit-tests PATCH v7 00/13] arm/arm64: Add ITS tests Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 01/13] libcflat: Add other size defines Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 02/13] page_alloc: Introduce get_order() Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 03/13] arm/arm64: gic: Introduce setup_irq() helper Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 04/13] arm/arm64: gicv3: Add some re-distributor defines Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 05/13] arm/arm64: gicv3: Set the LPI config and pending tables Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 06/13] arm/arm64: ITS: Introspection tests Eric Auger
2020-03-30  8:30   ` Zenghui Yu
2020-03-30  8:46     ` Auger Eric
2020-03-30  9:11       ` Andrew Jones
2020-03-30  9:56         ` Auger Eric
2020-03-30 10:19           ` Andrew Jones
2020-03-30 10:24             ` Auger Eric
2020-03-30 12:20         ` Zenghui Yu
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 07/13] arm/arm64: ITS: its_enable_defaults Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 08/13] arm/arm64: ITS: Device and collection Initialization Eric Auger
2020-03-25  8:10   ` Zenghui Yu
2020-03-25 21:20     ` Auger Eric
2020-03-30  9:13       ` Andrew Jones
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 09/13] arm/arm64: ITS: Commands Eric Auger
2020-03-30  9:22   ` Zenghui Yu
2020-03-30  9:57     ` Auger Eric
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 10/13] arm/arm64: ITS: INT functional tests Eric Auger
2020-03-30 10:43   ` Zenghui Yu
2020-04-02  8:50     ` Auger Eric
2020-04-02 12:40       ` Zenghui Yu
2020-04-02 14:41         ` Andrew Jones
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 11/13] arm/run: Allow Migration tests Eric Auger
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 12/13] arm/arm64: ITS: migration tests Eric Auger
2020-03-30 10:55   ` Zenghui Yu
2020-03-20  9:24 ` [kvm-unit-tests PATCH v7 13/13] arm/arm64: ITS: pending table migration test Eric Auger
2020-03-30 12:06   ` Zenghui Yu
2020-03-30 12:38     ` Auger Eric [this message]
2020-03-30 13:17       ` Zenghui Yu

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=ea74559c-2ab4-752c-e587-2bf40eab14b0@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=andre.przywara@arm.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 \
    --cc=yuzenghui@huawei.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).