Re: [PATCH v9 13/25] iommu/arm-smmu-v3-kvm: Add MMIO emulation

From: Nicolin Chen

Date: Fri Nov 06 2026 - 14:57:17 EST


On Thu, Oct 15, 2026 at 08:08:44PM +0000, Mostafa Saleh wrote:
> +static bool smmu_dabt_handler(struct user_pt_regs *regs, u64 esr, u64 addr)
> +{
> + struct hyp_arm_smmu_v3_device *smmu;
> + bool ret;
> +
> + for_each_smmu(smmu) {
> + if (addr < smmu->mmio_addr || addr >= smmu->mmio_addr + smmu->mmio_size)
> + continue;
> + hyp_spin_lock(&smmu->lock);
> + ret = smmu_dabt_device(smmu, regs, esr, addr - smmu->mmio_addr);

Going through the followup patches, I found this smmu_dabt_device
gets really too big. Perhaps it can be bisect to read and write at
least? Something like:

static bool smmu_mmio_handler(smmu, regs, esr, off)
{
/* decode ESR: len, rd, xzr; width check */
if (is_write)
return smmu_mmio_write_handler(smmu, off, len, val);
val = smmu_mmio_read_handler(smmu, off, len);
if (!is_xzr)
regs->regs[rd] = val;
return true;
}

Nicolin