On 06.07.2022 17:32, Marek Marczykowski-Górecki wrote:
> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
> @@ -1078,6 +1078,20 @@ static inline bool_t is_ivmd_block(u8 type)
>              type == ACPI_IVRS_TYPE_MEMORY_IOMMU);
>  }
>  
> +static int __init cf_check add_one_extra_ivmd(xen_pfn_t start, xen_ulong_t 
> nr, u32 id, void *ctxt)
> +{
> +    struct acpi_ivrs_memory ivmd;
> +
> +    ivmd.start_address = start << PAGE_SHIFT;
> +    ivmd.memory_length = nr << PAGE_SHIFT;

Aren't these at risk of truncation on 32-bit architectures? We have
suitable wrappers for such conversions, avoiding such issues.

> +    ivmd.header.flags = ACPI_IVMD_UNITY |
> +                        ACPI_IVMD_READ | ACPI_IVMD_WRITE;
> +    ivmd.header.length = sizeof(ivmd);
> +    ivmd.header.device_id = id;
> +    ivmd.header.type = ACPI_IVRS_TYPE_MEMORY_ONE;

Please make these the variable's initializer.

Jan

Reply via email to