Re: [PATCH v9 14/25] iommu/arm-smmu-v3-kvm: Shadow the command queue

From: Mostafa Saleh

Date: Mon Nov 09 2026 - 06:37:48 EST


On Thu, Nov 05, 2026 at 05:59:33PM -0800, Nicolin Chen wrote:
> One more thing:
>
> On Thu, Oct 15, 2026 at 08:08:45PM +0000, Mostafa Saleh wrote:
> > +/*
> > + * The kernel part of the driver allocates and zeroes the shadow cmdq. Take
> > + * ownership of it and program it into the hardware.
> > + */
> > +static int smmu_init_cmdq(struct hyp_arm_smmu_v3_device *smmu)
> > +{
> > + size_t cmdq_nr_pages;
> > + int ret;
> > +
> > + smmu->cmdq.llq.max_n_shift = min(smmu->cmdq.llq.max_n_shift, smmu->cmdq_max_shift);
>
> Given this is the cmdq used to run commands eventually..
>
> > +static void smmu_emulate_cmdq_enable(struct hyp_arm_smmu_v3_device *smmu)
> > +{
> > + u32 shift = smmu->cmdq_host.q_base & Q_BASE_LOG2SIZE;
> > +
> > + smmu->cmdq_host.llq.max_n_shift = min(shift, smmu->cmdq_max_shift);
>
> .. should this be min(shift, smmu->cmdq.llq.max_n_shift)?
>
> Otherwise, a buggy guest SW might setup a larger queue and number
> of commands?

Makes sense, as in patch#16, it caps the host view in the emulated IDR1:
val = readl_relaxed(smmu->base + ARM_SMMU_IDR1);
val &= ~IDR1_CMDQS;
val |= FIELD_PREP(IDR1_CMDQS, smmu->cmdq.llq.max_n_shift);
Thanks,
Mostafa

>
> Nicolin