xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64
@ 2016-02-28 11:18 Shannon Zhao
  2016-02-28 11:18 ` [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables Shannon Zhao
                   ` (23 more replies)
  0 siblings, 24 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:18 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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

Naresh Bhat (1):
  xen/arm64: Add ACPI support

Parth Dixit (2):
  arm/acpi: Read acpi memory info from uefi
  arm/p2m: Add helper functions to map memory regions

Shannon Zhao (21):
  arm/acpi: Define a enum for reserved tables
  arm/acpi: Add placeholder for efi and acpi load address
  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/acpi: Permit MMIO access of Xen unused devices for Dom0
  hvm/params: Add a new dilivery 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

 docs/misc/arm/device-tree/xen.txt |  58 ++++
 xen/arch/arm/Kconfig              |   1 +
 xen/arch/arm/acpi/lib.c           |  14 +
 xen/arch/arm/domain.c             |   4 +
 xen/arch/arm/domain_build.c       | 583 +++++++++++++++++++++++++++++++++++++-
 xen/arch/arm/efi/efi-boot.h       |  23 ++
 xen/arch/arm/gic-v2.c             |  34 +++
 xen/arch/arm/gic-v3.c             |  47 +++
 xen/arch/arm/gic.c                |   5 +
 xen/arch/arm/mm.c                 |   4 +
 xen/arch/arm/p2m.c                |  49 ++++
 xen/arch/arm/vgic.c               |  32 +++
 xen/common/efi/boot.c             | 149 ++++++++++
 xen/common/efi/runtime.c          |   8 +-
 xen/common/memory.c               |  14 +
 xen/include/asm-arm/acpi.h        |  14 +
 xen/include/asm-arm/config.h      |   5 +
 xen/include/asm-arm/domain.h      |   5 +
 xen/include/asm-arm/gic.h         |   3 +
 xen/include/asm-arm/p2m.h         |  15 +
 xen/include/asm-arm/setup.h       |  12 +
 xen/include/public/hvm/params.h   |   9 +
 xen/include/public/memory.h       |   1 +
 23 files changed, 1086 insertions(+), 3 deletions(-)
 create mode 100644 docs/misc/arm/device-tree/xen.txt

-- 
2.0.4



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

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

* [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
@ 2016-02-28 11:18 ` Shannon Zhao
  2016-02-29 14:02   ` Stefano Stabellini
  2016-02-29 15:16   ` Jan Beulich
  2016-02-28 11:18 ` [PATCH v4 02/24] arm/acpi: Add placeholder for efi and acpi load address Shannon Zhao
                   ` (22 subsequent siblings)
  23 siblings, 2 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:18 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

It needs to copy and change the contents of some ACPI and EFI tables for
Dom0. Here define a enum for those tables.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/asm-arm/acpi.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index a0f2f24..7f59761 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -30,6 +30,18 @@
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
 #define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
 
+/* Tables marked as reserved in efi table */
+typedef enum {
+    TBL_FADT,
+    TBL_MADT,
+    TBL_STAO,
+    TBL_XSDT,
+    TBL_RSDP,
+    TBL_EFIT,
+    TBL_MMAP,
+    TBL_MMAX,
+} EFI_MEM_RES;
+
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
 void __init acpi_smp_init_cpus(void);
-- 
2.0.4



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

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

* [PATCH v4 02/24] arm/acpi: Add placeholder for efi and acpi load address
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
  2016-02-28 11:18 ` [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables Shannon Zhao
@ 2016-02-28 11:18 ` Shannon Zhao
  2016-02-29 14:01   ` Stefano Stabellini
  2016-02-28 11:18 ` [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi Shannon Zhao
                   ` (21 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:18 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

We will create EFI table, memory description table and some of acpi
tables and we're going to map them to kinfo->gnttab_start of Dom0.
Add placeholder for the starting address for loading in DOM0 and the
size of new added tables. Also add a placeholder to store the new
created tables.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: explain why these need in commit message
---
 xen/include/asm-arm/domain.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index aa7f283..8e1161f 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -124,6 +124,11 @@ struct arch_domain
     } vuart;
 
     unsigned int evtchn_irq;
+#ifdef CONFIG_ACPI
+    void *efi_acpi_table;
+    paddr_t efi_acpi_gpa;
+    paddr_t efi_acpi_len;
+#endif
 }  __cacheline_aligned;
 
 struct arch_vcpu
-- 
2.0.4



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

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

* [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
  2016-02-28 11:18 ` [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables Shannon Zhao
  2016-02-28 11:18 ` [PATCH v4 02/24] arm/acpi: Add placeholder for efi and acpi load address Shannon Zhao
@ 2016-02-28 11:18 ` Shannon Zhao
  2016-02-29 14:57   ` Jan Beulich
  2016-02-28 11:19 ` [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
                   ` (20 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:18 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

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

ACPI memory is seperate from conventional memory and should be marked
as reserved while passing to DOM0. Create a new meminfo structure to
store all the acpi tables listed in uefi.

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

diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index e427e5f..a6c3b69 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -17,6 +17,9 @@ void __flush_dcache_area(const void *vaddr, unsigned long size);
 static struct file __initdata dtbfile;
 static void __initdata *fdt;
 static void __initdata *memmap;
+#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
+static struct meminfo __initdata acpi_mem;
+#endif
 
 static int __init setup_chosen_node(void *fdt, int *addr_cells, int *size_cells)
 {
@@ -129,6 +132,9 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
 {
     int Index;
     int i = 0;
+#ifdef CONFIG_ACPI
+    int j = 0;
+#endif
     EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
 
     for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
@@ -148,10 +154,27 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
             bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
             ++i;
         }
+#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
+        else if ( desc_ptr->Type == EfiACPIReclaimMemory )
+        {
+            if ( j >= NR_MEM_BANKS )
+            {
+                PrintStr(L"Error: All " __stringify(NR_MEM_BANKS)
+                          " acpi meminfo mem banks exhausted.\r\n");
+                return EFI_LOAD_ERROR;
+            }
+            acpi_mem.bank[j].start = desc_ptr->PhysicalStart;
+            acpi_mem.bank[j].size  = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
+            ++j;
+        }
+#endif
         desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
     }
 
     bootinfo.mem.nr_banks = i;
+#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
+    acpi_mem.nr_banks = j;
+#endif
     return EFI_SUCCESS;
 }
 
-- 
2.0.4



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

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

* [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (2 preceding siblings ...)
  2016-02-28 11:18 ` [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 11:11   ` Jan Beulich
  2016-02-29 12:13   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 05/24] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
                   ` (19 subsequent siblings)
  23 siblings, 2 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, peter.huangpeng, stefano.stabellini, shannon.zhao,
	Jan Beulich, zhaoshenglong

From: Shannon Zhao <shannon.zhao@linaro.org>

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.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: make the length of each table aligned with 64bit
---
 xen/arch/arm/domain.c       |  4 +++
 xen/arch/arm/domain_build.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-
 xen/common/efi/boot.c       | 20 +++++++++++
 xen/include/asm-arm/setup.h |  2 ++
 4 files changed, 106 insertions(+), 1 deletion(-)

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..b10a69d 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,79 @@ 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)
+{
+    u64 efi_size, acpi_size = 0, addr;
+    u32 madt_size;
+    struct acpi_table_rsdp *rsdp_tbl;
+    struct acpi_table_header *table = NULL;
+
+    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));
+    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
+                               sizeof(struct acpi_table_header));
+    /* 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 = 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. */
+    d->arch.efi_acpi_gpa = kinfo->gnttab_start;
+
+    return 0;
+}
+#else
+static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
+{
+    /* Only booting with ACPI will hit here */
+    BUG_ON(1);
+    return -EINVAL;
+}
+#endif
 static void dtb_load(struct kernel_info *kinfo)
 {
     void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr;
@@ -1540,7 +1615,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/common/efi/boot.c b/xen/common/efi/boot.c
index 53c7452..535c685 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -13,6 +13,7 @@
 #include <xen/multiboot.h>
 #include <xen/pci_regs.h>
 #include <xen/pfn.h>
+#include <asm/acpi.h>
 #if EFI_PAGE_SIZE != PAGE_SIZE
 # error Cannot use xen/pfn.h here!
 #endif
@@ -1171,6 +1172,25 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
     for( ; ; ); /* not reached */
 }
 
+#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
+/* Constant to indicate "Xen" in unicode u16 format */
+static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};
+
+int __init estimate_efi_size(int mem_nr_banks)
+{
+    int size = 0;
+    int est_size = sizeof(EFI_SYSTEM_TABLE);
+    int ect_size = sizeof(EFI_CONFIGURATION_TABLE);
+    int emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
+    int fw_vendor_size = sizeof(XEN_EFI_FW_VENDOR);
+
+    size += ROUNDUP((est_size + ect_size + fw_vendor_size), 8);
+    size += ROUNDUP(emd_size * (mem_nr_banks + acpi_mem.nr_banks + 1), 8);
+
+    return size;
+}
+#endif
+
 #ifndef CONFIG_ARM /* TODO - runtime service support */
 
 static bool_t __initdata efi_rs_enable = 1;
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 30ac53b..b759813 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);
 
+int estimate_efi_size(int mem_nr_banks);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.0.4



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

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

* [PATCH v4 05/24] arm/acpi: Add a helper function to get the acpi table offset
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (3 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 12:17   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 06/24] arm/acpi: Prepare FADT table for Dom0 Shannon Zhao
                   ` (18 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

These tables are aligned with 64bit.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: aligned with 64bit
---
 xen/arch/arm/acpi/lib.c    | 14 ++++++++++++++
 xen/include/asm-arm/acpi.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index 5698245..d5ac590 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -62,3 +62,17 @@ bool_t __init acpi_psci_hvc_present(void)
 {
     return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
 }
+
+unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index)
+{
+    int i;
+    unsigned int 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..b507dca 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);
+unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
 
 #ifdef CONFIG_ACPI
 extern bool_t acpi_disabled;
-- 
2.0.4



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

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

* [PATCH v4 06/24] arm/acpi: Prepare FADT table for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (4 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 05/24] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 12:22   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 07/24] arm/gic: Add a new callback for creating MADT " Shannon Zhao
                   ` (17 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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>
---
 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 b10a69d..f041a8a 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)
 {
     u64 efi_size, acpi_size = 0, addr;
@@ -1401,6 +1439,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 )
@@ -1419,6 +1458,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
      * region. So we use it as the ACPI table mapped address. */
     d->arch.efi_acpi_gpa = kinfo->gnttab_start;
 
+    rc = acpi_create_fadt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.0.4



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

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

* [PATCH v4 07/24] arm/gic: Add a new callback for creating MADT table for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (5 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 06/24] arm/acpi: Prepare FADT table for Dom0 Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 12:50   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 08/24] arm/acpi: Prepare " Shannon Zhao
                   ` (16 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/gic-v2.c     | 34 ++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic-v3.c     | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic.c        |  5 +++++
 xen/include/asm-arm/gic.h |  3 +++
 4 files changed, 89 insertions(+)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 0fcb894..02db5f2 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -685,6 +685,35 @@ static void __init gicv2_dt_init(void)
 }
 
 #ifdef CONFIG_ACPI
+static u32 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 )
+        panic("Can't get GICC entry");
+    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);
+        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 +805,10 @@ static void __init gicv2_acpi_init(void)
 }
 #else
 static void __init gicv2_acpi_init(void) { }
+static u32 gicv2_make_hwdom_madt(const struct domain *d, u32 offset)
+{
+    return 0;
+}
 #endif
 
 static int __init gicv2_init(void)
@@ -868,6 +901,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..d9fce4b 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1236,6 +1236,48 @@ static void __init gicv3_dt_init(void)
 }
 
 #ifdef CONFIG_ACPI
+static u32 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 )
+        panic("Can't get GICC entry");
+    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);
+        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 +1422,10 @@ static void __init gicv3_acpi_init(void)
 }
 #else
 static void __init gicv3_acpi_init(void) { }
+static u32 gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
+{
+    return 0;
+}
 #endif
 
 /* Set up the GIC */
@@ -1474,6 +1520,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..6d32432 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);
 }
 
+u32 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..4cf003d 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 */
+    u32 (*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);
+u32 gic_make_hwdom_madt(const struct domain *d, u32 offset);
 
 #endif /* __ASSEMBLY__ */
 #endif
-- 
2.0.4



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

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

* [PATCH v4 08/24] arm/acpi: Prepare MADT table for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (6 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 07/24] arm/gic: Add a new callback for creating MADT " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 12:52   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 09/24] arm/acpi: Prepare STAO " Shannon Zhao
                   ` (15 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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>
---
v4: use make_hwdom_madt callback to create MADT
---
 xen/arch/arm/domain_build.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index f041a8a..e373165 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,52 @@ 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);
+    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 )
+        panic("Can't get GICC entry");
+    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*/
+    table_size += gic_make_hwdom_madt(d, offset + table_size);
+
+    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[])
 {
@@ -1462,6 +1508,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.0.4



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

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

* [PATCH v4 09/24] arm/acpi: Prepare STAO table for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (7 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 08/24] arm/acpi: Prepare " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 14:07   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 10/24] arm/acpi: Prepare XSDT " Shannon Zhao
                   ` (14 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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>
---
 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 e373165..53cddb7 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 of some table, here use MADT */
+    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, 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;
@@ -1512,6 +1549,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.0.4



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

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

* [PATCH v4 10/24] arm/acpi: Prepare XSDT table for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (8 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 09/24] arm/acpi: Prepare STAO " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-28 11:19 ` [PATCH v4 11/24] arm/acpi: Prepare RSDP " Shannon Zhao
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Copy and modify XSDT table before passing it to Dom0. Repalce 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>
---
 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 53cddb7..0888ec3 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;
@@ -1553,6 +1621,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.0.4



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

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

* [PATCH v4 11/24] arm/acpi: Prepare RSDP table for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (9 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 10/24] arm/acpi: Prepare XSDT " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-28 11:19 ` [PATCH v4 12/24] arm/p2m: Add helper functions to map memory regions Shannon Zhao
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Copy RSDP table and replace rsdp->xsdt_physical_address with new 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>
---
 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 0888ec3..64e48ae 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,38 @@ 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 )
