diff mbox

[Xen-devel,v7,13/22] arm/acpi: Map the new created EFI and ACPI tables to Dom0

Message ID 1458913735-2678-14-git-send-email-shannon.zhao@linaro.org
State New
Headers show

Commit Message

Shannon Zhao March 25, 2016, 1:48 p.m. UTC
Map the UEFI and ACPI tables which we created to non-RAM space in Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: flush the cache
---
 xen/arch/arm/domain_build.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Julien Grall March 29, 2016, 3:01 p.m. UTC | #1
Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Map the UEFI and ACPI tables which we created to non-RAM space in Dom0.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

With the suggestion below:

Acked-by: Julien Grall <julien.grall@arm.com>

> ---
> v7: flush the cache
> ---
>   xen/arch/arm/domain_build.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 954e0e3..70c8421 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1723,6 +1723,25 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>       acpi_create_efi_system_table(d, tbl_add);
>       acpi_create_efi_mmap_table(d, &kinfo->mem, tbl_add);
>
> +    /* Map the EFI and ACPI tables to Dom0 */
> +    rc = map_regions_rw_cache(d,
> +                              paddr_to_pfn(d->arch.efi_acpi_gpa),
> +                              PFN_UP(d->arch.efi_acpi_len),
> +                              paddr_to_pfn(virt_to_maddr(d->arch.efi_acpi_table)));
> +    if ( rc != 0 )
> +    {
> +        printk(XENLOG_ERR "Unable to map EFI/ACPI table 0x%"PRIx64
> +               " - 0x%"PRIx64" in domain %d\n",
> +               d->arch.efi_acpi_gpa & PAGE_MASK,
> +               PAGE_ALIGN(d->arch.efi_acpi_gpa + d->arch.efi_acpi_len) - 1,
> +               d->domain_id);
> +        return rc;
> +    }
> +
> +    /* Flush cache of this region in case Dom0 gets wrong data. */

NIT: I think it would be clearer if you say:

"Flush the cache for this region, otherwise DOM0 may read wrong data 
when the cache is disabled."

> +    clean_and_invalidate_dcache_va_range(d->arch.efi_acpi_table,
> +                                         d->arch.efi_acpi_len);
> +
>       return 0;
>   }
>   #else
>

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 954e0e3..70c8421 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1723,6 +1723,25 @@  static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     acpi_create_efi_system_table(d, tbl_add);
     acpi_create_efi_mmap_table(d, &kinfo->mem, tbl_add);
 
+    /* Map the EFI and ACPI tables to Dom0 */
+    rc = map_regions_rw_cache(d,
+                              paddr_to_pfn(d->arch.efi_acpi_gpa),
+                              PFN_UP(d->arch.efi_acpi_len),
+                              paddr_to_pfn(virt_to_maddr(d->arch.efi_acpi_table)));
+    if ( rc != 0 )
+    {
+        printk(XENLOG_ERR "Unable to map EFI/ACPI table 0x%"PRIx64
+               " - 0x%"PRIx64" in domain %d\n",
+               d->arch.efi_acpi_gpa & PAGE_MASK,
+               PAGE_ALIGN(d->arch.efi_acpi_gpa + d->arch.efi_acpi_len) - 1,
+               d->domain_id);
+        return rc;
+    }
+
+    /* Flush cache of this region in case Dom0 gets wrong data. */
+    clean_and_invalidate_dcache_va_range(d->arch.efi_acpi_table,
+                                         d->arch.efi_acpi_len);
+
     return 0;
 }
 #else