xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64
@ 2016-03-25 13:48 Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
                   ` (22 more replies)
  0 siblings, 23 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

These patches are Part 4 (and last part) of the previous patch set I
sent which adds ACPI support for arm64 on Xen[1]. Split them as an
individual set for convenient reviewing.

These patches create UEFI and ACPI tables which are mapped to Dom0's
space and add other preparations for Dom0 to use ACPI. Then at last
enable ACPI support on ARM64.

See individual patch for changes.

Thanks,
Shannon
[1] http://lists.xenproject.org/archives/html/xen-devel/2015-11/msg01831.html

Parth Dixit (1):
  arm/p2m: Add helper functions to map memory regions

Shannon Zhao (21):
  arm/acpi: Estimate memory required for acpi/efi tables
  arm/acpi: Add a helper function to get the acpi table offset
  arm/acpi: Prepare FADT table for Dom0
  arm/gic: Add a new callback for creating MADT table for Dom0
  arm/acpi: Prepare MADT table for Dom0
  arm/acpi: Prepare STAO table for Dom0
  arm/acpi: Prepare XSDT table for Dom0
  arm/acpi: Prepare RSDP table for Dom0
  arm/acpi: Map all other tables for Dom0
  arm/acpi: Prepare EFI system table for Dom0
  arm/acpi: Prepare EFI memory descriptor for Dom0
  arm/acpi: Map the new created EFI and ACPI tables to Dom0
  arm/acpi: Create min DT stub for Dom0
  arm/acpi: Permit access all Xen unused SPIs for Dom0
  arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically
  arm/gic: Add a new callback to deny Dom0 access to GIC regions
  arm/acpi: Permit MMIO access of Xen unused devices for Dom0
  hvm/params: Add a new delivery type for event-channel in
    HVM_PARAM_CALLBACK_IRQ
  xen/acpi: Fix event-channel interrupt when booting with ACPI
  xen/arm: Add a hypercall for device mmio mapping
  xen/arm64: Add ACPI support

 docs/misc/arm/device-tree/guest.txt |  60 ++++
 xen/arch/arm/Kconfig                |   9 +
 xen/arch/arm/acpi/lib.c             |  20 ++
 xen/arch/arm/domain.c               |   4 +
 xen/arch/arm/domain_build.c         | 631 +++++++++++++++++++++++++++++++++++-
 xen/arch/arm/efi/Makefile           |   1 +
 xen/arch/arm/efi/efi-boot.h         |   4 +-
 xen/arch/arm/efi/efi-dom0.c         | 187 +++++++++++
 xen/arch/arm/efi/efi-dom0.h         |   8 +
 xen/arch/arm/gic-v2.c               |  69 ++++
 xen/arch/arm/gic-v3.c               |  97 ++++++
 xen/arch/arm/gic.c                  |  10 +
 xen/arch/arm/mm.c                   |   3 +
 xen/arch/arm/p2m.c                  |  48 +++
 xen/arch/arm/vgic.c                 |  32 ++
 xen/common/efi/runtime.c            |  12 +-
 xen/common/memory.c                 |  16 +
 xen/include/asm-arm/acpi.h          |   2 +
 xen/include/asm-arm/gic.h           |   6 +
 xen/include/asm-arm/p2m.h           |  15 +
 xen/include/asm-arm/setup.h         |  11 +
 xen/include/public/hvm/params.h     |  13 +
 xen/include/public/memory.h         |   1 +
 23 files changed, 1250 insertions(+), 9 deletions(-)
 create mode 100644 docs/misc/arm/device-tree/guest.txt
 create mode 100644 xen/arch/arm/efi/efi-dom0.c
 create mode 100644 xen/arch/arm/efi/efi-dom0.h

-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-26 13:02   ` Stefano Stabellini
  2016-03-29 10:24   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 02/22] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
                   ` (21 subsequent siblings)
  22 siblings, 2 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Estimate the memory required for loading acpi/efi tables in Dom0. Make
the length of each table aligned with 64bit. Alloc the pages to store
the new created EFI and ACPI tables and free these pages when
destroying domain.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v7: address several comments from Julien
---
 xen/arch/arm/domain.c       |   4 ++
 xen/arch/arm/domain_build.c | 103 +++++++++++++++++++++++++++++++++++++++++++-
 xen/arch/arm/efi/Makefile   |   1 +
 xen/arch/arm/efi/efi-boot.h |   4 +-
 xen/arch/arm/efi/efi-dom0.c |  59 +++++++++++++++++++++++++
 xen/arch/arm/efi/efi-dom0.h |   8 ++++
 xen/include/asm-arm/setup.h |   2 +
 7 files changed, 177 insertions(+), 4 deletions(-)
 create mode 100644 xen/arch/arm/efi/efi-dom0.c
 create mode 100644 xen/arch/arm/efi/efi-dom0.h

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 3d274ae..1365b4a 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -640,6 +640,10 @@ void arch_domain_destroy(struct domain *d)
     domain_vgic_free(d);
     domain_vuart_free(d);
     free_xenheap_page(d->shared_info);
+#ifdef CONFIG_ACPI
+    free_xenheap_pages(d->arch.efi_acpi_table,
+                       get_order_from_bytes(d->arch.efi_acpi_len));
+#endif
 }
 
 void arch_domain_shutdown(struct domain *d)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 83676e4..13027ea 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -12,6 +12,8 @@
 #include <xen/libfdt/libfdt.h>
 #include <xen/guest_access.h>
 #include <xen/iocap.h>
+#include <xen/acpi.h>
+#include <acpi/actables.h>
 #include <asm/device.h>
 #include <asm/setup.h>
 #include <asm/platform.h>
@@ -1354,6 +1356,101 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
     return -EINVAL;
 }
 
+#ifdef CONFIG_ACPI
+static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo)
+{
+    size_t efi_size, acpi_size, madt_size;
+    u64 addr;
+    struct acpi_table_rsdp *rsdp_tbl;
+    struct acpi_table_header *table;
+
+    efi_size = estimate_efi_size(kinfo->mem.nr_banks);
+
+    acpi_size = ROUNDUP(sizeof(struct acpi_table_fadt), 8);
+    acpi_size += ROUNDUP(sizeof(struct acpi_table_stao), 8);
+
+    madt_size = sizeof(struct acpi_table_madt)
+                + sizeof(struct acpi_madt_generic_interrupt) * d->max_vcpus
+                + sizeof(struct acpi_madt_generic_distributor);
+    if ( d->arch.vgic.version == GIC_V3 )
+        madt_size += sizeof(struct acpi_madt_generic_redistributor)
+                     * d->arch.vgic.nr_regions;
+    acpi_size += ROUNDUP(madt_size, 8);
+
+    addr = acpi_os_get_root_pointer();
+    if ( !addr )
+    {
+        printk("Unable to get acpi root pointer\n");
+        return -EINVAL;
+    }
+
+    rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp));
+    if ( !rsdp_tbl )
+    {
+        printk("Unable to map RSDP table\n");
+        return -EINVAL;
+    }
+
+    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
+                               sizeof(struct acpi_table_header));
+    if ( !table )
+    {
+        printk("Unable to map XSDT table\n");
+        return -EINVAL;
+    }
+
+    /* Add place for STAO table in XSDT table */
+    acpi_size += ROUNDUP(table->length + sizeof(u64), 8);
+    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
+    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
+
+    acpi_size += ROUNDUP(sizeof(struct acpi_table_rsdp), 8);
+    d->arch.efi_acpi_len = PAGE_ALIGN(ROUNDUP(efi_size, 8)
+                                      + ROUNDUP(acpi_size, 8));
+
+    return 0;
+}
+
+static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
+{
+    int rc = 0;
+    int order;
+
+    rc = estimate_acpi_efi_size(d, kinfo);
+    if ( rc != 0 )
+        return rc;
+
+    order = get_order_from_bytes(d->arch.efi_acpi_len);
+    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
+    if ( d->arch.efi_acpi_table == NULL )
+    {
+        printk("unable to allocate memory!\n");
+        return -ENOMEM;
+    }
+    memset(d->arch.efi_acpi_table, 0, d->arch.efi_acpi_len);
+
+    /*
+     * For ACPI, Dom0 doesn't use kinfo->gnttab_start to get the grant table
+     * region. So we use it as the ACPI table mapped address. Also it needs to
+     * check if the size of grant table region is enough for those ACPI tables.
+     */
+    d->arch.efi_acpi_gpa = kinfo->gnttab_start;
+    if ( kinfo->gnttab_size < d->arch.efi_acpi_len )
+    {
+        printk("The grant table region is not enough to fit the ACPI tables!\n");
+        return -EINVAL;
+    }
+
+    return 0;
+}
+#else
+static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
+{
+    /* Only booting with ACPI will hit here */
+    BUG();
+    return -EINVAL;
+}
+#endif
 static void dtb_load(struct kernel_info *kinfo)
 {
     void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr;
@@ -1540,7 +1637,11 @@ int construct_dom0(struct domain *d)
     allocate_memory(d, &kinfo);
     find_gnttab_region(d, &kinfo);
 
-    rc = prepare_dtb(d, &kinfo);
+    if ( acpi_disabled )
+        rc = prepare_dtb(d, &kinfo);
+    else
+        rc = prepare_acpi(d, &kinfo);
+
     if ( rc < 0 )
         return rc;
 
diff --git a/xen/arch/arm/efi/Makefile b/xen/arch/arm/efi/Makefile
index 729e53e..d34c916 100644
--- a/xen/arch/arm/efi/Makefile
+++ b/xen/arch/arm/efi/Makefile
@@ -1,3 +1,4 @@
 CFLAGS += -fshort-wchar
 
 obj-y +=  boot.init.o runtime.o
+obj-$(CONFIG_ACPI) +=  efi-dom0.init.o
diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index c58caca..045d6ce 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -7,6 +7,7 @@
 #include <xen/libfdt/libfdt.h>
 #include <asm/setup.h>
 #include <asm/smp.h>
+#include "efi-dom0.h"
 
 void noreturn efi_xen_start(void *fdt_ptr, uint32_t fdt_size);
 void __flush_dcache_area(const void *vaddr, unsigned long size);
@@ -17,9 +18,6 @@ void __flush_dcache_area(const void *vaddr, unsigned long size);
 static struct file __initdata dtbfile;
 static void __initdata *fdt;
 static void __initdata *memmap;
-#ifdef CONFIG_ACPI
-static struct meminfo __initdata acpi_mem;
-#endif
 
 static int __init setup_chosen_node(void *fdt, int *addr_cells, int *size_cells)
 {
diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
new file mode 100644
index 0000000..021aa02
--- /dev/null
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -0,0 +1,59 @@
+/*
+ *  efi-dom0.c - Domain0 EFI Boot Support
+ *
+ *  Copyright (C) 2016 Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include "efi.h"
+#include "efi-dom0.h"
+#include <asm/setup.h>
+#include <asm/acpi.h>
+
+struct meminfo __initdata acpi_mem;
+/* Constant to indicate "Xen" in unicode u16 format */
+static const CHAR16 xen_efi_fw_vendor[] = {0x0058, 0x0065, 0x006E, 0x0000};
+
+size_t __init estimate_efi_size(int mem_nr_banks)
+{
+    size_t size;
+    size_t est_size = sizeof(EFI_SYSTEM_TABLE);
+    size_t ect_size = sizeof(EFI_CONFIGURATION_TABLE);
+    size_t emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
+    size_t fw_vendor_size = sizeof(xen_efi_fw_vendor);
+    int acpi_mem_nr_banks = 0;
+
+    if ( !acpi_disabled )
+        acpi_mem_nr_banks = acpi_mem.nr_banks;
+
+    size = ROUNDUP(est_size + ect_size + fw_vendor_size, 8);
+    /* plus 1 for new created tables */
+    size += ROUNDUP(emd_size * (mem_nr_banks + acpi_mem_nr_banks + 1), 8);
+
+    return size;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/efi/efi-dom0.h b/xen/arch/arm/efi/efi-dom0.h
new file mode 100644
index 0000000..3cd4caa
--- /dev/null
+++ b/xen/arch/arm/efi/efi-dom0.h
@@ -0,0 +1,8 @@
+#ifndef __ARM_EFI_DOM0_H__
+#define __ARM_EFI_DOM0_H__
+
+#include <asm/setup.h>
+
+extern struct meminfo acpi_mem;
+
+#endif
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 30ac53b..7f233a1 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -51,6 +51,8 @@ void arch_init_memory(void);
 
 void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
 
+size_t estimate_efi_size(int mem_nr_banks);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 02/22] arm/acpi: Add a helper function to get the acpi table offset
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 10:48   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 03/22] arm/acpi: Prepare FADT table for Dom0 Shannon Zhao
                   ` (20 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

These tables are aligned with 64bit.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: add commnets to explain what thsi function does
---
 xen/arch/arm/acpi/lib.c    | 20 ++++++++++++++++++++
 xen/include/asm-arm/acpi.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index db5c4d8..cee2454 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -60,3 +60,23 @@ bool_t __init acpi_psci_hvc_present(void)
 {
     return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
 }
+
+/*
+ * This function is used to get the offset of some new created ACPI or EFI table
+ * in the allocated memory region. Currently the tables should be created in the
+ * order of enum EFI_MEM_RES.
+ */
+paddr_t __init acpi_get_table_offset(struct membank tbl_add[],
+                                     EFI_MEM_RES index)
+{
+    int i;
+    paddr_t offset = 0;
+
+    for ( i = 0; i < index; i++ )
+    {
+        /* Aligned with 64bit (8 bytes) */
+        offset += ROUNDUP(tbl_add[i].size, 8);
+    }
+
+    return offset;
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 7f59761..569fc31 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -25,6 +25,7 @@
 
 #include <xen/init.h>
 #include <asm/page.h>
+#include <asm/setup.h>
 
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
@@ -45,6 +46,7 @@ typedef enum {
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
 void __init acpi_smp_init_cpus(void);
+paddr_t acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
 
 #ifdef CONFIG_ACPI
 extern bool_t acpi_disabled;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 03/22] arm/acpi: Prepare FADT table for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 02/22] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 04/22] arm/gic: Add a new callback for creating MADT " Shannon Zhao
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Copy and modify FADT table before passing it to Dom0. Set PSCI_COMPLIANT
and PSCI_USE_HVC.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 13027ea..0e44e10 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,44 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+
+static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
+{
+    struct acpi_table_header *table = NULL;
+    struct acpi_table_fadt *fadt = NULL;
+    u64 table_size;
+    acpi_status status;
+    u8 *base_ptr;
+    u8 checksum;
+
+    status = acpi_get_table(ACPI_SIG_FADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        printk("Failed to get FADT table, %s\n", msg);
+        return -EINVAL;
+    }
+
+    table_size = table->length;
+    base_ptr = d->arch.efi_acpi_table
+               + acpi_get_table_offset(tbl_add, TBL_FADT);
+    ACPI_MEMCPY(base_ptr, table, table_size);
+    fadt = (struct acpi_table_fadt *)base_ptr;
+
+    /* Set PSCI_COMPLIANT and PSCI_USE_HVC */
+    fadt->arm_boot_flags |= (ACPI_FADT_PSCI_COMPLIANT | ACPI_FADT_PSCI_USE_HVC);
+    checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, fadt), table_size);
+    fadt->header.checksum -= checksum;
+
+    tbl_add[TBL_FADT].start = d->arch.efi_acpi_gpa
+                              + acpi_get_table_offset(tbl_add, TBL_FADT);
+    tbl_add[TBL_FADT].size = table_size;
+
+    return 0;
+}
+
 static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo)
 {
     size_t efi_size, acpi_size, madt_size;
@@ -1415,6 +1453,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
 {
     int rc = 0;
     int order;
+    struct membank tbl_add[TBL_MMAX] = {};
 
     rc = estimate_acpi_efi_size(d, kinfo);
     if ( rc != 0 )
@@ -1441,6 +1480,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
         return -EINVAL;
     }
 
+    rc = acpi_create_fadt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 04/22] arm/gic: Add a new callback for creating MADT table for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (2 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 03/22] arm/acpi: Prepare FADT table for Dom0 Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 12:47   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 05/22] arm/acpi: Prepare " Shannon Zhao
                   ` (18 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Add a new member in gic_hw_operations which is used to create MADT table
for Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: make other fields of GICC zero
---
 xen/arch/arm/gic-v2.c     | 42 +++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic-v3.c     | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic.c        |  5 +++++
 xen/include/asm-arm/gic.h |  3 +++
 4 files changed, 106 insertions(+)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 0fcb894..38e3216 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -685,6 +685,43 @@ static void __init gicv2_dt_init(void)
 }
 
 #ifdef CONFIG_ACPI
+static int gicv2_make_hwdom_madt(const struct domain *d, u32 offset)
+{
+    struct acpi_subtable_header *header;
+    struct acpi_madt_generic_interrupt *host_gicc, *gicc;
+    u32 i, size, table_len = 0;
+    u8 *base_ptr = d->arch.efi_acpi_table + offset;
+
+    header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
+    if ( !header )
+    {
+        printk("Can't get GICC entry");
+        return -EINVAL;
+    }
+
+    host_gicc = container_of(header, struct acpi_madt_generic_interrupt,
+                             header);
+    size = sizeof(struct acpi_madt_generic_interrupt);
+    /* Add Generic Interrupt */
+    for ( i = 0; i < d->max_vcpus; i++ )
+    {
+        gicc = (struct acpi_madt_generic_interrupt *)(base_ptr + table_len);
+        ACPI_MEMCPY(gicc, host_gicc, size);
+        gicc->cpu_interface_number = i;
+        gicc->uid = i;
+        gicc->flags = ACPI_MADT_ENABLED;
+        gicc->arm_mpidr = vcpuid_to_vaffinity(i);
+        gicc->parking_version = 0;
+        gicc->performance_interrupt = 0;
+        gicc->gicv_base_address = 0;
+        gicc->gich_base_address = 0;
+        gicc->vgic_interrupt = 0;
+        table_len += size;
+    }
+
+    return table_len;
+}
+
 static int __init
 gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
                         const unsigned long end)
@@ -776,6 +813,10 @@ static void __init gicv2_acpi_init(void)
 }
 #else
 static void __init gicv2_acpi_init(void) { }
+static int gicv2_make_hwdom_madt(const struct domain *d, u32 offset)
+{
+    return 0;
+}
 #endif
 
 static int __init gicv2_init(void)
@@ -868,6 +909,7 @@ const static struct gic_hw_operations gicv2_ops = {
     .read_vmcr_priority  = gicv2_read_vmcr_priority,
     .read_apr            = gicv2_read_apr,
     .make_hwdom_dt_node  = gicv2_make_hwdom_dt_node,
+    .make_hwdom_madt     = gicv2_make_hwdom_madt,
 };
 
 /* Set up the GIC */
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index f83fd88..52ee23c 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1236,6 +1236,57 @@ static void __init gicv3_dt_init(void)
 }
 
 #ifdef CONFIG_ACPI
+static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
+{
+    struct acpi_subtable_header *header;
+    struct acpi_madt_generic_interrupt *host_gicc, *gicc;
+    struct acpi_madt_generic_redistributor *gicr;
+    u8 *base_ptr = d->arch.efi_acpi_table + offset;
+    u32 i, table_len = 0, size;
+
+    /* Add Generic Interrupt */
+    header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
+    if ( !header )
+    {
+        printk("Can't get GICC entry");
+        return -EINVAL;
+    }
+
+    host_gicc = container_of(header, struct acpi_madt_generic_interrupt,
+                             header);
+    size = sizeof(struct acpi_madt_generic_interrupt);
+    for ( i = 0; i < d->max_vcpus; i++ )
+    {
+        gicc = (struct acpi_madt_generic_interrupt *)(base_ptr + table_len);
+        ACPI_MEMCPY(gicc, host_gicc, size);
+        gicc->cpu_interface_number = i;
+        gicc->uid = i;
+        gicc->flags = ACPI_MADT_ENABLED;
+        gicc->arm_mpidr = vcpuid_to_vaffinity(i);
+        gicc->parking_version = 0;
+        gicc->performance_interrupt = 0;
+        gicc->gicv_base_address = 0;
+        gicc->gich_base_address = 0;
+        gicc->gicr_base_address = 0;
+        gicc->vgic_interrupt = 0;
+        table_len += size;
+    }
+
+    /* Add Generic Redistributor */
+    size = sizeof(struct acpi_madt_generic_redistributor);
+    for ( i = 0; i < d->arch.vgic.nr_regions; i++ )
+    {
+        gicr = (struct acpi_madt_generic_redistributor *)(base_ptr + table_len);
+        gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
+        gicr->header.length = size;
+        gicr->base_address = d->arch.vgic.rdist_regions[i].base;
+        gicr->length = d->arch.vgic.rdist_regions[i].size;
+        table_len += size;
+    }
+
+    return table_len;
+}
+
 static int __init
 gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
                         const unsigned long end)
@@ -1380,6 +1431,10 @@ static void __init gicv3_acpi_init(void)
 }
 #else
 static void __init gicv3_acpi_init(void) { }
+static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
+{
+    return 0;
+}
 #endif
 
 /* Set up the GIC */
@@ -1474,6 +1529,7 @@ static const struct gic_hw_operations gicv3_ops = {
     .read_apr            = gicv3_read_apr,
     .secondary_init      = gicv3_secondary_cpu_init,
     .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
+    .make_hwdom_madt     = gicv3_make_hwdom_madt,
 };
 
 static int __init gicv3_dt_preinit(struct dt_device_node *node, const void *data)
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index fbbe37f..b3c1eb3 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -739,6 +739,11 @@ int gic_make_hwdom_dt_node(const struct domain *d,
     return gic_hw_ops->make_hwdom_dt_node(d, gic, fdt);
 }
 
+int gic_make_hwdom_madt(const struct domain *d, u32 offset)
+{
+    return gic_hw_ops->make_hwdom_madt(d, offset);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index 7bd06e1..8130136 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -358,12 +358,15 @@ struct gic_hw_operations {
     /* Create GIC node for the hardware domain */
     int (*make_hwdom_dt_node)(const struct domain *d,
                               const struct dt_device_node *gic, void *fdt);
+    /* Create MADT table for the hardware domain */
+    int (*make_hwdom_madt)(const struct domain *d, u32 offset);
 };
 
 void register_gic_ops(const struct gic_hw_operations *ops);
 int gic_make_hwdom_dt_node(const struct domain *d,
                            const struct dt_device_node *gic,
                            void *fdt);
+int gic_make_hwdom_madt(const struct domain *d, u32 offset);
 
 #endif /* __ASSEMBLY__ */
 #endif
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 05/22] arm/acpi: Prepare MADT table for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (3 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 04/22] arm/gic: Add a new callback for creating MADT " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 06/22] arm/acpi: Prepare STAO " Shannon Zhao
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Copy main MADT table contents and distributor subtable from physical
ACPI MADT table. Make other subtables through the callback of
gic_hw_ops.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 0e44e10..86fc3e0 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,62 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+static int acpi_create_madt(struct domain *d, struct membank tbl_add[])
+{
+    struct acpi_table_header *table = NULL;
+    struct acpi_table_madt *madt = NULL;
+    struct acpi_subtable_header *header;
+    struct acpi_madt_generic_distributor *gicd;
+    u32 table_size = sizeof(struct acpi_table_madt);
+    u32 offset = acpi_get_table_offset(tbl_add, TBL_MADT);
+    int ret;
+    acpi_status status;
+    u8 *base_ptr, checksum;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        printk("Failed to get MADT table, %s\n", msg);
+        return -EINVAL;
+    }
+
+    base_ptr = d->arch.efi_acpi_table + offset;
+    ACPI_MEMCPY(base_ptr, table, table_size);
+
+    /* Add Generic Distributor. */
+    header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+    if ( !header )
+    {
+        printk("Can't get GICD entry\n");
+        return -EINVAL;
+    }
+    gicd = container_of(header, struct acpi_madt_generic_distributor, header);
+    ACPI_MEMCPY(base_ptr + table_size, gicd,
+                sizeof(struct acpi_madt_generic_distributor));
+    table_size += sizeof(struct acpi_madt_generic_distributor);
+
+    /* Add other subtables. */
+    ret = gic_make_hwdom_madt(d, offset + table_size);
+    if ( ret < 0 )
+    {
+        printk("Failed to get other subtables\n");
+        return -EINVAL;
+    }
+    table_size += ret;
+
+    madt = (struct acpi_table_madt *)base_ptr;
+    madt->header.length = table_size;
+    checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, madt), table_size);
+    madt->header.checksum -= checksum;
+
+    tbl_add[TBL_MADT].start = d->arch.efi_acpi_gpa + offset;
+    tbl_add[TBL_MADT].size = table_size;
+
+    return 0;
+}
 
 static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
 {
@@ -1484,6 +1540,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_madt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 06/22] arm/acpi: Prepare STAO table for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (4 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 05/22] arm/acpi: Prepare " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 07/22] arm/acpi: Prepare XSDT " Shannon Zhao
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Create STAO table for Dom0. This table is used to tell Dom0 whether it
should ignore UART defined in SPCR table or the ACPI namespace names.

Look at below url for details:
http://wiki.xenproject.org/mediawiki/images/0/02/Status-override-table.pdf

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 86fc3e0..c09fb26 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,43 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
+{
+    struct acpi_table_header *table = NULL;
+    struct acpi_table_stao *stao = NULL;
+    u32 table_size = sizeof(struct acpi_table_stao);
+    u32 offset = acpi_get_table_offset(tbl_add, TBL_STAO);
+    acpi_status status;
+    u8 *base_ptr, checksum;
+
+    /* Copy OEM and ASL compiler fields from another table, use MADT */
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        printk("STAO: Failed to get MADT table, %s\n", msg);
+        return -EINVAL;
+    }
+
+    base_ptr = d->arch.efi_acpi_table + offset;
+    ACPI_MEMCPY(base_ptr, table, sizeof(struct acpi_table_header));
+
+    stao = (struct acpi_table_stao *)base_ptr;
+    ACPI_MEMCPY(stao->header.signature, ACPI_SIG_STAO, 4);
+    stao->header.revision = 1;
+    stao->header.length = table_size;
+    stao->ignore_uart = 1;
+    checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, stao), table_size);
+    stao->header.checksum -= checksum;
+
+    tbl_add[TBL_STAO].start = d->arch.efi_acpi_gpa + offset;
+    tbl_add[TBL_STAO].size = table_size;
+
+    return 0;
+}
+
 static int acpi_create_madt(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
@@ -1544,6 +1581,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_stao(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 07/22] arm/acpi: Prepare XSDT table for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (5 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 06/22] arm/acpi: Prepare STAO " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 08/22] arm/acpi: Prepare RSDP " Shannon Zhao
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Copy and modify XSDT table before passing it to Dom0. Replace the entry
value of the copied table. Add a new entry for STAO table as well. And
keep entry value of other reused tables unchanged.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c | 72 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index c09fb26..cd501ff 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,74 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+static void acpi_xsdt_modify_entry(u64 entry[], unsigned long entry_count,
+                                   char *signature, u64 addr)
+{
+    int i;
+    struct acpi_table_header *table;
+    u64 size = sizeof(struct acpi_table_header);
+
+    for( i = 0; i < entry_count; i++ )
+    {
+        table = acpi_os_map_memory(entry[i], size);
+        if ( ACPI_COMPARE_NAME(table->signature, signature) )
+        {
+            entry[i] = addr;
+            acpi_os_unmap_memory(table, size);
+            break;
+        }
+        acpi_os_unmap_memory(table, size);
+    }
+}
+
+static int acpi_create_xsdt(struct domain *d, struct membank tbl_add[])
+{
+    struct acpi_table_header *table = NULL;
+    struct acpi_table_rsdp *rsdp_tbl;
+    struct acpi_table_xsdt *xsdt = NULL;
+    u64 table_size, addr;
+    unsigned long entry_count;
+    u8 *base_ptr;
+    u8 checksum;
+
+    addr = acpi_os_get_root_pointer();
+    if ( !addr )
+    {
+        printk("Unable to get acpi root pointer\n");
+        return -EINVAL;
+    }
+    rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp));
+    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
+                               sizeof(struct acpi_table_header));
+
+    /* Add place for STAO table in XSDT table */
+    table_size = table->length + sizeof(u64);
+    entry_count = (table->length - sizeof(struct acpi_table_header))
+                  / sizeof(u64);
+    base_ptr = d->arch.efi_acpi_table
+               + acpi_get_table_offset(tbl_add, TBL_XSDT);
+    ACPI_MEMCPY(base_ptr, table, table->length);
+    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
+    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
+
+    xsdt = (struct acpi_table_xsdt *)base_ptr;
+    acpi_xsdt_modify_entry(xsdt->table_offset_entry, entry_count,
+                           ACPI_SIG_FADT, tbl_add[TBL_FADT].start);
+    acpi_xsdt_modify_entry(xsdt->table_offset_entry, entry_count,
+                           ACPI_SIG_MADT, tbl_add[TBL_MADT].start);
+    xsdt->table_offset_entry[entry_count] = tbl_add[TBL_STAO].start;
+
+    xsdt->header.length = table_size;
+    checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, xsdt), table_size);
+    xsdt->header.checksum -= checksum;
+
+    tbl_add[TBL_XSDT].start = d->arch.efi_acpi_gpa
+                              + acpi_get_table_offset(tbl_add, TBL_XSDT);
+    tbl_add[TBL_XSDT].size = table_size;
+
+    return 0;
+}
+
 static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
@@ -1585,6 +1653,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_xsdt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 08/22] arm/acpi: Prepare RSDP table for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (6 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 07/22] arm/acpi: Prepare XSDT " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 09/22] arm/p2m: Add helper functions to map memory regions Shannon Zhao
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Copy RSDP table and replace rsdp->xsdt_physical_address with the address
of XSDT table, so it can point to the right XSDT table.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index cd501ff..eeb1359 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,40 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+static int acpi_create_rsdp(struct domain *d, struct membank tbl_add[])
+{
+
+    struct acpi_table_rsdp *rsdp = NULL;
+    u64 addr;
+    u64 table_size = sizeof(struct acpi_table_rsdp);
+    u8 *base_ptr;
+    u8 checksum;
+
+    addr = acpi_os_get_root_pointer();
+    if ( !addr  )
+    {
+        printk("Unable to get acpi root pointer\n");
+        return -EINVAL;
+    }
+    rsdp = acpi_os_map_memory(addr, table_size);
+    base_ptr = d->arch.efi_acpi_table
+               + acpi_get_table_offset(tbl_add, TBL_RSDP);
+    ACPI_MEMCPY(base_ptr, rsdp, table_size);
+    acpi_os_unmap_memory(rsdp, table_size);
+
+    rsdp = (struct acpi_table_rsdp *)base_ptr;
+    /* Replace xsdt_physical_address */
+    rsdp->xsdt_physical_address = tbl_add[TBL_XSDT].start;
+    checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, rsdp), table_size);
+    rsdp->checksum = rsdp->checksum - checksum;
+
+    tbl_add[TBL_RSDP].start = d->arch.efi_acpi_gpa
+                              + acpi_get_table_offset(tbl_add, TBL_RSDP);
+    tbl_add[TBL_RSDP].size = table_size;
+
+    return 0;
+}
+
 static void acpi_xsdt_modify_entry(u64 entry[], unsigned long entry_count,
                                    char *signature, u64 addr)
 {
@@ -1657,6 +1691,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_rsdp(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 09/22] arm/p2m: Add helper functions to map memory regions
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (7 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 08/22] arm/acpi: Prepare RSDP " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 12:49   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 10/22] arm/acpi: Map all other tables for Dom0 Shannon Zhao
                   ` (13 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, julien.grall, stefano.stabellini, shannon.zhao,
	zhaoshenglong, Parth Dixit

From: Parth Dixit <parth.dixit@linaro.org>

Create a helper function for mapping with cached attributes and
read-write range.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: rename to map_regions_rw_cache
---
 xen/arch/arm/p2m.c        | 26 ++++++++++++++++++++++++++
 xen/include/asm-arm/p2m.h | 10 ++++++++++
 2 files changed, 36 insertions(+)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index a2a9c4b..7e5f5d1 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1218,6 +1218,32 @@ int p2m_populate_ram(struct domain *d,
                              d->arch.p2m.default_access);
 }
 