+        panic("Unable to get acpi root pointer\n");
+
+    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)
 {
@@ -1625,6 +1657,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.0.4



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

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

* [PATCH v4 12/24] arm/p2m: Add helper functions to map memory regions
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (10 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 11/24] arm/acpi: Prepare RSDP " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 14:11   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0 Shannon Zhao
                   ` (11 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

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

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

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: use p2m_access_r
---
 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..c36fdf6 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(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_r);
+}
+
+int unmap_regions(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_r);
+}
+
 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..945b613 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(struct domain *d,
+                    unsigned long start_gfn,
+                    unsigned long nr_mfns,
+                    unsigned long mfn);
+
+int unmap_regions(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.0.4



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

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

* [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (11 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 12/24] arm/p2m: Add helper functions to map memory regions Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 14:15   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 14/24] arm/acpi: Prepare EFI system table " Shannon Zhao
                   ` (10 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Map all other tables to Dom0 using 1:1 mappings.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: fix commit message
---
 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 64e48ae..6ad420c 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 other 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(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 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[])
 {
 
@@ -1661,6 +1685,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.0.4



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

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

* [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (12 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0 Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 11:19   ` Jan Beulich
  2016-02-28 11:19 ` [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
                   ` (9 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, peter.huangpeng, stefano.stabellini, shannon.zhao,
	Jan Beulich, zhaoshenglong

From: Shannon Zhao <shannon.zhao@linaro.org>

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

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: use already existing xz_crc32_init and xz_crc32
---
 xen/arch/arm/domain_build.c |  2 ++
 xen/common/efi/boot.c       | 44 ++++++++++++++++++++++++++++++++++++++++++++
 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 6ad420c..09f9770 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1686,6 +1686,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
         return rc;
 
     acpi_map_other_tables(d);
+    acpi_create_efi_system_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_table,
+                                 tbl_add);
 
     return 0;
 }
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 535c685..238c5fd 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1173,6 +1173,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 }
 
 #if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
+#include "../../../common/decompress.h"
+#define XZ_EXTERN STATIC
+#include "../../../common/xz/crc32.c"
+
 /* Constant to indicate "Xen" in unicode u16 format */
 static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};
 
@@ -1189,6 +1193,46 @@ int __init estimate_efi_size(int mem_nr_banks)
 
     return size;
 }
+
+void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
+                                         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 = paddr + 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 = 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((u16 *)(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;
+}
 #endif
 
 #ifndef CONFIG_ARM /* TODO - runtime service support */
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index b759813..2d65796 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);
 
 int estimate_efi_size(int mem_nr_banks);
 
+void acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
+                                  struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.0.4



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

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

* [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (13 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 14/24] arm/acpi: Prepare EFI system table " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 14:37   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 16/24] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
                   ` (8 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, peter.huangpeng, stefano.stabellini, shannon.zhao,
	Jan Beulich, zhaoshenglong

From: Shannon Zhao <shannon.zhao@linaro.org>

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

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: use a single descriptor for new created tables
---
 xen/arch/arm/domain_build.c |  2 ++
 xen/common/efi/boot.c       | 38 ++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/setup.h |  5 +++++
 3 files changed, 45 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 09f9770..1ec6271 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1688,6 +1688,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     acpi_map_other_tables(d);
     acpi_create_efi_system_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_table,
                                  tbl_add);
+    acpi_create_efi_mmap_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_len,
+                               d->arch.efi_acpi_table, &kinfo->mem, tbl_add);
 
     return 0;
 }
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 238c5fd..b8d7409 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1233,6 +1233,44 @@ void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
     tbl_add[TBL_EFIT].start = table_addr;
     tbl_add[TBL_EFIT].size = table_size;
 }
+
+void __init acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
+                                       void *efi_acpi_table,
+                                       const struct meminfo *mem,
+                                       struct membank tbl_add[])
+{
+    EFI_MEMORY_DESCRIPTOR *memory_map;
+    int i, offset;
+    u8 *base_ptr;
+
+    tbl_add[TBL_MMAP].start = paddr + 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);
+    base_ptr = 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;
+        memory_map[offset].NumberOfPages = PFN_UP(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;
+        memory_map[offset].NumberOfPages = PFN_UP(acpi_mem.bank[i].size);
+        memory_map[offset].Attribute = EFI_MEMORY_WB;
+    }
+
+    memory_map[offset].Type = EfiACPIReclaimMemory;
+    memory_map[offset].PhysicalStart = paddr;
+    memory_map[offset].NumberOfPages = PFN_UP(size);
+    memory_map[offset].Attribute = EFI_MEMORY_WB;
+}
 #endif
 
 #ifndef CONFIG_ARM /* TODO - runtime service support */
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 2d65796..af5a038 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -56,6 +56,11 @@ int estimate_efi_size(int mem_nr_banks);
 void acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
                                   struct membank tbl_add[]);
 
+void acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
+                                void *efi_acpi_table,
+                                const struct meminfo *mem,
+                                struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.0.4



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

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

* [PATCH v4 16/24] arm/acpi: Map the new created EFI and ACPI tables to Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (14 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 14:42   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 17/24] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
                   ` (7 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Map the UEFI and ACPI tables which we created to non-RAM space in Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 1ec6271..083ddd5 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1691,6 +1691,21 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     acpi_create_efi_mmap_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_len,
                                d->arch.efi_acpi_table, &kinfo->mem, tbl_add);
 
+    /* Map the EFI and ACPI tables to Dom0 */
+    rc = map_regions(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 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;
+    }
+
     return 0;
 }
 #else
-- 
2.0.4



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

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

* [PATCH v4 17/24] arm/acpi: Create min DT stub for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (15 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 16/24] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 15:05   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 18/24] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
                   ` (6 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, peter.huangpeng, stefano.stabellini, shannon.zhao,
	Jan Beulich, zhaoshenglong

From: Shannon Zhao <shannon.zhao@linaro.org>

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 port the document of this device tree bindings from Linux.

Cc: Jan Beulich <jbeulich@suse.com>
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>
---
v4: port the document of this device tree bindings from Linux
---
 docs/misc/arm/device-tree/xen.txt |  58 ++++++++++++++++
 xen/arch/arm/domain_build.c       | 143 ++++++++++++++++++++++++++++++++++++++
 xen/common/efi/boot.c             |  47 +++++++++++++
 xen/include/asm-arm/setup.h       |   2 +
 4 files changed, 250 insertions(+)
 create mode 100644 docs/misc/arm/device-tree/xen.txt

diff --git a/docs/misc/arm/device-tree/xen.txt b/docs/misc/arm/device-tree/xen.txt
new file mode 100644
index 0000000..6f83f76
--- /dev/null
+++ b/docs/misc/arm/device-tree/xen.txt
@@ -0,0 +1,58 @@
+* 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()).
+
+- interrupts: the interrupt used by Xen to inject event notifications.
+  A GIC node is also required.
+
+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, which are provided by the regular 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
+http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html.
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 083ddd5..4b1f387 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,145 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+#define ACPI_DOM0_FDT_MIN_SIZE 4096
+
+static int make_chosen_node(const struct kernel_info *kinfo,
+                            struct membank tbl_add[])
+{
+    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 = arm_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 = make_chosen_node(kinfo, tbl_add);
+    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;
@@ -1706,6 +1845,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
         return rc;
     }
 
+    rc = create_acpi_dtb(kinfo, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index b8d7409..c0b08ef 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1271,6 +1271,53 @@ void __init acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
     memory_map[offset].NumberOfPages = PFN_UP(size);
     memory_map[offset].Attribute = EFI_MEMORY_WB;
 }
+
+/* Create place holder for efi values. */
+int __init arm_acpi_make_efi_nodes(void *fdt, struct membank tbl_add[])
+{
+    u64 fdt_val64;
+    u32 fdt_val32;
+    int desc_ver = mdesc_ver;
+    int res;
+
+    res = fdt_begin_node(fdt, "uefi");
+    if ( res )
+        return res;
+
+    fdt_val64 = cpu_to_fdt64(tbl_add[TBL_EFIT].start);
+    res = fdt_property(fdt, "xen,uefi-system-table",
+                       &fdt_val64, sizeof(fdt_val64));
+    if ( res )
+        return res;
+
+    fdt_val64 = cpu_to_fdt64(tbl_add[TBL_MMAP].start);
+    res = fdt_property(fdt, "xen,uefi-mmap-start",
+                       &fdt_val64,  sizeof(fdt_val64));
+    if ( res )
+        return res;
+
+    fdt_val32 = cpu_to_fdt32(tbl_add[TBL_MMAP].size);
+    res = fdt_property(fdt, "xen,uefi-mmap-size",
+                       &fdt_val32,  sizeof(fdt_val32));
+    if ( res )
+        return res;
+
+    fdt_val32 = cpu_to_fdt32(sizeof(EFI_MEMORY_DESCRIPTOR));
+    res = fdt_property(fdt, "xen,uefi-mmap-desc-size",
+                         &fdt_val32, sizeof(fdt_val32));
+    if ( res )
+        return res;
+
+    fdt_val32 = cpu_to_fdt32(desc_ver);
+    res = fdt_property(fdt, "xen,uefi-mmap-desc-ver",
+                         &fdt_val32, sizeof(fdt_val32));
+    if ( res )
+        return res;
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
 #endif
 
 #ifndef CONFIG_ARM /* TODO - runtime service support */
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index af5a038..fdec501 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -61,6 +61,8 @@ void acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
                                 const struct meminfo *mem,
                                 struct membank tbl_add[]);
 
+int arm_acpi_make_efi_nodes(void *fdt, struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.0.4



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

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

* [PATCH v4 18/24] arm/acpi: Permit access all Xen unused SPIs for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (16 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 17/24] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 15:13   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 19/24] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
                   ` (5 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

Permit access all Xen unused SPIs for Dom0 except the interrupts that
Xen uses. 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>
---
v4: only permmit access all Xen unused SPIs for Dom0 and don't set type
---
 xen/arch/arm/domain_build.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 4b1f387..4aaffae 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,33 @@ 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++ )
+    {
+        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 make_chosen_node(const struct kernel_info *kinfo,
                             struct membank tbl_add[])
 {
@@ -1849,6 +1876,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.0.4



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

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

* [PATCH v4 19/24] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (17 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 18/24] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 16:58   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 20/24] arm/acpi: Permit MMIO access of Xen unused devices for Dom0 Shannon Zhao
                   ` (4 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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>
---
 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..902a16d 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,8 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
     }
 }
 
+#define VGIC_ICFG_MASK(intr) ( 1 << ( ( 2 * ( intr % 16 ) ) + 1 ) )
+
 void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
 {
     const unsigned long mask = r;
@@ -342,9 +346,37 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
     unsigned long flags;
     int i = 0;
     struct vcpu *v_target;
+#ifdef CONFIG_HAS_ACPI
+    struct domain *d = v->domain;
+    struct vgic_irq_rank *vr = vgic_get_rank(v, n);
+    uint32_t tr;
+    int ret;
+#endif
 
     while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
         irq = i + (32 * n);
+#ifdef CONFIG_HAS_ACPI
+        /* 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 ) )
+        {
+            tr = vr->icfg[i >> 4];
+
+            if ( tr & VGIC_ICFG_MASK(i) )
+                ret = irq_set_spi_type(irq, IRQ_TYPE_EDGE_BOTH);
+            else
+                ret = irq_set_spi_type(irq, IRQ_TYPE_LEVEL_MASK);
+            if ( ret )
+                printk(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 )
+                printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
+                       irq, d->domain_id);
+        }
+#endif
         v_target = __vgic_get_target_vcpu(v, irq);
         p = irq_to_pending(v_target, irq);
         set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
-- 
2.0.4



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

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

* [PATCH v4 20/24] arm/acpi: Permit MMIO access of Xen unused devices for Dom0
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (18 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 19/24] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 17:02   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
                   ` (3 subsequent siblings)
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: add comments for TODO
---
 xen/arch/arm/domain_build.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 4aaffae..7750798 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,33 @@ 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 */
+    return iomem_deny_access(d, gfn, gfn + 1);
+}
+
 static int acpi_permit_spi_access(struct domain *d)
 {
     int i, res;
@@ -1880,6 +1907,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.0.4



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

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

* [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (19 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 20/24] arm/acpi: Permit MMIO access of Xen unused devices for Dom0 Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 11:23   ` Jan Beulich
  2016-02-29 17:04   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 22/24] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
                   ` (2 subsequent siblings)
  23 siblings, 2 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: ian.campbell, peter.huangpeng, stefano.stabellini, shannon.zhao,
	Jan Beulich, zhaoshenglong

From: Shannon Zhao <shannon.zhao@linaro.org>

Add a new dilivery type:
val[63:56] == 3: val[15:8] is flag: val[7:0] is a PPI.
To the flag, bit 0 stands the interrupt mode is edge(1) or level(0) and
bit 1 stands the interrupt polarity is active low(1) or high(0).

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: rebase on master
---
 xen/include/public/hvm/params.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index 81f9451..382a79d 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -55,6 +55,15 @@
  * if this delivery method is available.
  */
 
+#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
+/*
+ * val[15:8] is flag of event-channel interrupt:
+ *  bit 0: interrupt is edge(1) or level(0) triggered
+ *  bit 1: interrupt is active low(1) or high(0)
+ * val[7:0] is PPI number used by event-channel.
+ * This is only used by ARM/ARM64.
+ */
+
 /*
  * These are not used by Xen. They are here for convenience of HVM-guest
  * xenbus implementations.
-- 
2.0.4



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

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

* [PATCH v4 22/24] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (20 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 17:08   ` Stefano Stabellini
  2016-02-28 11:19 ` [PATCH v4 23/24] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
  2016-02-28 11:19 ` [PATCH v4 24/24] xen/arm64: Add ACPI support Shannon Zhao
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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>
---
v4: always set HVM_PARAM_CALLBACK_IRQ parameter
---
 xen/arch/arm/domain_build.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 7750798..80c4230 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2003,6 +2003,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;
 
     /*
@@ -2018,6 +2019,15 @@ 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_EVENT << 56;
+    val |= (2 << 8); /* Active-low level-sensitive  */
+    val |= d->arch.evtchn_irq & 0xff;
+    d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val;
+
+    if ( !acpi_disabled )
+        return;
+
     /* Fix up "interrupts" in /hypervisor node */
     node = fdt_path_offset(kinfo->fdt, "/hypervisor");
     if ( node < 0 )
-- 
2.0.4



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

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

* [PATCH v4 23/24] xen/arm: Add a hypercall for device mmio mapping
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (21 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 22/24] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 11:32   ` Jan Beulich
  2016-02-28 11:19 ` [PATCH v4 24/24] xen/arm64: Add ACPI support Shannon Zhao
  23 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Shannon Zhao <shannon.zhao@linaro.org>

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.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
v4: check the domain if it's Dom0 and it maps to itself
---
 xen/arch/arm/mm.c           |  4 ++++
 xen/arch/arm/p2m.c          | 23 +++++++++++++++++++++++
 xen/common/memory.c         | 14 ++++++++++++++
 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..c4bf0a5 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1138,6 +1138,10 @@ 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;
+        break;
 
     default:
         return -ENOSYS;
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index c36fdf6..d9796ef 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,28 @@ 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(!iomem_access_permitted(d, start_gfn, start_gfn + nr))
+        return 0;
+
+    res = map_mmio_regions(d, start_gfn, nr, mfn);
+    if ( res < 0 )
+    {
+        printk(XENLOG_ERR "Unable to map 0x%lx - 0x%lx in domain %d\n",
+               start_gfn << PAGE_SHIFT, (start_gfn + nr) << PAGE_SHIFT,
+               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 ef57219..c8fcffe 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -980,6 +980,13 @@ 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) &&
+             (!is_hardware_domain(current->domain) || (d != current->domain)) )
+            return -EOPNOTSUPP;
+
         rc = xsm_add_to_physmap(XSM_TARGET, current->domain, d);
         if ( rc )
         {
@@ -1024,6 +1031,13 @@ 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) &&
+             (!is_hardware_domain(current->domain) || (d != current->domain)) )
+            return -EOPNOTSUPP;
+
         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 945b613..e92a96e 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -154,6 +154,11 @@ int unmap_regions(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.0.4



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

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

* [PATCH v4 24/24] xen/arm64: Add ACPI support
  2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
                   ` (22 preceding siblings ...)
  2016-02-28 11:19 ` [PATCH v4 23/24] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
@ 2016-02-28 11:19 ` Shannon Zhao
  2016-02-29 11:34   ` Jan Beulich
  2016-02-29 17:15   ` Stefano Stabellini
  23 siblings, 2 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-02-28 11:19 UTC (permalink / raw)
  To: xen-devel
  Cc: peter.huangpeng, zhaoshenglong, stefano.stabellini, ian.campbell,
	shannon.zhao

From: Naresh Bhat <naresh.bhat@linaro.org>

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

Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
V4: add comments to explain why efi_enabled = 1 needs
---
 xen/arch/arm/Kconfig         | 1 +
 xen/common/efi/runtime.c     | 8 ++++++--
 xen/include/asm-arm/config.h | 5 +++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 60e923c..e39b05b 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -14,6 +14,7 @@ config ARM_64
 	def_bool y
 	depends on 64BIT
 	select HAS_GICV3
+	select HAS_ACPI
 
 config ARM
 	def_bool y
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index ae87557..26a82a7 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -10,8 +10,12 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
 
 #ifndef COMPAT
 
-#ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
-const bool_t efi_enabled = 0;
+#ifdef CONFIG_ARM
+/* Currently it doesn't implement runtime services on ARM, but to boot Dom0 with
+ * ACPI it needs to assign efi_enabled with 1 to get acpi_os_get_root_pointer
+ * work.
+ */
+const bool_t efi_enabled = 1;
 #else
 # include <asm/i387.h>
 # include <asm/xstate.h>
diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
index a26cb1a..98710fe 100644
--- a/xen/include/asm-arm/config.h
+++ b/xen/include/asm-arm/config.h
@@ -36,6 +36,11 @@
 
 #define CONFIG_ARM_L1_CACHE_SHIFT 7 /* XXX */
 
+#if defined(CONFIG_ARM_64)
+#define CONFIG_ACPI 1
+#define CONFIG_ACPI_BOOT 1
+#endif
+
 #define CONFIG_SMP 1
 
 #define CONFIG_VIDEO 1
-- 
2.0.4



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

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

* Re: [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables
  2016-02-28 11:19 ` [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
@ 2016-02-29 11:11   ` Jan Beulich
  2016-02-29 12:13   ` Stefano Stabellini
  1 sibling, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 11:11 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: shannon.zhao, xen-devel, stefano.stabellini, ian.campbell,
	peter.huangpeng

>>> On 28.02.16 at 12:19, <zhaoshenglong@huawei.com> wrote:
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -13,6 +13,7 @@
>  #include <xen/multiboot.h>
>  #include <xen/pci_regs.h>
>  #include <xen/pfn.h>
> +#include <asm/acpi.h>
>  #if EFI_PAGE_SIZE != PAGE_SIZE
>  # error Cannot use xen/pfn.h here!
>  #endif
> @@ -1171,6 +1172,25 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>      for( ; ; ); /* not reached */
>  }
>  
> +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)

Are both parts really necessary? It would seem to me that the
latter should suffice.

> +/* Constant to indicate "Xen" in unicode u16 format */
> +static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};

