From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: "Oliver Upton" <oupton@kernel.org>,
kvmarm@lists.linux.dev, "Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v2 4/4] KVM: arm64: selftests: Add ITS table save tests
Date: Fri, 21 Aug 2026 07:00:38 +0000 [thread overview]
Message-ID: <20260821070039.120B51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821064445.615838-5-fuad.tabba@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Unsafe DMA Buffer Configuration (ITT Size Miscalculation)
- [Medium] Incorrect Endianness Conversion for L1 Device Table
--
--- Patch [4]: [PATCH v2 4/4] KVM: arm64: selftests: Add ITS table save tests ---
commit 00c3ff8ee303e906c6d0f346f17949dbb0abf5fc
Author: Fuad Tabba <fuad.tabba@linux.dev>
Subject: KVM: arm64: selftests: Add ITS table save tests
This commit adds selftests for KVM_DEV_ARM_ITS_SAVE_TABLES to cover cases
where a guest alters tables. It tests handling of a GITS_BASER<coll> write
that changes the table, and a device whose L2 block the guest invalidated.
Each case is then reset and restored to verify the save functionality.
> diff --git a/tools/testing/selftests/kvm/arm64/vgic_its_save.c b/tools/testing/selftests/kvm/arm64/vgic_its_save.c
> new file mode 100644
> index 0000000000000..864da01539f3f
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/arm64/vgic_its_save.c
> @@ -0,0 +1,441 @@
[ ... ]
> +/*
> + * its_send_mapd_cmd() encodes ilog2(itt_size) - 1 as num_eventid_bits, and
> + * vgic_its_restore_itt() scans BIT_ULL(num_eventid_bits) * ESZ, so the size
> + * handed to MAPD has to match the ITT allocated for it.
> + */
> +#define ITT_EVENTID_BITS 13
> +#define ITT_MAPD_SIZE BIT_ULL(ITT_EVENTID_BITS + 1)
[Severity: Medium]
Does this calculation configure the hardware with an ITT size of 128KB instead
of the intended 64KB?
The test calculates ITT_MAPD_SIZE as BIT_ULL(ITT_EVENTID_BITS + 1) (evaluating
to 16,384) to compensate for its_send_mapd_cmd() subtracting 1. However, KVM's
its_cmd_get_size() adds 1 back, resulting in 14 bits of event IDs.
During restore, KVM computes the scan size as BIT_ULL(14) * 8 = 128KB, causing
it to read 64KB past the end of the allocated ITT memory.
> +#define ITT_SZ (BIT_ULL(ITT_EVENTID_BITS) * ESZ)
[ ... ]
> +static void guest_unreachable_device(void)
> +{
> + u64 *l1;
[ ... ]
> + guest_make_device_table_indirect();
> +
> + /* Both L2 blocks present, so both MAPDs are in range. */
> + l1 = test_data.device_l1_va;
> + l1[0] = L1E_VALID_MASK | (test_data.device_l2[0] & L1E_ADDR_MASK);
> + l1[1] = L1E_VALID_MASK | (test_data.device_l2[1] & L1E_ADDR_MASK);
[Severity: Medium]
Will this fail on big-endian hosts? The L1 entries are being populated using
native CPU endianness.
Since the ARM GICv3 ITS architecture and KVM emulator require these tables to
be little-endian (using le64_to_cpu on read), shouldn't these use htole64()
when writing them?
> +
> + its_send_mapd_cmd(test_data.cmdq_base_va, DEVICE_A_ID,
> + test_data.itt_tables, ITT_MAPD_SIZE, true);
> + its_send_mapd_cmd(test_data.cmdq_base_va, DEVICE_B_ID,
> + test_data.itt_tables + ITT_SZ, ITT_MAPD_SIZE, true);
[Severity: Medium]
This isn't a separate bug, but as a result of the ITT_MAPD_SIZE miscalculation
above, doesn't this send MAPD commands configuring overlapping, out-of-bounds
ITT tables for the two devices?
> +
> + /*
> + * Drop the block holding device B. No ITS command and no GITS_BASER
> + * write is involved, so nothing tells KVM the device is now
> + * unreachable.
> + */
> + l1[1] = 0;
> +
> + GUEST_DONE();
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821064445.615838-1-fuad.tabba@linux.dev?part=4
next prev parent reply other threads:[~2026-08-21 7:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 6:44 [PATCH v2 0/4] KVM: arm64: vgic-its: Make the ITS table save reliable Fuad Tabba
2026-08-21 6:44 ` [PATCH v2 1/4] KVM: arm64: vgic-its: Free the caches when GITS_BASER changes Fuad Tabba
2026-08-21 6:57 ` sashiko-bot
2026-08-21 7:37 ` Fuad Tabba
2026-08-21 8:50 ` Marc Zyngier
2026-08-21 8:55 ` Fuad Tabba
2026-08-21 6:44 ` [PATCH v2 2/4] Revert "KVM: arm64: vgic-its: Don't save collections the table cannot hold" Fuad Tabba
2026-08-21 6:44 ` [PATCH v2 3/4] KVM: arm64: vgic-its: Skip unreachable devices instead of failing the save Fuad Tabba
2026-08-21 6:44 ` [PATCH v2 4/4] KVM: arm64: selftests: Add ITS table save tests Fuad Tabba
2026-08-21 7:00 ` sashiko-bot [this message]
2026-08-21 7:51 ` Fuad Tabba
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=20260821070039.120B51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=fuad.tabba@linux.dev \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.