+int map_regions_rw_cache(struct domain *d,
+                         unsigned long start_gfn,
+                         unsigned long nr,
+                         unsigned long mfn)
+{
+    return apply_p2m_changes(d, INSERT,
+                             pfn_to_paddr(start_gfn),
+                             pfn_to_paddr(start_gfn + nr),
+                             pfn_to_paddr(mfn),
+                             MATTR_MEM, 0, p2m_mmio_direct,
+                             p2m_access_rw);
+}
+
+int unmap_regions_rw_cache(struct domain *d,
+                           unsigned long start_gfn,
+                           unsigned long nr,
+                           unsigned long mfn)
+{
+    return apply_p2m_changes(d, REMOVE,
+                             pfn_to_paddr(start_gfn),
+                             pfn_to_paddr(start_gfn + nr),
+                             pfn_to_paddr(mfn),
+                             MATTR_MEM, 0, p2m_invalid,
+                             p2m_access_rw);
+}
+
 int map_mmio_regions(struct domain *d,
                      unsigned long start_gfn,
                      unsigned long nr,
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 433952a..55626b4 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -144,6 +144,16 @@ int p2m_cache_flush(struct domain *d, xen_pfn_t start_mfn, xen_pfn_t end_mfn);
 /* Setup p2m RAM mapping for domain d from start-end. */
 int p2m_populate_ram(struct domain *d, paddr_t start, paddr_t end);
 
+int map_regions_rw_cache(struct domain *d,
+                         unsigned long start_gfn,
+                         unsigned long nr_mfns,
+                         unsigned long mfn);
+
+int unmap_regions_rw_cache(struct domain *d,
+                           unsigned long start_gfn,
+                           unsigned long nr_mfns,
+                           unsigned long mfn);
+
 int guest_physmap_add_entry(struct domain *d,
                             unsigned long gfn,
                             unsigned long mfn,
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 10/22] arm/acpi: Map all other tables for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (8 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 09/22] arm/p2m: Add helper functions to map memory regions Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 13:02   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 11/22] arm/acpi: Prepare EFI system table " Shannon Zhao
                   ` (12 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Map all other ACPI tables into Dom0 using 1:1 mappings.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: Fix comments and printk log
---
 xen/arch/arm/domain_build.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index eeb1359..1bfb2fc 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,30 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+static void acpi_map_other_tables(struct domain *d)
+{
+    int i;
+    unsigned long res;
+    u64 addr, size;
+
+    /* Map all ACPI tables to Dom0 using 1:1 mappings. */
+    for( i = 0; i < acpi_gbl_root_table_list.count; i++ )
+    {
+        addr = acpi_gbl_root_table_list.tables[i].address;
+        size = acpi_gbl_root_table_list.tables[i].length;
+        res = map_regions_rw_cache(d,
+                                   paddr_to_pfn(addr & PAGE_MASK),
+                                   DIV_ROUND_UP(size, PAGE_SIZE),
+                                   paddr_to_pfn(addr & PAGE_MASK));
+        if ( res )
+        {
+             panic(XENLOG_ERR "Unable to map ACPI region 0x%"PRIx64
+                   " - 0x%"PRIx64" in domain \n",
+                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
+        }
+    }
+}
+
 static int acpi_create_rsdp(struct domain *d, struct membank tbl_add[])
 {
 
@@ -1695,6 +1719,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    acpi_map_other_tables(d);
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 11/22] arm/acpi: Prepare EFI system table for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (9 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 10/22] arm/acpi: Map all other tables for Dom0 Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 14:54   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 12/22] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
                   ` (11 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Prepare EFI system table for Dom0 to describe the information of UEFI.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: use domain as parameter
---
 xen/arch/arm/domain_build.c |  1 +
 xen/arch/arm/efi/efi-dom0.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/setup.h |  3 +++
 3 files changed, 49 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 1bfb2fc..f14bc5b 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1720,6 +1720,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
         return rc;
 
     acpi_map_other_tables(d);
+    acpi_create_efi_system_table(d, tbl_add);
 
     return 0;
 }
diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
index 021aa02..f4f84b6 100644
--- a/xen/arch/arm/efi/efi-dom0.c
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -23,8 +23,12 @@
 
 #include "efi.h"
 #include "efi-dom0.h"
+#include <xen/sched.h>
 #include <asm/setup.h>
 #include <asm/acpi.h>
+#include "../../../common/decompress.h"
+#define XZ_EXTERN STATIC
+#include "../../../common/xz/crc32.c"
 
 struct meminfo __initdata acpi_mem;
 /* Constant to indicate "Xen" in unicode u16 format */
@@ -49,6 +53,47 @@ size_t __init estimate_efi_size(int mem_nr_banks)
     return size;
 }
 
+void __init acpi_create_efi_system_table(struct domain *d,
+                                         struct membank tbl_add[])
+{
+    u64 table_addr, table_size, offset = 0;
+    u8 *base_ptr;
+    EFI_CONFIGURATION_TABLE *efi_conf_tbl;
+    EFI_SYSTEM_TABLE *efi_sys_tbl;
+
+    table_addr = d->arch.efi_acpi_gpa
+                 + acpi_get_table_offset(tbl_add, TBL_EFIT);
+    table_size = sizeof(EFI_SYSTEM_TABLE) + sizeof(EFI_CONFIGURATION_TABLE)
+                 + sizeof(xen_efi_fw_vendor);
+    base_ptr = d->arch.efi_acpi_table
+               + acpi_get_table_offset(tbl_add, TBL_EFIT);
+    efi_sys_tbl = (EFI_SYSTEM_TABLE *)base_ptr;
+
+    efi_sys_tbl->Hdr.Signature = EFI_SYSTEM_TABLE_SIGNATURE;
+    /* Specify the revision as 2.5 */
+    efi_sys_tbl->Hdr.Revision = (2 << 16 | 50);
+    efi_sys_tbl->Hdr.HeaderSize = table_size;
+
+    efi_sys_tbl->FirmwareRevision = 1;
+    efi_sys_tbl->NumberOfTableEntries = 1;
+    offset += sizeof(EFI_SYSTEM_TABLE);
+    memcpy(base_ptr + offset, xen_efi_fw_vendor, sizeof(xen_efi_fw_vendor));
+    efi_sys_tbl->FirmwareVendor = (CHAR16 *)(table_addr + offset);
+
+    offset += sizeof(xen_efi_fw_vendor);
+    efi_conf_tbl = (EFI_CONFIGURATION_TABLE *)(base_ptr + offset);
+    efi_conf_tbl->VendorGuid = (EFI_GUID)ACPI_20_TABLE_GUID;
+    efi_conf_tbl->VendorTable = (VOID *)tbl_add[TBL_RSDP].start;
+    efi_sys_tbl->ConfigurationTable = (EFI_CONFIGURATION_TABLE *)(table_addr
+                                                                  + offset);
+    xz_crc32_init();
+    efi_sys_tbl->Hdr.CRC32 = xz_crc32((uint8_t *)efi_sys_tbl,
+                                      efi_sys_tbl->Hdr.HeaderSize, 0);
+
+    tbl_add[TBL_EFIT].start = table_addr;
+    tbl_add[TBL_EFIT].size = table_size;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 7f233a1..fc9fd7c 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -53,6 +53,9 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
 
 size_t estimate_efi_size(int mem_nr_banks);
 
+void acpi_create_efi_system_table(struct domain *d,
+                                  struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 12/22] arm/acpi: Prepare EFI memory descriptor for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (10 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 11/22] arm/acpi: Prepare EFI system table " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 14:54   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 13/22] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
                   ` (10 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Create EFI memory descriptors to tell Dom0 the RAM region information,
ACPI table regions and EFI tables reserved regions.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: check the size
---
 xen/arch/arm/domain_build.c |  1 +
 xen/arch/arm/efi/efi-dom0.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/setup.h |  4 ++++
 3 files changed, 49 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index f14bc5b..954e0e3 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1721,6 +1721,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
 
     acpi_map_other_tables(d);
     acpi_create_efi_system_table(d, tbl_add);
+    acpi_create_efi_mmap_table(d, &kinfo->mem, tbl_add);
 
     return 0;
 }
diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
index f4f84b6..cf71bf4 100644
--- a/xen/arch/arm/efi/efi-dom0.c
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -24,6 +24,7 @@
 #include "efi.h"
 #include "efi-dom0.h"
 #include <xen/sched.h>
+#include <xen/pfn.h>
 #include <asm/setup.h>
 #include <asm/acpi.h>
 #include "../../../common/decompress.h"
@@ -94,6 +95,49 @@ void __init acpi_create_efi_system_table(struct domain *d,
     tbl_add[TBL_EFIT].size = table_size;
 }
 
+void __init acpi_create_efi_mmap_table(struct domain *d,
+                                       const struct meminfo *mem,
+                                       struct membank tbl_add[])
+{
+    EFI_MEMORY_DESCRIPTOR *memory_map;
+    unsigned int i, offset;
+    u8 *base_ptr;
+
+    base_ptr = d->arch.efi_acpi_table
+               + acpi_get_table_offset(tbl_add, TBL_MMAP);
+    memory_map = (EFI_MEMORY_DESCRIPTOR *)base_ptr;
+
+    offset = 0;
+    for( i = 0; i < mem->nr_banks; i++, offset++ )
+    {
+        memory_map[offset].Type = EfiConventionalMemory;
+        memory_map[offset].PhysicalStart = mem->bank[i].start;
+        BUG_ON(mem->bank[i].size & EFI_PAGE_MASK);
+        memory_map[offset].NumberOfPages = EFI_SIZE_TO_PAGES(mem->bank[i].size);
+        memory_map[offset].Attribute = EFI_MEMORY_WB;
+    }
+
+    for( i = 0; i < acpi_mem.nr_banks; i++, offset++ )
+    {
+        memory_map[offset].Type = EfiACPIReclaimMemory;
+        memory_map[offset].PhysicalStart = acpi_mem.bank[i].start;
+        BUG_ON(acpi_mem.bank[i].size & EFI_PAGE_MASK);
+        memory_map[offset].NumberOfPages = EFI_SIZE_TO_PAGES(acpi_mem.bank[i].size);
+        memory_map[offset].Attribute = EFI_MEMORY_WB;
+    }
+
+    memory_map[offset].Type = EfiACPIReclaimMemory;
+    memory_map[offset].PhysicalStart = d->arch.efi_acpi_gpa;
+    BUG_ON(d->arch.efi_acpi_len & EFI_PAGE_MASK);
+    memory_map[offset].NumberOfPages = EFI_SIZE_TO_PAGES(d->arch.efi_acpi_len);
+    memory_map[offset].Attribute = EFI_MEMORY_WB;
+
+    tbl_add[TBL_MMAP].start = d->arch.efi_acpi_gpa
+                              + acpi_get_table_offset(tbl_add, TBL_MMAP);
+    tbl_add[TBL_MMAP].size = sizeof(EFI_MEMORY_DESCRIPTOR)
+                             * (mem->nr_banks + acpi_mem.nr_banks + 1);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index fc9fd7c..9a71e90 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -56,6 +56,10 @@ size_t estimate_efi_size(int mem_nr_banks);
 void acpi_create_efi_system_table(struct domain *d,
                                   struct membank tbl_add[]);
 
+void acpi_create_efi_mmap_table(struct domain *d,
+                                const struct meminfo *mem,
+                                struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 13/22] arm/acpi: Map the new created EFI and ACPI tables to Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (11 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 12/22] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 15:01   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 14/22] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
                   ` (9 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

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(+)

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
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 14/22] arm/acpi: Create min DT stub for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (12 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 13/22] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 16:10   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 15/22] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
                   ` (8 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Create a DT for Dom0 for ACPI-case only. DT contains minimal required
informations such as Dom0 bootargs, initrd, efi description table and
address of uefi memory table.

Also document this device tree bindings of "hypervisor" and
"hypervisor/uefi" node.

Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: change the function name and address comments
---
 docs/misc/arm/device-tree/guest.txt |  60 +++++++++++++++
 xen/arch/arm/domain_build.c         | 142 ++++++++++++++++++++++++++++++++++++
 xen/arch/arm/efi/efi-dom0.c         |  39 ++++++++++
 xen/include/asm-arm/setup.h         |   2 +
 4 files changed, 243 insertions(+)
 create mode 100644 docs/misc/arm/device-tree/guest.txt

diff --git a/docs/misc/arm/device-tree/guest.txt b/docs/misc/arm/device-tree/guest.txt
new file mode 100644
index 0000000..418f1e9
--- /dev/null
+++ b/docs/misc/arm/device-tree/guest.txt
@@ -0,0 +1,60 @@
+* Xen hypervisor device tree bindings
+
+Xen ARM virtual platforms shall have a top-level "hypervisor" node with
+the following properties:
+
+- compatible:
+	compatible = "xen,xen-<version>", "xen,xen";
+  where <version> is the version of the Xen ABI of the platform.
+
+- reg: specifies the base physical address and size of a region in
+  memory where the grant table should be mapped to, using an
+  HYPERVISOR_memory_op hypercall. The memory region is large enough to map
+  the whole grant table (it is larger or equal to gnttab_max_grant_frames()).
+  This property is unnecessary when booting Dom0 using ACPI.
+
+- interrupts: the interrupt used by Xen to inject event notifications.
+  A GIC node is also required.
+  This property is unnecessary when booting Dom0 using ACPI.
+
+To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
+under /hypervisor with following parameters:
+
+________________________________________________________________________________
+Name                      | Size   | Description
+================================================================================
+xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
+                          |        | Table.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
+                          |        | map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
+                          |        | pointed to in previous entry.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
+                          |        | memory map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
+--------------------------------------------------------------------------------
+
+Example (assuming #address-cells = <2> and #size-cells = <2>):
+
+hypervisor {
+	compatible = "xen,xen-4.3", "xen,xen";
+	reg = <0 0xb0000000 0 0x20000>;
+	interrupts = <1 15 0xf08>;
+	uefi {
+		xen,uefi-system-table = <0xXXXXXXXX>;
+		xen,uefi-mmap-start = <0xXXXXXXXX>;
+		xen,uefi-mmap-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
+        };
+};
+
+The format and meaning of the "xen,uefi-*" parameters are similar to those in
+Documentation/arm/uefi.txt in Linux, which are provided by the regular Linux
+UEFI stub. However they differ because they are provided by the Xen hypervisor,
+together with a set of UEFI runtime services implemented via hypercalls, see
+xen/include/public/platform.h.
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 70c8421..58a44ff 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,144 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+#define ACPI_DOM0_FDT_MIN_SIZE 4096
+
+static int acpi_make_chosen_node(const struct kernel_info *kinfo)
+{
+    int res;
+    const char *bootargs = NULL;
+    const struct bootmodule *mod = kinfo->kernel_bootmodule;
+    void *fdt = kinfo->fdt;
+
+    DPRINT("Create chosen node\n");
+    res = fdt_begin_node(fdt, "chosen");
+    if ( res )
+        return res;
+
+    if ( mod && mod->cmdline[0] )
+    {
+        bootargs = &mod->cmdline[0];
+        res = fdt_property(fdt, "bootargs", bootargs, strlen(bootargs) + 1);
+        if ( res )
+           return res;
+    }
+
+    /*
+     * If the bootloader provides an initrd, we must create a placeholder
+     * for the initrd properties. The values will be replaced later.
+     */
+    if ( mod && mod->size )
+    {
+        u64 a = 0;
+        res = fdt_property(kinfo->fdt, "linux,initrd-start", &a, sizeof(a));
+        if ( res )
+            return res;
+
+        res = fdt_property(kinfo->fdt, "linux,initrd-end", &a, sizeof(a));
+        if ( res )
+            return res;
+    }
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
+static int acpi_make_hypervisor_node(const struct kernel_info *kinfo,
+                                     struct membank tbl_add[])
+{
+    const char compat[] =
+        "xen,xen-"__stringify(XEN_VERSION)"."__stringify(XEN_SUBVERSION)"\0"
+        "xen,xen";
+    int res;
+    /* Convenience alias */
+    void *fdt = kinfo->fdt;
+
+    DPRINT("Create hypervisor node\n");
+
+    /* See linux Documentation/devicetree/bindings/arm/xen.txt */
+    res = fdt_begin_node(fdt, "hypervisor");
+    if ( res )
+        return res;
+
+    /* Cannot use fdt_property_string due to embedded nulls */
+    res = fdt_property(fdt, "compatible", compat, sizeof(compat));
+    if ( res )
+        return res;
+
+    res = acpi_make_efi_nodes(fdt, tbl_add);
+    if ( res )
+        return res;
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
+/*
+ * Prepare a minimal DTB for Dom0 which contains bootargs, initrd, memory
+ * information, EFI table.
+ */
+static int create_acpi_dtb(struct kernel_info *kinfo, struct membank tbl_add[])
+{
+    int new_size;
+    int ret;
+
+    DPRINT("Prepare a min DTB for DOM0\n");
+
+    /* Allocate min size for DT */
+    new_size = ACPI_DOM0_FDT_MIN_SIZE;
+    kinfo->fdt = xmalloc_bytes(new_size);
+
+    if ( kinfo->fdt == NULL )
+        return -ENOMEM;
+
+    /* Create a new empty DT for DOM0 */
+    ret = fdt_create(kinfo->fdt, new_size);
+    if ( ret < 0 )
+        goto err;
+
+    ret = fdt_finish_reservemap(kinfo->fdt);
+    if ( ret < 0 )
+        goto err;
+
+    ret = fdt_begin_node(kinfo->fdt, "/");
+    if ( ret < 0 )
+        goto err;
+
+    ret = fdt_property_cell(kinfo->fdt, "#address-cells", 2);
+    if ( ret )
+        return ret;
+
+    ret = fdt_property_cell(kinfo->fdt, "#size-cells", 1);
+    if ( ret )
+        return ret;
+
+    /* Create a chosen node for DOM0 */
+    ret = acpi_make_chosen_node(kinfo);
+    if ( ret )
+        goto err;
+
+    ret = acpi_make_hypervisor_node(kinfo, tbl_add);
+    if ( ret )
+        goto err;
+
+    ret = fdt_end_node(kinfo->fdt);
+    if ( ret < 0 )
+        goto err;
+
+    ret = fdt_finish(kinfo->fdt);
+    if ( ret < 0 )
+        goto err;
+
+    return 0;
+
+  err:
+    printk("Device tree generation failed (%d).\n", ret);
+    xfree(kinfo->fdt);
+    return -EINVAL;
+}
+
 static void acpi_map_other_tables(struct domain *d)
 {
     int i;
@@ -1742,6 +1880,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     clean_and_invalidate_dcache_va_range(d->arch.efi_acpi_table,
                                          d->arch.efi_acpi_len);
 
+    rc = create_acpi_dtb(kinfo, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
index cf71bf4..c40a7c5 100644
--- a/xen/arch/arm/efi/efi-dom0.c
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -25,6 +25,7 @@
 #include "efi-dom0.h"
 #include <xen/sched.h>
 #include <xen/pfn.h>
+#include <xen/libfdt/libfdt.h>
 #include <asm/setup.h>
 #include <asm/acpi.h>
 #include "../../../common/decompress.h"
@@ -138,6 +139,44 @@ void __init acpi_create_efi_mmap_table(struct domain *d,
                              * (mem->nr_banks + acpi_mem.nr_banks + 1);
 }
 
+/* Create /hypervisor/uefi node for efi properties. */
+int __init acpi_make_efi_nodes(void *fdt, struct membank tbl_add[])
+{
+    int res;
+
+    res = fdt_begin_node(fdt, "uefi");
+    if ( res )
+        return res;
+
+    res = fdt_property_u64(fdt, "xen,uefi-system-table",
+                           tbl_add[TBL_EFIT].start);
+    if ( res )
+        return res;
+
+    res = fdt_property_u64(fdt, "xen,uefi-mmap-start",
+                           tbl_add[TBL_MMAP].start);
+    if ( res )
+        return res;
+
+    res = fdt_property_u32(fdt, "xen,uefi-mmap-size",
+                           tbl_add[TBL_MMAP].size);
+    if ( res )
+        return res;
+
+    res = fdt_property_u32(fdt, "xen,uefi-mmap-desc-size",
+                           sizeof(EFI_MEMORY_DESCRIPTOR));
+    if ( res )
+        return res;
+
+    res = fdt_property_u32(fdt, "xen,uefi-mmap-desc-ver", 1);
+    if ( res )
+        return res;
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 9a71e90..3da7a49 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -60,6 +60,8 @@ void acpi_create_efi_mmap_table(struct domain *d,
                                 const struct meminfo *mem,
                                 struct membank tbl_add[]);
 
+int acpi_make_efi_nodes(void *fdt, struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 15/22] arm/acpi: Permit access all Xen unused SPIs for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (13 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 14/22] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 16:10   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 16/22] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
                   ` (7 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Allow DOM0 to use all SPIs but the ones used by Xen. Then when Dom0
configures the interrupt, it could set the interrupt type and route it
to Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: add a TODO for SMMU used SPIs
---
 xen/arch/arm/domain_build.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 58a44ff..28b85e5 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,37 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define ACPI_DOM0_FDT_MIN_SIZE 4096
 
+static int acpi_permit_spi_access(struct domain *d)
+{
+    int i, res;
+    struct irq_desc *desc;
+
+    /*
+     * Here just permit Dom0 to access the SPIs which Xen doesn't use. Then when
+     * Dom0 configures the interrupt, set the interrupt type and route it to
+     * Dom0.
+     */
+    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
+    {
+        /*
+	 * TODO: Exclude the SPIs SMMU uses which should not be routed to Dom0.
+	 */
+        desc = irq_to_desc(i);
+        if ( desc->action != NULL)
+            continue;
+
+        res = irq_permit_access(d, i);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Unable to permit to dom%u access to IRQ %u\n",
+                   d->domain_id, i);
+            return res;
+        }
+    }
+
+    return 0;
+}
+
 static int acpi_make_chosen_node(const struct kernel_info *kinfo)
 {
     int res;
@@ -1884,6 +1915,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_permit_spi_access(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 16/22] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (14 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 15/22] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 16:12   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions Shannon Zhao
                   ` (6 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Interrupt information is described in DSDT and is not available at the
time of booting. Check if the interrupt is permitted to access and set
the interrupt type, route it to guest dynamically only for SPI
and Dom0.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen/arch/arm/vgic.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index ee35683..aa420bb 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -25,6 +25,8 @@
 #include <xen/irq.h>
 #include <xen/sched.h>
 #include <xen/perfc.h>
+#include <xen/iocap.h>
+#include <xen/acpi.h>
 
 #include <asm/current.h>
 
@@ -334,6 +336,19 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
     }
 }
 
+#define VGIC_ICFG_MASK(intr) (1 << ((2 * ((intr) % 16)) + 1))
+
+static inline unsigned int get_the_irq_type(struct vcpu *v, int n, int index)
+{
+    struct vgic_irq_rank *vr = vgic_get_rank(v, n);
+    uint32_t tr = vr->icfg[index >> 4];
+
+    if ( tr & VGIC_ICFG_MASK(index) )
+        return IRQ_TYPE_EDGE_BOTH;
+    else
+        return IRQ_TYPE_LEVEL_MASK;
+}
+
 void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
 {
     const unsigned long mask = r;
@@ -342,9 +357,26 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
     unsigned long flags;
     int i = 0;
     struct vcpu *v_target;
+    struct domain *d = v->domain;
+    int ret;
 
     while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
         irq = i + (32 * n);
+        /* Set the irq type and route it to guest only for SPI and Dom0 */
+        if( irq_access_permitted(d, irq) && is_hardware_domain(d) &&
+            ( irq >= 32 ) && ( !acpi_disabled ) )
+        {
+            ret = irq_set_spi_type(irq, get_the_irq_type(v, n, i));
+            if ( ret )
+                gprintk(XENLOG_WARNING, "The irq type is not correct\n");
+
+            vgic_reserve_virq(d, irq);
+
+            ret = route_irq_to_guest(d, irq, irq, NULL);
+            if ( ret )
+                gprintk(XENLOG_ERR, "Unable to route IRQ %u to domain %u\n",
+                        irq, d->domain_id);
+        }
         v_target = __vgic_get_target_vcpu(v, irq);
         p = irq_to_pending(v_target, irq);
         set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (15 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 16/22] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-26 13:04   ` Stefano Stabellini
  2016-03-29 16:13   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 18/22] arm/acpi: Permit MMIO access of Xen unused devices for Dom0 Shannon Zhao
                   ` (5 subsequent siblings)
  22 siblings, 2 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Add a new member in gic_hw_operations which is used to deny Dom0 access
to GIC regions.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v7: move them out of CONFIG_ACPI
---
 xen/arch/arm/gic-v2.c     | 27 +++++++++++++++++++++++++++
 xen/arch/arm/gic-v3.c     | 41 +++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic.c        |  5 +++++
 xen/include/asm-arm/gic.h |  3 +++
 4 files changed, 76 insertions(+)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 38e3216..450755f 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -22,6 +22,7 @@
 #include <xen/init.h>
 #include <xen/mm.h>
 #include <xen/irq.h>
+#include <xen/iocap.h>
 #include <xen/sched.h>
 #include <xen/errno.h>
 #include <xen/softirq.h>
@@ -684,6 +685,31 @@ static void __init gicv2_dt_init(void)
                csize, vsize);
 }
 
+static int gicv2_iomem_deny_access(const struct domain *d)
+{
+    int rc;
+    unsigned long gfn, nr;
+
+    gfn = dbase >> PAGE_SHIFT;
+    rc = iomem_deny_access(d, gfn, gfn + 1);
+    if ( rc )
+        return rc;
+
+    gfn = hbase >> PAGE_SHIFT;
+    rc = iomem_deny_access(d, gfn, gfn + 1);
+    if ( rc )
+        return rc;
+
+    gfn = cbase >> PAGE_SHIFT;
+    nr = DIV_ROUND_UP(csize, PAGE_SIZE);
+    rc = iomem_deny_access(d, gfn, gfn + nr);
+    if ( rc )
+        return rc;
+
+    gfn = vbase >> PAGE_SHIFT;
+    return iomem_deny_access(d, gfn, gfn + nr);
+}
+
 #ifdef CONFIG_ACPI
 static int gicv2_make_hwdom_madt(const struct domain *d, u32 offset)
 {
@@ -910,6 +936,7 @@ const static struct gic_hw_operations gicv2_ops = {
     .read_apr            = gicv2_read_apr,
     .make_hwdom_dt_node  = gicv2_make_hwdom_dt_node,
     .make_hwdom_madt     = gicv2_make_hwdom_madt,
+    .iomem_deny_access   = gicv2_iomem_deny_access,
 };
 
 /* Set up the GIC */
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 52ee23c..a095064 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -27,6 +27,7 @@
 #include <xen/cpu.h>
 #include <xen/mm.h>
 #include <xen/irq.h>
+#include <xen/iocap.h>
 #include <xen/sched.h>
 #include <xen/errno.h>
 #include <xen/delay.h>
@@ -1235,6 +1236,45 @@ static void __init gicv3_dt_init(void)
                           &vbase, &vsize);
 }
 
+static int gicv3_iomem_deny_access(const struct domain *d)
+{
+    int rc, i;
+    unsigned long gfn, nr;
+
+    gfn = dbase >> PAGE_SHIFT;
+    nr = DIV_ROUND_UP(SZ_64K, PAGE_SIZE);
+    rc = iomem_deny_access(d, gfn, gfn + nr);
+    if ( rc )
+        return rc;
+
+    for ( i = 0; i < gicv3.rdist_count; i++ )
+    {
+        gfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT;
+        nr = DIV_ROUND_UP(gicv3.rdist_regions[i].size, PAGE_SIZE);
+        rc = iomem_deny_access(d, gfn, gfn + nr);
+        if ( rc )
+            return rc;
+    }
+
+    if ( cbase != INVALID_PADDR )
+    {
+        gfn = cbase >> PAGE_SHIFT;
+        nr = DIV_ROUND_UP(csize, PAGE_SIZE);
+        rc = iomem_deny_access(d, gfn, gfn + nr);
+        if ( rc )
+            return rc;
+    }
+
+    if ( vbase != INVALID_PADDR )
+    {
+        gfn = vbase >> PAGE_SHIFT;
+        nr = DIV_ROUND_UP(csize, PAGE_SIZE);
+        return iomem_deny_access(d, gfn, gfn + nr);
+    }
+
+    return 0;
+}
+
 #ifdef CONFIG_ACPI
 static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
 {
@@ -1530,6 +1570,7 @@ static const struct gic_hw_operations gicv3_ops = {
     .secondary_init      = gicv3_secondary_cpu_init,
     .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
     .make_hwdom_madt     = gicv3_make_hwdom_madt,
+    .iomem_deny_access   = gicv3_iomem_deny_access,
 };
 
 static int __init gicv3_dt_preinit(struct dt_device_node *node, const void *data)
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index b3c1eb3..2bfe4de 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -744,6 +744,11 @@ int gic_make_hwdom_madt(const struct domain *d, u32 offset)
     return gic_hw_ops->make_hwdom_madt(d, offset);
 }
 
+int gic_iomem_deny_access(const struct domain *d)
+{
+    return gic_hw_ops->iomem_deny_access(d);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index 8130136..cd97bb2 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -360,6 +360,8 @@ struct gic_hw_operations {
                               const struct dt_device_node *gic, void *fdt);
     /* Create MADT table for the hardware domain */
     int (*make_hwdom_madt)(const struct domain *d, u32 offset);
+    /* Deny access to GIC regions */
+    int (*iomem_deny_access)(const struct domain *d);
 };
 
 void register_gic_ops(const struct gic_hw_operations *ops);
@@ -367,6 +369,7 @@ int gic_make_hwdom_dt_node(const struct domain *d,
                            const struct dt_device_node *gic,
                            void *fdt);
 int gic_make_hwdom_madt(const struct domain *d, u32 offset);
+int gic_iomem_deny_access(const struct domain *d);
 
 #endif /* __ASSEMBLY__ */
 #endif
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 18/22] arm/acpi: Permit MMIO access of Xen unused devices for Dom0
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (16 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-25 13:48 ` [PATCH v7 19/22] hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
access of Xen used devices, such as UART, GIC, SMMU. Currently, it only
denies the MMIO access of UART and GIC regions. For other Xen used
devices it could be added later when they are supported.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain_build.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 28b85e5..f004d92 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,38 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define ACPI_DOM0_FDT_MIN_SIZE 4096
 