This should be a wide string literal, with the variable type being
CHAR16. Also variable names shouldn't be all upper case.

> +int __init estimate_efi_size(int mem_nr_banks)
> +{
> +    int size = 0;
> +    int est_size = sizeof(EFI_SYSTEM_TABLE);
> +    int ect_size = sizeof(EFI_CONFIGURATION_TABLE);
> +    int emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
> +    int fw_vendor_size = sizeof(XEN_EFI_FW_VENDOR);
> +
> +    size += ROUNDUP((est_size + ect_size + fw_vendor_size), 8);
> +    size += ROUNDUP(emd_size * (mem_nr_banks + acpi_mem.nr_banks + 1), 8);
> +
> +    return size;
> +}

It would seem to me that none of the variables involved really
holds a signed quantity. This should be reflected by the types
chosen - likely you need s/int/size_t/ for the entire function,
except for the function parameter, which looks like it wants to
be unsigned int.

Also the initializer of "size" could be easily got rid of, and there's
a pair of pointless parentheses in the first ROUNDUP().

As to the configuration table - the sizeof() covers a single table
entry only afaict - is that really intended?

Jan


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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-02-28 11:19 ` [PATCH v4 14/24] arm/acpi: Prepare EFI system table " Shannon Zhao
@ 2016-02-29 11:19   ` Jan Beulich
  2016-02-29 14:25     ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 11:19 UTC (permalink / raw)
  To: Shannon Zhao; +Cc: xen-devel, stefano.stabellini, peter.huangpeng, shannon.zhao

>>> On 28.02.16 at 12:19, <zhaoshenglong@huawei.com> wrote:
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1173,6 +1173,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>  }
>  
>  #if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> +#include "../../../common/decompress.h"
> +#define XZ_EXTERN STATIC
> +#include "../../../common/xz/crc32.c"
> +
>  /* Constant to indicate "Xen" in unicode u16 format */
>  static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};
>  
> @@ -1189,6 +1193,46 @@ int __init estimate_efi_size(int mem_nr_banks)
>  
>      return size;
>  }
> +
> +void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
> +                                         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 = paddr + 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 = 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((u16 *)(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;
> +}
>  #endif
>  
>  #ifndef CONFIG_ARM /* TODO - runtime service support */

While the previous addition here was probably fine on its own, here
it becomes clear that these additions all belong into arch/arm/efi/.

Also it doesn't look very nice to me to (ab)use xz's CRC32 code
here; I don't know who has suggested doing so.

Jan


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

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

* Re: [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-02-28 11:19 ` [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
@ 2016-02-29 11:23   ` Jan Beulich
  2016-02-29 17:04   ` Stefano Stabellini
  1 sibling, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 11:23 UTC (permalink / raw)
  To: Shannon Zhao; +Cc: xen-devel, stefano.stabellini, peter.huangpeng, shannon.zhao

>>> On 28.02.16 at 12:19, <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new dilivery type:
> val[63:56] == 3: val[15:8] is flag: val[7:0] is a PPI.
> To the flag, bit 0 stands the interrupt mode is edge(1) or level(0) and
> bit 1 stands the interrupt polarity is active low(1) or high(0).
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> v4: rebase on master
> ---
>  xen/include/public/hvm/params.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
> index 81f9451..382a79d 100644
> --- a/xen/include/public/hvm/params.h
> +++ b/xen/include/public/hvm/params.h
> @@ -55,6 +55,15 @@
>   * if this delivery method is available.
>   */
>  
> +#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
> +/*
> + * val[15:8] is flag of event-channel interrupt:
> + *  bit 0: interrupt is edge(1) or level(0) triggered
> + *  bit 1: interrupt is active low(1) or high(0)

Wouldn't it be better to name these bit 8 and bit 9 respectively,
to avoid confusion with the full value's bits 0 and 1?

Also please state explicitly that bits 16..63 need to be zero (and
make sure you check this in the code consuming the input).

Jan

> + * val[7:0] is PPI number used by event-channel.
> + * This is only used by ARM/ARM64.
> + */
> +
>  /*
>   * These are not used by Xen. They are here for convenience of HVM-guest
>   * xenbus implementations.
> -- 
> 2.0.4




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

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

* Re: [PATCH v4 23/24] xen/arm: Add a hypercall for device mmio mapping
  2016-02-28 11:19 ` [PATCH v4 23/24] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
@ 2016-02-29 11:32   ` Jan Beulich
  0 siblings, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 11:32 UTC (permalink / raw)
  To: zhaoshenglong
  Cc: xen-devel, stefano.stabellini, peter.huangpeng, shannon.zhao

>>> On 28.02.16 at 12:19, <zhaoshenglong@huawei.com> 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.

Leaving aside the fact that XEN_DOMCTL_memory_mapping is not
meant to be called by other than the tools - is there anything here
which that hypercall wouldn't provide? If not, I think the commit
message should reference that hypercall too while rationalizing
the need for this new map space.

> ---
>  xen/arch/arm/mm.c           |  4 ++++
>  xen/arch/arm/p2m.c          | 23 +++++++++++++++++++++++
>  xen/common/memory.c         | 14 ++++++++++++++
>  xen/include/asm-arm/p2m.h   |  5 +++++
>  xen/include/public/memory.h |  1 +
>  5 files changed, 47 insertions(+)

This touches code with no maintainers Cc-ed.

> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -1138,6 +1138,10 @@ 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;
> +        break;

Dead code.

> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -980,6 +980,13 @@ 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.
> +         */

Coding style.

> +        if ( (xatp.space == XENMAPSPACE_dev_mmio) &&
> +             (!is_hardware_domain(current->domain) || (d != current->domain)) )
> +            return -EOPNOTSUPP;

More like -EPERM or -EACCES.

Jan


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

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

* Re: [PATCH v4 24/24] xen/arm64: Add ACPI support
  2016-02-28 11:19 ` [PATCH v4 24/24] xen/arm64: Add ACPI support Shannon Zhao
@ 2016-02-29 11:34   ` Jan Beulich
  2016-02-29 17:15   ` Stefano Stabellini
  1 sibling, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 11:34 UTC (permalink / raw)
  To: zhaoshenglong
  Cc: xen-devel, stefano.stabellini, peter.huangpeng, shannon.zhao

>>> On 28.02.16 at 12:19, <zhaoshenglong@huawei.com> wrote:
> ---
>  xen/arch/arm/Kconfig         | 1 +
>  xen/common/efi/runtime.c     | 8 ++++++--
>  xen/include/asm-arm/config.h | 5 +++++
>  3 files changed, 12 insertions(+), 2 deletions(-)

Again - please Cc maintainers of all code modified.

> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -10,8 +10,12 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  
>  #ifndef COMPAT
>  
> -#ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
> -const bool_t efi_enabled = 0;
> +#ifdef CONFIG_ARM
> +/* Currently it doesn't implement runtime services on ARM, but to boot Dom0 with
> + * ACPI it needs to assign efi_enabled with 1 to get acpi_os_get_root_pointer
> + * work.
> + */
> +const bool_t efi_enabled = 1;

This is now the same as x86's - the two should thus be folded.

Jan


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

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

* Re: [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables
  2016-02-28 11:19 ` [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
  2016-02-29 11:11   ` Jan Beulich
@ 2016-02-29 12:13   ` Stefano Stabellini
  2016-03-01  2:09     ` Shannon Zhao
  1 sibling, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 12:13 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Jan Beulich

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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.
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> v4: make the length of each table aligned with 64bit
> ---
>  xen/arch/arm/domain.c       |  4 +++
>  xen/arch/arm/domain_build.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-
>  xen/common/efi/boot.c       | 20 +++++++++++
>  xen/include/asm-arm/setup.h |  2 ++
>  4 files changed, 106 insertions(+), 1 deletion(-)
> 
> 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..b10a69d 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,79 @@ 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)
> +{
> +    u64 efi_size, acpi_size = 0, addr;
> +    u32 madt_size;
> +    struct acpi_table_rsdp *rsdp_tbl;
> +    struct acpi_table_header *table = NULL;
> +
> +    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));
> +    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
> +                               sizeof(struct acpi_table_header));
> +    /* 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 = 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. */
> +    d->arch.efi_acpi_gpa = kinfo->gnttab_start;
> +
> +    return 0;
> +}
> +#else
> +static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
> +{
> +    /* Only booting with ACPI will hit here */
> +    BUG_ON(1);
> +    return -EINVAL;
> +}
> +#endif
>  static void dtb_load(struct kernel_info *kinfo)
>  {
>      void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr;
> @@ -1540,7 +1615,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/common/efi/boot.c b/xen/common/efi/boot.c
> index 53c7452..535c685 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -13,6 +13,7 @@
>  #include <xen/multiboot.h>
>  #include <xen/pci_regs.h>
>  #include <xen/pfn.h>
> +#include <asm/acpi.h>
>  #if EFI_PAGE_SIZE != PAGE_SIZE
>  # error Cannot use xen/pfn.h here!
>  #endif
> @@ -1171,6 +1172,25 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>      for( ; ; ); /* not reached */
>  }
>  
> +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> +/* Constant to indicate "Xen" in unicode u16 format */
> +static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};
> +
> +int __init estimate_efi_size(int mem_nr_banks)
> +{
> +    int size = 0;
> +    int est_size = sizeof(EFI_SYSTEM_TABLE);
> +    int ect_size = sizeof(EFI_CONFIGURATION_TABLE);
> +    int emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
> +    int fw_vendor_size = sizeof(XEN_EFI_FW_VENDOR);
> +
> +    size += ROUNDUP((est_size + ect_size + fw_vendor_size), 8);
> +    size += ROUNDUP(emd_size * (mem_nr_banks + acpi_mem.nr_banks + 1), 8);
> +
> +    return size;
> +}
> +#endif

Given that EFI and ACPI are separate things, I don't think we should
ifdef CONFIG_ACPI this function. estimate_efi_size should work even if
no ACPI tables are present, right?

Like Jan suggested, we need to be consistent with the integer types in
this function and the callers.

Given that mem_nr_banks, like acpi_mem.nr_banks, is also available
through the bootinfo global variable, I don't think it makes too much
sense to get the number of memory banks from a parameter and the number
of acpi banks from the global variable. We should be consistent.


>  #ifndef CONFIG_ARM /* TODO - runtime service support */
>  
>  static bool_t __initdata efi_rs_enable = 1;
> diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
> index 30ac53b..b759813 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);
>  
> +int estimate_efi_size(int mem_nr_banks);
> +
>  int construct_dom0(struct domain *d);
>  
>  void discard_initial_modules(void);

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

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

* Re: [PATCH v4 05/24] arm/acpi: Add a helper function to get the acpi table offset
  2016-02-28 11:19 ` [PATCH v4 05/24] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
@ 2016-02-29 12:17   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 12:17 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> These tables are aligned with 64bit.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> v4: aligned with 64bit
> ---
>  xen/arch/arm/acpi/lib.c    | 14 ++++++++++++++
>  xen/include/asm-arm/acpi.h |  2 ++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index 5698245..d5ac590 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -62,3 +62,17 @@ bool_t __init acpi_psci_hvc_present(void)
>  {
>      return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
>  }
> +
> +unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index)
> +{
> +    int i;
> +    unsigned int offset = 0;
> +
> +    for ( i = 0; i < index; i++ )
> +    {
> +        /* Aligned with 64bit (8 bytes) */
> +        offset += ROUNDUP(tbl_add[i].size, 8);
> +    }
> +
> +    return offset;

offset and the return type of this function need to be of the same type
of tbl_add[i].size, which is paddr_t (u64).


> +}
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 7f59761..b507dca 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);
> +unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
>  
>  #ifdef CONFIG_ACPI
>  extern bool_t acpi_disabled;
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 06/24] arm/acpi: Prepare FADT table for Dom0
  2016-02-28 11:19 ` [PATCH v4 06/24] arm/acpi: Prepare FADT table for Dom0 Shannon Zhao
@ 2016-02-29 12:22   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 12:22 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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>


>  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 b10a69d..f041a8a 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)
>  {
>      u64 efi_size, acpi_size = 0, addr;
> @@ -1401,6 +1439,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 )
> @@ -1419,6 +1458,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>       * region. So we use it as the ACPI table mapped address. */
>      d->arch.efi_acpi_gpa = kinfo->gnttab_start;
>  
> +    rc = acpi_create_fadt(d, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 07/24] arm/gic: Add a new callback for creating MADT table for Dom0
  2016-02-28 11:19 ` [PATCH v4 07/24] arm/gic: Add a new callback for creating MADT " Shannon Zhao
@ 2016-02-29 12:50   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 12:50 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new member in gic_hw_operations which is used to creat MADT table
> for Dom0.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/arch/arm/gic-v2.c     | 34 ++++++++++++++++++++++++++++++++++
>  xen/arch/arm/gic-v3.c     | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  xen/arch/arm/gic.c        |  5 +++++
>  xen/include/asm-arm/gic.h |  3 +++
>  4 files changed, 89 insertions(+)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 0fcb894..02db5f2 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -685,6 +685,35 @@ static void __init gicv2_dt_init(void)
>  }
>  
>  #ifdef CONFIG_ACPI
> +static u32 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 )
> +        panic("Can't get GICC entry");
> +    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);
> +        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 +805,10 @@ static void __init gicv2_acpi_init(void)
>  }
>  #else
>  static void __init gicv2_acpi_init(void) { }
> +static u32 gicv2_make_hwdom_madt(const struct domain *d, u32 offset)
> +{
> +    return 0;
> +}
>  #endif
>  
>  static int __init gicv2_init(void)
> @@ -868,6 +901,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..d9fce4b 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -1236,6 +1236,48 @@ static void __init gicv3_dt_init(void)
>  }
>  
>  #ifdef CONFIG_ACPI
> +static u32 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 )
> +        panic("Can't get GICC entry");
> +    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);
> +        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 +1422,10 @@ static void __init gicv3_acpi_init(void)
>  }
>  #else
>  static void __init gicv3_acpi_init(void) { }
> +static u32 gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
> +{
> +    return 0;
> +}
>  #endif
>  
>  /* Set up the GIC */
> @@ -1474,6 +1520,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..6d32432 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);
>  }
>  
> +u32 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..4cf003d 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 */
> +    u32 (*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);
> +u32 gic_make_hwdom_madt(const struct domain *d, u32 offset);
>  
>  #endif /* __ASSEMBLY__ */
>  #endif
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 08/24] arm/acpi: Prepare MADT table for Dom0
  2016-02-28 11:19 ` [PATCH v4 08/24] arm/acpi: Prepare " Shannon Zhao
