From: Oliver Upton <oupton@kernel.org>
To: Sascha Bischoff <sascha.bischoff@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
kvm@vger.kernel.org, maz@kernel.org, oliver.upton@linux.dev,
joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com,
peter.maydell@linaro.org, lpieralisi@kernel.org,
timothy.hayes@arm.com, fuad.tabba@linux.dev
Subject: Re: [PATCH v2 07/16] KVM: arm64: gic-v5: Add ITS guest table translation emulation
Date: Wed, 4 Nov 2026 16:02:38 -0800 [thread overview]
Message-ID: <auvHnnymzccd9OaF@kernel.org> (raw)
In-Reply-To: <20261102194454.4086911-8-sascha.bischoff@arm.com>
On Mon, Nov 02, 2026 at 07:44:45PM +0000, Sascha Bischoff wrote:
> +static int parse_linear_dt(struct kvm *kvm, gpa_t dt_base, u32 device_id,
> + gpa_t *itt_base, bool *two_level_itt,
> + unsigned int *event_id_bits, unsigned int *itt_l2sz)
> +{
> + __le64 dt_l2_entry;
> + gpa_t entry_addr;
> + u64 val;
> + int ret;
> +
<snip>
> + entry_addr = dt_base + device_id * sizeof(__le64);
> + ret = kvm_read_guest_lock(kvm, entry_addr, &dt_l2_entry,
> + sizeof(dt_l2_entry));
> + if (ret) {
> + kvm_debug("Failed to read guest memory for L2 DT\n");
99% chance of this being either the guest or userspace's fault. I don't
see any reason why we need to carry a pr_debug() here.
What would be nice is some preparatory return codes or helpers for
recording the SWERR that caused an ITS operation to fail so we can add
support for ITS_IDR0.SWE later on.
The GICv3 ITS made a half-attempt at doing this. Even though it never
conveyed that information to the guest, I think it was a net-win in
terms of readability.
> + return ret;
> + }
> +
> + val = le64_to_cpu(dt_l2_entry);
</snip>
Feels like "read the Nth entry from this table out of guest memory"
should be done in a helper shared with the other callsites. On top of
that, arm64 is little-endian only as of 7.4.
While I'm not saying we should go tear out every instance of byteorder
twiddling, I think that shared helper would be an excellent spot to
either do the le_to_cpu() or document the fact that both the kernel and
the ITS are LE-only.
> + if (!FIELD_GET(GICV5_DTL2E_VALID, val)) {
> + kvm_debug("Guest DT entry is invalid\n");
> + return -EINVAL;
> + }
> +
> + *itt_base = FIELD_GET(GICV5_DTL2E_ITT_ADDR_MASK, val) << 3;
> + *two_level_itt = FIELD_GET(GICV5_DTL2E_ITT_STRUCTURE, val);
> + *event_id_bits = FIELD_GET(GICV5_DTL2E_EVENT_ID_BITS, val);
> + *itt_l2sz = FIELD_GET(GICV5_DTL2E_ITT_L2SZ, val);
Same sense brewing here about the parsing, with the added gripe that
multiple out pointers can be a bit annoying to cope with. I'd rather see
the literal DTE get passed around or we use a struct containing all the
extracted fields we care about.
> +static int parse_two_level_dt(struct kvm *kvm, gpa_t dt_base,
> + unsigned int dt_l2sz, u32 device_id,
> + gpa_t *itt_base, bool *two_level_itt,
> + unsigned int *event_id_bits,
> + unsigned int *itt_l2sz)
Any reason why this can't be anchored on a pointer to the ITS? Because
you're passing down a lot of state that's just per-ITS context.
> + if (device_id >= 1UL << device_id_bits) {
BIT_ULL()?
> +static int parse_two_level_itt(struct kvm *kvm, u32 event_id, gpa_t itt_base,
> + unsigned int itt_l2sz, __le64 *itt_l2_entry)
> +{
> + unsigned int itt_split_bits, l2_event_id_bits;
> + gpa_t itt_l2_base, entry_addr;
> + u32 l1_event_id, l2_event_id;
> + __le64 itt_l1_entry;
> + u64 val;
> + int ret;
> +
> + switch (itt_l2sz) {
> + case 0:
> + itt_split_bits = 9;
> + break;
> + case 1:
> + itt_split_bits = 11;
> + break;
> + case 2:
> + itt_split_bits = 13;
> + break;
> + default:
> + return -EINVAL;
> + }
this should be a shared helper
Thanks,
Oliver
next prev parent reply other threads:[~2026-11-05 0:02 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 19:44 [PATCH v2 00/16] KVM: arm64: Add GICv5 ITS support Sascha Bischoff
2026-11-02 19:44 ` [PATCH v2 01/16] KVM: arm64: vgic: Split out common LPI allocation Sascha Bischoff
2026-11-03 13:41 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 02/16] KVM: arm64: vgic: Pass opaque device pointer to ITS MMIO callbacks Sascha Bischoff
2026-11-03 13:42 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 03/16] KVM: arm64: gic-v5: Share CoreSight ID register emulation Sascha Bischoff
2026-11-03 13:43 ` Fuad Tabba
2026-11-03 20:37 ` Wei-Lin Chang
2026-11-02 19:44 ` [PATCH v2 04/16] irqchip/gic-v5: Add ITS MMIO register definitions Sascha Bischoff
2026-11-03 13:44 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 05/16] KVM: arm64: gic-v5: Add ITS device skeleton Sascha Bischoff
2026-11-02 20:08 ` sashiko-bot
2026-11-02 19:44 ` [PATCH v2 06/16] KVM: arm64: gic-v5: Add ITS MMIO state emulation Sascha Bischoff
2026-11-02 20:05 ` sashiko-bot
2026-11-03 13:48 ` Fuad Tabba
2026-11-04 2:27 ` Wei-Lin Chang
2026-11-04 23:24 ` Oliver Upton
2026-11-02 19:44 ` [PATCH v2 07/16] KVM: arm64: gic-v5: Add ITS guest table translation emulation Sascha Bischoff
2026-11-02 20:23 ` sashiko-bot
2026-11-04 4:40 ` Wei-Lin Chang
2026-11-05 0:02 ` Oliver Upton [this message]
2026-11-02 19:44 ` [PATCH v2 08/16] KVM: arm64: gic-v5: Add ITS translation cache maintenance Sascha Bischoff
2026-11-03 13:54 ` Fuad Tabba
2026-11-04 22:46 ` Wei-Lin Chang
2026-11-05 0:26 ` Oliver Upton
2026-11-02 19:44 ` [PATCH v2 09/16] KVM: arm64: gic-v5: Add ITS MSI injection Sascha Bischoff
2026-11-02 20:38 ` sashiko-bot
2026-11-03 13:56 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 10/16] KVM: arm64: gic-v5: Add ITS userspace register access Sascha Bischoff
2026-11-02 20:52 ` sashiko-bot
2026-11-03 14:22 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 11/16] irqchip/gic-v5: Enable direct injection in ITS Sascha Bischoff
2026-11-02 20:57 ` sashiko-bot
2026-11-03 14:47 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 12/16] KVM: arm64: vgic: Move direct MSI support helper to common MMIO code Sascha Bischoff
2026-11-02 19:44 ` [PATCH v2 13/16] KVM: arm64: gic-v5: Implement irq forwarding Sascha Bischoff
2026-11-02 21:17 ` sashiko-bot
2026-11-03 15:29 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 14/16] KVM: selftests: Add VGICv5 ITS attribute tests Sascha Bischoff
2026-11-02 19:44 ` [PATCH v2 15/16] KVM: selftests: Add VGICv5 ITS translation cache tests Sascha Bischoff
2026-11-02 21:07 ` sashiko-bot
2026-11-03 16:02 ` Fuad Tabba
2026-11-02 19:44 ` [PATCH v2 16/16] KVM: arm64: gic-v5: Document ITS userspace ABI Sascha Bischoff
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=auvHnnymzccd9OaF@kernel.org \
--to=oupton@kernel.org \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=peter.maydell@linaro.org \
--cc=sascha.bischoff@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=timothy.hayes@arm.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 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.