+static int acpi_iomem_deny_access(struct domain *d)
+{
+    acpi_status status;
+    struct acpi_table_spcr *spcr = NULL;
+    unsigned long gfn;
+    int rc;
+
+    /* Firstly permit full MMIO capabilities. */
+    rc = iomem_permit_access(d, 0UL, ~0UL);
+    if ( rc )
+        return rc;
+
+    /* TODO: Deny MMIO access for SMMU, GIC ITS */
+    status = acpi_get_table(ACPI_SIG_SPCR, 0,
+                            (struct acpi_table_header **)&spcr);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        printk("Failed to get SPCR table\n");
+        return -EINVAL;
+    }
+
+    gfn = spcr->serial_port.address >> PAGE_SHIFT;
+    /* Deny MMIO access for UART */
+    rc = iomem_deny_access(d, gfn, gfn + 1);
+    if ( rc )
+        return rc;
+
+    /* Deny MMIO access for GIC regions */
+    return gic_iomem_deny_access(d);
+}
+
 static int acpi_permit_spi_access(struct domain *d)
 {
     int i, res;
@@ -1919,6 +1951,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_iomem_deny_access(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 19/22] hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (17 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 18/22] arm/acpi: Permit MMIO access of Xen unused devices for Dom0 Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 16:16   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 20/22] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
                   ` (3 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Keir Fraser, Tim Deegan, Ian Jackson, peter.huangpeng,
	julien.grall, stefano.stabellini, shannon.zhao, Jan Beulich,
	zhaoshenglong

This new delivery type which is for ARM shares the same value with
HVM_PARAM_CALLBACK_TYPE_VECTOR which is for x86.

val[15:8] is flag: val[7:0] is a PPI.
To the flag, bit 8 stands the interrupt mode is edge(1) or level(0) and
bit 9 stands the interrupt polarity is active low(1) or high(0).

Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/public/hvm/params.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index e69c72c..f7338a3 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -49,11 +49,24 @@
  * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
  */
 
+#if defined(__i386__) || defined(__x86_64__)
 #define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
 /*
  * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
  * if this delivery method is available.
  */
+#elif defined(__arm__) || defined(__aarch64__)
+#define HVM_PARAM_CALLBACK_TYPE_PPI      2
+/*
+ * val[55:16] needs to be zero.
+ * val[15:8] is interrupt flag of the PPI used by event-channel:
+ *  bit 8: the PPI is edge(1) or level(0) triggered
+ *  bit 9: the PPI is active low(1) or high(0)
+ * val[7:0] is a PPI number used by event-channel.
+ * This is only used by ARM/ARM64 and masking/eoi the interrupt associated to
+ * the notification is handled by the interrupt controller.
+ */
+#endif
 
 /*
  * These are not used by Xen. They are here for convenience of HVM-guest
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 20/22] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (18 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 19/22] hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 16:16   ` Julien Grall
  2016-03-25 13:48 ` [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
                   ` (2 subsequent siblings)
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: julien.grall, shannon.zhao, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Store the event-channel interrupt number and flag in HVM parameter
HVM_PARAM_CALLBACK_IRQ. Then Dom0 could get it through hypercall
HVMOP_get_param.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index f004d92..d9bc3de 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2047,6 +2047,7 @@ static void initrd_load(struct kernel_info *kinfo)
 static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
 {
     int res, node;
+    u64 val;
     gic_interrupt_t intr;
 
     /*
@@ -2062,6 +2063,19 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
     printk("Allocating PPI %u for event channel interrupt\n",
            d->arch.evtchn_irq);
 
+    /* Set the value of domain param HVM_PARAM_CALLBACK_IRQ */
+    val = (u64)HVM_PARAM_CALLBACK_TYPE_PPI << 56;
+    val |= (2 << 8); /* Active-low level-sensitive  */
+    val |= d->arch.evtchn_irq & 0xff;
+    d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val;
+
+    /*
+     * When booting Dom0 using ACPI, Dom0 can only get the event channel
+     * interrupt via hypercall.
+     */
+    if ( !acpi_disabled )
+        return;
+
     /* Fix up "interrupts" in /hypervisor node */
     node = fdt_path_offset(kinfo->fdt, "/hypervisor");
     if ( node < 0 )
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (19 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 20/22] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-30 16:05   ` Konrad Rzeszutek Wilk
  2016-03-30 16:07   ` Konrad Rzeszutek Wilk
  2016-03-25 13:48 ` [PATCH v7 22/22] xen/arm64: Add ACPI support Shannon Zhao
  2016-03-29  7:12 ` [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Jan Beulich
  22 siblings, 2 replies; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Keir Fraser, Tim Deegan, Ian Jackson, peter.huangpeng,
	julien.grall, stefano.stabellini, shannon.zhao, Jan Beulich,
	zhaoshenglong

It needs to map platform or amba device mmio to Dom0 on ARM. But when
booting with ACPI, it can't get the mmio region in Xen due to lack of
AML interpreter to parse DSDT table. Therefore, let Dom0 call a
hypercall to map mmio region when it adds the devices.

Here we add a new map space like the XEN_DOMCTL_memory_mapping to map
mmio region for Dom0.

Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/mm.c           |  3 +++
 xen/arch/arm/p2m.c          | 22 ++++++++++++++++++++++
 xen/common/memory.c         | 16 ++++++++++++++++
 xen/include/asm-arm/p2m.h   |  5 +++++
 xen/include/public/memory.h |  1 +
 5 files changed, 47 insertions(+)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 81f9e2e..0aae6c5 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1138,6 +1138,9 @@ int xenmem_add_to_physmap_one(
         rcu_unlock_domain(od);
         break;
     }
+    case XENMAPSPACE_dev_mmio:
+        rc = map_dev_mmio_region(d, gpfn, 1, idx);
+        return rc;
 
     default:
         return -ENOSYS;
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 7e5f5d1..0011708 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -7,6 +7,7 @@
 #include <xen/bitops.h>
 #include <xen/vm_event.h>
 #include <xen/mem_access.h>
+#include <xen/iocap.h>
 #include <public/vm_event.h>
 #include <asm/flushtlb.h>
 #include <asm/gic.h>
@@ -1270,6 +1271,27 @@ int unmap_mmio_regions(struct domain *d,
                              d->arch.p2m.default_access);
 }
 
+int map_dev_mmio_region(struct domain *d,
+                        unsigned long start_gfn,
+                        unsigned long nr,
+                        unsigned long mfn)
+{
+    int res;
+
+    if ( !(nr && iomem_access_permitted(d, start_gfn, start_gfn + nr - 1)) )
+        return 0;
+
+    res = map_mmio_regions(d, start_gfn, nr, mfn);
+    if ( res < 0 )
+    {
+        printk(XENLOG_ERR "Unable to map [%#lx - %#lx] in Dom%d\n",
+               start_gfn, start_gfn + nr - 1, d->domain_id);
+        return res;
+    }
+
+    return 0;
+}
+
 int guest_physmap_add_entry(struct domain *d,
                             unsigned long gpfn,
                             unsigned long mfn,
diff --git a/xen/common/memory.c b/xen/common/memory.c
index c7fca96..25ff86c 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -980,6 +980,14 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( d == NULL )
             return -ESRCH;
 
+        /*
+         * XENMAPSPACE_dev_mmio mapping is only supported for hardware Domain
+         * to map this kind of space to itself.
+         */
+        if ( (xatp.space == XENMAPSPACE_dev_mmio) &&
+             ((d != current->domain) || !is_hardware_domain(d)) )
+            return -EACCES;
+
         rc = xsm_add_to_physmap(XSM_TARGET, current->domain, d);
         if ( rc )
         {
@@ -1024,6 +1032,14 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( d == NULL )
             return -ESRCH;
 
+        /*
+         * XENMAPSPACE_dev_mmio mapping is only supported for hardware Domain
+         * to map this kind of space to itself.
+         */
+        if ( (xatpb.space == XENMAPSPACE_dev_mmio) &&
+             ((d != current->domain) || !is_hardware_domain(d)) )
+            return -EACCES;
+
         rc = xsm_add_to_physmap(XSM_TARGET, current->domain, d);
         if ( rc )
         {
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 55626b4..d240d1e 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -154,6 +154,11 @@ int unmap_regions_rw_cache(struct domain *d,
                            unsigned long nr_mfns,
                            unsigned long mfn);
 
+int map_dev_mmio_region(struct domain *d,
+                        unsigned long start_gfn,
+                        unsigned long nr,
+                        unsigned long mfn);
+
 int guest_physmap_add_entry(struct domain *d,
                             unsigned long gfn,
                             unsigned long mfn,
diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
index f69e92f..fe52ee1 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -220,6 +220,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
 #define XENMAPSPACE_gmfn_range   3 /* GMFN range, XENMEM_add_to_physmap only. */
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
                                     * XENMEM_add_to_physmap_batch only. */
+#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
 /* ` } */
 
 /*
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* [PATCH v7 22/22] xen/arm64: Add ACPI support
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (20 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
@ 2016-03-25 13:48 ` Shannon Zhao
  2016-03-29 16:20   ` Julien Grall
  2016-03-29  7:12 ` [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Jan Beulich
  22 siblings, 1 reply; 45+ messages in thread
From: Shannon Zhao @ 2016-03-25 13:48 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, julien.grall, stefano.stabellini, shannon.zhao,
	Jan Beulich, zhaoshenglong

Add ACPI support on arm64 xen hypervisor. Enable EFI support on ARM.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
v7: Drop CONFIG_ACPI_BOOT
---
 xen/arch/arm/Kconfig     |  9 +++++++++
 xen/common/efi/runtime.c | 12 +++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index cb99df5..6231cd5 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -33,6 +33,15 @@ menu "Architecture Features"
 
 source "arch/Kconfig"
 
+config ACPI
+	bool
+	prompt "ACPI (Advanced Configuration and Power Interface) Support" if EXPERT = "y"
+	depends on ARM_64
+	---help---
+
+	  Advanced Configuration and Power Interface (ACPI) support for Xen is
+	  an alternative to device tree on ARM64.
+
 # Select HAS_GICV3 if GICv3 is supported
 config HAS_GICV3
 	bool
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index ae87557..c256814 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -10,14 +10,16 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
 
 #ifndef COMPAT
 
-#ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
-const bool_t efi_enabled = 0;
-#else
+/*
+ * Currently runtime services are not implemented on ARM. To boot Xen with ACPI,
+ * set efi_enabled to 1, so that Xen can get the ACPI root pointer from EFI.
+ */
+const bool_t efi_enabled = 1;
+
+#ifndef CONFIG_ARM
 # include <asm/i387.h>
 # include <asm/xstate.h>
 # include <public/platform.h>
-
-const bool_t efi_enabled = 1;
 #endif
 
 unsigned int __read_mostly efi_num_ct;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables
  2016-03-25 13:48 ` [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
@ 2016-03-26 13:02   ` Stefano Stabellini
  2016-03-29 10:24   ` Julien Grall
  1 sibling, 0 replies; 45+ messages in thread
From: Stefano Stabellini @ 2016-03-26 13:02 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: julien.grall, zhaoshenglong, stefano.stabellini, peter.huangpeng,
	xen-devel

On Fri, 25 Mar 2016, Shannon Zhao wrote:
> Estimate the memory required for loading acpi/efi tables in Dom0. Make
> the length of each table aligned with 64bit. Alloc the pages to store
> the new created EFI and ACPI tables and free these pages when
> destroying domain.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


> v7: address several comments from Julien
> ---
>  xen/arch/arm/domain.c       |   4 ++
>  xen/arch/arm/domain_build.c | 103 +++++++++++++++++++++++++++++++++++++++++++-
>  xen/arch/arm/efi/Makefile   |   1 +
>  xen/arch/arm/efi/efi-boot.h |   4 +-
>  xen/arch/arm/efi/efi-dom0.c |  59 +++++++++++++++++++++++++
>  xen/arch/arm/efi/efi-dom0.h |   8 ++++
>  xen/include/asm-arm/setup.h |   2 +
>  7 files changed, 177 insertions(+), 4 deletions(-)
>  create mode 100644 xen/arch/arm/efi/efi-dom0.c
>  create mode 100644 xen/arch/arm/efi/efi-dom0.h
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 3d274ae..1365b4a 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -640,6 +640,10 @@ void arch_domain_destroy(struct domain *d)
>      domain_vgic_free(d);
>      domain_vuart_free(d);
>      free_xenheap_page(d->shared_info);
> +#ifdef CONFIG_ACPI
> +    free_xenheap_pages(d->arch.efi_acpi_table,
> +                       get_order_from_bytes(d->arch.efi_acpi_len));
> +#endif
>  }
>  
>  void arch_domain_shutdown(struct domain *d)
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 83676e4..13027ea 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -12,6 +12,8 @@
>  #include <xen/libfdt/libfdt.h>
>  #include <xen/guest_access.h>
>  #include <xen/iocap.h>
> +#include <xen/acpi.h>
> +#include <acpi/actables.h>
>  #include <asm/device.h>
>  #include <asm/setup.h>
>  #include <asm/platform.h>
> @@ -1354,6 +1356,101 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>      return -EINVAL;
>  }
>  
> +#ifdef CONFIG_ACPI
> +static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo)
> +{
> +    size_t efi_size, acpi_size, madt_size;
> +    u64 addr;
> +    struct acpi_table_rsdp *rsdp_tbl;
> +    struct acpi_table_header *table;
> +
> +    efi_size = estimate_efi_size(kinfo->mem.nr_banks);
> +
> +    acpi_size = ROUNDUP(sizeof(struct acpi_table_fadt), 8);
> +    acpi_size += ROUNDUP(sizeof(struct acpi_table_stao), 8);
> +
> +    madt_size = sizeof(struct acpi_table_madt)
> +                + sizeof(struct acpi_madt_generic_interrupt) * d->max_vcpus
> +                + sizeof(struct acpi_madt_generic_distributor);
> +    if ( d->arch.vgic.version == GIC_V3 )
> +        madt_size += sizeof(struct acpi_madt_generic_redistributor)
> +                     * d->arch.vgic.nr_regions;
> +    acpi_size += ROUNDUP(madt_size, 8);
> +
> +    addr = acpi_os_get_root_pointer();
> +    if ( !addr )
> +    {
> +        printk("Unable to get acpi root pointer\n");
> +        return -EINVAL;
> +    }
> +
> +    rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp));
> +    if ( !rsdp_tbl )
> +    {
> +        printk("Unable to map RSDP table\n");
> +        return -EINVAL;
> +    }
> +
> +    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
> +                               sizeof(struct acpi_table_header));
> +    if ( !table )
> +    {
> +        printk("Unable to map XSDT table\n");
> +        return -EINVAL;
> +    }
> +
> +    /* Add place for STAO table in XSDT table */
> +    acpi_size += ROUNDUP(table->length + sizeof(u64), 8);
> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
> +
> +    acpi_size += ROUNDUP(sizeof(struct acpi_table_rsdp), 8);
> +    d->arch.efi_acpi_len = PAGE_ALIGN(ROUNDUP(efi_size, 8)
> +                                      + ROUNDUP(acpi_size, 8));
> +
> +    return 0;
> +}
> +
> +static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
> +{
> +    int rc = 0;
> +    int order;
> +
> +    rc = estimate_acpi_efi_size(d, kinfo);
> +    if ( rc != 0 )
> +        return rc;
> +
> +    order = get_order_from_bytes(d->arch.efi_acpi_len);
> +    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
> +    if ( d->arch.efi_acpi_table == NULL )
> +    {
> +        printk("unable to allocate memory!\n");
> +        return -ENOMEM;
> +    }
> +    memset(d->arch.efi_acpi_table, 0, d->arch.efi_acpi_len);
> +
> +    /*
> +     * For ACPI, Dom0 doesn't use kinfo->gnttab_start to get the grant table
> +     * region. So we use it as the ACPI table mapped address. Also it needs to
> +     * check if the size of grant table region is enough for those ACPI tables.
> +     */
> +    d->arch.efi_acpi_gpa = kinfo->gnttab_start;
> +    if ( kinfo->gnttab_size < d->arch.efi_acpi_len )
> +    {
> +        printk("The grant table region is not enough to fit the ACPI tables!\n");
> +        return -EINVAL;
> +    }
> +
> +    return 0;
> +}
> +#else
> +static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
> +{
> +    /* Only booting with ACPI will hit here */
> +    BUG();
> +    return -EINVAL;
> +}
> +#endif
>  static void dtb_load(struct kernel_info *kinfo)
>  {
>      void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr;
> @@ -1540,7 +1637,11 @@ int construct_dom0(struct domain *d)
>      allocate_memory(d, &kinfo);
>      find_gnttab_region(d, &kinfo);
>  
> -    rc = prepare_dtb(d, &kinfo);
> +    if ( acpi_disabled )
> +        rc = prepare_dtb(d, &kinfo);
> +    else
> +        rc = prepare_acpi(d, &kinfo);
> +
>      if ( rc < 0 )
>          return rc;
>  
> diff --git a/xen/arch/arm/efi/Makefile b/xen/arch/arm/efi/Makefile
> index 729e53e..d34c916 100644
> --- a/xen/arch/arm/efi/Makefile
> +++ b/xen/arch/arm/efi/Makefile
> @@ -1,3 +1,4 @@
>  CFLAGS += -fshort-wchar
>  
>  obj-y +=  boot.init.o runtime.o
> +obj-$(CONFIG_ACPI) +=  efi-dom0.init.o
> diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
> index c58caca..045d6ce 100644
> --- a/xen/arch/arm/efi/efi-boot.h
> +++ b/xen/arch/arm/efi/efi-boot.h
> @@ -7,6 +7,7 @@
>  #include <xen/libfdt/libfdt.h>
>  #include <asm/setup.h>
>  #include <asm/smp.h>
> +#include "efi-dom0.h"
>  
>  void noreturn efi_xen_start(void *fdt_ptr, uint32_t fdt_size);
>  void __flush_dcache_area(const void *vaddr, unsigned long size);
> @@ -17,9 +18,6 @@ void __flush_dcache_area(const void *vaddr, unsigned long size);
>  static struct file __initdata dtbfile;
>  static void __initdata *fdt;
>  static void __initdata *memmap;
> -#ifdef CONFIG_ACPI
> -static struct meminfo __initdata acpi_mem;
> -#endif
>  
>  static int __init setup_chosen_node(void *fdt, int *addr_cells, int *size_cells)
>  {
> diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
> new file mode 100644
> index 0000000..021aa02
> --- /dev/null
> +++ b/xen/arch/arm/efi/efi-dom0.c
> @@ -0,0 +1,59 @@
> +/*
> + *  efi-dom0.c - Domain0 EFI Boot Support
> + *
> + *  Copyright (C) 2016 Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; If not, see <http://www.gnu.org/licenses/>.
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#include "efi.h"
> +#include "efi-dom0.h"
> +#include <asm/setup.h>
> +#include <asm/acpi.h>
> +
> +struct meminfo __initdata acpi_mem;
> +/* Constant to indicate "Xen" in unicode u16 format */
> +static const CHAR16 xen_efi_fw_vendor[] = {0x0058, 0x0065, 0x006E, 0x0000};
> +
> +size_t __init estimate_efi_size(int mem_nr_banks)
> +{
> +    size_t size;
> +    size_t est_size = sizeof(EFI_SYSTEM_TABLE);
> +    size_t ect_size = sizeof(EFI_CONFIGURATION_TABLE);
> +    size_t emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
> +    size_t fw_vendor_size = sizeof(xen_efi_fw_vendor);
> +    int acpi_mem_nr_banks = 0;
> +
> +    if ( !acpi_disabled )
> +        acpi_mem_nr_banks = acpi_mem.nr_banks;
> +
> +    size = ROUNDUP(est_size + ect_size + fw_vendor_size, 8);
> +    /* plus 1 for new created tables */
> +    size += ROUNDUP(emd_size * (mem_nr_banks + acpi_mem_nr_banks + 1), 8);
> +
> +    return size;
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/arm/efi/efi-dom0.h b/xen/arch/arm/efi/efi-dom0.h
> new file mode 100644
> index 0000000..3cd4caa
> --- /dev/null
> +++ b/xen/arch/arm/efi/efi-dom0.h
> @@ -0,0 +1,8 @@
> +#ifndef __ARM_EFI_DOM0_H__
> +#define __ARM_EFI_DOM0_H__
> +
> +#include <asm/setup.h>
> +
> +extern struct meminfo acpi_mem;
> +
> +#endif
> diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
> index 30ac53b..7f233a1 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -51,6 +51,8 @@ void arch_init_memory(void);
>  
>  void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
>  
> +size_t estimate_efi_size(int mem_nr_banks);
> +
>  int construct_dom0(struct domain *d);
>  
>  void discard_initial_modules(void);
> -- 
> 2.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions
  2016-03-25 13:48 ` [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions Shannon Zhao
@ 2016-03-26 13:04   ` Stefano Stabellini
  2016-03-29 16:13   ` Julien Grall
  1 sibling, 0 replies; 45+ messages in thread
From: Stefano Stabellini @ 2016-03-26 13:04 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: julien.grall, zhaoshenglong, stefano.stabellini, peter.huangpeng,
	xen-devel

On Fri, 25 Mar 2016, Shannon Zhao wrote:
> Add a new member in gic_hw_operations which is used to deny Dom0 access
> to GIC regions.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


> v7: move them out of CONFIG_ACPI
> ---
>  xen/arch/arm/gic-v2.c     | 27 +++++++++++++++++++++++++++
>  xen/arch/arm/gic-v3.c     | 41 +++++++++++++++++++++++++++++++++++++++++
>  xen/arch/arm/gic.c        |  5 +++++
>  xen/include/asm-arm/gic.h |  3 +++
>  4 files changed, 76 insertions(+)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 38e3216..450755f 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -22,6 +22,7 @@
>  #include <xen/init.h>
>  #include <xen/mm.h>
>  #include <xen/irq.h>
> +#include <xen/iocap.h>
>  #include <xen/sched.h>
>  #include <xen/errno.h>
>  #include <xen/softirq.h>
> @@ -684,6 +685,31 @@ static void __init gicv2_dt_init(void)
>                 csize, vsize);
>  }
>  
> +static int gicv2_iomem_deny_access(const struct domain *d)
> +{
> +    int rc;
> +    unsigned long gfn, nr;
> +
> +    gfn = dbase >> PAGE_SHIFT;
> +    rc = iomem_deny_access(d, gfn, gfn + 1);
> +    if ( rc )
> +        return rc;
> +
> +    gfn = hbase >> PAGE_SHIFT;
> +    rc = iomem_deny_access(d, gfn, gfn + 1);
> +    if ( rc )
> +        return rc;
> +
> +    gfn = cbase >> PAGE_SHIFT;
> +    nr = DIV_ROUND_UP(csize, PAGE_SIZE);
> +    rc = iomem_deny_access(d, gfn, gfn + nr);
> +    if ( rc )
> +        return rc;
> +
> +    gfn = vbase >> PAGE_SHIFT;
> +    return iomem_deny_access(d, gfn, gfn + nr);
> +}
> +
>  #ifdef CONFIG_ACPI
>  static int gicv2_make_hwdom_madt(const struct domain *d, u32 offset)
>  {
> @@ -910,6 +936,7 @@ const static struct gic_hw_operations gicv2_ops = {
>      .read_apr            = gicv2_read_apr,
>      .make_hwdom_dt_node  = gicv2_make_hwdom_dt_node,
>      .make_hwdom_madt     = gicv2_make_hwdom_madt,
> +    .iomem_deny_access   = gicv2_iomem_deny_access,
>  };
>  
>  /* Set up the GIC */
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 52ee23c..a095064 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -27,6 +27,7 @@
>  #include <xen/cpu.h>
>  #include <xen/mm.h>
>  #include <xen/irq.h>
> +#include <xen/iocap.h>
>  #include <xen/sched.h>
>  #include <xen/errno.h>
>  #include <xen/delay.h>
> @@ -1235,6 +1236,45 @@ static void __init gicv3_dt_init(void)
>                            &vbase, &vsize);
>  }
>  
> +static int gicv3_iomem_deny_access(const struct domain *d)
> +{
> +    int rc, i;
> +    unsigned long gfn, nr;
> +
> +    gfn = dbase >> PAGE_SHIFT;
> +    nr = DIV_ROUND_UP(SZ_64K, PAGE_SIZE);
> +    rc = iomem_deny_access(d, gfn, gfn + nr);
> +    if ( rc )
> +        return rc;
> +
> +    for ( i = 0; i < gicv3.rdist_count; i++ )
> +    {
> +        gfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT;
> +        nr = DIV_ROUND_UP(gicv3.rdist_regions[i].size, PAGE_SIZE);
> +        rc = iomem_deny_access(d, gfn, gfn + nr);
> +        if ( rc )
> +            return rc;
> +    }
> +
> +    if ( cbase != INVALID_PADDR )
> +    {
> +        gfn = cbase >> PAGE_SHIFT;
> +        nr = DIV_ROUND_UP(csize, PAGE_SIZE);
> +        rc = iomem_deny_access(d, gfn, gfn + nr);
> +        if ( rc )
> +            return rc;
> +    }
> +
> +    if ( vbase != INVALID_PADDR )
> +    {
> +        gfn = vbase >> PAGE_SHIFT;
> +        nr = DIV_ROUND_UP(csize, PAGE_SIZE);
> +        return iomem_deny_access(d, gfn, gfn + nr);
> +    }
> +
> +    return 0;
> +}
> +
>  #ifdef CONFIG_ACPI
>  static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
>  {
> @@ -1530,6 +1570,7 @@ static const struct gic_hw_operations gicv3_ops = {
>      .secondary_init      = gicv3_secondary_cpu_init,
>      .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
>      .make_hwdom_madt     = gicv3_make_hwdom_madt,
> +    .iomem_deny_access   = gicv3_iomem_deny_access,
>  };
>  
>  static int __init gicv3_dt_preinit(struct dt_device_node *node, const void *data)
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index b3c1eb3..2bfe4de 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -744,6 +744,11 @@ int gic_make_hwdom_madt(const struct domain *d, u32 offset)
>      return gic_hw_ops->make_hwdom_madt(d, offset);
>  }
>  
> +int gic_iomem_deny_access(const struct domain *d)
> +{
> +    return gic_hw_ops->iomem_deny_access(d);
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
> index 8130136..cd97bb2 100644
> --- a/xen/include/asm-arm/gic.h
> +++ b/xen/include/asm-arm/gic.h
> @@ -360,6 +360,8 @@ struct gic_hw_operations {
>                                const struct dt_device_node *gic, void *fdt);
>      /* Create MADT table for the hardware domain */
>      int (*make_hwdom_madt)(const struct domain *d, u32 offset);
> +    /* Deny access to GIC regions */
> +    int (*iomem_deny_access)(const struct domain *d);
>  };
>  
>  void register_gic_ops(const struct gic_hw_operations *ops);
> @@ -367,6 +369,7 @@ int gic_make_hwdom_dt_node(const struct domain *d,
>                             const struct dt_device_node *gic,
>                             void *fdt);
>  int gic_make_hwdom_madt(const struct domain *d, u32 offset);
> +int gic_iomem_deny_access(const struct domain *d);
>  
>  #endif /* __ASSEMBLY__ */
>  #endif
> -- 
> 2.1.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64
  2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (21 preceding siblings ...)
  2016-03-25 13:48 ` [PATCH v7 22/22] xen/arm64: Add ACPI support Shannon Zhao
@ 2016-03-29  7:12 ` Jan Beulich
  2016-03-29 16:22   ` Julien Grall
  22 siblings, 1 reply; 45+ messages in thread
From: Jan Beulich @ 2016-03-29  7:12 UTC (permalink / raw)
  To: julien.grall
  Cc: shannon.zhao, xen-devel, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

>>> On 25.03.16 at 14:48, <shannon.zhao@linaro.org> wrote:
> These patches are Part 4 (and last part) of the previous patch set I
> sent which adds ACPI support for arm64 on Xen[1]. Split them as an
> individual set for convenient reviewing.
> 
> These patches create UEFI and ACPI tables which are mapped to Dom0's
> space and add other preparations for Dom0 to use ACPI. Then at last
> enable ACPI support on ARM64.

Looks like this series is ready to go in up to patch 20. Julien, you
had a number of comments on v6, and I didn't follow the
discussion too closely - could you (just informally, no need to send
out further individual acks if you didn't mean to send such anyway)
confirm that all the issues you had raised have got taken care of?

Thanks, Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables
  2016-03-25 13:48 ` [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
  2016-03-26 13:02   ` Stefano Stabellini
@ 2016-03-29 10:24   ` Julien Grall
  1 sibling, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 10:24 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:

[...]

> +static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo)
> +{
> +    size_t efi_size, acpi_size, madt_size;
> +    u64 addr;
> +    struct acpi_table_rsdp *rsdp_tbl;
> +    struct acpi_table_header *table;
> +
> +    efi_size = estimate_efi_size(kinfo->mem.nr_banks);
> +
> +    acpi_size = ROUNDUP(sizeof(struct acpi_table_fadt), 8);
> +    acpi_size += ROUNDUP(sizeof(struct acpi_table_stao), 8);
> +
> +    madt_size = sizeof(struct acpi_table_madt)
> +                + sizeof(struct acpi_madt_generic_interrupt) * d->max_vcpus
> +                + sizeof(struct acpi_madt_generic_distributor);
> +    if ( d->arch.vgic.version == GIC_V3 )
> +        madt_size += sizeof(struct acpi_madt_generic_redistributor)
> +                     * d->arch.vgic.nr_regions;
> +    acpi_size += ROUNDUP(madt_size, 8);
> +
> +    addr = acpi_os_get_root_pointer();
> +    if ( !addr )
> +    {
> +        printk("Unable to get acpi root pointer\n");
> +        return -EINVAL;
> +    }
> +
> +    rsdp_tbl = acpi_os_map_memory(addr, sizeof(struct acpi_table_rsdp));
> +    if ( !rsdp_tbl )
> +    {
> +        printk("Unable to map RSDP table\n");
> +        return -EINVAL;
> +    }
> +
> +    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
> +                               sizeof(struct acpi_table_header));
> +    if ( !table )

rsdp_tbl will be left mapped if Xen fails to map the XSDT.

As you don't use rsdp_tbl later, I would move 
acpi_os_unmap_memory(rsdp_tlb,...) here.

With this change:

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


> +    {
> +        printk("Unable to map XSDT table\n");
> +        return -EINVAL;
> +    }
> +
> +    /* Add place for STAO table in XSDT table */
> +    acpi_size += ROUNDUP(table->length + sizeof(u64), 8);
> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
> +
> +    acpi_size += ROUNDUP(sizeof(struct acpi_table_rsdp), 8);
> +    d->arch.efi_acpi_len = PAGE_ALIGN(ROUNDUP(efi_size, 8)
> +                                      + ROUNDUP(acpi_size, 8));
> +
> +    return 0;
> +}

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 02/22] arm/acpi: Add a helper function to get the acpi table offset
  2016-03-25 13:48 ` [PATCH v7 02/22] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
@ 2016-03-29 10:48   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 10:48 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> These tables are aligned with 64bit.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
> v7: add commnets to explain what thsi function does
> ---
>   xen/arch/arm/acpi/lib.c    | 20 ++++++++++++++++++++
>   xen/include/asm-arm/acpi.h |  2 ++
>   2 files changed, 22 insertions(+)
>
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index db5c4d8..cee2454 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -60,3 +60,23 @@ bool_t __init acpi_psci_hvc_present(void)
>   {
>       return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
>   }
> +
> +/*
> + * This function is used to get the offset of some new created ACPI or EFI table
> + * in the allocated memory region. Currently the tables should be created in the
> + * order of enum EFI_MEM_RES.
> + */

The function could be called after the table is created and still return 
the correct value. I would clearly write in the description when this 
function can be called or not. Something along those lines:

"This function returns the offset of a given ACPI/EFI table in the 
allocated memory region.

Currently, the tables should be created in the same order as their 
associated 'index' in the enum EFI_MEM_RES. This means the function 
won't return the correct offset until all the tables before a given 
'index' are created.".

Also, the description of an external function is usually done in the header.

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 04/22] arm/gic: Add a new callback for creating MADT table for Dom0
  2016-03-25 13:48 ` [PATCH v7 04/22] arm/gic: Add a new callback for creating MADT " Shannon Zhao
@ 2016-03-29 12:47   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 12:47 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Add a new member in gic_hw_operations which is used to create MADT table
> for Dom0.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 09/22] arm/p2m: Add helper functions to map memory regions
  2016-03-25 13:48 ` [PATCH v7 09/22] arm/p2m: Add helper functions to map memory regions Shannon Zhao
@ 2016-03-29 12:49   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 12:49 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: Parth Dixit, stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
>
> Create a helper function for mapping with cached attributes and
> read-write range.
>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 10/22] arm/acpi: Map all other tables for Dom0
  2016-03-25 13:48 ` [PATCH v7 10/22] arm/acpi: Map all other tables for Dom0 Shannon Zhao