@ 2016-02-29 12:52   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 12:52 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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>
> ---
> v4: use make_hwdom_madt callback to create MADT
> ---
>  xen/arch/arm/domain_build.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index f041a8a..e373165 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1357,6 +1357,52 @@ 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);
> +    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 )
> +        panic("Can't get GICC entry");
                            ^GICD

Aside from this:

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


> +    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*/
> +    table_size += gic_make_hwdom_madt(d, offset + table_size);
> +
> +    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[])
>  {
> @@ -1462,6 +1508,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.0.4
> 
> 

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

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

* Re: [PATCH v4 02/24] arm/acpi: Add placeholder for efi and acpi load address
  2016-02-28 11:18 ` [PATCH v4 02/24] arm/acpi: Add placeholder for efi and acpi load address Shannon Zhao
@ 2016-02-29 14:01   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:01 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> We will create EFI table, memory description table and some of acpi
> tables and we're going to map them to kinfo->gnttab_start of Dom0.
> Add placeholder for the starting address for loading in DOM0 and the
> size of new added tables. Also add a placeholder to store the new
> created tables.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> V4: explain why these need in commit message
> ---
>  xen/include/asm-arm/domain.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
> index aa7f283..8e1161f 100644
> --- a/xen/include/asm-arm/domain.h
> +++ b/xen/include/asm-arm/domain.h
> @@ -124,6 +124,11 @@ struct arch_domain
>      } vuart;
>  
>      unsigned int evtchn_irq;
> +#ifdef CONFIG_ACPI
> +    void *efi_acpi_table;
> +    paddr_t efi_acpi_gpa;
> +    paddr_t efi_acpi_len;
> +#endif
>  }  __cacheline_aligned;
>  
>  struct arch_vcpu
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables
  2016-02-28 11:18 ` [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables Shannon Zhao
@ 2016-02-29 14:02   ` Stefano Stabellini
  2016-02-29 15:16   ` Jan Beulich
  1 sibling, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:02 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> It needs to copy and change the contents of some ACPI and EFI tables for
> Dom0. Here define a enum for those tables.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/asm-arm/acpi.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index a0f2f24..7f59761 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -30,6 +30,18 @@
>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
>  #define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
>  
> +/* Tables marked as reserved in efi table */
> +typedef enum {
> +    TBL_FADT,
> +    TBL_MADT,
> +    TBL_STAO,
> +    TBL_XSDT,
> +    TBL_RSDP,
> +    TBL_EFIT,
> +    TBL_MMAP,
> +    TBL_MMAX,
> +} EFI_MEM_RES;
> +
>  bool_t __init acpi_psci_present(void);
>  bool_t __init acpi_psci_hvc_present(void);
>  void __init acpi_smp_init_cpus(void);
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 09/24] arm/acpi: Prepare STAO table for Dom0
  2016-02-28 11:19 ` [PATCH v4 09/24] arm/acpi: Prepare STAO " Shannon Zhao
@ 2016-02-29 14:07   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:07 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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>
>
>  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 e373165..53cddb7 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 of some table, here use MADT */

"Copy OEM and ASL compiler fields from another table, use MADT" would be
better.

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


> +    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, 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;
> @@ -1512,6 +1549,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.0.4
> 
> 

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

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

* Re: [PATCH v4 12/24] arm/p2m: Add helper functions to map memory regions
  2016-02-28 11:19 ` [PATCH v4 12/24] arm/p2m: Add helper functions to map memory regions Shannon Zhao
@ 2016-02-29 14:11   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:11 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Create a helper function for mapping with cached attributes and
> read-only range.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

This is good, but for clarity please rename the two functions to
map_regions_ro and unmap_regions_ro.


> v4: use p2m_access_r
> ---
>  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..c36fdf6 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(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_r);
> +}
> +
> +int unmap_regions(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_r);
> +}
> +
>  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..945b613 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(struct domain *d,
> +                    unsigned long start_gfn,
> +                    unsigned long nr_mfns,
> +                    unsigned long mfn);
> +
> +int unmap_regions(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,

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

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

* Re: [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-02-28 11:19 ` [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0 Shannon Zhao
@ 2016-02-29 14:15   ` Stefano Stabellini
  2016-02-29 19:06     ` Shannon Zhao
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:15 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Map all other tables to Dom0 using 1:1 mappings.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> v4: fix commit message
> ---
>  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 64e48ae..6ad420c 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 other 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(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 0x%"PRIx64
> +                   " - 0x%"PRIx64" in domain \n",
> +                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
> +        }
> +    }
> +}

The problem with this function is that it is mapping all other tables to
the guest, including the unmodified FADT and MADT. This way dom0 is
going to find two different versions of the FADT and MADT, isn't that
right?


>  static int acpi_create_rsdp(struct domain *d, struct membank tbl_add[])
>  {
>  
> @@ -1661,6 +1685,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.0.4
> 
> 

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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-02-29 11:19   ` Jan Beulich
@ 2016-02-29 14:25     ` Stefano Stabellini
  2016-02-29 14:36       ` Jan Beulich
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:25 UTC (permalink / raw)
  To: Jan Beulich
  Cc: shannon.zhao, xen-devel, stefano.stabellini, peter.huangpeng,
	Shannon Zhao

On Mon, 29 Feb 2016, Jan Beulich wrote:
> >>> On 28.02.16 at 12:19, <zhaoshenglong@huawei.com> wrote:
> > --- a/xen/common/efi/boot.c
> > +++ b/xen/common/efi/boot.c
> > @@ -1173,6 +1173,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
> >  }
> >  
> >  #if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> > +#include "../../../common/decompress.h"
> > +#define XZ_EXTERN STATIC
> > +#include "../../../common/xz/crc32.c"
> > +
> >  /* Constant to indicate "Xen" in unicode u16 format */
> >  static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};
> >  
> > @@ -1189,6 +1193,46 @@ int __init estimate_efi_size(int mem_nr_banks)
> >  
> >      return size;
> >  }
> > +
> > +void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
> > +                                         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 = paddr + 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 = 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((u16 *)(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;
> > +}
> >  #endif
> >  
> >  #ifndef CONFIG_ARM /* TODO - runtime service support */
> 
> While the previous addition here was probably fine on its own, here
> it becomes clear that these additions all belong into arch/arm/efi/.

Right, or maybe into xen/arch/arm/domain_build.c


> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
> here; I don't know who has suggested doing so.
 
It was suggested by Julien.

I agree that including ../../../common/xz/crc32.c seems a bit fragile
but introducing another copy of xz_crc32 seems even worse to me (see
http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
better suggestion?

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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-02-29 14:25     ` Stefano Stabellini
@ 2016-02-29 14:36       ` Jan Beulich
  2016-02-29 14:39         ` Stefano Stabellini
  2016-03-01  2:35         ` Shannon Zhao
  0 siblings, 2 replies; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 14:36 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: shannon.zhao, xen-devel, stefano.stabellini, peter.huangpeng,
	Shannon Zhao

>>> On 29.02.16 at 15:25, <stefano.stabellini@eu.citrix.com> wrote:
> On Mon, 29 Feb 2016, Jan Beulich wrote:
>> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
>> here; I don't know who has suggested doing so.
>  
> It was suggested by Julien.
> 
> I agree that including ../../../common/xz/crc32.c seems a bit fragile
> but introducing another copy of xz_crc32 seems even worse to me (see
> http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
> better suggestion?

Well, at some point there was talk of ARM not wanting to
ExitBootServices() as early as x86 does. In that case there
would be a CRC32 function among the various boot services
ones.

The other option would be to have a generic crc32() function,
and maybe make xz use it.

Jan


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

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

* Re: [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor for Dom0
  2016-02-28 11:19 ` [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
@ 2016-02-29 14:37   ` Stefano Stabellini
  2016-03-01  3:00     ` Shannon Zhao
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:37 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Jan Beulich

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Create a few EFI memory descriptors to tell Dom0 the RAM region
> information, ACPI table regions and EFI tables reserved resions.
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> v4: use a single descriptor for new created tables
> ---
>  xen/arch/arm/domain_build.c |  2 ++
>  xen/common/efi/boot.c       | 38 ++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/setup.h |  5 +++++
>  3 files changed, 45 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 09f9770..1ec6271 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1688,6 +1688,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      acpi_map_other_tables(d);
>      acpi_create_efi_system_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_table,
>                                   tbl_add);
> +    acpi_create_efi_mmap_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_len,
> +                               d->arch.efi_acpi_table, &kinfo->mem, tbl_add);
>  
>      return 0;
>  }
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 238c5fd..b8d7409 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1233,6 +1233,44 @@ void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
>      tbl_add[TBL_EFIT].start = table_addr;
>      tbl_add[TBL_EFIT].size = table_size;
>  }
> +
> +void __init acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
> +                                       void *efi_acpi_table,
> +                                       const struct meminfo *mem,
> +                                       struct membank tbl_add[])

This function probably belongs to xen/arch/arm/domain_build.c or
arch/arm/efi


> +{
> +    EFI_MEMORY_DESCRIPTOR *memory_map;
> +    int i, offset;
> +    u8 *base_ptr;
> +
> +    tbl_add[TBL_MMAP].start = paddr + 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);

I don't like the fact that we are getting the number of memory banks
from a parameter and the number of acpi banks from a global variable.
Can we pass in acpi_mem.nr_banks too?


> +    base_ptr = 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;
> +        memory_map[offset].NumberOfPages = PFN_UP(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;
> +        memory_map[offset].NumberOfPages = PFN_UP(acpi_mem.bank[i].size);
> +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> +    }
> +
> +    memory_map[offset].Type = EfiACPIReclaimMemory;
> +    memory_map[offset].PhysicalStart = paddr;
> +    memory_map[offset].NumberOfPages = PFN_UP(size);
> +    memory_map[offset].Attribute = EFI_MEMORY_WB;
> +}
>  #endif
>  
>  #ifndef CONFIG_ARM /* TODO - runtime service support */
> diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
> index 2d65796..af5a038 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -56,6 +56,11 @@ int estimate_efi_size(int mem_nr_banks);
>  void acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
>                                    struct membank tbl_add[]);
>  
> +void acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
> +                                void *efi_acpi_table,
> +                                const struct meminfo *mem,
> +                                struct membank tbl_add[]);
> +
>  int construct_dom0(struct domain *d);
>  
>  void discard_initial_modules(void);

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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-02-29 14:36       ` Jan Beulich
@ 2016-02-29 14:39         ` Stefano Stabellini
  2016-03-01  2:35         ` Shannon Zhao
  1 sibling, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:39 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao, Shannon Zhao

On Mon, 29 Feb 2016, Jan Beulich wrote:
> >>> On 29.02.16 at 15:25, <stefano.stabellini@eu.citrix.com> wrote:
> > On Mon, 29 Feb 2016, Jan Beulich wrote:
> >> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
> >> here; I don't know who has suggested doing so.
> >  
> > It was suggested by Julien.
> > 
> > I agree that including ../../../common/xz/crc32.c seems a bit fragile
> > but introducing another copy of xz_crc32 seems even worse to me (see
> > http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
> > better suggestion?
> 
> Well, at some point there was talk of ARM not wanting to
> ExitBootServices() as early as x86 does. In that case there
> would be a CRC32 function among the various boot services
> ones.
> 
> The other option would be to have a generic crc32() function,
> and maybe make xz use it.

Either way seems good to me.

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

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

* Re: [PATCH v4 16/24] arm/acpi: Map the new created EFI and ACPI tables to Dom0
  2016-02-28 11:19 ` [PATCH v4 16/24] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
@ 2016-02-29 14:42   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 14:42 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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>


>  xen/arch/arm/domain_build.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 1ec6271..083ddd5 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1691,6 +1691,21 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      acpi_create_efi_mmap_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_len,
>                                 d->arch.efi_acpi_table, &kinfo->mem, tbl_add);
>  
> +    /* Map the EFI and ACPI tables to Dom0 */
> +    rc = map_regions(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 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;
> +    }
> +
>      return 0;
>  }
>  #else
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi
  2016-02-28 11:18 ` [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi Shannon Zhao
@ 2016-02-29 14:57   ` Jan Beulich
  2016-02-29 15:07     ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 14:57 UTC (permalink / raw)
  To: zhaoshenglong
  Cc: shannon.zhao, xen-devel, stefano.stabellini, ian.campbell,
	peter.huangpeng

>>> On 28.02.16 at 12:18, <zhaoshenglong@huawei.com> wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> ACPI memory is seperate from conventional memory and should be marked
> as reserved while passing to DOM0. Create a new meminfo structure to
> store all the acpi tables listed in uefi.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

With this I'll commit as is, but I'd like to note that ...

> @@ -129,6 +132,9 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
>  {
>      int Index;
>      int i = 0;
> +#ifdef CONFIG_ACPI
> +    int j = 0;
> +#endif
>      EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
>  
>      for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
> @@ -148,10 +154,27 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
>              bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
>              ++i;
>          }
> +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> +        else if ( desc_ptr->Type == EfiACPIReclaimMemory )
> +        {
> +            if ( j >= NR_MEM_BANKS )
> +            {
> +                PrintStr(L"Error: All " __stringify(NR_MEM_BANKS)
> +                          " acpi meminfo mem banks exhausted.\r\n");
> +                return EFI_LOAD_ERROR;
> +            }
> +            acpi_mem.bank[j].start = desc_ptr->PhysicalStart;
> +            acpi_mem.bank[j].size  = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
> +            ++j;
> +        }
> +#endif
>          desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
>      }
>  
>      bootinfo.mem.nr_banks = i;
> +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> +    acpi_mem.nr_banks = j;
> +#endif
>      return EFI_SUCCESS;
>  }

... the three #ifdef-s here aren't consistent.

Jan


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

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

* Re: [PATCH v4 17/24] arm/acpi: Create min DT stub for Dom0
  2016-02-28 11:19 ` [PATCH v4 17/24] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
@ 2016-02-29 15:05   ` Stefano Stabellini
  2016-03-03 12:31     ` Shannon Zhao
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 15:05 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Jan Beulich

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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 port the document of this device tree bindings from Linux.
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> 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>
> ---
> v4: port the document of this device tree bindings from Linux
> ---
>  docs/misc/arm/device-tree/xen.txt |  58 ++++++++++++++++
>  xen/arch/arm/domain_build.c       | 143 ++++++++++++++++++++++++++++++++++++++
>  xen/common/efi/boot.c             |  47 +++++++++++++
>  xen/include/asm-arm/setup.h       |   2 +
>  4 files changed, 250 insertions(+)
>  create mode 100644 docs/misc/arm/device-tree/xen.txt
> 
> diff --git a/docs/misc/arm/device-tree/xen.txt b/docs/misc/arm/device-tree/xen.txt
> new file mode 100644
> index 0000000..6f83f76
> --- /dev/null
> +++ b/docs/misc/arm/device-tree/xen.txt

Calling this file xen.txt inside the Xen repository is not very
meaningful, maybe we should rename it to uefi.txt

Otherwise you can add this info to the existing booting.txt


> @@ -0,0 +1,58 @@
> +* 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()).
> +
> +- interrupts: the interrupt used by Xen to inject event notifications.
> +  A GIC node is also required.
> +
> +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, which are provided by the regular UEFI stub. However
                             ^ in Linux                         ^ Linux


> +they differ because they are provided by the Xen hypervisor, together with a set
> +of UEFI runtime services implemented via hypercalls, see
> +http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html.

I think that here is fine to use a simple path within the Xen repo:

xen/include/public/platform.h


> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 083ddd5..4b1f387 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1357,6 +1357,145 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  }
>  
>  #ifdef CONFIG_ACPI
> +#define ACPI_DOM0_FDT_MIN_SIZE 4096
> +
> +static int make_chosen_node(const struct kernel_info *kinfo,
> +                            struct membank tbl_add[])
> +{
> +    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 = arm_acpi_make_efi_nodes(fdt, tbl_add);
> +    if ( res )
> +        return res;
> +
> +    res = fdt_end_node(fdt);
> +
> +    return res;
> +}

Please refactor the existing make_hypervisor_node into a shared function
and use that instead.


> +/*
> + * 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 = make_chosen_node(kinfo, tbl_add);
> +    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;
> @@ -1706,6 +1845,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>          return rc;
>      }
>  
> +    rc = create_acpi_dtb(kinfo, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index b8d7409..c0b08ef 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1271,6 +1271,53 @@ void __init acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
>      memory_map[offset].NumberOfPages = PFN_UP(size);
>      memory_map[offset].Attribute = EFI_MEMORY_WB;
>  }
> +
> +/* Create place holder for efi values. */
> +int __init arm_acpi_make_efi_nodes(void *fdt, struct membank tbl_add[])
> +{
> +    u64 fdt_val64;
> +    u32 fdt_val32;
> +    int desc_ver = mdesc_ver;
> +    int res;
> +
> +    res = fdt_begin_node(fdt, "uefi");
> +    if ( res )
> +        return res;
> +
> +    fdt_val64 = cpu_to_fdt64(tbl_add[TBL_EFIT].start);
> +    res = fdt_property(fdt, "xen,uefi-system-table",
> +                       &fdt_val64, sizeof(fdt_val64));
> +    if ( res )
> +        return res;
> +
> +    fdt_val64 = cpu_to_fdt64(tbl_add[TBL_MMAP].start);
> +    res = fdt_property(fdt, "xen,uefi-mmap-start",
> +                       &fdt_val64,  sizeof(fdt_val64));
> +    if ( res )
> +        return res;
> +
> +    fdt_val32 = cpu_to_fdt32(tbl_add[TBL_MMAP].size);
> +    res = fdt_property(fdt, "xen,uefi-mmap-size",
> +                       &fdt_val32,  sizeof(fdt_val32));
> +    if ( res )
> +        return res;
> +
> +    fdt_val32 = cpu_to_fdt32(sizeof(EFI_MEMORY_DESCRIPTOR));
> +    res = fdt_property(fdt, "xen,uefi-mmap-desc-size",
> +                         &fdt_val32, sizeof(fdt_val32));
> +    if ( res )
> +        return res;
> +
> +    fdt_val32 = cpu_to_fdt32(desc_ver);
> +    res = fdt_property(fdt, "xen,uefi-mmap-desc-ver",
> +                         &fdt_val32, sizeof(fdt_val32));
> +    if ( res )
> +        return res;
> +
> +    res = fdt_end_node(fdt);
> +
> +    return res;
> +}

This function should not be under /common. It should be in domain_build.c
or arch/arm/efi.


>  #endif
>  
>  #ifndef CONFIG_ARM /* TODO - runtime service support */
> diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
> index af5a038..fdec501 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -61,6 +61,8 @@ void acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
>                                  const struct meminfo *mem,
>                                  struct membank tbl_add[]);
>  
> +int arm_acpi_make_efi_nodes(void *fdt, struct membank tbl_add[]);
> +
>  int construct_dom0(struct domain *d);
>  
>  void discard_initial_modules(void);
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi
  2016-02-29 14:57   ` Jan Beulich
@ 2016-02-29 15:07     ` Stefano Stabellini
  2016-02-29 15:20       ` Jan Beulich
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 15:07 UTC (permalink / raw)
  To: Jan Beulich
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, zhaoshenglong

On Mon, 29 Feb 2016, Jan Beulich wrote:
> >>> On 28.02.16 at 12:18, <zhaoshenglong@huawei.com> wrote:
> > From: Parth Dixit <parth.dixit@linaro.org>
> > 
> > ACPI memory is seperate from conventional memory and should be marked
> > as reserved while passing to DOM0. Create a new meminfo structure to
> > store all the acpi tables listed in uefi.
> > 
> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> 
> With this I'll commit as is, but I'd like to note that ...
> 
> > @@ -129,6 +132,9 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
> >  {
> >      int Index;
> >      int i = 0;
> > +#ifdef CONFIG_ACPI
> > +    int j = 0;
> > +#endif
> >      EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
> >  
> >      for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
> > @@ -148,10 +154,27 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
> >              bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
> >              ++i;
> >          }
> > +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> > +        else if ( desc_ptr->Type == EfiACPIReclaimMemory )
> > +        {
> > +            if ( j >= NR_MEM_BANKS )
> > +            {
> > +                PrintStr(L"Error: All " __stringify(NR_MEM_BANKS)
> > +                          " acpi meminfo mem banks exhausted.\r\n");
> > +                return EFI_LOAD_ERROR;
> > +            }
> > +            acpi_mem.bank[j].start = desc_ptr->PhysicalStart;
> > +            acpi_mem.bank[j].size  = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
> > +            ++j;
> > +        }
> > +#endif
> >          desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
> >      }
> >  
> >      bootinfo.mem.nr_banks = i;
> > +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> > +    acpi_mem.nr_banks = j;
> > +#endif
> >      return EFI_SUCCESS;
> >  }
> 
> ... the three #ifdef-s here aren't consistent.
 
Well spotted, the CONFIG_ARM is redundant, could you please remove it
while committing?

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

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

* Re: [PATCH v4 18/24] arm/acpi: Permit access all Xen unused SPIs for Dom0
  2016-02-28 11:19 ` [PATCH v4 18/24] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
@ 2016-02-29 15:13   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 15:13 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, shannon.zhao, stefano.stabellini, peter.huangpeng,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Permit access all Xen unused SPIs for Dom0 except the interrupts that
> Xen uses. 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>


> v4: only permmit access all Xen unused SPIs for Dom0 and don't set type
> ---
>  xen/arch/arm/domain_build.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 4b1f387..4aaffae 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,33 @@ 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++ )
> +    {
> +        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 make_chosen_node(const struct kernel_info *kinfo,
>                              struct membank tbl_add[])
>  {
> @@ -1849,6 +1876,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.0.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] 73+ messages in thread

* Re: [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables
  2016-02-28 11:18 ` [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables Shannon Zhao
  2016-02-29 14:02   ` Stefano Stabellini
@ 2016-02-29 15:16   ` Jan Beulich
  1 sibling, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 15:16 UTC (permalink / raw)
  To: zhaoshenglong
  Cc: shannon.zhao, xen-devel, stefano.stabellini, ian.campbell,
	peter.huangpeng

>>> On 28.02.16 at 12:18, <zhaoshenglong@huawei.com> wrote:
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -30,6 +30,18 @@
>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
>  #define ACPI_MAP_MEM_ATTR          PAGE_HYPERVISOR
>  
> +/* Tables marked as reserved in efi table */
> +typedef enum {
> +    TBL_FADT,
> +    TBL_MADT,
> +    TBL_STAO,
> +    TBL_XSDT,
> +    TBL_RSDP,
> +    TBL_EFIT,
> +    TBL_MMAP,
> +    TBL_MMAX,
> +} EFI_MEM_RES;
> +
>  bool_t __init acpi_psci_present(void);
>  bool_t __init acpi_psci_hvc_present(void);
>  void __init acpi_smp_init_cpus(void);

This patch apparently expected the other series to be fully applied
first, which afaics hasn't been stated anywhere. I've fixed up the
context, but please avoid the committer needing to do such by
explicitly stating interdependencies between individually submitted
series, or by keeping the later series RFC (making clear it is not
expected to go in yet).

Jan


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

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

* Re: [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi
  2016-02-29 15:07     ` Stefano Stabellini
@ 2016-02-29 15:20       ` Jan Beulich
  0 siblings, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-02-29 15:20 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, zhaoshenglong

>>> On 29.02.16 at 16:07, <stefano.stabellini@eu.citrix.com> wrote:
> On Mon, 29 Feb 2016, Jan Beulich wrote:
>> >>> On 28.02.16 at 12:18, <zhaoshenglong@huawei.com> wrote:
>> > From: Parth Dixit <parth.dixit@linaro.org>
>> > 
>> > ACPI memory is seperate from conventional memory and should be marked
>> > as reserved while passing to DOM0. Create a new meminfo structure to
>> > store all the acpi tables listed in uefi.
>> > 
>> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>> 
>> With this I'll commit as is, but I'd like to note that ...
>> 
>> > @@ -129,6 +132,9 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
>> >  {
>> >      int Index;
>> >      int i = 0;
>> > +#ifdef CONFIG_ACPI
>> > +    int j = 0;
>> > +#endif
>> >      EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
>> >  
>> >      for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
>> > @@ -148,10 +154,27 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
>> >              bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
>> >              ++i;
>> >          }
>> > +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
>> > +        else if ( desc_ptr->Type == EfiACPIReclaimMemory )
>> > +        {
>> > +            if ( j >= NR_MEM_BANKS )
>> > +            {
>> > +                PrintStr(L"Error: All " __stringify(NR_MEM_BANKS)
>> > +                          " acpi meminfo mem banks exhausted.\r\n");
>> > +                return EFI_LOAD_ERROR;
>> > +            }
>> > +            acpi_mem.bank[j].start = desc_ptr->PhysicalStart;
>> > +            acpi_mem.bank[j].size  = desc_ptr->NumberOfPages * EFI_PAGE_SIZE;
>> > +            ++j;
>> > +        }
>> > +#endif
>> >          desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
>> >      }
>> >  
>> >      bootinfo.mem.nr_banks = i;
>> > +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
>> > +    acpi_mem.nr_banks = j;
>> > +#endif
>> >      return EFI_SUCCESS;
>> >  }
>> 
>> ... the three #ifdef-s here aren't consistent.
>  
> Well spotted, the CONFIG_ARM is redundant, could you please remove it
> while committing?

Too late, will require a fixup patch now.

Jan


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

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

* Re: [PATCH v4 19/24] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically
  2016-02-28 11:19 ` [PATCH v4 19/24] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
@ 2016-02-29 16:58   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 16:58 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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>
> ---
>  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..902a16d 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,8 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
>      }
>  }
>  
> +#define VGIC_ICFG_MASK(intr) ( 1 << ( ( 2 * ( intr % 16 ) ) + 1 ) )

I would prefer to see a small function that given an icfg register and
an interrupt number, returns the appropriate IRQ_TYPE for it.

The rest is fine.


>  void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>  {
>      const unsigned long mask = r;
> @@ -342,9 +346,37 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>      unsigned long flags;
>      int i = 0;
>      struct vcpu *v_target;
> +#ifdef CONFIG_HAS_ACPI
> +    struct domain *d = v->domain;
> +    struct vgic_irq_rank *vr = vgic_get_rank(v, n);
> +    uint32_t tr;
> +    int ret;
> +#endif
>  
>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
>          irq = i + (32 * n);
> +#ifdef CONFIG_HAS_ACPI
> +        /* 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 ) )
> +        {
> +            tr = vr->icfg[i >> 4];
> +
> +            if ( tr & VGIC_ICFG_MASK(i) )
> +                ret = irq_set_spi_type(irq, IRQ_TYPE_EDGE_BOTH);
> +            else
> +                ret = irq_set_spi_type(irq, IRQ_TYPE_LEVEL_MASK);
> +            if ( ret )
> +                printk(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 )
> +                printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
> +                       irq, d->domain_id);
> +        }
> +#endif
>          v_target = __vgic_get_target_vcpu(v, irq);
>          p = irq_to_pending(v_target, irq);
>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 20/24] arm/acpi: Permit MMIO access of Xen unused devices for Dom0
  2016-02-28 11:19 ` [PATCH v4 20/24] arm/acpi: Permit MMIO access of Xen unused devices for Dom0 Shannon Zhao
@ 2016-02-29 17:02   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 17:02 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, shannon.zhao, stefano.stabellini, peter.huangpeng,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
> access of Xen used devices, such as UART, SMMU. Currently, it only
> denies the MMIO access of UART and for other Xen used devices it could
> be added later when they are supported.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> v4: add comments for TODO
> ---
>  xen/arch/arm/domain_build.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 4aaffae..7750798 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,33 @@ 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;

coding style


> +    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 */
> +    return iomem_deny_access(d, gfn, gfn + 1);

It would be nice if at least the GIC regions were protected.


> +}
> +
>  static int acpi_permit_spi_access(struct domain *d)
>  {
>      int i, res;
> @@ -1880,6 +1907,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.0.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] 73+ messages in thread

* Re: [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-02-28 11:19 ` [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
  2016-02-29 11:23   ` Jan Beulich
@ 2016-02-29 17:04   ` Stefano Stabellini
  1 sibling, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 17:04 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Jan Beulich

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new dilivery type:
             ^ "delivery", also in the subject line


> val[63:56] == 3: val[15:8] is flag: val[7:0] is a PPI.
> To the flag, bit 0 stands the interrupt mode is edge(1) or level(0) and
> bit 1 stands the interrupt polarity is active low(1) or high(0).
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> v4: rebase on master
> ---
>  xen/include/public/hvm/params.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
> index 81f9451..382a79d 100644
> --- a/xen/include/public/hvm/params.h
> +++ b/xen/include/public/hvm/params.h
> @@ -55,6 +55,15 @@
>   * if this delivery method is available.
>   */
>  
> +#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
> +/*
> + * val[15:8] is flag of event-channel interrupt:
> + *  bit 0: interrupt is edge(1) or level(0) triggered
> + *  bit 1: interrupt is active low(1) or high(0)
> + * val[7:0] is PPI number used by event-channel.
> + * This is only used by ARM/ARM64.
> + */
> +
>  /*
>   * These are not used by Xen. They are here for convenience of HVM-guest
>   * xenbus implementations.
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 22/24] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2016-02-28 11:19 ` [PATCH v4 22/24] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
@ 2016-02-29 17:08   ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 17:08 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> 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>


> v4: always set HVM_PARAM_CALLBACK_IRQ parameter
> ---
>  xen/arch/arm/domain_build.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 7750798..80c4230 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -2003,6 +2003,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;
>  
>      /*
> @@ -2018,6 +2019,15 @@ 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_EVENT << 56;
> +    val |= (2 << 8); /* Active-low level-sensitive  */
> +    val |= d->arch.evtchn_irq & 0xff;
> +    d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val;
> +
> +    if ( !acpi_disabled )
> +        return;
> +
>      /* Fix up "interrupts" in /hypervisor node */
>      node = fdt_path_offset(kinfo->fdt, "/hypervisor");
>      if ( node < 0 )
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 24/24] xen/arm64: Add ACPI support
  2016-02-28 11:19 ` [PATCH v4 24/24] xen/arm64: Add ACPI support Shannon Zhao
  2016-02-29 11:34   ` Jan Beulich
@ 2016-02-29 17:15   ` Stefano Stabellini
  1 sibling, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-02-29 17:15 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel

On Sun, 28 Feb 2016, Shannon Zhao wrote:

> From: Naresh Bhat <naresh.bhat@linaro.org>
> 
> Add ACPI support on arm64 xen hypervisor. Enable EFI support on ARM.
> 
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> V4: add comments to explain why efi_enabled = 1 needs
> ---
>  xen/arch/arm/Kconfig         | 1 +
>  xen/common/efi/runtime.c     | 8 ++++++--
>  xen/include/asm-arm/config.h | 5 +++++
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
> index 60e923c..e39b05b 100644
> --- a/xen/arch/arm/Kconfig
> +++ b/xen/arch/arm/Kconfig
> @@ -14,6 +14,7 @@ config ARM_64
>  	def_bool y
>  	depends on 64BIT
>  	select HAS_GICV3
> +	select HAS_ACPI

Actually ACPI is one of the things that would be nice if users were
actually asked if they want to enable or not.

I would prefer if ACPI had is own separate config entry, with default y,
like SHADOW_PAGING on x86.


>  config ARM
>  	def_bool y
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index ae87557..26a82a7 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -10,8 +10,12 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  
>  #ifndef COMPAT
>  
> -#ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
> -const bool_t efi_enabled = 0;
> +#ifdef CONFIG_ARM
> +/* Currently it doesn't implement runtime services on ARM, but to boot Dom0 with
> + * ACPI it needs to assign efi_enabled with 1 to get acpi_os_get_root_pointer
> + * work.

"Currently runtime services are not implemented on ARM. To boot Dom0
with ACPI, set efi_enabled to 1, so that the guest OS can get the ACPI
root pointer from EFI."


> + */
> +const bool_t efi_enabled = 1;
>  #else
>  # include <asm/i387.h>
>  # include <asm/xstate.h>
> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
> index a26cb1a..98710fe 100644
> --- a/xen/include/asm-arm/config.h
> +++ b/xen/include/asm-arm/config.h
> @@ -36,6 +36,11 @@
>  
>  #define CONFIG_ARM_L1_CACHE_SHIFT 7 /* XXX */
>  
> +#if defined(CONFIG_ARM_64)
> +#define CONFIG_ACPI 1
> +#define CONFIG_ACPI_BOOT 1
> +#endif
> +
>  #define CONFIG_SMP 1
>  
>  #define CONFIG_VIDEO 1
> -- 
> 2.0.4
> 
> 

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

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

* Re: [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-02-29 14:15   ` Stefano Stabellini
@ 2016-02-29 19:06     ` Shannon Zhao
  2016-03-01 15:28       ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-02-29 19:06 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: peter.huangpeng, shannon.zhao, stefano.stabellini, ian.campbell,
	xen-devel



On 2016/2/29 22:15, Stefano Stabellini wrote:
> On Sun, 28 Feb 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Map all other tables to Dom0 using 1:1 mappings.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> > v4: fix commit message
>> > ---
>> >  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 64e48ae..6ad420c 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 other 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(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 0x%"PRIx64
>> > +                   " - 0x%"PRIx64" in domain \n",
>> > +                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
>> > +        }
>> > +    }
>> > +}
> The problem with this function is that it is mapping all other tables to
> the guest, including the unmodified FADT and MADT. This way dom0 is
> going to find two different versions of the FADT and MADT, isn't that
> right?
>  
We've replaced the entries of XSDT table with new value. That means XSDT
points to new table. Guest will not see the old ones.

Thanks,
-- 
Shannon


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

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

* Re: [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables
  2016-02-29 12:13   ` Stefano Stabellini
@ 2016-03-01  2:09     ` Shannon Zhao
  2016-03-01 14:41       ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-03-01  2:09 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Jan Beulich



On 2016/2/29 20:13, Stefano Stabellini wrote:
> On Sun, 28 Feb 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > 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.
>> > 
>> > Cc: Jan Beulich <jbeulich@suse.com>
>> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> > v4: make the length of each table aligned with 64bit
>> > ---
>> >  xen/arch/arm/domain.c       |  4 +++
>> >  xen/arch/arm/domain_build.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-
>> >  xen/common/efi/boot.c       | 20 +++++++++++
>> >  xen/include/asm-arm/setup.h |  2 ++
>> >  4 files changed, 106 insertions(+), 1 deletion(-)
>> > 
>> > 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..b10a69d 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,79 @@ 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)
>> > +{
>> > +    u64 efi_size, acpi_size = 0, addr;
>> > +    u32 madt_size;
>> > +    struct acpi_table_rsdp *rsdp_tbl;
>> > +    struct acpi_table_header *table = NULL;
>> > +
>> > +    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));
>> > +    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
>> > +                               sizeof(struct acpi_table_header));
>> > +    /* 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 = 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. */
>> > +    d->arch.efi_acpi_gpa = kinfo->gnttab_start;
>> > +
>> > +    return 0;
>> > +}
>> > +#else
>> > +static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>> > +{
>> > +    /* Only booting with ACPI will hit here */
>> > +    BUG_ON(1);
>> > +    return -EINVAL;
>> > +}
>> > +#endif
>> >  static void dtb_load(struct kernel_info *kinfo)
>> >  {
>> >      void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr;
>> > @@ -1540,7 +1615,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/common/efi/boot.c b/xen/common/efi/boot.c
>> > index 53c7452..535c685 100644
>> > --- a/xen/common/efi/boot.c
>> > +++ b/xen/common/efi/boot.c
>> > @@ -13,6 +13,7 @@
>> >  #include <xen/multiboot.h>
>> >  #include <xen/pci_regs.h>
>> >  #include <xen/pfn.h>
>> > +#include <asm/acpi.h>
>> >  #if EFI_PAGE_SIZE != PAGE_SIZE
>> >  # error Cannot use xen/pfn.h here!
>> >  #endif
>> > @@ -1171,6 +1172,25 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>> >      for( ; ; ); /* not reached */
>> >  }
>> >  
>> > +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
>> > +/* Constant to indicate "Xen" in unicode u16 format */
>> > +static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};
>> > +
>> > +int __init estimate_efi_size(int mem_nr_banks)
>> > +{
>> > +    int size = 0;
>> > +    int est_size = sizeof(EFI_SYSTEM_TABLE);
>> > +    int ect_size = sizeof(EFI_CONFIGURATION_TABLE);
>> > +    int emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
>> > +    int fw_vendor_size = sizeof(XEN_EFI_FW_VENDOR);
>> > +
>> > +    size += ROUNDUP((est_size + ect_size + fw_vendor_size), 8);
>> > +    size += ROUNDUP(emd_size * (mem_nr_banks + acpi_mem.nr_banks + 1), 8);
>> > +
>> > +    return size;
>> > +}
>> > +#endif
> Given that EFI and ACPI are separate things, I don't think we should
> ifdef CONFIG_ACPI this function. estimate_efi_size should work even if
> no ACPI tables are present, right?
> 
Yes, while we could check acpi_disabled to know whether Xen boots with
ACPI, is there any way to check if Xen boots with UEFI(especially UEFI +
DT)?

Thanks,
-- 
Shannon


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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-02-29 14:36       ` Jan Beulich
  2016-02-29 14:39         ` Stefano Stabellini
@ 2016-03-01  2:35         ` Shannon Zhao
  2016-03-01  9:27           ` Jan Beulich
  1 sibling, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-03-01  2:35 UTC (permalink / raw)
  To: Jan Beulich, Stefano Stabellini
  Cc: xen-devel, stefano.stabellini, peter.huangpeng, shannon.zhao



On 2016/2/29 22:36, Jan Beulich wrote:
>>>> On 29.02.16 at 15:25, <stefano.stabellini@eu.citrix.com> wrote:
>> > On Mon, 29 Feb 2016, Jan Beulich wrote:
>>> >> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
>>> >> here; I don't know who has suggested doing so.
>> >  
>> > It was suggested by Julien.
>> > 
>> > I agree that including ../../../common/xz/crc32.c seems a bit fragile
>> > but introducing another copy of xz_crc32 seems even worse to me (see
>> > http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
>> > better suggestion?
> Well, at some point there was talk of ARM not wanting to
> ExitBootServices() as early as x86 does. In that case there
> would be a CRC32 function among the various boot services
> ones.
> 
At this point, I think it already ExitBootServices() while it's creating
Dom0.

> The other option would be to have a generic crc32() function,
> and maybe make xz use it.
Ok, I'll go for this way.

Thanks,
-- 
Shannon


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

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

* Re: [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor for Dom0
  2016-02-29 14:37   ` Stefano Stabellini
@ 2016-03-01  3:00     ` Shannon Zhao
  2016-03-01 14:57       ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-03-01  3:00 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Jan Beulich



On 2016/2/29 22:37, Stefano Stabellini wrote:
> On Sun, 28 Feb 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Create a few EFI memory descriptors to tell Dom0 the RAM region
>> > information, ACPI table regions and EFI tables reserved resions.
>> > 
>> > Cc: Jan Beulich <jbeulich@suse.com>
>> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> > v4: use a single descriptor for new created tables
>> > ---
>> >  xen/arch/arm/domain_build.c |  2 ++
>> >  xen/common/efi/boot.c       | 38 ++++++++++++++++++++++++++++++++++++++
>> >  xen/include/asm-arm/setup.h |  5 +++++
>> >  3 files changed, 45 insertions(+)
>> > 
>> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> > index 09f9770..1ec6271 100644
>> > --- a/xen/arch/arm/domain_build.c
>> > +++ b/xen/arch/arm/domain_build.c
>> > @@ -1688,6 +1688,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>> >      acpi_map_other_tables(d);
>> >      acpi_create_efi_system_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_table,
>> >                                   tbl_add);
>> > +    acpi_create_efi_mmap_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_len,
>> > +                               d->arch.efi_acpi_table, &kinfo->mem, tbl_add);
>> >  
>> >      return 0;
>> >  }
>> > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
>> > index 238c5fd..b8d7409 100644
>> > --- a/xen/common/efi/boot.c
>> > +++ b/xen/common/efi/boot.c
>> > @@ -1233,6 +1233,44 @@ void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
>> >      tbl_add[TBL_EFIT].start = table_addr;
>> >      tbl_add[TBL_EFIT].size = table_size;
>> >  }
>> > +
>> > +void __init acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
>> > +                                       void *efi_acpi_table,
>> > +                                       const struct meminfo *mem,
>> > +                                       struct membank tbl_add[])
> This function probably belongs to xen/arch/arm/domain_build.c or
> arch/arm/efi
> 
As said before at previous patch set, placing these functions in
common/efi/boot.c is to use the EFI_MEMORY_DESCRIPTOR etc.

See
http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg00097.html

But I agree that it cloud be moved to a new file(e.g. dom0-efi.c) under
arch/arm/efi.

> 
>> > +{
>> > +    EFI_MEMORY_DESCRIPTOR *memory_map;
>> > +    int i, offset;
>> > +    u8 *base_ptr;
>> > +
>> > +    tbl_add[TBL_MMAP].start = paddr + 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);
> I don't like the fact that we are getting the number of memory banks
> from a parameter and the number of acpi banks from a global variable.
> Can we pass in acpi_mem.nr_banks too?
> 
While acpi_mem is defined in efi-boot.h, the caller in domain_build.c of
acpi_create_efi_mmap_table can't access acpi_mem since if we include
efi-boot.h in domain_build.c there are some compiling errors like above.

Thanks,
-- 
Shannon


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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-03-01  2:35         ` Shannon Zhao
@ 2016-03-01  9:27           ` Jan Beulich
  2016-03-01 12:49             ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Jan Beulich @ 2016-03-01  9:27 UTC (permalink / raw)
  To: Stefano Stabellini, Shannon Zhao
  Cc: xen-devel, stefano.stabellini, peter.huangpeng, shannon.zhao

>>> On 01.03.16 at 03:35, <zhaoshenglong@huawei.com> wrote:

> 
> On 2016/2/29 22:36, Jan Beulich wrote:
>>>>> On 29.02.16 at 15:25, <stefano.stabellini@eu.citrix.com> wrote:
>>> > On Mon, 29 Feb 2016, Jan Beulich wrote:
>>>> >> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
>>>> >> here; I don't know who has suggested doing so.
>>> >  
>>> > It was suggested by Julien.
>>> > 
>>> > I agree that including ../../../common/xz/crc32.c seems a bit fragile
>>> > but introducing another copy of xz_crc32 seems even worse to me (see
>>> > http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
>>> > better suggestion?
>> Well, at some point there was talk of ARM not wanting to
>> ExitBootServices() as early as x86 does. In that case there
>> would be a CRC32 function among the various boot services
>> ones.
>> 
> At this point, I think it already ExitBootServices() while it's creating
> Dom0.

I understand that's the case today, hence my saying "at some
point there was talk of ...".

>> The other option would be to have a generic crc32() function,
>> and maybe make xz use it.
> Ok, I'll go for this way.

Well, for the avoidance of doubt: With the code moving into an
ARM specific file, if Stefano is fine with the xz hack, I certainly
won't insist on you adding a separate crc32().

Jan


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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-03-01  9:27           ` Jan Beulich
@ 2016-03-01 12:49             ` Stefano Stabellini
  2016-03-04  3:55               ` Shannon Zhao
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-03-01 12:49 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao, Shannon Zhao

On Tue, 1 Mar 2016, Jan Beulich wrote:
> >>> On 01.03.16 at 03:35, <zhaoshenglong@huawei.com> wrote:
> 
> > 
> > On 2016/2/29 22:36, Jan Beulich wrote:
> >>>>> On 29.02.16 at 15:25, <stefano.stabellini@eu.citrix.com> wrote:
> >>> > On Mon, 29 Feb 2016, Jan Beulich wrote:
> >>>> >> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
> >>>> >> here; I don't know who has suggested doing so.
> >>> >  
> >>> > It was suggested by Julien.
> >>> > 
> >>> > I agree that including ../../../common/xz/crc32.c seems a bit fragile
> >>> > but introducing another copy of xz_crc32 seems even worse to me (see
> >>> > http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
> >>> > better suggestion?
> >> Well, at some point there was talk of ARM not wanting to
> >> ExitBootServices() as early as x86 does. In that case there
> >> would be a CRC32 function among the various boot services
> >> ones.
> >> 
> > At this point, I think it already ExitBootServices() while it's creating
> > Dom0.
> 
> I understand that's the case today, hence my saying "at some
> point there was talk of ...".
> 
> >> The other option would be to have a generic crc32() function,
> >> and maybe make xz use it.
> > Ok, I'll go for this way.
> 
> Well, for the avoidance of doubt: With the code moving into an
> ARM specific file, if Stefano is fine with the xz hack, I certainly
> won't insist on you adding a separate crc32().

Having a generic crc32() function like you suggested would be nicer than
the xz hack. If Shannon is OK with doing that, it would be best.

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

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

* Re: [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables
  2016-03-01  2:09     ` Shannon Zhao
@ 2016-03-01 14:41       ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-03-01 14:41 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao, Jan Beulich

On Tue, 1 Mar 2016, Shannon Zhao wrote:
> On 2016/2/29 20:13, Stefano Stabellini wrote:
> > On Sun, 28 Feb 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > 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.
> >> > 
> >> > Cc: Jan Beulich <jbeulich@suse.com>
> >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> > v4: make the length of each table aligned with 64bit
> >> > ---
> >> >  xen/arch/arm/domain.c       |  4 +++
> >> >  xen/arch/arm/domain_build.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-
> >> >  xen/common/efi/boot.c       | 20 +++++++++++
> >> >  xen/include/asm-arm/setup.h |  2 ++
> >> >  4 files changed, 106 insertions(+), 1 deletion(-)
> >> > 
> >> > 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..b10a69d 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,79 @@ 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)
> >> > +{
> >> > +    u64 efi_size, acpi_size = 0, addr;
> >> > +    u32 madt_size;
> >> > +    struct acpi_table_rsdp *rsdp_tbl;
> >> > +    struct acpi_table_header *table = NULL;
> >> > +
> >> > +    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));
> >> > +    table = acpi_os_map_memory(rsdp_tbl->xsdt_physical_address,
> >> > +                               sizeof(struct acpi_table_header));
> >> > +    /* 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 = 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. */
> >> > +    d->arch.efi_acpi_gpa = kinfo->gnttab_start;
> >> > +
> >> > +    return 0;
> >> > +}
> >> > +#else
> >> > +static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
> >> > +{
> >> > +    /* Only booting with ACPI will hit here */
> >> > +    BUG_ON(1);
> >> > +    return -EINVAL;
> >> > +}
> >> > +#endif
> >> >  static void dtb_load(struct kernel_info *kinfo)
> >> >  {
> >> >      void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr;
> >> > @@ -1540,7 +1615,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/common/efi/boot.c b/xen/common/efi/boot.c
> >> > index 53c7452..535c685 100644
> >> > --- a/xen/common/efi/boot.c
> >> > +++ b/xen/common/efi/boot.c
> >> > @@ -13,6 +13,7 @@
> >> >  #include <xen/multiboot.h>
> >> >  #include <xen/pci_regs.h>
> >> >  #include <xen/pfn.h>
> >> > +#include <asm/acpi.h>
> >> >  #if EFI_PAGE_SIZE != PAGE_SIZE
> >> >  # error Cannot use xen/pfn.h here!
> >> >  #endif
> >> > @@ -1171,6 +1172,25 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
> >> >      for( ; ; ); /* not reached */
> >> >  }
> >> >  
> >> > +#if defined (CONFIG_ACPI) && defined (CONFIG_ARM)
> >> > +/* Constant to indicate "Xen" in unicode u16 format */
> >> > +static const u16 XEN_EFI_FW_VENDOR[] ={0x0058,0x0065,0x006E,0x0000};
> >> > +
> >> > +int __init estimate_efi_size(int mem_nr_banks)
> >> > +{
> >> > +    int size = 0;
> >> > +    int est_size = sizeof(EFI_SYSTEM_TABLE);
> >> > +    int ect_size = sizeof(EFI_CONFIGURATION_TABLE);
> >> > +    int emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
> >> > +    int fw_vendor_size = sizeof(XEN_EFI_FW_VENDOR);
> >> > +
> >> > +    size += ROUNDUP((est_size + ect_size + fw_vendor_size), 8);
> >> > +    size += ROUNDUP(emd_size * (mem_nr_banks + acpi_mem.nr_banks + 1), 8);
> >> > +
> >> > +    return size;
> >> > +}
> >> > +#endif
> > Given that EFI and ACPI are separate things, I don't think we should
> > ifdef CONFIG_ACPI this function. estimate_efi_size should work even if
> > no ACPI tables are present, right?
> > 
> Yes, while we could check acpi_disabled to know whether Xen boots with
> ACPI, is there any way to check if Xen boots with UEFI(especially UEFI +
> DT)?

There is an efi_enabled variable, but that is 0 on ARM because runtime
services are not implemented yet. But it is OK to assume that on ARM if
ACPI is enabled, efi is also enabled.

That said, these are runtime checks, while the problem with the code in
this patch is a compile-time #ifdef.

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

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

* Re: [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor for Dom0
  2016-03-01  3:00     ` Shannon Zhao
@ 2016-03-01 14:57       ` Stefano Stabellini
  2016-03-01 15:07         ` Jan Beulich
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-03-01 14:57 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao, Jan Beulich

On Tue, 1 Mar 2016, Shannon Zhao wrote:
> On 2016/2/29 22:37, Stefano Stabellini wrote:
> > On Sun, 28 Feb 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > Create a few EFI memory descriptors to tell Dom0 the RAM region
> >> > information, ACPI table regions and EFI tables reserved resions.
> >> > 
> >> > Cc: Jan Beulich <jbeulich@suse.com>
> >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> > v4: use a single descriptor for new created tables
> >> > ---
> >> >  xen/arch/arm/domain_build.c |  2 ++
> >> >  xen/common/efi/boot.c       | 38 ++++++++++++++++++++++++++++++++++++++
> >> >  xen/include/asm-arm/setup.h |  5 +++++
> >> >  3 files changed, 45 insertions(+)
> >> > 
> >> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> >> > index 09f9770..1ec6271 100644
> >> > --- a/xen/arch/arm/domain_build.c
> >> > +++ b/xen/arch/arm/domain_build.c
> >> > @@ -1688,6 +1688,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
> >> >      acpi_map_other_tables(d);
> >> >      acpi_create_efi_system_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_table,
> >> >                                   tbl_add);
> >> > +    acpi_create_efi_mmap_table(d->arch.efi_acpi_gpa, d->arch.efi_acpi_len,
> >> > +                               d->arch.efi_acpi_table, &kinfo->mem, tbl_add);
> >> >  
> >> >      return 0;
> >> >  }
> >> > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> >> > index 238c5fd..b8d7409 100644
> >> > --- a/xen/common/efi/boot.c
> >> > +++ b/xen/common/efi/boot.c
> >> > @@ -1233,6 +1233,44 @@ void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
> >> >      tbl_add[TBL_EFIT].start = table_addr;
> >> >      tbl_add[TBL_EFIT].size = table_size;
> >> >  }
> >> > +
> >> > +void __init acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
> >> > +                                       void *efi_acpi_table,
> >> > +                                       const struct meminfo *mem,
> >> > +                                       struct membank tbl_add[])
> > This function probably belongs to xen/arch/arm/domain_build.c or
> > arch/arm/efi
> > 
> As said before at previous patch set, placing these functions in
> common/efi/boot.c is to use the EFI_MEMORY_DESCRIPTOR etc.
> 
> See
> http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg00097.html

