[RFC PATCH 24/45] KVM: arm64: smmu-v3: Setup stream table
Mostafa Saleh
smostafa at google.com
Tue Jan 16 00:59:41 PST 2024
Hi Jean,
On Wed, Feb 1, 2023 at 12:59 PM Jean-Philippe Brucker
<jean-philippe at linaro.org> wrote:
>
> Map the stream table allocated by the host into the hypervisor address
> space. When the host mappings are finalized, the table is unmapped from
> the host. Depending on the host configuration, the stream table may have
> one or two levels. Populate the level-2 stream table lazily.
>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe at linaro.org>
> ---
> include/kvm/arm_smmu_v3.h | 4 +
> arch/arm64/kvm/hyp/nvhe/iommu/arm-smmu-v3.c | 133 +++++++++++++++++++-
> 2 files changed, 136 insertions(+), 1 deletion(-)
>
> diff --git a/include/kvm/arm_smmu_v3.h b/include/kvm/arm_smmu_v3.h
> index da36737bc1e0..fc67a3bf5709 100644
> --- a/include/kvm/arm_smmu_v3.h
> +++ b/include/kvm/arm_smmu_v3.h
> @@ -24,6 +24,10 @@ struct hyp_arm_smmu_v3_device {
> u32 cmdq_prod;
> u64 *cmdq_base;
> size_t cmdq_log2size;
> + u64 *strtab_base;
> + size_t strtab_num_entries;
> + size_t strtab_num_l1_entries;
> + u8 strtab_split;
> };
>
> extern size_t kvm_nvhe_sym(kvm_hyp_arm_smmu_v3_count);
> diff --git a/arch/arm64/kvm/hyp/nvhe/iommu/arm-smmu-v3.c b/arch/arm64/kvm/hyp/nvhe/iommu/arm-smmu-v3.c
> index 36ee5724f36f..021bebebd40c 100644
> --- a/arch/arm64/kvm/hyp/nvhe/iommu/arm-smmu-v3.c
> +++ b/arch/arm64/kvm/hyp/nvhe/iommu/arm-smmu-v3.c
> @@ -141,7 +141,6 @@ static int smmu_sync_cmd(struct hyp_arm_smmu_v3_device *smmu)
> return smmu_wait_event(smmu, smmu_cmdq_empty(smmu));
> }
>
> -__maybe_unused
> static int smmu_send_cmd(struct hyp_arm_smmu_v3_device *smmu,
> struct arm_smmu_cmdq_ent *cmd)
> {
> @@ -153,6 +152,82 @@ static int smmu_send_cmd(struct hyp_arm_smmu_v3_device *smmu,
> return smmu_sync_cmd(smmu);
> }
>
> +__maybe_unused
> +static int smmu_sync_ste(struct hyp_arm_smmu_v3_device *smmu, u32 sid)
> +{
> + struct arm_smmu_cmdq_ent cmd = {
> + .opcode = CMDQ_OP_CFGI_STE,
> + .cfgi.sid = sid,
> + .cfgi.leaf = true,
> + };
> +
> + return smmu_send_cmd(smmu, &cmd);
> +}
> +
I see the page tables are properly configured for ARM_SMMU_FEAT_COHERENCY but no
handling for the STE or CMDQ, I believe here we should have something as:
if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY))
kvm_flush_dcache_to_poc(step, STRTAB_STE_DWORDS << 3);
Similarly in "smmu_add_cmd" for the command queue. Or use NC mapping
(which doesn't exist
upstream as far as I can see)
Thanks,
Mostafa
More information about the linux-arm-kernel
mailing list