@ 2016-03-29 13:02   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 13:02 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Map all other ACPI tables into Dom0 using 1:1 mappings.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 11/22] arm/acpi: Prepare EFI system table for Dom0
  2016-03-25 13:48 ` [PATCH v7 11/22] arm/acpi: Prepare EFI system table " Shannon Zhao
@ 2016-03-29 14:54   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 14:54 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Prepare EFI system table for Dom0 to describe the information of UEFI.
>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 12/22] arm/acpi: Prepare EFI memory descriptor for Dom0
  2016-03-25 13:48 ` [PATCH v7 12/22] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
@ 2016-03-29 14:54   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 14:54 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Create EFI memory descriptors to tell Dom0 the RAM region information,
> ACPI table regions and EFI tables reserved regions.
>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 13/22] arm/acpi: Map the new created EFI and ACPI tables to Dom0
  2016-03-25 13:48 ` [PATCH v7 13/22] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
@ 2016-03-29 15:01   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 15:01 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

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,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 14/22] arm/acpi: Create min DT stub for Dom0
  2016-03-25 13:48 ` [PATCH v7 14/22] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
@ 2016-03-29 16:10   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:10 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Create a DT for Dom0 for ACPI-case only. DT contains minimal required
> informations such as Dom0 bootargs, initrd, efi description table and