Sorry Shannon, I forgot about it.


> But I agree that it cloud be moved to a new file(e.g. dom0-efi.c) under
> arch/arm/efi.

Given the limitations, it would be acceptable to have the function here,
but given that this is about acpi and only useful on ARM, adding the
function to a file under arch/arm/efi would be even better.


> >> > +{
> >> > +    EFI_MEMORY_DESCRIPTOR *memory_map;
> >> > +    int i, offset;
> >> > +    u8 *base_ptr;
> >> > +
> >> > +    tbl_add[TBL_MMAP].start = paddr + 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);
> > I don't like the fact that we are getting the number of memory banks
> > from a parameter and the number of acpi banks from a global variable.
> > Can we pass in acpi_mem.nr_banks too?
> > 
> While acpi_mem is defined in efi-boot.h, the caller in domain_build.c of
> acpi_create_efi_mmap_table can't access acpi_mem since if we include
> efi-boot.h in domain_build.c there are some compiling errors like above.

All right, it is not very nice, but I cannot think of a better way of
doing it right now.

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

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

* Re: [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor for Dom0
  2016-03-01 14:57       ` Stefano Stabellini
@ 2016-03-01 15:07         ` Jan Beulich
  0 siblings, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-03-01 15:07 UTC (permalink / raw)
  To: Stefano Stabellini, Shannon Zhao
  Cc: shannon.zhao, xen-devel, stefano.stabellini, ian.campbell,
	peter.huangpeng

>>> On 01.03.16 at 15:57, <stefano.stabellini@eu.citrix.com> wrote:
> On Tue, 1 Mar 2016, Shannon Zhao wrote:
>> On 2016/2/29 22:37, Stefano Stabellini wrote:
>> > On Sun, 28 Feb 2016, Shannon Zhao wrote:
>> >> > --- a/xen/common/efi/boot.c
>> >> > +++ b/xen/common/efi/boot.c
>> >> > @@ -1233,6 +1233,44 @@ void __init acpi_create_efi_system_table(paddr_t paddr, void *efi_acpi_table,
>> >> >      tbl_add[TBL_EFIT].start = table_addr;
>> >> >      tbl_add[TBL_EFIT].size = table_size;
>> >> >  }
>> >> > +
>> >> > +void __init acpi_create_efi_mmap_table(paddr_t paddr, paddr_t size,
>> >> > +                                       void *efi_acpi_table,
>> >> > +                                       const struct meminfo *mem,
>> >> > +                                       struct membank tbl_add[])
>> > This function probably belongs to xen/arch/arm/domain_build.c or
>> > arch/arm/efi
>> > 
>> As said before at previous patch set, placing these functions in
>> common/efi/boot.c is to use the EFI_MEMORY_DESCRIPTOR etc.
>> 
>> See
>> http://lists.xenproject.org/archives/html/xen-devel/2016-01/msg00097.html 
> 
> Sorry Shannon, I forgot about it.
> 
> 
>> But I agree that it cloud be moved to a new file(e.g. dom0-efi.c) under
>> arch/arm/efi.
> 
> Given the limitations, it would be acceptable to have the function here,

Afaic, having it in xen/common/efi/ is a no-go (we be acceptable
only it we were really just taking of one relatively small function,
but more gets added here by other patches), hence ...

> but given that this is about acpi and only useful on ARM, adding the
> function to a file under arch/arm/efi would be even better.

... this seems the only viable alternative.

Jan


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

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

* Re: [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-02-29 19:06     ` Shannon Zhao
@ 2016-03-01 15:28       ` Stefano Stabellini
  2016-03-01 17:01         ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-03-01 15:28 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: ian.campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao

On Tue, 1 Mar 2016, Shannon Zhao wrote:
> On 2016/2/29 22:15, Stefano Stabellini wrote:
> > On Sun, 28 Feb 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > Map all other tables to Dom0 using 1:1 mappings.
> >> > 
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> > v4: fix commit message
> >> > ---
> >> >  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 64e48ae..6ad420c 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 other 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(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 0x%"PRIx64
> >> > +                   " - 0x%"PRIx64" in domain \n",
> >> > +                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
> >> > +        }
> >> > +    }
> >> > +}
> > The problem with this function is that it is mapping all other tables to
> > the guest, including the unmodified FADT and MADT. This way dom0 is
> > going to find two different versions of the FADT and MADT, isn't that
> > right?
> >  
> We've replaced the entries of XSDT table with new value. That means XSDT
> points to new table. Guest will not see the old ones.

All right. Of course it would be best to avoid mapping the original FADT
and MADT at all, but given that they are not likely to be page aligned,
it wouldn't be easy to do.

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

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

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

* Re: [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-03-01 15:28       ` Stefano Stabellini
@ 2016-03-01 17:01         ` Stefano Stabellini
  2016-03-02 12:43           ` Shannon Zhao
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-03-01 17:01 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Shannon Zhao

On Tue, 1 Mar 2016, Stefano Stabellini wrote:
> On Tue, 1 Mar 2016, Shannon Zhao wrote:
> > On 2016/2/29 22:15, Stefano Stabellini wrote:
> > > On Sun, 28 Feb 2016, Shannon Zhao wrote:
> > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> > >> > 
> > >> > Map all other tables to Dom0 using 1:1 mappings.
> > >> > 
> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > >> > ---
> > >> > v4: fix commit message
> > >> > ---
> > >> >  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 64e48ae..6ad420c 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 other 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(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 0x%"PRIx64
> > >> > +                   " - 0x%"PRIx64" in domain \n",
> > >> > +                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
> > >> > +        }
> > >> > +    }
> > >> > +}
> > > The problem with this function is that it is mapping all other tables to
> > > the guest, including the unmodified FADT and MADT. This way dom0 is
> > > going to find two different versions of the FADT and MADT, isn't that
> > > right?
> > >  
> > We've replaced the entries of XSDT table with new value. That means XSDT
> > points to new table. Guest will not see the old ones.
> 
> All right. Of course it would be best to avoid mapping the original FADT
> and MADT at all, but given that they are not likely to be page aligned,
> it wouldn't be easy to do.
> 
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

However I have one more question: given that map_regions maps the memory
read-only to Dom0, isn't it possible that one or more of the DSDT
functions could not work as expected? I would imagine that the ACPI
bytecode is allowed to change its own memory, right?

Note that I am not suggesting to change map_regions to map memory
read-write, because that would be undesirable from a security
perspective.

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

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

* Re: [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-03-01 17:01         ` Stefano Stabellini
@ 2016-03-02 12:43           ` Shannon Zhao
  2016-03-02 15:00             ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-03-02 12:43 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: peter.huangpeng, xen-devel, stefano.stabellini, ian.campbell,
	Shannon Zhao

On 2016年03月02日 01:01, Stefano Stabellini wrote:
> On Tue, 1 Mar 2016, Stefano Stabellini wrote:
>> > On Tue, 1 Mar 2016, Shannon Zhao wrote:
>>> > > On 2016/2/29 22:15, Stefano Stabellini wrote:
>>>> > > > On Sun, 28 Feb 2016, Shannon Zhao wrote:
>>>>>> > > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>> > > >> > 
>>>>>> > > >> > Map all other tables to Dom0 using 1:1 mappings.
>>>>>> > > >> > 
>>>>>> > > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>> > > >> > ---
>>>>>> > > >> > v4: fix commit message
>>>>>> > > >> > ---
>>>>>> > > >> >  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 64e48ae..6ad420c 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 other 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(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 0x%"PRIx64
>>>>>> > > >> > +                   " - 0x%"PRIx64" in domain \n",
>>>>>> > > >> > +                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
>>>>>> > > >> > +        }
>>>>>> > > >> > +    }
>>>>>> > > >> > +}
>>>> > > > The problem with this function is that it is mapping all other tables to
>>>> > > > the guest, including the unmodified FADT and MADT. This way dom0 is
>>>> > > > going to find two different versions of the FADT and MADT, isn't that
>>>> > > > right?
>>>> > > >  
>>> > > We've replaced the entries of XSDT table with new value. That means XSDT
>>> > > points to new table. Guest will not see the old ones.
>> > 
>> > All right. Of course it would be best to avoid mapping the original FADT
>> > and MADT at all, but given that they are not likely to be page aligned,
>> > it wouldn't be easy to do.
>> > 
>> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> However I have one more question: given that map_regions maps the memory
> read-only to Dom0, isn't it possible that one or more of the DSDT
> functions could not work as expected? I would imagine that the ACPI
> bytecode is allowed to change its own memory, right?
> 
I'm not sure about this. But it seems that Xen or Linux always map these
tables to its memory.

Thanks,
--
Shannon

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

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

* Re: [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-03-02 12:43           ` Shannon Zhao
@ 2016-03-02 15:00             ` Stefano Stabellini
  2016-03-02 16:00               ` Jan Beulich
  0 siblings, 1 reply; 73+ messages in thread
From: Stefano Stabellini @ 2016-03-02 15:00 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: Ian Campbell, Stefano Stabellini, peter.huangpeng, xen-devel,
	stefano.stabellini, Shannon Zhao, Roger Pau Monne

[-- Attachment #1: Type: text/plain, Size: 4121 bytes --]

On Wed, 2 Mar 2016, Shannon Zhao wrote:
> On 2016年03月02日 01:01, Stefano Stabellini wrote:
> > On Tue, 1 Mar 2016, Stefano Stabellini wrote:
> >> > On Tue, 1 Mar 2016, Shannon Zhao wrote:
> >>> > > On 2016/2/29 22:15, Stefano Stabellini wrote:
> >>>> > > > On Sun, 28 Feb 2016, Shannon Zhao wrote:
> >>>>>> > > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>>> > > >> > 
> >>>>>> > > >> > Map all other tables to Dom0 using 1:1 mappings.
> >>>>>> > > >> > 
> >>>>>> > > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >>>>>> > > >> > ---
> >>>>>> > > >> > v4: fix commit message
> >>>>>> > > >> > ---
> >>>>>> > > >> >  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 64e48ae..6ad420c 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 other 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(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 0x%"PRIx64
> >>>>>> > > >> > +                   " - 0x%"PRIx64" in domain \n",
> >>>>>> > > >> > +                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
> >>>>>> > > >> > +        }
> >>>>>> > > >> > +    }
> >>>>>> > > >> > +}
> >>>> > > > The problem with this function is that it is mapping all other tables to
> >>>> > > > the guest, including the unmodified FADT and MADT. This way dom0 is
> >>>> > > > going to find two different versions of the FADT and MADT, isn't that
> >>>> > > > right?
> >>>> > > >  
> >>> > > We've replaced the entries of XSDT table with new value. That means XSDT
> >>> > > points to new table. Guest will not see the old ones.
> >> > 
> >> > All right. Of course it would be best to avoid mapping the original FADT
> >> > and MADT at all, but given that they are not likely to be page aligned,
> >> > it wouldn't be easy to do.
> >> > 
> >> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> >
> > However I have one more question: given that map_regions maps the memory
> > read-only to Dom0, isn't it possible that one or more of the DSDT
> > functions could not work as expected? I would imagine that the ACPI
> > bytecode is allowed to change its own memory, right?
> > 
> I'm not sure about this. But it seems that Xen or Linux always map these
> tables to its memory.