NIT: informations/information/

> address of uefi memory table.
>
> Also document this device tree bindings of "hypervisor" and
> "hypervisor/uefi" node.
>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 15/22] arm/acpi: Permit access all Xen unused SPIs for Dom0
  2016-03-25 13:48 ` [PATCH v7 15/22] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
@ 2016-03-29 16:10   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:10 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Allow DOM0 to use all SPIs but the ones used by Xen. Then when Dom0
> configures the interrupt, it could set the interrupt type and route it
> to Dom0.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 16/22] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically
  2016-03-25 13:48 ` [PATCH v7 16/22] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
@ 2016-03-29 16:12   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:12 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Interrupt information is described in DSDT and is not available at the
> time of booting. Check if the interrupt is permitted to access and set
> the interrupt type, route it to guest dynamically only for SPI
> and Dom0.
>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions
  2016-03-25 13:48 ` [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions Shannon Zhao
  2016-03-26 13:04   ` Stefano Stabellini
@ 2016-03-29 16:13   ` Julien Grall
  1 sibling, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:13 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Add a new member in gic_hw_operations which is used to deny Dom0 access
> to GIC regions.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 19/22] hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-03-25 13:48 ` [PATCH v7 19/22] hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
@ 2016-03-29 16:16   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:16 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: Keir Fraser, Tim Deegan, Ian Jackson, peter.huangpeng,
	stefano.stabellini, Jan Beulich, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> This new delivery type which is for ARM shares the same value with
> HVM_PARAM_CALLBACK_TYPE_VECTOR which is for x86.
>
> val[15:8] is flag: val[7:0] is a PPI.
> To the flag, bit 8 stands the interrupt mode is edge(1) or level(0) and
> bit 9 stands the interrupt polarity is active low(1) or high(0).
>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Keir Fraser <keir@xen.org>
> Cc: Tim Deegan <tim@xen.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 20/22] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2016-03-25 13:48 ` [PATCH v7 20/22] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
@ 2016-03-29 16:16   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:16 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Store the event-channel interrupt number and flag in HVM parameter
> HVM_PARAM_CALLBACK_IRQ. Then Dom0 could get it through hypercall
> HVMOP_get_param.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 22/22] xen/arm64: Add ACPI support
  2016-03-25 13:48 ` [PATCH v7 22/22] xen/arm64: Add ACPI support Shannon Zhao
@ 2016-03-29 16:20   ` Julien Grall
  0 siblings, 0 replies; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:20 UTC (permalink / raw)
  To: Shannon Zhao, xen-devel
  Cc: stefano.stabellini, peter.huangpeng, Jan Beulich, zhaoshenglong

Hi Shannon,

On 25/03/16 13:48, Shannon Zhao wrote:
> Add ACPI support on arm64 xen hypervisor. Enable EFI support on ARM.
>
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64
  2016-03-29  7:12 ` [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Jan Beulich
@ 2016-03-29 16:22   ` Julien Grall
  2016-03-30  7:55     ` Jan Beulich
  0 siblings, 1 reply; 45+ messages in thread
From: Julien Grall @ 2016-03-29 16:22 UTC (permalink / raw)
  To: Jan Beulich
  Cc: shannon.zhao, xen-devel, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

Hi Jan,

On 29/03/16 08:12, Jan Beulich wrote:
>>>> On 25.03.16 at 14:48, <shannon.zhao@linaro.org> wrote:
>> These patches are Part 4 (and last part) of the previous patch set I
>> sent which adds ACPI support for arm64 on Xen[1]. Split them as an
>> individual set for convenient reviewing.
>>
>> These patches create UEFI and ACPI tables which are mapped to Dom0's
>> space and add other preparations for Dom0 to use ACPI. Then at last
>> enable ACPI support on ARM64.
>
> Looks like this series is ready to go in up to patch 20. Julien, you
> had a number of comments on v6, and I didn't follow the
> discussion too closely - could you (just informally, no need to send
> out further individual acks if you didn't mean to send such anyway)
> confirm that all the issues you had raised have got taken care of?

I got some comments on patches #1, #2, #13 and #14. The rest is fine by me.

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64
  2016-03-29 16:22   ` Julien Grall
@ 2016-03-30  7:55     ` Jan Beulich
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Beulich @ 2016-03-30  7:55 UTC (permalink / raw)
  To: Julien Grall
  Cc: shannon.zhao, xen-devel, stefano.stabellini, peter.huangpeng,
	zhaoshenglong

>>> On 29.03.16 at 18:22, <julien.grall@arm.com> wrote:
> On 29/03/16 08:12, Jan Beulich wrote:
>>>>> On 25.03.16 at 14:48, <shannon.zhao@linaro.org> wrote:
>>> These patches are Part 4 (and last part) of the previous patch set I
>>> sent which adds ACPI support for arm64 on Xen[1]. Split them as an
>>> individual set for convenient reviewing.
>>>
>>> These patches create UEFI and ACPI tables which are mapped to Dom0's
>>> space and add other preparations for Dom0 to use ACPI. Then at last
>>> enable ACPI support on ARM64.
>>
>> Looks like this series is ready to go in up to patch 20. Julien, you
>> had a number of comments on v6, and I didn't follow the
>> discussion too closely - could you (just informally, no need to send
>> out further individual acks if you didn't mean to send such anyway)
>> confirm that all the issues you had raised have got taken care of?
> 
> I got some comments on patches #1, #2, #13 and #14. The rest is fine by me.

Thanks - means another iteration then.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping
  2016-03-25 13:48 ` [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
@ 2016-03-30 16:05   ` Konrad Rzeszutek Wilk
  2016-03-30 16:07   ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 45+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-03-30 16:05 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: Keir Fraser, Ian Jackson, Tim Deegan, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, Jan Beulich, zhaoshenglong

On Fri, Mar 25, 2016 at 09:48:54PM +0800, Shannon Zhao wrote:
> It needs to map platform or amba device mmio to Dom0 on ARM. But when
> booting with ACPI, it can't get the mmio region in Xen due to lack of
> AML interpreter to parse DSDT table. Therefore, let Dom0 call a
> hypercall to map mmio region when it adds the devices.
> 
> Here we add a new map space like the XEN_DOMCTL_memory_mapping to map
> mmio region for Dom0.
> 
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Keir Fraser <keir@xen.org>
> Cc: Tim Deegan <tim@xen.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/mm.c           |  3 +++
>  xen/arch/arm/p2m.c          | 22 ++++++++++++++++++++++
>  xen/common/memory.c         | 16 ++++++++++++++++
>  xen/include/asm-arm/p2m.h   |  5 +++++
>  xen/include/public/memory.h |  1 +
>  5 files changed, 47 insertions(+)
> 
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 81f9e2e..0aae6c5 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -1138,6 +1138,9 @@ int xenmem_add_to_physmap_one(
>          rcu_unlock_domain(od);
>          break;
>      }
> +    case XENMAPSPACE_dev_mmio:
> +        rc = map_dev_mmio_region(d, gpfn, 1, idx);
> +        return rc;
>  
>      default:
>          return -ENOSYS;
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index 7e5f5d1..0011708 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -7,6 +7,7 @@
>  #include <xen/bitops.h>
>  #include <xen/vm_event.h>
>  #include <xen/mem_access.h>
> +#include <xen/iocap.h>
>  #include <public/vm_event.h>
>  #include <asm/flushtlb.h>
>  #include <asm/gic.h>
> @@ -1270,6 +1271,27 @@ int unmap_mmio_regions(struct domain *d,
>                               d->arch.p2m.default_access);
>  }
>  
> +int map_dev_mmio_region(struct domain *d,
> +                        unsigned long start_gfn,
> +                        unsigned long nr,
> +                        unsigned long mfn)
> +{
> +    int res;
> +
> +    if ( !(nr && iomem_access_permitted(d, start_gfn, start_gfn + nr - 1)) )
> +        return 0;
> +
> +    res = map_mmio_regions(d, start_gfn, nr, mfn);
> +    if ( res < 0 )
> +    {
> +        printk(XENLOG_ERR "Unable to map [%#lx - %#lx] in Dom%d\n",
> +               start_gfn, start_gfn + nr - 1, d->domain_id);
> +        return res;
> +    }
> +
> +    return 0;
> +}
> +
>  int guest_physmap_add_entry(struct domain *d,
>                              unsigned long gpfn,
>                              unsigned long mfn,
> diff --git a/xen/common/memory.c b/xen/common/memory.c
> index c7fca96..25ff86c 100644
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -980,6 +980,14 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>          if ( d == NULL )
>              return -ESRCH;
>  
> +        /*
> +         * XENMAPSPACE_dev_mmio mapping is only supported for hardware Domain

Any reason to make Domain be uppercase?

> +         * to map this kind of space to itself.
> +         */
> +        if ( (xatp.space == XENMAPSPACE_dev_mmio) &&
> +             ((d != current->domain) || !is_hardware_domain(d)) )
> +            return -EACCES;

Shouldnt' this be -EPERM? 
Also you probably want to do 'rcu_unlock_domain(d)' before you return?

> +
>          rc = xsm_add_to_physmap(XSM_TARGET, current->domain, d);
>          if ( rc )
>          {
> @@ -1024,6 +1032,14 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>          if ( d == NULL )
>              return -ESRCH;
>  
> +        /*
> +         * XENMAPSPACE_dev_mmio mapping is only supported for hardware Domain

Any reason to make Domain be uppercase?

> +         * to map this kind of space to itself.
> +         */
> +        if ( (xatpb.space == XENMAPSPACE_dev_mmio) &&
> +             ((d != current->domain) || !is_hardware_domain(d)) )
> +            return -EACCES;
> +
>          rc = xsm_add_to_physmap(XSM_TARGET, current->domain, d);
>          if ( rc )
>          {
> diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
> index 55626b4..d240d1e 100644
> --- a/xen/include/asm-arm/p2m.h
> +++ b/xen/include/asm-arm/p2m.h
> @@ -154,6 +154,11 @@ int unmap_regions_rw_cache(struct domain *d,
>                             unsigned long nr_mfns,
>                             unsigned long mfn);
>  
> +int map_dev_mmio_region(struct domain *d,
> +                        unsigned long start_gfn,
> +                        unsigned long nr,
> +                        unsigned long mfn);
> +
>  int guest_physmap_add_entry(struct domain *d,
>                              unsigned long gfn,
>                              unsigned long mfn,
> diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
> index f69e92f..fe52ee1 100644
> --- a/xen/include/public/memory.h
> +++ b/xen/include/public/memory.h
> @@ -220,6 +220,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
>  #define XENMAPSPACE_gmfn_range   3 /* GMFN range, XENMEM_add_to_physmap only. */
>  #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
>                                      * XENMEM_add_to_physmap_batch only. */
> +#define XENMAPSPACE_dev_mmio     5 /* device mmio region */

You probably want to mention what the return values can be? Also why
not make 'device' be 'Device'.

>  /* ` } */
>  
>  /*
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping
  2016-03-25 13:48 ` [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
  2016-03-30 16:05   ` Konrad Rzeszutek Wilk
@ 2016-03-30 16:07   ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 45+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-03-30 16:07 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: Keir Fraser, Ian Jackson, Tim Deegan, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, Jan Beulich, zhaoshenglong

> +int map_dev_mmio_region(struct domain *d,
> +                        unsigned long start_gfn,
> +                        unsigned long nr,
> +                        unsigned long mfn)
> +{
> +    int res;
> +
> +    if ( !(nr && iomem_access_permitted(d, start_gfn, start_gfn + nr - 1)) )
> +        return 0;
> +
> +    res = map_mmio_regions(d, start_gfn, nr, mfn);
> +    if ( res < 0 )
> +    {
> +        printk(XENLOG_ERR "Unable to map [%#lx - %#lx] in Dom%d\n",

Perhaps we also want to rate limit this?
> +               start_gfn, start_gfn + nr - 1, d->domain_id);
> +        return res;
> +    }
> +
> +    return 0;
> +}
> +

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2016-03-30 16:07 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-25 13:48 [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
2016-03-25 13:48 ` [PATCH v7 01/22] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
2016-03-26 13:02   ` Stefano Stabellini
2016-03-29 10:24   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 02/22] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
2016-03-29 10:48   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 03/22] arm/acpi: Prepare FADT table for Dom0 Shannon Zhao
2016-03-25 13:48 ` [PATCH v7 04/22] arm/gic: Add a new callback for creating MADT " Shannon Zhao
2016-03-29 12:47   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 05/22] arm/acpi: Prepare " Shannon Zhao
2016-03-25 13:48 ` [PATCH v7 06/22] arm/acpi: Prepare STAO " Shannon Zhao
2016-03-25 13:48 ` [PATCH v7 07/22] arm/acpi: Prepare XSDT " Shannon Zhao
2016-03-25 13:48 ` [PATCH v7 08/22] arm/acpi: Prepare RSDP " Shannon Zhao
2016-03-25 13:48 ` [PATCH v7 09/22] arm/p2m: Add helper functions to map memory regions Shannon Zhao
2016-03-29 12:49   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 10/22] arm/acpi: Map all other tables for Dom0 Shannon Zhao
2016-03-29 13:02   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 11/22] arm/acpi: Prepare EFI system table " Shannon Zhao
2016-03-29 14:54   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 12/22] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
2016-03-29 14:54   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 13/22] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
2016-03-29 15:01   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 14/22] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
2016-03-29 16:10   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 15/22] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
2016-03-29 16:10   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 16/22] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
2016-03-29 16:12   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 17/22] arm/gic: Add a new callback to deny Dom0 access to GIC regions Shannon Zhao
2016-03-26 13:04   ` Stefano Stabellini
2016-03-29 16:13   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 18/22] arm/acpi: Permit MMIO access of Xen unused devices for Dom0 Shannon Zhao
2016-03-25 13:48 ` [PATCH v7 19/22] hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
2016-03-29 16:16   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 20/22] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
2016-03-29 16:16   ` Julien Grall
2016-03-25 13:48 ` [PATCH v7 21/22] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
2016-03-30 16:05   ` Konrad Rzeszutek Wilk
2016-03-30 16:07   ` Konrad Rzeszutek Wilk
2016-03-25 13:48 ` [PATCH v7 22/22] xen/arm64: Add ACPI support Shannon Zhao
2016-03-29 16:20   ` Julien Grall
2016-03-29  7:12 ` [PATCH v7 00/22] Prepare UEFI and ACPI tables for Dom0 on ARM64 Jan Beulich
2016-03-29 16:22   ` Julien Grall
2016-03-30  7:55     ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).