It's not mapping pages in general the problem. The potential issue comes
from the pages being mapped read-only. If an AML function in the DSDT
needs to write something to memory, I imagine that the function would
fail when called from Dom0.

I think we need to map them read-write, which is safe, even for the
original FADT and MADT, because by the time Dom0 gets to see them, Xen
won't parse them anymore (Xen completes parsing ACPI tables, before
booting Dom0).

So this patch is fine, but
http://marc.info/?l=xen-devel&m=145665887528175 needs to be changed to
use p2m_access_rw instead of p2m_access_r.

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

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

* Re: [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0
  2016-03-02 15:00             ` Stefano Stabellini
@ 2016-03-02 16:00               ` Jan Beulich
  0 siblings, 0 replies; 73+ messages in thread
From: Jan Beulich @ 2016-03-02 16:00 UTC (permalink / raw)
  To: Stefano Stabellini, Shannon Zhao
  Cc: Ian Campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	Shannon Zhao, Roger Pau Monne

>>> On 02.03.16 at 16:00, <stefano.stabellini@eu.citrix.com> wrote:
> On Wed, 2 Mar 2016, Shannon Zhao wrote:
>> On 2016年03月02日 01:01, Stefano Stabellini wrote:
>> > On Tue, 1 Mar 2016, Stefano Stabellini wrote:
>> >> > On Tue, 1 Mar 2016, Shannon Zhao wrote:
>> >>> > > On 2016/2/29 22:15, Stefano Stabellini wrote:
>> >>>> > > > On Sun, 28 Feb 2016, Shannon Zhao wrote:
>> >>>>>> > > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> >>>>>> > > >> > 
>> >>>>>> > > >> > Map all other tables to Dom0 using 1:1 mappings.
>> >>>>>> > > >> > 
>> >>>>>> > > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> >>>>>> > > >> > ---
>> >>>>>> > > >> > v4: fix commit message
>> >>>>>> > > >> > ---
>> >>>>>> > > >> >  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 64e48ae..6ad420c 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 other 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(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 0x%"PRIx64
>> >>>>>> > > >> > +                   " - 0x%"PRIx64" in domain \n",
>> >>>>>> > > >> > +                   addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1);
>> >>>>>> > > >> > +        }
>> >>>>>> > > >> > +    }
>> >>>>>> > > >> > +}
>> >>>> > > > The problem with this function is that it is mapping all other tables to
>> >>>> > > > the guest, including the unmodified FADT and MADT. This way dom0 is
>> >>>> > > > going to find two different versions of the FADT and MADT, isn't that
>> >>>> > > > right?
>> >>>> > > >  
>> >>> > > We've replaced the entries of XSDT table with new value. That means XSDT
>> >>> > > points to new table. Guest will not see the old ones.
>> >> > 
>> >> > All right. Of course it would be best to avoid mapping the original FADT
>> >> > and MADT at all, but given that they are not likely to be page aligned,
>> >> > it wouldn't be easy to do.
>> >> > 
>> >> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>> >
>> > However I have one more question: given that map_regions maps the memory
>> > read-only to Dom0, isn't it possible that one or more of the DSDT
>> > functions could not work as expected? I would imagine that the ACPI
>> > bytecode is allowed to change its own memory, right?
>> > 
>> I'm not sure about this. But it seems that Xen or Linux always map these
>> tables to its memory.
> 
> It's not mapping pages in general the problem. The potential issue comes
> from the pages being mapped read-only. If an AML function in the DSDT
> needs to write something to memory, I imagine that the function would
> fail when called from Dom0.
> 
> I think we need to map them read-write, which is safe, even for the
> original FADT and MADT, because by the time Dom0 gets to see them, Xen
> won't parse them anymore (Xen completes parsing ACPI tables, before
> booting Dom0).
> 
> So this patch is fine, but
> http://marc.info/?l=xen-devel&m=145665887528175 needs to be changed to
> use p2m_access_rw instead of p2m_access_r.

Yes, I agree, r/w mappings ought to be fine here as long as only
Dom0 gets them.

Jan

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

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

* Re: [PATCH v4 17/24] arm/acpi: Create min DT stub for Dom0
  2016-02-29 15:05   ` Stefano Stabellini
@ 2016-03-03 12:31     ` Shannon Zhao
  0 siblings, 0 replies; 73+ messages in thread
From: Shannon Zhao @ 2016-03-03 12:31 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: ian.campbell, peter.huangpeng, xen-devel, stefano.stabellini,
	shannon.zhao, Jan Beulich



On 2016/2/29 23:05, Stefano Stabellini wrote:
>> +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 = arm_acpi_make_efi_nodes(fdt, tbl_add);
>> > +    if ( res )
>> > +        return res;
>> > +
>> > +    res = fdt_end_node(fdt);
>> > +
>> > +    return res;
>> > +}
> Please refactor the existing make_hypervisor_node into a shared function
> and use that instead.
> 
Not sure this works since the parameters of them are different and it
will add a uefi node under hypervisor node in new function.

-- 
Shannon


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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-03-01 12:49             ` Stefano Stabellini
@ 2016-03-04  3:55               ` Shannon Zhao
  2016-03-04 10:46                 ` Stefano Stabellini
  0 siblings, 1 reply; 73+ messages in thread
From: Shannon Zhao @ 2016-03-04  3:55 UTC (permalink / raw)
  To: Stefano Stabellini, Jan Beulich
  Cc: stefano.stabellini, shannon.zhao, xen-devel



On 2016/3/1 20:49, Stefano Stabellini wrote:
> On Tue, 1 Mar 2016, Jan Beulich wrote:
>>>>> > >>> On 01.03.16 at 03:35, <zhaoshenglong@huawei.com> wrote:
>> > 
>>> > > 
>>> > > On 2016/2/29 22:36, Jan Beulich wrote:
>>>>>>> > >>>>> On 29.02.16 at 15:25, <stefano.stabellini@eu.citrix.com> wrote:
>>>>>> > >>> > On Mon, 29 Feb 2016, Jan Beulich wrote:
>>>>>>>> > >>>> >> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
>>>>>>>> > >>>> >> here; I don't know who has suggested doing so.
>>>>>> > >>> >  
>>>>>> > >>> > It was suggested by Julien.
>>>>>> > >>> > 
>>>>>> > >>> > I agree that including ../../../common/xz/crc32.c seems a bit fragile
>>>>>> > >>> > but introducing another copy of xz_crc32 seems even worse to me (see
>>>>>> > >>> > http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
>>>>>> > >>> > better suggestion?
>>>> > >> Well, at some point there was talk of ARM not wanting to
>>>> > >> ExitBootServices() as early as x86 does. In that case there
>>>> > >> would be a CRC32 function among the various boot services
>>>> > >> ones.
>>>> > >> 
>>> > > At this point, I think it already ExitBootServices() while it's creating
>>> > > Dom0.
>> > 
>> > I understand that's the case today, hence my saying "at some
>> > point there was talk of ...".
>> > 
>>>> > >> The other option would be to have a generic crc32() function,
>>>> > >> and maybe make xz use it.
>>> > > Ok, I'll go for this way.
>> > 
>> > Well, for the avoidance of doubt: With the code moving into an
>> > ARM specific file, if Stefano is fine with the xz hack, I certainly
>> > won't insist on you adding a separate crc32().
> Having a generic crc32() function like you suggested would be nicer than
> the xz hack. If Shannon is OK with doing that, it would be best.
Since this will introduce more changes, I want to stay with current way.

Thanks,
-- 
Shannon


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

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

* Re: [PATCH v4 14/24] arm/acpi: Prepare EFI system table for Dom0
  2016-03-04  3:55               ` Shannon Zhao
@ 2016-03-04 10:46                 ` Stefano Stabellini
  0 siblings, 0 replies; 73+ messages in thread
From: Stefano Stabellini @ 2016-03-04 10:46 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: xen-devel, stefano.stabellini, shannon.zhao, Jan Beulich,
	Stefano Stabellini

On Fri, 4 Mar 2016, Shannon Zhao wrote:
> On 2016/3/1 20:49, Stefano Stabellini wrote:
> > On Tue, 1 Mar 2016, Jan Beulich wrote:
> >>>>> > >>> On 01.03.16 at 03:35, <zhaoshenglong@huawei.com> wrote:
> >> > 
> >>> > > 
> >>> > > On 2016/2/29 22:36, Jan Beulich wrote:
> >>>>>>> > >>>>> On 29.02.16 at 15:25, <stefano.stabellini@eu.citrix.com> wrote:
> >>>>>> > >>> > On Mon, 29 Feb 2016, Jan Beulich wrote:
> >>>>>>>> > >>>> >> Also it doesn't look very nice to me to (ab)use xz's CRC32 code
> >>>>>>>> > >>>> >> here; I don't know who has suggested doing so.
> >>>>>> > >>> >  
> >>>>>> > >>> > It was suggested by Julien.
> >>>>>> > >>> > 
> >>>>>> > >>> > I agree that including ../../../common/xz/crc32.c seems a bit fragile
> >>>>>> > >>> > but introducing another copy of xz_crc32 seems even worse to me (see
> >>>>>> > >>> > http://marc.info/?l=xen-devel&m=144775375427921&w=2). Maybe you have a
> >>>>>> > >>> > better suggestion?
> >>>> > >> Well, at some point there was talk of ARM not wanting to
> >>>> > >> ExitBootServices() as early as x86 does. In that case there
> >>>> > >> would be a CRC32 function among the various boot services
> >>>> > >> ones.
> >>>> > >> 
> >>> > > At this point, I think it already ExitBootServices() while it's creating
> >>> > > Dom0.
> >> > 
> >> > I understand that's the case today, hence my saying "at some
> >> > point there was talk of ...".
> >> > 
> >>>> > >> The other option would be to have a generic crc32() function,
> >>>> > >> and maybe make xz use it.
> >>> > > Ok, I'll go for this way.
> >> > 
> >> > Well, for the avoidance of doubt: With the code moving into an
> >> > ARM specific file, if Stefano is fine with the xz hack, I certainly
> >> > won't insist on you adding a separate crc32().
> > Having a generic crc32() function like you suggested would be nicer than
> > the xz hack. If Shannon is OK with doing that, it would be best.
> Since this will introduce more changes, I want to stay with current way.
 
OK

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

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

end of thread, other threads:[~2016-03-04 10:46 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-28 11:18 [PATCH v4 00/24] Prepare UEFI and ACPI tables for Dom0 on ARM64 Shannon Zhao
2016-02-28 11:18 ` [PATCH v4 01/24] arm/acpi: Define a enum for reserved tables Shannon Zhao
2016-02-29 14:02   ` Stefano Stabellini
2016-02-29 15:16   ` Jan Beulich
2016-02-28 11:18 ` [PATCH v4 02/24] arm/acpi: Add placeholder for efi and acpi load address Shannon Zhao
2016-02-29 14:01   ` Stefano Stabellini
2016-02-28 11:18 ` [PATCH v4 03/24] arm/acpi: Read acpi memory info from uefi Shannon Zhao
2016-02-29 14:57   ` Jan Beulich
2016-02-29 15:07     ` Stefano Stabellini
2016-02-29 15:20       ` Jan Beulich
2016-02-28 11:19 ` [PATCH v4 04/24] arm/acpi: Estimate memory required for acpi/efi tables Shannon Zhao
2016-02-29 11:11   ` Jan Beulich
2016-02-29 12:13   ` Stefano Stabellini
2016-03-01  2:09     ` Shannon Zhao
2016-03-01 14:41       ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 05/24] arm/acpi: Add a helper function to get the acpi table offset Shannon Zhao
2016-02-29 12:17   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 06/24] arm/acpi: Prepare FADT table for Dom0 Shannon Zhao
2016-02-29 12:22   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 07/24] arm/gic: Add a new callback for creating MADT " Shannon Zhao
2016-02-29 12:50   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 08/24] arm/acpi: Prepare " Shannon Zhao
2016-02-29 12:52   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 09/24] arm/acpi: Prepare STAO " Shannon Zhao
2016-02-29 14:07   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 10/24] arm/acpi: Prepare XSDT " Shannon Zhao
2016-02-28 11:19 ` [PATCH v4 11/24] arm/acpi: Prepare RSDP " Shannon Zhao
2016-02-28 11:19 ` [PATCH v4 12/24] arm/p2m: Add helper functions to map memory regions Shannon Zhao
2016-02-29 14:11   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 13/24] arm/acpi: Map all other tables for Dom0 Shannon Zhao
2016-02-29 14:15   ` Stefano Stabellini
2016-02-29 19:06     ` Shannon Zhao
2016-03-01 15:28       ` Stefano Stabellini
2016-03-01 17:01         ` Stefano Stabellini
2016-03-02 12:43           ` Shannon Zhao
2016-03-02 15:00             ` Stefano Stabellini
2016-03-02 16:00               ` Jan Beulich
2016-02-28 11:19 ` [PATCH v4 14/24] arm/acpi: Prepare EFI system table " Shannon Zhao
2016-02-29 11:19   ` Jan Beulich
2016-02-29 14:25     ` Stefano Stabellini
2016-02-29 14:36       ` Jan Beulich
2016-02-29 14:39         ` Stefano Stabellini
2016-03-01  2:35         ` Shannon Zhao
2016-03-01  9:27           ` Jan Beulich
2016-03-01 12:49             ` Stefano Stabellini
2016-03-04  3:55               ` Shannon Zhao
2016-03-04 10:46                 ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 15/24] arm/acpi: Prepare EFI memory descriptor " Shannon Zhao
2016-02-29 14:37   ` Stefano Stabellini
2016-03-01  3:00     ` Shannon Zhao
2016-03-01 14:57       ` Stefano Stabellini
2016-03-01 15:07         ` Jan Beulich
2016-02-28 11:19 ` [PATCH v4 16/24] arm/acpi: Map the new created EFI and ACPI tables to Dom0 Shannon Zhao
2016-02-29 14:42   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 17/24] arm/acpi: Create min DT stub for Dom0 Shannon Zhao
2016-02-29 15:05   ` Stefano Stabellini
2016-03-03 12:31     ` Shannon Zhao
2016-02-28 11:19 ` [PATCH v4 18/24] arm/acpi: Permit access all Xen unused SPIs " Shannon Zhao
2016-02-29 15:13   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 19/24] arm/acpi: Configure SPI interrupt type and route to Dom0 dynamically Shannon Zhao
2016-02-29 16:58   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 20/24] arm/acpi: Permit MMIO access of Xen unused devices for Dom0 Shannon Zhao
2016-02-29 17:02   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 21/24] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
2016-02-29 11:23   ` Jan Beulich
2016-02-29 17:04   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 22/24] xen/acpi: Fix event-channel interrupt when booting with ACPI Shannon Zhao
2016-02-29 17:08   ` Stefano Stabellini
2016-02-28 11:19 ` [PATCH v4 23/24] xen/arm: Add a hypercall for device mmio mapping Shannon Zhao
2016-02-29 11:32   ` Jan Beulich
2016-02-28 11:19 ` [PATCH v4 24/24] xen/arm64: Add ACPI support Shannon Zhao
2016-02-29 11:34   ` Jan Beulich
2016-02-29 17:15   ` Stefano Stabellini

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).